From: Matt Corallo Date: Tue, 3 Sep 2024 18:54:15 +0000 (+0000) Subject: Update auto-generated bindings to LDK 0.0.124 X-Git-Tag: v0.0.124.0^2 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=f5149130995f5bf71f19b9d4c6bf82f1a5592e8e;p=ldk-c-bindings Update auto-generated bindings to LDK 0.0.124 --- diff --git a/lightning-c-bindings/include/ldk_rust_types.h b/lightning-c-bindings/include/ldk_rust_types.h index e37879c..bbc7ca0 100644 --- a/lightning-c-bindings/include/ldk_rust_types.h +++ b/lightning-c-bindings/include/ldk_rust_types.h @@ -24,8 +24,6 @@ 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; @@ -63,10 +61,6 @@ struct nativeRouteParametersOpaque; typedef struct nativeRouteParametersOpaque LDKnativeRouteParameters; struct nativePaymentParametersOpaque; typedef struct nativePaymentParametersOpaque LDKnativePaymentParameters; -struct nativeRouteHintOpaque; -typedef struct nativeRouteHintOpaque LDKnativeRouteHint; -struct nativeRouteHintHopOpaque; -typedef struct nativeRouteHintHopOpaque LDKnativeRouteHintHop; struct nativeFirstHopCandidateOpaque; typedef struct nativeFirstHopCandidateOpaque LDKnativeFirstHopCandidate; struct nativePublicHopCandidateOpaque; @@ -77,6 +71,10 @@ struct nativeBlindedPathCandidateOpaque; typedef struct nativeBlindedPathCandidateOpaque LDKnativeBlindedPathCandidate; struct nativeOneHopBlindedPathCandidateOpaque; typedef struct nativeOneHopBlindedPathCandidateOpaque LDKnativeOneHopBlindedPathCandidate; +struct nativeUntrustedStringOpaque; +typedef struct nativeUntrustedStringOpaque LDKnativeUntrustedString; +struct nativePrintableStringOpaque; +typedef struct nativePrintableStringOpaque LDKnativePrintableString; struct nativeMultiThreadedLockableScoreOpaque; typedef struct nativeMultiThreadedLockableScoreOpaque LDKnativeMultiThreadedLockableScore; struct nativeMultiThreadedScoreLockReadOpaque; @@ -97,24 +95,6 @@ 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 nativeBolt11InvoiceFeaturesOpaque; -typedef struct nativeBolt11InvoiceFeaturesOpaque LDKnativeBolt11InvoiceFeatures; -struct nativeOfferFeaturesOpaque; -typedef struct nativeOfferFeaturesOpaque LDKnativeOfferFeatures; -struct nativeInvoiceRequestFeaturesOpaque; -typedef struct nativeInvoiceRequestFeaturesOpaque LDKnativeInvoiceRequestFeatures; -struct nativeBolt12InvoiceFeaturesOpaque; -typedef struct nativeBolt12InvoiceFeaturesOpaque LDKnativeBolt12InvoiceFeatures; -struct nativeBlindedHopFeaturesOpaque; -typedef struct nativeBlindedHopFeaturesOpaque LDKnativeBlindedHopFeatures; -struct nativeChannelTypeFeaturesOpaque; -typedef struct nativeChannelTypeFeaturesOpaque LDKnativeChannelTypeFeatures; struct nativeOfferIdOpaque; typedef struct nativeOfferIdOpaque LDKnativeOfferId; struct nativeOfferWithExplicitMetadataBuilderOpaque; @@ -137,10 +117,8 @@ struct nativeChannelInfoOpaque; typedef struct nativeChannelInfoOpaque LDKnativeChannelInfo; struct nativeDirectedChannelInfoOpaque; typedef struct nativeDirectedChannelInfoOpaque LDKnativeDirectedChannelInfo; -struct nativeRoutingFeesOpaque; -typedef struct nativeRoutingFeesOpaque LDKnativeRoutingFees; -struct nativeNodeAnnouncementInfoOpaque; -typedef struct nativeNodeAnnouncementInfoOpaque LDKnativeNodeAnnouncementInfo; +struct nativeNodeAnnouncementDetailsOpaque; +typedef struct nativeNodeAnnouncementDetailsOpaque LDKnativeNodeAnnouncementDetails; struct nativeNodeAliasOpaque; typedef struct nativeNodeAliasOpaque LDKnativeNodeAlias; struct nativeNodeInfoOpaque; @@ -231,6 +209,8 @@ struct nativePongOpaque; typedef struct nativePongOpaque LDKnativePong; struct nativeCommonOpenChannelFieldsOpaque; typedef struct nativeCommonOpenChannelFieldsOpaque LDKnativeCommonOpenChannelFields; +struct nativeChannelParametersOpaque; +typedef struct nativeChannelParametersOpaque LDKnativeChannelParameters; struct nativeOpenChannelOpaque; typedef struct nativeOpenChannelOpaque LDKnativeOpenChannel; struct nativeOpenChannelV2Opaque; @@ -249,8 +229,8 @@ struct nativeChannelReadyOpaque; typedef struct nativeChannelReadyOpaque LDKnativeChannelReady; struct nativeStfuOpaque; typedef struct nativeStfuOpaque LDKnativeStfu; -struct nativeSpliceOpaque; -typedef struct nativeSpliceOpaque LDKnativeSplice; +struct nativeSpliceInitOpaque; +typedef struct nativeSpliceInitOpaque LDKnativeSpliceInit; struct nativeSpliceAckOpaque; typedef struct nativeSpliceAckOpaque LDKnativeSpliceAck; struct nativeSpliceLockedOpaque; @@ -289,6 +269,8 @@ struct nativeUpdateFailHTLCOpaque; typedef struct nativeUpdateFailHTLCOpaque LDKnativeUpdateFailHTLC; struct nativeUpdateFailMalformedHTLCOpaque; typedef struct nativeUpdateFailMalformedHTLCOpaque LDKnativeUpdateFailMalformedHTLC; +struct nativeCommitmentSignedBatchOpaque; +typedef struct nativeCommitmentSignedBatchOpaque LDKnativeCommitmentSignedBatch; struct nativeCommitmentSignedOpaque; typedef struct nativeCommitmentSignedOpaque LDKnativeCommitmentSigned; struct nativeRevokeAndACKOpaque; @@ -347,6 +329,10 @@ struct nativeFutureOpaque; typedef struct nativeFutureOpaque LDKnativeFuture; struct nativeSleeperOpaque; typedef struct nativeSleeperOpaque LDKnativeSleeper; +struct nativeHeldHtlcAvailableOpaque; +typedef struct nativeHeldHtlcAvailableOpaque LDKnativeHeldHtlcAvailable; +struct nativeReleaseHeldHtlcOpaque; +typedef struct nativeReleaseHeldHtlcOpaque LDKnativeReleaseHeldHtlc; struct nativeCounterpartyCommitmentSecretsOpaque; typedef struct nativeCounterpartyCommitmentSecretsOpaque LDKnativeCounterpartyCommitmentSecrets; struct nativeTxCreationKeysOpaque; @@ -383,6 +369,16 @@ struct nativePacketOpaque; typedef struct nativePacketOpaque LDKnativePacket; struct nativeClaimedHTLCOpaque; typedef struct nativeClaimedHTLCOpaque LDKnativeClaimedHTLC; +struct nativeReplayEventOpaque; +typedef struct nativeReplayEventOpaque LDKnativeReplayEvent; +struct nativeNonceOpaque; +typedef struct nativeNonceOpaque LDKnativeNonce; +struct nativeRoutingFeesOpaque; +typedef struct nativeRoutingFeesOpaque LDKnativeRoutingFees; +struct nativeRouteHintOpaque; +typedef struct nativeRouteHintOpaque LDKnativeRouteHint; +struct nativeRouteHintHopOpaque; +typedef struct nativeRouteHintHopOpaque LDKnativeRouteHintHop; struct nativeBolt11InvoiceOpaque; typedef struct nativeBolt11InvoiceOpaque LDKnativeBolt11Invoice; struct nativeSignedRawBolt11InvoiceOpaque; @@ -415,14 +411,14 @@ 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 nativeChannelIdOpaque; typedef struct nativeChannelIdOpaque LDKnativeChannelId; -struct nativeForwardNodeOpaque; -typedef struct nativeForwardNodeOpaque LDKnativeForwardNode; +struct nativeBlindedPayInfoOpaque; +typedef struct nativeBlindedPayInfoOpaque LDKnativeBlindedPayInfo; +struct nativeBlindedPaymentPathOpaque; +typedef struct nativeBlindedPaymentPathOpaque LDKnativeBlindedPaymentPath; +struct nativePaymentForwardNodeOpaque; +typedef struct nativePaymentForwardNodeOpaque LDKnativePaymentForwardNode; struct nativeForwardTlvsOpaque; typedef struct nativeForwardTlvsOpaque LDKnativeForwardTlvs; struct nativeReceiveTlvsOpaque; @@ -441,14 +437,34 @@ struct nativeUtxoFutureOpaque; typedef struct nativeUtxoFutureOpaque LDKnativeUtxoFuture; struct nativeOnionMessengerOpaque; typedef struct nativeOnionMessengerOpaque LDKnativeOnionMessenger; +struct nativeResponderOpaque; +typedef struct nativeResponderOpaque LDKnativeResponder; +struct nativeResponseInstructionOpaque; +typedef struct nativeResponseInstructionOpaque LDKnativeResponseInstruction; struct nativeDefaultMessageRouterOpaque; typedef struct nativeDefaultMessageRouterOpaque LDKnativeDefaultMessageRouter; struct nativeOnionMessagePathOpaque; typedef struct nativeOnionMessagePathOpaque LDKnativeOnionMessagePath; struct nativeFilesystemStoreOpaque; typedef struct nativeFilesystemStoreOpaque LDKnativeFilesystemStore; -struct nativeBlindedPathOpaque; -typedef struct nativeBlindedPathOpaque LDKnativeBlindedPath; +struct nativeInitFeaturesOpaque; +typedef struct nativeInitFeaturesOpaque LDKnativeInitFeatures; +struct nativeNodeFeaturesOpaque; +typedef struct nativeNodeFeaturesOpaque LDKnativeNodeFeatures; +struct nativeChannelFeaturesOpaque; +typedef struct nativeChannelFeaturesOpaque LDKnativeChannelFeatures; +struct nativeBolt11InvoiceFeaturesOpaque; +typedef struct nativeBolt11InvoiceFeaturesOpaque LDKnativeBolt11InvoiceFeatures; +struct nativeOfferFeaturesOpaque; +typedef struct nativeOfferFeaturesOpaque LDKnativeOfferFeatures; +struct nativeInvoiceRequestFeaturesOpaque; +typedef struct nativeInvoiceRequestFeaturesOpaque LDKnativeInvoiceRequestFeatures; +struct nativeBolt12InvoiceFeaturesOpaque; +typedef struct nativeBolt12InvoiceFeaturesOpaque LDKnativeBolt12InvoiceFeatures; +struct nativeBlindedHopFeaturesOpaque; +typedef struct nativeBlindedHopFeaturesOpaque LDKnativeBlindedHopFeatures; +struct nativeChannelTypeFeaturesOpaque; +typedef struct nativeChannelTypeFeaturesOpaque LDKnativeChannelTypeFeatures; struct nativeEmptyNodeIdLookUpOpaque; typedef struct nativeEmptyNodeIdLookUpOpaque LDKnativeEmptyNodeIdLookUp; struct nativeBlindedHopOpaque; @@ -473,9 +489,11 @@ struct nativeRevocationBasepointOpaque; typedef struct nativeRevocationBasepointOpaque LDKnativeRevocationBasepoint; struct nativeRevocationKeyOpaque; typedef struct nativeRevocationKeyOpaque LDKnativeRevocationKey; -struct nativeMonitorUpdateIdOpaque; -typedef struct nativeMonitorUpdateIdOpaque LDKnativeMonitorUpdateId; struct nativeLockedChannelMonitorOpaque; typedef struct nativeLockedChannelMonitorOpaque LDKnativeLockedChannelMonitor; struct nativeChainMonitorOpaque; typedef struct nativeChainMonitorOpaque LDKnativeChainMonitor; +struct nativeBlindedMessagePathOpaque; +typedef struct nativeBlindedMessagePathOpaque LDKnativeBlindedMessagePath; +struct nativeMessageForwardNodeOpaque; +typedef struct nativeMessageForwardNodeOpaque LDKnativeMessageForwardNode; diff --git a/lightning-c-bindings/include/lightning.h b/lightning-c-bindings/include/lightning.h index fad8366..9076f1a 100644 --- a/lightning-c-bindings/include/lightning.h +++ b/lightning-c-bindings/include/lightning.h @@ -10,6 +10,33 @@ #include #include "ldk_rust_types.h" +/** + * Indicates whether the balance is derived from a cooperative close, a force-close + * (for holder or counterparty), or whether it is for an HTLC. + */ +typedef enum LDKBalanceSource { + /** + * The channel was force closed by the holder. + */ + LDKBalanceSource_HolderForceClosed, + /** + * The channel was force closed by the counterparty. + */ + LDKBalanceSource_CounterpartyForceClosed, + /** + * The channel was cooperatively closed. + */ + LDKBalanceSource_CoopClose, + /** + * This balance is the result of an HTLC. + */ + LDKBalanceSource_Htlc, + /** + * Must be last for serialization purposes + */ + LDKBalanceSource_Sentinel, +} LDKBalanceSource; + /** * Whether this blinded HTLC is being failed backwards by the introduction node or a blinded node, * which determines the failure message that should be used. @@ -195,6 +222,10 @@ typedef enum LDKBolt12SemanticError { * An invoice payment hash was expected but was missing. */ LDKBolt12SemanticError_MissingPaymentHash, + /** + * An invoice payment hash was provided but was not expected. + */ + LDKBolt12SemanticError_UnexpectedPaymentHash, /** * A signature was expected but was missing. */ @@ -344,13 +375,23 @@ typedef enum LDKChannelShutdownState { * estimation. */ typedef enum LDKConfirmationTarget { + /** + * The most aggressive (i.e. highest) feerate estimate available. + * + * This is used to sanity-check our counterparty's feerates and should be as conservative as + * possible to ensure that we don't confuse a peer using a very conservative estimator for one + * trying to burn channel balance to dust. + */ + LDKConfirmationTarget_MaximumFeeEstimate, /** * We have some funds available on chain which we need to spend prior to some expiry time at - * which point our counterparty may be able to steal them. Generally we have in the high tens - * to low hundreds of blocks to get our transaction on-chain, but we shouldn't risk too low a - * fee - this should be a relatively high priority feerate. + * which point our counterparty may be able to steal them. + * + * Generally we have in the high tens to low hundreds of blocks to get our transaction + * on-chain (it doesn't have to happen in the next few blocks!), but we shouldn't risk too low + * a fee - this should be a relatively high priority feerate. */ - LDKConfirmationTarget_OnChainSweep, + LDKConfirmationTarget_UrgentOnChainSweep, /** * This is the lowest feerate we will allow our channel counterparty to have in an anchor * channel in order to close the channel if a channel party goes away. @@ -432,14 +473,18 @@ typedef enum LDKConfirmationTarget { */ LDKConfirmationTarget_ChannelCloseMinimum, /** - * The feerate [`OutputSweeper`] will use on transactions spending - * [`SpendableOutputDescriptor`]s after a channel closure. + * The feerate used to claim on-chain funds when there is no particular urgency to do so. + * + * It is used to get commitment transactions without any HTLCs confirmed in [`ChannelMonitor`] + * and by [`OutputSweeper`] on transactions spending [`SpendableOutputDescriptor`]s after a + * channel closure. * * Generally spending these outputs is safe as long as they eventually confirm, so a value * (slightly above) the mempool minimum should suffice. However, as this value will influence * how long funds will be unavailable after channel closure, [`FeeEstimator`] implementors * might want to choose a higher feerate to regain control over funds faster. * + * [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor * [`OutputSweeper`]: crate::util::sweep::OutputSweeper * [`SpendableOutputDescriptor`]: crate::sign::SpendableOutputDescriptor */ @@ -471,16 +516,11 @@ typedef enum LDKCreationError { */ LDKCreationError_InvalidAmount, /** - * Route hints were required for this invoice and were missing. Applies to - * [phantom invoices]. - * - * [phantom invoices]: crate::utils::create_phantom_invoice + * Route hints were required for this invoice and were missing. */ LDKCreationError_MissingRouteHints, /** - * The provided `min_final_cltv_expiry_delta` was less than [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. - * - * [`MIN_FINAL_CLTV_EXPIRY_DELTA`]: lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA + * The provided `min_final_cltv_expiry_delta` was less than rust-lightning's minimum. */ LDKCreationError_MinFinalCltvExpiryDeltaTooShort, /** @@ -520,8 +560,8 @@ typedef enum LDKCurrency { } LDKCurrency; /** - * The side of a channel that is the [`IntroductionNode`] in a [`BlindedPath`]. [BOLT 7] defines - * which nodes is which in the [`ChannelAnnouncement`] message. + * The side of a channel that is the [`IntroductionNode`] in a blinded path. [BOLT 7] defines which + * nodes is which in the [`ChannelAnnouncement`] message. * * [BOLT 7]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_announcement-message * [`ChannelAnnouncement`]: crate::ln::msgs::ChannelAnnouncement @@ -766,6 +806,12 @@ typedef enum LDKOutboundHTLCStateDetails { typedef enum LDKPaymentFailureReason { /** * The intended recipient rejected our payment. + * + * Also used for [`UnknownRequiredFeatures`] and [`InvoiceRequestRejected`] when downgrading to + * version prior to 0.0.124. + * + * [`UnknownRequiredFeatures`]: Self::UnknownRequiredFeatures + * [`InvoiceRequestRejected`]: Self::InvoiceRequestRejected */ LDKPaymentFailureReason_RecipientRejected, /** @@ -787,7 +833,10 @@ typedef enum LDKPaymentFailureReason { * The payment expired while retrying, based on the provided * [`PaymentParameters::expiry_time`]. * + * Also used for [`InvoiceRequestExpired`] when downgrading to version prior to 0.0.124. + * * [`PaymentParameters::expiry_time`]: crate::routing::router::PaymentParameters::expiry_time + * [`InvoiceRequestExpired`]: Self::InvoiceRequestExpired */ LDKPaymentFailureReason_PaymentExpired, /** @@ -803,6 +852,20 @@ typedef enum LDKPaymentFailureReason { * your router. */ LDKPaymentFailureReason_UnexpectedError, + /** + * An invoice was received that required unknown features. + */ + LDKPaymentFailureReason_UnknownRequiredFeatures, + /** + * A [`Bolt12Invoice`] was not received in a reasonable amount of time. + */ + LDKPaymentFailureReason_InvoiceRequestExpired, + /** + * An [`InvoiceRequest`] for the payment was rejected by the recipient. + * + * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest + */ + LDKPaymentFailureReason_InvoiceRequestRejected, /** * Must be last for serialization purposes */ @@ -862,6 +925,14 @@ typedef enum LDKRetryableSendFailure { * [`Event::PaymentFailed`]: crate::events::Event::PaymentFailed */ LDKRetryableSendFailure_DuplicatePayment, + /** + * The [`RecipientOnionFields::payment_metadata`], [`RecipientOnionFields::custom_tlvs`], or + * [`BlindedPaymentPath`]s provided are too large and caused us to exceed the maximum onion + * packet size of 1300 bytes. + * + * [`BlindedPaymentPath`]: crate::blinded_path::payment::BlindedPaymentPath + */ + LDKRetryableSendFailure_OnionPacketSizeExceeded, /** * Must be last for serialization purposes */ @@ -916,6 +987,10 @@ typedef enum LDKSecp256k1Error { * The only valid parity values are 0 or 1. */ LDKSecp256k1Error_InvalidParityValue, + /** + * Invalid Elligator Swift Value + */ + LDKSecp256k1Error_InvalidEllSwift, /** * Must be last for serialization purposes */ @@ -1417,39 +1492,137 @@ typedef struct LDKCOption_u64Z { /** - * Onion messages and payments can be sent and received to blinded paths, which serve to hide the - * identity of the recipient. + * A blinded path to be used for sending or receiving a message, hiding the identity of the + * recipient. */ -typedef struct MUST_USE_STRUCT LDKBlindedPath { +typedef struct MUST_USE_STRUCT LDKBlindedMessagePath { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeBlindedPath *inner; + LDKnativeBlindedMessagePath *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; -} LDKBlindedPath; +} LDKBlindedMessagePath; /** - * A dynamically-allocated array of crate::lightning::blinded_path::BlindedPaths of arbitrary size. + * A dynamically-allocated array of crate::lightning::blinded_path::message::BlindedMessagePaths of arbitrary size. * This corresponds to std::vector in C++ */ -typedef struct LDKCVec_BlindedPathZ { +typedef struct LDKCVec_BlindedMessagePathZ { /** * The elements in the array. * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - struct LDKBlindedPath *data; + struct LDKBlindedMessagePath *data; /** * The number of elements pointed to by `data`. */ uintptr_t datalen; -} LDKCVec_BlindedPathZ; +} LDKCVec_BlindedMessagePathZ; + +/** + * An error in decoding a message or struct. + */ +typedef enum LDKDecodeError_Tag { + /** + * A version byte specified something we don't know how to handle. + * + * Includes unknown realm byte in an onion hop data packet. + */ + LDKDecodeError_UnknownVersion, + /** + * Unknown feature mandating we fail to parse message (e.g., TLV with an even, unknown type) + */ + LDKDecodeError_UnknownRequiredFeature, + /** + * Value was invalid. + * + * For example, a byte which was supposed to be a bool was something other than a 0 + * or 1, a public key/private key/signature was invalid, text wasn't UTF-8, TLV was + * syntactically incorrect, etc. + */ + LDKDecodeError_InvalidValue, + /** + * The buffer to be read was too short. + */ + LDKDecodeError_ShortRead, + /** + * A length descriptor in the packet didn't describe the later data correctly. + */ + LDKDecodeError_BadLengthDescriptor, + /** + * Error from [`std::io`]. + */ + LDKDecodeError_Io, + /** + * The message included zlib-compressed values, which we don't support. + */ + LDKDecodeError_UnsupportedCompression, + /** + * Value is validly encoded but is dangerous to use. + * + * This is used for things like [`ChannelManager`] deserialization where we want to ensure + * that we don't use a [`ChannelManager`] which is in out of sync with the [`ChannelMonitor`]. + * This indicates that there is a critical implementation flaw in the storage implementation + * and it's unsafe to continue. + * + * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager + * [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor + */ + LDKDecodeError_DangerousValue, + /** + * Must be last for serialization purposes + */ + LDKDecodeError_Sentinel, +} LDKDecodeError_Tag; + +typedef struct MUST_USE_STRUCT LDKDecodeError { + LDKDecodeError_Tag tag; + union { + struct { + enum LDKIOError io; + }; + }; +} LDKDecodeError; + +/** + * The contents of CResult_RefundDecodeErrorZ + */ +typedef union LDKCResult_RefundDecodeErrorZPtr { + /** + * 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 LDKDecodeError *err; +} LDKCResult_RefundDecodeErrorZPtr; + +/** + * A CResult_RefundDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::offers::refund::Refund 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_RefundDecodeErrorZ { + /** + * The contents of this CResult_RefundDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_RefundDecodeErrorZPtr contents; + /** + * Whether this CResult_RefundDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_RefundDecodeErrorZ; @@ -1541,71 +1714,6 @@ typedef struct MUST_USE_STRUCT LDKRetry { }; } LDKRetry; -/** - * An error in decoding a message or struct. - */ -typedef enum LDKDecodeError_Tag { - /** - * A version byte specified something we don't know how to handle. - * - * Includes unknown realm byte in an onion hop data packet. - */ - LDKDecodeError_UnknownVersion, - /** - * Unknown feature mandating we fail to parse message (e.g., TLV with an even, unknown type) - */ - LDKDecodeError_UnknownRequiredFeature, - /** - * Value was invalid. - * - * For example, a byte which was supposed to be a bool was something other than a 0 - * or 1, a public key/private key/signature was invalid, text wasn't UTF-8, TLV was - * syntactically incorrect, etc. - */ - LDKDecodeError_InvalidValue, - /** - * The buffer to be read was too short. - */ - LDKDecodeError_ShortRead, - /** - * A length descriptor in the packet didn't describe the later data correctly. - */ - LDKDecodeError_BadLengthDescriptor, - /** - * Error from [`std::io`]. - */ - LDKDecodeError_Io, - /** - * The message included zlib-compressed values, which we don't support. - */ - LDKDecodeError_UnsupportedCompression, - /** - * Value is validly encoded but is dangerous to use. - * - * This is used for things like [`ChannelManager`] deserialization where we want to ensure - * that we don't use a [`ChannelManager`] which is in out of sync with the [`ChannelMonitor`]. - * This indicates that there is a critical implementation flaw in the storage implementation - * and it's unsafe to continue. - * - * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager - * [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor - */ - LDKDecodeError_DangerousValue, - /** - * Must be last for serialization purposes - */ - LDKDecodeError_Sentinel, -} LDKDecodeError_Tag; - -typedef struct MUST_USE_STRUCT LDKDecodeError { - LDKDecodeError_Tag tag; - union { - struct { - enum LDKIOError io; - }; - }; -} LDKDecodeError; - /** * The contents of CResult_RetryDecodeErrorZ */ @@ -2162,6 +2270,22 @@ typedef struct LDKCResult_SchnorrSignatureNoneZ { bool result_ok; } LDKCResult_SchnorrSignatureNoneZ; +/** + * A dynamically-allocated array of crate::c_types::Strs of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_StrZ { + /** + * 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_StrZ; + /** * A dynamically-allocated array of crate::c_types::ThirtyTwoBytess of arbitrary size. * This corresponds to std::vector in C++ @@ -2381,58 +2505,38 @@ typedef struct LDKCResult_ThirtyTwoBytesNoneZ { bool result_ok; } LDKCResult_ThirtyTwoBytesNoneZ; - - -/** - * Information needed to route a payment across a [`BlindedPath`]. - */ -typedef struct MUST_USE_STRUCT LDKBlindedPayInfo { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, 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; - /** - * Indicates that this is the only struct which contains the same pointer. - * Rust 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; - /** - * The contents of CResult_BlindedPayInfoDecodeErrorZ + * The contents of CResult_Bolt12InvoiceDecodeErrorZ */ -typedef union LDKCResult_BlindedPayInfoDecodeErrorZPtr { +typedef union LDKCResult_Bolt12InvoiceDecodeErrorZPtr { /** * 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 LDKBolt12Invoice *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_Bolt12InvoiceDecodeErrorZPtr; /** - * 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_Bolt12InvoiceDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::offers::invoice::Bolt12Invoice 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_Bolt12InvoiceDecodeErrorZ { /** - * The contents of this CResult_BlindedPayInfoDecodeErrorZ, accessible via either + * The contents of this CResult_Bolt12InvoiceDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_BlindedPayInfoDecodeErrorZPtr contents; + union LDKCResult_Bolt12InvoiceDecodeErrorZPtr contents; /** - * Whether this CResult_BlindedPayInfoDecodeErrorZ represents a success state. + * Whether this CResult_Bolt12InvoiceDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_BlindedPayInfoDecodeErrorZ; +} LDKCResult_Bolt12InvoiceDecodeErrorZ; @@ -2549,7 +2653,7 @@ typedef struct LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ { /** * A reference to a transaction output. * - * Differs from bitcoin::blockdata::transaction::OutPoint as the index is a u16 instead of u32 + * Differs from bitcoin::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 { @@ -2938,37 +3042,6 @@ typedef struct LDKCResult_HTLCDescriptorDecodeErrorZ { bool result_ok; } LDKCResult_HTLCDescriptorDecodeErrorZ; -/** - * The contents of CResult_NoneNoneZ - */ -typedef union LDKCResult_NoneNoneZPtr { - /** - * Note that this value is always NULL, as there are no contents in the OK variant - */ - void *result; - /** - * Note that this value is always NULL, as there are no contents in the Err variant - */ - void *err; -} LDKCResult_NoneNoneZPtr; - -/** - * 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_NoneNoneZ { - /** - * The contents of this CResult_NoneNoneZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. - */ - union LDKCResult_NoneNoneZPtr contents; - /** - * Whether this CResult_NoneNoneZ represents a success state. - */ - bool result_ok; -} LDKCResult_NoneNoneZ; - /** * Represents a valid secp256k1 public key serialized in "compressed form" as a 33 byte array. */ @@ -3011,6 +3084,69 @@ typedef struct LDKCResult_PublicKeyNoneZ { bool result_ok; } LDKCResult_PublicKeyNoneZ; +/** + * The contents of CResult__u832NoneZ + */ +typedef union LDKCResult__u832NoneZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKThirtyTwoBytes *result; + /** + * Note that this value is always NULL, as there are no contents in the Err variant + */ + void *err; +} LDKCResult__u832NoneZPtr; + +/** + * A CResult__u832NoneZ 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__u832NoneZ { + /** + * The contents of this CResult__u832NoneZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult__u832NoneZPtr contents; + /** + * Whether this CResult__u832NoneZ represents a success state. + */ + bool result_ok; +} LDKCResult__u832NoneZ; + +/** + * The contents of CResult_NoneNoneZ + */ +typedef union LDKCResult_NoneNoneZPtr { + /** + * Note that this value is always NULL, as there are no contents in the OK variant + */ + void *result; + /** + * Note that this value is always NULL, as there are no contents in the Err variant + */ + void *err; +} LDKCResult_NoneNoneZPtr; + +/** + * 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_NoneNoneZ { + /** + * The contents of this CResult_NoneNoneZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_NoneNoneZPtr contents; + /** + * Whether this CResult_NoneNoneZ represents a success state. + */ + bool result_ok; +} LDKCResult_NoneNoneZ; + /** * An enum which can either contain a crate::c_types::BigEndianScalar or not */ @@ -3038,29 +3174,6 @@ typedef struct LDKCOption_BigEndianScalarZ { }; } LDKCOption_BigEndianScalarZ; -/** - * Integer in the range `0..32` - */ -typedef struct LDKU5 { - uint8_t _0; -} LDKU5; - -/** - * A dynamically-allocated array of crate::c_types::U5s of arbitrary size. - * This corresponds to std::vector in C++ - */ -typedef struct LDKCVec_U5Z { - /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - */ - struct LDKU5 *data; - /** - * The number of elements pointed to by `data`. - */ - uintptr_t datalen; -} LDKCVec_U5Z; - /** * 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. @@ -3401,6 +3514,10 @@ typedef struct MUST_USE_STRUCT LDKChannelTransactionParameters { /** * A trait to handle Lightning channel key material without concretizing the channel type or * the signature mechanism. + * + * Several methods allow error types to be returned to support async signing. This feature + * is not yet complete, and panics may occur in certain situations when returning errors + * for these methods. */ typedef struct LDKChannelSigner { /** @@ -3412,8 +3529,13 @@ typedef struct LDKChannelSigner { * Gets the per-commitment point for a specific commitment number * * Note that the commitment number starts at `(1 << 48) - 1` and counts backwards. + * + * If the signer returns `Err`, then the user is responsible for either force-closing the channel + * or calling `ChannelManager::signer_unblocked` (this method is only available when the + * `async_signing` cfg flag is enabled) once the signature is ready. + * */ - struct LDKPublicKey (*get_per_commitment_point)(const void *this_arg, uint64_t idx); + struct LDKCResult_PublicKeyNoneZ (*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 * @@ -3424,7 +3546,7 @@ typedef struct LDKChannelSigner { * * 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); + struct LDKCResult__u832NoneZ (*release_commitment_secret)(const void *this_arg, uint64_t idx); /** * Validate the counterparty's signatures on the holder commitment transaction and HTLCs. * @@ -3670,80 +3792,50 @@ typedef struct LDKEcdsaChannelSigner { */ 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); - /** - * Called, if set, after this WriteableEcdsaChannelSigner has been cloned into a duplicate object. - * The new WriteableEcdsaChannelSigner is provided, and should be mutated as needed to perform a + * Called, if set, after this EcdsaChannelSigner has been cloned into a duplicate object. + * The new EcdsaChannelSigner 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 LDKWriteableEcdsaChannelSigner *NONNULL_PTR new_WriteableEcdsaChannelSigner); + void (*cloned)(struct LDKEcdsaChannelSigner *NONNULL_PTR new_EcdsaChannelSigner); /** * 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; +} LDKEcdsaChannelSigner; /** - * The contents of CResult_WriteableEcdsaChannelSignerDecodeErrorZ + * The contents of CResult_EcdsaChannelSignerDecodeErrorZ */ -typedef union LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZPtr { +typedef union LDKCResult_EcdsaChannelSignerDecodeErrorZPtr { /** * 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 LDKEcdsaChannelSigner *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_EcdsaChannelSignerDecodeErrorZPtr; /** - * A CResult_WriteableEcdsaChannelSignerDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::sign::ecdsa::WriteableEcdsaChannelSigner on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_EcdsaChannelSignerDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::sign::ecdsa::EcdsaChannelSigner 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_EcdsaChannelSignerDecodeErrorZ { /** - * The contents of this CResult_WriteableEcdsaChannelSignerDecodeErrorZ, accessible via either + * The contents of this CResult_EcdsaChannelSignerDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZPtr contents; + union LDKCResult_EcdsaChannelSignerDecodeErrorZPtr contents; /** - * Whether this CResult_WriteableEcdsaChannelSignerDecodeErrorZ represents a success state. + * Whether this CResult_EcdsaChannelSignerDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ; +} LDKCResult_EcdsaChannelSignerDecodeErrorZ; /** * The contents of CResult_CVec_u8ZNoneZ @@ -3898,7 +3990,7 @@ typedef struct LDKCResult_WitnessNoneZ { /** - * A simple implementation of [`WriteableEcdsaChannelSigner`] that just keeps the private keys in memory. + * A simple implementation of [`EcdsaChannelSigner`] that just keeps the private keys in memory. * * This implementation performs no policy checks and is insufficient by itself as * a secure external signer. @@ -4096,6 +4188,8 @@ typedef enum LDKCandidateRouteHop_Tag { * * This primarily exists to track that we need to included a blinded path at the end of our * [`Route`], even though it doesn't actually add an additional hop in the payment. + * + * [`BlindedPayInfo`]: crate::blinded_path::payment::BlindedPayInfo */ LDKCandidateRouteHop_OneHopBlinded, /** @@ -4381,11 +4475,89 @@ typedef struct LDKCResult_NoneIOErrorZ { +/** + * Parameters needed to find a [`Route`]. + * + * Passed to [`find_route`] and [`build_route_from_hops`]. + */ +typedef struct MUST_USE_STRUCT LDKRouteParameters { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeRouteParameters *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; +} LDKRouteParameters; + +/** + * A tuple of 3 elements. See the individual fields for the types contained. + */ +typedef struct LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ { + /** + * The element at position 0 + */ + struct LDKThirtyTwoBytes a; + /** + * The element at position 1 + */ + struct LDKRecipientOnionFields b; + /** + * The element at position 2 + */ + struct LDKRouteParameters c; +} LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ; + +/** + * The contents of CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ + */ +typedef union LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ *result; + /** + * Note that this value is always NULL, as there are no contents in the Err variant + */ + void *err; +} LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZPtr; + +/** + * A CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ represents the result of a fallible operation, + * containing a crate::c_types::derived::C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ on success and a () on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ { + /** + * The contents of this CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZPtr contents; + /** + * Whether this CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ represents a success state. + */ + bool result_ok; +} LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ; + + + /** * Details of a channel, as returned by [`ChannelManager::list_channels`] and [`ChannelManager::list_usable_channels`] * + * Balances of a channel are available through [`ChainMonitor::get_claimable_balances`] and + * [`ChannelMonitor::get_claimable_balances`], calculated with respect to the corresponding on-chain + * transactions. + * * [`ChannelManager::list_channels`]: crate::ln::channelmanager::ChannelManager::list_channels * [`ChannelManager::list_usable_channels`]: crate::ln::channelmanager::ChannelManager::list_usable_channels + * [`ChainMonitor::get_claimable_balances`]: crate::chain::chainmonitor::ChainMonitor::get_claimable_balances + * [`ChannelMonitor::get_claimable_balances`]: crate::chain::channelmonitor::ChannelMonitor::get_claimable_balances */ typedef struct MUST_USE_STRUCT LDKChannelDetails { /** @@ -4492,67 +4664,74 @@ typedef struct LDKCResult_RouteLightningErrorZ { bool result_ok; } LDKCResult_RouteLightningErrorZ; + + /** - * A tuple of 2 elements. See the individual fields for the types contained. + * A blinded path to be used for sending or receiving a payment, hiding the identity of the + * recipient. */ -typedef struct LDKC2Tuple_BlindedPayInfoBlindedPathZ { +typedef struct MUST_USE_STRUCT LDKBlindedPaymentPath { /** - * 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 LDKBlindedPayInfo a; + LDKnativeBlindedPaymentPath *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 LDKBlindedPath b; -} LDKC2Tuple_BlindedPayInfoBlindedPathZ; + bool is_owned; +} LDKBlindedPaymentPath; /** - * A dynamically-allocated array of crate::c_types::derived::C2Tuple_BlindedPayInfoBlindedPathZs of arbitrary size. + * A dynamically-allocated array of crate::lightning::blinded_path::payment::BlindedPaymentPaths of arbitrary size. * This corresponds to std::vector in C++ */ -typedef struct LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ { +typedef struct LDKCVec_BlindedPaymentPathZ { /** * The elements in the array. * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - struct LDKC2Tuple_BlindedPayInfoBlindedPathZ *data; + struct LDKBlindedPaymentPath *data; /** * The number of elements pointed to by `data`. */ uintptr_t datalen; -} LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ; +} LDKCVec_BlindedPaymentPathZ; /** - * The contents of CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ + * The contents of CResult_CVec_BlindedPaymentPathZNoneZ */ -typedef union LDKCResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZPtr { +typedef union LDKCResult_CVec_BlindedPaymentPathZNoneZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ *result; + struct LDKCVec_BlindedPaymentPathZ *result; /** * Note that this value is always NULL, as there are no contents in the Err variant */ void *err; -} LDKCResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZPtr; +} LDKCResult_CVec_BlindedPaymentPathZNoneZPtr; /** - * A CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ represents the result of a fallible operation, - * containing a crate::c_types::derived::CVec_C2Tuple_BlindedPayInfoBlindedPathZZ on success and a () on failure. + * A CResult_CVec_BlindedPaymentPathZNoneZ represents the result of a fallible operation, + * containing a crate::c_types::derived::CVec_BlindedPaymentPathZ on success and a () on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ { +typedef struct LDKCResult_CVec_BlindedPaymentPathZNoneZ { /** - * The contents of this CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ, accessible via either + * The contents of this CResult_CVec_BlindedPaymentPathZNoneZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZPtr contents; + union LDKCResult_CVec_BlindedPaymentPathZNoneZPtr contents; /** - * Whether this CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ represents a success state. + * Whether this CResult_CVec_BlindedPaymentPathZNoneZ represents a success state. */ bool result_ok; -} LDKCResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ; +} LDKCResult_CVec_BlindedPaymentPathZNoneZ; /** * A dynamically-allocated array of crate::c_types::PublicKeys of arbitrary size. @@ -4623,36 +4802,72 @@ typedef struct LDKCResult_OnionMessagePathNoneZ { } LDKCResult_OnionMessagePathNoneZ; /** - * The contents of CResult_CVec_BlindedPathZNoneZ + * The contents of CResult_CVec_BlindedMessagePathZNoneZ */ -typedef union LDKCResult_CVec_BlindedPathZNoneZPtr { +typedef union LDKCResult_CVec_BlindedMessagePathZNoneZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKCVec_BlindedPathZ *result; + struct LDKCVec_BlindedMessagePathZ *result; /** * Note that this value is always NULL, as there are no contents in the Err variant */ void *err; -} LDKCResult_CVec_BlindedPathZNoneZPtr; +} LDKCResult_CVec_BlindedMessagePathZNoneZPtr; /** - * A CResult_CVec_BlindedPathZNoneZ represents the result of a fallible operation, - * containing a crate::c_types::derived::CVec_BlindedPathZ on success and a () on failure. + * A CResult_CVec_BlindedMessagePathZNoneZ represents the result of a fallible operation, + * containing a crate::c_types::derived::CVec_BlindedMessagePathZ on success and a () on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_CVec_BlindedPathZNoneZ { +typedef struct LDKCResult_CVec_BlindedMessagePathZNoneZ { /** - * The contents of this CResult_CVec_BlindedPathZNoneZ, accessible via either + * The contents of this CResult_CVec_BlindedMessagePathZNoneZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_CVec_BlindedPathZNoneZPtr contents; + union LDKCResult_CVec_BlindedMessagePathZNoneZPtr contents; /** - * Whether this CResult_CVec_BlindedPathZNoneZ represents a success state. + * Whether this CResult_CVec_BlindedMessagePathZNoneZ represents a success state. */ bool result_ok; -} LDKCResult_CVec_BlindedPathZNoneZ; +} LDKCResult_CVec_BlindedMessagePathZNoneZ; + + + +/** + * An intermediate node, and possibly a short channel id leading to the next node. + */ +typedef struct MUST_USE_STRUCT LDKMessageForwardNode { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeMessageForwardNode *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; +} LDKMessageForwardNode; + +/** + * A dynamically-allocated array of crate::lightning::blinded_path::message::MessageForwardNodes of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_MessageForwardNodeZ { + /** + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + */ + struct LDKMessageForwardNode *data; + /** + * The number of elements pointed to by `data`. + */ + uintptr_t datalen; +} LDKCVec_MessageForwardNodeZ; @@ -4921,28 +5136,6 @@ typedef struct LDKCResult_RouteDecodeErrorZ { bool result_ok; } LDKCResult_RouteDecodeErrorZ; - - -/** - * Parameters needed to find a [`Route`]. - * - * Passed to [`find_route`] and [`build_route_from_hops`]. - */ -typedef struct MUST_USE_STRUCT LDKRouteParameters { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeRouteParameters *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; -} LDKRouteParameters; - /** * The contents of CResult_RouteParametersDecodeErrorZ */ @@ -5066,7 +5259,7 @@ typedef struct MUST_USE_STRUCT LDKRouteHint { } LDKRouteHint; /** - * A dynamically-allocated array of crate::lightning::routing::router::RouteHints of arbitrary size. + * A dynamically-allocated array of crate::lightning_types::routing::RouteHints of arbitrary size. * This corresponds to std::vector in C++ */ typedef struct LDKCVec_RouteHintZ { @@ -5081,6 +5274,39 @@ typedef struct LDKCVec_RouteHintZ { uintptr_t datalen; } LDKCVec_RouteHintZ; +/** + * The contents of CResult_RouteHintDecodeErrorZ + */ +typedef union LDKCResult_RouteHintDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKRouteHint *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_RouteHintDecodeErrorZPtr; + +/** + * A CResult_RouteHintDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning_types::routing::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`. + */ +typedef struct LDKCResult_RouteHintDecodeErrorZ { + /** + * The contents of this CResult_RouteHintDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_RouteHintDecodeErrorZPtr contents; + /** + * Whether this CResult_RouteHintDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_RouteHintDecodeErrorZ; + /** @@ -5105,55 +5331,6 @@ typedef struct MUST_USE_STRUCT LDKRouteHintHop { bool is_owned; } LDKRouteHintHop; -/** - * A dynamically-allocated array of crate::lightning::routing::router::RouteHintHops of arbitrary size. - * This corresponds to std::vector in C++ - */ -typedef struct LDKCVec_RouteHintHopZ { - /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - */ - struct LDKRouteHintHop *data; - /** - * The number of elements pointed to by `data`. - */ - uintptr_t datalen; -} LDKCVec_RouteHintHopZ; - -/** - * The contents of CResult_RouteHintDecodeErrorZ - */ -typedef union LDKCResult_RouteHintDecodeErrorZPtr { - /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. - */ - struct LDKRouteHint *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_RouteHintDecodeErrorZPtr; - -/** - * 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`. - */ -typedef struct LDKCResult_RouteHintDecodeErrorZ { - /** - * The contents of this CResult_RouteHintDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. - */ - union LDKCResult_RouteHintDecodeErrorZPtr contents; - /** - * Whether this CResult_RouteHintDecodeErrorZ represents a success state. - */ - bool result_ok; -} LDKCResult_RouteHintDecodeErrorZ; - /** * The contents of CResult_RouteHintHopDecodeErrorZ */ @@ -5172,7 +5349,7 @@ typedef union LDKCResult_RouteHintHopDecodeErrorZPtr { /** * 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. + * containing a crate::lightning_types::routing::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`. */ typedef struct LDKCResult_RouteHintHopDecodeErrorZ { @@ -5831,6 +6008,16 @@ typedef enum LDKClosureReason_Tag { * One of our HTLCs timed out in a channel, causing us to force close the channel. */ LDKClosureReason_HTLCsTimedOut, + /** + * Our peer provided a feerate which violated our required minimum (fetched from our + * [`FeeEstimator`] either as [`ConfirmationTarget::MinAllowedAnchorChannelRemoteFee`] or + * [`ConfirmationTarget::MinAllowedNonAnchorChannelRemoteFee`]). + * + * [`FeeEstimator`]: crate::chain::chaininterface::FeeEstimator + * [`ConfirmationTarget::MinAllowedAnchorChannelRemoteFee`]: crate::chain::chaininterface::ConfirmationTarget::MinAllowedAnchorChannelRemoteFee + * [`ConfirmationTarget::MinAllowedNonAnchorChannelRemoteFee`]: crate::chain::chaininterface::ConfirmationTarget::MinAllowedNonAnchorChannelRemoteFee + */ + LDKClosureReason_PeerFeerateTooLow, /** * Must be last for serialization purposes */ @@ -5850,6 +6037,24 @@ typedef struct LDKClosureReason_LDKCounterpartyForceClosed_Body { struct LDKUntrustedString peer_msg; } LDKClosureReason_LDKCounterpartyForceClosed_Body; +typedef struct LDKClosureReason_LDKHolderForceClosed_Body { + /** + * Whether or not the latest transaction was broadcasted when the channel was force + * closed. + * + * Channels closed using [`ChannelManager::force_close_broadcasting_latest_txn`] will have + * this field set to true, whereas channels closed using [`ChannelManager::force_close_without_broadcasting_txn`] + * or force-closed prior to being funded will have this field set to false. + * + * This will be `None` for objects generated or written by LDK 0.0.123 and + * earlier. + * + * [`ChannelManager::force_close_broadcasting_latest_txn`]: crate::ln::channelmanager::ChannelManager::force_close_broadcasting_latest_txn. + * [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn. + */ + struct LDKCOption_boolZ broadcasted_latest_txn; +} LDKClosureReason_LDKHolderForceClosed_Body; + typedef struct LDKClosureReason_LDKProcessingError_Body { /** * A developer-readable error message which we generated. @@ -5857,11 +6062,26 @@ typedef struct LDKClosureReason_LDKProcessingError_Body { struct LDKStr err; } LDKClosureReason_LDKProcessingError_Body; +typedef struct LDKClosureReason_LDKPeerFeerateTooLow_Body { + /** + * The feerate on our channel set by our peer. + */ + uint32_t peer_feerate_sat_per_kw; + /** + * The required feerate we enforce, from our [`FeeEstimator`]. + * + * [`FeeEstimator`]: crate::chain::chaininterface::FeeEstimator + */ + uint32_t required_feerate_sat_per_kw; +} LDKClosureReason_LDKPeerFeerateTooLow_Body; + typedef struct MUST_USE_STRUCT LDKClosureReason { LDKClosureReason_Tag tag; union { LDKClosureReason_LDKCounterpartyForceClosed_Body counterparty_force_closed; + LDKClosureReason_LDKHolderForceClosed_Body holder_force_closed; LDKClosureReason_LDKProcessingError_Body processing_error; + LDKClosureReason_LDKPeerFeerateTooLow_Body peer_feerate_too_low; }; } LDKClosureReason; @@ -6063,7 +6283,7 @@ typedef union LDKCResult_InitFeaturesDecodeErrorZPtr { /** * 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. + * containing a crate::lightning_types::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`. */ typedef struct LDKCResult_InitFeaturesDecodeErrorZ { @@ -6116,7 +6336,7 @@ typedef union LDKCResult_ChannelFeaturesDecodeErrorZPtr { /** * 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. + * containing a crate::lightning_types::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`. */ typedef struct LDKCResult_ChannelFeaturesDecodeErrorZ { @@ -6169,7 +6389,7 @@ typedef union LDKCResult_NodeFeaturesDecodeErrorZPtr { /** * 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. + * containing a crate::lightning_types::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`. */ typedef struct LDKCResult_NodeFeaturesDecodeErrorZ { @@ -6222,7 +6442,7 @@ typedef union 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. + * containing a crate::lightning_types::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 { @@ -6275,7 +6495,7 @@ typedef union LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZPtr { /** * 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. + * containing a crate::lightning_types::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_Bolt12InvoiceFeaturesDecodeErrorZ { @@ -6328,7 +6548,7 @@ typedef union LDKCResult_BlindedHopFeaturesDecodeErrorZPtr { /** * 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. + * containing a crate::lightning_types::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`. */ typedef struct LDKCResult_BlindedHopFeaturesDecodeErrorZ { @@ -6390,7 +6610,7 @@ typedef union LDKCResult_ChannelTypeFeaturesDecodeErrorZPtr { /** * 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. + * containing a crate::lightning_types::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`. */ typedef struct LDKCResult_ChannelTypeFeaturesDecodeErrorZ { @@ -6502,7 +6722,7 @@ typedef struct LDKCResult_NoneBolt12SemanticErrorZ { * 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. + * Through the use of [`BlindedMessagePath`]s, offers provide recipient privacy. * * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice @@ -6669,6 +6889,39 @@ typedef struct LDKCResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12Semantic bool result_ok; } LDKCResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ; +/** + * The contents of CResult_OfferDecodeErrorZ + */ +typedef union LDKCResult_OfferDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKOffer *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_OfferDecodeErrorZPtr; + +/** + * A CResult_OfferDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::offers::offer::Offer 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_OfferDecodeErrorZ { + /** + * The contents of this CResult_OfferDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_OfferDecodeErrorZPtr contents; + /** + * Whether this CResult_OfferDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_OfferDecodeErrorZ; + /** * The contents of CResult_OfferBolt12ParseErrorZ */ @@ -6768,28 +7021,6 @@ typedef struct LDKCResult_PublicKeySecp256k1ErrorZ { bool result_ok; } LDKCResult_PublicKeySecp256k1ErrorZ; - - -/** - * A [`channel_update`] message to be sent to or received from a peer. - * - * [`channel_update`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_update-message - */ -typedef struct MUST_USE_STRUCT LDKChannelUpdate { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeChannelUpdate *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; -} LDKChannelUpdate; - /** * Update to the [`NetworkGraph`] based on payment failure information conveyed via the Onion * return packet by a node along the route. See [BOLT #4] for details. @@ -6797,11 +7028,6 @@ typedef struct MUST_USE_STRUCT LDKChannelUpdate { * [BOLT #4]: https://github.com/lightning/bolts/blob/master/04-onion-routing.md */ typedef enum LDKNetworkUpdate_Tag { - /** - * An error indicating a `channel_update` messages should be applied via - * [`NetworkGraph::update_channel`]. - */ - LDKNetworkUpdate_ChannelUpdateMessage, /** * An error indicating that a channel failed to route a payment, which should be applied via * [`NetworkGraph::channel_failed_permanent`] if permanent. @@ -6818,13 +7044,6 @@ typedef enum LDKNetworkUpdate_Tag { LDKNetworkUpdate_Sentinel, } LDKNetworkUpdate_Tag; -typedef struct LDKNetworkUpdate_LDKChannelUpdateMessage_Body { - /** - * The update to apply via [`NetworkGraph::update_channel`]. - */ - struct LDKChannelUpdate msg; -} LDKNetworkUpdate_LDKChannelUpdateMessage_Body; - typedef struct LDKNetworkUpdate_LDKChannelFailure_Body { /** * The short channel id of the closed channel. @@ -6852,7 +7071,6 @@ typedef struct LDKNetworkUpdate_LDKNodeFailure_Body { typedef struct MUST_USE_STRUCT LDKNetworkUpdate { LDKNetworkUpdate_Tag tag; union { - LDKNetworkUpdate_LDKChannelUpdateMessage_Body channel_update_message; LDKNetworkUpdate_LDKChannelFailure_Body channel_failure; LDKNetworkUpdate_LDKNodeFailure_Body node_failure; }; @@ -7150,6 +7368,28 @@ typedef struct MUST_USE_STRUCT LDKChannelAnnouncement { bool is_owned; } LDKChannelAnnouncement; + + +/** + * A [`channel_update`] message to be sent to or received from a peer. + * + * [`channel_update`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_update-message + */ +typedef struct MUST_USE_STRUCT LDKChannelUpdate { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeChannelUpdate *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; +} LDKChannelUpdate; + /** * A tuple of 3 elements. See the individual fields for the types contained. */ @@ -7340,7 +7580,8 @@ typedef struct MUST_USE_STRUCT LDKFundingSigned { /** - * An stfu (quiescence) message to be sent by or received from the stfu initiator. + * An `stfu` (quiescence) message to be sent by or received from the stfu initiator. + * */ typedef struct MUST_USE_STRUCT LDKStfu { /** @@ -7360,27 +7601,28 @@ typedef struct MUST_USE_STRUCT LDKStfu { /** - * A splice message to be sent by or received from the stfu initiator (splice initiator). + * A `splice_init` message to be sent by or received from the stfu initiator (splice initiator). + * */ -typedef struct MUST_USE_STRUCT LDKSplice { +typedef struct MUST_USE_STRUCT LDKSpliceInit { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeSplice *inner; + LDKnativeSpliceInit *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; -} LDKSplice; +} LDKSpliceInit; /** - * A splice_ack message to be received by or sent to the splice initiator. + * A `splice_ack` message to be received by or sent to the splice initiator. * */ typedef struct MUST_USE_STRUCT LDKSpliceAck { @@ -7401,7 +7643,7 @@ typedef struct MUST_USE_STRUCT LDKSpliceAck { /** - * A splice_locked message to be sent to or received from a peer. + * A `splice_locked` message to be sent to or received from a peer. * */ typedef struct MUST_USE_STRUCT LDKSpliceLocked { @@ -8069,9 +8311,9 @@ typedef enum LDKMessageSendEvent_Tag { */ LDKMessageSendEvent_SendStfu, /** - * Used to indicate that a splice message should be sent to the peer with the given node id. + * Used to indicate that a splice_init message should be sent to the peer with the given node id. */ - LDKMessageSendEvent_SendSplice, + LDKMessageSendEvent_SendSpliceInit, /** * Used to indicate that a splice_ack message should be sent to the peer with the given node id. */ @@ -8283,7 +8525,7 @@ typedef struct LDKMessageSendEvent_LDKSendStfu_Body { struct LDKStfu msg; } LDKMessageSendEvent_LDKSendStfu_Body; -typedef struct LDKMessageSendEvent_LDKSendSplice_Body { +typedef struct LDKMessageSendEvent_LDKSendSpliceInit_Body { /** * The node_id of the node which should receive this message */ @@ -8291,8 +8533,8 @@ typedef struct LDKMessageSendEvent_LDKSendSplice_Body { /** * The message which should be sent. */ - struct LDKSplice msg; -} LDKMessageSendEvent_LDKSendSplice_Body; + struct LDKSpliceInit msg; +} LDKMessageSendEvent_LDKSendSpliceInit_Body; typedef struct LDKMessageSendEvent_LDKSendSpliceAck_Body { /** @@ -8610,7 +8852,7 @@ typedef struct MUST_USE_STRUCT LDKMessageSendEvent { LDKMessageSendEvent_LDKSendFundingCreated_Body send_funding_created; LDKMessageSendEvent_LDKSendFundingSigned_Body send_funding_signed; LDKMessageSendEvent_LDKSendStfu_Body send_stfu; - LDKMessageSendEvent_LDKSendSplice_Body send_splice; + LDKMessageSendEvent_LDKSendSpliceInit_Body send_splice_init; LDKMessageSendEvent_LDKSendSpliceAck_Body send_splice_ack; LDKMessageSendEvent_LDKSendSpliceLocked_Body send_splice_locked; LDKMessageSendEvent_LDKSendTxAddInput_Body send_tx_add_input; @@ -8803,7 +9045,7 @@ typedef union LDKCResult_RoutingFeesDecodeErrorZPtr { /** * 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. + * containing a crate::lightning_types::routing::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 { @@ -8984,21 +9226,53 @@ typedef struct LDKCVec_SocketAddressZ { /** - * Information received in the latest node_announcement from this node. + * Non-relayable information received in the latest node_announcement from this node. */ -typedef struct MUST_USE_STRUCT LDKNodeAnnouncementInfo { +typedef struct MUST_USE_STRUCT LDKNodeAnnouncementDetails { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeNodeAnnouncementInfo *inner; + LDKnativeNodeAnnouncementDetails *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; +} LDKNodeAnnouncementDetails; + +/** + * Information received in the latest node_announcement from this node. + */ +typedef enum LDKNodeAnnouncementInfo_Tag { + /** + * An initial announcement of the node + * Everything else is useful only for sending out for initial routing sync. + * Not stored if contains excess data to prevent DoS. + */ + LDKNodeAnnouncementInfo_Relayed, + /** + * Non-relayable information received in the latest node_announcement from this node. + */ + LDKNodeAnnouncementInfo_Local, + /** + * Must be last for serialization purposes + */ + LDKNodeAnnouncementInfo_Sentinel, +} LDKNodeAnnouncementInfo_Tag; + +typedef struct MUST_USE_STRUCT LDKNodeAnnouncementInfo { + LDKNodeAnnouncementInfo_Tag tag; + union { + struct { + struct LDKNodeAnnouncement relayed; + }; + struct { + struct LDKNodeAnnouncementDetails local; + }; + }; } LDKNodeAnnouncementInfo; /** @@ -9090,6 +9364,33 @@ typedef struct LDKCResult_NodeAliasDecodeErrorZ { bool result_ok; } LDKCResult_NodeAliasDecodeErrorZ; +/** + * An enum which can either contain a crate::lightning::routing::gossip::NodeAnnouncementInfo or not + */ +typedef enum LDKCOption_NodeAnnouncementInfoZ_Tag { + /** + * When we're in this state, this COption_NodeAnnouncementInfoZ contains a crate::lightning::routing::gossip::NodeAnnouncementInfo + */ + LDKCOption_NodeAnnouncementInfoZ_Some, + /** + * When we're in this state, this COption_NodeAnnouncementInfoZ contains nothing + */ + LDKCOption_NodeAnnouncementInfoZ_None, + /** + * Must be last for serialization purposes + */ + LDKCOption_NodeAnnouncementInfoZ_Sentinel, +} LDKCOption_NodeAnnouncementInfoZ_Tag; + +typedef struct LDKCOption_NodeAnnouncementInfoZ { + LDKCOption_NodeAnnouncementInfoZ_Tag tag; + union { + struct { + struct LDKNodeAnnouncementInfo some; + }; + }; +} LDKCOption_NodeAnnouncementInfoZ; + /** @@ -9594,10 +9895,9 @@ typedef struct MUST_USE_STRUCT LDKBolt12RefundContext { } LDKBolt12RefundContext; /** - * The context of an inbound payment, which is included in a [`BlindedPath`] via [`ReceiveTlvs`] - * and surfaced in [`PaymentPurpose`]. + * The context of an inbound payment, which is included in a [`BlindedPaymentPath`] via + * [`ReceiveTlvs`] and surfaced in [`PaymentPurpose`]. * - * [`BlindedPath`]: crate::blinded_path::BlindedPath * [`PaymentPurpose`]: crate::events::PaymentPurpose */ typedef enum LDKPaymentContext_Tag { @@ -10411,6 +10711,160 @@ typedef struct LDKCResult_ThirtyTwoBytesAPIErrorZ { +/** + * A 128-bit number used only once. + * + * Needed when constructing [`Offer::metadata`] and deriving [`Offer::signing_pubkey`] from + * [`ExpandedKey`]. Must not be reused for any other derivation without first hashing. + * + * [`Offer::metadata`]: crate::offers::offer::Offer::metadata + * [`Offer::signing_pubkey`]: crate::offers::offer::Offer::signing_pubkey + * [`ExpandedKey`]: crate::ln::inbound_payment::ExpandedKey + */ +typedef struct MUST_USE_STRUCT LDKNonce { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeNonce *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; +} LDKNonce; + +/** + * Contains data specific to an [`OffersMessage`]. + * + * [`OffersMessage`]: crate::onion_message::offers::OffersMessage + */ +typedef enum LDKOffersContext_Tag { + /** + * Context used by a [`BlindedMessagePath`] within an [`Offer`]. + * + * This variant is intended to be received when handling an [`InvoiceRequest`]. + * + * [`Offer`]: crate::offers::offer::Offer + * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest + */ + LDKOffersContext_InvoiceRequest, + /** + * Context used by a [`BlindedMessagePath`] within a [`Refund`] or as a reply path for an + * [`InvoiceRequest`]. + * + * This variant is intended to be received when handling a [`Bolt12Invoice`] or an + * [`InvoiceError`]. + * + * [`Refund`]: crate::offers::refund::Refund + * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest + * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice + * [`InvoiceError`]: crate::offers::invoice_error::InvoiceError + */ + LDKOffersContext_OutboundPayment, + /** + * Context used by a [`BlindedMessagePath`] as a reply path for a [`Bolt12Invoice`]. + * + * This variant is intended to be received when handling an [`InvoiceError`]. + * + * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice + * [`InvoiceError`]: crate::offers::invoice_error::InvoiceError + */ + LDKOffersContext_InboundPayment, + /** + * Must be last for serialization purposes + */ + LDKOffersContext_Sentinel, +} LDKOffersContext_Tag; + +typedef struct LDKOffersContext_LDKInvoiceRequest_Body { + /** + * A nonce used for authenticating that an [`InvoiceRequest`] is for a valid [`Offer`] and + * for deriving the offer's signing keys. + * + * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest + * [`Offer`]: crate::offers::offer::Offer + */ + struct LDKNonce nonce; +} LDKOffersContext_LDKInvoiceRequest_Body; + +typedef struct LDKOffersContext_LDKOutboundPayment_Body { + /** + * Payment ID used when creating a [`Refund`] or [`InvoiceRequest`]. + * + * [`Refund`]: crate::offers::refund::Refund + * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest + */ + struct LDKThirtyTwoBytes payment_id; + /** + * A nonce used for authenticating that a [`Bolt12Invoice`] is for a valid [`Refund`] or + * [`InvoiceRequest`] and for deriving their signing keys. + * + * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice + * [`Refund`]: crate::offers::refund::Refund + * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest + */ + struct LDKNonce nonce; + /** + * Authentication code for the [`PaymentId`], which should be checked when the context is + * used with an [`InvoiceError`]. + * + * [`InvoiceError`]: crate::offers::invoice_error::InvoiceError + * + * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + */ + struct LDKThirtyTwoBytes hmac; +} LDKOffersContext_LDKOutboundPayment_Body; + +typedef struct LDKOffersContext_LDKInboundPayment_Body { + /** + * The same payment hash as [`Bolt12Invoice::payment_hash`]. + * + * [`Bolt12Invoice::payment_hash`]: crate::offers::invoice::Bolt12Invoice::payment_hash + */ + struct LDKThirtyTwoBytes payment_hash; +} LDKOffersContext_LDKInboundPayment_Body; + +typedef struct MUST_USE_STRUCT LDKOffersContext { + LDKOffersContext_Tag tag; + union { + LDKOffersContext_LDKInvoiceRequest_Body invoice_request; + LDKOffersContext_LDKOutboundPayment_Body outbound_payment; + LDKOffersContext_LDKInboundPayment_Body inbound_payment; + }; +} LDKOffersContext; + +/** + * An enum which can either contain a crate::lightning::blinded_path::message::OffersContext or not + */ +typedef enum LDKCOption_OffersContextZ_Tag { + /** + * When we're in this state, this COption_OffersContextZ contains a crate::lightning::blinded_path::message::OffersContext + */ + LDKCOption_OffersContextZ_Some, + /** + * When we're in this state, this COption_OffersContextZ contains nothing + */ + LDKCOption_OffersContextZ_None, + /** + * Must be last for serialization purposes + */ + LDKCOption_OffersContextZ_Sentinel, +} LDKCOption_OffersContextZ_Tag; + +typedef struct LDKCOption_OffersContextZ { + LDKCOption_OffersContextZ_Tag tag; + union { + struct { + struct LDKOffersContext some; + }; + }; +} LDKCOption_OffersContextZ; + + + /** * An `InvoiceRequest` is a request for a [`Bolt12Invoice`] formulated from an [`Offer`]. * @@ -10501,32 +10955,66 @@ typedef struct MUST_USE_STRUCT LDKOffersMessage { }; } LDKOffersMessage; + + /** - * An enum which can either contain a crate::lightning::onion_message::offers::OffersMessage or not + * Instructions for how and where to send the response to an onion message. */ -typedef enum LDKCOption_OffersMessageZ_Tag { +typedef struct MUST_USE_STRUCT LDKResponseInstruction { /** - * When we're in this state, this COption_OffersMessageZ contains a crate::lightning::onion_message::offers::OffersMessage + * A pointer to the opaque Rust object. + * Nearly everywhere, 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_OffersMessageZ_Some, + LDKnativeResponseInstruction *inner; /** - * When we're in this state, this COption_OffersMessageZ contains nothing + * Indicates that this is the only struct which contains the same pointer. + * Rust 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_OffersMessageZ_None, + bool is_owned; +} LDKResponseInstruction; + +/** + * A tuple of 2 elements. See the individual fields for the types contained. + */ +typedef struct LDKC2Tuple_OffersMessageResponseInstructionZ { + /** + * The element at position 0 + */ + struct LDKOffersMessage a; + /** + * The element at position 1 + */ + struct LDKResponseInstruction b; +} LDKC2Tuple_OffersMessageResponseInstructionZ; + +/** + * An enum which can either contain a crate::c_types::derived::C2Tuple_OffersMessageResponseInstructionZ or not + */ +typedef enum LDKCOption_C2Tuple_OffersMessageResponseInstructionZZ_Tag { + /** + * When we're in this state, this COption_C2Tuple_OffersMessageResponseInstructionZZ contains a crate::c_types::derived::C2Tuple_OffersMessageResponseInstructionZ + */ + LDKCOption_C2Tuple_OffersMessageResponseInstructionZZ_Some, + /** + * When we're in this state, this COption_C2Tuple_OffersMessageResponseInstructionZZ contains nothing + */ + LDKCOption_C2Tuple_OffersMessageResponseInstructionZZ_None, /** * Must be last for serialization purposes */ - LDKCOption_OffersMessageZ_Sentinel, -} LDKCOption_OffersMessageZ_Tag; + LDKCOption_C2Tuple_OffersMessageResponseInstructionZZ_Sentinel, +} LDKCOption_C2Tuple_OffersMessageResponseInstructionZZ_Tag; -typedef struct LDKCOption_OffersMessageZ { - LDKCOption_OffersMessageZ_Tag tag; +typedef struct LDKCOption_C2Tuple_OffersMessageResponseInstructionZZ { + LDKCOption_C2Tuple_OffersMessageResponseInstructionZZ_Tag tag; union { struct { - struct LDKOffersMessage some; + struct LDKC2Tuple_OffersMessageResponseInstructionZ some; }; }; -} LDKCOption_OffersMessageZ; +} LDKCOption_C2Tuple_OffersMessageResponseInstructionZZ; /** * The destination of an onion message. @@ -10553,15 +11041,129 @@ typedef struct MUST_USE_STRUCT LDKDestination { struct LDKPublicKey node; }; struct { - struct LDKBlindedPath blinded_path; + struct LDKBlindedMessagePath blinded_path; }; }; } LDKDestination; /** - * A tuple of 3 elements. See the individual fields for the types contained. + * Additional data included by the recipient in a [`BlindedMessagePath`]. + * + * This data is encrypted by the recipient and will be given to the corresponding message handler + * when handling a message sent over the [`BlindedMessagePath`]. The recipient can use this data to + * authenticate the message or for further processing if needed. */ -typedef struct LDKC3Tuple_OffersMessageDestinationBlindedPathZ { +typedef enum LDKMessageContext_Tag { + /** + * Context specific to an [`OffersMessage`]. + * + * [`OffersMessage`]: crate::onion_message::offers::OffersMessage + */ + LDKMessageContext_Offers, + /** + * Context specific to a [`CustomOnionMessageHandler::CustomMessage`]. + * + * [`CustomOnionMessageHandler::CustomMessage`]: crate::onion_message::messenger::CustomOnionMessageHandler::CustomMessage + */ + LDKMessageContext_Custom, + /** + * Must be last for serialization purposes + */ + LDKMessageContext_Sentinel, +} LDKMessageContext_Tag; + +typedef struct MUST_USE_STRUCT LDKMessageContext { + LDKMessageContext_Tag tag; + union { + struct { + struct LDKOffersContext offers; + }; + struct { + struct LDKCVec_u8Z custom; + }; + }; +} LDKMessageContext; + +/** + * Instructions for how and where to send a message. + */ +typedef enum LDKMessageSendInstructions_Tag { + /** + * Indicates that a message should be sent including the provided reply path for the recipient + * to respond. + */ + LDKMessageSendInstructions_WithSpecifiedReplyPath, + /** + * Indicates that a message should be sent including a reply path for the recipient to + * respond. + */ + LDKMessageSendInstructions_WithReplyPath, + /** + * Indicates that a message should be sent without including a reply path, preventing the + * recipient from responding. + */ + LDKMessageSendInstructions_WithoutReplyPath, + /** + * Indicates that a message is being sent as a reply to a received message. + */ + LDKMessageSendInstructions_ForReply, + /** + * Must be last for serialization purposes + */ + LDKMessageSendInstructions_Sentinel, +} LDKMessageSendInstructions_Tag; + +typedef struct LDKMessageSendInstructions_LDKWithSpecifiedReplyPath_Body { + /** + * The destination where we need to send our message. + */ + struct LDKDestination destination; + /** + * The reply path which should be included in the message. + */ + struct LDKBlindedMessagePath reply_path; +} LDKMessageSendInstructions_LDKWithSpecifiedReplyPath_Body; + +typedef struct LDKMessageSendInstructions_LDKWithReplyPath_Body { + /** + * The destination where we need to send our message. + */ + struct LDKDestination destination; + /** + * The context to include in the reply path we'll give the recipient so they can respond + * to us. + */ + struct LDKMessageContext context; +} LDKMessageSendInstructions_LDKWithReplyPath_Body; + +typedef struct LDKMessageSendInstructions_LDKWithoutReplyPath_Body { + /** + * The destination where we need to send our message. + */ + struct LDKDestination destination; +} LDKMessageSendInstructions_LDKWithoutReplyPath_Body; + +typedef struct LDKMessageSendInstructions_LDKForReply_Body { + /** + * The instructions provided by the [`Responder`]. + */ + struct LDKResponseInstruction instructions; +} LDKMessageSendInstructions_LDKForReply_Body; + +typedef struct MUST_USE_STRUCT LDKMessageSendInstructions { + LDKMessageSendInstructions_Tag tag; + union { + LDKMessageSendInstructions_LDKWithSpecifiedReplyPath_Body with_specified_reply_path; + LDKMessageSendInstructions_LDKWithReplyPath_Body with_reply_path; + LDKMessageSendInstructions_LDKWithoutReplyPath_Body without_reply_path; + LDKMessageSendInstructions_LDKForReply_Body for_reply; + }; +} LDKMessageSendInstructions; + +/** + * A tuple of 2 elements. See the individual fields for the types contained. + */ +typedef struct LDKC2Tuple_OffersMessageMessageSendInstructionsZ { /** * The element at position 0 */ @@ -10569,28 +11171,170 @@ typedef struct LDKC3Tuple_OffersMessageDestinationBlindedPathZ { /** * The element at position 1 */ - struct LDKDestination b; + struct LDKMessageSendInstructions b; +} LDKC2Tuple_OffersMessageMessageSendInstructionsZ; + +/** + * A dynamically-allocated array of crate::c_types::derived::C2Tuple_OffersMessageMessageSendInstructionsZs of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_C2Tuple_OffersMessageMessageSendInstructionsZZ { /** - * The element at position 2 + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + */ + struct LDKC2Tuple_OffersMessageMessageSendInstructionsZ *data; + /** + * The number of elements pointed to by `data`. + */ + uintptr_t datalen; +} LDKCVec_C2Tuple_OffersMessageMessageSendInstructionsZZ; + + + +/** + * Releases the HTLC corresponding to an inbound [`HeldHtlcAvailable`] message. + */ +typedef struct MUST_USE_STRUCT LDKReleaseHeldHtlc { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeReleaseHeldHtlc *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; +} LDKReleaseHeldHtlc; + +/** + * A tuple of 2 elements. See the individual fields for the types contained. + */ +typedef struct LDKC2Tuple_ReleaseHeldHtlcResponseInstructionZ { + /** + * The element at position 0 + */ + struct LDKReleaseHeldHtlc a; + /** + * The element at position 1 + */ + struct LDKResponseInstruction b; +} LDKC2Tuple_ReleaseHeldHtlcResponseInstructionZ; + +/** + * An enum which can either contain a crate::c_types::derived::C2Tuple_ReleaseHeldHtlcResponseInstructionZ or not + */ +typedef enum LDKCOption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ_Tag { + /** + * When we're in this state, this COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ contains a crate::c_types::derived::C2Tuple_ReleaseHeldHtlcResponseInstructionZ + */ + LDKCOption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ_Some, + /** + * When we're in this state, this COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ contains nothing + */ + LDKCOption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ_None, + /** + * Must be last for serialization purposes */ - struct LDKBlindedPath c; -} LDKC3Tuple_OffersMessageDestinationBlindedPathZ; + LDKCOption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ_Sentinel, +} LDKCOption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ_Tag; + +typedef struct LDKCOption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ { + LDKCOption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ_Tag tag; + union { + struct { + struct LDKC2Tuple_ReleaseHeldHtlcResponseInstructionZ some; + }; + }; +} LDKCOption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ; + + /** - * A dynamically-allocated array of crate::c_types::derived::C3Tuple_OffersMessageDestinationBlindedPathZs of arbitrary size. + * An HTLC destined for the recipient of this message is being held upstream. The reply path + * accompanying this onion message should be used to send a [`ReleaseHeldHtlc`] response, which + * will cause the upstream HTLC to be released. + */ +typedef struct MUST_USE_STRUCT LDKHeldHtlcAvailable { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeHeldHtlcAvailable *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; +} LDKHeldHtlcAvailable; + +/** + * Possible async payment messages sent and received via an [`OnionMessage`]. + * + * [`OnionMessage`]: crate::ln::msgs::OnionMessage + */ +typedef enum LDKAsyncPaymentsMessage_Tag { + /** + * An HTLC is being held upstream for the often-offline recipient, to be released via + * [`ReleaseHeldHtlc`]. + */ + LDKAsyncPaymentsMessage_HeldHtlcAvailable, + /** + * Releases the HTLC corresponding to an inbound [`HeldHtlcAvailable`] message. + */ + LDKAsyncPaymentsMessage_ReleaseHeldHtlc, + /** + * Must be last for serialization purposes + */ + LDKAsyncPaymentsMessage_Sentinel, +} LDKAsyncPaymentsMessage_Tag; + +typedef struct MUST_USE_STRUCT LDKAsyncPaymentsMessage { + LDKAsyncPaymentsMessage_Tag tag; + union { + struct { + struct LDKHeldHtlcAvailable held_htlc_available; + }; + struct { + struct LDKReleaseHeldHtlc release_held_htlc; + }; + }; +} LDKAsyncPaymentsMessage; + +/** + * A tuple of 2 elements. See the individual fields for the types contained. + */ +typedef struct LDKC2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ { + /** + * The element at position 0 + */ + struct LDKAsyncPaymentsMessage a; + /** + * The element at position 1 + */ + struct LDKMessageSendInstructions b; +} LDKC2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ; + +/** + * A dynamically-allocated array of crate::c_types::derived::C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZs of arbitrary size. * This corresponds to std::vector in C++ */ -typedef struct LDKCVec_C3Tuple_OffersMessageDestinationBlindedPathZZ { +typedef struct LDKCVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ { /** * The elements in the array. * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - struct LDKC3Tuple_OffersMessageDestinationBlindedPathZ *data; + struct LDKC2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ *data; /** * The number of elements pointed to by `data`. */ uintptr_t datalen; -} LDKCVec_C3Tuple_OffersMessageDestinationBlindedPathZZ; +} LDKCVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ; @@ -11206,6 +11950,30 @@ typedef struct LDKEntropySource { +/** + * 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 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. + */ + 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; +} LDKRawBolt11Invoice; + + + /** * A semantically valid [`InvoiceRequest`] that hasn't been signed. * @@ -11364,7 +12132,7 @@ typedef struct LDKNodeSigner { * * 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); + struct LDKCResult_RecoverableSignatureNoneZ (*sign_invoice)(const void *this_arg, const struct LDKRawBolt11Invoice *NONNULL_PTR invoice, enum LDKRecipient recipient); /** * Signs the [`TaggedHash`] of a BOLT 12 invoice request. * @@ -11435,11 +12203,11 @@ typedef struct LDKSignerProvider { * re-derived from its `channel_keys_id`, which can be obtained through its trait method * [`ChannelSigner::channel_keys_id`]. */ - struct LDKWriteableEcdsaChannelSigner (*derive_channel_signer)(const void *this_arg, uint64_t channel_value_satoshis, struct LDKThirtyTwoBytes channel_keys_id); + struct LDKEcdsaChannelSigner (*derive_channel_signer)(const void *this_arg, 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). + * [`EcdsaChannelSigner`]-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. @@ -11451,7 +12219,7 @@ typedef struct LDKSignerProvider { * [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager */ - struct LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ (*read_chan_signer)(const void *this_arg, struct LDKu8slice reader); + struct LDKCResult_EcdsaChannelSignerDecodeErrorZ (*read_chan_signer)(const void *this_arg, struct LDKu8slice reader); /** * Get a script pubkey which we send funds to when claiming on-chain contestable outputs. * @@ -11555,10 +12323,26 @@ typedef struct LDKMessageRouter { */ struct LDKCResult_OnionMessagePathNoneZ (*find_path)(const void *this_arg, struct LDKPublicKey sender, struct LDKCVec_PublicKeyZ peers, struct LDKDestination destination); /** - * Creates [`BlindedPath`]s to the `recipient` node. The nodes in `peers` are assumed to be - * direct peers with the `recipient`. + * Creates [`BlindedMessagePath`]s to the `recipient` node. The nodes in `peers` are assumed to + * be direct peers with the `recipient`. + */ + struct LDKCResult_CVec_BlindedMessagePathZNoneZ (*create_blinded_paths)(const void *this_arg, struct LDKPublicKey recipient, struct LDKMessageContext context, struct LDKCVec_PublicKeyZ peers); + /** + * Creates compact [`BlindedMessagePath`]s to the `recipient` node. The nodes in `peers` are + * assumed to be direct peers with the `recipient`. + * + * Compact blinded paths use short channel ids instead of pubkeys for a smaller serialization, + * which is beneficial when a QR code is used to transport the data. The SCID is passed using + * a [`MessageForwardNode`] but may be `None` for graceful degradation. + * + * Implementations using additional intermediate nodes are responsible for using a + * [`MessageForwardNode`] with `Some` short channel id, if possible. Similarly, implementations + * should call [`BlindedMessagePath::use_compact_introduction_node`]. + * + * The provided implementation simply delegates to [`MessageRouter::create_blinded_paths`], + * ignoring the short channel ids. */ - struct LDKCResult_CVec_BlindedPathZNoneZ (*create_blinded_paths)(const void *this_arg, struct LDKPublicKey recipient, struct LDKCVec_PublicKeyZ peers); + struct LDKCResult_CVec_BlindedMessagePathZNoneZ (*create_compact_blinded_paths)(const void *this_arg, struct LDKPublicKey recipient, struct LDKMessageContext context, struct LDKCVec_MessageForwardNodeZ peers); /** * 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. @@ -11597,11 +12381,11 @@ typedef struct LDKRouter { */ 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); /** - * Creates [`BlindedPath`]s for payment to the `recipient` node. The channels in `first_hops` + * Creates [`BlindedPaymentPath`]s for payment to the `recipient` node. The channels in `first_hops` * are assumed to be with the `recipient`'s peers. The payment secret and any constraints are * given in `tlvs`. */ - struct LDKCResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ (*create_blinded_payment_paths)(const void *this_arg, struct LDKPublicKey recipient, struct LDKCVec_ChannelDetailsZ first_hops, struct LDKReceiveTlvs tlvs, uint64_t amount_msats); + struct LDKCResult_CVec_BlindedPaymentPathZNoneZ (*create_blinded_payment_paths)(const void *this_arg, struct LDKPublicKey recipient, struct LDKCVec_ChannelDetailsZ first_hops, struct LDKReceiveTlvs tlvs, uint64_t amount_msats); /** * Implementation of MessageRouter for this object. */ @@ -11668,7 +12452,7 @@ typedef struct LDKRouter { * * ``` * use bitcoin::BlockHash; - * use bitcoin::network::constants::Network; + * use bitcoin::network::Network; * use lightning::chain::BestBlock; * # use lightning::chain::channelmonitor::ChannelMonitor; * use lightning::ln::channelmanager::{ChainParameters, ChannelManager, ChannelManagerReadArgs}; @@ -11803,35 +12587,38 @@ typedef struct LDKRouter { * } * * // On the event processing thread once the peer has responded - * channel_manager.process_pending_events(&|event| match event { - * Event::FundingGenerationReady { - * temporary_channel_id, counterparty_node_id, channel_value_satoshis, output_script, - * user_channel_id, .. - * } => { - * assert_eq!(user_channel_id, 42); - * let funding_transaction = wallet.create_funding_transaction( - * channel_value_satoshis, output_script - * ); - * match channel_manager.funding_transaction_generated( - * &temporary_channel_id, &counterparty_node_id, funding_transaction - * ) { - * Ok(()) => println!(\"Funding channel {}\", temporary_channel_id), - * Err(e) => println!(\"Error funding channel {}: {:?}\", temporary_channel_id, e), - * } - * }, - * Event::ChannelPending { channel_id, user_channel_id, former_temporary_channel_id, .. } => { - * assert_eq!(user_channel_id, 42); - * println!( - * \"Channel {} now {} pending (funding transaction has been broadcasted)\", channel_id, - * former_temporary_channel_id.unwrap() - * ); - * }, - * Event::ChannelReady { channel_id, user_channel_id, .. } => { - * assert_eq!(user_channel_id, 42); - * println!(\"Channel {} ready\", channel_id); - * }, - * // ... - * # _ => {}, + * channel_manager.process_pending_events(&|event| { + * match event { + * Event::FundingGenerationReady { + * temporary_channel_id, counterparty_node_id, channel_value_satoshis, output_script, + * user_channel_id, .. + * } => { + * assert_eq!(user_channel_id, 42); + * let funding_transaction = wallet.create_funding_transaction( + * channel_value_satoshis, output_script + * ); + * match channel_manager.funding_transaction_generated( + * temporary_channel_id, counterparty_node_id, funding_transaction + * ) { + * Ok(()) => println!(\"Funding channel {}\", temporary_channel_id), + * Err(e) => println!(\"Error funding channel {}: {:?}\", temporary_channel_id, e), + * } + * }, + * Event::ChannelPending { channel_id, user_channel_id, former_temporary_channel_id, .. } => { + * assert_eq!(user_channel_id, 42); + * println!( + * \"Channel {} now {} pending (funding transaction has been broadcasted)\", channel_id, + * former_temporary_channel_id.unwrap() + * ); + * }, + * Event::ChannelReady { channel_id, user_channel_id, .. } => { + * assert_eq!(user_channel_id, 42); + * println!(\"Channel {} ready\", channel_id); + * }, + * // ... + * # _ => {}, + * } + * Ok(()) * }); * # } * ``` @@ -11854,28 +12641,32 @@ typedef struct LDKRouter { * # * # fn example(channel_manager: T) { * # let channel_manager = channel_manager.get_cm(); - * channel_manager.process_pending_events(&|event| match event { - * Event::OpenChannelRequest { temporary_channel_id, counterparty_node_id, .. } => { - * if !is_trusted(counterparty_node_id) { - * match channel_manager.force_close_without_broadcasting_txn( - * &temporary_channel_id, &counterparty_node_id - * ) { - * Ok(()) => println!(\"Rejecting channel {}\", temporary_channel_id), - * Err(e) => println!(\"Error rejecting channel {}: {:?}\", temporary_channel_id, e), + * # let error_message = \"Channel force-closed\"; + * channel_manager.process_pending_events(&|event| { + * match event { + * Event::OpenChannelRequest { temporary_channel_id, counterparty_node_id, .. } => { + * if !is_trusted(counterparty_node_id) { + * match channel_manager.force_close_without_broadcasting_txn( + * &temporary_channel_id, &counterparty_node_id, error_message.to_string() + * ) { + * Ok(()) => println!(\"Rejecting channel {}\", temporary_channel_id), + * Err(e) => println!(\"Error rejecting channel {}: {:?}\", temporary_channel_id, e), + * } + * return Ok(()); * } - * return; - * } * - * let user_channel_id = 43; - * match channel_manager.accept_inbound_channel( - * &temporary_channel_id, &counterparty_node_id, user_channel_id - * ) { - * Ok(()) => println!(\"Accepting channel {}\", temporary_channel_id), - * Err(e) => println!(\"Error accepting channel {}: {:?}\", temporary_channel_id, e), - * } - * }, - * // ... - * # _ => {}, + * let user_channel_id = 43; + * match channel_manager.accept_inbound_channel( + * &temporary_channel_id, &counterparty_node_id, user_channel_id + * ) { + * Ok(()) => println!(\"Accepting channel {}\", temporary_channel_id), + * Err(e) => println!(\"Error accepting channel {}: {:?}\", temporary_channel_id, e), + * } + * }, + * // ... + * # _ => {}, + * } + * Ok(()) * }); * # } * ``` @@ -11904,13 +12695,16 @@ typedef struct LDKRouter { * } * * // On the event processing thread - * channel_manager.process_pending_events(&|event| match event { - * Event::ChannelClosed { channel_id, user_channel_id, .. } => { - * assert_eq!(user_channel_id, 42); - * println!(\"Channel {} closed\", channel_id); - * }, - * // ... - * # _ => {}, + * channel_manager.process_pending_events(&|event| { + * match event { + * Event::ChannelClosed { channel_id, user_channel_id, .. } => { + * assert_eq!(user_channel_id, 42); + * println!(\"Channel {} closed\", channel_id); + * }, + * // ... + * # _ => {}, + * } + * Ok(()) * }); * # } * ``` @@ -11960,30 +12754,33 @@ typedef struct LDKRouter { * }; * * // On the event processing thread - * channel_manager.process_pending_events(&|event| match event { - * Event::PaymentClaimable { payment_hash, purpose, .. } => match purpose { - * PaymentPurpose::Bolt11InvoicePayment { payment_preimage: Some(payment_preimage), .. } => { - * assert_eq!(payment_hash, known_payment_hash); - * println!(\"Claiming payment {}\", payment_hash); - * channel_manager.claim_funds(payment_preimage); + * channel_manager.process_pending_events(&|event| { + * match event { + * Event::PaymentClaimable { payment_hash, purpose, .. } => match purpose { + * PaymentPurpose::Bolt11InvoicePayment { payment_preimage: Some(payment_preimage), .. } => { + * assert_eq!(payment_hash, known_payment_hash); + * println!(\"Claiming payment {}\", payment_hash); + * channel_manager.claim_funds(payment_preimage); + * }, + * PaymentPurpose::Bolt11InvoicePayment { payment_preimage: None, .. } => { + * println!(\"Unknown payment hash: {}\", payment_hash); + * }, + * PaymentPurpose::SpontaneousPayment(payment_preimage) => { + * assert_ne!(payment_hash, known_payment_hash); + * println!(\"Claiming spontaneous payment {}\", payment_hash); + * channel_manager.claim_funds(payment_preimage); + * }, + * // ... + * # _ => {}, * }, - * PaymentPurpose::Bolt11InvoicePayment { payment_preimage: None, .. } => { - * println!(\"Unknown payment hash: {}\", payment_hash); - * }, - * PaymentPurpose::SpontaneousPayment(payment_preimage) => { - * assert_ne!(payment_hash, known_payment_hash); - * println!(\"Claiming spontaneous payment {}\", payment_hash); - * channel_manager.claim_funds(payment_preimage); + * Event::PaymentClaimed { payment_hash, amount_msat, .. } => { + * assert_eq!(payment_hash, known_payment_hash); + * println!(\"Claimed {} msats\", amount_msat); * }, * // ... - * # _ => {}, - * }, - * Event::PaymentClaimed { payment_hash, amount_msat, .. } => { - * assert_eq!(payment_hash, known_payment_hash); - * println!(\"Claimed {} msats\", amount_msat); - * }, - * // ... - * # _ => {}, + * # _ => {}, + * } + * Ok(()) * }); * # } * ``` @@ -12026,11 +12823,15 @@ typedef struct LDKRouter { * ); * * // On the event processing thread - * channel_manager.process_pending_events(&|event| match event { - * Event::PaymentSent { payment_hash, .. } => println!(\"Paid {}\", payment_hash), - * Event::PaymentFailed { payment_hash, .. } => println!(\"Failed paying {}\", payment_hash), - * // ... - * # _ => {}, + * channel_manager.process_pending_events(&|event| { + * match event { + * Event::PaymentSent { payment_hash, .. } => println!(\"Paid {}\", payment_hash), + * Event::PaymentFailed { payment_hash: Some(payment_hash), .. } => + * println!(\"Failed paying {}\", payment_hash), + * // ... + * # _ => {}, + * } + * Ok(()) * }); * # } * ``` @@ -12051,8 +12852,9 @@ typedef struct LDKRouter { * # * # fn example(channel_manager: T) -> Result<(), Bolt12SemanticError> { * # let channel_manager = channel_manager.get_cm(); + * # let absolute_expiry = None; * let offer = channel_manager - * .create_offer_builder()? + * .create_offer_builder(absolute_expiry)? * # ; * # // Needed for compiling for c_bindings * # let builder: lightning::offers::offer::OfferBuilder<_, _> = offer.into(); @@ -12063,31 +12865,32 @@ typedef struct LDKRouter { * let bech32_offer = offer.to_string(); * * // On the event processing thread - * channel_manager.process_pending_events(&|event| match event { - * Event::PaymentClaimable { payment_hash, purpose, .. } => match purpose { - * PaymentPurpose::Bolt12OfferPayment { payment_preimage: Some(payment_preimage), .. } => { - * println!(\"Claiming payment {}\", payment_hash); - * channel_manager.claim_funds(payment_preimage); + * channel_manager.process_pending_events(&|event| { + * match event { + * Event::PaymentClaimable { payment_hash, purpose, .. } => match purpose { + * PaymentPurpose::Bolt12OfferPayment { payment_preimage: Some(payment_preimage), .. } => { + * println!(\"Claiming payment {}\", payment_hash); + * channel_manager.claim_funds(payment_preimage); + * }, + * PaymentPurpose::Bolt12OfferPayment { payment_preimage: None, .. } => { + * println!(\"Unknown payment hash: {}\", payment_hash); + * } + * # _ => {}, * }, - * PaymentPurpose::Bolt12OfferPayment { payment_preimage: None, .. } => { - * println!(\"Unknown payment hash: {}\", payment_hash); + * Event::PaymentClaimed { payment_hash, amount_msat, .. } => { + * println!(\"Claimed {} msats\", amount_msat); * }, * // ... - * # _ => {}, - * }, - * Event::PaymentClaimed { payment_hash, amount_msat, .. } => { - * println!(\"Claimed {} msats\", amount_msat); - * }, - * // ... - * # _ => {}, + * # _ => {}, + * } + * Ok(()) * }); * # Ok(()) * # } * ``` * * Use [`pay_for_offer`] to initiated payment, which sends an [`InvoiceRequest`] for an [`Offer`] - * and pays the [`Bolt12Invoice`] response. In addition to success and failure events, - * [`ChannelManager`] may also generate an [`Event::InvoiceRequestFailed`]. + * and pays the [`Bolt12Invoice`] response. * * ``` * # use lightning::events::{Event, EventsProvider}; @@ -12125,12 +12928,14 @@ typedef struct LDKRouter { * ); * * // On the event processing thread - * channel_manager.process_pending_events(&|event| match event { - * Event::PaymentSent { payment_id: Some(payment_id), .. } => println!(\"Paid {}\", payment_id), - * Event::PaymentFailed { payment_id, .. } => println!(\"Failed paying {}\", payment_id), - * Event::InvoiceRequestFailed { payment_id, .. } => println!(\"Failed paying {}\", payment_id), - * // ... - * # _ => {}, + * channel_manager.process_pending_events(&|event| { + * match event { + * Event::PaymentSent { payment_id: Some(payment_id), .. } => println!(\"Paid {}\", payment_id), + * Event::PaymentFailed { payment_id, .. } => println!(\"Failed paying {}\", payment_id), + * // ... + * # _ => {}, + * } + * Ok(()) * }); * # } * ``` @@ -12185,11 +12990,14 @@ typedef struct LDKRouter { * ); * * // On the event processing thread - * channel_manager.process_pending_events(&|event| match event { - * Event::PaymentSent { payment_id: Some(payment_id), .. } => println!(\"Paid {}\", payment_id), - * Event::PaymentFailed { payment_id, .. } => println!(\"Failed paying {}\", payment_id), - * // ... - * # _ => {}, + * channel_manager.process_pending_events(&|event| { + * match event { + * Event::PaymentSent { payment_id: Some(payment_id), .. } => println!(\"Paid {}\", payment_id), + * Event::PaymentFailed { payment_id, .. } => println!(\"Failed paying {}\", payment_id), + * // ... + * # _ => {}, + * } + * Ok(()) * }); * # Ok(()) * # } @@ -12215,18 +13023,19 @@ typedef struct LDKRouter { * }; * * // On the event processing thread - * channel_manager.process_pending_events(&|event| match event { - * Event::PaymentClaimable { payment_hash, purpose, .. } => match purpose { - * \tPaymentPurpose::Bolt12RefundPayment { payment_preimage: Some(payment_preimage), .. } => { - * assert_eq!(payment_hash, known_payment_hash); - * println!(\"Claiming payment {}\", payment_hash); - * channel_manager.claim_funds(payment_preimage); - * }, - * \tPaymentPurpose::Bolt12RefundPayment { payment_preimage: None, .. } => { - * println!(\"Unknown payment hash: {}\", payment_hash); - * \t}, - * // ... - * # _ => {}, + * channel_manager.process_pending_events(&|event| { + * match event { + * Event::PaymentClaimable { payment_hash, purpose, .. } => match purpose { + * PaymentPurpose::Bolt12RefundPayment { payment_preimage: Some(payment_preimage), .. } => { + * assert_eq!(payment_hash, known_payment_hash); + * println!(\"Claiming payment {}\", payment_hash); + * channel_manager.claim_funds(payment_preimage); + * }, + * PaymentPurpose::Bolt12RefundPayment { payment_preimage: None, .. } => { + * println!(\"Unknown payment hash: {}\", payment_hash); + * }, + * // ... + * # _ => {}, * }, * Event::PaymentClaimed { payment_hash, amount_msat, .. } => { * assert_eq!(payment_hash, known_payment_hash); @@ -12234,6 +13043,8 @@ typedef struct LDKRouter { * }, * // ... * # _ => {}, + * } + * Ok(()) * }); * # } * ``` @@ -12407,17 +13218,17 @@ typedef enum LDKMaxDustHTLCExposure_Tag { */ LDKMaxDustHTLCExposure_FixedLimitMsat, /** - * This sets a multiplier on the [`ConfirmationTarget::OnChainSweep`] feerate (in sats/KW) to - * determine the maximum allowed dust exposure. If this variant is used then the maximum dust - * exposure in millisatoshis is calculated as: + * This sets a multiplier on the [`ConfirmationTarget::MaximumFeeEstimate`] feerate (in + * sats/KW) to determine the maximum allowed dust exposure. If this variant is used then the + * maximum dust exposure in millisatoshis is calculated as: * `feerate_per_kw * value`. For example, with our default value * `FeeRateMultiplier(10_000)`: * * - 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 * 10_000 = 2,530,000 msats. + * defaults to 253 sats/KW for rounding, see [`FeeEstimator`]), the max dust exposure would + * be 253 * 10_000 = 2,530,000 msats. * - For a fee rate of 30 sat/vByte (7500 sat/KW), the max dust exposure would be - * 7500 * 50_000 = 75,000,000 msats (0.00075 BTC). + * 7500 * 50_000 = 75,000,000 msats (0.00075 BTC). * * 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, @@ -12432,7 +13243,7 @@ typedef enum LDKMaxDustHTLCExposure_Tag { * by default this will be set to a [`Self::FixedLimitMsat`] of 5,000,000 msat. * * [`FeeEstimator`]: crate::chain::chaininterface::FeeEstimator - * [`ConfirmationTarget::OnChainSweep`]: crate::chain::chaininterface::ConfirmationTarget::OnChainSweep + * [`ConfirmationTarget::MaximumFeeEstimate`]: crate::chain::chaininterface::ConfirmationTarget::MaximumFeeEstimate */ LDKMaxDustHTLCExposure_FeeRateMultiplier, /** @@ -12827,6 +13638,62 @@ typedef struct LDKCVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZZ { uintptr_t datalen; } LDKCVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZZ; + + +/** + * An error type that may be returned to LDK in order to safely abort event handling if it can't + * currently succeed (e.g., due to a persistence failure). + * + * Depending on the type, LDK may ensure the event is persisted and will eventually be replayed. + * Please refer to the documentation of each [`Event`] variant for more details. + */ +typedef struct MUST_USE_STRUCT LDKReplayEvent { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeReplayEvent *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; +} LDKReplayEvent; + +/** + * The contents of CResult_NoneReplayEventZ + */ +typedef union LDKCResult_NoneReplayEventZPtr { + /** + * 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 LDKReplayEvent *err; +} LDKCResult_NoneReplayEventZPtr; + +/** + * A CResult_NoneReplayEventZ represents the result of a fallible operation, + * containing a () on success and a crate::lightning::events::ReplayEvent on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_NoneReplayEventZ { + /** + * The contents of this CResult_NoneReplayEventZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_NoneReplayEventZPtr contents; + /** + * Whether this CResult_NoneReplayEventZ represents a success state. + */ + bool result_ok; +} LDKCResult_NoneReplayEventZ; + /** * A dynamically-allocated array of crate::lightning::ln::chan_utils::CommitmentTransactions of arbitrary size. * This corresponds to std::vector in C++ @@ -12963,6 +13830,59 @@ typedef struct LDKBalance_LDKClaimableOnChannelClose_Body { * required to do so. */ uint64_t amount_satoshis; + /** + * The transaction fee we pay for the closing commitment transaction. This amount is not + * included in the [`Balance::ClaimableOnChannelClose::amount_satoshis`] value. + * + * Note that if this channel is inbound (and thus our counterparty pays the commitment + * transaction fee) this value will be zero. For [`ChannelMonitor`]s created prior to LDK + * 0.0.124, the channel is always treated as outbound (and thus this value is never zero). + */ + uint64_t transaction_fee_satoshis; + /** + * The amount of millisatoshis which has been burned to fees from HTLCs which are outbound + * from us and are related to a payment which was sent by us. This is the sum of the + * millisatoshis part of all HTLCs which are otherwise represented by + * [`Balance::MaybeTimeoutClaimableHTLC`] with their + * [`Balance::MaybeTimeoutClaimableHTLC::outbound_payment`] flag set, as well as any dust + * HTLCs which would otherwise be represented the same. + * + * This amount (rounded up to a whole satoshi value) will not be included in `amount_satoshis`. + */ + uint64_t outbound_payment_htlc_rounded_msat; + /** + * The amount of millisatoshis which has been burned to fees from HTLCs which are outbound + * from us and are related to a forwarded HTLC. This is the sum of the millisatoshis part + * of all HTLCs which are otherwise represented by [`Balance::MaybeTimeoutClaimableHTLC`] + * with their [`Balance::MaybeTimeoutClaimableHTLC::outbound_payment`] flag *not* set, as + * well as any dust HTLCs which would otherwise be represented the same. + * + * This amount (rounded up to a whole satoshi value) will not be included in `amount_satoshis`. + */ + uint64_t outbound_forwarded_htlc_rounded_msat; + /** + * The amount of millisatoshis which has been burned to fees from HTLCs which are inbound + * to us and for which we know the preimage. This is the sum of the millisatoshis part of + * all HTLCs which would be represented by [`Balance::ContentiousClaimable`] on channel + * close, but whose current value is included in + * [`Balance::ClaimableOnChannelClose::amount_satoshis`], as well as any dust HTLCs which + * would otherwise be represented the same. + * + * This amount (rounded up to a whole satoshi value) will not be included in the counterparty's + * `amount_satoshis`. + */ + uint64_t inbound_claiming_htlc_rounded_msat; + /** + * The amount of millisatoshis which has been burned to fees from HTLCs which are inbound + * to us and for which we do not know the preimage. This is the sum of the millisatoshis + * part of all HTLCs which would be represented by [`Balance::MaybePreimageClaimableHTLC`] + * on channel close, as well as any dust HTLCs which would otherwise be represented the + * same. + * + * This amount (rounded up to a whole satoshi value) will not be included in the counterparty's + * `amount_satoshis`. + */ + uint64_t inbound_htlc_rounded_msat; } LDKBalance_LDKClaimableOnChannelClose_Body; typedef struct LDKBalance_LDKClaimableAwaitingConfirmations_Body { @@ -12976,6 +13896,10 @@ typedef struct LDKBalance_LDKClaimableAwaitingConfirmations_Body { * amount. */ uint32_t confirmation_height; + /** + * Whether this balance is a result of cooperative close, a force-close, or an HTLC. + */ + enum LDKBalanceSource source; } LDKBalance_LDKClaimableAwaitingConfirmations_Body; typedef struct LDKBalance_LDKContentiousClaimable_Body { @@ -13014,6 +13938,12 @@ typedef struct LDKBalance_LDKMaybeTimeoutClaimableHTLC_Body { * The payment hash whose preimage our counterparty needs to claim this HTLC. */ struct LDKThirtyTwoBytes payment_hash; + /** + * Whether this HTLC represents a payment which was sent outbound from us. Otherwise it + * represents an HTLC which was forwarded (and should, thus, have a corresponding inbound + * edge on another channel). + */ + bool outbound_payment; } LDKBalance_LDKMaybeTimeoutClaimableHTLC_Body; typedef struct LDKBalance_LDKMaybePreimageClaimableHTLC_Body { @@ -13184,36 +14114,6 @@ typedef struct LDKCVec_C2Tuple_PublicKeyTypeZZ { uintptr_t datalen; } LDKCVec_C2Tuple_PublicKeyTypeZZ; -/** - * A tuple of 2 elements. See the individual fields for the types contained. - */ -typedef struct LDKC2Tuple_PublicKeyCVec_SocketAddressZZ { - /** - * The element at position 0 - */ - struct LDKPublicKey a; - /** - * The element at position 1 - */ - struct LDKCVec_SocketAddressZ b; -} LDKC2Tuple_PublicKeyCVec_SocketAddressZZ; - -/** - * A dynamically-allocated array of crate::c_types::derived::C2Tuple_PublicKeyCVec_SocketAddressZZs of arbitrary size. - * This corresponds to std::vector in C++ - */ -typedef struct LDKCVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ { - /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - */ - struct LDKC2Tuple_PublicKeyCVec_SocketAddressZZ *data; - /** - * The number of elements pointed to by `data`. - */ - uintptr_t datalen; -} LDKCVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ; - /** * The contents of an onion message. */ @@ -13227,6 +14127,10 @@ typedef struct LDKOnionMessageContents { * Returns the TLV type identifying the message contents. MUST be >= 64. */ uint64_t (*tlv_type)(const void *this_arg); + /** + * Returns the message type + */ + struct LDKStr (*msg_type)(const void *this_arg); /** * Serialize the object into a byte array */ @@ -13248,6 +14152,47 @@ typedef struct LDKOnionMessageContents { void (*free)(void *this_arg); } LDKOnionMessageContents; +/** + * A tuple of 2 elements. See the individual fields for the types contained. + */ +typedef struct LDKC2Tuple_OnionMessageContentsResponseInstructionZ { + /** + * The element at position 0 + */ + struct LDKOnionMessageContents a; + /** + * The element at position 1 + */ + struct LDKResponseInstruction b; +} LDKC2Tuple_OnionMessageContentsResponseInstructionZ; + +/** + * An enum which can either contain a crate::c_types::derived::C2Tuple_OnionMessageContentsResponseInstructionZ or not + */ +typedef enum LDKCOption_C2Tuple_OnionMessageContentsResponseInstructionZZ_Tag { + /** + * When we're in this state, this COption_C2Tuple_OnionMessageContentsResponseInstructionZZ contains a crate::c_types::derived::C2Tuple_OnionMessageContentsResponseInstructionZ + */ + LDKCOption_C2Tuple_OnionMessageContentsResponseInstructionZZ_Some, + /** + * When we're in this state, this COption_C2Tuple_OnionMessageContentsResponseInstructionZZ contains nothing + */ + LDKCOption_C2Tuple_OnionMessageContentsResponseInstructionZZ_None, + /** + * Must be last for serialization purposes + */ + LDKCOption_C2Tuple_OnionMessageContentsResponseInstructionZZ_Sentinel, +} LDKCOption_C2Tuple_OnionMessageContentsResponseInstructionZZ_Tag; + +typedef struct LDKCOption_C2Tuple_OnionMessageContentsResponseInstructionZZ { + LDKCOption_C2Tuple_OnionMessageContentsResponseInstructionZZ_Tag tag; + union { + struct { + struct LDKC2Tuple_OnionMessageContentsResponseInstructionZ some; + }; + }; +} LDKCOption_C2Tuple_OnionMessageContentsResponseInstructionZZ; + /** * An enum which can either contain a crate::lightning::onion_message::packet::OnionMessageContents or not */ @@ -13309,9 +14254,9 @@ typedef struct LDKCResult_COption_OnionMessageContentsZDecodeErrorZ { } LDKCResult_COption_OnionMessageContentsZDecodeErrorZ; /** - * A tuple of 3 elements. See the individual fields for the types contained. + * A tuple of 2 elements. See the individual fields for the types contained. */ -typedef struct LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ { +typedef struct LDKC2Tuple_OnionMessageContentsMessageSendInstructionsZ { /** * The element at position 0 */ @@ -13319,28 +14264,24 @@ typedef struct LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ { /** * The element at position 1 */ - struct LDKDestination b; - /** - * The element at position 2 - */ - struct LDKBlindedPath c; -} LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ; + struct LDKMessageSendInstructions b; +} LDKC2Tuple_OnionMessageContentsMessageSendInstructionsZ; /** - * A dynamically-allocated array of crate::c_types::derived::C3Tuple_OnionMessageContentsDestinationBlindedPathZs of arbitrary size. + * A dynamically-allocated array of crate::c_types::derived::C2Tuple_OnionMessageContentsMessageSendInstructionsZs of arbitrary size. * This corresponds to std::vector in C++ */ -typedef struct LDKCVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ { +typedef struct LDKCVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ { /** * The elements in the array. * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - struct LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ *data; + struct LDKC2Tuple_OnionMessageContentsMessageSendInstructionsZ *data; /** * The number of elements pointed to by `data`. */ uintptr_t datalen; -} LDKCVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ; +} LDKCVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ; /** * An enum which can either contain a crate::lightning::ln::wire::Type or not @@ -13683,22 +14624,6 @@ typedef struct LDKCResult_CVec_u8ZIOErrorZ { bool result_ok; } LDKCResult_CVec_u8ZIOErrorZ; -/** - * A dynamically-allocated array of crate::c_types::Strs of arbitrary size. - * This corresponds to std::vector in C++ - */ -typedef struct LDKCVec_StrZ { - /** - * 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_StrZ; - /** * The contents of CResult_CVec_StrZIOErrorZ */ @@ -13880,43 +14805,6 @@ typedef struct LDKCResult_InvoiceRequestBolt12SemanticErrorZ { bool result_ok; } LDKCResult_InvoiceRequestBolt12SemanticErrorZ; -/** - * 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; - -/** - * An enum which can either contain a crate::c_types::SecretKey or not - */ -typedef enum LDKCOption_SecretKeyZ_Tag { - /** - * When we're in this state, this COption_SecretKeyZ contains a crate::c_types::SecretKey - */ - LDKCOption_SecretKeyZ_Some, - /** - * When we're in this state, this COption_SecretKeyZ contains nothing - */ - LDKCOption_SecretKeyZ_None, - /** - * Must be last for serialization purposes - */ - LDKCOption_SecretKeyZ_Sentinel, -} LDKCOption_SecretKeyZ_Tag; - -typedef struct LDKCOption_SecretKeyZ { - LDKCOption_SecretKeyZ_Tag tag; - union { - struct { - struct LDKSecretKey some; - }; - }; -} LDKCOption_SecretKeyZ; - /** @@ -13981,8 +14869,9 @@ typedef struct LDKCResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticE /** - * An [`InvoiceRequest`] that has been verified by [`InvoiceRequest::verify`] and exposes different - * ways to respond depending on whether the signing keys were derived. + * An [`InvoiceRequest`] that has been verified by [`InvoiceRequest::verify_using_metadata`] or + * [`InvoiceRequest::verify_using_recipient_data`] and exposes different ways to respond depending + * on whether the signing keys were derived. */ typedef struct MUST_USE_STRUCT LDKVerifiedInvoiceRequest { /** @@ -14535,37 +15424,37 @@ typedef struct LDKCResult_StfuDecodeErrorZ { } LDKCResult_StfuDecodeErrorZ; /** - * The contents of CResult_SpliceDecodeErrorZ + * The contents of CResult_SpliceInitDecodeErrorZ */ -typedef union LDKCResult_SpliceDecodeErrorZPtr { +typedef union LDKCResult_SpliceInitDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKSplice *result; + struct LDKSpliceInit *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_SpliceDecodeErrorZPtr; +} LDKCResult_SpliceInitDecodeErrorZPtr; /** - * A CResult_SpliceDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::Splice on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_SpliceInitDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::SpliceInit 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_SpliceDecodeErrorZ { +typedef struct LDKCResult_SpliceInitDecodeErrorZ { /** - * The contents of this CResult_SpliceDecodeErrorZ, accessible via either + * The contents of this CResult_SpliceInitDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_SpliceDecodeErrorZPtr contents; + union LDKCResult_SpliceInitDecodeErrorZPtr contents; /** - * Whether this CResult_SpliceDecodeErrorZ represents a success state. + * Whether this CResult_SpliceInitDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_SpliceDecodeErrorZ; +} LDKCResult_SpliceInitDecodeErrorZ; /** * The contents of CResult_SpliceAckDecodeErrorZ @@ -15087,6 +15976,59 @@ typedef struct LDKCResult_ClosingSignedFeeRangeDecodeErrorZ { +/** + * Optional batch parameters for `commitment_signed` message. + */ +typedef struct MUST_USE_STRUCT LDKCommitmentSignedBatch { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeCommitmentSignedBatch *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; +} LDKCommitmentSignedBatch; + +/** + * The contents of CResult_CommitmentSignedBatchDecodeErrorZ + */ +typedef union LDKCResult_CommitmentSignedBatchDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKCommitmentSignedBatch *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_CommitmentSignedBatchDecodeErrorZPtr; + +/** + * A CResult_CommitmentSignedBatchDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::CommitmentSignedBatch 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_CommitmentSignedBatchDecodeErrorZ { + /** + * The contents of this CResult_CommitmentSignedBatchDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_CommitmentSignedBatchDecodeErrorZPtr contents; + /** + * Whether this CResult_CommitmentSignedBatchDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_CommitmentSignedBatchDecodeErrorZ; + + + /** * A [`commitment_signed`] message to be sent to or received from a peer. * @@ -16297,110 +17239,6 @@ typedef struct LDKCResult_GossipTimestampFilterDecodeErrorZ { bool result_ok; } LDKCResult_GossipTimestampFilterDecodeErrorZ; -/** - * A dynamically-allocated array of crate::lightning::ln::channelmanager::PhantomRouteHintss of arbitrary size. - * This corresponds to std::vector in C++ - */ -typedef struct LDKCVec_PhantomRouteHintsZ { - /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - */ - struct LDKPhantomRouteHints *data; - /** - * The number of elements pointed to by `data`. - */ - uintptr_t datalen; -} LDKCVec_PhantomRouteHintsZ; - - - -/** - * 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 MUST_USE_STRUCT LDKBolt11Invoice { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeBolt11Invoice *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; -} LDKBolt11Invoice; - -/** - * When signing using a fallible method either an user-supplied `SignError` or a [`CreationError`] - * may occur. - */ -typedef enum LDKSignOrCreationError_Tag { - /** - * An error occurred during signing - */ - LDKSignOrCreationError_SignError, - /** - * An error occurred while building the transaction - */ - LDKSignOrCreationError_CreationError, - /** - * Must be last for serialization purposes - */ - LDKSignOrCreationError_Sentinel, -} LDKSignOrCreationError_Tag; - -typedef struct MUST_USE_STRUCT LDKSignOrCreationError { - LDKSignOrCreationError_Tag tag; - union { - struct { - enum LDKCreationError creation_error; - }; - }; -} LDKSignOrCreationError; - -/** - * The contents of CResult_Bolt11InvoiceSignOrCreationErrorZ - */ -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. - */ - struct LDKBolt11Invoice *result; - /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. - */ - struct LDKSignOrCreationError *err; -} LDKCResult_Bolt11InvoiceSignOrCreationErrorZPtr; - -/** - * 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_Bolt11InvoiceSignOrCreationErrorZ { - /** - * The contents of this CResult_Bolt11InvoiceSignOrCreationErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. - */ - union LDKCResult_Bolt11InvoiceSignOrCreationErrorZPtr contents; - /** - * Whether this CResult_Bolt11InvoiceSignOrCreationErrorZ represents a success state. - */ - bool result_ok; -} LDKCResult_Bolt11InvoiceSignOrCreationErrorZ; - /** * An enum which can either contain a crate::lightning::ln::channel_state::InboundHTLCStateDetails or not */ @@ -16895,6 +17733,105 @@ typedef struct LDKCVec_FutureZ { uintptr_t datalen; } LDKCVec_FutureZ; +/** + * The contents of CResult_HeldHtlcAvailableDecodeErrorZ + */ +typedef union LDKCResult_HeldHtlcAvailableDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKHeldHtlcAvailable *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_HeldHtlcAvailableDecodeErrorZPtr; + +/** + * A CResult_HeldHtlcAvailableDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::onion_message::async_payments::HeldHtlcAvailable 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_HeldHtlcAvailableDecodeErrorZ { + /** + * The contents of this CResult_HeldHtlcAvailableDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_HeldHtlcAvailableDecodeErrorZPtr contents; + /** + * Whether this CResult_HeldHtlcAvailableDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_HeldHtlcAvailableDecodeErrorZ; + +/** + * The contents of CResult_ReleaseHeldHtlcDecodeErrorZ + */ +typedef union LDKCResult_ReleaseHeldHtlcDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKReleaseHeldHtlc *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_ReleaseHeldHtlcDecodeErrorZPtr; + +/** + * A CResult_ReleaseHeldHtlcDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::onion_message::async_payments::ReleaseHeldHtlc 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_ReleaseHeldHtlcDecodeErrorZ { + /** + * The contents of this CResult_ReleaseHeldHtlcDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_ReleaseHeldHtlcDecodeErrorZPtr contents; + /** + * Whether this CResult_ReleaseHeldHtlcDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_ReleaseHeldHtlcDecodeErrorZ; + +/** + * The contents of CResult_AsyncPaymentsMessageDecodeErrorZ + */ +typedef union LDKCResult_AsyncPaymentsMessageDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKAsyncPaymentsMessage *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_AsyncPaymentsMessageDecodeErrorZPtr; + +/** + * A CResult_AsyncPaymentsMessageDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::onion_message::async_payments::AsyncPaymentsMessage 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_AsyncPaymentsMessageDecodeErrorZ { + /** + * The contents of this CResult_AsyncPaymentsMessageDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_AsyncPaymentsMessageDecodeErrorZPtr contents; + /** + * Whether this CResult_AsyncPaymentsMessageDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_AsyncPaymentsMessageDecodeErrorZ; + /** * The contents of CResult_OffersMessageDecodeErrorZ */ @@ -17605,6 +18542,86 @@ typedef struct LDKCResult_ShutdownScriptInvalidShutdownScriptZ { bool result_ok; } LDKCResult_ShutdownScriptInvalidShutdownScriptZ; +/** + * `FundingInfo` holds information about a channel's funding transaction. + * + * When LDK is set to manual propagation of the funding transaction + * (via [`ChannelManager::unsafe_manual_funding_transaction_generated`), + * LDK does not have the full transaction data. Instead, the `OutPoint` + * for the funding is provided here. + * + * [`ChannelManager::unsafe_manual_funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::unsafe_manual_funding_transaction_generated + */ +typedef enum LDKFundingInfo_Tag { + /** + * The full funding `Transaction`. + */ + LDKFundingInfo_Tx, + /** + * The `OutPoint` of the funding. + */ + LDKFundingInfo_OutPoint, + /** + * Must be last for serialization purposes + */ + LDKFundingInfo_Sentinel, +} LDKFundingInfo_Tag; + +typedef struct LDKFundingInfo_LDKTx_Body { + /** + * The funding transaction + */ + struct LDKTransaction transaction; +} LDKFundingInfo_LDKTx_Body; + +typedef struct LDKFundingInfo_LDKOutPoint_Body { + /** + * The outpoint of the funding + */ + struct LDKOutPoint outpoint; +} LDKFundingInfo_LDKOutPoint_Body; + +typedef struct MUST_USE_STRUCT LDKFundingInfo { + LDKFundingInfo_Tag tag; + union { + LDKFundingInfo_LDKTx_Body tx; + LDKFundingInfo_LDKOutPoint_Body out_point; + }; +} LDKFundingInfo; + +/** + * The contents of CResult_FundingInfoDecodeErrorZ + */ +typedef union LDKCResult_FundingInfoDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKFundingInfo *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_FundingInfoDecodeErrorZPtr; + +/** + * A CResult_FundingInfoDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::events::FundingInfo 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_FundingInfoDecodeErrorZ { + /** + * The contents of this CResult_FundingInfoDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_FundingInfoDecodeErrorZPtr contents; + /** + * Whether this CResult_FundingInfoDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_FundingInfoDecodeErrorZ; + /** * 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. @@ -18128,37 +19145,64 @@ typedef struct LDKCResult_COption_HTLCDestinationZDecodeErrorZ { } LDKCResult_COption_HTLCDestinationZDecodeErrorZ; /** - * The contents of CResult_PaymentFailureReasonDecodeErrorZ + * An enum which can either contain a crate::lightning::events::PaymentFailureReason or not + */ +typedef enum LDKCOption_PaymentFailureReasonZ_Tag { + /** + * 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 + */ + 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; + +/** + * The contents of CResult_COption_PaymentFailureReasonZDecodeErrorZ */ -typedef union LDKCResult_PaymentFailureReasonDecodeErrorZPtr { +typedef union LDKCResult_COption_PaymentFailureReasonZDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - enum LDKPaymentFailureReason *result; + struct LDKCOption_PaymentFailureReasonZ *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_PaymentFailureReasonDecodeErrorZPtr; +} LDKCResult_COption_PaymentFailureReasonZDecodeErrorZPtr; /** - * 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_COption_PaymentFailureReasonZDecodeErrorZ represents the result of a fallible operation, + * containing a crate::c_types::derived::COption_PaymentFailureReasonZ 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_PaymentFailureReasonDecodeErrorZ { +typedef struct LDKCResult_COption_PaymentFailureReasonZDecodeErrorZ { /** - * The contents of this CResult_PaymentFailureReasonDecodeErrorZ, accessible via either + * The contents of this CResult_COption_PaymentFailureReasonZDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_PaymentFailureReasonDecodeErrorZPtr contents; + union LDKCResult_COption_PaymentFailureReasonZDecodeErrorZPtr contents; /** - * Whether this CResult_PaymentFailureReasonDecodeErrorZ represents a success state. + * Whether this CResult_COption_PaymentFailureReasonZDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_PaymentFailureReasonDecodeErrorZ; +} LDKCResult_COption_PaymentFailureReasonZDecodeErrorZ; /** * An enum which can either contain a crate::c_types::U128 or not @@ -18203,32 +19247,47 @@ typedef struct LDKCVec_ClaimedHTLCZ { uintptr_t datalen; } LDKCVec_ClaimedHTLCZ; + + /** - * An enum which can either contain a crate::lightning::events::PaymentFailureReason or not + * The `Responder` struct creates an appropriate [`ResponseInstruction`] for responding to a + * message. */ -typedef enum LDKCOption_PaymentFailureReasonZ_Tag { +typedef struct MUST_USE_STRUCT LDKResponder { /** - * When we're in this state, this COption_PaymentFailureReasonZ contains a crate::lightning::events::PaymentFailureReason + * A pointer to the opaque Rust object. + * Nearly everywhere, 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_Some, + LDKnativeResponder *inner; /** - * When we're in this state, this COption_PaymentFailureReasonZ contains nothing + * Indicates that this is the only struct which contains the same pointer. + * Rust 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_None, + bool is_owned; +} LDKResponder; + + + +/** + * A subset of [`CommonOpenChannelFields`], containing various parameters which are set by the + * channel initiator and which are not part of the channel funding transaction. + */ +typedef struct MUST_USE_STRUCT LDKChannelParameters { /** - * 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. */ - LDKCOption_PaymentFailureReasonZ_Sentinel, -} LDKCOption_PaymentFailureReasonZ_Tag; - -typedef struct LDKCOption_PaymentFailureReasonZ { - LDKCOption_PaymentFailureReasonZ_Tag tag; - union { - struct { - enum LDKPaymentFailureReason some; - }; - }; -} LDKCOption_PaymentFailureReasonZ; + LDKnativeChannelParameters *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; +} LDKChannelParameters; @@ -18435,10 +19494,29 @@ typedef enum LDKEvent_Tag { * Note that *all inputs* in the funding transaction must spend SegWit outputs or your * counterparty can steal your funds! * + * # Failure Behavior and Persistence + * This event will eventually be replayed after failures-to-handle (i.e., the event handler + * returning `Err(ReplayEvent ())`), but won't be persisted across restarts. + * * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager * [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated */ LDKEvent_FundingGenerationReady, + /** + * Used to indicate that the counterparty node has provided the signature(s) required to + * recover our funds in case they go offline. + * + * It is safe (and your responsibility) to broadcast the funding transaction upon receiving this + * event. + * + * This event is only emitted if you called + * [`ChannelManager::unsafe_manual_funding_transaction_generated`] instead of + * [`ChannelManager::funding_transaction_generated`]. + * + * [`ChannelManager::unsafe_manual_funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::unsafe_manual_funding_transaction_generated + * [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated + */ + LDKEvent_FundingTxBroadcastSafe, /** * 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`]. @@ -18469,6 +19547,10 @@ typedef enum LDKEvent_Tag { * # Note * This event used to be called `PaymentReceived` in LDK versions 0.0.112 and earlier. * + * # Failure Behavior and Persistence + * This event will eventually be replayed after failures-to-handle (i.e., the event handler + * returning `Err(ReplayEvent ())`) and will be persisted across restarts. + * * [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds * [`ChannelManager::claim_funds_with_known_custom_tlvs`]: crate::ln::channelmanager::ChannelManager::claim_funds_with_known_custom_tlvs * [`FailureCode::InvalidOnionPayload`]: crate::ln::channelmanager::FailureCode::InvalidOnionPayload @@ -18490,6 +19572,10 @@ typedef enum LDKEvent_Tag { * [`ChannelManager::claim_funds`] twice for the same [`Event::PaymentClaimable`] you may get * multiple `PaymentClaimed` events. * + * # Failure Behavior and Persistence + * This event will eventually be replayed after failures-to-handle (i.e., the event handler + * returning `Err(ReplayEvent ())`) and will be persisted across restarts. + * * [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds */ LDKEvent_PaymentClaimed, @@ -18503,6 +19589,11 @@ typedef enum LDKEvent_Tag { * This event will not be generated for onion message forwards; only for sends including * replies. Handlers should connect to the node otherwise any buffered messages may be lost. * + * # Failure Behavior and Persistence + * This event won't be replayed after failures-to-handle + * (i.e., the event handler returning `Err(ReplayEvent ())`), and also won't be persisted + * across restarts. + * * [`OnionMessage`]: msgs::OnionMessage * [`MessageRouter`]: crate::onion_message::messenger::MessageRouter * [`Destination`]: crate::onion_message::messenger::Destination @@ -18510,22 +19601,35 @@ typedef enum LDKEvent_Tag { */ LDKEvent_ConnectionNeeded, /** - * Indicates a request for an invoice failed to yield a response in a reasonable amount of time - * or was explicitly abandoned by [`ChannelManager::abandon_payment`]. This may be for an - * [`InvoiceRequest`] sent for an [`Offer`] or for a [`Refund`] that hasn't been redeemed. + * Indicates a [`Bolt12Invoice`] in response to an [`InvoiceRequest`] or a [`Refund`] was + * received. + * + * This event will only be generated if [`UserConfig::manually_handle_bolt12_invoices`] is set. + * Use [`ChannelManager::send_payment_for_bolt12_invoice`] to pay the invoice or + * [`ChannelManager::abandon_payment`] to abandon the associated payment. See those docs for + * further details. + * + * # Failure Behavior and Persistence + * This event will eventually be replayed after failures-to-handle (i.e., the event handler + * returning `Err(ReplayEvent ())`) and will be persisted across restarts. * - * [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest - * [`Offer`]: crate::offers::offer::Offer * [`Refund`]: crate::offers::refund::Refund + * [`UserConfig::manually_handle_bolt12_invoices`]: crate::util::config::UserConfig::manually_handle_bolt12_invoices + * [`ChannelManager::send_payment_for_bolt12_invoice`]: crate::ln::channelmanager::ChannelManager::send_payment_for_bolt12_invoice + * [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment */ - LDKEvent_InvoiceRequestFailed, + LDKEvent_InvoiceReceived, /** * 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. + * + * # Failure Behavior and Persistence + * This event will eventually be replayed after failures-to-handle (i.e., the event handler + * returning `Err(ReplayEvent ())`) and will be persisted across restarts. */ LDKEvent_PaymentSent, /** @@ -18541,6 +19645,10 @@ typedef enum LDKEvent_Tag { * received and processed. In this case, the [`Event::PaymentFailed`] event MUST be ignored, * and the payment MUST be treated as having succeeded. * + * # Failure Behavior and Persistence + * This event will eventually be replayed after failures-to-handle (i.e., the event handler + * returning `Err(ReplayEvent ())`) and will be persisted across restarts. + * * [`Retry`]: crate::ln::channelmanager::Retry * [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment */ @@ -18550,6 +19658,10 @@ typedef enum LDKEvent_Tag { * * Always generated after [`Event::PaymentSent`] and thus useful for scoring channels. See * [`Event::PaymentSent`] for obtaining the payment preimage. + * + * # Failure Behavior and Persistence + * This event will eventually be replayed after failures-to-handle (i.e., the event handler + * returning `Err(ReplayEvent ())`) and will be persisted across restarts. */ LDKEvent_PaymentPathSuccessful, /** @@ -18562,21 +19674,37 @@ typedef enum LDKEvent_Tag { * See [`ChannelManager::abandon_payment`] for giving up on this payment before its retries have * been exhausted. * + * # Failure Behavior and Persistence + * This event will eventually be replayed after failures-to-handle (i.e., the event handler + * returning `Err(ReplayEvent ())`) and will be persisted across restarts. + * * [`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. + * + * # Failure Behavior and Persistence + * This event will eventually be replayed after failures-to-handle (i.e., the event handler + * returning `Err(ReplayEvent ())`) and will be persisted across restarts. */ LDKEvent_ProbeSuccessful, /** * Indicates that a probe payment we sent failed at an intermediary node on the path. + * + * # Failure Behavior and Persistence + * This event will eventually be replayed after failures-to-handle (i.e., the event handler + * returning `Err(ReplayEvent ())`) and will be persisted across restarts. */ LDKEvent_ProbeFailed, /** * Used to indicate that [`ChannelManager::process_pending_htlc_forwards`] should be called at * a time in the future. * + * # Failure Behavior and Persistence + * This event will eventually be replayed after failures-to-handle (i.e., the event handler + * returning `Err(ReplayEvent ())`) and will be regenerated after restarts. + * * [`ChannelManager::process_pending_htlc_forwards`]: crate::ln::channelmanager::ChannelManager::process_pending_htlc_forwards */ LDKEvent_PendingHTLCsForwardable, @@ -18589,6 +19717,10 @@ typedef enum LDKEvent_Tag { * [`ChannelManager::fail_intercepted_htlc`] MUST be called in response to this event. See * their docs for more information. * + * # Failure Behavior and Persistence + * This event will eventually be replayed after failures-to-handle (i.e., the event handler + * returning `Err(ReplayEvent ())`) and will be persisted across restarts. + * * [`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 @@ -18606,12 +19738,20 @@ typedef enum LDKEvent_Tag { * You may hand them to the [`OutputSweeper`] utility which will store and (re-)generate spending * transactions for you. * + * # Failure Behavior and Persistence + * This event will eventually be replayed after failures-to-handle (i.e., the event handler + * returning `Err(ReplayEvent ())`) and will be persisted across restarts. + * * [`OutputSweeper`]: crate::util::sweep::OutputSweeper */ LDKEvent_SpendableOutputs, /** * This event is generated when a payment has been successfully forwarded through us and a * forwarding fee earned. + * + * # Failure Behavior and Persistence + * This event will eventually be replayed after failures-to-handle (i.e., the event handler + * returning `Err(ReplayEvent ())`) and will be persisted across restarts. */ LDKEvent_PaymentForwarded, /** @@ -18621,6 +19761,10 @@ typedef enum LDKEvent_Tag { * 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. + * + * # Failure Behavior and Persistence + * This event will eventually be replayed after failures-to-handle (i.e., the event handler + * returning `Err(ReplayEvent ())`) and will be persisted across restarts. */ LDKEvent_ChannelPending, /** @@ -18628,6 +19772,10 @@ typedef enum LDKEvent_Tag { * 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. + * + * # Failure Behavior and Persistence + * This event will eventually be replayed after failures-to-handle (i.e., the event handler + * returning `Err(ReplayEvent ())`) and will be persisted across restarts. */ LDKEvent_ChannelReady, /** @@ -18640,6 +19788,10 @@ typedef enum LDKEvent_Tag { * * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel * [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels + * + * # Failure Behavior and Persistence + * This event will eventually be replayed after failures-to-handle (i.e., the event handler + * returning `Err(ReplayEvent ())`) and will be persisted across restarts. */ LDKEvent_ChannelClosed, /** @@ -18647,6 +19799,10 @@ typedef enum LDKEvent_Tag { * inputs for another purpose. * * This event is not guaranteed to be generated for channels that are closed due to a restart. + * + * # Failure Behavior and Persistence + * This event will eventually be replayed after failures-to-handle (i.e., the event handler + * returning `Err(ReplayEvent ())`) and will be persisted across restarts. */ LDKEvent_DiscardFunding, /** @@ -18659,6 +19815,10 @@ typedef enum LDKEvent_Tag { * 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. * + * # Failure Behavior and Persistence + * This event will eventually be replayed after failures-to-handle (i.e., the event handler + * returning `Err(ReplayEvent ())`) and will be persisted across restarts. + * * [`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 @@ -18677,6 +19837,10 @@ typedef enum LDKEvent_Tag { * * 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). + * + * # Failure Behavior and Persistence + * This event will eventually be replayed after failures-to-handle (i.e., the event handler + * returning `Err(ReplayEvent ())`) and will be persisted across restarts. */ LDKEvent_HTLCHandlingFailed, /** @@ -18687,9 +19851,40 @@ typedef enum LDKEvent_Tag { * [`ChannelHandshakeConfig::negotiate_anchors_zero_fee_htlc_tx`] config flag is set to true. * It is limited to the scope of channels with anchor outputs. * + * # Failure Behavior and Persistence + * This event will eventually be replayed after failures-to-handle (i.e., the event handler + * returning `Err(ReplayEvent ())`), but will only be regenerated as needed after restarts. + * * [`ChannelHandshakeConfig::negotiate_anchors_zero_fee_htlc_tx`]: crate::util::config::ChannelHandshakeConfig::negotiate_anchors_zero_fee_htlc_tx */ LDKEvent_BumpTransaction, + /** + * We received an onion message that is intended to be forwarded to a peer + * that is currently offline. This event will only be generated if the + * `OnionMessenger` was initialized with + * [`OnionMessenger::new_with_offline_peer_interception`], see its docs. + * + * # Failure Behavior and Persistence + * This event will eventually be replayed after failures-to-handle (i.e., the event handler + * returning `Err(ReplayEvent ())`), but won't be persisted across restarts. + * + * [`OnionMessenger::new_with_offline_peer_interception`]: crate::onion_message::messenger::OnionMessenger::new_with_offline_peer_interception + */ + LDKEvent_OnionMessageIntercepted, + /** + * Indicates that an onion message supporting peer has come online and it may + * be time to forward any onion messages that were previously intercepted for + * them. This event will only be generated if the `OnionMessenger` was + * initialized with + * [`OnionMessenger::new_with_offline_peer_interception`], see its docs. + * + * # Failure Behavior and Persistence + * This event will eventually be replayed after failures-to-handle (i.e., the event handler + * returning `Err(ReplayEvent ())`), but won't be persisted across restarts. + * + * [`OnionMessenger::new_with_offline_peer_interception`]: crate::onion_message::messenger::OnionMessenger::new_with_offline_peer_interception + */ + LDKEvent_OnionMessagePeerConnected, /** * Must be last for serialization purposes */ @@ -18733,6 +19928,31 @@ typedef struct LDKEvent_LDKFundingGenerationReady_Body { struct LDKU128 user_channel_id; } LDKEvent_LDKFundingGenerationReady_Body; +typedef struct LDKEvent_LDKFundingTxBroadcastSafe_Body { + /** + * The `channel_id` indicating which channel has reached this stage. + */ + struct LDKChannelId channel_id; + /** + * The `user_channel_id` value passed in to [`ChannelManager::create_channel`]. + * + * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel + */ + struct LDKU128 user_channel_id; + /** + * The outpoint of the channel's funding transaction. + */ + struct LDKOutPoint funding_txo; + /** + * The `node_id` of the channel counterparty. + */ + struct LDKPublicKey counterparty_node_id; + /** + * The `temporary_channel_id` this channel used to be known by during channel establishment. + */ + struct LDKChannelId former_temporary_channel_id; +} LDKEvent_LDKFundingTxBroadcastSafe_Body; + typedef struct LDKEvent_LDKPaymentClaimable_Body { /** * The node that will receive the payment after it has been claimed. @@ -18846,6 +20066,15 @@ typedef struct LDKEvent_LDKPaymentClaimed_Body { * serialized prior to LDK version 0.0.117. */ struct LDKCOption_u64Z sender_intended_total_msat; + /** + * 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.124 will have this field unset. + * + * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + */ + struct LDKRecipientOnionFields onion_fields; } LDKEvent_LDKPaymentClaimed_Body; typedef struct LDKEvent_LDKConnectionNeeded_Body { @@ -18859,12 +20088,32 @@ typedef struct LDKEvent_LDKConnectionNeeded_Body { struct LDKCVec_SocketAddressZ addresses; } LDKEvent_LDKConnectionNeeded_Body; -typedef struct LDKEvent_LDKInvoiceRequestFailed_Body { +typedef struct LDKEvent_LDKInvoiceReceived_Body { /** - * The `payment_id` to have been associated with payment for the requested invoice. + * The `payment_id` associated with payment for the invoice. */ struct LDKThirtyTwoBytes payment_id; -} LDKEvent_LDKInvoiceRequestFailed_Body; + /** + * The invoice to pay. + */ + struct LDKBolt12Invoice invoice; + /** + * The context of the [`BlindedMessagePath`] used to send the invoice. + * + * [`BlindedMessagePath`]: crate::blinded_path::message::BlindedMessagePath + */ + struct LDKCOption_OffersContextZ context; + /** + * A responder for replying with an [`InvoiceError`] if needed. + * + * `None` if the invoice wasn't sent with a reply path. + * + * [`InvoiceError`]: crate::offers::invoice_error::InvoiceError + * + * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + */ + struct LDKResponder responder; +} LDKEvent_LDKInvoiceReceived_Body; typedef struct LDKEvent_LDKPaymentSent_Body { /** @@ -18894,6 +20143,8 @@ typedef struct LDKEvent_LDKPaymentSent_Body { * If the recipient or an intermediate node misbehaves and gives us free money, this may * overstate the amount paid, though this is unlikely. * + * This is only `None` for payments initiated on LDK versions prior to 0.0.103. + * * [`Route::get_total_fees`]: crate::routing::router::Route::get_total_fees */ struct LDKCOption_u64Z fee_paid_msat; @@ -18907,14 +20158,17 @@ typedef struct LDKEvent_LDKPaymentFailed_Body { */ struct LDKThirtyTwoBytes payment_id; /** - * The hash that was given to [`ChannelManager::send_payment`]. + * The hash that was given to [`ChannelManager::send_payment`]. `None` if the payment failed + * before receiving an invoice when paying a BOLT12 [`Offer`]. * * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment + * [`Offer`]: crate::offers::offer::Offer */ - struct LDKThirtyTwoBytes payment_hash; + struct LDKCOption_ThirtyTwoBytesZ payment_hash; /** * The reason the payment failed. This is only `None` for events generated or serialized - * by versions prior to 0.0.115. + * by versions prior to 0.0.115, or when downgrading to a version with a reason that was + * added after. */ struct LDKCOption_PaymentFailureReasonZ reason; } LDKEvent_LDKPaymentFailed_Body; @@ -19290,7 +20544,7 @@ typedef struct LDKEvent_LDKDiscardFunding_Body { /** * The full transaction received from the user */ - struct LDKTransaction transaction; + struct LDKFundingInfo funding_info; } LDKEvent_LDKDiscardFunding_Body; typedef struct LDKEvent_LDKOpenChannelRequest_Body { @@ -19343,6 +20597,14 @@ typedef struct LDKEvent_LDKOpenChannelRequest_Body { * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager */ struct LDKChannelTypeFeatures channel_type; + /** + * True if this channel is (or will be) publicly-announced. + */ + bool is_announced; + /** + * Channel parameters given by the counterparty. + */ + struct LDKChannelParameters params; } LDKEvent_LDKOpenChannelRequest_Body; typedef struct LDKEvent_LDKHTLCHandlingFailed_Body { @@ -19356,14 +20618,34 @@ typedef struct LDKEvent_LDKHTLCHandlingFailed_Body { struct LDKHTLCDestination failed_next_destination; } LDKEvent_LDKHTLCHandlingFailed_Body; +typedef struct LDKEvent_LDKOnionMessageIntercepted_Body { + /** + * The node id of the offline peer. + */ + struct LDKPublicKey peer_node_id; + /** + * The onion message intended to be forwarded to `peer_node_id`. + */ + struct LDKOnionMessage message; +} LDKEvent_LDKOnionMessageIntercepted_Body; + +typedef struct LDKEvent_LDKOnionMessagePeerConnected_Body { + /** + * The node id of the peer we just connected to, who advertises support for + * onion messages. + */ + struct LDKPublicKey peer_node_id; +} LDKEvent_LDKOnionMessagePeerConnected_Body; + typedef struct MUST_USE_STRUCT LDKEvent { LDKEvent_Tag tag; union { LDKEvent_LDKFundingGenerationReady_Body funding_generation_ready; + LDKEvent_LDKFundingTxBroadcastSafe_Body funding_tx_broadcast_safe; LDKEvent_LDKPaymentClaimable_Body payment_claimable; LDKEvent_LDKPaymentClaimed_Body payment_claimed; LDKEvent_LDKConnectionNeeded_Body connection_needed; - LDKEvent_LDKInvoiceRequestFailed_Body invoice_request_failed; + LDKEvent_LDKInvoiceReceived_Body invoice_received; LDKEvent_LDKPaymentSent_Body payment_sent; LDKEvent_LDKPaymentFailed_Body payment_failed; LDKEvent_LDKPaymentPathSuccessful_Body payment_path_successful; @@ -19383,6 +20665,8 @@ typedef struct MUST_USE_STRUCT LDKEvent { struct { struct LDKBumpTransactionEvent bump_transaction; }; + LDKEvent_LDKOnionMessageIntercepted_Body onion_message_intercepted; + LDKEvent_LDKOnionMessagePeerConnected_Body onion_message_peer_connected; }; } LDKEvent; @@ -19446,6 +20730,55 @@ typedef struct LDKCResult_COption_EventZDecodeErrorZ { bool result_ok; } LDKCResult_COption_EventZDecodeErrorZ; +/** + * The contents of CResult_NonceDecodeErrorZ + */ +typedef union LDKCResult_NonceDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKNonce *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_NonceDecodeErrorZPtr; + +/** + * A CResult_NonceDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::offers::nonce::Nonce 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_NonceDecodeErrorZ { + /** + * The contents of this CResult_NonceDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_NonceDecodeErrorZPtr contents; + /** + * Whether this CResult_NonceDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_NonceDecodeErrorZ; + +/** + * A dynamically-allocated array of crate::lightning_types::routing::RouteHintHops of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_RouteHintHopZ { + /** + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + */ + struct LDKRouteHintHop *data; + /** + * The number of elements pointed to by `data`. + */ + uintptr_t datalen; +} LDKCVec_RouteHintHopZ; + /** * Sub-errors which don't have specific information in them use this type. */ @@ -19543,6 +20876,33 @@ typedef struct LDKCResult_SiPrefixBolt11ParseErrorZ { bool result_ok; } LDKCResult_SiPrefixBolt11ParseErrorZ; + + +/** + * 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 MUST_USE_STRUCT LDKBolt11Invoice { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeBolt11Invoice *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; +} LDKBolt11Invoice; + /** * 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 @@ -19667,30 +21027,6 @@ typedef struct LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ { -/** - * 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 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. - */ - 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; -} LDKRawBolt11Invoice; - - - /** * Recoverable signature */ @@ -20124,6 +21460,39 @@ typedef struct LDKCResult_BigSizeDecodeErrorZ { bool result_ok; } LDKCResult_BigSizeDecodeErrorZ; +/** + * The contents of CResult_UntrustedStringDecodeErrorZ + */ +typedef union LDKCResult_UntrustedStringDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKUntrustedString *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; + +/** + * A CResult_UntrustedStringDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning_types::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 { + /** + * The contents of this CResult_UntrustedStringDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_UntrustedStringDecodeErrorZPtr contents; + /** + * Whether this CResult_UntrustedStringDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_UntrustedStringDecodeErrorZ; + /** * The contents of CResult_HostnameDecodeErrorZ */ @@ -20246,84 +21615,172 @@ typedef struct LDKCResult_TransactionU16LenLimitedDecodeErrorZ { } LDKCResult_TransactionU16LenLimitedDecodeErrorZ; /** - * The contents of CResult_UntrustedStringDecodeErrorZ + * The contents of CResult_ChannelIdDecodeErrorZ */ -typedef union LDKCResult_UntrustedStringDecodeErrorZPtr { +typedef union LDKCResult_ChannelIdDecodeErrorZPtr { /** * 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 LDKChannelId *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_ChannelIdDecodeErrorZPtr; /** - * 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_ChannelIdDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::types::ChannelId 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_ChannelIdDecodeErrorZ { /** - * The contents of this CResult_UntrustedStringDecodeErrorZ, accessible via either + * The contents of this CResult_ChannelIdDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_UntrustedStringDecodeErrorZPtr contents; + union LDKCResult_ChannelIdDecodeErrorZPtr contents; /** - * Whether this CResult_UntrustedStringDecodeErrorZ represents a success state. + * Whether this CResult_ChannelIdDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_UntrustedStringDecodeErrorZ; +} LDKCResult_ChannelIdDecodeErrorZ; /** - * The contents of CResult_ChannelIdDecodeErrorZ + * A tuple of 2 elements. See the individual fields for the types contained. */ -typedef union LDKCResult_ChannelIdDecodeErrorZPtr { +typedef struct LDKC2Tuple__u832u16Z { + /** + * The element at position 0 + */ + struct LDKThirtyTwoBytes a; + /** + * The element at position 1 + */ + uint16_t b; +} LDKC2Tuple__u832u16Z; + + + +/** + * Information needed to route a payment across a [`BlindedPaymentPath`]. + */ +typedef struct MUST_USE_STRUCT LDKBlindedPayInfo { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, 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; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust 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; + +/** + * The contents of CResult_BlindedPayInfoDecodeErrorZ + */ +typedef union LDKCResult_BlindedPayInfoDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKChannelId *result; + struct LDKBlindedPayInfo *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_ChannelIdDecodeErrorZPtr; +} LDKCResult_BlindedPayInfoDecodeErrorZPtr; /** - * A CResult_ChannelIdDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::types::ChannelId on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_BlindedPayInfoDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::blinded_path::payment::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_ChannelIdDecodeErrorZ { +typedef struct LDKCResult_BlindedPayInfoDecodeErrorZ { /** - * The contents of this CResult_ChannelIdDecodeErrorZ, accessible via either + * The contents of this CResult_BlindedPayInfoDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_ChannelIdDecodeErrorZPtr contents; + union LDKCResult_BlindedPayInfoDecodeErrorZPtr contents; /** - * Whether this CResult_ChannelIdDecodeErrorZ represents a success state. + * Whether this CResult_BlindedPayInfoDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_ChannelIdDecodeErrorZ; +} LDKCResult_BlindedPayInfoDecodeErrorZ; /** - * A tuple of 2 elements. See the individual fields for the types contained. + * The contents of CResult_BlindedPaymentPathNoneZ */ -typedef struct LDKC2Tuple__u832u16Z { +typedef union LDKCResult_BlindedPaymentPathNoneZPtr { /** - * 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 LDKBlindedPaymentPath *result; /** - * The element at position 1 + * Note that this value is always NULL, as there are no contents in the Err variant */ - uint16_t b; -} LDKC2Tuple__u832u16Z; + void *err; +} LDKCResult_BlindedPaymentPathNoneZPtr; + +/** + * A CResult_BlindedPaymentPathNoneZ represents the result of a fallible operation, + * containing a crate::lightning::blinded_path::payment::BlindedPaymentPath on success and a () on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_BlindedPaymentPathNoneZ { + /** + * The contents of this CResult_BlindedPaymentPathNoneZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_BlindedPaymentPathNoneZPtr contents; + /** + * Whether this CResult_BlindedPaymentPathNoneZ represents a success state. + */ + bool result_ok; +} LDKCResult_BlindedPaymentPathNoneZ; + + + +/** + * An intermediate node, its outbound channel, and relay parameters. + */ +typedef struct MUST_USE_STRUCT LDKPaymentForwardNode { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativePaymentForwardNode *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; +} LDKPaymentForwardNode; + +/** + * A dynamically-allocated array of crate::lightning::blinded_path::payment::PaymentForwardNodes of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_PaymentForwardNodeZ { + /** + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + */ + struct LDKPaymentForwardNode *data; + /** + * The number of elements pointed to by `data`. + */ + uintptr_t datalen; +} LDKCVec_PaymentForwardNodeZ; @@ -20568,87 +22025,64 @@ typedef struct LDKCResult_Bolt12RefundContextDecodeErrorZ { } LDKCResult_Bolt12RefundContextDecodeErrorZ; /** - * The contents of CResult_StrSecp256k1ErrorZ + * The contents of CResult_ResponderDecodeErrorZ */ -typedef union LDKCResult_StrSecp256k1ErrorZPtr { +typedef union LDKCResult_ResponderDecodeErrorZPtr { /** * 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 LDKResponder *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_StrSecp256k1ErrorZPtr; + struct LDKDecodeError *err; +} LDKCResult_ResponderDecodeErrorZPtr; /** - * A CResult_StrSecp256k1ErrorZ 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_ResponderDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::onion_message::messenger::Responder 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_StrSecp256k1ErrorZ { +typedef struct LDKCResult_ResponderDecodeErrorZ { /** - * The contents of this CResult_StrSecp256k1ErrorZ, accessible via either + * The contents of this CResult_ResponderDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_StrSecp256k1ErrorZPtr contents; + union LDKCResult_ResponderDecodeErrorZPtr contents; /** - * Whether this CResult_StrSecp256k1ErrorZ represents a success state. + * Whether this CResult_ResponderDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_StrSecp256k1ErrorZ; +} LDKCResult_ResponderDecodeErrorZ; /** - * A tuple of 3 elements. See the individual fields for the types contained. + * An enum which can either contain a crate::lightning::blinded_path::message::MessageContext or not */ -typedef struct LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ { +typedef enum LDKCOption_MessageContextZ_Tag { /** - * The element at position 0 - */ - struct LDKThirtyTwoBytes a; - /** - * The element at position 1 + * When we're in this state, this COption_MessageContextZ contains a crate::lightning::blinded_path::message::MessageContext */ - struct LDKRecipientOnionFields b; + LDKCOption_MessageContextZ_Some, /** - * The element at position 2 + * When we're in this state, this COption_MessageContextZ contains nothing */ - struct LDKRouteParameters c; -} LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ; - -/** - * The contents of CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ - */ -typedef union LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZPtr { + LDKCOption_MessageContextZ_None, /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. - */ - struct LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ *result; - /** - * Note that this value is always NULL, as there are no contents in the Err variant + * Must be last for serialization purposes */ - void *err; -} LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZPtr; + LDKCOption_MessageContextZ_Sentinel, +} LDKCOption_MessageContextZ_Tag; -/** - * A CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ represents the result of a fallible operation, - * containing a crate::c_types::derived::C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ on success and a () on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ { - /** - * The contents of this CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. - */ - union LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZPtr contents; - /** - * Whether this CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ represents a success state. - */ - bool result_ok; -} LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ; +typedef struct LDKCOption_MessageContextZ { + LDKCOption_MessageContextZ_Tag tag; + union { + struct { + struct LDKMessageContext some; + }; + }; +} LDKCOption_MessageContextZ; /** * A tuple of 3 elements. See the individual fields for the types contained. @@ -20684,8 +22118,8 @@ typedef enum LDKSendError_Tag { */ LDKSendError_TooBigPacket, /** - * The provided [`Destination`] was an invalid [`BlindedPath`] due to not having any blinded - * hops. + * The provided [`Destination`] was an invalid [`BlindedMessagePath`] due to not having any + * blinded hops. */ LDKSendError_TooFewBlindedHops, /** @@ -20693,7 +22127,11 @@ typedef enum LDKSendError_Tag { */ LDKSendError_InvalidFirstHop, /** - * A path from the sender to the destination could not be found by the [`MessageRouter`]. + * Indicates that a path could not be found by the [`MessageRouter`]. + * + * This occurs when either: + * - No path from the sender to the destination was found to send the onion message + * - No reply path to the sender could be created when responding to an onion message */ LDKSendError_PathNotFound, /** @@ -20848,7 +22286,7 @@ typedef enum LDKPeeledOnion_Tag { */ LDKPeeledOnion_Forward, /** - * Received onion message, with decrypted contents, path_id, and reply path + * Received onion message, with decrypted contents, context, and reply path */ LDKPeeledOnion_Receive, /** @@ -20864,16 +22302,12 @@ typedef struct LDKPeeledOnion_LDKForward_Body { typedef struct LDKPeeledOnion_LDKReceive_Body { struct LDKParsedOnionMessageContents _0; + struct LDKCOption_MessageContextZ _1; /** * * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None */ - struct LDKThirtyTwoBytes _1; - /** - * - * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None - */ - struct LDKBlindedPath _2; + struct LDKBlindedMessagePath _2; } LDKPeeledOnion_LDKReceive_Body; typedef struct MUST_USE_STRUCT LDKPeeledOnion { @@ -20981,170 +22415,146 @@ typedef struct LDKCResult_SendSuccessSendErrorZ { } LDKCResult_SendSuccessSendErrorZ; /** - * The contents of CResult_BlindedPathNoneZ + * The contents of CResult_NoneSendErrorZ */ -typedef union LDKCResult_BlindedPathNoneZPtr { +typedef union LDKCResult_NoneSendErrorZPtr { /** - * 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 LDKBlindedPath *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_BlindedPathNoneZPtr; + struct LDKSendError *err; +} LDKCResult_NoneSendErrorZPtr; /** - * 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_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_BlindedPathNoneZ { +typedef struct LDKCResult_NoneSendErrorZ { /** - * The contents of this CResult_BlindedPathNoneZ, accessible via either + * The contents of this CResult_NoneSendErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_BlindedPathNoneZPtr contents; + union LDKCResult_NoneSendErrorZPtr contents; /** - * Whether this CResult_BlindedPathNoneZ represents a success state. + * Whether this CResult_NoneSendErrorZ represents a success state. */ bool result_ok; -} LDKCResult_BlindedPathNoneZ; +} LDKCResult_NoneSendErrorZ; /** - * The contents of CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ + * The contents of CResult_BlindedHopDecodeErrorZ */ -typedef union LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZPtr { +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 LDKC2Tuple_BlindedPayInfoBlindedPathZ *result; + struct LDKBlindedHop *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_C2Tuple_BlindedPayInfoBlindedPathZNoneZPtr; + struct LDKDecodeError *err; +} LDKCResult_BlindedHopDecodeErrorZPtr; /** - * A CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ represents the result of a fallible operation, - * containing a crate::c_types::derived::C2Tuple_BlindedPayInfoBlindedPathZ on success and a () 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`. */ -typedef struct LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ { +typedef struct LDKCResult_BlindedHopDecodeErrorZ { /** - * The contents of this CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ, accessible via either + * The contents of this CResult_BlindedHopDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZPtr contents; + union LDKCResult_BlindedHopDecodeErrorZPtr contents; /** - * Whether this CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ represents a success state. + * Whether this CResult_BlindedHopDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ; - - - -/** - * An intermediate node, its outbound channel, and relay parameters. - */ -typedef struct MUST_USE_STRUCT LDKForwardNode { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeForwardNode *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; -} LDKForwardNode; +} LDKCResult_BlindedHopDecodeErrorZ; /** - * A dynamically-allocated array of crate::lightning::blinded_path::payment::ForwardNodes of arbitrary size. + * A dynamically-allocated array of crate::lightning::ln::channelmanager::PhantomRouteHintss of arbitrary size. * This corresponds to std::vector in C++ */ -typedef struct LDKCVec_ForwardNodeZ { +typedef struct LDKCVec_PhantomRouteHintsZ { /** * The elements in the array. * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - struct LDKForwardNode *data; + struct LDKPhantomRouteHints *data; /** * The number of elements pointed to by `data`. */ uintptr_t datalen; -} LDKCVec_ForwardNodeZ; +} LDKCVec_PhantomRouteHintsZ; /** - * The contents of CResult_BlindedPathDecodeErrorZ + * When signing using a fallible method either an user-supplied `SignError` or a [`CreationError`] + * may occur. */ -typedef union LDKCResult_BlindedPathDecodeErrorZPtr { - /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. - */ - struct LDKBlindedPath *result; +typedef enum LDKSignOrCreationError_Tag { /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * An error occurred during signing */ - 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 { + LDKSignOrCreationError_SignError, /** - * The contents of this CResult_BlindedPathDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * An error occurred while building the transaction */ - union LDKCResult_BlindedPathDecodeErrorZPtr contents; + LDKSignOrCreationError_CreationError, /** - * Whether this CResult_BlindedPathDecodeErrorZ represents a success state. + * Must be last for serialization purposes */ - bool result_ok; -} LDKCResult_BlindedPathDecodeErrorZ; + LDKSignOrCreationError_Sentinel, +} LDKSignOrCreationError_Tag; + +typedef struct MUST_USE_STRUCT LDKSignOrCreationError { + LDKSignOrCreationError_Tag tag; + union { + struct { + enum LDKCreationError creation_error; + }; + }; +} LDKSignOrCreationError; /** - * The contents of CResult_BlindedHopDecodeErrorZ + * The contents of CResult_Bolt11InvoiceSignOrCreationErrorZ */ -typedef union LDKCResult_BlindedHopDecodeErrorZPtr { +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. */ - struct LDKBlindedHop *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 LDKDecodeError *err; -} LDKCResult_BlindedHopDecodeErrorZPtr; + struct LDKSignOrCreationError *err; +} LDKCResult_Bolt11InvoiceSignOrCreationErrorZPtr; /** - * 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_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_BlindedHopDecodeErrorZ { +typedef struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ { /** - * The contents of this CResult_BlindedHopDecodeErrorZ, accessible via either + * The contents of this CResult_Bolt11InvoiceSignOrCreationErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_BlindedHopDecodeErrorZPtr contents; + union LDKCResult_Bolt11InvoiceSignOrCreationErrorZPtr contents; /** - * Whether this CResult_BlindedHopDecodeErrorZ represents a success state. + * Whether this CResult_Bolt11InvoiceSignOrCreationErrorZ represents a success state. */ bool result_ok; -} LDKCResult_BlindedHopDecodeErrorZ; +} LDKCResult_Bolt11InvoiceSignOrCreationErrorZ; /** * The contents of CResult_InvoiceErrorDecodeErrorZ @@ -21355,6 +22765,9 @@ typedef struct LDKCResult_OutputSpendStatusDecodeErrorZ { * 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. * + * Depending on your block source, you may need one or both of either [`Self::outpoint`] or + * [`Self::script_pubkey`]. + * * [`ChannelMonitor`]: channelmonitor::ChannelMonitor * [`ChannelMonitor::block_connected`]: channelmonitor::ChannelMonitor::block_connected */ @@ -21404,6 +22817,11 @@ typedef struct LDKFilter { /** * Registers interest in a transaction with `txid` and having an output with `script_pubkey` as * a spending condition. + * + * This may be used, for example, to monitor for when a funding transaction confirms. + * + * The `script_pubkey` is provided for informational purposes and may be useful for block + * sources which only support filtering on scripts. */ void (*register_tx)(const void *this_arg, const uint8_t (*txid)[32], struct LDKu8slice script_pubkey); /** @@ -21413,6 +22831,9 @@ typedef struct LDKFilter { * 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. + * + * This may be used, for example, to monitor for when a funding output is spent (by any + * transaction). */ void (*register_output)(const void *this_arg, struct LDKWatchedOutput output); /** @@ -21781,7 +23202,7 @@ typedef struct LDKCResult_DelayedPaymentBasepointDecodeErrorZ { * punish and claim all the channel funds if the state broadcasted was previously revoked. * * [See the BOLT specs] - * (https://github.com/lightning/bolts/blob/master/03-transactions.md#localpubkey-local_htlcpubkey-remote_htlcpubkey-local_delayedpubkey-and-remote_delayedpubkey-derivation) + * * for more information on key derivation details. */ typedef struct MUST_USE_STRUCT LDKDelayedPaymentKey { @@ -21899,7 +23320,7 @@ typedef struct LDKCResult_HtlcBasepointDecodeErrorZ { * Thus, both channel counterparties' HTLC keys will appears in each HTLC output's script. * * [See the BOLT specs] - * (https://github.com/lightning/bolts/blob/master/03-transactions.md#localpubkey-local_htlcpubkey-remote_htlcpubkey-local_delayedpubkey-and-remote_delayedpubkey-derivation) + * * for more information on key derivation details. */ typedef struct MUST_USE_STRUCT LDKHtlcKey { @@ -22014,7 +23435,7 @@ typedef struct LDKCResult_RevocationBasepointDecodeErrorZ { * per_commitment_point which is used in both commitment and HTLC transactions. * * See [the BOLT spec for derivation details] - * (https://github.com/lightning/bolts/blob/master/03-transactions.md#revocationpubkey-derivation) + * */ typedef struct MUST_USE_STRUCT LDKRevocationKey { /** @@ -22149,71 +23570,166 @@ typedef struct LDKCVec_C2Tuple_OutPointChannelIdZZ { uintptr_t datalen; } LDKCVec_C2Tuple_OutPointChannelIdZZ; - - /** - * An opaque identifier describing a specific [`Persist`] method call. + * A tuple of 2 elements. See the individual fields for the types contained. */ -typedef struct MUST_USE_STRUCT LDKMonitorUpdateId { +typedef struct LDKC2Tuple_OutPointCVec_u64ZZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, 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 */ - LDKnativeMonitorUpdateId *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; -} LDKMonitorUpdateId; + struct LDKCVec_u64Z b; +} LDKC2Tuple_OutPointCVec_u64ZZ; /** - * A dynamically-allocated array of crate::lightning::chain::chainmonitor::MonitorUpdateIds of arbitrary size. + * A dynamically-allocated array of crate::c_types::derived::C2Tuple_OutPointCVec_u64ZZs of arbitrary size. * This corresponds to std::vector in C++ */ -typedef struct LDKCVec_MonitorUpdateIdZ { +typedef struct LDKCVec_C2Tuple_OutPointCVec_u64ZZZ { /** * The elements in the array. * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - struct LDKMonitorUpdateId *data; + struct LDKC2Tuple_OutPointCVec_u64ZZ *data; /** * The number of elements pointed to by `data`. */ uintptr_t datalen; -} LDKCVec_MonitorUpdateIdZ; +} LDKCVec_C2Tuple_OutPointCVec_u64ZZZ; /** - * A tuple of 2 elements. See the individual fields for the types contained. + * The contents of CResult_BlindedMessagePathDecodeErrorZ */ -typedef struct LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ { +typedef union LDKCResult_BlindedMessagePathDecodeErrorZPtr { /** - * 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 LDKBlindedMessagePath *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 LDKDecodeError *err; +} LDKCResult_BlindedMessagePathDecodeErrorZPtr; /** - * A dynamically-allocated array of crate::c_types::derived::C2Tuple_OutPointCVec_MonitorUpdateIdZZs of arbitrary size. - * This corresponds to std::vector in C++ + * A CResult_BlindedMessagePathDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::blinded_path::message::BlindedMessagePath 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_OutPointCVec_MonitorUpdateIdZZZ { +typedef struct LDKCResult_BlindedMessagePathDecodeErrorZ { /** - * 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_BlindedMessagePathDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ *data; + union LDKCResult_BlindedMessagePathDecodeErrorZPtr contents; /** - * The number of elements pointed to by `data`. + * Whether this CResult_BlindedMessagePathDecodeErrorZ represents a success state. */ - uintptr_t datalen; -} LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ; + bool result_ok; +} LDKCResult_BlindedMessagePathDecodeErrorZ; + +/** + * The contents of CResult_BlindedMessagePathNoneZ + */ +typedef union LDKCResult_BlindedMessagePathNoneZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKBlindedMessagePath *result; + /** + * Note that this value is always NULL, as there are no contents in the Err variant + */ + void *err; +} LDKCResult_BlindedMessagePathNoneZPtr; + +/** + * A CResult_BlindedMessagePathNoneZ represents the result of a fallible operation, + * containing a crate::lightning::blinded_path::message::BlindedMessagePath on success and a () on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_BlindedMessagePathNoneZ { + /** + * The contents of this CResult_BlindedMessagePathNoneZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_BlindedMessagePathNoneZPtr contents; + /** + * Whether this CResult_BlindedMessagePathNoneZ represents a success state. + */ + bool result_ok; +} LDKCResult_BlindedMessagePathNoneZ; + +/** + * The contents of CResult_MessageContextDecodeErrorZ + */ +typedef union LDKCResult_MessageContextDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKMessageContext *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_MessageContextDecodeErrorZPtr; + +/** + * A CResult_MessageContextDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::blinded_path::message::MessageContext 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_MessageContextDecodeErrorZ { + /** + * The contents of this CResult_MessageContextDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_MessageContextDecodeErrorZPtr contents; + /** + * Whether this CResult_MessageContextDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_MessageContextDecodeErrorZ; + +/** + * The contents of CResult_OffersContextDecodeErrorZ + */ +typedef union LDKCResult_OffersContextDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKOffersContext *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_OffersContextDecodeErrorZPtr; + +/** + * A CResult_OffersContextDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::blinded_path::message::OffersContext 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_OffersContextDecodeErrorZ { + /** + * The contents of this CResult_OffersContextDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_OffersContextDecodeErrorZPtr contents; + /** + * Whether this CResult_OffersContextDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_OffersContextDecodeErrorZ; /** * Trait that handles persisting a [`ChannelManager`], [`NetworkGraph`], and [`WriteableScore`] to disk. @@ -22382,7 +23898,7 @@ typedef struct MUST_USE_STRUCT LDKMonitorUpdatingPersister { * All calls should generally spawn a background task and immediately return * [`ChannelMonitorUpdateStatus::InProgress`]. Once the update completes, * [`ChainMonitor::channel_monitor_updated`] should be called with the corresponding - * [`MonitorUpdateId`]. + * [`ChannelMonitor::get_latest_update_id`] or [`ChannelMonitorUpdate::update_id`]. * * Note that unlike the direct [`chain::Watch`] interface, * [`ChainMonitor::channel_monitor_updated`] must be called once for *each* update which occurs. @@ -22420,8 +23936,9 @@ typedef struct LDKPersist { * 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`]. + * The [`ChannelMonitor::get_latest_update_id`] uniquely links this call to [`ChainMonitor::channel_monitor_updated`]. + * For [`Persist::persist_new_channel`], it is only necessary to call [`ChainMonitor::channel_monitor_updated`] + * when you return [`ChannelMonitorUpdateStatus::InProgress`]. * * See [`Writeable::write`] on [`ChannelMonitor`] for writing out a `ChannelMonitor` * and [`ChannelMonitorUpdateStatus`] for requirements when returning errors. @@ -22429,7 +23946,7 @@ typedef struct LDKPersist { * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager * [`Writeable::write`]: crate::util::ser::Writeable::write */ - enum LDKChannelMonitorUpdateStatus (*persist_new_channel)(const void *this_arg, struct LDKOutPoint channel_funding_outpoint, const struct LDKChannelMonitor *NONNULL_PTR data, struct LDKMonitorUpdateId update_id); + enum LDKChannelMonitorUpdateStatus (*persist_new_channel)(const void *this_arg, struct LDKOutPoint channel_funding_outpoint, const struct LDKChannelMonitor *NONNULL_PTR monitor); /** * Update one channel's data. The provided [`ChannelMonitor`] has already applied the given * update. @@ -22447,7 +23964,9 @@ typedef struct LDKPersist { * 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 + * deserialization routine. If there are any gaps in the persisted [`ChannelMonitorUpdate`]s, + * implementer can safely ignore [`ChannelMonitorUpdate`]s after the gap and load without them. + * 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. * @@ -22456,8 +23975,10 @@ typedef struct LDKPersist { * 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`]. + * The [`ChannelMonitorUpdate::update_id`] or [`ChannelMonitor::get_latest_update_id`] uniquely + * links this call to [`ChainMonitor::channel_monitor_updated`]. + * For [`Persist::update_persisted_channel`], it is only necessary to call [`ChainMonitor::channel_monitor_updated`] + * when a [`ChannelMonitorUpdate`] is provided and when you return [`ChannelMonitorUpdateStatus::InProgress`]. * * See [`Writeable::write`] on [`ChannelMonitor`] for writing out a `ChannelMonitor`, * [`Writeable::write`] on [`ChannelMonitorUpdate`] for writing out an update, and @@ -22465,9 +23986,9 @@ typedef struct LDKPersist { * * [`Writeable::write`]: crate::util::ser::Writeable::write * - * Note that update (or a relevant inner pointer) may be NULL or all-0s to represent None + * Note that monitor_update (or a relevant inner pointer) may be NULL or all-0s to represent None */ - enum LDKChannelMonitorUpdateStatus (*update_persisted_channel)(const void *this_arg, struct LDKOutPoint channel_funding_outpoint, struct LDKChannelMonitorUpdate update, const struct LDKChannelMonitor *NONNULL_PTR data, struct LDKMonitorUpdateId update_id); + enum LDKChannelMonitorUpdateStatus (*update_persisted_channel)(const void *this_arg, struct LDKOutPoint channel_funding_outpoint, struct LDKChannelMonitorUpdate monitor_update, const struct LDKChannelMonitor *NONNULL_PTR monitor); /** * Prevents the channel monitor from being loaded on startup. * @@ -22482,27 +24003,6 @@ typedef struct LDKPersist { void (*free)(void *this_arg); } LDKPersist; - - -/** - * A string that displays only printable characters, replacing control characters with - * [`core::char::REPLACEMENT_CHARACTER`]. - */ -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. - */ - 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; -} LDKPrintableString; - /** * The `Listen` trait is used to notify when blocks have been connected or disconnected from the * chain. @@ -22747,7 +24247,7 @@ typedef struct MUST_USE_STRUCT LDKSleeper { /** * Configuration we set when applicable. * - * Default::default() provides sane defaults. + * `Default::default()` provides sane defaults. */ typedef struct MUST_USE_STRUCT LDKChannelHandshakeConfig { /** @@ -22771,7 +24271,7 @@ typedef struct MUST_USE_STRUCT LDKChannelHandshakeConfig { * * These limits are only applied to our counterparty's limits, not our own. * - * Use 0/`::max_value()` as appropriate to skip checking. + * Use `0` or `::max_value()` as appropriate to skip checking. * * Provides sane defaults for most configurations. * @@ -22819,8 +24319,8 @@ typedef struct MUST_USE_STRUCT LDKChannelConfigUpdate { /** * Top-level config which holds ChannelHandshakeLimits and ChannelConfig. * - * Default::default() provides sane defaults for most configurations - * (but currently with 0 relay fees!) + * `Default::default()` provides sane defaults for most configurations + * (but currently with zero relay fees!) */ typedef struct MUST_USE_STRUCT LDKUserConfig { /** @@ -22877,7 +24377,7 @@ typedef struct MUST_USE_STRUCT LDKChainMonitor { * * 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`. + * core::future::Future>, H: Fn(Event) -> F`. */ typedef struct LDKEventHandler { /** @@ -22890,7 +24390,7 @@ typedef struct LDKEventHandler { * * See [`EventsProvider`] for details that must be considered when implementing this method. */ - void (*handle_event)(const void *this_arg, struct LDKEvent event); + struct LDKCResult_NoneReplayEventZ (*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. @@ -22914,8 +24414,12 @@ typedef struct LDKEventHandler { * * 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. + * [`process_pending_events`] returns `Ok(())`, thus handlers MUST fully handle [`Event`]s and + * persist any relevant changes to disk *before* returning `Ok(())`. In case of an error (e.g., + * persistence failure) implementors should return `Err(ReplayEvent())`, signalling to the + * [`EventsProvider`] to replay unhandled events on the next invocation (generally immediately). + * Note that some events might not be replayed, please refer to the documentation for + * the individual [`Event`] variants for more detail. * * 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 @@ -23241,15 +24745,17 @@ typedef struct LDKOffersMessageHandler { * The returned [`OffersMessage`], if any, is enqueued to be sent by [`OnionMessenger`]. * * [`OnionMessenger`]: crate::onion_message::messenger::OnionMessenger + * + * Note that responder (or a relevant inner pointer) may be NULL or all-0s to represent None */ - struct LDKCOption_OffersMessageZ (*handle_message)(const void *this_arg, struct LDKOffersMessage message); + struct LDKCOption_C2Tuple_OffersMessageResponseInstructionZZ (*handle_message)(const void *this_arg, struct LDKOffersMessage message, struct LDKCOption_OffersContextZ context, struct LDKResponder responder); /** * Releases any [`OffersMessage`]s that need to be sent. * * Typically, this is used for messages initiating a payment flow rather than in response to * another message. The latter should use the return value of [`Self::handle_message`]. */ - struct LDKCVec_C3Tuple_OffersMessageDestinationBlindedPathZZ (*release_pending_messages)(const void *this_arg); + struct LDKCVec_C2Tuple_OffersMessageMessageSendInstructionsZZ (*release_pending_messages)(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. @@ -23257,6 +24763,43 @@ typedef struct LDKOffersMessageHandler { void (*free)(void *this_arg); } LDKOffersMessageHandler; +/** + * A handler for an [`OnionMessage`] containing an async payments message as its payload. + * + * [`OnionMessage`]: crate::ln::msgs::OnionMessage + */ +typedef struct LDKAsyncPaymentsMessageHandler { + /** + * 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 a [`HeldHtlcAvailable`] message. A [`ReleaseHeldHtlc`] should be returned to release + * the held funds. + * + * Note that responder (or a relevant inner pointer) may be NULL or all-0s to represent None + */ + struct LDKCOption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ (*held_htlc_available)(const void *this_arg, struct LDKHeldHtlcAvailable message, struct LDKResponder responder); + /** + * Handle a [`ReleaseHeldHtlc`] message. If authentication of the message succeeds, an HTLC + * should be released to the corresponding payee. + */ + void (*release_held_htlc)(const void *this_arg, struct LDKReleaseHeldHtlc message); + /** + * Release any [`AsyncPaymentsMessage`]s that need to be sent. + * + * Typically, this is used for messages initiating an async payment flow rather than in response + * to another message. + */ + struct LDKCVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ (*release_pending_messages)(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); +} LDKAsyncPaymentsMessageHandler; + /** * An interface for looking up the node id of a channel counterparty for the purpose of forwarding * an [`OnionMessage`]. @@ -23545,16 +25088,6 @@ typedef struct LDKOnionMessageHandler { * This has no meaning in the LDK, and can be NULL or any other value. */ void *this_arg; - /** - * Because much of the lightning network does not yet support forwarding onion messages, we - * may need to directly connect to a node which will forward a message for us. In such a case, - * this method will return the set of nodes which need connection by node_id and the - * corresponding socket addresses where they may accept incoming connections. - * - * Thus, this method should be polled regularly to detect messages await such a direct - * connection. - */ - struct LDKCVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ (*get_and_clear_connections_needed)(const void *this_arg); /** * Handle an incoming `onion_message` message from the given peer. */ @@ -23677,6 +25210,18 @@ typedef struct LDKCustomMessageHandler { * 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); + /** + * Indicates a peer disconnected. + */ + void (*peer_disconnected)(const void *this_arg, struct LDKPublicKey their_node_id); + /** + * Handle a peer connecting. + * + * 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); /** * 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`] @@ -23747,8 +25292,10 @@ typedef struct LDKCustomOnionMessageHandler { * Called with the custom message that was received, returning a response to send, if any. * * The returned [`Self::CustomMessage`], if any, is enqueued to be sent by [`OnionMessenger`]. + * + * Note that responder (or a relevant inner pointer) may be NULL or all-0s to represent None */ - struct LDKCOption_OnionMessageContentsZ (*handle_custom_message)(const void *this_arg, struct LDKOnionMessageContents msg); + struct LDKCOption_C2Tuple_OnionMessageContentsResponseInstructionZZ (*handle_custom_message)(const void *this_arg, struct LDKOnionMessageContents message, struct LDKCOption_CVec_u8ZZ context, struct LDKResponder responder); /** * Read a custom message of type `message_type` from `buffer`, returning `Ok(None)` if the * message type is unknown. @@ -23760,7 +25307,7 @@ typedef struct LDKCustomOnionMessageHandler { * Typically, this is used for messages initiating a message flow rather than in response to * another message. The latter should use the return value of [`Self::handle_custom_message`]. */ - struct LDKCVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ (*release_pending_custom_messages)(const void *this_arg); + struct LDKCVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ (*release_pending_custom_messages)(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. @@ -23916,6 +25463,16 @@ typedef struct MUST_USE_STRUCT LDKPeerManager { bool is_owned; } LDKPeerManager; +/** + * 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; + /** @@ -23943,66 +25500,122 @@ typedef struct MUST_USE_STRUCT LDKDirectedChannelTransactionParameters { /** - * Features used within an `offer`. + * SHA-256 hash */ -typedef struct MUST_USE_STRUCT LDKOfferFeatures { +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. */ - LDKnativeOfferFeatures *inner; + 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; -} LDKOfferFeatures; +} LDKSha256; + +/** + * An error when attempting to pay a [`Bolt12Invoice`]. + */ +typedef enum LDKBolt12PaymentError_Tag { + /** + * The invoice was not requested. + */ + LDKBolt12PaymentError_UnexpectedInvoice, + /** + * Payment for an invoice with the corresponding [`PaymentId`] was already initiated. + */ + LDKBolt12PaymentError_DuplicateInvoice, + /** + * The invoice was valid for the corresponding [`PaymentId`], but required unknown features. + */ + LDKBolt12PaymentError_UnknownRequiredFeatures, + /** + * The invoice was valid for the corresponding [`PaymentId`], but sending the payment failed. + */ + LDKBolt12PaymentError_SendingFailed, + /** + * Must be last for serialization purposes + */ + LDKBolt12PaymentError_Sentinel, +} LDKBolt12PaymentError_Tag; + +typedef struct MUST_USE_STRUCT LDKBolt12PaymentError { + LDKBolt12PaymentError_Tag tag; + union { + struct { + enum LDKRetryableSendFailure sending_failed; + }; + }; +} LDKBolt12PaymentError; /** - * Features used within an `invoice_request`. + * Builds an [`Offer`] for the \"offer to be paid\" flow. + * + * See [module-level documentation] for usage. + * + * [module-level documentation]: self */ -typedef struct MUST_USE_STRUCT LDKInvoiceRequestFeatures { +typedef struct MUST_USE_STRUCT LDKOfferWithExplicitMetadataBuilder { /** * A pointer to the opaque Rust object. * Nearly everywhere, 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; + LDKnativeOfferWithExplicitMetadataBuilder *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; +} LDKOfferWithExplicitMetadataBuilder; /** - * Builds an [`Offer`] for the \"offer to be paid\" flow. - * - * See [module-level documentation] for usage. - * - * [module-level documentation]: self + * A string that displays only printable characters, replacing control characters with + * [`core::char::REPLACEMENT_CHARACTER`]. */ -typedef struct MUST_USE_STRUCT LDKOfferWithExplicitMetadataBuilder { +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. */ - LDKnativeOfferWithExplicitMetadataBuilder *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; -} LDKOfferWithExplicitMetadataBuilder; +} LDKPrintableString; + + + +/** + * 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; /** * Represents a tweaked X-only public key as required for BIP 340 (Taproot). @@ -24060,6 +25673,26 @@ typedef struct MUST_USE_STRUCT LDKTaggedHash { +/** + * 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; + + + /** * The field in the [`InvoiceRequest`] or the [`Bolt12Invoice`] that contained an error. * @@ -24280,6 +25913,11 @@ typedef struct MUST_USE_STRUCT LDKEffectiveCapacity { /** * A [`Router`] implemented using [`find_route`]. + * + * # Privacy + * + * Implements [`MessageRouter`] by delegating to [`DefaultMessageRouter`]. See those docs for + * privacy implications. */ typedef struct MUST_USE_STRUCT LDKDefaultRouter { /** @@ -24346,7 +25984,7 @@ 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; + struct LDKCVec_BlindedPaymentPathZ route_hints; /** * Features supported by the payee. * @@ -24619,12 +26257,13 @@ typedef struct MUST_USE_STRUCT LDKRandomBytes { * ``` * # extern crate bitcoin; * # use bitcoin::hashes::_export::_core::time::Duration; - * # use bitcoin::hashes::hex::FromHex; + * # use bitcoin::hex::FromHex; * # use bitcoin::secp256k1::{PublicKey, Secp256k1, SecretKey, self}; - * # use lightning::blinded_path::{BlindedPath, EmptyNodeIdLookUp}; + * # use lightning::blinded_path::EmptyNodeIdLookUp; + * # use lightning::blinded_path::message::{BlindedMessagePath, MessageForwardNode, MessageContext}; * # use lightning::sign::{EntropySource, KeysManager}; * # use lightning::ln::peer_handler::IgnoringMessageHandler; - * # use lightning::onion_message::messenger::{Destination, MessageRouter, OnionMessagePath, OnionMessenger}; + * # use lightning::onion_message::messenger::{Destination, MessageRouter, MessageSendInstructions, OnionMessagePath, OnionMessenger}; * # use lightning::onion_message::packet::OnionMessageContents; * # use lightning::util::logger::{Logger, Record}; * # use lightning::util::ser::{Writeable, Writer}; @@ -24648,8 +26287,8 @@ typedef struct MUST_USE_STRUCT LDKRandomBytes { * # }) * # } * # fn create_blinded_paths( - * # &self, _recipient: PublicKey, _peers: Vec, _secp_ctx: &Secp256k1 - * # ) -> Result, ()> { + * # &self, _recipient: PublicKey, _context: MessageContext, _peers: Vec, _secp_ctx: &Secp256k1 + * # ) -> Result, ()> { * # unreachable!() * # } * # } @@ -24666,11 +26305,12 @@ typedef struct MUST_USE_STRUCT LDKRandomBytes { * # let message_router = Arc::new(FakeMessageRouter {}); * # let custom_message_handler = IgnoringMessageHandler {}; * # let offers_message_handler = IgnoringMessageHandler {}; + * # let async_payments_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, &node_id_lookup, message_router, - * &offers_message_handler, &custom_message_handler + * &offers_message_handler, &async_payments_message_handler, &custom_message_handler * ); * * # #[derive(Debug, Clone)] @@ -24686,23 +26326,28 @@ typedef struct MUST_USE_STRUCT LDKRandomBytes { * \t\t# let your_custom_message_type = 42; * \t\tyour_custom_message_type * \t} + * \tfn msg_type(&self) -> &'static str { \"YourCustomMessageType\" } * } * // Send a custom onion message to a node id. * let destination = Destination::Node(destination_node_id); - * let reply_path = None; + * let instructions = MessageSendInstructions::WithoutReplyPath { destination }; * # let message = YourCustomMessage {}; - * onion_messenger.send_onion_message(message, destination, reply_path); + * onion_messenger.send_onion_message(message, instructions); * * // 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(); + * let hops = [ + * \tMessageForwardNode { node_id: hop_node_id3, short_channel_id: None }, + * \tMessageForwardNode { node_id: hop_node_id4, short_channel_id: None }, + * ]; + * let context = MessageContext::Custom(Vec::new()); + * let blinded_path = BlindedMessagePath::new(&hops, your_node_id, context, &keys_manager, &secp_ctx).unwrap(); * * // Send a custom onion message to a blinded path. * let destination = Destination::BlindedPath(blinded_path); - * let reply_path = None; + * let instructions = MessageSendInstructions::WithoutReplyPath { destination }; * # let message = YourCustomMessage {}; - * onion_messenger.send_onion_message(message, destination, reply_path); + * onion_messenger.send_onion_message(message, instructions); * ``` * * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest @@ -24727,6 +26372,13 @@ typedef struct MUST_USE_STRUCT LDKOnionMessenger { /** * A [`MessageRouter`] that can only route to a directly connected [`Destination`]. + * + * # Privacy + * + * Creating [`BlindedMessagePath`]s may affect privacy since, if a suitable path cannot be found, + * it will create a one-hop path using the recipient as the introduction node if it is a announced + * node. Otherwise, there is no way to find a path to the introduction node in order to send a + * message, and thus an `Err` is returned. */ typedef struct MUST_USE_STRUCT LDKDefaultMessageRouter { /** @@ -24744,7 +26396,7 @@ typedef struct MUST_USE_STRUCT LDKDefaultMessageRouter { } LDKDefaultMessageRouter; /** - * The unblinded node in a [`BlindedPath`]. + * The unblinded node in a blinded path. */ typedef enum LDKIntroductionNode_Tag { /** @@ -25108,26 +26760,6 @@ typedef struct MUST_USE_STRUCT 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 @@ -25256,6 +26888,8 @@ extern const uint32_t DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA; extern const uint8_t DEFAULT_MAX_PATH_COUNT; +extern const uint8_t MAX_PATH_LENGTH_ESTIMATE; + extern const uint64_t MAX_TIMESTAMP; extern const uint64_t DEFAULT_EXPIRY_TIME; @@ -25515,7 +27149,33 @@ struct LDKCOption_u64Z COption_u64Z_clone(const struct LDKCOption_u64Z *NONNULL_ /** * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -void CVec_BlindedPathZ_free(struct LDKCVec_BlindedPathZ _res); +void CVec_BlindedMessagePathZ_free(struct LDKCVec_BlindedMessagePathZ _res); + +/** + * Creates a new CResult_RefundDecodeErrorZ in the success state. + */ +struct LDKCResult_RefundDecodeErrorZ CResult_RefundDecodeErrorZ_ok(struct LDKRefund o); + +/** + * Creates a new CResult_RefundDecodeErrorZ in the error state. + */ +struct LDKCResult_RefundDecodeErrorZ CResult_RefundDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_RefundDecodeErrorZ_is_ok(const struct LDKCResult_RefundDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_RefundDecodeErrorZ. + */ +void CResult_RefundDecodeErrorZ_free(struct LDKCResult_RefundDecodeErrorZ _res); + +/** + * Creates a new CResult_RefundDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_RefundDecodeErrorZ CResult_RefundDecodeErrorZ_clone(const struct LDKCResult_RefundDecodeErrorZ *NONNULL_PTR orig); /** * Creates a new CResult_RefundBolt12ParseErrorZ in the success state. @@ -25798,6 +27458,11 @@ void CResult_SchnorrSignatureNoneZ_free(struct LDKCResult_SchnorrSignatureNoneZ */ struct LDKCResult_SchnorrSignatureNoneZ CResult_SchnorrSignatureNoneZ_clone(const struct LDKCResult_SchnorrSignatureNoneZ *NONNULL_PTR orig); +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_StrZ_free(struct LDKCVec_StrZ _res); + /** * Frees the buffer pointed to by `data` if `datalen` is non-0. */ @@ -25893,30 +27558,30 @@ void CResult_ThirtyTwoBytesNoneZ_free(struct LDKCResult_ThirtyTwoBytesNoneZ _res struct LDKCResult_ThirtyTwoBytesNoneZ CResult_ThirtyTwoBytesNoneZ_clone(const struct LDKCResult_ThirtyTwoBytesNoneZ *NONNULL_PTR orig); /** - * Creates a new CResult_BlindedPayInfoDecodeErrorZ in the success state. + * Creates a new CResult_Bolt12InvoiceDecodeErrorZ in the success state. */ -struct LDKCResult_BlindedPayInfoDecodeErrorZ CResult_BlindedPayInfoDecodeErrorZ_ok(struct LDKBlindedPayInfo o); +struct LDKCResult_Bolt12InvoiceDecodeErrorZ CResult_Bolt12InvoiceDecodeErrorZ_ok(struct LDKBolt12Invoice o); /** - * Creates a new CResult_BlindedPayInfoDecodeErrorZ in the error state. + * Creates a new CResult_Bolt12InvoiceDecodeErrorZ in the error state. */ -struct LDKCResult_BlindedPayInfoDecodeErrorZ CResult_BlindedPayInfoDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_Bolt12InvoiceDecodeErrorZ CResult_Bolt12InvoiceDecodeErrorZ_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_Bolt12InvoiceDecodeErrorZ_is_ok(const struct LDKCResult_Bolt12InvoiceDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_BlindedPayInfoDecodeErrorZ. + * Frees any resources used by the CResult_Bolt12InvoiceDecodeErrorZ. */ -void CResult_BlindedPayInfoDecodeErrorZ_free(struct LDKCResult_BlindedPayInfoDecodeErrorZ _res); +void CResult_Bolt12InvoiceDecodeErrorZ_free(struct LDKCResult_Bolt12InvoiceDecodeErrorZ _res); /** - * Creates a new CResult_BlindedPayInfoDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_Bolt12InvoiceDecodeErrorZ 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_Bolt12InvoiceDecodeErrorZ CResult_Bolt12InvoiceDecodeErrorZ_clone(const struct LDKCResult_Bolt12InvoiceDecodeErrorZ *NONNULL_PTR orig); /** * Creates a new CResult_DelayedPaymentOutputDescriptorDecodeErrorZ in the success state. @@ -26122,56 +27787,82 @@ void CResult_HTLCDescriptorDecodeErrorZ_free(struct LDKCResult_HTLCDescriptorDec struct LDKCResult_HTLCDescriptorDecodeErrorZ CResult_HTLCDescriptorDecodeErrorZ_clone(const struct LDKCResult_HTLCDescriptorDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_NoneNoneZ in the success state. + * Creates a new CResult_PublicKeyNoneZ in the success state. */ -struct LDKCResult_NoneNoneZ CResult_NoneNoneZ_ok(void); +struct LDKCResult_PublicKeyNoneZ CResult_PublicKeyNoneZ_ok(struct LDKPublicKey o); /** - * Creates a new CResult_NoneNoneZ in the error state. + * Creates a new CResult_PublicKeyNoneZ in the error state. */ -struct LDKCResult_NoneNoneZ CResult_NoneNoneZ_err(void); +struct LDKCResult_PublicKeyNoneZ CResult_PublicKeyNoneZ_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); +bool CResult_PublicKeyNoneZ_is_ok(const struct LDKCResult_PublicKeyNoneZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_NoneNoneZ. + * Frees any resources used by the CResult_PublicKeyNoneZ. */ -void CResult_NoneNoneZ_free(struct LDKCResult_NoneNoneZ _res); +void CResult_PublicKeyNoneZ_free(struct LDKCResult_PublicKeyNoneZ _res); /** - * Creates a new CResult_NoneNoneZ which has the same data as `orig` + * Creates a new CResult_PublicKeyNoneZ 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_PublicKeyNoneZ CResult_PublicKeyNoneZ_clone(const struct LDKCResult_PublicKeyNoneZ *NONNULL_PTR orig); /** - * Creates a new CResult_PublicKeyNoneZ in the success state. + * Creates a new CResult__u832NoneZ in the success state. */ -struct LDKCResult_PublicKeyNoneZ CResult_PublicKeyNoneZ_ok(struct LDKPublicKey o); +struct LDKCResult__u832NoneZ CResult__u832NoneZ_ok(struct LDKThirtyTwoBytes o); /** - * Creates a new CResult_PublicKeyNoneZ in the error state. + * Creates a new CResult__u832NoneZ in the error state. */ -struct LDKCResult_PublicKeyNoneZ CResult_PublicKeyNoneZ_err(void); +struct LDKCResult__u832NoneZ CResult__u832NoneZ_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); +bool CResult__u832NoneZ_is_ok(const struct LDKCResult__u832NoneZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_PublicKeyNoneZ. + * Frees any resources used by the CResult__u832NoneZ. */ -void CResult_PublicKeyNoneZ_free(struct LDKCResult_PublicKeyNoneZ _res); +void CResult__u832NoneZ_free(struct LDKCResult__u832NoneZ _res); /** - * Creates a new CResult_PublicKeyNoneZ which has the same data as `orig` + * Creates a new CResult__u832NoneZ 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__u832NoneZ CResult__u832NoneZ_clone(const struct LDKCResult__u832NoneZ *NONNULL_PTR orig); + +/** + * 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); /** * Constructs a new COption_BigEndianScalarZ containing a crate::c_types::BigEndianScalar @@ -26194,11 +27885,6 @@ void COption_BigEndianScalarZ_free(struct LDKCOption_BigEndianScalarZ _res); */ struct LDKCOption_BigEndianScalarZ COption_BigEndianScalarZ_clone(const struct LDKCOption_BigEndianScalarZ *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. */ @@ -26278,30 +27964,30 @@ void CResult_TransactionNoneZ_free(struct LDKCResult_TransactionNoneZ _res); struct LDKCResult_TransactionNoneZ CResult_TransactionNoneZ_clone(const struct LDKCResult_TransactionNoneZ *NONNULL_PTR orig); /** - * Creates a new CResult_WriteableEcdsaChannelSignerDecodeErrorZ in the success state. + * Creates a new CResult_EcdsaChannelSignerDecodeErrorZ in the success state. */ -struct LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ CResult_WriteableEcdsaChannelSignerDecodeErrorZ_ok(struct LDKWriteableEcdsaChannelSigner o); +struct LDKCResult_EcdsaChannelSignerDecodeErrorZ CResult_EcdsaChannelSignerDecodeErrorZ_ok(struct LDKEcdsaChannelSigner o); /** - * Creates a new CResult_WriteableEcdsaChannelSignerDecodeErrorZ in the error state. + * Creates a new CResult_EcdsaChannelSignerDecodeErrorZ in the error state. */ -struct LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ CResult_WriteableEcdsaChannelSignerDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_EcdsaChannelSignerDecodeErrorZ CResult_EcdsaChannelSignerDecodeErrorZ_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); +bool CResult_EcdsaChannelSignerDecodeErrorZ_is_ok(const struct LDKCResult_EcdsaChannelSignerDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_WriteableEcdsaChannelSignerDecodeErrorZ. + * Frees any resources used by the CResult_EcdsaChannelSignerDecodeErrorZ. */ -void CResult_WriteableEcdsaChannelSignerDecodeErrorZ_free(struct LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ _res); +void CResult_EcdsaChannelSignerDecodeErrorZ_free(struct LDKCResult_EcdsaChannelSignerDecodeErrorZ _res); /** - * Creates a new CResult_WriteableEcdsaChannelSignerDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_EcdsaChannelSignerDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ CResult_WriteableEcdsaChannelSignerDecodeErrorZ_clone(const struct LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_EcdsaChannelSignerDecodeErrorZ CResult_EcdsaChannelSignerDecodeErrorZ_clone(const struct LDKCResult_EcdsaChannelSignerDecodeErrorZ *NONNULL_PTR orig); /** * Creates a new CResult_CVec_u8ZNoneZ in the success state. @@ -26537,6 +28223,48 @@ void CResult_NoneIOErrorZ_free(struct LDKCResult_NoneIOErrorZ _res); */ struct LDKCResult_NoneIOErrorZ CResult_NoneIOErrorZ_clone(const struct LDKCResult_NoneIOErrorZ *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_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ_clone(const struct LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ *NONNULL_PTR orig); + +/** + * Creates a new C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ from the contained elements. + */ +struct LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ_new(struct LDKThirtyTwoBytes a, struct LDKRecipientOnionFields b, struct LDKRouteParameters c); + +/** + * Frees any resources used by the C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ. + */ +void C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ_free(struct LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ _res); + +/** + * Creates a new CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ in the success state. + */ +struct LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ_ok(struct LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ o); + +/** + * Creates a new CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ in the error state. + */ +struct LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ_err(void); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ_is_ok(const struct LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ. + */ +void CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ_free(struct LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ _res); + +/** + * Creates a new CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ_clone(const struct LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ *NONNULL_PTR orig); + /** * Frees the buffer pointed to by `data` if `datalen` is non-0. */ @@ -26568,52 +28296,36 @@ void CResult_RouteLightningErrorZ_free(struct LDKCResult_RouteLightningErrorZ _r */ struct LDKCResult_RouteLightningErrorZ CResult_RouteLightningErrorZ_clone(const struct LDKCResult_RouteLightningErrorZ *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); +void CVec_BlindedPaymentPathZ_free(struct LDKCVec_BlindedPaymentPathZ _res); /** - * Creates a new CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ in the success state. + * Creates a new CResult_CVec_BlindedPaymentPathZNoneZ in the success state. */ -struct LDKCResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ_ok(struct LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ o); +struct LDKCResult_CVec_BlindedPaymentPathZNoneZ CResult_CVec_BlindedPaymentPathZNoneZ_ok(struct LDKCVec_BlindedPaymentPathZ o); /** - * Creates a new CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ in the error state. + * Creates a new CResult_CVec_BlindedPaymentPathZNoneZ in the error state. */ -struct LDKCResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ_err(void); +struct LDKCResult_CVec_BlindedPaymentPathZNoneZ CResult_CVec_BlindedPaymentPathZNoneZ_err(void); /** * Checks if the given object is currently in the success state */ -bool CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ_is_ok(const struct LDKCResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ *NONNULL_PTR o); +bool CResult_CVec_BlindedPaymentPathZNoneZ_is_ok(const struct LDKCResult_CVec_BlindedPaymentPathZNoneZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ. + * Frees any resources used by the CResult_CVec_BlindedPaymentPathZNoneZ. */ -void CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ_free(struct LDKCResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ _res); +void CResult_CVec_BlindedPaymentPathZNoneZ_free(struct LDKCResult_CVec_BlindedPaymentPathZNoneZ _res); /** - * Creates a new CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ which has the same data as `orig` + * Creates a new CResult_CVec_BlindedPaymentPathZNoneZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ_clone(const struct LDKCResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ *NONNULL_PTR orig); +struct LDKCResult_CVec_BlindedPaymentPathZNoneZ CResult_CVec_BlindedPaymentPathZNoneZ_clone(const struct LDKCResult_CVec_BlindedPaymentPathZNoneZ *NONNULL_PTR orig); /** * Frees the buffer pointed to by `data` if `datalen` is non-0. @@ -26647,30 +28359,35 @@ void CResult_OnionMessagePathNoneZ_free(struct LDKCResult_OnionMessagePathNoneZ struct LDKCResult_OnionMessagePathNoneZ CResult_OnionMessagePathNoneZ_clone(const struct LDKCResult_OnionMessagePathNoneZ *NONNULL_PTR orig); /** - * Creates a new CResult_CVec_BlindedPathZNoneZ in the success state. + * Creates a new CResult_CVec_BlindedMessagePathZNoneZ in the success state. */ -struct LDKCResult_CVec_BlindedPathZNoneZ CResult_CVec_BlindedPathZNoneZ_ok(struct LDKCVec_BlindedPathZ o); +struct LDKCResult_CVec_BlindedMessagePathZNoneZ CResult_CVec_BlindedMessagePathZNoneZ_ok(struct LDKCVec_BlindedMessagePathZ o); /** - * Creates a new CResult_CVec_BlindedPathZNoneZ in the error state. + * Creates a new CResult_CVec_BlindedMessagePathZNoneZ in the error state. */ -struct LDKCResult_CVec_BlindedPathZNoneZ CResult_CVec_BlindedPathZNoneZ_err(void); +struct LDKCResult_CVec_BlindedMessagePathZNoneZ CResult_CVec_BlindedMessagePathZNoneZ_err(void); /** * Checks if the given object is currently in the success state */ -bool CResult_CVec_BlindedPathZNoneZ_is_ok(const struct LDKCResult_CVec_BlindedPathZNoneZ *NONNULL_PTR o); +bool CResult_CVec_BlindedMessagePathZNoneZ_is_ok(const struct LDKCResult_CVec_BlindedMessagePathZNoneZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_CVec_BlindedPathZNoneZ. + * Frees any resources used by the CResult_CVec_BlindedMessagePathZNoneZ. */ -void CResult_CVec_BlindedPathZNoneZ_free(struct LDKCResult_CVec_BlindedPathZNoneZ _res); +void CResult_CVec_BlindedMessagePathZNoneZ_free(struct LDKCResult_CVec_BlindedMessagePathZNoneZ _res); /** - * Creates a new CResult_CVec_BlindedPathZNoneZ which has the same data as `orig` + * Creates a new CResult_CVec_BlindedMessagePathZNoneZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_CVec_BlindedPathZNoneZ CResult_CVec_BlindedPathZNoneZ_clone(const struct LDKCResult_CVec_BlindedPathZNoneZ *NONNULL_PTR orig); +struct LDKCResult_CVec_BlindedMessagePathZNoneZ CResult_CVec_BlindedMessagePathZNoneZ_clone(const struct LDKCResult_CVec_BlindedMessagePathZNoneZ *NONNULL_PTR orig); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_MessageForwardNodeZ_free(struct LDKCVec_MessageForwardNodeZ _res); /** * Creates a new CResult_InFlightHtlcsDecodeErrorZ in the success state. @@ -26853,11 +28570,6 @@ struct LDKCResult_PaymentParametersDecodeErrorZ CResult_PaymentParametersDecodeE */ 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. */ @@ -27474,6 +29186,32 @@ bool CResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ_is_ok( */ void CResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ_free(struct LDKCResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ _res); +/** + * Creates a new CResult_OfferDecodeErrorZ in the success state. + */ +struct LDKCResult_OfferDecodeErrorZ CResult_OfferDecodeErrorZ_ok(struct LDKOffer o); + +/** + * Creates a new CResult_OfferDecodeErrorZ in the error state. + */ +struct LDKCResult_OfferDecodeErrorZ CResult_OfferDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_OfferDecodeErrorZ_is_ok(const struct LDKCResult_OfferDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_OfferDecodeErrorZ. + */ +void CResult_OfferDecodeErrorZ_free(struct LDKCResult_OfferDecodeErrorZ _res); + +/** + * Creates a new CResult_OfferDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_OfferDecodeErrorZ CResult_OfferDecodeErrorZ_clone(const struct LDKCResult_OfferDecodeErrorZ *NONNULL_PTR orig); + /** * Creates a new CResult_OfferBolt12ParseErrorZ in the success state. */ @@ -27843,6 +29581,27 @@ void CResult_NodeAliasDecodeErrorZ_free(struct LDKCResult_NodeAliasDecodeErrorZ */ struct LDKCResult_NodeAliasDecodeErrorZ CResult_NodeAliasDecodeErrorZ_clone(const struct LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR orig); +/** + * Constructs a new COption_NodeAnnouncementInfoZ containing a crate::lightning::routing::gossip::NodeAnnouncementInfo + */ +struct LDKCOption_NodeAnnouncementInfoZ COption_NodeAnnouncementInfoZ_some(struct LDKNodeAnnouncementInfo o); + +/** + * Constructs a new COption_NodeAnnouncementInfoZ containing nothing + */ +struct LDKCOption_NodeAnnouncementInfoZ COption_NodeAnnouncementInfoZ_none(void); + +/** + * Frees any resources associated with the crate::lightning::routing::gossip::NodeAnnouncementInfo, if we are in the Some state + */ +void COption_NodeAnnouncementInfoZ_free(struct LDKCOption_NodeAnnouncementInfoZ _res); + +/** + * Creates a new COption_NodeAnnouncementInfoZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCOption_NodeAnnouncementInfoZ COption_NodeAnnouncementInfoZ_clone(const struct LDKCOption_NodeAnnouncementInfoZ *NONNULL_PTR orig); + /** * Creates a new CResult_NodeInfoDecodeErrorZ in the success state. */ @@ -28441,46 +30200,141 @@ void CResult_ThirtyTwoBytesAPIErrorZ_free(struct LDKCResult_ThirtyTwoBytesAPIErr struct LDKCResult_ThirtyTwoBytesAPIErrorZ CResult_ThirtyTwoBytesAPIErrorZ_clone(const struct LDKCResult_ThirtyTwoBytesAPIErrorZ *NONNULL_PTR orig); /** - * Constructs a new COption_OffersMessageZ containing a crate::lightning::onion_message::offers::OffersMessage + * Constructs a new COption_OffersContextZ containing a crate::lightning::blinded_path::message::OffersContext */ -struct LDKCOption_OffersMessageZ COption_OffersMessageZ_some(struct LDKOffersMessage o); +struct LDKCOption_OffersContextZ COption_OffersContextZ_some(struct LDKOffersContext o); /** - * Constructs a new COption_OffersMessageZ containing nothing + * Constructs a new COption_OffersContextZ containing nothing */ -struct LDKCOption_OffersMessageZ COption_OffersMessageZ_none(void); +struct LDKCOption_OffersContextZ COption_OffersContextZ_none(void); /** - * Frees any resources associated with the crate::lightning::onion_message::offers::OffersMessage, if we are in the Some state + * Frees any resources associated with the crate::lightning::blinded_path::message::OffersContext, if we are in the Some state */ -void COption_OffersMessageZ_free(struct LDKCOption_OffersMessageZ _res); +void COption_OffersContextZ_free(struct LDKCOption_OffersContextZ _res); /** - * Creates a new COption_OffersMessageZ which has the same data as `orig` + * Creates a new COption_OffersContextZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCOption_OffersMessageZ COption_OffersMessageZ_clone(const struct LDKCOption_OffersMessageZ *NONNULL_PTR orig); +struct LDKCOption_OffersContextZ COption_OffersContextZ_clone(const struct LDKCOption_OffersContextZ *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_OffersMessageDestinationBlindedPathZ C3Tuple_OffersMessageDestinationBlindedPathZ_clone(const struct LDKC3Tuple_OffersMessageDestinationBlindedPathZ *NONNULL_PTR orig); +struct LDKC2Tuple_OffersMessageResponseInstructionZ C2Tuple_OffersMessageResponseInstructionZ_clone(const struct LDKC2Tuple_OffersMessageResponseInstructionZ *NONNULL_PTR orig); + +/** + * Creates a new C2Tuple_OffersMessageResponseInstructionZ from the contained elements. + */ +struct LDKC2Tuple_OffersMessageResponseInstructionZ C2Tuple_OffersMessageResponseInstructionZ_new(struct LDKOffersMessage a, struct LDKResponseInstruction b); + +/** + * Frees any resources used by the C2Tuple_OffersMessageResponseInstructionZ. + */ +void C2Tuple_OffersMessageResponseInstructionZ_free(struct LDKC2Tuple_OffersMessageResponseInstructionZ _res); + +/** + * Constructs a new COption_C2Tuple_OffersMessageResponseInstructionZZ containing a crate::c_types::derived::C2Tuple_OffersMessageResponseInstructionZ + */ +struct LDKCOption_C2Tuple_OffersMessageResponseInstructionZZ COption_C2Tuple_OffersMessageResponseInstructionZZ_some(struct LDKC2Tuple_OffersMessageResponseInstructionZ o); + +/** + * Constructs a new COption_C2Tuple_OffersMessageResponseInstructionZZ containing nothing + */ +struct LDKCOption_C2Tuple_OffersMessageResponseInstructionZZ COption_C2Tuple_OffersMessageResponseInstructionZZ_none(void); /** - * Creates a new C3Tuple_OffersMessageDestinationBlindedPathZ from the contained elements. + * Frees any resources associated with the crate::c_types::derived::C2Tuple_OffersMessageResponseInstructionZ, if we are in the Some state */ -struct LDKC3Tuple_OffersMessageDestinationBlindedPathZ C3Tuple_OffersMessageDestinationBlindedPathZ_new(struct LDKOffersMessage a, struct LDKDestination b, struct LDKBlindedPath c); +void COption_C2Tuple_OffersMessageResponseInstructionZZ_free(struct LDKCOption_C2Tuple_OffersMessageResponseInstructionZZ _res); /** - * Frees any resources used by the C3Tuple_OffersMessageDestinationBlindedPathZ. + * Creates a new COption_C2Tuple_OffersMessageResponseInstructionZZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -void C3Tuple_OffersMessageDestinationBlindedPathZ_free(struct LDKC3Tuple_OffersMessageDestinationBlindedPathZ _res); +struct LDKCOption_C2Tuple_OffersMessageResponseInstructionZZ COption_C2Tuple_OffersMessageResponseInstructionZZ_clone(const struct LDKCOption_C2Tuple_OffersMessageResponseInstructionZZ *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_OffersMessageMessageSendInstructionsZ C2Tuple_OffersMessageMessageSendInstructionsZ_clone(const struct LDKC2Tuple_OffersMessageMessageSendInstructionsZ *NONNULL_PTR orig); + +/** + * Creates a new C2Tuple_OffersMessageMessageSendInstructionsZ from the contained elements. + */ +struct LDKC2Tuple_OffersMessageMessageSendInstructionsZ C2Tuple_OffersMessageMessageSendInstructionsZ_new(struct LDKOffersMessage a, struct LDKMessageSendInstructions b); + +/** + * Frees any resources used by the C2Tuple_OffersMessageMessageSendInstructionsZ. + */ +void C2Tuple_OffersMessageMessageSendInstructionsZ_free(struct LDKC2Tuple_OffersMessageMessageSendInstructionsZ _res); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_C2Tuple_OffersMessageMessageSendInstructionsZZ_free(struct LDKCVec_C2Tuple_OffersMessageMessageSendInstructionsZZ _res); + +/** + * Creates a new tuple which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKC2Tuple_ReleaseHeldHtlcResponseInstructionZ C2Tuple_ReleaseHeldHtlcResponseInstructionZ_clone(const struct LDKC2Tuple_ReleaseHeldHtlcResponseInstructionZ *NONNULL_PTR orig); + +/** + * Creates a new C2Tuple_ReleaseHeldHtlcResponseInstructionZ from the contained elements. + */ +struct LDKC2Tuple_ReleaseHeldHtlcResponseInstructionZ C2Tuple_ReleaseHeldHtlcResponseInstructionZ_new(struct LDKReleaseHeldHtlc a, struct LDKResponseInstruction b); + +/** + * Frees any resources used by the C2Tuple_ReleaseHeldHtlcResponseInstructionZ. + */ +void C2Tuple_ReleaseHeldHtlcResponseInstructionZ_free(struct LDKC2Tuple_ReleaseHeldHtlcResponseInstructionZ _res); + +/** + * Constructs a new COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ containing a crate::c_types::derived::C2Tuple_ReleaseHeldHtlcResponseInstructionZ + */ +struct LDKCOption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ_some(struct LDKC2Tuple_ReleaseHeldHtlcResponseInstructionZ o); + +/** + * Constructs a new COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ containing nothing + */ +struct LDKCOption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ_none(void); + +/** + * Frees any resources associated with the crate::c_types::derived::C2Tuple_ReleaseHeldHtlcResponseInstructionZ, if we are in the Some state + */ +void COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ_free(struct LDKCOption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ _res); + +/** + * Creates a new COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCOption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ_clone(const struct LDKCOption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ *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_AsyncPaymentsMessageMessageSendInstructionsZ C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ_clone(const struct LDKC2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ *NONNULL_PTR orig); + +/** + * Creates a new C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ from the contained elements. + */ +struct LDKC2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ_new(struct LDKAsyncPaymentsMessage a, struct LDKMessageSendInstructions b); + +/** + * Frees any resources used by the C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ. + */ +void C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ_free(struct LDKC2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ _res); /** * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -void CVec_C3Tuple_OffersMessageDestinationBlindedPathZZ_free(struct LDKCVec_C3Tuple_OffersMessageDestinationBlindedPathZZ _res); +void CVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ_free(struct LDKCVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ _res); /** * Creates a new CResult_PhantomRouteHintsDecodeErrorZ in the success state. @@ -28924,6 +30778,32 @@ void C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ_free(struct LDKC2Tuple_Th */ void CVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZZ_free(struct LDKCVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZZ _res); +/** + * Creates a new CResult_NoneReplayEventZ in the success state. + */ +struct LDKCResult_NoneReplayEventZ CResult_NoneReplayEventZ_ok(void); + +/** + * Creates a new CResult_NoneReplayEventZ in the error state. + */ +struct LDKCResult_NoneReplayEventZ CResult_NoneReplayEventZ_err(struct LDKReplayEvent e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_NoneReplayEventZ_is_ok(const struct LDKCResult_NoneReplayEventZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_NoneReplayEventZ. + */ +void CResult_NoneReplayEventZ_free(struct LDKCResult_NoneReplayEventZ _res); + +/** + * Creates a new CResult_NoneReplayEventZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_NoneReplayEventZ CResult_NoneReplayEventZ_clone(const struct LDKCResult_NoneReplayEventZ *NONNULL_PTR orig); + /** * Frees the buffer pointed to by `data` if `datalen` is non-0. */ @@ -29043,22 +30923,38 @@ void CVec_C2Tuple_PublicKeyTypeZZ_free(struct LDKCVec_C2Tuple_PublicKeyTypeZZ _r * Creates a new tuple which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKC2Tuple_PublicKeyCVec_SocketAddressZZ C2Tuple_PublicKeyCVec_SocketAddressZZ_clone(const struct LDKC2Tuple_PublicKeyCVec_SocketAddressZZ *NONNULL_PTR orig); +struct LDKC2Tuple_OnionMessageContentsResponseInstructionZ C2Tuple_OnionMessageContentsResponseInstructionZ_clone(const struct LDKC2Tuple_OnionMessageContentsResponseInstructionZ *NONNULL_PTR orig); /** - * Creates a new C2Tuple_PublicKeyCVec_SocketAddressZZ from the contained elements. + * Creates a new C2Tuple_OnionMessageContentsResponseInstructionZ from the contained elements. */ -struct LDKC2Tuple_PublicKeyCVec_SocketAddressZZ C2Tuple_PublicKeyCVec_SocketAddressZZ_new(struct LDKPublicKey a, struct LDKCVec_SocketAddressZ b); +struct LDKC2Tuple_OnionMessageContentsResponseInstructionZ C2Tuple_OnionMessageContentsResponseInstructionZ_new(struct LDKOnionMessageContents a, struct LDKResponseInstruction b); /** - * Frees any resources used by the C2Tuple_PublicKeyCVec_SocketAddressZZ. + * Frees any resources used by the C2Tuple_OnionMessageContentsResponseInstructionZ. */ -void C2Tuple_PublicKeyCVec_SocketAddressZZ_free(struct LDKC2Tuple_PublicKeyCVec_SocketAddressZZ _res); +void C2Tuple_OnionMessageContentsResponseInstructionZ_free(struct LDKC2Tuple_OnionMessageContentsResponseInstructionZ _res); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Constructs a new COption_C2Tuple_OnionMessageContentsResponseInstructionZZ containing a crate::c_types::derived::C2Tuple_OnionMessageContentsResponseInstructionZ + */ +struct LDKCOption_C2Tuple_OnionMessageContentsResponseInstructionZZ COption_C2Tuple_OnionMessageContentsResponseInstructionZZ_some(struct LDKC2Tuple_OnionMessageContentsResponseInstructionZ o); + +/** + * Constructs a new COption_C2Tuple_OnionMessageContentsResponseInstructionZZ containing nothing */ -void CVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ_free(struct LDKCVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ _res); +struct LDKCOption_C2Tuple_OnionMessageContentsResponseInstructionZZ COption_C2Tuple_OnionMessageContentsResponseInstructionZZ_none(void); + +/** + * Frees any resources associated with the crate::c_types::derived::C2Tuple_OnionMessageContentsResponseInstructionZ, if we are in the Some state + */ +void COption_C2Tuple_OnionMessageContentsResponseInstructionZZ_free(struct LDKCOption_C2Tuple_OnionMessageContentsResponseInstructionZZ _res); + +/** + * Creates a new COption_C2Tuple_OnionMessageContentsResponseInstructionZZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCOption_C2Tuple_OnionMessageContentsResponseInstructionZZ COption_C2Tuple_OnionMessageContentsResponseInstructionZZ_clone(const struct LDKCOption_C2Tuple_OnionMessageContentsResponseInstructionZZ *NONNULL_PTR orig); /** * Constructs a new COption_OnionMessageContentsZ containing a crate::lightning::onion_message::packet::OnionMessageContents @@ -29111,22 +31007,22 @@ struct LDKCResult_COption_OnionMessageContentsZDecodeErrorZ CResult_COption_Onio * Creates a new tuple which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ C3Tuple_OnionMessageContentsDestinationBlindedPathZ_clone(const struct LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ *NONNULL_PTR orig); +struct LDKC2Tuple_OnionMessageContentsMessageSendInstructionsZ C2Tuple_OnionMessageContentsMessageSendInstructionsZ_clone(const struct LDKC2Tuple_OnionMessageContentsMessageSendInstructionsZ *NONNULL_PTR orig); /** - * Creates a new C3Tuple_OnionMessageContentsDestinationBlindedPathZ from the contained elements. + * Creates a new C2Tuple_OnionMessageContentsMessageSendInstructionsZ from the contained elements. */ -struct LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ C3Tuple_OnionMessageContentsDestinationBlindedPathZ_new(struct LDKOnionMessageContents a, struct LDKDestination b, struct LDKBlindedPath c); +struct LDKC2Tuple_OnionMessageContentsMessageSendInstructionsZ C2Tuple_OnionMessageContentsMessageSendInstructionsZ_new(struct LDKOnionMessageContents a, struct LDKMessageSendInstructions b); /** - * Frees any resources used by the C3Tuple_OnionMessageContentsDestinationBlindedPathZ. + * Frees any resources used by the C2Tuple_OnionMessageContentsMessageSendInstructionsZ. */ -void C3Tuple_OnionMessageContentsDestinationBlindedPathZ_free(struct LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ _res); +void C2Tuple_OnionMessageContentsMessageSendInstructionsZ_free(struct LDKC2Tuple_OnionMessageContentsMessageSendInstructionsZ _res); /** * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -void CVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ_free(struct LDKCVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ _res); +void CVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ_free(struct LDKCVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ _res); /** * Constructs a new COption_TypeZ containing a crate::lightning::ln::wire::Type @@ -29325,11 +31221,6 @@ void CResult_CVec_u8ZIOErrorZ_free(struct LDKCResult_CVec_u8ZIOErrorZ _res); */ struct LDKCResult_CVec_u8ZIOErrorZ CResult_CVec_u8ZIOErrorZ_clone(const struct LDKCResult_CVec_u8ZIOErrorZ *NONNULL_PTR orig); -/** - * Frees the buffer pointed to by `data` if `datalen` is non-0. - */ -void CVec_StrZ_free(struct LDKCVec_StrZ _res); - /** * Creates a new CResult_CVec_StrZIOErrorZ in the success state. */ @@ -29465,27 +31356,6 @@ void CResult_InvoiceRequestBolt12SemanticErrorZ_free(struct LDKCResult_InvoiceRe */ struct LDKCResult_InvoiceRequestBolt12SemanticErrorZ CResult_InvoiceRequestBolt12SemanticErrorZ_clone(const struct LDKCResult_InvoiceRequestBolt12SemanticErrorZ *NONNULL_PTR orig); -/** - * Constructs a new COption_SecretKeyZ containing a crate::c_types::SecretKey - */ -struct LDKCOption_SecretKeyZ COption_SecretKeyZ_some(struct LDKSecretKey o); - -/** - * Constructs a new COption_SecretKeyZ containing nothing - */ -struct LDKCOption_SecretKeyZ COption_SecretKeyZ_none(void); - -/** - * Frees any resources associated with the crate::c_types::SecretKey, if we are in the Some state - */ -void COption_SecretKeyZ_free(struct LDKCOption_SecretKeyZ _res); - -/** - * Creates a new COption_SecretKeyZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKCOption_SecretKeyZ COption_SecretKeyZ_clone(const struct LDKCOption_SecretKeyZ *NONNULL_PTR orig); - /** * Creates a new CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ in the success state. */ @@ -29791,30 +31661,30 @@ void CResult_StfuDecodeErrorZ_free(struct LDKCResult_StfuDecodeErrorZ _res); struct LDKCResult_StfuDecodeErrorZ CResult_StfuDecodeErrorZ_clone(const struct LDKCResult_StfuDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_SpliceDecodeErrorZ in the success state. + * Creates a new CResult_SpliceInitDecodeErrorZ in the success state. */ -struct LDKCResult_SpliceDecodeErrorZ CResult_SpliceDecodeErrorZ_ok(struct LDKSplice o); +struct LDKCResult_SpliceInitDecodeErrorZ CResult_SpliceInitDecodeErrorZ_ok(struct LDKSpliceInit o); /** - * Creates a new CResult_SpliceDecodeErrorZ in the error state. + * Creates a new CResult_SpliceInitDecodeErrorZ in the error state. */ -struct LDKCResult_SpliceDecodeErrorZ CResult_SpliceDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_SpliceInitDecodeErrorZ CResult_SpliceInitDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_SpliceDecodeErrorZ_is_ok(const struct LDKCResult_SpliceDecodeErrorZ *NONNULL_PTR o); +bool CResult_SpliceInitDecodeErrorZ_is_ok(const struct LDKCResult_SpliceInitDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_SpliceDecodeErrorZ. + * Frees any resources used by the CResult_SpliceInitDecodeErrorZ. */ -void CResult_SpliceDecodeErrorZ_free(struct LDKCResult_SpliceDecodeErrorZ _res); +void CResult_SpliceInitDecodeErrorZ_free(struct LDKCResult_SpliceInitDecodeErrorZ _res); /** - * Creates a new CResult_SpliceDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_SpliceInitDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_SpliceDecodeErrorZ CResult_SpliceDecodeErrorZ_clone(const struct LDKCResult_SpliceDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_SpliceInitDecodeErrorZ CResult_SpliceInitDecodeErrorZ_clone(const struct LDKCResult_SpliceInitDecodeErrorZ *NONNULL_PTR orig); /** * Creates a new CResult_SpliceAckDecodeErrorZ in the success state. @@ -30206,6 +32076,32 @@ void CResult_ClosingSignedFeeRangeDecodeErrorZ_free(struct LDKCResult_ClosingSig */ struct LDKCResult_ClosingSignedFeeRangeDecodeErrorZ CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(const struct LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR orig); +/** + * Creates a new CResult_CommitmentSignedBatchDecodeErrorZ in the success state. + */ +struct LDKCResult_CommitmentSignedBatchDecodeErrorZ CResult_CommitmentSignedBatchDecodeErrorZ_ok(struct LDKCommitmentSignedBatch o); + +/** + * Creates a new CResult_CommitmentSignedBatchDecodeErrorZ in the error state. + */ +struct LDKCResult_CommitmentSignedBatchDecodeErrorZ CResult_CommitmentSignedBatchDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_CommitmentSignedBatchDecodeErrorZ_is_ok(const struct LDKCResult_CommitmentSignedBatchDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_CommitmentSignedBatchDecodeErrorZ. + */ +void CResult_CommitmentSignedBatchDecodeErrorZ_free(struct LDKCResult_CommitmentSignedBatchDecodeErrorZ _res); + +/** + * Creates a new CResult_CommitmentSignedBatchDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_CommitmentSignedBatchDecodeErrorZ CResult_CommitmentSignedBatchDecodeErrorZ_clone(const struct LDKCResult_CommitmentSignedBatchDecodeErrorZ *NONNULL_PTR orig); + /** * Creates a new CResult_CommitmentSignedDecodeErrorZ in the success state. */ @@ -31038,37 +32934,6 @@ void CResult_GossipTimestampFilterDecodeErrorZ_free(struct LDKCResult_GossipTime */ struct LDKCResult_GossipTimestampFilterDecodeErrorZ CResult_GossipTimestampFilterDecodeErrorZ_clone(const struct LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR orig); -/** - * Frees the buffer pointed to by `data` if `datalen` is non-0. - */ -void CVec_PhantomRouteHintsZ_free(struct LDKCVec_PhantomRouteHintsZ _res); - -/** - * Creates a new CResult_Bolt11InvoiceSignOrCreationErrorZ in the success state. - */ -struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ CResult_Bolt11InvoiceSignOrCreationErrorZ_ok(struct LDKBolt11Invoice o); - -/** - * Creates a new CResult_Bolt11InvoiceSignOrCreationErrorZ in the error state. - */ -struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ CResult_Bolt11InvoiceSignOrCreationErrorZ_err(struct LDKSignOrCreationError e); - -/** - * Checks if the given object is currently in the success state - */ -bool CResult_Bolt11InvoiceSignOrCreationErrorZ_is_ok(const struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ *NONNULL_PTR o); - -/** - * Frees any resources used by the CResult_Bolt11InvoiceSignOrCreationErrorZ. - */ -void CResult_Bolt11InvoiceSignOrCreationErrorZ_free(struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ _res); - -/** - * Creates a new CResult_Bolt11InvoiceSignOrCreationErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ CResult_Bolt11InvoiceSignOrCreationErrorZ_clone(const struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ *NONNULL_PTR orig); - /** * Constructs a new COption_InboundHTLCStateDetailsZ containing a crate::lightning::ln::channel_state::InboundHTLCStateDetails */ @@ -31355,6 +33220,84 @@ struct LDKCResult_ChannelShutdownStateDecodeErrorZ CResult_ChannelShutdownStateD */ void CVec_FutureZ_free(struct LDKCVec_FutureZ _res); +/** + * Creates a new CResult_HeldHtlcAvailableDecodeErrorZ in the success state. + */ +struct LDKCResult_HeldHtlcAvailableDecodeErrorZ CResult_HeldHtlcAvailableDecodeErrorZ_ok(struct LDKHeldHtlcAvailable o); + +/** + * Creates a new CResult_HeldHtlcAvailableDecodeErrorZ in the error state. + */ +struct LDKCResult_HeldHtlcAvailableDecodeErrorZ CResult_HeldHtlcAvailableDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_HeldHtlcAvailableDecodeErrorZ_is_ok(const struct LDKCResult_HeldHtlcAvailableDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_HeldHtlcAvailableDecodeErrorZ. + */ +void CResult_HeldHtlcAvailableDecodeErrorZ_free(struct LDKCResult_HeldHtlcAvailableDecodeErrorZ _res); + +/** + * Creates a new CResult_HeldHtlcAvailableDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_HeldHtlcAvailableDecodeErrorZ CResult_HeldHtlcAvailableDecodeErrorZ_clone(const struct LDKCResult_HeldHtlcAvailableDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_ReleaseHeldHtlcDecodeErrorZ in the success state. + */ +struct LDKCResult_ReleaseHeldHtlcDecodeErrorZ CResult_ReleaseHeldHtlcDecodeErrorZ_ok(struct LDKReleaseHeldHtlc o); + +/** + * Creates a new CResult_ReleaseHeldHtlcDecodeErrorZ in the error state. + */ +struct LDKCResult_ReleaseHeldHtlcDecodeErrorZ CResult_ReleaseHeldHtlcDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_ReleaseHeldHtlcDecodeErrorZ_is_ok(const struct LDKCResult_ReleaseHeldHtlcDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_ReleaseHeldHtlcDecodeErrorZ. + */ +void CResult_ReleaseHeldHtlcDecodeErrorZ_free(struct LDKCResult_ReleaseHeldHtlcDecodeErrorZ _res); + +/** + * Creates a new CResult_ReleaseHeldHtlcDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_ReleaseHeldHtlcDecodeErrorZ CResult_ReleaseHeldHtlcDecodeErrorZ_clone(const struct LDKCResult_ReleaseHeldHtlcDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_AsyncPaymentsMessageDecodeErrorZ in the success state. + */ +struct LDKCResult_AsyncPaymentsMessageDecodeErrorZ CResult_AsyncPaymentsMessageDecodeErrorZ_ok(struct LDKAsyncPaymentsMessage o); + +/** + * Creates a new CResult_AsyncPaymentsMessageDecodeErrorZ in the error state. + */ +struct LDKCResult_AsyncPaymentsMessageDecodeErrorZ CResult_AsyncPaymentsMessageDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_AsyncPaymentsMessageDecodeErrorZ_is_ok(const struct LDKCResult_AsyncPaymentsMessageDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_AsyncPaymentsMessageDecodeErrorZ. + */ +void CResult_AsyncPaymentsMessageDecodeErrorZ_free(struct LDKCResult_AsyncPaymentsMessageDecodeErrorZ _res); + +/** + * Creates a new CResult_AsyncPaymentsMessageDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_AsyncPaymentsMessageDecodeErrorZ CResult_AsyncPaymentsMessageDecodeErrorZ_clone(const struct LDKCResult_AsyncPaymentsMessageDecodeErrorZ *NONNULL_PTR orig); + /** * Creates a new CResult_OffersMessageDecodeErrorZ in the success state. */ @@ -31774,6 +33717,32 @@ struct LDKCResult_ShutdownScriptInvalidShutdownScriptZ CResult_ShutdownScriptInv */ void CVec_TransactionZ_free(struct LDKCVec_TransactionZ _res); +/** + * Creates a new CResult_FundingInfoDecodeErrorZ in the success state. + */ +struct LDKCResult_FundingInfoDecodeErrorZ CResult_FundingInfoDecodeErrorZ_ok(struct LDKFundingInfo o); + +/** + * Creates a new CResult_FundingInfoDecodeErrorZ in the error state. + */ +struct LDKCResult_FundingInfoDecodeErrorZ CResult_FundingInfoDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_FundingInfoDecodeErrorZ_is_ok(const struct LDKCResult_FundingInfoDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_FundingInfoDecodeErrorZ. + */ +void CResult_FundingInfoDecodeErrorZ_free(struct LDKCResult_FundingInfoDecodeErrorZ _res); + +/** + * Creates a new CResult_FundingInfoDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_FundingInfoDecodeErrorZ CResult_FundingInfoDecodeErrorZ_clone(const struct LDKCResult_FundingInfoDecodeErrorZ *NONNULL_PTR orig); + /** * Creates a new CResult_PaymentPurposeDecodeErrorZ in the success state. */ @@ -31968,77 +33937,77 @@ void CResult_COption_HTLCDestinationZDecodeErrorZ_free(struct LDKCResult_COption struct LDKCResult_COption_HTLCDestinationZDecodeErrorZ CResult_COption_HTLCDestinationZDecodeErrorZ_clone(const struct LDKCResult_COption_HTLCDestinationZDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_PaymentFailureReasonDecodeErrorZ in the success state. + * Constructs a new COption_PaymentFailureReasonZ containing a crate::lightning::events::PaymentFailureReason */ -struct LDKCResult_PaymentFailureReasonDecodeErrorZ CResult_PaymentFailureReasonDecodeErrorZ_ok(enum LDKPaymentFailureReason o); +struct LDKCOption_PaymentFailureReasonZ COption_PaymentFailureReasonZ_some(enum LDKPaymentFailureReason o); /** - * Creates a new CResult_PaymentFailureReasonDecodeErrorZ in the error state. + * Constructs a new COption_PaymentFailureReasonZ containing nothing */ -struct LDKCResult_PaymentFailureReasonDecodeErrorZ CResult_PaymentFailureReasonDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCOption_PaymentFailureReasonZ COption_PaymentFailureReasonZ_none(void); /** - * Checks if the given object is currently in the success state + * Frees any resources associated with the crate::lightning::events::PaymentFailureReason, if we are in the Some state */ -bool CResult_PaymentFailureReasonDecodeErrorZ_is_ok(const struct LDKCResult_PaymentFailureReasonDecodeErrorZ *NONNULL_PTR o); +void COption_PaymentFailureReasonZ_free(struct LDKCOption_PaymentFailureReasonZ _res); /** - * Frees any resources used by the CResult_PaymentFailureReasonDecodeErrorZ. + * Creates a new COption_PaymentFailureReasonZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -void CResult_PaymentFailureReasonDecodeErrorZ_free(struct LDKCResult_PaymentFailureReasonDecodeErrorZ _res); +struct LDKCOption_PaymentFailureReasonZ COption_PaymentFailureReasonZ_clone(const struct LDKCOption_PaymentFailureReasonZ *NONNULL_PTR orig); /** - * Creates a new CResult_PaymentFailureReasonDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Creates a new CResult_COption_PaymentFailureReasonZDecodeErrorZ in the success state. */ -struct LDKCResult_PaymentFailureReasonDecodeErrorZ CResult_PaymentFailureReasonDecodeErrorZ_clone(const struct LDKCResult_PaymentFailureReasonDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_COption_PaymentFailureReasonZDecodeErrorZ CResult_COption_PaymentFailureReasonZDecodeErrorZ_ok(struct LDKCOption_PaymentFailureReasonZ o); /** - * Constructs a new COption_U128Z containing a crate::c_types::U128 + * Creates a new CResult_COption_PaymentFailureReasonZDecodeErrorZ in the error state. */ -struct LDKCOption_U128Z COption_U128Z_some(struct LDKU128 o); +struct LDKCResult_COption_PaymentFailureReasonZDecodeErrorZ CResult_COption_PaymentFailureReasonZDecodeErrorZ_err(struct LDKDecodeError e); /** - * Constructs a new COption_U128Z containing nothing + * Checks if the given object is currently in the success state */ -struct LDKCOption_U128Z COption_U128Z_none(void); +bool CResult_COption_PaymentFailureReasonZDecodeErrorZ_is_ok(const struct LDKCResult_COption_PaymentFailureReasonZDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources associated with the crate::c_types::U128, if we are in the Some state + * Frees any resources used by the CResult_COption_PaymentFailureReasonZDecodeErrorZ. */ -void COption_U128Z_free(struct LDKCOption_U128Z _res); +void CResult_COption_PaymentFailureReasonZDecodeErrorZ_free(struct LDKCResult_COption_PaymentFailureReasonZDecodeErrorZ _res); /** - * Creates a new COption_U128Z which has the same data as `orig` + * Creates a new CResult_COption_PaymentFailureReasonZDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCOption_U128Z COption_U128Z_clone(const struct LDKCOption_U128Z *NONNULL_PTR orig); +struct LDKCResult_COption_PaymentFailureReasonZDecodeErrorZ CResult_COption_PaymentFailureReasonZDecodeErrorZ_clone(const struct LDKCResult_COption_PaymentFailureReasonZDecodeErrorZ *NONNULL_PTR orig); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Constructs a new COption_U128Z containing a crate::c_types::U128 */ -void CVec_ClaimedHTLCZ_free(struct LDKCVec_ClaimedHTLCZ _res); +struct LDKCOption_U128Z COption_U128Z_some(struct LDKU128 o); /** - * Constructs a new COption_PaymentFailureReasonZ containing a crate::lightning::events::PaymentFailureReason + * Constructs a new COption_U128Z containing nothing */ -struct LDKCOption_PaymentFailureReasonZ COption_PaymentFailureReasonZ_some(enum LDKPaymentFailureReason o); +struct LDKCOption_U128Z COption_U128Z_none(void); /** - * Constructs a new COption_PaymentFailureReasonZ containing nothing + * Frees any resources associated with the crate::c_types::U128, if we are in the Some state */ -struct LDKCOption_PaymentFailureReasonZ COption_PaymentFailureReasonZ_none(void); +void COption_U128Z_free(struct LDKCOption_U128Z _res); /** - * Frees any resources associated with the crate::lightning::events::PaymentFailureReason, if we are in the Some state + * Creates a new COption_U128Z which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -void COption_PaymentFailureReasonZ_free(struct LDKCOption_PaymentFailureReasonZ _res); +struct LDKCOption_U128Z COption_U128Z_clone(const struct LDKCOption_U128Z *NONNULL_PTR orig); /** - * Creates a new COption_PaymentFailureReasonZ 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 LDKCOption_PaymentFailureReasonZ COption_PaymentFailureReasonZ_clone(const struct LDKCOption_PaymentFailureReasonZ *NONNULL_PTR orig); +void CVec_ClaimedHTLCZ_free(struct LDKCVec_ClaimedHTLCZ _res); /** * Constructs a new COption_EventZ containing a crate::lightning::events::Event @@ -32087,6 +34056,37 @@ void CResult_COption_EventZDecodeErrorZ_free(struct LDKCResult_COption_EventZDec */ struct LDKCResult_COption_EventZDecodeErrorZ CResult_COption_EventZDecodeErrorZ_clone(const struct LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR orig); +/** + * Creates a new CResult_NonceDecodeErrorZ in the success state. + */ +struct LDKCResult_NonceDecodeErrorZ CResult_NonceDecodeErrorZ_ok(struct LDKNonce o); + +/** + * Creates a new CResult_NonceDecodeErrorZ in the error state. + */ +struct LDKCResult_NonceDecodeErrorZ CResult_NonceDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_NonceDecodeErrorZ_is_ok(const struct LDKCResult_NonceDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_NonceDecodeErrorZ. + */ +void CResult_NonceDecodeErrorZ_free(struct LDKCResult_NonceDecodeErrorZ _res); + +/** + * Creates a new CResult_NonceDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_NonceDecodeErrorZ CResult_NonceDecodeErrorZ_clone(const struct LDKCResult_NonceDecodeErrorZ *NONNULL_PTR orig); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_RouteHintHopZ_free(struct LDKCVec_RouteHintHopZ _res); + /** * Creates a new CResult_SiPrefixBolt11ParseErrorZ in the success state. */ @@ -32394,6 +34394,32 @@ void CResult_BigSizeDecodeErrorZ_free(struct LDKCResult_BigSizeDecodeErrorZ _res */ struct LDKCResult_BigSizeDecodeErrorZ CResult_BigSizeDecodeErrorZ_clone(const struct LDKCResult_BigSizeDecodeErrorZ *NONNULL_PTR orig); +/** + * Creates a new CResult_UntrustedStringDecodeErrorZ in the success state. + */ +struct LDKCResult_UntrustedStringDecodeErrorZ CResult_UntrustedStringDecodeErrorZ_ok(struct LDKUntrustedString o); + +/** + * Creates a new CResult_UntrustedStringDecodeErrorZ in the error state. + */ +struct LDKCResult_UntrustedStringDecodeErrorZ CResult_UntrustedStringDecodeErrorZ_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); + +/** + * Frees any resources used by the CResult_UntrustedStringDecodeErrorZ. + */ +void CResult_UntrustedStringDecodeErrorZ_free(struct LDKCResult_UntrustedStringDecodeErrorZ _res); + +/** + * Creates a new CResult_UntrustedStringDecodeErrorZ 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); + /** * Creates a new CResult_HostnameDecodeErrorZ in the success state. */ @@ -32473,72 +34499,103 @@ void CResult_TransactionU16LenLimitedDecodeErrorZ_free(struct LDKCResult_Transac struct LDKCResult_TransactionU16LenLimitedDecodeErrorZ CResult_TransactionU16LenLimitedDecodeErrorZ_clone(const struct LDKCResult_TransactionU16LenLimitedDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_UntrustedStringDecodeErrorZ in the success state. + * Creates a new CResult_ChannelIdDecodeErrorZ in the success state. */ -struct LDKCResult_UntrustedStringDecodeErrorZ CResult_UntrustedStringDecodeErrorZ_ok(struct LDKUntrustedString o); +struct LDKCResult_ChannelIdDecodeErrorZ CResult_ChannelIdDecodeErrorZ_ok(struct LDKChannelId o); /** - * Creates a new CResult_UntrustedStringDecodeErrorZ in the error state. + * Creates a new CResult_ChannelIdDecodeErrorZ in the error state. */ -struct LDKCResult_UntrustedStringDecodeErrorZ CResult_UntrustedStringDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_ChannelIdDecodeErrorZ CResult_ChannelIdDecodeErrorZ_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_ChannelIdDecodeErrorZ_is_ok(const struct LDKCResult_ChannelIdDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_UntrustedStringDecodeErrorZ. + * Frees any resources used by the CResult_ChannelIdDecodeErrorZ. */ -void CResult_UntrustedStringDecodeErrorZ_free(struct LDKCResult_UntrustedStringDecodeErrorZ _res); +void CResult_ChannelIdDecodeErrorZ_free(struct LDKCResult_ChannelIdDecodeErrorZ _res); /** - * Creates a new CResult_UntrustedStringDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_ChannelIdDecodeErrorZ 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_ChannelIdDecodeErrorZ CResult_ChannelIdDecodeErrorZ_clone(const struct LDKCResult_ChannelIdDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_ChannelIdDecodeErrorZ in the success state. + * Creates a new tuple which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_ChannelIdDecodeErrorZ CResult_ChannelIdDecodeErrorZ_ok(struct LDKChannelId o); +struct LDKC2Tuple__u832u16Z C2Tuple__u832u16Z_clone(const struct LDKC2Tuple__u832u16Z *NONNULL_PTR orig); /** - * Creates a new CResult_ChannelIdDecodeErrorZ in the error state. + * Creates a new C2Tuple__u832u16Z from the contained elements. */ -struct LDKCResult_ChannelIdDecodeErrorZ CResult_ChannelIdDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKC2Tuple__u832u16Z C2Tuple__u832u16Z_new(struct LDKThirtyTwoBytes a, uint16_t b); + +/** + * Frees any resources used by the C2Tuple__u832u16Z. + */ +void C2Tuple__u832u16Z_free(struct LDKC2Tuple__u832u16Z _res); + +/** + * 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_ChannelIdDecodeErrorZ_is_ok(const struct LDKCResult_ChannelIdDecodeErrorZ *NONNULL_PTR o); +bool CResult_BlindedPayInfoDecodeErrorZ_is_ok(const struct LDKCResult_BlindedPayInfoDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_ChannelIdDecodeErrorZ. + * Frees any resources used by the CResult_BlindedPayInfoDecodeErrorZ. */ -void CResult_ChannelIdDecodeErrorZ_free(struct LDKCResult_ChannelIdDecodeErrorZ _res); +void CResult_BlindedPayInfoDecodeErrorZ_free(struct LDKCResult_BlindedPayInfoDecodeErrorZ _res); /** - * Creates a new CResult_ChannelIdDecodeErrorZ 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. */ -struct LDKCResult_ChannelIdDecodeErrorZ CResult_ChannelIdDecodeErrorZ_clone(const struct LDKCResult_ChannelIdDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_BlindedPayInfoDecodeErrorZ CResult_BlindedPayInfoDecodeErrorZ_clone(const struct LDKCResult_BlindedPayInfoDecodeErrorZ *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_BlindedPaymentPathNoneZ in the success state. */ -struct LDKC2Tuple__u832u16Z C2Tuple__u832u16Z_clone(const struct LDKC2Tuple__u832u16Z *NONNULL_PTR orig); +struct LDKCResult_BlindedPaymentPathNoneZ CResult_BlindedPaymentPathNoneZ_ok(struct LDKBlindedPaymentPath o); /** - * Creates a new C2Tuple__u832u16Z from the contained elements. + * Creates a new CResult_BlindedPaymentPathNoneZ in the error state. */ -struct LDKC2Tuple__u832u16Z C2Tuple__u832u16Z_new(struct LDKThirtyTwoBytes a, uint16_t b); +struct LDKCResult_BlindedPaymentPathNoneZ CResult_BlindedPaymentPathNoneZ_err(void); /** - * Frees any resources used by the C2Tuple__u832u16Z. + * Checks if the given object is currently in the success state */ -void C2Tuple__u832u16Z_free(struct LDKC2Tuple__u832u16Z _res); +bool CResult_BlindedPaymentPathNoneZ_is_ok(const struct LDKCResult_BlindedPaymentPathNoneZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_BlindedPaymentPathNoneZ. + */ +void CResult_BlindedPaymentPathNoneZ_free(struct LDKCResult_BlindedPaymentPathNoneZ _res); + +/** + * Creates a new CResult_BlindedPaymentPathNoneZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_BlindedPaymentPathNoneZ CResult_BlindedPaymentPathNoneZ_clone(const struct LDKCResult_BlindedPaymentPathNoneZ *NONNULL_PTR orig); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_PaymentForwardNodeZ_free(struct LDKCVec_PaymentForwardNodeZ _res); /** * Creates a new CResult_PaymentRelayDecodeErrorZ in the success state. @@ -32697,98 +34754,77 @@ void CResult_Bolt12RefundContextDecodeErrorZ_free(struct LDKCResult_Bolt12Refund struct LDKCResult_Bolt12RefundContextDecodeErrorZ CResult_Bolt12RefundContextDecodeErrorZ_clone(const struct LDKCResult_Bolt12RefundContextDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_StrSecp256k1ErrorZ in the success state. + * Creates a new CResult_TxOutUtxoLookupErrorZ in the success state. */ -struct LDKCResult_StrSecp256k1ErrorZ CResult_StrSecp256k1ErrorZ_ok(struct LDKStr o); +struct LDKCResult_TxOutUtxoLookupErrorZ CResult_TxOutUtxoLookupErrorZ_ok(struct LDKTxOut o); /** - * Creates a new CResult_StrSecp256k1ErrorZ in the error state. + * Creates a new CResult_TxOutUtxoLookupErrorZ in the error state. */ -struct LDKCResult_StrSecp256k1ErrorZ CResult_StrSecp256k1ErrorZ_err(enum LDKSecp256k1Error e); +struct LDKCResult_TxOutUtxoLookupErrorZ CResult_TxOutUtxoLookupErrorZ_err(enum LDKUtxoLookupError e); /** * Checks if the given object is currently in the success state */ -bool CResult_StrSecp256k1ErrorZ_is_ok(const struct LDKCResult_StrSecp256k1ErrorZ *NONNULL_PTR o); - -/** - * Frees any resources used by the CResult_StrSecp256k1ErrorZ. - */ -void CResult_StrSecp256k1ErrorZ_free(struct LDKCResult_StrSecp256k1ErrorZ _res); +bool CResult_TxOutUtxoLookupErrorZ_is_ok(const struct LDKCResult_TxOutUtxoLookupErrorZ *NONNULL_PTR o); /** - * Creates a new CResult_StrSecp256k1ErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Frees any resources used by the CResult_TxOutUtxoLookupErrorZ. */ -struct LDKCResult_StrSecp256k1ErrorZ CResult_StrSecp256k1ErrorZ_clone(const struct LDKCResult_StrSecp256k1ErrorZ *NONNULL_PTR orig); +void CResult_TxOutUtxoLookupErrorZ_free(struct LDKCResult_TxOutUtxoLookupErrorZ _res); /** - * Creates a new tuple 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 LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ_clone(const struct LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ *NONNULL_PTR orig); - -/** - * Creates a new C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ from the contained elements. - */ -struct LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ_new(struct LDKThirtyTwoBytes a, struct LDKRecipientOnionFields b, struct LDKRouteParameters c); - -/** - * Frees any resources used by the C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ. - */ -void C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ_free(struct LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ _res); +struct LDKCResult_TxOutUtxoLookupErrorZ CResult_TxOutUtxoLookupErrorZ_clone(const struct LDKCResult_TxOutUtxoLookupErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ in the success state. + * Creates a new CResult_ResponderDecodeErrorZ in the success state. */ -struct LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ_ok(struct LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ o); +struct LDKCResult_ResponderDecodeErrorZ CResult_ResponderDecodeErrorZ_ok(struct LDKResponder o); /** - * Creates a new CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ in the error state. + * Creates a new CResult_ResponderDecodeErrorZ in the error state. */ -struct LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ_err(void); +struct LDKCResult_ResponderDecodeErrorZ CResult_ResponderDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ_is_ok(const struct LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ *NONNULL_PTR o); +bool CResult_ResponderDecodeErrorZ_is_ok(const struct LDKCResult_ResponderDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ. + * Frees any resources used by the CResult_ResponderDecodeErrorZ. */ -void CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ_free(struct LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ _res); +void CResult_ResponderDecodeErrorZ_free(struct LDKCResult_ResponderDecodeErrorZ _res); /** - * Creates a new CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ which has the same data as `orig` + * Creates a new CResult_ResponderDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ_clone(const struct LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ *NONNULL_PTR orig); +struct LDKCResult_ResponderDecodeErrorZ CResult_ResponderDecodeErrorZ_clone(const struct LDKCResult_ResponderDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_TxOutUtxoLookupErrorZ in the success state. + * Constructs a new COption_MessageContextZ containing a crate::lightning::blinded_path::message::MessageContext */ -struct LDKCResult_TxOutUtxoLookupErrorZ CResult_TxOutUtxoLookupErrorZ_ok(struct LDKTxOut o); +struct LDKCOption_MessageContextZ COption_MessageContextZ_some(struct LDKMessageContext o); /** - * Creates a new CResult_TxOutUtxoLookupErrorZ in the error state. + * Constructs a new COption_MessageContextZ containing nothing */ -struct LDKCResult_TxOutUtxoLookupErrorZ CResult_TxOutUtxoLookupErrorZ_err(enum LDKUtxoLookupError e); - -/** - * Checks if the given object is currently in the success state - */ -bool CResult_TxOutUtxoLookupErrorZ_is_ok(const struct LDKCResult_TxOutUtxoLookupErrorZ *NONNULL_PTR o); +struct LDKCOption_MessageContextZ COption_MessageContextZ_none(void); /** - * Frees any resources used by the CResult_TxOutUtxoLookupErrorZ. + * Frees any resources associated with the crate::lightning::blinded_path::message::MessageContext, if we are in the Some state */ -void CResult_TxOutUtxoLookupErrorZ_free(struct LDKCResult_TxOutUtxoLookupErrorZ _res); +void COption_MessageContextZ_free(struct LDKCOption_MessageContextZ _res); /** - * Creates a new CResult_TxOutUtxoLookupErrorZ which has the same data as `orig` + * Creates a new COption_MessageContextZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_TxOutUtxoLookupErrorZ CResult_TxOutUtxoLookupErrorZ_clone(const struct LDKCResult_TxOutUtxoLookupErrorZ *NONNULL_PTR orig); +struct LDKCOption_MessageContextZ COption_MessageContextZ_clone(const struct LDKCOption_MessageContextZ *NONNULL_PTR orig); /** * Creates a new tuple which has the same data as `orig` @@ -32885,87 +34921,30 @@ void CResult_SendSuccessSendErrorZ_free(struct LDKCResult_SendSuccessSendErrorZ struct LDKCResult_SendSuccessSendErrorZ CResult_SendSuccessSendErrorZ_clone(const struct LDKCResult_SendSuccessSendErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_BlindedPathNoneZ in the success state. - */ -struct LDKCResult_BlindedPathNoneZ CResult_BlindedPathNoneZ_ok(struct LDKBlindedPath o); - -/** - * Creates a new CResult_BlindedPathNoneZ in the error state. - */ -struct LDKCResult_BlindedPathNoneZ CResult_BlindedPathNoneZ_err(void); - -/** - * Checks if the given object is currently in the success state - */ -bool CResult_BlindedPathNoneZ_is_ok(const struct LDKCResult_BlindedPathNoneZ *NONNULL_PTR o); - -/** - * Frees any resources used by the CResult_BlindedPathNoneZ. - */ -void CResult_BlindedPathNoneZ_free(struct LDKCResult_BlindedPathNoneZ _res); - -/** - * Creates a new CResult_BlindedPathNoneZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKCResult_BlindedPathNoneZ CResult_BlindedPathNoneZ_clone(const struct LDKCResult_BlindedPathNoneZ *NONNULL_PTR orig); - -/** - * Creates a new CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ in the success state. - */ -struct LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ_ok(struct LDKC2Tuple_BlindedPayInfoBlindedPathZ o); - -/** - * Creates a new CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ in the error state. - */ -struct LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ_err(void); - -/** - * Checks if the given object is currently in the success state - */ -bool CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ_is_ok(const struct LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ *NONNULL_PTR o); - -/** - * Frees any resources used by the CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ. - */ -void CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ_free(struct LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ _res); - -/** - * Creates a new CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ_clone(const struct LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ *NONNULL_PTR orig); - -/** - * Frees the buffer pointed to by `data` if `datalen` is non-0. - */ -void CVec_ForwardNodeZ_free(struct LDKCVec_ForwardNodeZ _res); - -/** - * Creates a new CResult_BlindedPathDecodeErrorZ in the success state. + * Creates a new CResult_NoneSendErrorZ in the success state. */ -struct LDKCResult_BlindedPathDecodeErrorZ CResult_BlindedPathDecodeErrorZ_ok(struct LDKBlindedPath o); +struct LDKCResult_NoneSendErrorZ CResult_NoneSendErrorZ_ok(void); /** - * Creates a new CResult_BlindedPathDecodeErrorZ in the error state. + * Creates a new CResult_NoneSendErrorZ in the error state. */ -struct LDKCResult_BlindedPathDecodeErrorZ CResult_BlindedPathDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_NoneSendErrorZ CResult_NoneSendErrorZ_err(struct LDKSendError e); /** * Checks if the given object is currently in the success state */ -bool CResult_BlindedPathDecodeErrorZ_is_ok(const struct LDKCResult_BlindedPathDecodeErrorZ *NONNULL_PTR o); +bool CResult_NoneSendErrorZ_is_ok(const struct LDKCResult_NoneSendErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_BlindedPathDecodeErrorZ. + * Frees any resources used by the CResult_NoneSendErrorZ. */ -void CResult_BlindedPathDecodeErrorZ_free(struct LDKCResult_BlindedPathDecodeErrorZ _res); +void CResult_NoneSendErrorZ_free(struct LDKCResult_NoneSendErrorZ _res); /** - * Creates a new CResult_BlindedPathDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_NoneSendErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_BlindedPathDecodeErrorZ CResult_BlindedPathDecodeErrorZ_clone(const struct LDKCResult_BlindedPathDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_NoneSendErrorZ CResult_NoneSendErrorZ_clone(const struct LDKCResult_NoneSendErrorZ *NONNULL_PTR orig); /** * Creates a new CResult_BlindedHopDecodeErrorZ in the success state. @@ -32993,6 +34972,37 @@ void CResult_BlindedHopDecodeErrorZ_free(struct LDKCResult_BlindedHopDecodeError */ struct LDKCResult_BlindedHopDecodeErrorZ CResult_BlindedHopDecodeErrorZ_clone(const struct LDKCResult_BlindedHopDecodeErrorZ *NONNULL_PTR orig); +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_PhantomRouteHintsZ_free(struct LDKCVec_PhantomRouteHintsZ _res); + +/** + * Creates a new CResult_Bolt11InvoiceSignOrCreationErrorZ in the success state. + */ +struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ CResult_Bolt11InvoiceSignOrCreationErrorZ_ok(struct LDKBolt11Invoice o); + +/** + * Creates a new CResult_Bolt11InvoiceSignOrCreationErrorZ in the error state. + */ +struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ CResult_Bolt11InvoiceSignOrCreationErrorZ_err(struct LDKSignOrCreationError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_Bolt11InvoiceSignOrCreationErrorZ_is_ok(const struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_Bolt11InvoiceSignOrCreationErrorZ. + */ +void CResult_Bolt11InvoiceSignOrCreationErrorZ_free(struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ _res); + +/** + * Creates a new CResult_Bolt11InvoiceSignOrCreationErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ CResult_Bolt11InvoiceSignOrCreationErrorZ_clone(const struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ *NONNULL_PTR orig); + /** * Creates a new CResult_InvoiceErrorDecodeErrorZ in the success state. */ @@ -33338,31 +35348,130 @@ void C2Tuple_OutPointChannelIdZ_free(struct LDKC2Tuple_OutPointChannelIdZ _res); */ void CVec_C2Tuple_OutPointChannelIdZZ_free(struct LDKCVec_C2Tuple_OutPointChannelIdZZ _res); +/** + * Creates a new tuple which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKC2Tuple_OutPointCVec_u64ZZ C2Tuple_OutPointCVec_u64ZZ_clone(const struct LDKC2Tuple_OutPointCVec_u64ZZ *NONNULL_PTR orig); + +/** + * Creates a new C2Tuple_OutPointCVec_u64ZZ from the contained elements. + */ +struct LDKC2Tuple_OutPointCVec_u64ZZ C2Tuple_OutPointCVec_u64ZZ_new(struct LDKOutPoint a, struct LDKCVec_u64Z b); + +/** + * Frees any resources used by the C2Tuple_OutPointCVec_u64ZZ. + */ +void C2Tuple_OutPointCVec_u64ZZ_free(struct LDKC2Tuple_OutPointCVec_u64ZZ _res); + /** * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -void CVec_MonitorUpdateIdZ_free(struct LDKCVec_MonitorUpdateIdZ _res); +void CVec_C2Tuple_OutPointCVec_u64ZZZ_free(struct LDKCVec_C2Tuple_OutPointCVec_u64ZZZ _res); /** - * Creates a new tuple which has the same data as `orig` + * Creates a new CResult_BlindedMessagePathDecodeErrorZ in the success state. + */ +struct LDKCResult_BlindedMessagePathDecodeErrorZ CResult_BlindedMessagePathDecodeErrorZ_ok(struct LDKBlindedMessagePath o); + +/** + * Creates a new CResult_BlindedMessagePathDecodeErrorZ in the error state. + */ +struct LDKCResult_BlindedMessagePathDecodeErrorZ CResult_BlindedMessagePathDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_BlindedMessagePathDecodeErrorZ_is_ok(const struct LDKCResult_BlindedMessagePathDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_BlindedMessagePathDecodeErrorZ. + */ +void CResult_BlindedMessagePathDecodeErrorZ_free(struct LDKCResult_BlindedMessagePathDecodeErrorZ _res); + +/** + * Creates a new CResult_BlindedMessagePathDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ C2Tuple_OutPointCVec_MonitorUpdateIdZZ_clone(const struct LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ *NONNULL_PTR orig); +struct LDKCResult_BlindedMessagePathDecodeErrorZ CResult_BlindedMessagePathDecodeErrorZ_clone(const struct LDKCResult_BlindedMessagePathDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new C2Tuple_OutPointCVec_MonitorUpdateIdZZ from the contained elements. + * Creates a new CResult_BlindedMessagePathNoneZ in the success state. */ -struct LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ C2Tuple_OutPointCVec_MonitorUpdateIdZZ_new(struct LDKOutPoint a, struct LDKCVec_MonitorUpdateIdZ b); +struct LDKCResult_BlindedMessagePathNoneZ CResult_BlindedMessagePathNoneZ_ok(struct LDKBlindedMessagePath o); /** - * Frees any resources used by the C2Tuple_OutPointCVec_MonitorUpdateIdZZ. + * Creates a new CResult_BlindedMessagePathNoneZ in the error state. */ -void C2Tuple_OutPointCVec_MonitorUpdateIdZZ_free(struct LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ _res); +struct LDKCResult_BlindedMessagePathNoneZ CResult_BlindedMessagePathNoneZ_err(void); /** - * 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_BlindedMessagePathNoneZ_is_ok(const struct LDKCResult_BlindedMessagePathNoneZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_BlindedMessagePathNoneZ. + */ +void CResult_BlindedMessagePathNoneZ_free(struct LDKCResult_BlindedMessagePathNoneZ _res); + +/** + * Creates a new CResult_BlindedMessagePathNoneZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -void CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ_free(struct LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ _res); +struct LDKCResult_BlindedMessagePathNoneZ CResult_BlindedMessagePathNoneZ_clone(const struct LDKCResult_BlindedMessagePathNoneZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_MessageContextDecodeErrorZ in the success state. + */ +struct LDKCResult_MessageContextDecodeErrorZ CResult_MessageContextDecodeErrorZ_ok(struct LDKMessageContext o); + +/** + * Creates a new CResult_MessageContextDecodeErrorZ in the error state. + */ +struct LDKCResult_MessageContextDecodeErrorZ CResult_MessageContextDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_MessageContextDecodeErrorZ_is_ok(const struct LDKCResult_MessageContextDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_MessageContextDecodeErrorZ. + */ +void CResult_MessageContextDecodeErrorZ_free(struct LDKCResult_MessageContextDecodeErrorZ _res); + +/** + * Creates a new CResult_MessageContextDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_MessageContextDecodeErrorZ CResult_MessageContextDecodeErrorZ_clone(const struct LDKCResult_MessageContextDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_OffersContextDecodeErrorZ in the success state. + */ +struct LDKCResult_OffersContextDecodeErrorZ CResult_OffersContextDecodeErrorZ_ok(struct LDKOffersContext o); + +/** + * Creates a new CResult_OffersContextDecodeErrorZ in the error state. + */ +struct LDKCResult_OffersContextDecodeErrorZ CResult_OffersContextDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_OffersContextDecodeErrorZ_is_ok(const struct LDKCResult_OffersContextDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_OffersContextDecodeErrorZ. + */ +void CResult_OffersContextDecodeErrorZ_free(struct LDKCResult_OffersContextDecodeErrorZ _res); + +/** + * Creates a new CResult_OffersContextDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_OffersContextDecodeErrorZ CResult_OffersContextDecodeErrorZ_clone(const struct LDKCResult_OffersContextDecodeErrorZ *NONNULL_PTR orig); /** * Frees any resources used by the APIError @@ -33461,6 +35570,16 @@ struct LDKCVec_u8Z BigSize_write(const struct LDKBigSize *NONNULL_PTR obj); */ struct LDKCResult_BigSizeDecodeErrorZ BigSize_read(struct LDKu8slice ser); +/** + * Serialize the UntrustedString object into a byte array which can be read by UntrustedString_read + */ +struct LDKCVec_u8Z UntrustedString_write(const struct LDKUntrustedString *NONNULL_PTR obj); + +/** + * Read a UntrustedString from a byte array, created by UntrustedString_write + */ +struct LDKCResult_UntrustedStringDecodeErrorZ UntrustedString_read(struct LDKu8slice ser); + /** * Frees any resources used by the Hostname, if is_owned is set and inner is non-NULL. */ @@ -33556,7 +35675,7 @@ struct LDKCResult_TransactionU16LenLimitedDecodeErrorZ TransactionU16LenLimited_ * 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_StrSecp256k1ErrorZ sign(struct LDKu8slice msg, const uint8_t (*sk)[32]); +struct LDKStr sign(struct LDKu8slice msg, const uint8_t (*sk)[32]); /** * Recovers the PublicKey of the signer of the message given the message and the signature. @@ -33569,11 +35688,6 @@ struct LDKCResult_PublicKeySecp256k1ErrorZ recover_pk(struct LDKu8slice msg, str */ bool verify(struct LDKu8slice msg, struct LDKStr sig, struct LDKPublicKey pk); -/** - * Construct the invoice's HRP and signatureless data into a preimage to be hashed. - */ -struct LDKCVec_u8Z construct_invoice_preimage(struct LDKu8slice hrp_bytes, struct LDKCVec_U5Z data_without_signature); - /** * Calls the free function if one is set */ @@ -33612,7 +35726,7 @@ void MonitorUpdatingPersister_free(struct LDKMonitorUpdatingPersister this_obj); * - [`MonitorUpdatingPersister`] will potentially have more listing to do if you need to run * [`MonitorUpdatingPersister::cleanup_stale_updates`]. */ -MUST_USE_RES struct LDKMonitorUpdatingPersister MonitorUpdatingPersister_new(struct LDKKVStore kv_store, struct LDKLogger logger, uint64_t maximum_pending_updates, struct LDKEntropySource entropy_source, struct LDKSignerProvider signer_provider); +MUST_USE_RES struct LDKMonitorUpdatingPersister MonitorUpdatingPersister_new(struct LDKKVStore kv_store, struct LDKLogger logger, uint64_t maximum_pending_updates, struct LDKEntropySource entropy_source, struct LDKSignerProvider signer_provider, struct LDKBroadcasterInterface broadcaster, struct LDKFeeEstimator fee_estimator); /** * Reads all stored channel monitors, along with any stored updates for them. @@ -33621,7 +35735,7 @@ MUST_USE_RES struct LDKMonitorUpdatingPersister MonitorUpdatingPersister_new(str * [`io::ErrorKind::NotFound`] variant correctly. For more information, please see the * documentation for [`MonitorUpdatingPersister`]. */ -MUST_USE_RES struct LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ MonitorUpdatingPersister_read_all_channel_monitors_with_updates(const struct LDKMonitorUpdatingPersister *NONNULL_PTR this_arg, const struct LDKBroadcasterInterface *NONNULL_PTR broadcaster, const struct LDKFeeEstimator *NONNULL_PTR fee_estimator); +MUST_USE_RES struct LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ MonitorUpdatingPersister_read_all_channel_monitors_with_updates(const struct LDKMonitorUpdatingPersister *NONNULL_PTR this_arg); /** * Read a single channel monitor, along with any stored updates for it. @@ -33642,7 +35756,7 @@ MUST_USE_RES struct LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErro * Loading a large number of monitors will be faster if done in parallel. You can use this * function to accomplish this. Take care to limit the number of parallel readers. */ -MUST_USE_RES struct LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ MonitorUpdatingPersister_read_channel_monitor_with_updates(const struct LDKMonitorUpdatingPersister *NONNULL_PTR this_arg, const struct LDKBroadcasterInterface *NONNULL_PTR broadcaster, const struct LDKFeeEstimator *NONNULL_PTR fee_estimator, struct LDKStr monitor_key); +MUST_USE_RES struct LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ MonitorUpdatingPersister_read_channel_monitor_with_updates(const struct LDKMonitorUpdatingPersister *NONNULL_PTR this_arg, struct LDKStr monitor_key); /** * Cleans up stale updates for all monitors. @@ -33707,71 +35821,6 @@ uint16_t vout_from_scid(uint64_t short_channel_id); */ struct LDKCResult_u64ShortChannelIdErrorZ scid_from_parts(uint64_t block, uint64_t tx_index, uint64_t vout_index); -/** - * Frees any resources used by the UntrustedString, if is_owned is set and inner is non-NULL. - */ -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); - -/** - * Constructs a new UntrustedString given each field - */ -MUST_USE_RES struct LDKUntrustedString UntrustedString_new(struct LDKStr a_arg); - -/** - * Creates a copy of the UntrustedString - */ -struct LDKUntrustedString UntrustedString_clone(const struct LDKUntrustedString *NONNULL_PTR orig); - -/** - * 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. - */ -bool UntrustedString_eq(const struct LDKUntrustedString *NONNULL_PTR a, const struct LDKUntrustedString *NONNULL_PTR b); - -/** - * Generates a non-cryptographic 64-bit hash of the UntrustedString. - */ -uint64_t UntrustedString_hash(const struct LDKUntrustedString *NONNULL_PTR o); - -/** - * Serialize the UntrustedString object into a byte array which can be read by UntrustedString_read - */ -struct LDKCVec_u8Z UntrustedString_write(const struct LDKUntrustedString *NONNULL_PTR obj); - -/** - * Read a UntrustedString from a byte array, created by UntrustedString_write - */ -struct LDKCResult_UntrustedStringDecodeErrorZ UntrustedString_read(struct LDKu8slice ser); - -/** - * Get the string representation of a UntrustedString object - */ -struct LDKStr UntrustedString_to_str(const struct LDKUntrustedString *NONNULL_PTR o); - -/** - * Frees any resources used by the PrintableString, if is_owned is set and inner is non-NULL. - */ -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); - -/** - * Constructs a new PrintableString given each field - */ -MUST_USE_RES struct LDKPrintableString PrintableString_new(struct LDKStr a_arg); - -/** - * Get the string representation of a PrintableString object - */ -struct LDKStr PrintableString_to_str(const struct LDKPrintableString *NONNULL_PTR o); - /** * Frees any resources used by the TrackedSpendableOutput, if is_owned is set and inner is non-NULL. */ @@ -34020,6 +36069,12 @@ MUST_USE_RES struct LDKSleeper Sleeper_from_single_future(const struct LDKFuture */ MUST_USE_RES struct LDKSleeper Sleeper_from_two_futures(const struct LDKFuture *NONNULL_PTR fut_a, const struct LDKFuture *NONNULL_PTR fut_b); +/** + * Constructs a new sleeper from three futures, allowing blocking on all three at once. + * + */ +MUST_USE_RES struct LDKSleeper Sleeper_from_three_futures(const struct LDKFuture *NONNULL_PTR fut_a, const struct LDKFuture *NONNULL_PTR fut_b, const struct LDKFuture *NONNULL_PTR fut_c); + /** * Constructs a new sleeper on many futures, allowing blocking on all at once. */ @@ -34186,13 +36241,29 @@ uint32_t Record_get_line(const struct LDKRecord *NONNULL_PTR this_ptr); */ void Record_set_line(struct LDKRecord *NONNULL_PTR this_ptr, uint32_t val); +/** + * The payment hash. + * + * Note that this is only filled in for logs pertaining to a specific payment, and will be + * `None` for logs which are not directly related to a payment. + */ +struct LDKCOption_ThirtyTwoBytesZ Record_get_payment_hash(const struct LDKRecord *NONNULL_PTR this_ptr); + +/** + * The payment hash. + * + * Note that this is only filled in for logs pertaining to a specific payment, and will be + * `None` for logs which are not directly related to a payment. + */ +void Record_set_payment_hash(struct LDKRecord *NONNULL_PTR this_ptr, struct LDKCOption_ThirtyTwoBytesZ val); + /** * Constructs a new Record given each field * * Note that peer_id_arg (or a relevant inner pointer) may be NULL or all-0s to represent None * Note that channel_id_arg (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKRecord Record_new(enum LDKLevel level_arg, struct LDKPublicKey peer_id_arg, struct LDKChannelId channel_id_arg, struct LDKStr args_arg, struct LDKStr module_path_arg, struct LDKStr file_arg, uint32_t line_arg); +MUST_USE_RES struct LDKRecord Record_new(enum LDKLevel level_arg, struct LDKPublicKey peer_id_arg, struct LDKChannelId channel_id_arg, struct LDKStr args_arg, struct LDKStr module_path_arg, struct LDKStr file_arg, uint32_t line_arg, struct LDKCOption_ThirtyTwoBytesZ payment_hash_arg); /** * Creates a copy of the Record @@ -34211,15 +36282,15 @@ void ChannelHandshakeConfig_free(struct LDKChannelHandshakeConfig this_obj); /** * Confirmations we will wait for before considering the channel locked in. - * Applied only for inbound channels (see ChannelHandshakeLimits::max_minimum_depth for the + * 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 + * 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. + * 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 @@ -34228,15 +36299,15 @@ uint32_t ChannelHandshakeConfig_get_minimum_depth(const struct LDKChannelHandsha /** * Confirmations we will wait for before considering the channel locked in. - * Applied only for inbound channels (see ChannelHandshakeLimits::max_minimum_depth for the + * 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 + * 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. + * 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 @@ -34257,8 +36328,8 @@ void ChannelHandshakeConfig_set_minimum_depth(struct LDKChannelHandshakeConfig * * 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. + * 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.) */ uint16_t ChannelHandshakeConfig_get_our_to_self_delay(const struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr); @@ -34276,8 +36347,8 @@ uint16_t ChannelHandshakeConfig_get_our_to_self_delay(const struct LDKChannelHan * 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. + * 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.) */ void ChannelHandshakeConfig_set_our_to_self_delay(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, uint16_t val); @@ -34287,8 +36358,8 @@ void ChannelHandshakeConfig_set_our_to_self_delay(struct LDKChannelHandshakeConf * 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. + * Default value: `1` (If the value is less than `1`, it is ignored and set to `1`, as is + * required by the protocol. */ uint64_t ChannelHandshakeConfig_get_our_htlc_minimum_msat(const struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr); @@ -34298,8 +36369,8 @@ uint64_t ChannelHandshakeConfig_get_our_htlc_minimum_msat(const struct LDKChanne * 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. + * Default value: `1` (If the value is less than `1`, it is ignored and set to `1`, as is + * required by the protocol. */ void ChannelHandshakeConfig_set_our_htlc_minimum_msat(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, uint64_t val); @@ -34311,22 +36382,24 @@ void ChannelHandshakeConfig_set_our_htlc_minimum_msat(struct LDKChannelHandshake * 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`. + * * 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. + * 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. + * 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. + * Default value: `10` + * + * Minimum value: `1` (Any values less will be treated as `1` instead.) + * + * Maximum value: `100` (Any values larger will be treated as `100` instead.) */ uint8_t ChannelHandshakeConfig_get_max_inbound_htlc_value_in_flight_percent_of_channel(const struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr); @@ -34338,22 +36411,24 @@ uint8_t ChannelHandshakeConfig_get_max_inbound_htlc_value_in_flight_percent_of_c * 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`. + * * 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. + * 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. + * 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 will be treated as `1` instead.) * - * 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. + * Maximum value: `100` (Any values larger will be treated as `100` instead.) */ void ChannelHandshakeConfig_set_max_inbound_htlc_value_in_flight_percent_of_channel(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, uint8_t val); @@ -34372,10 +36447,10 @@ void ChannelHandshakeConfig_set_max_inbound_htlc_value_in_flight_percent_of_chan * private channel without that option. * * Ignored if the channel is negotiated to be announced, see - * [`ChannelHandshakeConfig::announced_channel`] and + * [`ChannelHandshakeConfig::announce_for_forwarding`] and * [`ChannelHandshakeLimits::force_announced_channel_preference`] for more. * - * Default value: false. This value is likely to change to true in the future. + * 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 @@ -34397,10 +36472,10 @@ bool ChannelHandshakeConfig_get_negotiate_scid_privacy(const struct LDKChannelHa * private channel without that option. * * Ignored if the channel is negotiated to be announced, see - * [`ChannelHandshakeConfig::announced_channel`] and + * [`ChannelHandshakeConfig::announce_for_forwarding`] and * [`ChannelHandshakeLimits::force_announced_channel_preference`] for more. * - * Default value: false. This value is likely to change to true in the future. + * 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 @@ -34416,9 +36491,9 @@ void ChannelHandshakeConfig_set_negotiate_scid_privacy(struct LDKChannelHandshak * 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. + * Default value: `false` */ -bool ChannelHandshakeConfig_get_announced_channel(const struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr); +bool ChannelHandshakeConfig_get_announce_for_forwarding(const struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr); /** * Set to announce the channel publicly and notify all nodes that they can route via this @@ -34429,9 +36504,9 @@ bool ChannelHandshakeConfig_get_announced_channel(const struct LDKChannelHandsha * 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. + * Default value: `false` */ -void ChannelHandshakeConfig_set_announced_channel(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, bool val); +void ChannelHandshakeConfig_set_announce_for_forwarding(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, bool val); /** * When set, we commit to an upfront shutdown_pubkey at channel open. If our counterparty @@ -34444,7 +36519,7 @@ void ChannelHandshakeConfig_set_announced_channel(struct LDKChannelHandshakeConf * * The upfront key committed is provided from [`SignerProvider::get_shutdown_scriptpubkey`]. * - * Default value: true. + * Default value: `true` * * [`SignerProvider::get_shutdown_scriptpubkey`]: crate::sign::SignerProvider::get_shutdown_scriptpubkey */ @@ -34461,7 +36536,7 @@ bool ChannelHandshakeConfig_get_commit_upfront_shutdown_pubkey(const struct LDKC * * The upfront key committed is provided from [`SignerProvider::get_shutdown_scriptpubkey`]. * - * Default value: true. + * Default value: `true` * * [`SignerProvider::get_shutdown_scriptpubkey`]: crate::sign::SignerProvider::get_shutdown_scriptpubkey */ @@ -34485,11 +36560,15 @@ void ChannelHandshakeConfig_set_commit_upfront_shutdown_pubkey(struct LDKChannel * 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. + * Default value: `10_000` millionths (i.e., 1% of channel value) + * + * 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` (i.e., 100% of channel value. Any values larger than one million + * will be treated as one million instead, although channel negotiations will + * fail in that case.) */ uint32_t ChannelHandshakeConfig_get_their_channel_reserve_proportional_millionths(const struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr); @@ -34511,11 +36590,15 @@ uint32_t ChannelHandshakeConfig_get_their_channel_reserve_proportional_millionth * 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. + * Default value: `10_000` millionths (i.e., 1% of channel value) + * + * 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` (i.e., 100% of channel value. Any values larger than one million + * will be treated as one million instead, although channel negotiations will + * fail in that case.) */ void ChannelHandshakeConfig_set_their_channel_reserve_proportional_millionths(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, uint32_t val); @@ -34542,7 +36625,7 @@ void ChannelHandshakeConfig_set_their_channel_reserve_proportional_millionths(st * 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. + * 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 @@ -34574,7 +36657,7 @@ bool ChannelHandshakeConfig_get_negotiate_anchors_zero_fee_htlc_tx(const struct * 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. + * 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 @@ -34592,9 +36675,10 @@ void ChannelHandshakeConfig_set_negotiate_anchors_zero_fee_htlc_tx(struct LDKCha * 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`. + * 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`.) */ uint16_t ChannelHandshakeConfig_get_our_max_accepted_htlcs(const struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr); @@ -34607,16 +36691,17 @@ uint16_t ChannelHandshakeConfig_get_our_max_accepted_htlcs(const struct LDKChann * 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`. + * 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 ChannelHandshakeConfig_set_our_max_accepted_htlcs(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, uint16_t val); /** * Constructs a new ChannelHandshakeConfig given each field */ -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); +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 announce_for_forwarding_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 copy of the ChannelHandshakeConfig @@ -34637,7 +36722,8 @@ void ChannelHandshakeLimits_free(struct LDKChannelHandshakeLimits this_obj); * Minimum allowed satoshis when a channel is funded. This is supplied by the sender and so * only applies to inbound channels. * - * Default value: 0. + * Default value: `1000` + * (Minimum of [`ChannelHandshakeConfig::their_channel_reserve_proportional_millionths`]) */ uint64_t ChannelHandshakeLimits_get_min_funding_satoshis(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); @@ -34645,7 +36731,8 @@ uint64_t ChannelHandshakeLimits_get_min_funding_satoshis(const struct LDKChannel * Minimum allowed satoshis when a channel is funded. This is supplied by the sender and so * only applies to inbound channels. * - * Default value: 0. + * Default value: `1000` + * (Minimum of [`ChannelHandshakeConfig::their_channel_reserve_proportional_millionths`]) */ void ChannelHandshakeLimits_set_min_funding_satoshis(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint64_t val); @@ -34653,7 +36740,7 @@ void ChannelHandshakeLimits_set_min_funding_satoshis(struct LDKChannelHandshakeL * 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. + * Default value: `2^24 - 1` */ uint64_t ChannelHandshakeLimits_get_max_funding_satoshis(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); @@ -34661,7 +36748,7 @@ uint64_t ChannelHandshakeLimits_get_max_funding_satoshis(const struct LDKChannel * 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. + * Default value: `2^24 - 1` */ void ChannelHandshakeLimits_set_max_funding_satoshis(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint64_t val); @@ -34669,7 +36756,7 @@ void ChannelHandshakeLimits_set_max_funding_satoshis(struct LDKChannelHandshakeL * 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. + * Default value: `u64::max_value` */ uint64_t ChannelHandshakeLimits_get_max_htlc_minimum_msat(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); @@ -34677,7 +36764,7 @@ uint64_t ChannelHandshakeLimits_get_max_htlc_minimum_msat(const struct LDKChanne * 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. + * Default value: `u64::max_value` */ void ChannelHandshakeLimits_set_max_htlc_minimum_msat(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint64_t val); @@ -34685,7 +36772,7 @@ void ChannelHandshakeLimits_set_max_htlc_minimum_msat(struct LDKChannelHandshake * 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. + * Default value: `0` */ uint64_t ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); @@ -34693,7 +36780,7 @@ uint64_t ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(const stru * 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. + * Default value: `0` */ void ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint64_t val); @@ -34702,7 +36789,7 @@ void ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(struct LDKChan * 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. + * Default value: `u64::max_value`. */ uint64_t ChannelHandshakeLimits_get_max_channel_reserve_satoshis(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); @@ -34711,7 +36798,7 @@ uint64_t ChannelHandshakeLimits_get_max_channel_reserve_satoshis(const struct LD * 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. + * Default value: `u64::max_value`. */ void ChannelHandshakeLimits_set_max_channel_reserve_satoshis(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint64_t val); @@ -34719,7 +36806,7 @@ void ChannelHandshakeLimits_set_max_channel_reserve_satoshis(struct LDKChannelHa * 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. + * Default value: `0` */ uint16_t ChannelHandshakeLimits_get_min_max_accepted_htlcs(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); @@ -34727,7 +36814,7 @@ uint16_t ChannelHandshakeLimits_get_min_max_accepted_htlcs(const struct LDKChann * 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. + * Default value: `0` */ void ChannelHandshakeLimits_set_min_max_accepted_htlcs(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint16_t val); @@ -34737,7 +36824,7 @@ void ChannelHandshakeLimits_set_min_max_accepted_htlcs(struct LDKChannelHandshak * 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. + * Default value: `144`, or roughly one day and only applies to outbound channels */ uint32_t ChannelHandshakeLimits_get_max_minimum_depth(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); @@ -34747,7 +36834,7 @@ uint32_t ChannelHandshakeLimits_get_max_minimum_depth(const struct LDKChannelHan * 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. + * Default value: `144`, or roughly one day and only applies to outbound channels */ void ChannelHandshakeLimits_set_max_minimum_depth(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint32_t val); @@ -34763,12 +36850,12 @@ void ChannelHandshakeLimits_set_max_minimum_depth(struct LDKChannelHandshakeLimi * 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. + * 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). + * `true` (`0`) and `false` (`1`). * - * Default value: true + * Default value: `true` */ bool ChannelHandshakeLimits_get_trust_own_funding_0conf(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); @@ -34784,36 +36871,36 @@ bool ChannelHandshakeLimits_get_trust_own_funding_0conf(const struct LDKChannelH * 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. + * 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). + * `true` (`0`) and `false` (`1`). * - * Default value: true + * Default value: `true` */ void ChannelHandshakeLimits_set_trust_own_funding_0conf(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, bool val); /** * Set to force an incoming channel to match our announced channel preference in - * [`ChannelHandshakeConfig::announced_channel`]. + * [`ChannelHandshakeConfig::announce_for_forwarding`]. * * 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) + * [`ChannelHandshakeConfig::announce_for_forwarding`] set to false, ensuring that no announced (aka public) * channels will ever be opened. * - * Default value: true. + * Default value: `true` */ bool ChannelHandshakeLimits_get_force_announced_channel_preference(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); /** * Set to force an incoming channel to match our announced channel preference in - * [`ChannelHandshakeConfig::announced_channel`]. + * [`ChannelHandshakeConfig::announce_for_forwarding`]. * * 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) + * [`ChannelHandshakeConfig::announce_for_forwarding`] set to false, ensuring that no announced (aka public) * channels will ever be opened. * - * Default value: true. + * Default value: `true` */ void ChannelHandshakeLimits_set_force_announced_channel_preference(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, bool val); @@ -34823,7 +36910,7 @@ void ChannelHandshakeLimits_set_force_announced_channel_preference(struct LDKCha * 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 + * 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) */ uint16_t ChannelHandshakeLimits_get_their_to_self_delay(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); @@ -34834,7 +36921,7 @@ uint16_t ChannelHandshakeLimits_get_their_to_self_delay(const struct LDKChannelH * 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 + * 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 ChannelHandshakeLimits_set_their_to_self_delay(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint16_t val); @@ -34901,7 +36988,7 @@ void ChannelConfig_free(struct LDKChannelConfig this_obj); * 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. + * Default value: `0` */ uint32_t ChannelConfig_get_forwarding_fee_proportional_millionths(const struct LDKChannelConfig *NONNULL_PTR this_ptr); @@ -34911,7 +36998,7 @@ uint32_t ChannelConfig_get_forwarding_fee_proportional_millionths(const struct L * 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. + * Default value: `0` */ void ChannelConfig_set_forwarding_fee_proportional_millionths(struct LDKChannelConfig *NONNULL_PTR this_ptr, uint32_t val); @@ -34925,7 +37012,7 @@ void ChannelConfig_set_forwarding_fee_proportional_millionths(struct LDKChannelC * as of July 2021. Adjusting it upwards or downwards may change whether nodes route through * this node. * - * Default value: 1000. + * Default value: `1000` * * [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths */ @@ -34941,7 +37028,7 @@ uint32_t ChannelConfig_get_forwarding_fee_base_msat(const struct LDKChannelConfi * as of July 2021. Adjusting it upwards or downwards may change whether nodes route through * this node. * - * Default value: 1000. + * Default value: `1000` * * [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths */ @@ -34962,9 +37049,10 @@ void ChannelConfig_set_forwarding_fee_base_msat(struct LDKChannelConfig *NONNULL * 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. + * 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 */ @@ -34985,9 +37073,10 @@ uint16_t ChannelConfig_get_cltv_expiry_delta(const struct LDKChannelConfig *NONN * 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. + * 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 */ @@ -35042,12 +37131,12 @@ void ChannelConfig_set_cltv_expiry_delta(struct LDKChannelConfig *NONNULL_PTR th * Note that when using [`MaxDustHTLCExposure::FeeRateMultiplier`] this maximum disagreement * will scale linearly with increases (or decreases) in the our feerate estimates. Further, * for anchor channels we expect our counterparty to use a relatively low feerate estimate - * while we use [`ConfirmationTarget::OnChainSweep`] (which should be relatively high) and - * feerate disagreement force-closures should only occur when theirs is higher than ours. + * while we use [`ConfirmationTarget::MaximumFeeEstimate`] (which should be relatively high) + * and feerate disagreement force-closures should only occur when theirs is higher than ours. * - * Default value: [`MaxDustHTLCExposure::FeeRateMultiplier`] with a multiplier of 10_000. + * Default value: [`MaxDustHTLCExposure::FeeRateMultiplier`] with a multiplier of `10_000` * - * [`ConfirmationTarget::OnChainSweep`]: crate::chain::chaininterface::ConfirmationTarget::OnChainSweep + * [`ConfirmationTarget::MaximumFeeEstimate`]: crate::chain::chaininterface::ConfirmationTarget::MaximumFeeEstimate */ struct LDKMaxDustHTLCExposure ChannelConfig_get_max_dust_htlc_exposure(const struct LDKChannelConfig *NONNULL_PTR this_ptr); @@ -35100,12 +37189,12 @@ struct LDKMaxDustHTLCExposure ChannelConfig_get_max_dust_htlc_exposure(const str * Note that when using [`MaxDustHTLCExposure::FeeRateMultiplier`] this maximum disagreement * will scale linearly with increases (or decreases) in the our feerate estimates. Further, * for anchor channels we expect our counterparty to use a relatively low feerate estimate - * while we use [`ConfirmationTarget::OnChainSweep`] (which should be relatively high) and - * feerate disagreement force-closures should only occur when theirs is higher than ours. + * while we use [`ConfirmationTarget::MaximumFeeEstimate`] (which should be relatively high) + * and feerate disagreement force-closures should only occur when theirs is higher than ours. * - * Default value: [`MaxDustHTLCExposure::FeeRateMultiplier`] with a multiplier of 10_000. + * Default value: [`MaxDustHTLCExposure::FeeRateMultiplier`] with a multiplier of `10_000` * - * [`ConfirmationTarget::OnChainSweep`]: crate::chain::chaininterface::ConfirmationTarget::OnChainSweep + * [`ConfirmationTarget::MaximumFeeEstimate`]: crate::chain::chaininterface::ConfirmationTarget::MaximumFeeEstimate */ void ChannelConfig_set_max_dust_htlc_exposure(struct LDKChannelConfig *NONNULL_PTR this_ptr, struct LDKMaxDustHTLCExposure val); @@ -35128,7 +37217,7 @@ void ChannelConfig_set_max_dust_htlc_exposure(struct LDKChannelConfig *NONNULL_P * [`ChannelCloseMinimum`] 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. + * Default value: `1000` * * [`NonAnchorChannelFee`]: crate::chain::chaininterface::ConfirmationTarget::NonAnchorChannelFee * [`ChannelCloseMinimum`]: crate::chain::chaininterface::ConfirmationTarget::ChannelCloseMinimum @@ -35154,7 +37243,7 @@ uint64_t ChannelConfig_get_force_close_avoidance_max_fee_satoshis(const struct L * [`ChannelCloseMinimum`] 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. + * Default value: `1000` * * [`NonAnchorChannelFee`]: crate::chain::chaininterface::ConfirmationTarget::NonAnchorChannelFee * [`ChannelCloseMinimum`]: crate::chain::chaininterface::ConfirmationTarget::ChannelCloseMinimum @@ -35185,7 +37274,7 @@ void ChannelConfig_set_force_close_avoidance_max_fee_satoshis(struct LDKChannelC * 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. + * Default value: `false` * * [intercept scids]: crate::ln::channelmanager::ChannelManager::get_intercept_scid * [`forward_intercepted_htlc`]: crate::ln::channelmanager::ChannelManager::forward_intercepted_htlc @@ -35220,7 +37309,7 @@ bool ChannelConfig_get_accept_underpaying_htlcs(const struct LDKChannelConfig *N * 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. + * Default value: `false` * * [intercept scids]: crate::ln::channelmanager::ChannelManager::get_intercept_scid * [`forward_intercepted_htlc`]: crate::ln::channelmanager::ChannelManager::forward_intercepted_htlc @@ -35302,11 +37391,6 @@ void ChannelConfigUpdate_set_force_close_avoidance_max_fee_satoshis(struct LDKCh */ 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 "default" ChannelConfigUpdate. See struct and individual field documentaiton for details on which values are used. - */ -MUST_USE_RES struct LDKChannelConfigUpdate ChannelConfigUpdate_default(void); - /** * Frees any resources used by the UserConfig, if is_owned is set and inner is non-NULL. */ @@ -35343,13 +37427,13 @@ struct LDKChannelConfig UserConfig_get_channel_config(const struct LDKUserConfig void UserConfig_set_channel_config(struct LDKUserConfig *NONNULL_PTR this_ptr, struct LDKChannelConfig val); /** - * If this is set to false, we will reject any HTLCs which were to be forwarded over private + * 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 + * (using [`ChannelHandshakeConfig::announce_for_forwarding`] 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 @@ -35358,18 +37442,18 @@ void UserConfig_set_channel_config(struct LDKUserConfig *NONNULL_PTR this_ptr, s * 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. + * Default value: `false` */ bool UserConfig_get_accept_forwards_to_priv_channels(const struct LDKUserConfig *NONNULL_PTR this_ptr); /** - * If this is set to false, we will reject any HTLCs which were to be forwarded over private + * 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 + * (using [`ChannelHandshakeConfig::announce_for_forwarding`] 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 @@ -35378,32 +37462,34 @@ bool UserConfig_get_accept_forwards_to_priv_channels(const struct LDKUserConfig * 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. + * Default value: `false` */ void UserConfig_set_accept_forwards_to_priv_channels(struct LDKUserConfig *NONNULL_PTR this_ptr, bool val); /** - * If this is set to false, we do not accept inbound requests to open a new channel. - * Default value: true. + * If this is set to `false`, we do not accept inbound requests to open a new channel. + * + * Default value: `true` */ bool UserConfig_get_accept_inbound_channels(const struct LDKUserConfig *NONNULL_PTR this_ptr); /** - * If this is set to false, we do not accept inbound requests to open a new channel. - * Default value: true. + * If this is set to `false`, we do not accept inbound requests to open a new channel. + * + * Default value: `true` */ void UserConfig_set_accept_inbound_channels(struct LDKUserConfig *NONNULL_PTR this_ptr, bool val); /** - * If this is set to true, the user needs to manually accept inbound requests to open a new + * 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 + * 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. + * Default value: `false` * * [`Event::OpenChannelRequest`]: crate::events::Event::OpenChannelRequest * [`msgs::OpenChannel`]: crate::ln::msgs::OpenChannel @@ -35412,15 +37498,15 @@ void UserConfig_set_accept_inbound_channels(struct LDKUserConfig *NONNULL_PTR th bool UserConfig_get_manually_accept_inbound_channels(const struct LDKUserConfig *NONNULL_PTR this_ptr); /** - * If this is set to true, the user needs to manually accept inbound requests to open a new + * 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 + * 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. + * Default value: `false` * * [`Event::OpenChannelRequest`]: crate::events::Event::OpenChannelRequest * [`msgs::OpenChannel`]: crate::ln::msgs::OpenChannel @@ -35429,13 +37515,13 @@ bool UserConfig_get_manually_accept_inbound_channels(const struct LDKUserConfig void UserConfig_set_manually_accept_inbound_channels(struct LDKUserConfig *NONNULL_PTR this_ptr, bool val); /** - * If this is set to true, LDK will intercept HTLCs that are attempting to be forwarded over + * 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. + * Setting this to `true` may break backwards compatibility with LDK versions < 0.0.113. * - * Default value: false. + * Default value: `false` * * [`ChannelManager::get_intercept_scid`]: crate::ln::channelmanager::ChannelManager::get_intercept_scid * [`Event::HTLCIntercepted`]: crate::events::Event::HTLCIntercepted @@ -35443,13 +37529,13 @@ void UserConfig_set_manually_accept_inbound_channels(struct LDKUserConfig *NONNU bool UserConfig_get_accept_intercept_htlcs(const struct LDKUserConfig *NONNULL_PTR this_ptr); /** - * If this is set to true, LDK will intercept HTLCs that are attempting to be forwarded over + * 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. + * Setting this to `true` may break backwards compatibility with LDK versions < 0.0.113. * - * Default value: false. + * Default value: `false` * * [`ChannelManager::get_intercept_scid`]: crate::ln::channelmanager::ChannelManager::get_intercept_scid * [`Event::HTLCIntercepted`]: crate::events::Event::HTLCIntercepted @@ -35457,37 +37543,71 @@ bool UserConfig_get_accept_intercept_htlcs(const struct LDKUserConfig *NONNULL_P void UserConfig_set_accept_intercept_htlcs(struct LDKUserConfig *NONNULL_PTR this_ptr, bool 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. + * 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 + * Setting this to `true` will break backwards compatibility upon downgrading to an LDK + * version prior to 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. + * Default value: `false` * * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager */ bool UserConfig_get_accept_mpp_keysend(const struct LDKUserConfig *NONNULL_PTR this_ptr); /** - * 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. + * 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 + * Setting this to `true` will break backwards compatibility upon downgrading to an LDK + * version prior to 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. + * Default value: `false` * * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager */ void UserConfig_set_accept_mpp_keysend(struct LDKUserConfig *NONNULL_PTR this_ptr, bool val); +/** + * If this is set to `true`, the user needs to manually pay [`Bolt12Invoice`]s when received. + * + * When set to `true`, [`Event::InvoiceReceived`] will be generated for each received + * [`Bolt12Invoice`] instead of being automatically paid after verification. Use + * [`ChannelManager::send_payment_for_bolt12_invoice`] to pay the invoice or + * [`ChannelManager::abandon_payment`] to abandon the associated payment. + * + * Default value: `false` + * + * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice + * [`Event::InvoiceReceived`]: crate::events::Event::InvoiceReceived + * [`ChannelManager::send_payment_for_bolt12_invoice`]: crate::ln::channelmanager::ChannelManager::send_payment_for_bolt12_invoice + * [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment + */ +bool UserConfig_get_manually_handle_bolt12_invoices(const struct LDKUserConfig *NONNULL_PTR this_ptr); + +/** + * If this is set to `true`, the user needs to manually pay [`Bolt12Invoice`]s when received. + * + * When set to `true`, [`Event::InvoiceReceived`] will be generated for each received + * [`Bolt12Invoice`] instead of being automatically paid after verification. Use + * [`ChannelManager::send_payment_for_bolt12_invoice`] to pay the invoice or + * [`ChannelManager::abandon_payment`] to abandon the associated payment. + * + * Default value: `false` + * + * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice + * [`Event::InvoiceReceived`]: crate::events::Event::InvoiceReceived + * [`ChannelManager::send_payment_for_bolt12_invoice`]: crate::ln::channelmanager::ChannelManager::send_payment_for_bolt12_invoice + * [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment + */ +void UserConfig_set_manually_handle_bolt12_invoices(struct LDKUserConfig *NONNULL_PTR this_ptr, bool val); + /** * Constructs a new UserConfig given each field */ -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); +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, bool manually_handle_bolt12_invoices_arg); /** * Creates a copy of the UserConfig @@ -35676,9 +37796,14 @@ void BroadcasterInterface_free(struct LDKBroadcasterInterface this_ptr); enum LDKConfirmationTarget ConfirmationTarget_clone(const enum LDKConfirmationTarget *NONNULL_PTR orig); /** - * Utility method to constructs a new OnChainSweep-variant ConfirmationTarget + * Utility method to constructs a new MaximumFeeEstimate-variant ConfirmationTarget + */ +enum LDKConfirmationTarget ConfirmationTarget_maximum_fee_estimate(void); + +/** + * Utility method to constructs a new UrgentOnChainSweep-variant ConfirmationTarget */ -enum LDKConfirmationTarget ConfirmationTarget_on_chain_sweep(void); +enum LDKConfirmationTarget ConfirmationTarget_urgent_on_chain_sweep(void); /** * Utility method to constructs a new MinAllowedAnchorChannelRemoteFee-variant ConfirmationTarget @@ -35726,28 +37851,6 @@ bool ConfirmationTarget_eq(const enum LDKConfirmationTarget *NONNULL_PTR a, cons */ void FeeEstimator_free(struct LDKFeeEstimator this_ptr); -/** - * Frees any resources used by the MonitorUpdateId, if is_owned is set and inner is non-NULL. - */ -void MonitorUpdateId_free(struct LDKMonitorUpdateId this_obj); - -/** - * Creates a copy of the MonitorUpdateId - */ -struct LDKMonitorUpdateId MonitorUpdateId_clone(const struct LDKMonitorUpdateId *NONNULL_PTR orig); - -/** - * Generates a non-cryptographic 64-bit hash of the MonitorUpdateId. - */ -uint64_t MonitorUpdateId_hash(const struct LDKMonitorUpdateId *NONNULL_PTR o); - -/** - * 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. - */ -bool MonitorUpdateId_eq(const struct LDKMonitorUpdateId *NONNULL_PTR a, const struct LDKMonitorUpdateId *NONNULL_PTR b); - /** * Calls the free function if one is set */ @@ -35779,8 +37882,7 @@ MUST_USE_RES struct LDKChainMonitor ChainMonitor_new(struct LDKCOption_FilterZ c * 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`]). + * `ignored_channels`. * * See [`ChannelMonitor::get_claimable_balances`] for more details on the exact criteria for * inclusion in the return value. @@ -35806,8 +37908,11 @@ MUST_USE_RES struct LDKCVec_C2Tuple_OutPointChannelIdZZ ChainMonitor_list_monito /** * Lists the pending updates for each [`ChannelMonitor`] (by `OutPoint` being monitored). + * Each `Vec` contains `update_id`s from [`ChannelMonitor::get_latest_update_id`] for updates + * that have not yet been fully persisted. Note that if a full monitor is persisted all the pending + * monitor updates must be individually marked completed by calling [`ChainMonitor::channel_monitor_updated`]. */ -MUST_USE_RES struct LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ ChainMonitor_list_pending_monitor_updates(const struct LDKChainMonitor *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCVec_C2Tuple_OutPointCVec_u64ZZZ ChainMonitor_list_pending_monitor_updates(const struct LDKChainMonitor *NONNULL_PTR this_arg); /** * Indicates the persistence of a [`ChannelMonitor`] has completed after @@ -35817,14 +37922,21 @@ MUST_USE_RES struct LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ ChainMonitor * 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. + * 2) once all remote copies are updated, you call this function with [`ChannelMonitor::get_latest_update_id`] + * or [`ChannelMonitorUpdate::update_id`] as the `completed_update_id`, and once all pending + * updates have completed the channel will be re-enabled. + * + * It is only necessary to call [`ChainMonitor::channel_monitor_updated`] when you return [`ChannelMonitorUpdateStatus::InProgress`] + * from [`Persist`] and either: + * 1. A new [`ChannelMonitor`] was added in [`Persist::persist_new_channel`], or + * 2. A [`ChannelMonitorUpdate`] was provided as part of [`Persist::update_persisted_channel`]. + * Note that we don't care about calls to [`Persist::update_persisted_channel`] where no + * [`ChannelMonitorUpdate`] was provided. * * Returns an [`APIError::APIMisuseError`] if `funding_txo` does not match any currently * registered [`ChannelMonitor`]s. */ -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); +MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChainMonitor_channel_monitor_updated(const struct LDKChainMonitor *NONNULL_PTR this_arg, struct LDKOutPoint funding_txo, uint64_t completed_update_id); /** * Gets a [`Future`] that completes when an event is available either via @@ -36052,6 +38164,37 @@ struct LDKCVec_u8Z HTLCUpdate_write(const struct LDKHTLCUpdate *NONNULL_PTR obj) */ struct LDKCResult_HTLCUpdateDecodeErrorZ HTLCUpdate_read(struct LDKu8slice ser); +/** + * Creates a copy of the BalanceSource + */ +enum LDKBalanceSource BalanceSource_clone(const enum LDKBalanceSource *NONNULL_PTR orig); + +/** + * Utility method to constructs a new HolderForceClosed-variant BalanceSource + */ +enum LDKBalanceSource BalanceSource_holder_force_closed(void); + +/** + * Utility method to constructs a new CounterpartyForceClosed-variant BalanceSource + */ +enum LDKBalanceSource BalanceSource_counterparty_force_closed(void); + +/** + * Utility method to constructs a new CoopClose-variant BalanceSource + */ +enum LDKBalanceSource BalanceSource_coop_close(void); + +/** + * Utility method to constructs a new Htlc-variant BalanceSource + */ +enum LDKBalanceSource BalanceSource_htlc(void); + +/** + * Checks if two BalanceSources contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + */ +bool BalanceSource_eq(const enum LDKBalanceSource *NONNULL_PTR a, const enum LDKBalanceSource *NONNULL_PTR b); + /** * Frees any resources used by the Balance */ @@ -36065,12 +38208,12 @@ struct LDKBalance Balance_clone(const struct LDKBalance *NONNULL_PTR orig); /** * Utility method to constructs a new ClaimableOnChannelClose-variant Balance */ -struct LDKBalance Balance_claimable_on_channel_close(uint64_t amount_satoshis); +struct LDKBalance Balance_claimable_on_channel_close(uint64_t amount_satoshis, uint64_t transaction_fee_satoshis, uint64_t outbound_payment_htlc_rounded_msat, uint64_t outbound_forwarded_htlc_rounded_msat, uint64_t inbound_claiming_htlc_rounded_msat, uint64_t inbound_htlc_rounded_msat); /** * Utility method to constructs a new ClaimableAwaitingConfirmations-variant Balance */ -struct LDKBalance Balance_claimable_awaiting_confirmations(uint64_t amount_satoshis, uint32_t confirmation_height); +struct LDKBalance Balance_claimable_awaiting_confirmations(uint64_t amount_satoshis, uint32_t confirmation_height, enum LDKBalanceSource source); /** * Utility method to constructs a new ContentiousClaimable-variant Balance @@ -36080,7 +38223,7 @@ struct LDKBalance Balance_contentious_claimable(uint64_t amount_satoshis, uint32 /** * Utility method to constructs a new MaybeTimeoutClaimableHTLC-variant Balance */ -struct LDKBalance Balance_maybe_timeout_claimable_htlc(uint64_t amount_satoshis, uint32_t claimable_height, struct LDKThirtyTwoBytes payment_hash); +struct LDKBalance Balance_maybe_timeout_claimable_htlc(uint64_t amount_satoshis, uint32_t claimable_height, struct LDKThirtyTwoBytes payment_hash, bool outbound_payment); /** * Utility method to constructs a new MaybePreimageClaimableHTLC-variant Balance @@ -36099,9 +38242,15 @@ struct LDKBalance Balance_counterparty_revoked_output_claimable(uint64_t amount_ bool Balance_eq(const struct LDKBalance *NONNULL_PTR a, const struct LDKBalance *NONNULL_PTR b); /** - * 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 + * The amount claimable, in satoshis. + * + * For outbound payments, this excludes the balance from the possible HTLC timeout. + * + * For forwarded payments, this includes the balance from the possible HTLC timeout as + * (to be conservative) that balance does not include routing fees we'd earn if we'd claim + * the balance from a preimage in a successful forward. + * + * 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. @@ -36178,10 +38327,12 @@ MUST_USE_RES struct LDKCVec_MonitorEventZ ChannelMonitor_get_and_clear_pending_m * An [`EventHandler`] may safely call back to the provider, though this shouldn't be needed in * order to handle these events. * + * Will return a [`ReplayEvent`] error if event handling failed and should eventually be retried. + * * [`SpendableOutputs`]: crate::events::Event::SpendableOutputs * [`BumpTransaction`]: crate::events::Event::BumpTransaction */ -void ChannelMonitor_process_pending_events(const struct LDKChannelMonitor *NONNULL_PTR this_arg, const struct LDKEventHandler *NONNULL_PTR handler); +MUST_USE_RES struct LDKCResult_NoneReplayEventZ ChannelMonitor_process_pending_events(const struct LDKChannelMonitor *NONNULL_PTR this_arg, const struct LDKEventHandler *NONNULL_PTR handler); /** * Gets the counterparty's initial commitment transaction. The returned commitment @@ -36342,6 +38493,11 @@ MUST_USE_RES struct LDKBestBlock ChannelMonitor_current_best_block(const struct */ void ChannelMonitor_rebroadcast_pending_claims(const struct LDKChannelMonitor *NONNULL_PTR this_arg, struct LDKBroadcasterInterface broadcaster, struct LDKFeeEstimator fee_estimator, const struct LDKLogger *NONNULL_PTR logger); +/** + * Returns true if the monitor has pending claim requests that are not fully confirmed yet. + */ +MUST_USE_RES bool ChannelMonitor_has_pending_claims(const struct LDKChannelMonitor *NONNULL_PTR this_arg); + /** * Triggers rebroadcasts of pending claims from a force-closed channel after a transaction * signature generation failure. @@ -36534,7 +38690,7 @@ bool InboundHTLCErr_eq(const struct LDKInboundHTLCErr *NONNULL_PTR a, const stru * * [`Event::PaymentClaimable`]: crate::events::Event::PaymentClaimable */ -struct LDKCResult_PendingHTLCInfoInboundHTLCErrZ peel_payment_onion(const struct LDKUpdateAddHTLC *NONNULL_PTR msg, const struct LDKNodeSigner *NONNULL_PTR node_signer, const struct LDKLogger *NONNULL_PTR logger, uint32_t cur_height, bool accept_mpp_keysend, bool allow_skimmed_fees); +struct LDKCResult_PendingHTLCInfoInboundHTLCErrZ peel_payment_onion(const struct LDKUpdateAddHTLC *NONNULL_PTR msg, struct LDKNodeSigner node_signer, struct LDKLogger logger, uint32_t cur_height, bool accept_mpp_keysend, bool allow_skimmed_fees); /** * Frees any resources used by the PendingHTLCRouting @@ -36592,10 +38748,30 @@ enum LDKBlindedFailure BlindedForward_get_failure(const struct LDKBlindedForward */ void BlindedForward_set_failure(struct LDKBlindedForward *NONNULL_PTR this_ptr, enum LDKBlindedFailure val); +/** + * Overrides the next hop's [`msgs::UpdateAddHTLC::blinding_point`]. Set if this HTLC is being + * forwarded within a [`BlindedPaymentPath`] that was concatenated to another blinded path that + * starts at the next hop. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +struct LDKPublicKey BlindedForward_get_next_blinding_override(const struct LDKBlindedForward *NONNULL_PTR this_ptr); + +/** + * Overrides the next hop's [`msgs::UpdateAddHTLC::blinding_point`]. Set if this HTLC is being + * forwarded within a [`BlindedPaymentPath`] that was concatenated to another blinded path that + * starts at the next hop. + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +void BlindedForward_set_next_blinding_override(struct LDKBlindedForward *NONNULL_PTR this_ptr, struct LDKPublicKey val); + /** * Constructs a new BlindedForward given each field + * + * Note that next_blinding_override_arg (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKBlindedForward BlindedForward_new(struct LDKPublicKey inbound_blinding_point_arg, enum LDKBlindedFailure failure_arg); +MUST_USE_RES struct LDKBlindedForward BlindedForward_new(struct LDKPublicKey inbound_blinding_point_arg, enum LDKBlindedFailure failure_arg, struct LDKPublicKey next_blinding_override_arg); /** * Creates a copy of the BlindedForward @@ -37085,38 +39261,56 @@ MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_close_channel(const MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_close_channel_with_feerate_and_script(const struct LDKChannelManager *NONNULL_PTR this_arg, const struct LDKChannelId *NONNULL_PTR channel_id, struct LDKPublicKey counterparty_node_id, struct LDKCOption_u32Z target_feerate_sats_per_1000_weight, struct LDKShutdownScript shutdown_script); /** - * 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. + * Force closes a channel, immediately broadcasting the latest local transaction(s), + * rejecting new HTLCs. + * + * The provided `error_message` is sent to connected peers for closing + * channels and should be a human-readable description of what went wrong. + * + * Fails if `channel_id` is unknown to the manager, or if the `counterparty_node_id` + * isn't the counterparty of the corresponding channel. */ -MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_force_close_broadcasting_latest_txn(const struct LDKChannelManager *NONNULL_PTR this_arg, const struct LDKChannelId *NONNULL_PTR channel_id, struct LDKPublicKey counterparty_node_id); +MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_force_close_broadcasting_latest_txn(const struct LDKChannelManager *NONNULL_PTR this_arg, const struct LDKChannelId *NONNULL_PTR channel_id, struct LDKPublicKey counterparty_node_id, struct LDKStr error_message); /** * 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. + * the latest local transaction(s). * + * The provided `error_message` is sent to connected peers for closing channels and should + * be a human-readable description of what went wrong. + * + * 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 broadcast the latest local transaction(s) via * [`ChannelMonitor::broadcast_latest_holder_commitment_txn`]. */ -MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_force_close_without_broadcasting_txn(const struct LDKChannelManager *NONNULL_PTR this_arg, const struct LDKChannelId *NONNULL_PTR channel_id, struct LDKPublicKey counterparty_node_id); +MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_force_close_without_broadcasting_txn(const struct LDKChannelManager *NONNULL_PTR this_arg, const struct LDKChannelId *NONNULL_PTR channel_id, struct LDKPublicKey counterparty_node_id, struct LDKStr error_message); /** * Force close all channels, immediately broadcasting the latest local commitment transaction * for each to the chain and rejecting new HTLCs on each. + * + * The provided `error_message` is sent to connected peers for closing channels and should + * be a human-readable description of what went wrong. */ -void ChannelManager_force_close_all_channels_broadcasting_latest_txn(const struct LDKChannelManager *NONNULL_PTR this_arg); +void ChannelManager_force_close_all_channels_broadcasting_latest_txn(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKStr error_message); /** * Force close all channels rejecting new HTLCs on each but without broadcasting the latest * local transaction(s). + * + * The provided `error_message` is sent to connected peers for closing channels and + * should be a human-readable description of what went wrong. */ -void ChannelManager_force_close_all_channels_without_broadcasting_txn(const struct LDKChannelManager *NONNULL_PTR this_arg); +void ChannelManager_force_close_all_channels_without_broadcasting_txn(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKStr error_message); /** * Sends a payment along a given route. * + * This method is *DEPRECATED*, use [`Self::send_payment`] instead. If you wish to fix the + * route for a payment, do so by matching the [`PaymentId`] passed to + * [`Router::find_route_with_id`]. + * * Value parameters are provided via the last hop in route, see documentation for [`RouteHop`] * fields for more info. * @@ -37167,7 +39361,7 @@ void ChannelManager_force_close_all_channels_without_broadcasting_txn(const stru * [`PeerManager::process_events`]: crate::ln::peer_handler::PeerManager::process_events * [`ChannelMonitorUpdateStatus::InProgress`]: crate::chain::ChannelMonitorUpdateStatus::InProgress */ -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); +MUST_USE_RES struct LDKCResult_NonePaymentSendFailureZ ChannelManager_send_payment_with_route(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKRoute route, struct LDKThirtyTwoBytes payment_hash, struct LDKRecipientOnionFields recipient_onion, struct LDKThirtyTwoBytes payment_id); /** * Similar to [`ChannelManager::send_payment_with_route`], but will automatically find a route based on @@ -37192,15 +39386,13 @@ MUST_USE_RES struct LDKCResult_NoneRetryableSendFailureZ ChannelManager_send_pay * # Requested Invoices * * In the case of paying a [`Bolt12Invoice`] via [`ChannelManager::pay_for_offer`], abandoning - * the payment prior to receiving the invoice will result in an [`Event::InvoiceRequestFailed`] - * and prevent any attempts at paying it once received. The other events may only be generated - * once the invoice has been received. + * the payment prior to receiving the invoice will result in an [`Event::PaymentFailed`] and + * prevent any attempts at paying it once received. * * # Restart Behavior * * If an [`Event::PaymentFailed`] is generated and we restart without first persisting the - * [`ChannelManager`], another [`Event::PaymentFailed`] may be generated; likewise for - * [`Event::InvoiceRequestFailed`]. + * [`ChannelManager`], another [`Event::PaymentFailed`] may be generated. * * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice */ @@ -37299,7 +39491,38 @@ MUST_USE_RES struct LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeS * [`Event::FundingGenerationReady`]: crate::events::Event::FundingGenerationReady * [`Event::ChannelClosed`]: crate::events::Event::ChannelClosed */ -MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_funding_transaction_generated(const struct LDKChannelManager *NONNULL_PTR this_arg, const struct LDKChannelId *NONNULL_PTR temporary_channel_id, struct LDKPublicKey counterparty_node_id, struct LDKTransaction funding_transaction); +MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_funding_transaction_generated(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKChannelId temporary_channel_id, struct LDKPublicKey counterparty_node_id, struct LDKTransaction funding_transaction); + +/** + * **Unsafe**: This method does not validate the spent output. It is the caller's + * responsibility to ensure the spent outputs are SegWit, as well as making sure the funding + * transaction has a final absolute locktime, i.e., its locktime is lower than the next block height. + * + * For a safer method, please refer to [`ChannelManager::funding_transaction_generated`]. + * + * Call this in response to a [`Event::FundingGenerationReady`] event. + * + * Note that if this method is called successfully, the funding transaction won't be + * broadcasted and you are expected to broadcast it manually when receiving the + * [`Event::FundingTxBroadcastSafe`] event. + * + * 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 funding output is duplicative with some other channel (note that this + * should be trivially prevented by using unique funding transaction keys per-channel). + * + * 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::FundingTxBroadcastSafe`]: crate::events::Event::FundingTxBroadcastSafe + * [`Event::ChannelClosed`]: crate::events::Event::ChannelClosed + * [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated + */ +MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_unsafe_manual_funding_transaction_generated(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKChannelId temporary_channel_id, struct LDKPublicKey counterparty_node_id, struct LDKOutPoint funding); /** * Call this upon creation of a batch funding transaction for the given channels. @@ -37553,16 +39776,15 @@ MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_accept_inbound_chann /** * Creates an [`OfferBuilder`] such that the [`Offer`] it builds is recognized by the - * [`ChannelManager`] when handling [`InvoiceRequest`] messages for the offer. The offer will - * not have an expiration unless otherwise set on the builder. + * [`ChannelManager`] when handling [`InvoiceRequest`] messages for the offer. The offer's + * expiration will be `absolute_expiry` if `Some`, otherwise it will not expire. * * # Privacy * - * Uses [`MessageRouter::create_blinded_paths`] to construct a [`BlindedPath`] for the offer. - * However, if one is not found, uses a one-hop [`BlindedPath`] with - * [`ChannelManager::get_our_node_id`] as the introduction node instead. In the latter case, - * the node must be announced, otherwise, there is no way to find a path to the introduction in - * order to send the [`InvoiceRequest`]. + * Uses [`MessageRouter`] to construct a [`BlindedMessagePath`] for the offer based on the given + * `absolute_expiry` according to [`MAX_SHORT_LIVED_RELATIVE_EXPIRY`]. See those docs for + * privacy implications as well as those of the parameterized [`Router`], which implements + * [`MessageRouter`]. * * Also, uses a derived signing pubkey in the offer for recipient privacy. * @@ -37578,7 +39800,7 @@ MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_accept_inbound_chann * [`Offer`]: crate::offers::offer::Offer * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest */ -MUST_USE_RES struct LDKCResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ ChannelManager_create_offer_builder(const struct LDKChannelManager *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ ChannelManager_create_offer_builder(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKCOption_u64Z absolute_expiry); /** * Creates a [`RefundBuilder`] such that the [`Refund`] it builds is recognized by the @@ -37596,18 +39818,17 @@ MUST_USE_RES struct LDKCResult_OfferWithDerivedMetadataBuilderBolt12SemanticErro * * To revoke the refund, use [`ChannelManager::abandon_payment`] prior to receiving the * invoice. If abandoned, or an invoice isn't received before expiration, the payment will fail - * with an [`Event::InvoiceRequestFailed`]. + * with an [`Event::PaymentFailed`]. * * If `max_total_routing_fee_msat` is not specified, The default from * [`RouteParameters::from_payment_params_and_value`] is applied. * * # Privacy * - * Uses [`MessageRouter::create_blinded_paths`] to construct a [`BlindedPath`] for the refund. - * However, if one is not found, uses a one-hop [`BlindedPath`] with - * [`ChannelManager::get_our_node_id`] as the introduction node instead. In the latter case, - * the node must be announced, otherwise, there is no way to find a path to the introduction in - * order to send the [`Bolt12Invoice`]. + * Uses [`MessageRouter`] to construct a [`BlindedMessagePath`] for the refund based on the given + * `absolute_expiry` according to [`MAX_SHORT_LIVED_RELATIVE_EXPIRY`]. See those docs for + * privacy implications as well as those of the parameterized [`Router`], which implements + * [`MessageRouter`]. * * Also, uses a derived payer id in the refund for payer privacy. * @@ -37654,14 +39875,13 @@ MUST_USE_RES struct LDKCResult_RefundMaybeWithDerivedMetadataBuilderBolt12Semant * * To revoke the request, use [`ChannelManager::abandon_payment`] prior to receiving the * invoice. If abandoned, or an invoice isn't received in a reasonable amount of time, the - * payment will fail with an [`Event::InvoiceRequestFailed`]. + * payment will fail with an [`Event::PaymentFailed`]. * * # Privacy * - * Uses a one-hop [`BlindedPath`] for the reply path with [`ChannelManager::get_our_node_id`] - * as the introduction node and a derived payer id for payer privacy. As such, currently, the - * node must be announced. Otherwise, there is no way to find a path to the introduction node - * in order to send the [`Bolt12Invoice`]. + * For payer privacy, uses a derived payer id and uses [`MessageRouter::create_blinded_paths`] + * to construct a [`BlindedMessagePath`] for the reply path. For further privacy implications, see the + * docs of the parameterized [`Router`], which implements [`MessageRouter`]. * * # Limitations * @@ -37693,8 +39913,8 @@ MUST_USE_RES struct LDKCResult_NoneBolt12SemanticErrorZ ChannelManager_pay_for_o * message. * * The resulting invoice uses a [`PaymentHash`] recognized by the [`ChannelManager`] and a - * [`BlindedPath`] containing the [`PaymentSecret`] needed to reconstruct the corresponding - * [`PaymentPreimage`]. It is returned purely for informational purposes. + * [`BlindedPaymentPath`] containing the [`PaymentSecret`] needed to reconstruct the + * corresponding [`PaymentPreimage`]. It is returned purely for informational purposes. * * # Limitations * @@ -37923,6 +40143,12 @@ struct LDKChannelMessageHandler ChannelManager_as_ChannelMessageHandler(const st */ struct LDKOffersMessageHandler ChannelManager_as_OffersMessageHandler(const struct LDKChannelManager *NONNULL_PTR this_arg); +/** + * Constructs a new AsyncPaymentsMessageHandler which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned AsyncPaymentsMessageHandler must be freed before this_arg is + */ +struct LDKAsyncPaymentsMessageHandler ChannelManager_as_AsyncPaymentsMessageHandler(const struct LDKChannelManager *NONNULL_PTR this_arg); + /** * Constructs a new NodeIdLookUp which calls the relevant methods on this_arg. * This copies the `inner` pointer in this_arg and thus the returned NodeIdLookUp must be freed before this_arg is @@ -39435,12 +41661,12 @@ void ChannelDetails_set_is_usable(struct LDKChannelDetails *NONNULL_PTR this_ptr /** * True if this channel is (or will be) publicly-announced. */ -bool ChannelDetails_get_is_public(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +bool ChannelDetails_get_is_announced(const struct LDKChannelDetails *NONNULL_PTR this_ptr); /** * True if this channel is (or will be) publicly-announced. */ -void ChannelDetails_set_is_public(struct LDKChannelDetails *NONNULL_PTR this_ptr, bool val); +void ChannelDetails_set_is_announced(struct LDKChannelDetails *NONNULL_PTR this_ptr, bool val); /** * The smallest value HTLC (in msat) we will accept, for this channel. This field @@ -39517,7 +41743,7 @@ void ChannelDetails_set_pending_outbound_htlcs(struct LDKChannelDetails *NONNULL * Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None * Note that config_arg (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKChannelDetails ChannelDetails_new(struct LDKChannelId 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, struct LDKCVec_InboundHTLCDetailsZ pending_inbound_htlcs_arg, struct LDKCVec_OutboundHTLCDetailsZ pending_outbound_htlcs_arg); +MUST_USE_RES struct LDKChannelDetails ChannelDetails_new(struct LDKChannelId 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_announced_arg, struct LDKCOption_u64Z inbound_htlc_minimum_msat_arg, struct LDKCOption_u64Z inbound_htlc_maximum_msat_arg, struct LDKChannelConfig config_arg, struct LDKCVec_InboundHTLCDetailsZ pending_inbound_htlcs_arg, struct LDKCVec_OutboundHTLCDetailsZ pending_outbound_htlcs_arg); /** * Creates a copy of the ChannelDetails @@ -40228,6 +42454,104 @@ uint64_t CommonOpenChannelFields_hash(const struct LDKCommonOpenChannelFields *N */ bool CommonOpenChannelFields_eq(const struct LDKCommonOpenChannelFields *NONNULL_PTR a, const struct LDKCommonOpenChannelFields *NONNULL_PTR b); +/** + * The [`ChannelParameters`] for this channel. + */ +MUST_USE_RES struct LDKChannelParameters CommonOpenChannelFields_channel_parameters(const struct LDKCommonOpenChannelFields *NONNULL_PTR this_arg); + +/** + * Frees any resources used by the ChannelParameters, if is_owned is set and inner is non-NULL. + */ +void ChannelParameters_free(struct LDKChannelParameters this_obj); + +/** + * The threshold below which outputs on transactions broadcast by the channel initiator will be + * omitted. + */ +uint64_t ChannelParameters_get_dust_limit_satoshis(const struct LDKChannelParameters *NONNULL_PTR this_ptr); + +/** + * The threshold below which outputs on transactions broadcast by the channel initiator will be + * omitted. + */ +void ChannelParameters_set_dust_limit_satoshis(struct LDKChannelParameters *NONNULL_PTR this_ptr, uint64_t val); + +/** + * The maximum inbound HTLC value in flight towards channel initiator, in milli-satoshi + */ +uint64_t ChannelParameters_get_max_htlc_value_in_flight_msat(const struct LDKChannelParameters *NONNULL_PTR this_ptr); + +/** + * The maximum inbound HTLC value in flight towards channel initiator, in milli-satoshi + */ +void ChannelParameters_set_max_htlc_value_in_flight_msat(struct LDKChannelParameters *NONNULL_PTR this_ptr, uint64_t val); + +/** + * The minimum HTLC size for HTLCs towards the channel initiator, in milli-satoshi + */ +uint64_t ChannelParameters_get_htlc_minimum_msat(const struct LDKChannelParameters *NONNULL_PTR this_ptr); + +/** + * The minimum HTLC size for HTLCs towards the channel initiator, in milli-satoshi + */ +void ChannelParameters_set_htlc_minimum_msat(struct LDKChannelParameters *NONNULL_PTR this_ptr, uint64_t val); + +/** + * The feerate for the commitment transaction set by the channel initiator until updated by + * [`UpdateFee`] + */ +uint32_t ChannelParameters_get_commitment_feerate_sat_per_1000_weight(const struct LDKChannelParameters *NONNULL_PTR this_ptr); + +/** + * The feerate for the commitment transaction set by the channel initiator until updated by + * [`UpdateFee`] + */ +void ChannelParameters_set_commitment_feerate_sat_per_1000_weight(struct LDKChannelParameters *NONNULL_PTR this_ptr, uint32_t val); + +/** + * The number of blocks which the non-channel-initator will have to wait to claim on-chain + * funds if they broadcast a commitment transaction. + */ +uint16_t ChannelParameters_get_to_self_delay(const struct LDKChannelParameters *NONNULL_PTR this_ptr); + +/** + * The number of blocks which the non-channel-initator will have to wait to claim on-chain + * funds if they broadcast a commitment transaction. + */ +void ChannelParameters_set_to_self_delay(struct LDKChannelParameters *NONNULL_PTR this_ptr, uint16_t val); + +/** + * The maximum number of pending HTLCs towards the channel initiator. + */ +uint16_t ChannelParameters_get_max_accepted_htlcs(const struct LDKChannelParameters *NONNULL_PTR this_ptr); + +/** + * The maximum number of pending HTLCs towards the channel initiator. + */ +void ChannelParameters_set_max_accepted_htlcs(struct LDKChannelParameters *NONNULL_PTR this_ptr, uint16_t val); + +/** + * Constructs a new ChannelParameters given each field + */ +MUST_USE_RES struct LDKChannelParameters ChannelParameters_new(uint64_t dust_limit_satoshis_arg, uint64_t max_htlc_value_in_flight_msat_arg, uint64_t htlc_minimum_msat_arg, uint32_t commitment_feerate_sat_per_1000_weight_arg, uint16_t to_self_delay_arg, uint16_t max_accepted_htlcs_arg); + +/** + * Creates a copy of the ChannelParameters + */ +struct LDKChannelParameters ChannelParameters_clone(const struct LDKChannelParameters *NONNULL_PTR orig); + +/** + * Generates a non-cryptographic 64-bit hash of the ChannelParameters. + */ +uint64_t ChannelParameters_hash(const struct LDKChannelParameters *NONNULL_PTR o); + +/** + * Checks if two ChannelParameterss 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 ChannelParameters_eq(const struct LDKChannelParameters *NONNULL_PTR a, const struct LDKChannelParameters *NONNULL_PTR b); + /** * Frees any resources used by the OpenChannel, if is_owned is set and inner is non-NULL. */ @@ -40897,88 +43221,88 @@ struct LDKStfu Stfu_clone(const struct LDKStfu *NONNULL_PTR orig); bool Stfu_eq(const struct LDKStfu *NONNULL_PTR a, const struct LDKStfu *NONNULL_PTR b); /** - * Frees any resources used by the Splice, if is_owned is set and inner is non-NULL. + * Frees any resources used by the SpliceInit, if is_owned is set and inner is non-NULL. */ -void Splice_free(struct LDKSplice this_obj); +void SpliceInit_free(struct LDKSpliceInit this_obj); /** * The channel ID where splicing is intended */ -struct LDKChannelId Splice_get_channel_id(const struct LDKSplice *NONNULL_PTR this_ptr); +struct LDKChannelId SpliceInit_get_channel_id(const struct LDKSpliceInit *NONNULL_PTR this_ptr); /** * The channel ID where splicing is intended */ -void Splice_set_channel_id(struct LDKSplice *NONNULL_PTR this_ptr, struct LDKChannelId val); - -/** - * The genesis hash of the blockchain where the channel is intended to be spliced - */ -const uint8_t (*Splice_get_chain_hash(const struct LDKSplice *NONNULL_PTR this_ptr))[32]; - -/** - * The genesis hash of the blockchain where the channel is intended to be spliced - */ -void Splice_set_chain_hash(struct LDKSplice *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void SpliceInit_set_channel_id(struct LDKSpliceInit *NONNULL_PTR this_ptr, struct LDKChannelId val); /** - * The intended change in channel capacity: the amount to be added (positive value) - * or removed (negative value) by the sender (splice initiator) by splicing into/from the channel. + * The amount the splice initiator is intending to add to its channel balance (splice-in) + * or remove from its channel balance (splice-out). */ -int64_t Splice_get_relative_satoshis(const struct LDKSplice *NONNULL_PTR this_ptr); +int64_t SpliceInit_get_funding_contribution_satoshis(const struct LDKSpliceInit *NONNULL_PTR this_ptr); /** - * The intended change in channel capacity: the amount to be added (positive value) - * or removed (negative value) by the sender (splice initiator) by splicing into/from the channel. + * The amount the splice initiator is intending to add to its channel balance (splice-in) + * or remove from its channel balance (splice-out). */ -void Splice_set_relative_satoshis(struct LDKSplice *NONNULL_PTR this_ptr, int64_t val); +void SpliceInit_set_funding_contribution_satoshis(struct LDKSpliceInit *NONNULL_PTR this_ptr, int64_t val); /** * The feerate for the new funding transaction, set by the splice initiator */ -uint32_t Splice_get_funding_feerate_perkw(const struct LDKSplice *NONNULL_PTR this_ptr); +uint32_t SpliceInit_get_funding_feerate_perkw(const struct LDKSpliceInit *NONNULL_PTR this_ptr); /** * The feerate for the new funding transaction, set by the splice initiator */ -void Splice_set_funding_feerate_perkw(struct LDKSplice *NONNULL_PTR this_ptr, uint32_t val); +void SpliceInit_set_funding_feerate_perkw(struct LDKSpliceInit *NONNULL_PTR this_ptr, uint32_t val); /** * The locktime for the new funding transaction */ -uint32_t Splice_get_locktime(const struct LDKSplice *NONNULL_PTR this_ptr); +uint32_t SpliceInit_get_locktime(const struct LDKSpliceInit *NONNULL_PTR this_ptr); /** * The locktime for the new funding transaction */ -void Splice_set_locktime(struct LDKSplice *NONNULL_PTR this_ptr, uint32_t val); +void SpliceInit_set_locktime(struct LDKSpliceInit *NONNULL_PTR this_ptr, uint32_t val); /** * The key of the sender (splice initiator) controlling the new funding transaction */ -struct LDKPublicKey Splice_get_funding_pubkey(const struct LDKSplice *NONNULL_PTR this_ptr); +struct LDKPublicKey SpliceInit_get_funding_pubkey(const struct LDKSpliceInit *NONNULL_PTR this_ptr); /** * The key of the sender (splice initiator) controlling the new funding transaction */ -void Splice_set_funding_pubkey(struct LDKSplice *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void SpliceInit_set_funding_pubkey(struct LDKSpliceInit *NONNULL_PTR this_ptr, struct LDKPublicKey val); + +/** + * If set, only confirmed inputs added (by the splice acceptor) will be accepted + */ +enum LDKCOption_NoneZ SpliceInit_get_require_confirmed_inputs(const struct LDKSpliceInit *NONNULL_PTR this_ptr); /** - * Constructs a new Splice given each field + * If set, only confirmed inputs added (by the splice acceptor) will be accepted */ -MUST_USE_RES struct LDKSplice Splice_new(struct LDKChannelId channel_id_arg, struct LDKThirtyTwoBytes chain_hash_arg, int64_t relative_satoshis_arg, uint32_t funding_feerate_perkw_arg, uint32_t locktime_arg, struct LDKPublicKey funding_pubkey_arg); +void SpliceInit_set_require_confirmed_inputs(struct LDKSpliceInit *NONNULL_PTR this_ptr, enum LDKCOption_NoneZ val); /** - * Creates a copy of the Splice + * Constructs a new SpliceInit given each field */ -struct LDKSplice Splice_clone(const struct LDKSplice *NONNULL_PTR orig); +MUST_USE_RES struct LDKSpliceInit SpliceInit_new(struct LDKChannelId channel_id_arg, int64_t funding_contribution_satoshis_arg, uint32_t funding_feerate_perkw_arg, uint32_t locktime_arg, struct LDKPublicKey funding_pubkey_arg, enum LDKCOption_NoneZ require_confirmed_inputs_arg); /** - * Checks if two Splices contain equal inner contents. + * Creates a copy of the SpliceInit + */ +struct LDKSpliceInit SpliceInit_clone(const struct LDKSpliceInit *NONNULL_PTR orig); + +/** + * Checks if two SpliceInits 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 Splice_eq(const struct LDKSplice *NONNULL_PTR a, const struct LDKSplice *NONNULL_PTR b); +bool SpliceInit_eq(const struct LDKSpliceInit *NONNULL_PTR a, const struct LDKSpliceInit *NONNULL_PTR b); /** * Frees any resources used by the SpliceAck, if is_owned is set and inner is non-NULL. @@ -40996,41 +43320,41 @@ struct LDKChannelId SpliceAck_get_channel_id(const struct LDKSpliceAck *NONNULL_ void SpliceAck_set_channel_id(struct LDKSpliceAck *NONNULL_PTR this_ptr, struct LDKChannelId val); /** - * The genesis hash of the blockchain where the channel is intended to be spliced + * The amount the splice acceptor is intending to add to its channel balance (splice-in) + * or remove from its channel balance (splice-out). */ -const uint8_t (*SpliceAck_get_chain_hash(const struct LDKSpliceAck *NONNULL_PTR this_ptr))[32]; +int64_t SpliceAck_get_funding_contribution_satoshis(const struct LDKSpliceAck *NONNULL_PTR this_ptr); /** - * The genesis hash of the blockchain where the channel is intended to be spliced + * The amount the splice acceptor is intending to add to its channel balance (splice-in) + * or remove from its channel balance (splice-out). */ -void SpliceAck_set_chain_hash(struct LDKSpliceAck *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void SpliceAck_set_funding_contribution_satoshis(struct LDKSpliceAck *NONNULL_PTR this_ptr, int64_t val); /** - * The intended change in channel capacity: the amount to be added (positive value) - * or removed (negative value) by the sender (splice acceptor) by splicing into/from the channel. + * The key of the sender (splice acceptor) controlling the new funding transaction */ -int64_t SpliceAck_get_relative_satoshis(const struct LDKSpliceAck *NONNULL_PTR this_ptr); +struct LDKPublicKey SpliceAck_get_funding_pubkey(const struct LDKSpliceAck *NONNULL_PTR this_ptr); /** - * The intended change in channel capacity: the amount to be added (positive value) - * or removed (negative value) by the sender (splice acceptor) by splicing into/from the channel. + * The key of the sender (splice acceptor) controlling the new funding transaction */ -void SpliceAck_set_relative_satoshis(struct LDKSpliceAck *NONNULL_PTR this_ptr, int64_t val); +void SpliceAck_set_funding_pubkey(struct LDKSpliceAck *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * The key of the sender (splice acceptor) controlling the new funding transaction + * If set, only confirmed inputs added (by the splice initiator) will be accepted */ -struct LDKPublicKey SpliceAck_get_funding_pubkey(const struct LDKSpliceAck *NONNULL_PTR this_ptr); +enum LDKCOption_NoneZ SpliceAck_get_require_confirmed_inputs(const struct LDKSpliceAck *NONNULL_PTR this_ptr); /** - * The key of the sender (splice acceptor) controlling the new funding transaction + * If set, only confirmed inputs added (by the splice initiator) will be accepted */ -void SpliceAck_set_funding_pubkey(struct LDKSpliceAck *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void SpliceAck_set_require_confirmed_inputs(struct LDKSpliceAck *NONNULL_PTR this_ptr, enum LDKCOption_NoneZ val); /** * Constructs a new SpliceAck given each field */ -MUST_USE_RES struct LDKSpliceAck SpliceAck_new(struct LDKChannelId channel_id_arg, struct LDKThirtyTwoBytes chain_hash_arg, int64_t relative_satoshis_arg, struct LDKPublicKey funding_pubkey_arg); +MUST_USE_RES struct LDKSpliceAck SpliceAck_new(struct LDKChannelId channel_id_arg, int64_t funding_contribution_satoshis_arg, struct LDKPublicKey funding_pubkey_arg, enum LDKCOption_NoneZ require_confirmed_inputs_arg); /** * Creates a copy of the SpliceAck @@ -41059,10 +43383,20 @@ struct LDKChannelId SpliceLocked_get_channel_id(const struct LDKSpliceLocked *NO */ void SpliceLocked_set_channel_id(struct LDKSpliceLocked *NONNULL_PTR this_ptr, struct LDKChannelId val); +/** + * The ID of the new funding transaction that has been locked + */ +const uint8_t (*SpliceLocked_get_splice_txid(const struct LDKSpliceLocked *NONNULL_PTR this_ptr))[32]; + +/** + * The ID of the new funding transaction that has been locked + */ +void SpliceLocked_set_splice_txid(struct LDKSpliceLocked *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); + /** * Constructs a new SpliceLocked given each field */ -MUST_USE_RES struct LDKSpliceLocked SpliceLocked_new(struct LDKChannelId channel_id_arg); +MUST_USE_RES struct LDKSpliceLocked SpliceLocked_new(struct LDKChannelId channel_id_arg, struct LDKThirtyTwoBytes splice_txid_arg); /** * Creates a copy of the SpliceLocked @@ -41135,10 +43469,20 @@ uint32_t TxAddInput_get_sequence(const struct LDKTxAddInput *NONNULL_PTR this_pt */ void TxAddInput_set_sequence(struct LDKTxAddInput *NONNULL_PTR this_ptr, uint32_t val); +/** + * The ID of the previous funding transaction, when it is being added as an input during splicing + */ +struct LDKCOption_ThirtyTwoBytesZ TxAddInput_get_shared_input_txid(const struct LDKTxAddInput *NONNULL_PTR this_ptr); + +/** + * The ID of the previous funding transaction, when it is being added as an input during splicing + */ +void TxAddInput_set_shared_input_txid(struct LDKTxAddInput *NONNULL_PTR this_ptr, struct LDKCOption_ThirtyTwoBytesZ val); + /** * Constructs a new TxAddInput given each field */ -MUST_USE_RES struct LDKTxAddInput TxAddInput_new(struct LDKChannelId channel_id_arg, uint64_t serial_id_arg, struct LDKTransactionU16LenLimited prevtx_arg, uint32_t prevtx_out_arg, uint32_t sequence_arg); +MUST_USE_RES struct LDKTxAddInput TxAddInput_new(struct LDKChannelId channel_id_arg, uint64_t serial_id_arg, struct LDKTransactionU16LenLimited prevtx_arg, uint32_t prevtx_out_arg, uint32_t sequence_arg, struct LDKCOption_ThirtyTwoBytesZ shared_input_txid_arg); /** * Creates a copy of the TxAddInput @@ -41397,17 +43741,17 @@ void TxSignatures_set_witnesses(struct LDKTxSignatures *NONNULL_PTR this_ptr, st /** * Optional signature for the shared input -- the previous funding outpoint -- signed by both peers */ -struct LDKCOption_ECDSASignatureZ TxSignatures_get_funding_outpoint_sig(const struct LDKTxSignatures *NONNULL_PTR this_ptr); +struct LDKCOption_ECDSASignatureZ TxSignatures_get_shared_input_signature(const struct LDKTxSignatures *NONNULL_PTR this_ptr); /** * Optional signature for the shared input -- the previous funding outpoint -- signed by both peers */ -void TxSignatures_set_funding_outpoint_sig(struct LDKTxSignatures *NONNULL_PTR this_ptr, struct LDKCOption_ECDSASignatureZ val); +void TxSignatures_set_shared_input_signature(struct LDKTxSignatures *NONNULL_PTR this_ptr, struct LDKCOption_ECDSASignatureZ val); /** * Constructs a new TxSignatures given each field */ -MUST_USE_RES struct LDKTxSignatures TxSignatures_new(struct LDKChannelId channel_id_arg, struct LDKThirtyTwoBytes tx_hash_arg, struct LDKCVec_WitnessZ witnesses_arg, struct LDKCOption_ECDSASignatureZ funding_outpoint_sig_arg); +MUST_USE_RES struct LDKTxSignatures TxSignatures_new(struct LDKChannelId channel_id_arg, struct LDKThirtyTwoBytes tx_hash_arg, struct LDKCVec_WitnessZ witnesses_arg, struct LDKCOption_ECDSASignatureZ shared_input_signature_arg); /** * Creates a copy of the TxSignatures @@ -42089,6 +44433,53 @@ uint64_t UpdateFailMalformedHTLC_hash(const struct LDKUpdateFailMalformedHTLC *N */ bool UpdateFailMalformedHTLC_eq(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR a, const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR b); +/** + * Frees any resources used by the CommitmentSignedBatch, if is_owned is set and inner is non-NULL. + */ +void CommitmentSignedBatch_free(struct LDKCommitmentSignedBatch this_obj); + +/** + * Batch size N: all N `commitment_signed` messages must be received before being processed + */ +uint16_t CommitmentSignedBatch_get_batch_size(const struct LDKCommitmentSignedBatch *NONNULL_PTR this_ptr); + +/** + * Batch size N: all N `commitment_signed` messages must be received before being processed + */ +void CommitmentSignedBatch_set_batch_size(struct LDKCommitmentSignedBatch *NONNULL_PTR this_ptr, uint16_t val); + +/** + * The funding transaction, to discriminate among multiple pending funding transactions (e.g. in case of splicing) + */ +const uint8_t (*CommitmentSignedBatch_get_funding_txid(const struct LDKCommitmentSignedBatch *NONNULL_PTR this_ptr))[32]; + +/** + * The funding transaction, to discriminate among multiple pending funding transactions (e.g. in case of splicing) + */ +void CommitmentSignedBatch_set_funding_txid(struct LDKCommitmentSignedBatch *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); + +/** + * Constructs a new CommitmentSignedBatch given each field + */ +MUST_USE_RES struct LDKCommitmentSignedBatch CommitmentSignedBatch_new(uint16_t batch_size_arg, struct LDKThirtyTwoBytes funding_txid_arg); + +/** + * Creates a copy of the CommitmentSignedBatch + */ +struct LDKCommitmentSignedBatch CommitmentSignedBatch_clone(const struct LDKCommitmentSignedBatch *NONNULL_PTR orig); + +/** + * Generates a non-cryptographic 64-bit hash of the CommitmentSignedBatch. + */ +uint64_t CommitmentSignedBatch_hash(const struct LDKCommitmentSignedBatch *NONNULL_PTR o); + +/** + * Checks if two CommitmentSignedBatchs 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 CommitmentSignedBatch_eq(const struct LDKCommitmentSignedBatch *NONNULL_PTR a, const struct LDKCommitmentSignedBatch *NONNULL_PTR b); + /** * Frees any resources used by the CommitmentSigned, if is_owned is set and inner is non-NULL. */ @@ -42126,10 +44517,26 @@ struct LDKCVec_ECDSASignatureZ CommitmentSigned_get_htlc_signatures(const struct */ void CommitmentSigned_set_htlc_signatures(struct LDKCommitmentSigned *NONNULL_PTR this_ptr, struct LDKCVec_ECDSASignatureZ val); +/** + * Optional batch size and other parameters + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +struct LDKCommitmentSignedBatch CommitmentSigned_get_batch(const struct LDKCommitmentSigned *NONNULL_PTR this_ptr); + +/** + * Optional batch size and other parameters + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +void CommitmentSigned_set_batch(struct LDKCommitmentSigned *NONNULL_PTR this_ptr, struct LDKCommitmentSignedBatch val); + /** * Constructs a new CommitmentSigned given each field + * + * Note that batch_arg (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKCommitmentSigned CommitmentSigned_new(struct LDKChannelId channel_id_arg, struct LDKECDSASignature signature_arg, struct LDKCVec_ECDSASignatureZ htlc_signatures_arg); +MUST_USE_RES struct LDKCommitmentSigned CommitmentSigned_new(struct LDKChannelId channel_id_arg, struct LDKECDSASignature signature_arg, struct LDKCVec_ECDSASignatureZ htlc_signatures_arg, struct LDKCommitmentSignedBatch batch_arg); /** * Creates a copy of the CommitmentSigned @@ -42958,14 +45365,26 @@ uint32_t UnsignedChannelUpdate_get_timestamp(const struct LDKUnsignedChannelUpda void UnsignedChannelUpdate_set_timestamp(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint32_t val); /** - * Channel flags + * Flags pertaining to this message. + */ +uint8_t UnsignedChannelUpdate_get_message_flags(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); + +/** + * Flags pertaining to this message. + */ +void UnsignedChannelUpdate_set_message_flags(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint8_t val); + +/** + * Flags pertaining to the channel, including to which direction in the channel this update + * applies and whether the direction is currently able to forward HTLCs. */ -uint8_t UnsignedChannelUpdate_get_flags(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); +uint8_t UnsignedChannelUpdate_get_channel_flags(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); /** - * Channel flags + * Flags pertaining to the channel, including to which direction in the channel this update + * applies and whether the direction is currently able to forward HTLCs. */ -void UnsignedChannelUpdate_set_flags(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint8_t val); +void UnsignedChannelUpdate_set_channel_flags(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint8_t val); /** * The number of blocks such that if: @@ -43056,7 +45475,7 @@ void UnsignedChannelUpdate_set_excess_data(struct LDKUnsignedChannelUpdate *NONN /** * Constructs a new UnsignedChannelUpdate given each field */ -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); +MUST_USE_RES struct LDKUnsignedChannelUpdate UnsignedChannelUpdate_new(struct LDKThirtyTwoBytes chain_hash_arg, uint64_t short_channel_id_arg, uint32_t timestamp_arg, uint8_t message_flags_arg, uint8_t channel_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 UnsignedChannelUpdate @@ -43821,14 +46240,14 @@ struct LDKCVec_u8Z Stfu_write(const struct LDKStfu *NONNULL_PTR obj); struct LDKCResult_StfuDecodeErrorZ Stfu_read(struct LDKu8slice ser); /** - * Serialize the Splice object into a byte array which can be read by Splice_read + * Serialize the SpliceInit object into a byte array which can be read by SpliceInit_read */ -struct LDKCVec_u8Z Splice_write(const struct LDKSplice *NONNULL_PTR obj); +struct LDKCVec_u8Z SpliceInit_write(const struct LDKSpliceInit *NONNULL_PTR obj); /** - * Read a Splice from a byte array, created by Splice_write + * Read a SpliceInit from a byte array, created by SpliceInit_write */ -struct LDKCResult_SpliceDecodeErrorZ Splice_read(struct LDKu8slice ser); +struct LDKCResult_SpliceInitDecodeErrorZ SpliceInit_read(struct LDKu8slice ser); /** * Serialize the SpliceAck object into a byte array which can be read by SpliceAck_read @@ -43980,6 +46399,16 @@ struct LDKCVec_u8Z ClosingSignedFeeRange_write(const struct LDKClosingSignedFeeR */ struct LDKCResult_ClosingSignedFeeRangeDecodeErrorZ ClosingSignedFeeRange_read(struct LDKu8slice ser); +/** + * Serialize the CommitmentSignedBatch object into a byte array which can be read by CommitmentSignedBatch_read + */ +struct LDKCVec_u8Z CommitmentSignedBatch_write(const struct LDKCommitmentSignedBatch *NONNULL_PTR obj); + +/** + * Read a CommitmentSignedBatch from a byte array, created by CommitmentSignedBatch_write + */ +struct LDKCResult_CommitmentSignedBatchDecodeErrorZ CommitmentSignedBatch_read(struct LDKu8slice ser); + /** * Serialize the CommitmentSigned object into a byte array which can be read by CommitmentSigned_read */ @@ -44322,12 +46751,6 @@ void IgnoringMessageHandler_free(struct LDKIgnoringMessageHandler this_obj); */ MUST_USE_RES struct LDKIgnoringMessageHandler IgnoringMessageHandler_new(void); -/** - * 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 LDKEventsProvider IgnoringMessageHandler_as_EventsProvider(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); - /** * 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 @@ -44352,6 +46775,12 @@ struct LDKOnionMessageHandler IgnoringMessageHandler_as_OnionMessageHandler(cons */ struct LDKOffersMessageHandler IgnoringMessageHandler_as_OffersMessageHandler(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); +/** + * Constructs a new AsyncPaymentsMessageHandler which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned AsyncPaymentsMessageHandler must be freed before this_arg is + */ +struct LDKAsyncPaymentsMessageHandler IgnoringMessageHandler_as_AsyncPaymentsMessageHandler(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); + /** * 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 @@ -44971,7 +47400,7 @@ struct LDKPublicKey ChannelPublicKeys_get_funding_pubkey(const struct LDKChannel 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 + * The base point which is used (with [`RevocationKey::from_basepoint`]) 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. @@ -44979,7 +47408,7 @@ void ChannelPublicKeys_set_funding_pubkey(struct LDKChannelPublicKeys *NONNULL_P struct LDKRevocationBasepoint ChannelPublicKeys_get_revocation_basepoint(const struct LDKChannelPublicKeys *NONNULL_PTR this_ptr); /** - * The base point which is used (with derive_public_revocation_key) to derive per-commitment + * The base point which is used (with [`RevocationKey::from_basepoint`]) 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. @@ -45167,6 +47596,13 @@ struct LDKHTLCOutputInCommitment HTLCOutputInCommitment_clone(const struct LDKHT */ bool HTLCOutputInCommitment_eq(const struct LDKHTLCOutputInCommitment *NONNULL_PTR a, const struct LDKHTLCOutputInCommitment *NONNULL_PTR b); +/** + * Converts HTLC's value with millisatoshi precision into [bitcoin::Amount] with satoshi precision. + * Typically this conversion is needed when transitioning from LN into base-layer Bitcoin, + * e. g. in commitment transactions. + */ +MUST_USE_RES uint64_t HTLCOutputInCommitment_to_bitcoin_amount(const struct LDKHTLCOutputInCommitment *NONNULL_PTR this_arg); + /** * Serialize the HTLCOutputInCommitment object into a byte array which can be read by HTLCOutputInCommitment_read */ @@ -45801,10674 +48237,11884 @@ MUST_USE_RES struct LDKCResult_TransactionNoneZ TrustedCommitmentTransaction_bui uint64_t get_commitment_transaction_number_obscure_factor(struct LDKPublicKey broadcaster_payment_basepoint, struct LDKPublicKey countersignatory_payment_basepoint, bool outbound_from_broadcaster); /** - * 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. + * Serialize the InitFeatures object into a byte array which can be read by InitFeatures_read */ -bool InitFeatures_eq(const struct LDKInitFeatures *NONNULL_PTR a, const struct LDKInitFeatures *NONNULL_PTR b); +struct LDKCVec_u8Z InitFeatures_write(const struct LDKInitFeatures *NONNULL_PTR obj); /** - * 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. + * Read a InitFeatures from a byte array, created by InitFeatures_write */ -bool NodeFeatures_eq(const struct LDKNodeFeatures *NONNULL_PTR a, const struct LDKNodeFeatures *NONNULL_PTR b); +struct LDKCResult_InitFeaturesDecodeErrorZ InitFeatures_read(struct LDKu8slice ser); /** - * 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. + * Serialize the ChannelFeatures object into a byte array which can be read by ChannelFeatures_read */ -bool ChannelFeatures_eq(const struct LDKChannelFeatures *NONNULL_PTR a, const struct LDKChannelFeatures *NONNULL_PTR b); +struct LDKCVec_u8Z ChannelFeatures_write(const struct LDKChannelFeatures *NONNULL_PTR obj); /** - * 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. + * Read a ChannelFeatures from a byte array, created by ChannelFeatures_write */ -bool Bolt11InvoiceFeatures_eq(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR a, const struct LDKBolt11InvoiceFeatures *NONNULL_PTR b); +struct LDKCResult_ChannelFeaturesDecodeErrorZ ChannelFeatures_read(struct LDKu8slice ser); /** - * 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. + * Serialize the NodeFeatures object into a byte array which can be read by NodeFeatures_read */ -bool OfferFeatures_eq(const struct LDKOfferFeatures *NONNULL_PTR a, const struct LDKOfferFeatures *NONNULL_PTR b); +struct LDKCVec_u8Z NodeFeatures_write(const struct LDKNodeFeatures *NONNULL_PTR obj); /** - * 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. + * Read a NodeFeatures from a byte array, created by NodeFeatures_write */ -bool InvoiceRequestFeatures_eq(const struct LDKInvoiceRequestFeatures *NONNULL_PTR a, const struct LDKInvoiceRequestFeatures *NONNULL_PTR b); +struct LDKCResult_NodeFeaturesDecodeErrorZ NodeFeatures_read(struct LDKu8slice ser); /** - * 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. + * Serialize the Bolt11InvoiceFeatures object into a byte array which can be read by Bolt11InvoiceFeatures_read */ -bool Bolt12InvoiceFeatures_eq(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR a, const struct LDKBolt12InvoiceFeatures *NONNULL_PTR b); +struct LDKCVec_u8Z Bolt11InvoiceFeatures_write(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR obj); /** - * 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. + * Read a Bolt11InvoiceFeatures from a byte array, created by Bolt11InvoiceFeatures_write */ -bool BlindedHopFeatures_eq(const struct LDKBlindedHopFeatures *NONNULL_PTR a, const struct LDKBlindedHopFeatures *NONNULL_PTR b); +struct LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ Bolt11InvoiceFeatures_read(struct LDKu8slice ser); /** - * 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. + * Serialize the Bolt12InvoiceFeatures object into a byte array which can be read by Bolt12InvoiceFeatures_read */ -bool ChannelTypeFeatures_eq(const struct LDKChannelTypeFeatures *NONNULL_PTR a, const struct LDKChannelTypeFeatures *NONNULL_PTR b); +struct LDKCVec_u8Z Bolt12InvoiceFeatures_write(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR obj); /** - * Creates a copy of the InitFeatures + * Read a Bolt12InvoiceFeatures from a byte array, created by Bolt12InvoiceFeatures_write */ -struct LDKInitFeatures InitFeatures_clone(const struct LDKInitFeatures *NONNULL_PTR orig); +struct LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ Bolt12InvoiceFeatures_read(struct LDKu8slice ser); /** - * Creates a copy of the NodeFeatures + * Serialize the BlindedHopFeatures object into a byte array which can be read by BlindedHopFeatures_read */ -struct LDKNodeFeatures NodeFeatures_clone(const struct LDKNodeFeatures *NONNULL_PTR orig); +struct LDKCVec_u8Z BlindedHopFeatures_write(const struct LDKBlindedHopFeatures *NONNULL_PTR obj); /** - * Creates a copy of the ChannelFeatures + * Read a BlindedHopFeatures from a byte array, created by BlindedHopFeatures_write */ -struct LDKChannelFeatures ChannelFeatures_clone(const struct LDKChannelFeatures *NONNULL_PTR orig); +struct LDKCResult_BlindedHopFeaturesDecodeErrorZ BlindedHopFeatures_read(struct LDKu8slice ser); /** - * Creates a copy of the Bolt11InvoiceFeatures + * Serialize the ChannelTypeFeatures object into a byte array which can be read by ChannelTypeFeatures_read */ -struct LDKBolt11InvoiceFeatures Bolt11InvoiceFeatures_clone(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR orig); +struct LDKCVec_u8Z ChannelTypeFeatures_write(const struct LDKChannelTypeFeatures *NONNULL_PTR obj); /** - * Creates a copy of the OfferFeatures + * Read a ChannelTypeFeatures from a byte array, created by ChannelTypeFeatures_write */ -struct LDKOfferFeatures OfferFeatures_clone(const struct LDKOfferFeatures *NONNULL_PTR orig); +struct LDKCResult_ChannelTypeFeaturesDecodeErrorZ ChannelTypeFeatures_read(struct LDKu8slice ser); /** - * Creates a copy of the InvoiceRequestFeatures + * Frees any resources used by the ShutdownScript, if is_owned is set and inner is non-NULL. */ -struct LDKInvoiceRequestFeatures InvoiceRequestFeatures_clone(const struct LDKInvoiceRequestFeatures *NONNULL_PTR orig); +void ShutdownScript_free(struct LDKShutdownScript this_obj); /** - * Creates a copy of the Bolt12InvoiceFeatures + * Creates a copy of the ShutdownScript */ -struct LDKBolt12InvoiceFeatures Bolt12InvoiceFeatures_clone(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR orig); +struct LDKShutdownScript ShutdownScript_clone(const struct LDKShutdownScript *NONNULL_PTR orig); /** - * Creates a copy of the BlindedHopFeatures + * 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. */ -struct LDKBlindedHopFeatures BlindedHopFeatures_clone(const struct LDKBlindedHopFeatures *NONNULL_PTR orig); +bool ShutdownScript_eq(const struct LDKShutdownScript *NONNULL_PTR a, const struct LDKShutdownScript *NONNULL_PTR b); /** - * Creates a copy of the ChannelTypeFeatures + * Frees any resources used by the InvalidShutdownScript, if is_owned is set and inner is non-NULL. */ -struct LDKChannelTypeFeatures ChannelTypeFeatures_clone(const struct LDKChannelTypeFeatures *NONNULL_PTR orig); +void InvalidShutdownScript_free(struct LDKInvalidShutdownScript this_obj); /** - * Generates a non-cryptographic 64-bit hash of the InitFeatures. + * The script that did not meet the requirements from [BOLT #2]. + * + * [BOLT #2]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md */ -uint64_t InitFeatures_hash(const struct LDKInitFeatures *NONNULL_PTR o); +struct LDKCVec_u8Z InvalidShutdownScript_get_script(const struct LDKInvalidShutdownScript *NONNULL_PTR this_ptr); /** - * Generates a non-cryptographic 64-bit hash of the NodeFeatures. + * The script that did not meet the requirements from [BOLT #2]. + * + * [BOLT #2]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md */ -uint64_t NodeFeatures_hash(const struct LDKNodeFeatures *NONNULL_PTR o); +void InvalidShutdownScript_set_script(struct LDKInvalidShutdownScript *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); /** - * Generates a non-cryptographic 64-bit hash of the ChannelFeatures. + * Constructs a new InvalidShutdownScript given each field */ -uint64_t ChannelFeatures_hash(const struct LDKChannelFeatures *NONNULL_PTR o); +MUST_USE_RES struct LDKInvalidShutdownScript InvalidShutdownScript_new(struct LDKCVec_u8Z script_arg); /** - * Generates a non-cryptographic 64-bit hash of the Bolt11InvoiceFeatures. + * Creates a copy of the InvalidShutdownScript */ -uint64_t Bolt11InvoiceFeatures_hash(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR o); +struct LDKInvalidShutdownScript InvalidShutdownScript_clone(const struct LDKInvalidShutdownScript *NONNULL_PTR orig); /** - * Generates a non-cryptographic 64-bit hash of the OfferFeatures. + * Serialize the ShutdownScript object into a byte array which can be read by ShutdownScript_read */ -uint64_t OfferFeatures_hash(const struct LDKOfferFeatures *NONNULL_PTR o); +struct LDKCVec_u8Z ShutdownScript_write(const struct LDKShutdownScript *NONNULL_PTR obj); /** - * Generates a non-cryptographic 64-bit hash of the InvoiceRequestFeatures. + * Read a ShutdownScript from a byte array, created by ShutdownScript_write */ -uint64_t InvoiceRequestFeatures_hash(const struct LDKInvoiceRequestFeatures *NONNULL_PTR o); +struct LDKCResult_ShutdownScriptDecodeErrorZ ShutdownScript_read(struct LDKu8slice ser); /** - * Generates a non-cryptographic 64-bit hash of the Bolt12InvoiceFeatures. + * Generates a P2WPKH script pubkey from the given [`WPubkeyHash`]. */ -uint64_t Bolt12InvoiceFeatures_hash(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR o); +MUST_USE_RES struct LDKShutdownScript ShutdownScript_new_p2wpkh(const uint8_t (*pubkey_hash)[20]); /** - * Generates a non-cryptographic 64-bit hash of the BlindedHopFeatures. + * Generates a P2WSH script pubkey from the given [`WScriptHash`]. */ -uint64_t BlindedHopFeatures_hash(const struct LDKBlindedHopFeatures *NONNULL_PTR o); +MUST_USE_RES struct LDKShutdownScript ShutdownScript_new_p2wsh(const uint8_t (*script_hash)[32]); /** - * Generates a non-cryptographic 64-bit hash of the ChannelTypeFeatures. + * 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`. */ -uint64_t ChannelTypeFeatures_hash(const struct LDKChannelTypeFeatures *NONNULL_PTR o); +MUST_USE_RES struct LDKCResult_ShutdownScriptInvalidShutdownScriptZ ShutdownScript_new_witness_program(struct LDKWitnessProgram witness_program); /** - * Frees any resources used by the InitFeatures, if is_owned is set and inner is non-NULL. + * Converts the shutdown script into the underlying [`ScriptBuf`]. */ -void InitFeatures_free(struct LDKInitFeatures this_obj); +MUST_USE_RES struct LDKCVec_u8Z ShutdownScript_into_inner(struct LDKShutdownScript this_arg); /** - * Frees any resources used by the NodeFeatures, if is_owned is set and inner is non-NULL. + * 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 */ -void NodeFeatures_free(struct LDKNodeFeatures this_obj); +MUST_USE_RES struct LDKPublicKey ShutdownScript_as_legacy_pubkey(const struct LDKShutdownScript *NONNULL_PTR this_arg); /** - * Frees any resources used by the ChannelFeatures, if is_owned is set and inner is non-NULL. + * Returns whether the shutdown script is compatible with the features as defined by BOLT #2. + * + * Specifically, checks for compliance with feature `option_shutdown_anysegwit`. */ -void ChannelFeatures_free(struct LDKChannelFeatures this_obj); +MUST_USE_RES bool ShutdownScript_is_compatible(const struct LDKShutdownScript *NONNULL_PTR this_arg, const struct LDKInitFeatures *NONNULL_PTR features); /** - * Frees any resources used by the Bolt11InvoiceFeatures, if is_owned is set and inner is non-NULL. + * Get the string representation of a ShutdownScript object */ -void Bolt11InvoiceFeatures_free(struct LDKBolt11InvoiceFeatures this_obj); +struct LDKStr ShutdownScript_to_str(const struct LDKShutdownScript *NONNULL_PTR o); /** - * Frees any resources used by the OfferFeatures, if is_owned is set and inner is non-NULL. + * Frees any resources used by the ChannelId, if is_owned is set and inner is non-NULL. */ -void OfferFeatures_free(struct LDKOfferFeatures this_obj); +void ChannelId_free(struct LDKChannelId this_obj); -/** - * Frees any resources used by the InvoiceRequestFeatures, if is_owned is set and inner is non-NULL. - */ -void InvoiceRequestFeatures_free(struct LDKInvoiceRequestFeatures this_obj); +const uint8_t (*ChannelId_get_a(const struct LDKChannelId *NONNULL_PTR this_ptr))[32]; + +void ChannelId_set_a(struct LDKChannelId *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Frees any resources used by the Bolt12InvoiceFeatures, if is_owned is set and inner is non-NULL. + * Constructs a new ChannelId given each field */ -void Bolt12InvoiceFeatures_free(struct LDKBolt12InvoiceFeatures this_obj); +MUST_USE_RES struct LDKChannelId ChannelId_new(struct LDKThirtyTwoBytes a_arg); /** - * Frees any resources used by the BlindedHopFeatures, if is_owned is set and inner is non-NULL. + * Creates a copy of the ChannelId */ -void BlindedHopFeatures_free(struct LDKBlindedHopFeatures this_obj); +struct LDKChannelId ChannelId_clone(const struct LDKChannelId *NONNULL_PTR orig); /** - * Frees any resources used by the ChannelTypeFeatures, if is_owned is set and inner is non-NULL. + * Checks if two ChannelIds 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 ChannelTypeFeatures_free(struct LDKChannelTypeFeatures this_obj); +bool ChannelId_eq(const struct LDKChannelId *NONNULL_PTR a, const struct LDKChannelId *NONNULL_PTR b); /** - * Create a blank Features with no features set + * Generates a non-cryptographic 64-bit hash of the ChannelId. */ -MUST_USE_RES struct LDKInitFeatures InitFeatures_empty(void); +uint64_t ChannelId_hash(const struct LDKChannelId *NONNULL_PTR o); /** - * Returns true if this `Features` object contains required features unknown by `other`. + * Create _v1_ channel ID based on a funding TX ID and output index */ -MUST_USE_RES bool InitFeatures_requires_unknown_bits_from(const struct LDKInitFeatures *NONNULL_PTR this_arg, const struct LDKInitFeatures *NONNULL_PTR other); +MUST_USE_RES struct LDKChannelId ChannelId_v1_from_funding_txid(const uint8_t (*txid)[32], uint16_t output_index); /** - * Returns true if this `Features` object contains unknown feature flags which are set as - * \"required\". + * Create _v1_ channel ID from a funding tx outpoint */ -MUST_USE_RES bool InitFeatures_requires_unknown_bits(const struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKChannelId ChannelId_v1_from_funding_outpoint(struct LDKOutPoint outpoint); /** - * Sets a required feature bit. Errors if `bit` is outside the feature range as defined - * by [BOLT 9]. - * - * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will - * be set instead (i.e., `bit - 1`). - * - * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md + * Create a _temporary_ channel ID randomly, based on an entropy source. */ -MUST_USE_RES struct LDKCResult_NoneNoneZ InitFeatures_set_required_feature_bit(struct LDKInitFeatures *NONNULL_PTR this_arg, uintptr_t bit); +MUST_USE_RES struct LDKChannelId ChannelId_temporary_from_entropy_source(const struct LDKEntropySource *NONNULL_PTR entropy_source); /** - * Sets an optional feature bit. Errors if `bit` is outside the feature range as defined - * by [BOLT 9]. - * - * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be - * set instead (i.e., `bit + 1`). - * - * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md + * Generic constructor; create a new channel ID from the provided data. + * Use a more specific `*_from_*` constructor when possible. */ -MUST_USE_RES struct LDKCResult_NoneNoneZ InitFeatures_set_optional_feature_bit(struct LDKInitFeatures *NONNULL_PTR this_arg, uintptr_t bit); +MUST_USE_RES struct LDKChannelId ChannelId_from_bytes(struct LDKThirtyTwoBytes data); /** - * 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 + * Create a channel ID consisting of all-zeros data (e.g. when uninitialized or a placeholder). */ -MUST_USE_RES struct LDKCResult_NoneNoneZ InitFeatures_set_required_custom_bit(struct LDKInitFeatures *NONNULL_PTR this_arg, uintptr_t bit); +MUST_USE_RES struct LDKChannelId ChannelId_new_zero(void); /** - * 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 + * Check whether ID is consisting of all zeros (uninitialized) */ -MUST_USE_RES struct LDKCResult_NoneNoneZ InitFeatures_set_optional_custom_bit(struct LDKInitFeatures *NONNULL_PTR this_arg, uintptr_t bit); +MUST_USE_RES bool ChannelId_is_zero(const struct LDKChannelId *NONNULL_PTR this_arg); /** - * Create a blank Features with no features set + * Create _v2_ channel ID by concatenating the holder revocation basepoint with the counterparty + * revocation basepoint and hashing the result. The basepoints will be concatenated in increasing + * sorted order. */ -MUST_USE_RES struct LDKNodeFeatures NodeFeatures_empty(void); +MUST_USE_RES struct LDKChannelId ChannelId_v2_from_revocation_basepoints(const struct LDKRevocationBasepoint *NONNULL_PTR ours, const struct LDKRevocationBasepoint *NONNULL_PTR theirs); /** - * Returns true if this `Features` object contains required features unknown by `other`. + * Create temporary _v2_ channel ID by concatenating a zeroed out basepoint with the holder + * revocation basepoint and hashing the result. */ -MUST_USE_RES bool NodeFeatures_requires_unknown_bits_from(const struct LDKNodeFeatures *NONNULL_PTR this_arg, const struct LDKNodeFeatures *NONNULL_PTR other); +MUST_USE_RES struct LDKChannelId ChannelId_temporary_v2_from_revocation_basepoint(const struct LDKRevocationBasepoint *NONNULL_PTR our_revocation_basepoint); /** - * Returns true if this `Features` object contains unknown feature flags which are set as - * \"required\". + * Serialize the ChannelId object into a byte array which can be read by ChannelId_read */ -MUST_USE_RES bool NodeFeatures_requires_unknown_bits(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKCVec_u8Z ChannelId_write(const struct LDKChannelId *NONNULL_PTR obj); /** - * Sets a required feature bit. Errors if `bit` is outside the feature range as defined - * by [BOLT 9]. - * - * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will - * be set instead (i.e., `bit - 1`). - * - * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md + * Read a ChannelId from a byte array, created by ChannelId_write */ -MUST_USE_RES struct LDKCResult_NoneNoneZ NodeFeatures_set_required_feature_bit(struct LDKNodeFeatures *NONNULL_PTR this_arg, uintptr_t bit); +struct LDKCResult_ChannelIdDecodeErrorZ ChannelId_read(struct LDKu8slice ser); /** - * Sets an optional feature bit. Errors if `bit` is outside the feature range as defined - * by [BOLT 9]. - * - * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be - * set instead (i.e., `bit + 1`). - * - * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md + * Get the string representation of a ChannelId object */ -MUST_USE_RES struct LDKCResult_NoneNoneZ NodeFeatures_set_optional_feature_bit(struct LDKNodeFeatures *NONNULL_PTR this_arg, uintptr_t bit); +struct LDKStr ChannelId_to_str(const struct LDKChannelId *NONNULL_PTR o); /** - * 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. + * 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. * - * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will - * be set instead (i.e., `bit - 1`). + * `phantom_route_hints` parameter: + * * Contains channel info for all nodes participating in the phantom invoice + * * Entries are retrieved from a call to [`ChannelManager::get_phantom_route_hints`] on each + * 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 * - * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits - */ -MUST_USE_RES struct LDKCResult_NoneNoneZ NodeFeatures_set_required_custom_bit(struct LDKNodeFeatures *NONNULL_PTR this_arg, uintptr_t bit); - -/** - * 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. + * `payment_hash` can be specified if you have a specific need for a custom payment hash (see the difference + * between [`ChannelManager::create_inbound_payment`] and [`ChannelManager::create_inbound_payment_for_hash`]). + * If `None` is provided for `payment_hash`, then one will be created. * - * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be - * set instead (i.e., `bit + 1`). + * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for + * in excess of the current time. * - * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits - */ -MUST_USE_RES struct LDKCResult_NoneNoneZ NodeFeatures_set_optional_custom_bit(struct LDKNodeFeatures *NONNULL_PTR this_arg, uintptr_t bit); - -/** - * Create a blank Features with no features set - */ -MUST_USE_RES struct LDKChannelFeatures ChannelFeatures_empty(void); - -/** - * Returns true if this `Features` object contains required features unknown by `other`. - */ -MUST_USE_RES bool ChannelFeatures_requires_unknown_bits_from(const struct LDKChannelFeatures *NONNULL_PTR this_arg, const struct LDKChannelFeatures *NONNULL_PTR other); - -/** - * Returns true if this `Features` object contains unknown feature flags which are set as - * \"required\". - */ -MUST_USE_RES bool ChannelFeatures_requires_unknown_bits(const struct LDKChannelFeatures *NONNULL_PTR this_arg); - -/** - * Sets a required feature bit. Errors if `bit` is outside the feature range as defined - * by [BOLT 9]. + * `duration_since_epoch` is the current time since epoch in seconds. * - * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will - * be set instead (i.e., `bit - 1`). + * You can specify a custom `min_final_cltv_expiry_delta`, or let LDK default it to + * [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. The provided expiry must be at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`] - 3. + * Note that LDK will add a buffer of 3 blocks to the delta to allow for up to a few new block + * confirmations during routing. * - * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md + * Note that the provided `keys_manager`'s `NodeSigner` implementation must support phantom + * invoices in its `sign_invoice` implementation ([`PhantomKeysManager`] satisfies this + * requirement). + * + * [`PhantomKeysManager`]: crate::sign::PhantomKeysManager + * [`ChannelManager::get_phantom_route_hints`]: crate::ln::channelmanager::ChannelManager::get_phantom_route_hints + * [`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 + * [`PhantomRouteHints::channels`]: crate::ln::channelmanager::PhantomRouteHints::channels + * [`MIN_FINAL_CLTV_EXPIRY_DETLA`]: crate::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA + * + * 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. */ -MUST_USE_RES struct LDKCResult_NoneNoneZ ChannelFeatures_set_required_feature_bit(struct LDKChannelFeatures *NONNULL_PTR this_arg, uintptr_t bit); +struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ create_phantom_invoice(struct LDKCOption_u64Z amt_msat, struct LDKCOption_ThirtyTwoBytesZ 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); /** - * Sets an optional feature bit. Errors if `bit` is outside the feature range as defined - * by [BOLT 9]. + * 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. * - * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be - * set instead (i.e., `bit + 1`). + * `phantom_route_hints` parameter: + * * Contains channel info for all nodes participating in the phantom invoice + * * Entries are retrieved from a call to [`ChannelManager::get_phantom_route_hints`] on each + * 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 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. * - * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md + * `description_hash` is a SHA-256 hash of the description text + * + * `payment_hash` can be specified if you have a specific need for a custom payment hash (see the difference + * between [`ChannelManager::create_inbound_payment`] and [`ChannelManager::create_inbound_payment_for_hash`]). + * If `None` is provided for `payment_hash`, then one will be created. + * + * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for + * in excess of the current time. + * + * `duration_since_epoch` is the current time since epoch in seconds. + * + * Note that the provided `keys_manager`'s `NodeSigner` implementation must support phantom + * invoices in its `sign_invoice` implementation ([`PhantomKeysManager`] satisfies this + * requirement). + * + * [`PhantomKeysManager`]: crate::sign::PhantomKeysManager + * [`ChannelManager::get_phantom_route_hints`]: crate::ln::channelmanager::ChannelManager::get_phantom_route_hints + * [`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 + * [`PhantomRouteHints::channels`]: crate::ln::channelmanager::PhantomRouteHints::channels + * + * 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. */ -MUST_USE_RES struct LDKCResult_NoneNoneZ ChannelFeatures_set_optional_feature_bit(struct LDKChannelFeatures *NONNULL_PTR this_arg, uintptr_t bit); +struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ create_phantom_invoice_with_description_hash(struct LDKCOption_u64Z amt_msat, struct LDKCOption_ThirtyTwoBytesZ 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); /** - * 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. + * Utility to construct an invoice. Generally, unless you want to do something like a custom + * cltv_expiry, this is what you should be using to create an invoice. The reason being, this + * method stores the invoice's payment secret and preimage in `ChannelManager`, so (a) the user + * doesn't have to store preimage/payment secret information and (b) `ChannelManager` can verify + * that the payment secret is valid when the invoice is paid. * - * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will - * be set instead (i.e., `bit - 1`). + * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for + * in excess of the current time. * - * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits + * You can specify a custom `min_final_cltv_expiry_delta`, or let LDK default it to + * [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. The provided expiry must be at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. + * Note that LDK will add a buffer of 3 blocks to the delta to allow for up to a few new block + * confirmations during routing. + * + * [`MIN_FINAL_CLTV_EXPIRY_DETLA`]: crate::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA */ -MUST_USE_RES struct LDKCResult_NoneNoneZ ChannelFeatures_set_required_custom_bit(struct LDKChannelFeatures *NONNULL_PTR this_arg, uintptr_t bit); +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); /** - * 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. + * Utility to construct an invoice. Generally, unless you want to do something like a custom + * cltv_expiry, this is what you should be using to create an invoice. The reason being, this + * method stores the invoice's payment secret and preimage in `ChannelManager`, so (a) the user + * doesn't have to store preimage/payment secret information and (b) `ChannelManager` can verify + * that the payment secret is valid when the invoice is paid. + * Use this variant if you want to pass the `description_hash` to the invoice. * - * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be - * set instead (i.e., `bit + 1`). + * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for + * in excess of the current time. * - * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits + * You can specify a custom `min_final_cltv_expiry_delta`, or let LDK default it to + * [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. The provided expiry must be at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. + * Note that LDK will add a buffer of 3 blocks to the delta to allow for up to a few new block + * confirmations during routing. + * + * [`MIN_FINAL_CLTV_EXPIRY_DETLA`]: crate::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA */ -MUST_USE_RES struct LDKCResult_NoneNoneZ ChannelFeatures_set_optional_custom_bit(struct LDKChannelFeatures *NONNULL_PTR this_arg, uintptr_t bit); +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); /** - * Create a blank Features with no features set + * 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. */ -MUST_USE_RES struct LDKBolt11InvoiceFeatures Bolt11InvoiceFeatures_empty(void); +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); /** - * Returns true if this `Features` object contains required features unknown by `other`. + * 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. */ -MUST_USE_RES bool Bolt11InvoiceFeatures_requires_unknown_bits_from(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg, const struct LDKBolt11InvoiceFeatures *NONNULL_PTR other); +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); /** - * Returns true if this `Features` object contains unknown feature flags which are set as - * \"required\". + * See [`create_invoice_from_channelmanager_and_duration_since_epoch`] + * This version allows for providing a custom [`PaymentHash`] for the invoice. + * 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. */ -MUST_USE_RES bool Bolt11InvoiceFeatures_requires_unknown_bits(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); +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); /** - * Sets a required feature bit. Errors if `bit` is outside the feature range as defined - * by [BOLT 9]. + * Builds the necessary parameters to pay or pre-flight probe the given zero-amount + * [`Bolt11Invoice`] using [`ChannelManager::send_payment`] or + * [`ChannelManager::send_preflight_probes`]. * - * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will - * be set instead (i.e., `bit - 1`). + * Prior to paying, you must ensure that the [`Bolt11Invoice::payment_hash`] is unique and the + * same [`PaymentHash`] has never been paid before. * - * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md + * Will always succeed unless the invoice has an amount specified, in which case + * [`payment_parameters_from_invoice`] should be used. + * + * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment + * [`ChannelManager::send_preflight_probes`]: crate::ln::channelmanager::ChannelManager::send_preflight_probes */ -MUST_USE_RES struct LDKCResult_NoneNoneZ Bolt11InvoiceFeatures_set_required_feature_bit(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg, uintptr_t bit); +struct LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ payment_parameters_from_zero_amount_invoice(const struct LDKBolt11Invoice *NONNULL_PTR invoice, uint64_t amount_msat); /** - * Sets an optional feature bit. Errors if `bit` is outside the feature range as defined - * by [BOLT 9]. + * Builds the necessary parameters to pay or pre-flight probe the given [`Bolt11Invoice`] using + * [`ChannelManager::send_payment`] or [`ChannelManager::send_preflight_probes`]. * - * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be - * set instead (i.e., `bit + 1`). + * Prior to paying, you must ensure that the [`Bolt11Invoice::payment_hash`] is unique and the + * same [`PaymentHash`] has never been paid before. * - * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md + * Will always succeed unless the invoice has no amount specified, in which case + * [`payment_parameters_from_zero_amount_invoice`] should be used. + * + * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment + * [`ChannelManager::send_preflight_probes`]: crate::ln::channelmanager::ChannelManager::send_preflight_probes */ -MUST_USE_RES struct LDKCResult_NoneNoneZ Bolt11InvoiceFeatures_set_optional_feature_bit(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg, uintptr_t bit); +struct LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ payment_parameters_from_invoice(const struct LDKBolt11Invoice *NONNULL_PTR invoice); /** - * 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 + * Frees any resources used by the Retry */ -MUST_USE_RES struct LDKCResult_NoneNoneZ Bolt11InvoiceFeatures_set_required_custom_bit(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg, uintptr_t bit); +void Retry_free(struct LDKRetry this_ptr); /** - * 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 + * Creates a copy of the Retry */ -MUST_USE_RES struct LDKCResult_NoneNoneZ Bolt11InvoiceFeatures_set_optional_custom_bit(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg, uintptr_t bit); +struct LDKRetry Retry_clone(const struct LDKRetry *NONNULL_PTR orig); /** - * Create a blank Features with no features set + * Utility method to constructs a new Attempts-variant Retry */ -MUST_USE_RES struct LDKOfferFeatures OfferFeatures_empty(void); +struct LDKRetry Retry_attempts(uint32_t a); /** - * Returns true if this `Features` object contains required features unknown by `other`. + * Utility method to constructs a new Timeout-variant Retry */ -MUST_USE_RES bool OfferFeatures_requires_unknown_bits_from(const struct LDKOfferFeatures *NONNULL_PTR this_arg, const struct LDKOfferFeatures *NONNULL_PTR other); +struct LDKRetry Retry_timeout(uint64_t a); /** - * Returns true if this `Features` object contains unknown feature flags which are set as - * \"required\". + * Checks if two Retrys contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -MUST_USE_RES bool OfferFeatures_requires_unknown_bits(const struct LDKOfferFeatures *NONNULL_PTR this_arg); +bool Retry_eq(const struct LDKRetry *NONNULL_PTR a, const struct LDKRetry *NONNULL_PTR b); /** - * Sets a required feature bit. Errors if `bit` is outside the feature range as defined - * by [BOLT 9]. - * - * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will - * be set instead (i.e., `bit - 1`). - * - * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md + * Generates a non-cryptographic 64-bit hash of the Retry. */ -MUST_USE_RES struct LDKCResult_NoneNoneZ OfferFeatures_set_required_feature_bit(struct LDKOfferFeatures *NONNULL_PTR this_arg, uintptr_t bit); +uint64_t Retry_hash(const struct LDKRetry *NONNULL_PTR o); /** - * Sets an optional feature bit. Errors if `bit` is outside the feature range as defined - * by [BOLT 9]. - * - * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be - * set instead (i.e., `bit + 1`). - * - * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md + * Serialize the Retry object into a byte array which can be read by Retry_read */ -MUST_USE_RES struct LDKCResult_NoneNoneZ OfferFeatures_set_optional_feature_bit(struct LDKOfferFeatures *NONNULL_PTR this_arg, uintptr_t bit); +struct LDKCVec_u8Z Retry_write(const struct LDKRetry *NONNULL_PTR obj); /** - * 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 + * Read a Retry from a byte array, created by Retry_write */ -MUST_USE_RES struct LDKCResult_NoneNoneZ OfferFeatures_set_required_custom_bit(struct LDKOfferFeatures *NONNULL_PTR this_arg, uintptr_t bit); +struct LDKCResult_RetryDecodeErrorZ Retry_read(struct LDKu8slice ser); /** - * 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 + * Creates a copy of the RetryableSendFailure */ -MUST_USE_RES struct LDKCResult_NoneNoneZ OfferFeatures_set_optional_custom_bit(struct LDKOfferFeatures *NONNULL_PTR this_arg, uintptr_t bit); +enum LDKRetryableSendFailure RetryableSendFailure_clone(const enum LDKRetryableSendFailure *NONNULL_PTR orig); /** - * Create a blank Features with no features set + * Utility method to constructs a new PaymentExpired-variant RetryableSendFailure */ -MUST_USE_RES struct LDKInvoiceRequestFeatures InvoiceRequestFeatures_empty(void); +enum LDKRetryableSendFailure RetryableSendFailure_payment_expired(void); /** - * Returns true if this `Features` object contains required features unknown by `other`. + * Utility method to constructs a new RouteNotFound-variant RetryableSendFailure */ -MUST_USE_RES bool InvoiceRequestFeatures_requires_unknown_bits_from(const struct LDKInvoiceRequestFeatures *NONNULL_PTR this_arg, const struct LDKInvoiceRequestFeatures *NONNULL_PTR other); +enum LDKRetryableSendFailure RetryableSendFailure_route_not_found(void); /** - * Returns true if this `Features` object contains unknown feature flags which are set as - * \"required\". + * Utility method to constructs a new DuplicatePayment-variant RetryableSendFailure */ -MUST_USE_RES bool InvoiceRequestFeatures_requires_unknown_bits(const struct LDKInvoiceRequestFeatures *NONNULL_PTR this_arg); +enum LDKRetryableSendFailure RetryableSendFailure_duplicate_payment(void); /** - * Sets a required feature bit. Errors if `bit` is outside the feature range as defined - * by [BOLT 9]. - * - * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will - * be set instead (i.e., `bit - 1`). - * - * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md + * Utility method to constructs a new OnionPacketSizeExceeded-variant RetryableSendFailure */ -MUST_USE_RES struct LDKCResult_NoneNoneZ InvoiceRequestFeatures_set_required_feature_bit(struct LDKInvoiceRequestFeatures *NONNULL_PTR this_arg, uintptr_t bit); +enum LDKRetryableSendFailure RetryableSendFailure_onion_packet_size_exceeded(void); /** - * Sets an optional feature bit. Errors if `bit` is outside the feature range as defined - * by [BOLT 9]. - * - * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be - * set instead (i.e., `bit + 1`). - * - * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md + * 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 struct LDKCResult_NoneNoneZ InvoiceRequestFeatures_set_optional_feature_bit(struct LDKInvoiceRequestFeatures *NONNULL_PTR this_arg, uintptr_t bit); +bool RetryableSendFailure_eq(const enum LDKRetryableSendFailure *NONNULL_PTR a, const enum LDKRetryableSendFailure *NONNULL_PTR b); /** - * 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 + * Frees any resources used by the PaymentSendFailure */ -MUST_USE_RES struct LDKCResult_NoneNoneZ InvoiceRequestFeatures_set_required_custom_bit(struct LDKInvoiceRequestFeatures *NONNULL_PTR this_arg, uintptr_t bit); +void PaymentSendFailure_free(struct LDKPaymentSendFailure this_ptr); /** - * 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 + * Creates a copy of the PaymentSendFailure */ -MUST_USE_RES struct LDKCResult_NoneNoneZ InvoiceRequestFeatures_set_optional_custom_bit(struct LDKInvoiceRequestFeatures *NONNULL_PTR this_arg, uintptr_t bit); +struct LDKPaymentSendFailure PaymentSendFailure_clone(const struct LDKPaymentSendFailure *NONNULL_PTR orig); /** - * Create a blank Features with no features set + * Utility method to constructs a new ParameterError-variant PaymentSendFailure */ -MUST_USE_RES struct LDKBolt12InvoiceFeatures Bolt12InvoiceFeatures_empty(void); +struct LDKPaymentSendFailure PaymentSendFailure_parameter_error(struct LDKAPIError a); /** - * Returns true if this `Features` object contains required features unknown by `other`. + * Utility method to constructs a new PathParameterError-variant PaymentSendFailure */ -MUST_USE_RES bool Bolt12InvoiceFeatures_requires_unknown_bits_from(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg, const struct LDKBolt12InvoiceFeatures *NONNULL_PTR other); +struct LDKPaymentSendFailure PaymentSendFailure_path_parameter_error(struct LDKCVec_CResult_NoneAPIErrorZZ a); /** - * Returns true if this `Features` object contains unknown feature flags which are set as - * \"required\". + * Utility method to constructs a new AllFailedResendSafe-variant PaymentSendFailure */ -MUST_USE_RES bool Bolt12InvoiceFeatures_requires_unknown_bits(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg); +struct LDKPaymentSendFailure PaymentSendFailure_all_failed_resend_safe(struct LDKCVec_APIErrorZ a); /** - * Sets a required feature bit. Errors if `bit` is outside the feature range as defined - * by [BOLT 9]. - * - * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will - * be set instead (i.e., `bit - 1`). - * - * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md + * Utility method to constructs a new DuplicatePayment-variant PaymentSendFailure */ -MUST_USE_RES struct LDKCResult_NoneNoneZ Bolt12InvoiceFeatures_set_required_feature_bit(struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg, uintptr_t bit); +struct LDKPaymentSendFailure PaymentSendFailure_duplicate_payment(void); /** - * Sets an optional feature bit. Errors if `bit` is outside the feature range as defined - * by [BOLT 9]. - * - * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be - * set instead (i.e., `bit + 1`). - * - * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md + * Utility method to constructs a new PartialFailure-variant PaymentSendFailure */ -MUST_USE_RES struct LDKCResult_NoneNoneZ Bolt12InvoiceFeatures_set_optional_feature_bit(struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg, uintptr_t bit); +struct LDKPaymentSendFailure PaymentSendFailure_partial_failure(struct LDKCVec_CResult_NoneAPIErrorZZ results, struct LDKRouteParameters failed_paths_retry, struct LDKThirtyTwoBytes payment_id); /** - * 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 + * Checks if two PaymentSendFailures contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -MUST_USE_RES struct LDKCResult_NoneNoneZ Bolt12InvoiceFeatures_set_required_custom_bit(struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg, uintptr_t bit); +bool PaymentSendFailure_eq(const struct LDKPaymentSendFailure *NONNULL_PTR a, const struct LDKPaymentSendFailure *NONNULL_PTR b); /** - * 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 + * Frees any resources used by the Bolt12PaymentError */ -MUST_USE_RES struct LDKCResult_NoneNoneZ Bolt12InvoiceFeatures_set_optional_custom_bit(struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg, uintptr_t bit); +void Bolt12PaymentError_free(struct LDKBolt12PaymentError this_ptr); /** - * Create a blank Features with no features set + * Creates a copy of the Bolt12PaymentError */ -MUST_USE_RES struct LDKBlindedHopFeatures BlindedHopFeatures_empty(void); +struct LDKBolt12PaymentError Bolt12PaymentError_clone(const struct LDKBolt12PaymentError *NONNULL_PTR orig); /** - * Returns true if this `Features` object contains required features unknown by `other`. + * Utility method to constructs a new UnexpectedInvoice-variant Bolt12PaymentError */ -MUST_USE_RES bool BlindedHopFeatures_requires_unknown_bits_from(const struct LDKBlindedHopFeatures *NONNULL_PTR this_arg, const struct LDKBlindedHopFeatures *NONNULL_PTR other); +struct LDKBolt12PaymentError Bolt12PaymentError_unexpected_invoice(void); /** - * Returns true if this `Features` object contains unknown feature flags which are set as - * \"required\". + * Utility method to constructs a new DuplicateInvoice-variant Bolt12PaymentError */ -MUST_USE_RES bool BlindedHopFeatures_requires_unknown_bits(const struct LDKBlindedHopFeatures *NONNULL_PTR this_arg); +struct LDKBolt12PaymentError Bolt12PaymentError_duplicate_invoice(void); /** - * Sets a required feature bit. Errors if `bit` is outside the feature range as defined - * by [BOLT 9]. - * - * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will - * be set instead (i.e., `bit - 1`). - * - * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md + * Utility method to constructs a new UnknownRequiredFeatures-variant Bolt12PaymentError */ -MUST_USE_RES struct LDKCResult_NoneNoneZ BlindedHopFeatures_set_required_feature_bit(struct LDKBlindedHopFeatures *NONNULL_PTR this_arg, uintptr_t bit); +struct LDKBolt12PaymentError Bolt12PaymentError_unknown_required_features(void); /** - * Sets an optional feature bit. Errors if `bit` is outside the feature range as defined - * by [BOLT 9]. - * - * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be - * set instead (i.e., `bit + 1`). - * - * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md + * Utility method to constructs a new SendingFailed-variant Bolt12PaymentError */ -MUST_USE_RES struct LDKCResult_NoneNoneZ BlindedHopFeatures_set_optional_feature_bit(struct LDKBlindedHopFeatures *NONNULL_PTR this_arg, uintptr_t bit); +struct LDKBolt12PaymentError Bolt12PaymentError_sending_failed(enum LDKRetryableSendFailure a); /** - * 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 + * Checks if two Bolt12PaymentErrors contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -MUST_USE_RES struct LDKCResult_NoneNoneZ BlindedHopFeatures_set_required_custom_bit(struct LDKBlindedHopFeatures *NONNULL_PTR this_arg, uintptr_t bit); +bool Bolt12PaymentError_eq(const struct LDKBolt12PaymentError *NONNULL_PTR a, const struct LDKBolt12PaymentError *NONNULL_PTR b); /** - * 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 + * Frees any resources used by the ProbeSendFailure */ -MUST_USE_RES struct LDKCResult_NoneNoneZ BlindedHopFeatures_set_optional_custom_bit(struct LDKBlindedHopFeatures *NONNULL_PTR this_arg, uintptr_t bit); +void ProbeSendFailure_free(struct LDKProbeSendFailure this_ptr); /** - * Create a blank Features with no features set + * Creates a copy of the ProbeSendFailure */ -MUST_USE_RES struct LDKChannelTypeFeatures ChannelTypeFeatures_empty(void); +struct LDKProbeSendFailure ProbeSendFailure_clone(const struct LDKProbeSendFailure *NONNULL_PTR orig); /** - * Returns true if this `Features` object contains required features unknown by `other`. + * Utility method to constructs a new RouteNotFound-variant ProbeSendFailure */ -MUST_USE_RES bool ChannelTypeFeatures_requires_unknown_bits_from(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg, const struct LDKChannelTypeFeatures *NONNULL_PTR other); +struct LDKProbeSendFailure ProbeSendFailure_route_not_found(void); /** - * Returns true if this `Features` object contains unknown feature flags which are set as - * \"required\". + * Utility method to constructs a new SendingFailed-variant ProbeSendFailure */ -MUST_USE_RES bool ChannelTypeFeatures_requires_unknown_bits(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +struct LDKProbeSendFailure ProbeSendFailure_sending_failed(struct LDKPaymentSendFailure a); /** - * Sets a required feature bit. Errors if `bit` is outside the feature range as defined - * by [BOLT 9]. + * Checks if two ProbeSendFailures contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + */ +bool ProbeSendFailure_eq(const struct LDKProbeSendFailure *NONNULL_PTR a, const struct LDKProbeSendFailure *NONNULL_PTR b); + +/** + * Frees any resources used by the RecipientOnionFields, if is_owned is set and inner is non-NULL. + */ +void RecipientOnionFields_free(struct LDKRecipientOnionFields 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. * - * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will - * be set instead (i.e., `bit - 1`). + * 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. * - * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md + * 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. */ -MUST_USE_RES struct LDKCResult_NoneNoneZ ChannelTypeFeatures_set_required_feature_bit(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg, uintptr_t bit); +struct LDKCOption_ThirtyTwoBytesZ RecipientOnionFields_get_payment_secret(const struct LDKRecipientOnionFields *NONNULL_PTR this_ptr); /** - * Sets an optional feature bit. Errors if `bit` is outside the feature range as defined - * by [BOLT 9]. + * 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. * - * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be - * set instead (i.e., `bit + 1`). + * 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. * - * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md + * 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. */ -MUST_USE_RES struct LDKCResult_NoneNoneZ ChannelTypeFeatures_set_optional_feature_bit(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg, uintptr_t bit); +void RecipientOnionFields_set_payment_secret(struct LDKRecipientOnionFields *NONNULL_PTR this_ptr, struct LDKCOption_ThirtyTwoBytesZ val); /** - * 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. + * 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. * - * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will - * be set instead (i.e., `bit - 1`). + * 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. * - * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits + * 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 struct LDKCResult_NoneNoneZ ChannelTypeFeatures_set_required_custom_bit(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg, uintptr_t bit); +struct LDKCOption_CVec_u8ZZ RecipientOnionFields_get_payment_metadata(const struct LDKRecipientOnionFields *NONNULL_PTR this_ptr); /** - * 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. + * 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. * - * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be - * set instead (i.e., `bit + 1`). + * 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. * - * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits + * 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 struct LDKCResult_NoneNoneZ ChannelTypeFeatures_set_optional_custom_bit(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg, uintptr_t bit); +void RecipientOnionFields_set_payment_metadata(struct LDKRecipientOnionFields *NONNULL_PTR this_ptr, struct LDKCOption_CVec_u8ZZ val); /** - * Serialize the InitFeatures object into a byte array which can be read by InitFeatures_read + * Creates a copy of the RecipientOnionFields */ -struct LDKCVec_u8Z InitFeatures_write(const struct LDKInitFeatures *NONNULL_PTR obj); +struct LDKRecipientOnionFields RecipientOnionFields_clone(const struct LDKRecipientOnionFields *NONNULL_PTR orig); /** - * Read a InitFeatures from a byte array, created by InitFeatures_write + * 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. */ -struct LDKCResult_InitFeaturesDecodeErrorZ InitFeatures_read(struct LDKu8slice ser); +bool RecipientOnionFields_eq(const struct LDKRecipientOnionFields *NONNULL_PTR a, const struct LDKRecipientOnionFields *NONNULL_PTR b); /** - * Serialize the ChannelFeatures object into a byte array which can be read by ChannelFeatures_read + * Serialize the RecipientOnionFields object into a byte array which can be read by RecipientOnionFields_read */ -struct LDKCVec_u8Z ChannelFeatures_write(const struct LDKChannelFeatures *NONNULL_PTR obj); +struct LDKCVec_u8Z RecipientOnionFields_write(const struct LDKRecipientOnionFields *NONNULL_PTR obj); /** - * Read a ChannelFeatures from a byte array, created by ChannelFeatures_write + * Read a RecipientOnionFields from a byte array, created by RecipientOnionFields_write */ -struct LDKCResult_ChannelFeaturesDecodeErrorZ ChannelFeatures_read(struct LDKu8slice ser); +struct LDKCResult_RecipientOnionFieldsDecodeErrorZ RecipientOnionFields_read(struct LDKu8slice ser); /** - * Serialize the NodeFeatures object into a byte array which can be read by NodeFeatures_read + * 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. */ -struct LDKCVec_u8Z NodeFeatures_write(const struct LDKNodeFeatures *NONNULL_PTR obj); +MUST_USE_RES struct LDKRecipientOnionFields RecipientOnionFields_secret_only(struct LDKThirtyTwoBytes payment_secret); /** - * Read a NodeFeatures from a byte array, created by NodeFeatures_write + * 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 */ -struct LDKCResult_NodeFeaturesDecodeErrorZ NodeFeatures_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKRecipientOnionFields RecipientOnionFields_spontaneous_empty(void); /** - * Serialize the Bolt11InvoiceFeatures object into a byte array which can be read by Bolt11InvoiceFeatures_read + * Creates a new [`RecipientOnionFields`] from an existing one, adding custom TLVs. Each + * TLV is provided as a `(u64, Vec)` for the type number and serialized value + * respectively. TLV type numbers must be unique and within the range + * reserved for custom types, i.e. >= 2^16, otherwise this method will return `Err(())`. + * + * This method will also error for types in the experimental range which have been + * standardized within the protocol, which only includes 5482373484 (keysend) for now. + * + * See [`Self::custom_tlvs`] for more info. */ -struct LDKCVec_u8Z Bolt11InvoiceFeatures_write(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR obj); +MUST_USE_RES struct LDKCResult_RecipientOnionFieldsNoneZ RecipientOnionFields_with_custom_tlvs(struct LDKRecipientOnionFields this_arg, struct LDKCVec_C2Tuple_u64CVec_u8ZZZ custom_tlvs); /** - * Read a Bolt11InvoiceFeatures from a byte array, created by Bolt11InvoiceFeatures_write + * Gets the custom TLVs that will be sent or have been received. + * + * Custom TLVs allow sending extra application-specific data with a payment. They provide + * additional flexibility on top of payment metadata, as while other implementations may + * require `payment_metadata` to reflect metadata provided in an invoice, custom TLVs + * do not have this restriction. + * + * Note that if this field is non-empty, it will contain strictly increasing TLVs, each + * represented by a `(u64, Vec)` for its type number and serialized value respectively. + * This is validated when setting this field using [`Self::with_custom_tlvs`]. */ -struct LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ Bolt11InvoiceFeatures_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKCVec_C2Tuple_u64CVec_u8ZZZ RecipientOnionFields_custom_tlvs(const struct LDKRecipientOnionFields *NONNULL_PTR this_arg); /** - * Serialize the Bolt12InvoiceFeatures object into a byte array which can be read by Bolt12InvoiceFeatures_read + * Calls the free function if one is set */ -struct LDKCVec_u8Z Bolt12InvoiceFeatures_write(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR obj); +void CustomMessageReader_free(struct LDKCustomMessageReader this_ptr); /** - * Read a Bolt12InvoiceFeatures from a byte array, created by Bolt12InvoiceFeatures_write + * Creates a copy of a Type */ -struct LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ Bolt12InvoiceFeatures_read(struct LDKu8slice ser); +struct LDKType Type_clone(const struct LDKType *NONNULL_PTR orig); /** - * Serialize the BlindedHopFeatures object into a byte array which can be read by BlindedHopFeatures_read + * Calls the free function if one is set */ -struct LDKCVec_u8Z BlindedHopFeatures_write(const struct LDKBlindedHopFeatures *NONNULL_PTR obj); +void Type_free(struct LDKType this_ptr); /** - * Read a BlindedHopFeatures from a byte array, created by BlindedHopFeatures_write + * Frees any resources used by the OfferId, if is_owned is set and inner is non-NULL. */ -struct LDKCResult_BlindedHopFeaturesDecodeErrorZ BlindedHopFeatures_read(struct LDKu8slice ser); +void OfferId_free(struct LDKOfferId this_obj); -/** - * Serialize the ChannelTypeFeatures object into a byte array which can be read by ChannelTypeFeatures_read - */ -struct LDKCVec_u8Z ChannelTypeFeatures_write(const struct LDKChannelTypeFeatures *NONNULL_PTR obj); +const uint8_t (*OfferId_get_a(const struct LDKOfferId *NONNULL_PTR this_ptr))[32]; + +void OfferId_set_a(struct LDKOfferId *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Read a ChannelTypeFeatures from a byte array, created by ChannelTypeFeatures_write + * Constructs a new OfferId given each field */ -struct LDKCResult_ChannelTypeFeaturesDecodeErrorZ ChannelTypeFeatures_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKOfferId OfferId_new(struct LDKThirtyTwoBytes a_arg); /** - * Set this feature as optional. + * Creates a copy of the OfferId */ -void InitFeatures_set_data_loss_protect_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKOfferId OfferId_clone(const struct LDKOfferId *NONNULL_PTR orig); /** - * Set this feature as required. + * Checks if two OfferIds 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_data_loss_protect_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +bool OfferId_eq(const struct LDKOfferId *NONNULL_PTR a, const struct LDKOfferId *NONNULL_PTR b); /** - * Checks if this feature is supported. + * Serialize the OfferId object into a byte array which can be read by OfferId_read */ -MUST_USE_RES bool InitFeatures_supports_data_loss_protect(const struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKCVec_u8Z OfferId_write(const struct LDKOfferId *NONNULL_PTR obj); /** - * Set this feature as optional. + * Read a OfferId from a byte array, created by OfferId_write */ -void NodeFeatures_set_data_loss_protect_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKCResult_OfferIdDecodeErrorZ OfferId_read(struct LDKu8slice ser); /** - * Set this feature as required. + * Frees any resources used by the OfferWithExplicitMetadataBuilder, if is_owned is set and inner is non-NULL. */ -void NodeFeatures_set_data_loss_protect_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +void OfferWithExplicitMetadataBuilder_free(struct LDKOfferWithExplicitMetadataBuilder this_obj); /** - * Checks if this feature is supported. + * Creates a copy of the OfferWithExplicitMetadataBuilder */ -MUST_USE_RES bool NodeFeatures_supports_data_loss_protect(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKOfferWithExplicitMetadataBuilder OfferWithExplicitMetadataBuilder_clone(const struct LDKOfferWithExplicitMetadataBuilder *NONNULL_PTR orig); /** - * Checks if this feature is required. + * Frees any resources used by the OfferWithDerivedMetadataBuilder, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES bool InitFeatures_requires_data_loss_protect(const struct LDKInitFeatures *NONNULL_PTR this_arg); +void OfferWithDerivedMetadataBuilder_free(struct LDKOfferWithDerivedMetadataBuilder this_obj); /** - * Checks if this feature is required. + * Creates a copy of the OfferWithDerivedMetadataBuilder */ -MUST_USE_RES bool NodeFeatures_requires_data_loss_protect(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKOfferWithDerivedMetadataBuilder OfferWithDerivedMetadataBuilder_clone(const struct LDKOfferWithDerivedMetadataBuilder *NONNULL_PTR orig); /** - * Set this feature as optional. + * Creates a new builder for an offer using the [`Offer::signing_pubkey`] for signing invoices. + * The associated secret key must be remembered while the offer is valid. + * + * Use a different pubkey per offer to avoid correlating offers. + * + * # Note + * + * If constructing an [`Offer`] for use with a [`ChannelManager`], use + * [`ChannelManager::create_offer_builder`] instead of [`OfferBuilder::new`]. + * + * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager + * [`ChannelManager::create_offer_builder`]: crate::ln::channelmanager::ChannelManager::create_offer_builder */ -void InitFeatures_set_initial_routing_sync_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKOfferWithExplicitMetadataBuilder OfferWithExplicitMetadataBuilder_new(struct LDKPublicKey signing_pubkey); /** - * Set this feature as required. + * Sets the [`Offer::metadata`] to the given bytes. + * + * Successive calls to this method will override the previous setting. */ -void InitFeatures_set_initial_routing_sync_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_NoneBolt12SemanticErrorZ OfferWithExplicitMetadataBuilder_metadata(struct LDKOfferWithExplicitMetadataBuilder this_arg, struct LDKCVec_u8Z metadata); /** - * Checks if this feature is supported. + * Adds the chain hash of the given [`Network`] to [`Offer::chains`]. If not called, + * the chain hash of [`Network::Bitcoin`] is assumed to be the only one supported. + * + * See [`Offer::chains`] on how this relates to the payment currency. + * + * Successive calls to this method will add another chain hash. */ -MUST_USE_RES bool InitFeatures_initial_routing_sync(const struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES void OfferWithExplicitMetadataBuilder_chain(struct LDKOfferWithExplicitMetadataBuilder this_arg, enum LDKNetwork network); /** - * Set this feature as optional. + * Sets the [`Offer::amount`] as an [`Amount::Bitcoin`]. + * + * Successive calls to this method will override the previous setting. */ -void InitFeatures_set_upfront_shutdown_script_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES void OfferWithExplicitMetadataBuilder_amount_msats(struct LDKOfferWithExplicitMetadataBuilder this_arg, uint64_t amount_msats); /** - * Set this feature as required. + * Sets the [`Offer::absolute_expiry`] as seconds since the Unix epoch. Any expiry that has + * already passed is valid and can be checked for using [`Offer::is_expired`]. + * + * Successive calls to this method will override the previous setting. */ -void InitFeatures_set_upfront_shutdown_script_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES void OfferWithExplicitMetadataBuilder_absolute_expiry(struct LDKOfferWithExplicitMetadataBuilder this_arg, uint64_t absolute_expiry); /** - * Checks if this feature is supported. + * Sets the [`Offer::description`]. + * + * Successive calls to this method will override the previous setting. */ -MUST_USE_RES bool InitFeatures_supports_upfront_shutdown_script(const struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES void OfferWithExplicitMetadataBuilder_description(struct LDKOfferWithExplicitMetadataBuilder this_arg, struct LDKStr description); /** - * Set this feature as optional. + * Sets the [`Offer::issuer`]. + * + * Successive calls to this method will override the previous setting. */ -void NodeFeatures_set_upfront_shutdown_script_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES void OfferWithExplicitMetadataBuilder_issuer(struct LDKOfferWithExplicitMetadataBuilder this_arg, struct LDKStr issuer); /** - * Set this feature as required. + * Adds a blinded path to [`Offer::paths`]. Must include at least one path if only connected by + * private channels or if [`Offer::signing_pubkey`] is not a public node id. + * + * Successive calls to this method will add another blinded path. Caller is responsible for not + * adding duplicate paths. */ -void NodeFeatures_set_upfront_shutdown_script_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES void OfferWithExplicitMetadataBuilder_path(struct LDKOfferWithExplicitMetadataBuilder this_arg, struct LDKBlindedMessagePath path); /** - * Checks if this feature is supported. + * Sets the quantity of items for [`Offer::supported_quantity`]. If not called, defaults to + * [`Quantity::One`]. + * + * Successive calls to this method will override the previous setting. */ -MUST_USE_RES bool NodeFeatures_supports_upfront_shutdown_script(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES void OfferWithExplicitMetadataBuilder_supported_quantity(struct LDKOfferWithExplicitMetadataBuilder this_arg, struct LDKQuantity quantity); /** - * Checks if this feature is required. + * Builds an [`Offer`] from the builder's settings. */ -MUST_USE_RES bool InitFeatures_requires_upfront_shutdown_script(const struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_OfferBolt12SemanticErrorZ OfferWithExplicitMetadataBuilder_build(struct LDKOfferWithExplicitMetadataBuilder this_arg); /** - * Checks if this feature is required. + * Similar to [`OfferBuilder::new`] except, if [`OfferBuilder::path`] is called, the signing + * pubkey is derived from the given [`ExpandedKey`] and [`Nonce`]. This provides recipient + * privacy by using a different signing pubkey for each offer. Otherwise, the provided + * `node_id` is used for the signing pubkey. + * + * Also, sets the metadata when [`OfferBuilder::build`] is called such that it can be used by + * [`InvoiceRequest::verify_using_metadata`] to determine if the request was produced for the + * offer given an [`ExpandedKey`]. However, if [`OfferBuilder::path`] is called, then the + * metadata will not be set and must be included in each [`BlindedMessagePath`] instead. In this case, + * use [`InvoiceRequest::verify_using_recipient_data`]. + * + * [`InvoiceRequest::verify_using_metadata`]: crate::offers::invoice_request::InvoiceRequest::verify_using_metadata + * [`InvoiceRequest::verify_using_recipient_data`]: crate::offers::invoice_request::InvoiceRequest::verify_using_recipient_data + * [`ExpandedKey`]: crate::ln::inbound_payment::ExpandedKey */ -MUST_USE_RES bool NodeFeatures_requires_upfront_shutdown_script(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKOfferWithDerivedMetadataBuilder OfferWithDerivedMetadataBuilder_deriving_signing_pubkey(struct LDKPublicKey node_id, const struct LDKExpandedKey *NONNULL_PTR expanded_key, struct LDKNonce nonce); /** - * Set this feature as optional. + * Adds the chain hash of the given [`Network`] to [`Offer::chains`]. If not called, + * the chain hash of [`Network::Bitcoin`] is assumed to be the only one supported. + * + * See [`Offer::chains`] on how this relates to the payment currency. + * + * Successive calls to this method will add another chain hash. */ -void InitFeatures_set_gossip_queries_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES void OfferWithDerivedMetadataBuilder_chain(struct LDKOfferWithDerivedMetadataBuilder this_arg, enum LDKNetwork network); /** - * Set this feature as required. + * Sets the [`Offer::amount`] as an [`Amount::Bitcoin`]. + * + * Successive calls to this method will override the previous setting. */ -void InitFeatures_set_gossip_queries_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES void OfferWithDerivedMetadataBuilder_amount_msats(struct LDKOfferWithDerivedMetadataBuilder this_arg, uint64_t amount_msats); /** - * Checks if this feature is supported. + * Sets the [`Offer::absolute_expiry`] as seconds since the Unix epoch. Any expiry that has + * already passed is valid and can be checked for using [`Offer::is_expired`]. + * + * Successive calls to this method will override the previous setting. */ -MUST_USE_RES bool InitFeatures_supports_gossip_queries(const struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES void OfferWithDerivedMetadataBuilder_absolute_expiry(struct LDKOfferWithDerivedMetadataBuilder this_arg, uint64_t absolute_expiry); /** - * Set this feature as optional. + * Sets the [`Offer::description`]. + * + * Successive calls to this method will override the previous setting. */ -void NodeFeatures_set_gossip_queries_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES void OfferWithDerivedMetadataBuilder_description(struct LDKOfferWithDerivedMetadataBuilder this_arg, struct LDKStr description); /** - * Set this feature as required. + * Sets the [`Offer::issuer`]. + * + * Successive calls to this method will override the previous setting. */ -void NodeFeatures_set_gossip_queries_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES void OfferWithDerivedMetadataBuilder_issuer(struct LDKOfferWithDerivedMetadataBuilder this_arg, struct LDKStr issuer); /** - * Checks if this feature is supported. + * Adds a blinded path to [`Offer::paths`]. Must include at least one path if only connected by + * private channels or if [`Offer::signing_pubkey`] is not a public node id. + * + * Successive calls to this method will add another blinded path. Caller is responsible for not + * adding duplicate paths. */ -MUST_USE_RES bool NodeFeatures_supports_gossip_queries(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES void OfferWithDerivedMetadataBuilder_path(struct LDKOfferWithDerivedMetadataBuilder this_arg, struct LDKBlindedMessagePath path); /** - * Checks if this feature is required. + * Sets the quantity of items for [`Offer::supported_quantity`]. If not called, defaults to + * [`Quantity::One`]. + * + * Successive calls to this method will override the previous setting. */ -MUST_USE_RES bool InitFeatures_requires_gossip_queries(const struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES void OfferWithDerivedMetadataBuilder_supported_quantity(struct LDKOfferWithDerivedMetadataBuilder this_arg, struct LDKQuantity quantity); /** - * Checks if this feature is required. + * Builds an [`Offer`] from the builder's settings. */ -MUST_USE_RES bool NodeFeatures_requires_gossip_queries(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_OfferBolt12SemanticErrorZ OfferWithDerivedMetadataBuilder_build(struct LDKOfferWithDerivedMetadataBuilder this_arg); /** - * Set this feature as optional. + * Frees any resources used by the Offer, if is_owned is set and inner is non-NULL. */ -void InitFeatures_set_variable_length_onion_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +void Offer_free(struct LDKOffer this_obj); /** - * Set this feature as required. + * Creates a copy of the Offer */ -void InitFeatures_set_variable_length_onion_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKOffer Offer_clone(const struct LDKOffer *NONNULL_PTR orig); /** - * Checks if this feature is supported. + * 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. */ -MUST_USE_RES bool InitFeatures_supports_variable_length_onion(const struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCVec_ThirtyTwoBytesZ Offer_chains(const struct LDKOffer *NONNULL_PTR this_arg); /** - * 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 NodeFeatures_set_variable_length_onion_optional(struct LDKNodeFeatures *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. */ -void NodeFeatures_set_variable_length_onion_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCOption_AmountZ 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. + * + * 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_variable_length_onion(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKPrintableString Offer_description(const struct LDKOffer *NONNULL_PTR this_arg); /** - * Set this feature as optional. + * Features pertaining to the offer. */ -void Bolt11InvoiceFeatures_set_variable_length_onion_optional(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKOfferFeatures Offer_offer_features(const struct LDKOffer *NONNULL_PTR this_arg); /** - * Set this feature as required. + * Duration since the Unix epoch when an invoice should no longer be requested. + * + * If `None`, the offer does not expire. */ -void Bolt11InvoiceFeatures_set_variable_length_onion_required(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCOption_u64Z Offer_absolute_expiry(const struct LDKOffer *NONNULL_PTR this_arg); /** - * Checks if this feature is supported. + * 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 */ -MUST_USE_RES bool Bolt11InvoiceFeatures_supports_variable_length_onion(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKPrintableString Offer_issuer(const struct LDKOffer *NONNULL_PTR this_arg); /** - * Checks if this feature is required. + * Paths to the recipient originating from publicly reachable nodes. Blinded paths provide + * recipient privacy by obfuscating its node id. */ -MUST_USE_RES bool InitFeatures_requires_variable_length_onion(const struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCVec_BlindedMessagePathZ Offer_paths(const struct LDKOffer *NONNULL_PTR this_arg); /** - * Checks if this feature is required. + * The quantity of items supported. */ -MUST_USE_RES bool NodeFeatures_requires_variable_length_onion(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKQuantity Offer_supported_quantity(const struct LDKOffer *NONNULL_PTR this_arg); /** - * Checks if this feature is required. + * The public key used by the recipient to sign invoices. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES bool Bolt11InvoiceFeatures_requires_variable_length_onion(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKPublicKey Offer_signing_pubkey(const struct LDKOffer *NONNULL_PTR this_arg); /** - * Set this feature as optional. + * Returns the id of the offer. */ -void InitFeatures_set_static_remote_key_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKOfferId Offer_id(const struct LDKOffer *NONNULL_PTR this_arg); /** - * Set this feature as required. + * Returns whether the given chain is supported by the offer. */ -void InitFeatures_set_static_remote_key_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES bool Offer_supports_chain(const struct LDKOffer *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes chain); /** - * Checks if this feature is supported. + * Whether the offer has expired. */ -MUST_USE_RES bool InitFeatures_supports_static_remote_key(const struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES bool Offer_is_expired(const struct LDKOffer *NONNULL_PTR this_arg); /** - * Set this feature as optional. + * Whether the offer has expired given the duration since the Unix epoch. */ -void NodeFeatures_set_static_remote_key_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES bool Offer_is_expired_no_std(const struct LDKOffer *NONNULL_PTR this_arg, uint64_t duration_since_epoch); /** - * Set this feature as required. + * Returns whether the given quantity is valid for the offer. */ -void NodeFeatures_set_static_remote_key_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES bool Offer_is_valid_quantity(const struct LDKOffer *NONNULL_PTR this_arg, uint64_t quantity); /** - * Checks if this feature is supported. + * Returns whether a quantity is expected in an [`InvoiceRequest`] for the offer. + * + * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest */ -MUST_USE_RES bool NodeFeatures_supports_static_remote_key(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES bool Offer_expects_quantity(const struct LDKOffer *NONNULL_PTR this_arg); /** - * Set this feature as optional. + * Similar to [`Offer::request_invoice`] except it: + * - derives the [`InvoiceRequest::payer_id`] such that a different key can be used for each + * request, + * - sets [`InvoiceRequest::payer_metadata`] when [`InvoiceRequestBuilder::build`] is called + * such that it can be used by [`Bolt12Invoice::verify_using_metadata`] to determine if the + * invoice was requested using a base [`ExpandedKey`] from which the payer id was derived, + * and + * - includes the [`PaymentId`] encrypted in [`InvoiceRequest::payer_metadata`] so that it can + * be used when sending the payment for the requested invoice. + * + * Useful to protect the sender's privacy. + * + * [`InvoiceRequest::payer_id`]: crate::offers::invoice_request::InvoiceRequest::payer_id + * [`InvoiceRequest::payer_metadata`]: crate::offers::invoice_request::InvoiceRequest::payer_metadata + * [`Bolt12Invoice::verify_using_metadata`]: crate::offers::invoice::Bolt12Invoice::verify_using_metadata + * [`ExpandedKey`]: crate::ln::inbound_payment::ExpandedKey */ -void ChannelTypeFeatures_set_static_remote_key_optional(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ Offer_request_invoice_deriving_payer_id(const struct LDKOffer *NONNULL_PTR this_arg, const struct LDKExpandedKey *NONNULL_PTR expanded_key, struct LDKNonce nonce, struct LDKThirtyTwoBytes payment_id); /** - * Set this feature as required. + * Similar to [`Offer::request_invoice_deriving_payer_id`] except uses `payer_id` for the + * [`InvoiceRequest::payer_id`] instead of deriving a different key for each request. + * + * Useful for recurring payments using the same `payer_id` with different invoices. + * + * [`InvoiceRequest::payer_id`]: crate::offers::invoice_request::InvoiceRequest::payer_id */ -void ChannelTypeFeatures_set_static_remote_key_required(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ Offer_request_invoice_deriving_metadata(const struct LDKOffer *NONNULL_PTR this_arg, struct LDKPublicKey payer_id, const struct LDKExpandedKey *NONNULL_PTR expanded_key, struct LDKNonce nonce, struct LDKThirtyTwoBytes payment_id); /** - * Checks if this feature is supported. + * Creates an [`InvoiceRequestBuilder`] for the offer with the given `metadata` and `payer_id`, + * which will be reflected in the `Bolt12Invoice` response. + * + * The `metadata` is useful for including information about the derivation of `payer_id` such + * that invoice response handling can be stateless. Also serves as payer-provided entropy while + * hashing in the signature calculation. + * + * This should not leak any information such as by using a simple BIP-32 derivation path. + * Otherwise, payments may be correlated. + * + * Errors if the offer contains unknown required features. + * + * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest */ -MUST_USE_RES bool ChannelTypeFeatures_supports_static_remote_key(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ Offer_request_invoice(const struct LDKOffer *NONNULL_PTR this_arg, struct LDKCVec_u8Z metadata, struct LDKPublicKey payer_id); /** - * Checks if this feature is required. + * Generates a non-cryptographic 64-bit hash of the Offer. */ -MUST_USE_RES bool InitFeatures_requires_static_remote_key(const struct LDKInitFeatures *NONNULL_PTR this_arg); +uint64_t Offer_hash(const struct LDKOffer *NONNULL_PTR o); /** - * Checks if this feature is required. + * Read a Offer from a byte array, created by Offer_write */ -MUST_USE_RES bool NodeFeatures_requires_static_remote_key(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKCResult_OfferDecodeErrorZ Offer_read(struct LDKu8slice ser); /** - * 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 ChannelTypeFeatures_requires_static_remote_key(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +struct LDKCVec_u8Z Offer_write(const struct LDKOffer *NONNULL_PTR obj); /** - * Set this feature as optional. + * Frees any resources used by the Amount */ -void InitFeatures_set_payment_secret_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +void Amount_free(struct LDKAmount this_ptr); /** - * Set this feature as required. + * Creates a copy of the Amount */ -void InitFeatures_set_payment_secret_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKAmount Amount_clone(const struct LDKAmount *NONNULL_PTR orig); /** - * Checks if this feature is supported. + * Utility method to constructs a new Bitcoin-variant Amount */ -MUST_USE_RES bool InitFeatures_supports_payment_secret(const struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKAmount Amount_bitcoin(uint64_t amount_msats); /** - * Set this feature as optional. + * Utility method to constructs a new Currency-variant Amount */ -void NodeFeatures_set_payment_secret_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKAmount Amount_currency(struct LDKThreeBytes iso4217_code, uint64_t amount); /** - * Set this feature as required. + * Frees any resources used by the Quantity */ -void NodeFeatures_set_payment_secret_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +void Quantity_free(struct LDKQuantity this_ptr); /** - * Checks if this feature is supported. + * Creates a copy of the Quantity */ -MUST_USE_RES bool NodeFeatures_supports_payment_secret(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKQuantity Quantity_clone(const struct LDKQuantity *NONNULL_PTR orig); /** - * Set this feature as optional. + * Utility method to constructs a new Bounded-variant Quantity */ -void Bolt11InvoiceFeatures_set_payment_secret_optional(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); +struct LDKQuantity Quantity_bounded(uint64_t a); /** - * Set this feature as required. + * Utility method to constructs a new Unbounded-variant Quantity */ -void Bolt11InvoiceFeatures_set_payment_secret_required(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); +struct LDKQuantity Quantity_unbounded(void); /** - * Checks if this feature is supported. + * Utility method to constructs a new One-variant Quantity */ -MUST_USE_RES bool Bolt11InvoiceFeatures_supports_payment_secret(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); +struct LDKQuantity Quantity_one(void); /** - * Checks if this feature is required. + * Read a Offer object from a string */ -MUST_USE_RES bool InitFeatures_requires_payment_secret(const struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKCResult_OfferBolt12ParseErrorZ Offer_from_str(struct LDKStr s); /** - * Checks if this feature is required. + * Get the string representation of a Offer object */ -MUST_USE_RES bool NodeFeatures_requires_payment_secret(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKStr Offer_to_str(const struct LDKOffer *NONNULL_PTR o); /** - * Checks if this feature is required. + * Frees any resources used by the InvoiceWithExplicitSigningPubkeyBuilder, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES bool Bolt11InvoiceFeatures_requires_payment_secret(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); +void InvoiceWithExplicitSigningPubkeyBuilder_free(struct LDKInvoiceWithExplicitSigningPubkeyBuilder this_obj); /** - * Set this feature as optional. + * Frees any resources used by the InvoiceWithDerivedSigningPubkeyBuilder, if is_owned is set and inner is non-NULL. */ -void InitFeatures_set_basic_mpp_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +void InvoiceWithDerivedSigningPubkeyBuilder_free(struct LDKInvoiceWithDerivedSigningPubkeyBuilder this_obj); /** - * Set this feature as required. + * Builds an unsigned [`Bolt12Invoice`] after checking for valid semantics. It can be signed by + * [`UnsignedBolt12Invoice::sign`]. */ -void InitFeatures_set_basic_mpp_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ InvoiceWithExplicitSigningPubkeyBuilder_build(struct LDKInvoiceWithExplicitSigningPubkeyBuilder this_arg); /** - * Checks if this feature is supported. + *Sets the [`Bolt12Invoice::relative_expiry`] + *as seconds since [`Bolt12Invoice::created_at`]. + *Any expiry that has already passed is valid and can be checked for using + *[`Bolt12Invoice::is_expired`]. + * + * Successive calls to this method will override the previous setting. */ -MUST_USE_RES bool InitFeatures_supports_basic_mpp(const struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES void InvoiceWithExplicitSigningPubkeyBuilder_relative_expiry(struct LDKInvoiceWithExplicitSigningPubkeyBuilder this_arg, uint32_t relative_expiry_secs); /** - * Set this feature as optional. + *Adds a P2WSH address to [`Bolt12Invoice::fallbacks`]. + * + * Successive calls to this method will add another address. Caller is responsible for not + * adding duplicate addresses and only calling if capable of receiving to P2WSH addresses. */ -void NodeFeatures_set_basic_mpp_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES void InvoiceWithExplicitSigningPubkeyBuilder_fallback_v0_p2wsh(struct LDKInvoiceWithExplicitSigningPubkeyBuilder this_arg, const uint8_t (*script_hash)[32]); /** - * Set this feature as required. + *Adds a P2WPKH address to [`Bolt12Invoice::fallbacks`]. + * + * Successive calls to this method will add another address. Caller is responsible for not + * adding duplicate addresses and only calling if capable of receiving to P2WPKH addresses. */ -void NodeFeatures_set_basic_mpp_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES void InvoiceWithExplicitSigningPubkeyBuilder_fallback_v0_p2wpkh(struct LDKInvoiceWithExplicitSigningPubkeyBuilder this_arg, const uint8_t (*pubkey_hash)[20]); /** - * Checks if this feature is supported. + *Adds a P2TR address to [`Bolt12Invoice::fallbacks`]. + * + * Successive calls to this method will add another address. Caller is responsible for not + * adding duplicate addresses and only calling if capable of receiving to P2TR addresses. */ -MUST_USE_RES bool NodeFeatures_supports_basic_mpp(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES void InvoiceWithExplicitSigningPubkeyBuilder_fallback_v1_p2tr_tweaked(struct LDKInvoiceWithExplicitSigningPubkeyBuilder this_arg, struct LDKTweakedPublicKey output_key); /** - * Set this feature as optional. + *Sets [`Bolt12Invoice::invoice_features`] + *to indicate MPP may be used. Otherwise, MPP is disallowed. */ -void Bolt11InvoiceFeatures_set_basic_mpp_optional(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); +MUST_USE_RES void InvoiceWithExplicitSigningPubkeyBuilder_allow_mpp(struct LDKInvoiceWithExplicitSigningPubkeyBuilder this_arg); /** - * Set this feature as required. + * Builds a signed [`Bolt12Invoice`] after checking for valid semantics. */ -void Bolt11InvoiceFeatures_set_basic_mpp_required(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_Bolt12InvoiceBolt12SemanticErrorZ InvoiceWithDerivedSigningPubkeyBuilder_build_and_sign(struct LDKInvoiceWithDerivedSigningPubkeyBuilder this_arg); /** - * Checks if this feature is supported. + *Sets the [`Bolt12Invoice::relative_expiry`] + *as seconds since [`Bolt12Invoice::created_at`]. + *Any expiry that has already passed is valid and can be checked for using + *[`Bolt12Invoice::is_expired`]. + * + * Successive calls to this method will override the previous setting. */ -MUST_USE_RES bool Bolt11InvoiceFeatures_supports_basic_mpp(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); +MUST_USE_RES void InvoiceWithDerivedSigningPubkeyBuilder_relative_expiry(struct LDKInvoiceWithDerivedSigningPubkeyBuilder this_arg, uint32_t relative_expiry_secs); /** - * Set this feature as optional. + *Adds a P2WSH address to [`Bolt12Invoice::fallbacks`]. + * + * Successive calls to this method will add another address. Caller is responsible for not + * adding duplicate addresses and only calling if capable of receiving to P2WSH addresses. */ -void Bolt12InvoiceFeatures_set_basic_mpp_optional(struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg); +MUST_USE_RES void InvoiceWithDerivedSigningPubkeyBuilder_fallback_v0_p2wsh(struct LDKInvoiceWithDerivedSigningPubkeyBuilder this_arg, const uint8_t (*script_hash)[32]); /** - * Set this feature as required. + *Adds a P2WPKH address to [`Bolt12Invoice::fallbacks`]. + * + * Successive calls to this method will add another address. Caller is responsible for not + * adding duplicate addresses and only calling if capable of receiving to P2WPKH addresses. */ -void Bolt12InvoiceFeatures_set_basic_mpp_required(struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg); +MUST_USE_RES void InvoiceWithDerivedSigningPubkeyBuilder_fallback_v0_p2wpkh(struct LDKInvoiceWithDerivedSigningPubkeyBuilder this_arg, const uint8_t (*pubkey_hash)[20]); /** - * Checks if this feature is supported. + *Adds a P2TR address to [`Bolt12Invoice::fallbacks`]. + * + * Successive calls to this method will add another address. Caller is responsible for not + * adding duplicate addresses and only calling if capable of receiving to P2TR addresses. */ -MUST_USE_RES bool Bolt12InvoiceFeatures_supports_basic_mpp(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg); +MUST_USE_RES void InvoiceWithDerivedSigningPubkeyBuilder_fallback_v1_p2tr_tweaked(struct LDKInvoiceWithDerivedSigningPubkeyBuilder this_arg, struct LDKTweakedPublicKey output_key); /** - * Checks if this feature is required. + *Sets [`Bolt12Invoice::invoice_features`] + *to indicate MPP may be used. Otherwise, MPP is disallowed. */ -MUST_USE_RES bool InitFeatures_requires_basic_mpp(const struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES void InvoiceWithDerivedSigningPubkeyBuilder_allow_mpp(struct LDKInvoiceWithDerivedSigningPubkeyBuilder this_arg); /** - * Checks if this feature is required. + * Frees any resources used by the UnsignedBolt12Invoice, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES bool NodeFeatures_requires_basic_mpp(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +void UnsignedBolt12Invoice_free(struct LDKUnsignedBolt12Invoice this_obj); /** - * Checks if this feature is required. + * Creates a copy of the UnsignedBolt12Invoice */ -MUST_USE_RES bool Bolt11InvoiceFeatures_requires_basic_mpp(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); +struct LDKUnsignedBolt12Invoice UnsignedBolt12Invoice_clone(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR orig); /** - * Checks if this feature is required. + * Calls the free function if one is set */ -MUST_USE_RES bool Bolt12InvoiceFeatures_requires_basic_mpp(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg); +void SignBolt12InvoiceFn_free(struct LDKSignBolt12InvoiceFn this_ptr); /** - * Set this feature as optional. + * Returns the [`TaggedHash`] of the invoice to sign. */ -void InitFeatures_set_wumbo_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKTaggedHash UnsignedBolt12Invoice_tagged_hash(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * Set this feature as required. + * Frees any resources used by the Bolt12Invoice, if is_owned is set and inner is non-NULL. */ -void InitFeatures_set_wumbo_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +void Bolt12Invoice_free(struct LDKBolt12Invoice this_obj); /** - * Checks if this feature is supported. + * Creates a copy of the Bolt12Invoice */ -MUST_USE_RES bool InitFeatures_supports_wumbo(const struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKBolt12Invoice Bolt12Invoice_clone(const struct LDKBolt12Invoice *NONNULL_PTR orig); /** - * Set this feature as optional. + * Duration since the Unix epoch when the invoice was created. */ -void NodeFeatures_set_wumbo_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES uint64_t UnsignedBolt12Invoice_created_at(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * Set this feature as required. + * Duration since + *[`Bolt12Invoice::created_at`] + * when the invoice has expired and therefore should no longer be paid. */ -void NodeFeatures_set_wumbo_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES uint64_t UnsignedBolt12Invoice_relative_expiry(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * Checks if this feature is supported. + * Whether the invoice has expired. */ -MUST_USE_RES bool NodeFeatures_supports_wumbo(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES bool UnsignedBolt12Invoice_is_expired(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * Checks if this feature is required. + * Fallback addresses for paying the invoice on-chain, in order of most-preferred to + * least-preferred. */ -MUST_USE_RES bool InitFeatures_requires_wumbo(const struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCVec_StrZ UnsignedBolt12Invoice_fallbacks(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * Checks if this feature is required. + * Features pertaining to paying an invoice. */ -MUST_USE_RES bool NodeFeatures_requires_wumbo(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKBolt12InvoiceFeatures UnsignedBolt12Invoice_invoice_features(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * Set this feature as optional. + * The public key corresponding to the key used to sign the invoice. */ -void InitFeatures_set_anchors_nonzero_fee_htlc_tx_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKPublicKey UnsignedBolt12Invoice_signing_pubkey(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * Set this feature as required. + * The chains that may be used when paying a requested invoice. + * + * From [`Offer::chains`]; `None` if the invoice was created in response to a [`Refund`]. + * + * [`Offer::chains`]: crate::offers::offer::Offer::chains */ -void InitFeatures_set_anchors_nonzero_fee_htlc_tx_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCOption_CVec_ThirtyTwoBytesZZ UnsignedBolt12Invoice_offer_chains(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * Checks if this feature is supported. + * The chain that must be used when paying the invoice; selected from [`offer_chains`] if the + * invoice originated from an offer. + * + * From [`InvoiceRequest::chain`] or [`Refund::chain`]. + * + * [`offer_chains`]: Self::offer_chains + * [`InvoiceRequest::chain`]: crate::offers::invoice_request::InvoiceRequest::chain */ -MUST_USE_RES bool InitFeatures_supports_anchors_nonzero_fee_htlc_tx(const struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKThirtyTwoBytes UnsignedBolt12Invoice_chain(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * Set this feature as optional. + * Opaque bytes set by the originating [`Offer`]. + * + * From [`Offer::metadata`]; `None` if the invoice was created in response to a [`Refund`] or + * if the [`Offer`] did not set it. + * + * [`Offer`]: crate::offers::offer::Offer + * [`Offer::metadata`]: crate::offers::offer::Offer::metadata */ -void NodeFeatures_set_anchors_nonzero_fee_htlc_tx_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCOption_CVec_u8ZZ UnsignedBolt12Invoice_metadata(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * Set this feature as required. + * The minimum amount required for a successful payment of a single item. + * + * From [`Offer::amount`]; `None` if the invoice was created in response to a [`Refund`] or if + * the [`Offer`] did not set it. + * + * [`Offer`]: crate::offers::offer::Offer + * [`Offer::amount`]: crate::offers::offer::Offer::amount */ -void NodeFeatures_set_anchors_nonzero_fee_htlc_tx_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCOption_AmountZ UnsignedBolt12Invoice_amount(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * Checks if this feature is supported. + * Features pertaining to the originating [`Offer`]. + * + * From [`Offer::offer_features`]; `None` if the invoice was created in response to a + * [`Refund`]. + * + * [`Offer`]: crate::offers::offer::Offer + * [`Offer::offer_features`]: crate::offers::offer::Offer::offer_features + * + * 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_anchors_nonzero_fee_htlc_tx(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKOfferFeatures UnsignedBolt12Invoice_offer_features(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * Set this feature as optional. + * A complete description of the purpose of the originating offer or refund. + * + * From [`Offer::description`] or [`Refund::description`]. + * + * [`Offer::description`]: crate::offers::offer::Offer::description + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void ChannelTypeFeatures_set_anchors_nonzero_fee_htlc_tx_optional(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKPrintableString UnsignedBolt12Invoice_description(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * Set this feature as required. + * Duration since the Unix epoch when an invoice should no longer be requested. + * + * From [`Offer::absolute_expiry`] or [`Refund::absolute_expiry`]. + * + * [`Offer::absolute_expiry`]: crate::offers::offer::Offer::absolute_expiry */ -void ChannelTypeFeatures_set_anchors_nonzero_fee_htlc_tx_required(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCOption_u64Z UnsignedBolt12Invoice_absolute_expiry(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * Checks if this feature is supported. + * The issuer of the offer or refund. + * + * From [`Offer::issuer`] or [`Refund::issuer`]. + * + * [`Offer::issuer`]: crate::offers::offer::Offer::issuer + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES bool ChannelTypeFeatures_supports_anchors_nonzero_fee_htlc_tx(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKPrintableString UnsignedBolt12Invoice_issuer(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * Checks if this feature is required. + * Paths to the recipient originating from publicly reachable nodes. + * + * From [`Offer::paths`] or [`Refund::paths`]. + * + * [`Offer::paths`]: crate::offers::offer::Offer::paths */ -MUST_USE_RES bool InitFeatures_requires_anchors_nonzero_fee_htlc_tx(const struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCVec_BlindedMessagePathZ UnsignedBolt12Invoice_message_paths(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * Checks if this feature is required. + * The quantity of items supported. + * + * From [`Offer::supported_quantity`]; `None` if the invoice was created in response to a + * [`Refund`]. + * + * [`Offer::supported_quantity`]: crate::offers::offer::Offer::supported_quantity */ -MUST_USE_RES bool NodeFeatures_requires_anchors_nonzero_fee_htlc_tx(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCOption_QuantityZ UnsignedBolt12Invoice_supported_quantity(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * Checks if this feature is required. + * An unpredictable series of bytes from the payer. + * + * From [`InvoiceRequest::payer_metadata`] or [`Refund::payer_metadata`]. */ -MUST_USE_RES bool ChannelTypeFeatures_requires_anchors_nonzero_fee_htlc_tx(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKu8slice UnsignedBolt12Invoice_payer_metadata(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * Set this feature as optional. + * Features pertaining to requesting an invoice. + * + * From [`InvoiceRequest::invoice_request_features`] or [`Refund::features`]. */ -void InitFeatures_set_anchors_zero_fee_htlc_tx_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKInvoiceRequestFeatures UnsignedBolt12Invoice_invoice_request_features(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * Set this feature as required. + * The quantity of items requested or refunded for. + * + * From [`InvoiceRequest::quantity`] or [`Refund::quantity`]. */ -void InitFeatures_set_anchors_zero_fee_htlc_tx_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCOption_u64Z UnsignedBolt12Invoice_quantity(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * Checks if this feature is supported. + * A possibly transient pubkey used to sign the invoice request or to send an invoice for a + * refund in case there are no [`message_paths`]. + * + * [`message_paths`]: Self::message_paths */ -MUST_USE_RES bool InitFeatures_supports_anchors_zero_fee_htlc_tx(const struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKPublicKey UnsignedBolt12Invoice_payer_id(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * Set this feature as optional. + * A payer-provided note reflected back in the invoice. + * + * From [`InvoiceRequest::payer_note`] or [`Refund::payer_note`]. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void NodeFeatures_set_anchors_zero_fee_htlc_tx_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKPrintableString UnsignedBolt12Invoice_payer_note(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * Set this feature as required. + * SHA256 hash of the payment preimage that will be given in return for paying the invoice. */ -void NodeFeatures_set_anchors_zero_fee_htlc_tx_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKThirtyTwoBytes UnsignedBolt12Invoice_payment_hash(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * Checks if this feature is supported. + * The minimum amount required for a successful payment of the invoice. */ -MUST_USE_RES bool NodeFeatures_supports_anchors_zero_fee_htlc_tx(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES uint64_t UnsignedBolt12Invoice_amount_msats(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * Set this feature as optional. + * Duration since the Unix epoch when the invoice was created. */ -void ChannelTypeFeatures_set_anchors_zero_fee_htlc_tx_optional(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES uint64_t Bolt12Invoice_created_at(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * Set this feature as required. + * Duration since + *[`Bolt12Invoice::created_at`] + * when the invoice has expired and therefore should no longer be paid. */ -void ChannelTypeFeatures_set_anchors_zero_fee_htlc_tx_required(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES uint64_t Bolt12Invoice_relative_expiry(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * Checks if this feature is supported. + * Whether the invoice has expired. */ -MUST_USE_RES bool ChannelTypeFeatures_supports_anchors_zero_fee_htlc_tx(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES bool Bolt12Invoice_is_expired(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * Checks if this feature is required. + * Fallback addresses for paying the invoice on-chain, in order of most-preferred to + * least-preferred. */ -MUST_USE_RES bool InitFeatures_requires_anchors_zero_fee_htlc_tx(const struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCVec_StrZ Bolt12Invoice_fallbacks(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_anchors_zero_fee_htlc_tx(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKBolt12InvoiceFeatures Bolt12Invoice_invoice_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 ChannelTypeFeatures_requires_anchors_zero_fee_htlc_tx(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKPublicKey Bolt12Invoice_signing_pubkey(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * Set this feature as optional. + * The chains that may be used when paying a requested invoice. + * + * From [`Offer::chains`]; `None` if the invoice was created in response to a [`Refund`]. + * + * [`Offer::chains`]: crate::offers::offer::Offer::chains */ -void InitFeatures_set_route_blinding_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCOption_CVec_ThirtyTwoBytesZZ Bolt12Invoice_offer_chains(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * Set this feature as required. + * The chain that must be used when paying the invoice; selected from [`offer_chains`] if the + * invoice originated from an offer. + * + * From [`InvoiceRequest::chain`] or [`Refund::chain`]. + * + * [`offer_chains`]: Self::offer_chains + * [`InvoiceRequest::chain`]: crate::offers::invoice_request::InvoiceRequest::chain */ -void InitFeatures_set_route_blinding_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKThirtyTwoBytes Bolt12Invoice_chain(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * Checks if this feature is supported. + * Opaque bytes set by the originating [`Offer`]. + * + * From [`Offer::metadata`]; `None` if the invoice was created in response to a [`Refund`] or + * if the [`Offer`] did not set it. + * + * [`Offer`]: crate::offers::offer::Offer + * [`Offer::metadata`]: crate::offers::offer::Offer::metadata */ -MUST_USE_RES bool InitFeatures_supports_route_blinding(const struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCOption_CVec_u8ZZ Bolt12Invoice_metadata(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * Set this feature as optional. + * The minimum amount required for a successful payment of a single item. + * + * From [`Offer::amount`]; `None` if the invoice was created in response to a [`Refund`] or if + * the [`Offer`] did not set it. + * + * [`Offer`]: crate::offers::offer::Offer + * [`Offer::amount`]: crate::offers::offer::Offer::amount */ -void NodeFeatures_set_route_blinding_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCOption_AmountZ Bolt12Invoice_amount(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * Set this feature as required. + * Features pertaining to the originating [`Offer`]. + * + * From [`Offer::offer_features`]; `None` if the invoice was created in response to a + * [`Refund`]. + * + * [`Offer`]: crate::offers::offer::Offer + * [`Offer::offer_features`]: crate::offers::offer::Offer::offer_features + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void NodeFeatures_set_route_blinding_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKOfferFeatures Bolt12Invoice_offer_features(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * Checks if this feature is supported. + * A complete description of the purpose of the originating offer or refund. + * + * From [`Offer::description`] or [`Refund::description`]. + * + * [`Offer::description`]: crate::offers::offer::Offer::description + * + * 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_route_blinding(const 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 required. + * Duration since the Unix epoch when an invoice should no longer be requested. + * + * From [`Offer::absolute_expiry`] or [`Refund::absolute_expiry`]. + * + * [`Offer::absolute_expiry`]: crate::offers::offer::Offer::absolute_expiry */ -MUST_USE_RES bool InitFeatures_requires_route_blinding(const struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCOption_u64Z Bolt12Invoice_absolute_expiry(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * Checks if this feature is required. + * The issuer of the offer or refund. + * + * From [`Offer::issuer`] or [`Refund::issuer`]. + * + * [`Offer::issuer`]: crate::offers::offer::Offer::issuer + * + * 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_route_blinding(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKPrintableString Bolt12Invoice_issuer(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * Set this feature as optional. + * Paths to the recipient originating from publicly reachable nodes. + * + * From [`Offer::paths`] or [`Refund::paths`]. + * + * [`Offer::paths`]: crate::offers::offer::Offer::paths */ -void InitFeatures_set_shutdown_any_segwit_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCVec_BlindedMessagePathZ Bolt12Invoice_message_paths(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * Set this feature as required. + * The quantity of items supported. + * + * From [`Offer::supported_quantity`]; `None` if the invoice was created in response to a + * [`Refund`]. + * + * [`Offer::supported_quantity`]: crate::offers::offer::Offer::supported_quantity */ -void InitFeatures_set_shutdown_any_segwit_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCOption_QuantityZ Bolt12Invoice_supported_quantity(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * Checks if this feature is supported. + * An unpredictable series of bytes from the payer. + * + * From [`InvoiceRequest::payer_metadata`] or [`Refund::payer_metadata`]. */ -MUST_USE_RES bool InitFeatures_supports_shutdown_anysegwit(const struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKu8slice Bolt12Invoice_payer_metadata(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * Set this feature as optional. + * Features pertaining to requesting an invoice. + * + * From [`InvoiceRequest::invoice_request_features`] or [`Refund::features`]. */ -void NodeFeatures_set_shutdown_any_segwit_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKInvoiceRequestFeatures Bolt12Invoice_invoice_request_features(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * Set this feature as required. + * The quantity of items requested or refunded for. + * + * From [`InvoiceRequest::quantity`] or [`Refund::quantity`]. */ -void NodeFeatures_set_shutdown_any_segwit_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCOption_u64Z Bolt12Invoice_quantity(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * Checks if this feature is supported. + * A possibly transient pubkey used to sign the invoice request or to send an invoice for a + * refund in case there are no [`message_paths`]. + * + * [`message_paths`]: Self::message_paths */ -MUST_USE_RES bool NodeFeatures_supports_shutdown_anysegwit(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKPublicKey Bolt12Invoice_payer_id(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * Checks if this feature is required. + * A payer-provided note reflected back in the invoice. + * + * From [`InvoiceRequest::payer_note`] or [`Refund::payer_note`]. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES bool InitFeatures_requires_shutdown_anysegwit(const struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKPrintableString Bolt12Invoice_payer_note(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * Checks if this feature is required. + * SHA256 hash of the payment preimage that will be given in return for paying the invoice. */ -MUST_USE_RES bool NodeFeatures_requires_shutdown_anysegwit(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKThirtyTwoBytes Bolt12Invoice_payment_hash(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * Set this feature as optional. + * The minimum amount required for a successful payment of the invoice. */ -void InitFeatures_set_taproot_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES uint64_t Bolt12Invoice_amount_msats(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * Set this feature as required. + * Signature of the invoice verified using [`Bolt12Invoice::signing_pubkey`]. */ -void InitFeatures_set_taproot_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKSchnorrSignature Bolt12Invoice_signature(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * Checks if this feature is supported. + * Hash that was used for signing the invoice. */ -MUST_USE_RES bool InitFeatures_supports_taproot(const 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 optional. + * Verifies that the invoice was for a request or refund created using the given key by + * checking the payer metadata from the invoice request. + * + * Returns the associated [`PaymentId`] to use when sending the payment. */ -void NodeFeatures_set_taproot_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_ThirtyTwoBytesNoneZ Bolt12Invoice_verify_using_metadata(const struct LDKBolt12Invoice *NONNULL_PTR this_arg, const struct LDKExpandedKey *NONNULL_PTR key); /** - * Set this feature as required. + * Verifies that the invoice was for a request or refund created using the given key by + * checking a payment id and nonce included with the [`BlindedMessagePath`] for which the invoice was + * sent through. */ -void NodeFeatures_set_taproot_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_ThirtyTwoBytesNoneZ Bolt12Invoice_verify_using_payer_data(const struct LDKBolt12Invoice *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes payment_id, struct LDKNonce nonce, const struct LDKExpandedKey *NONNULL_PTR key); /** - * Checks if this feature is supported. + * Generates a non-cryptographic 64-bit hash of the Bolt12Invoice. */ -MUST_USE_RES bool NodeFeatures_supports_taproot(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +uint64_t Bolt12Invoice_hash(const struct LDKBolt12Invoice *NONNULL_PTR o); /** - * Set this feature as optional. + * Serialize the UnsignedBolt12Invoice object into a byte array which can be read by UnsignedBolt12Invoice_read */ -void ChannelTypeFeatures_set_taproot_optional(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +struct LDKCVec_u8Z UnsignedBolt12Invoice_write(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR obj); /** - * Set this feature as required. + * Serialize the Bolt12Invoice object into a byte array which can be read by Bolt12Invoice_read */ -void ChannelTypeFeatures_set_taproot_required(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +struct LDKCVec_u8Z Bolt12Invoice_write(const struct LDKBolt12Invoice *NONNULL_PTR obj); /** - * Checks if this feature is supported. + * Read a Bolt12Invoice from a byte array, created by Bolt12Invoice_write */ -MUST_USE_RES bool ChannelTypeFeatures_supports_taproot(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +struct LDKCResult_Bolt12InvoiceDecodeErrorZ Bolt12Invoice_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 InitFeatures_requires_taproot(const struct LDKInitFeatures *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 NodeFeatures_requires_taproot(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKErroneousField InvoiceError_get_erroneous_field(const struct LDKInvoiceError *NONNULL_PTR this_ptr); /** - * 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 val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES bool ChannelTypeFeatures_requires_taproot(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +void InvoiceError_set_erroneous_field(struct LDKInvoiceError *NONNULL_PTR this_ptr, struct LDKErroneousField val); /** - * Set this feature as optional. + * An explanation of the error. */ -void InitFeatures_set_onion_messages_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKUntrustedString InvoiceError_get_message(const struct LDKInvoiceError *NONNULL_PTR this_ptr); /** - * Set this feature as required. + * An explanation of the error. */ -void InitFeatures_set_onion_messages_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +void InvoiceError_set_message(struct LDKInvoiceError *NONNULL_PTR this_ptr, struct LDKUntrustedString val); /** - * Checks if this feature is supported. + * Constructs a new InvoiceError given each field + * + * Note that erroneous_field_arg (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES bool InitFeatures_supports_onion_messages(const struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKInvoiceError InvoiceError_new(struct LDKErroneousField erroneous_field_arg, struct LDKUntrustedString message_arg); /** - * Set this feature as optional. + * Creates a copy of the InvoiceError */ -void NodeFeatures_set_onion_messages_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKInvoiceError InvoiceError_clone(const struct LDKInvoiceError *NONNULL_PTR orig); /** - * Set this feature as required. + * Frees any resources used by the ErroneousField, if is_owned is set and inner is non-NULL. */ -void NodeFeatures_set_onion_messages_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +void ErroneousField_free(struct LDKErroneousField this_obj); /** - * Checks if this feature is supported. + * The type number of the TLV field containing the error. */ -MUST_USE_RES bool NodeFeatures_supports_onion_messages(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +uint64_t ErroneousField_get_tlv_fieldnum(const struct LDKErroneousField *NONNULL_PTR this_ptr); /** - * Checks if this feature is required. + * The type number of the TLV field containing the error. */ -MUST_USE_RES bool InitFeatures_requires_onion_messages(const struct LDKInitFeatures *NONNULL_PTR this_arg); +void ErroneousField_set_tlv_fieldnum(struct LDKErroneousField *NONNULL_PTR this_ptr, uint64_t val); /** - * Checks if this feature is required. + * A value to use for the TLV field to avoid the error. + * + * Returns a copy of the field. */ -MUST_USE_RES bool NodeFeatures_requires_onion_messages(const struct LDKNodeFeatures *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 InitFeatures_set_channel_type_optional(struct LDKInitFeatures *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 InitFeatures_set_channel_type_required(struct LDKInitFeatures *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 InitFeatures_supports_channel_type(const struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKErroneousField ErroneousField_clone(const struct LDKErroneousField *NONNULL_PTR orig); /** - * Set this feature as optional. + * Creates an [`InvoiceError`] with the given message. */ -void NodeFeatures_set_channel_type_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKInvoiceError InvoiceError_from_string(struct LDKStr s); /** - * Set this feature as required. + * Get the string representation of a InvoiceError object */ -void NodeFeatures_set_channel_type_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKStr InvoiceError_to_str(const struct LDKInvoiceError *NONNULL_PTR o); /** - * Checks if this feature is supported. + * Serialize the InvoiceError object into a byte array which can be read by InvoiceError_read */ -MUST_USE_RES bool NodeFeatures_supports_channel_type(const struct LDKNodeFeatures *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 InitFeatures_requires_channel_type(const struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKCResult_InvoiceErrorDecodeErrorZ InvoiceError_read(struct LDKu8slice ser); /** - * Checks if this feature is required. + * Frees any resources used by the InvoiceRequestWithExplicitPayerIdBuilder, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES bool NodeFeatures_requires_channel_type(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +void InvoiceRequestWithExplicitPayerIdBuilder_free(struct LDKInvoiceRequestWithExplicitPayerIdBuilder this_obj); /** - * Set this feature as optional. + * Frees any resources used by the InvoiceRequestWithDerivedPayerIdBuilder, if is_owned is set and inner is non-NULL. */ -void InitFeatures_set_scid_privacy_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +void InvoiceRequestWithDerivedPayerIdBuilder_free(struct LDKInvoiceRequestWithDerivedPayerIdBuilder this_obj); /** - * Set this feature as required. + * Builds an unsigned [`InvoiceRequest`] after checking for valid semantics. It can be signed + * by [`UnsignedInvoiceRequest::sign`]. */ -void InitFeatures_set_scid_privacy_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_UnsignedInvoiceRequestBolt12SemanticErrorZ InvoiceRequestWithExplicitPayerIdBuilder_build(struct LDKInvoiceRequestWithExplicitPayerIdBuilder this_arg); /** - * Checks if this feature is supported. + * Sets the [`InvoiceRequest::chain`] of the given [`Network`] for paying an invoice. If not + * called, [`Network::Bitcoin`] is assumed. Errors if the chain for `network` is not supported + * by the offer. + * + * Successive calls to this method will override the previous setting. */ -MUST_USE_RES bool InitFeatures_supports_scid_privacy(const struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_NoneBolt12SemanticErrorZ InvoiceRequestWithExplicitPayerIdBuilder_chain(struct LDKInvoiceRequestWithExplicitPayerIdBuilder this_arg, enum LDKNetwork network); /** - * Set this feature as optional. + * Sets the [`InvoiceRequest::amount_msats`] for paying an invoice. Errors if `amount_msats` is + * not at least the expected invoice amount (i.e., [`Offer::amount`] times [`quantity`]). + * + * Successive calls to this method will override the previous setting. + * + * [`quantity`]: Self::quantity */ -void NodeFeatures_set_scid_privacy_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_NoneBolt12SemanticErrorZ InvoiceRequestWithExplicitPayerIdBuilder_amount_msats(struct LDKInvoiceRequestWithExplicitPayerIdBuilder this_arg, uint64_t amount_msats); /** - * Set this feature as required. + * Sets [`InvoiceRequest::quantity`] of items. If not set, `1` is assumed. Errors if `quantity` + * does not conform to [`Offer::is_valid_quantity`]. + * + * Successive calls to this method will override the previous setting. */ -void NodeFeatures_set_scid_privacy_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_NoneBolt12SemanticErrorZ InvoiceRequestWithExplicitPayerIdBuilder_quantity(struct LDKInvoiceRequestWithExplicitPayerIdBuilder this_arg, uint64_t quantity); /** - * Checks if this feature is supported. + * Sets the [`InvoiceRequest::payer_note`]. + * + * Successive calls to this method will override the previous setting. */ -MUST_USE_RES bool NodeFeatures_supports_scid_privacy(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES void InvoiceRequestWithExplicitPayerIdBuilder_payer_note(struct LDKInvoiceRequestWithExplicitPayerIdBuilder this_arg, struct LDKStr payer_note); /** - * Set this feature as optional. + * Builds a signed [`InvoiceRequest`] after checking for valid semantics. */ -void ChannelTypeFeatures_set_scid_privacy_optional(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_InvoiceRequestBolt12SemanticErrorZ InvoiceRequestWithDerivedPayerIdBuilder_build_and_sign(struct LDKInvoiceRequestWithDerivedPayerIdBuilder this_arg); /** - * Set this feature as required. + * Sets the [`InvoiceRequest::chain`] of the given [`Network`] for paying an invoice. If not + * called, [`Network::Bitcoin`] is assumed. Errors if the chain for `network` is not supported + * by the offer. + * + * Successive calls to this method will override the previous setting. */ -void ChannelTypeFeatures_set_scid_privacy_required(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_NoneBolt12SemanticErrorZ InvoiceRequestWithDerivedPayerIdBuilder_chain(struct LDKInvoiceRequestWithDerivedPayerIdBuilder this_arg, enum LDKNetwork network); /** - * Checks if this feature is supported. + * Sets the [`InvoiceRequest::amount_msats`] for paying an invoice. Errors if `amount_msats` is + * not at least the expected invoice amount (i.e., [`Offer::amount`] times [`quantity`]). + * + * Successive calls to this method will override the previous setting. + * + * [`quantity`]: Self::quantity */ -MUST_USE_RES bool ChannelTypeFeatures_supports_scid_privacy(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_NoneBolt12SemanticErrorZ InvoiceRequestWithDerivedPayerIdBuilder_amount_msats(struct LDKInvoiceRequestWithDerivedPayerIdBuilder this_arg, uint64_t amount_msats); /** - * Checks if this feature is required. + * Sets [`InvoiceRequest::quantity`] of items. If not set, `1` is assumed. Errors if `quantity` + * does not conform to [`Offer::is_valid_quantity`]. + * + * Successive calls to this method will override the previous setting. */ -MUST_USE_RES bool InitFeatures_requires_scid_privacy(const struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_NoneBolt12SemanticErrorZ InvoiceRequestWithDerivedPayerIdBuilder_quantity(struct LDKInvoiceRequestWithDerivedPayerIdBuilder this_arg, uint64_t quantity); /** - * Checks if this feature is required. + * Sets the [`InvoiceRequest::payer_note`]. + * + * Successive calls to this method will override the previous setting. */ -MUST_USE_RES bool NodeFeatures_requires_scid_privacy(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES void InvoiceRequestWithDerivedPayerIdBuilder_payer_note(struct LDKInvoiceRequestWithDerivedPayerIdBuilder this_arg, struct LDKStr payer_note); /** - * 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 ChannelTypeFeatures_requires_scid_privacy(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +void UnsignedInvoiceRequest_free(struct LDKUnsignedInvoiceRequest this_obj); /** - * Set this feature as optional. + * Creates a copy of the UnsignedInvoiceRequest */ -void Bolt11InvoiceFeatures_set_payment_metadata_optional(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); +struct LDKUnsignedInvoiceRequest UnsignedInvoiceRequest_clone(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR orig); /** - * Set this feature as required. + * Calls the free function if one is set */ -void Bolt11InvoiceFeatures_set_payment_metadata_required(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); +void SignInvoiceRequestFn_free(struct LDKSignInvoiceRequestFn this_ptr); /** - * Checks if this feature is supported. + * Returns the [`TaggedHash`] of the invoice to sign. */ -MUST_USE_RES bool Bolt11InvoiceFeatures_supports_payment_metadata(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKTaggedHash UnsignedInvoiceRequest_tagged_hash(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); /** - * 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 Bolt11InvoiceFeatures_requires_payment_metadata(const struct LDKBolt11InvoiceFeatures *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_zero_conf_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKInvoiceRequest InvoiceRequest_clone(const struct LDKInvoiceRequest *NONNULL_PTR orig); /** - * Set this feature as required. + * Frees any resources used by the VerifiedInvoiceRequest, if is_owned is set and inner is non-NULL. */ -void InitFeatures_set_zero_conf_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +void VerifiedInvoiceRequest_free(struct LDKVerifiedInvoiceRequest this_obj); /** - * Checks if this feature is supported. + * The identifier of the [`Offer`] for which the [`InvoiceRequest`] was made. */ -MUST_USE_RES bool InitFeatures_supports_zero_conf(const struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKOfferId VerifiedInvoiceRequest_get_offer_id(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_ptr); /** - * Set this feature as optional. + * The identifier of the [`Offer`] for which the [`InvoiceRequest`] was made. */ -void NodeFeatures_set_zero_conf_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +void VerifiedInvoiceRequest_set_offer_id(struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_ptr, struct LDKOfferId val); /** - * Set this feature as required. + * Creates a copy of the VerifiedInvoiceRequest */ -void NodeFeatures_set_zero_conf_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKVerifiedInvoiceRequest VerifiedInvoiceRequest_clone(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR orig); /** - * Checks if this feature is supported. + * 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. */ -MUST_USE_RES bool NodeFeatures_supports_zero_conf(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCVec_ThirtyTwoBytesZ UnsignedInvoiceRequest_chains(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); /** - * 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_zero_conf_optional(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCOption_CVec_u8ZZ UnsignedInvoiceRequest_metadata(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); /** - * Set this feature as required. + * The minimum amount required for a successful payment of a single item. */ -void ChannelTypeFeatures_set_zero_conf_required(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCOption_AmountZ UnsignedInvoiceRequest_amount(const struct LDKUnsignedInvoiceRequest *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. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES bool ChannelTypeFeatures_supports_zero_conf(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKPrintableString UnsignedInvoiceRequest_description(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); /** - * Checks if this feature is required. + * Features pertaining to the offer. */ -MUST_USE_RES bool InitFeatures_requires_zero_conf(const struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKOfferFeatures UnsignedInvoiceRequest_offer_features(const struct LDKUnsignedInvoiceRequest *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_zero_conf(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCOption_u64Z UnsignedInvoiceRequest_absolute_expiry(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); /** - * Checks if this feature is required. + * 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 */ -MUST_USE_RES bool ChannelTypeFeatures_requires_zero_conf(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKPrintableString UnsignedInvoiceRequest_issuer(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); /** - * Set this feature as optional. + * Paths to the recipient originating from publicly reachable nodes. Blinded paths provide + * recipient privacy by obfuscating its node id. */ -void NodeFeatures_set_keysend_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCVec_BlindedMessagePathZ UnsignedInvoiceRequest_paths(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); /** - * Set this feature as required. + * The quantity of items supported. */ -void NodeFeatures_set_keysend_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKQuantity UnsignedInvoiceRequest_supported_quantity(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); /** - * Checks if this feature is supported. + * The public key used by the recipient to sign invoices. + * + * 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 LDKPublicKey UnsignedInvoiceRequest_signing_pubkey(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); /** - * Checks if this feature is required. + * An unpredictable series of bytes, typically containing information about the derivation of + * [`payer_id`]. + * + * [`payer_id`]: Self::payer_id */ -MUST_USE_RES bool NodeFeatures_requires_keysend(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKu8slice UnsignedInvoiceRequest_payer_metadata(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); /** - * Set this feature as optional. + * A chain from [`Offer::chains`] that the offer is valid for. */ -void InitFeatures_set_trampoline_routing_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKThirtyTwoBytes UnsignedInvoiceRequest_chain(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); /** - * Set this feature as required. + * 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 InitFeatures_set_trampoline_routing_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCOption_u64Z UnsignedInvoiceRequest_amount_msats(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); /** - * Checks if this feature is supported. + * Features pertaining to requesting an invoice. */ -MUST_USE_RES bool InitFeatures_supports_trampoline_routing(const struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKInvoiceRequestFeatures UnsignedInvoiceRequest_invoice_request_features(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); /** - * Set this feature as optional. + * The quantity of the offer's item conforming to [`Offer::is_valid_quantity`]. */ -void NodeFeatures_set_trampoline_routing_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCOption_u64Z UnsignedInvoiceRequest_quantity(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); /** - * Set this feature as required. + * A possibly transient pubkey used to sign the invoice request. */ -void NodeFeatures_set_trampoline_routing_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKPublicKey UnsignedInvoiceRequest_payer_id(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); /** - * Checks if this feature is supported. + * 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_supports_trampoline_routing(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKPrintableString UnsignedInvoiceRequest_payer_note(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); /** - * Set this feature as optional. + * 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 Bolt11InvoiceFeatures_set_trampoline_routing_optional(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCVec_ThirtyTwoBytesZ InvoiceRequest_chains(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); /** - * Set this feature as required. + * 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 Bolt11InvoiceFeatures_set_trampoline_routing_required(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCOption_CVec_u8ZZ InvoiceRequest_metadata(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); /** - * Checks if this feature is supported. + * The minimum amount required for a successful payment of a single item. */ -MUST_USE_RES bool Bolt11InvoiceFeatures_supports_trampoline_routing(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCOption_AmountZ InvoiceRequest_amount(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); /** - * Checks if this feature is required. + * 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. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES bool InitFeatures_requires_trampoline_routing(const struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKPrintableString InvoiceRequest_description(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); /** - * Checks if this feature is required. + * Features pertaining to the offer. */ -MUST_USE_RES bool NodeFeatures_requires_trampoline_routing(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKOfferFeatures InvoiceRequest_offer_features(const struct LDKInvoiceRequest *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 Bolt11InvoiceFeatures_requires_trampoline_routing(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCOption_u64Z InvoiceRequest_absolute_expiry(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); /** - * Frees any resources used by the ShutdownScript, if is_owned is set and inner is non-NULL. + * 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 ShutdownScript_free(struct LDKShutdownScript this_obj); +MUST_USE_RES struct LDKPrintableString InvoiceRequest_issuer(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); /** - * Creates a copy of the ShutdownScript + * Paths to the recipient originating from publicly reachable nodes. Blinded paths provide + * recipient privacy by obfuscating its node id. */ -struct LDKShutdownScript ShutdownScript_clone(const struct LDKShutdownScript *NONNULL_PTR orig); +MUST_USE_RES struct LDKCVec_BlindedMessagePathZ InvoiceRequest_paths(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); /** - * 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. + * The quantity of items supported. */ -bool ShutdownScript_eq(const struct LDKShutdownScript *NONNULL_PTR a, const struct LDKShutdownScript *NONNULL_PTR b); +MUST_USE_RES struct LDKQuantity InvoiceRequest_supported_quantity(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); /** - * Frees any resources used by the InvalidShutdownScript, if is_owned is set and inner is non-NULL. + * The public key used by the recipient to sign invoices. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void InvalidShutdownScript_free(struct LDKInvalidShutdownScript this_obj); +MUST_USE_RES struct LDKPublicKey InvoiceRequest_signing_pubkey(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); /** - * The script that did not meet the requirements from [BOLT #2]. + * An unpredictable series of bytes, typically containing information about the derivation of + * [`payer_id`]. * - * [BOLT #2]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md + * [`payer_id`]: Self::payer_id */ -struct LDKCVec_u8Z InvalidShutdownScript_get_script(const struct LDKInvalidShutdownScript *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKu8slice InvoiceRequest_payer_metadata(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); /** - * The script that did not meet the requirements from [BOLT #2]. - * - * [BOLT #2]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md + * A chain from [`Offer::chains`] that the offer is valid for. */ -void InvalidShutdownScript_set_script(struct LDKInvalidShutdownScript *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); +MUST_USE_RES struct LDKThirtyTwoBytes InvoiceRequest_chain(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); /** - * Constructs a new InvalidShutdownScript given each field + * 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 */ -MUST_USE_RES struct LDKInvalidShutdownScript InvalidShutdownScript_new(struct LDKCVec_u8Z script_arg); +MUST_USE_RES struct LDKCOption_u64Z InvoiceRequest_amount_msats(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); /** - * Creates a copy of the InvalidShutdownScript + * Features pertaining to requesting an invoice. */ -struct LDKInvalidShutdownScript InvalidShutdownScript_clone(const struct LDKInvalidShutdownScript *NONNULL_PTR orig); +MUST_USE_RES struct LDKInvoiceRequestFeatures InvoiceRequest_invoice_request_features(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); /** - * Serialize the ShutdownScript object into a byte array which can be read by ShutdownScript_read + * The quantity of the offer's item conforming to [`Offer::is_valid_quantity`]. */ -struct LDKCVec_u8Z ShutdownScript_write(const struct LDKShutdownScript *NONNULL_PTR obj); +MUST_USE_RES struct LDKCOption_u64Z InvoiceRequest_quantity(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); /** - * Read a ShutdownScript from a byte array, created by ShutdownScript_write + * A possibly transient pubkey used to sign the invoice request. */ -struct LDKCResult_ShutdownScriptDecodeErrorZ ShutdownScript_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKPublicKey InvoiceRequest_payer_id(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); /** - * Generates a P2WPKH script pubkey from the given [`WPubkeyHash`]. + * 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 struct LDKShutdownScript ShutdownScript_new_p2wpkh(const uint8_t (*pubkey_hash)[20]); +MUST_USE_RES struct LDKPrintableString InvoiceRequest_payer_note(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); /** - * Generates a P2WSH script pubkey from the given [`WScriptHash`]. + * Creates an [`InvoiceBuilder`] for the request with the given required fields and using the + * [`Duration`] since [`std::time::SystemTime::UNIX_EPOCH`] as the creation time. + * + * See [`InvoiceRequest::respond_with_no_std`] for further details where the aforementioned + * creation time is used for the `created_at` parameter. + * + * [`Duration`]: core::time::Duration */ -MUST_USE_RES struct LDKShutdownScript ShutdownScript_new_p2wsh(const uint8_t (*script_hash)[32]); +MUST_USE_RES struct LDKCResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ InvoiceRequest_respond_with(const struct LDKInvoiceRequest *NONNULL_PTR this_arg, struct LDKCVec_BlindedPaymentPathZ payment_paths, struct LDKThirtyTwoBytes payment_hash); /** - * Generates a witness script pubkey from the given segwit version and program. + * Creates an [`InvoiceBuilder`] for the request with the given required fields. * - * Note for version-zero witness scripts you must use [`ShutdownScript::new_p2wpkh`] or - * [`ShutdownScript::new_p2wsh`] instead. + * Unless [`InvoiceBuilder::relative_expiry`] is set, the invoice will expire two hours after + * `created_at`, which is used to set [`Bolt12Invoice::created_at`]. Useful for `no-std` builds + * where [`std::time::SystemTime`] is not available. * - * # Errors + * The caller is expected to remember the preimage of `payment_hash` in order to claim a payment + * for the invoice. * - * This function may return an error if `program` is invalid for the segwit `version`. + * The `payment_paths` parameter is useful for maintaining the payment recipient's privacy. It + * must contain one or more elements ordered from most-preferred to least-preferred, if there's + * a preference. Note, however, that any privacy is lost if a public node id was used for + * [`Offer::signing_pubkey`]. + * + * Errors if the request contains unknown required features. + * + * # Note + * + * If the originating [`Offer`] was created using [`OfferBuilder::deriving_signing_pubkey`], + * then first use [`InvoiceRequest::verify_using_metadata`] or + * [`InvoiceRequest::verify_using_recipient_data`] and then [`VerifiedInvoiceRequest`] methods + * instead. + * + * [`Bolt12Invoice::created_at`]: crate::offers::invoice::Bolt12Invoice::created_at + * [`OfferBuilder::deriving_signing_pubkey`]: crate::offers::offer::OfferBuilder::deriving_signing_pubkey */ -MUST_USE_RES struct LDKCResult_ShutdownScriptInvalidShutdownScriptZ ShutdownScript_new_witness_program(struct LDKWitnessProgram witness_program); +MUST_USE_RES struct LDKCResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ InvoiceRequest_respond_with_no_std(const struct LDKInvoiceRequest *NONNULL_PTR this_arg, struct LDKCVec_BlindedPaymentPathZ payment_paths, struct LDKThirtyTwoBytes payment_hash, uint64_t created_at); /** - * Converts the shutdown script into the underlying [`ScriptBuf`]. + * Verifies that the request was for an offer created using the given key by checking the + * metadata from the offer. + * + * Returns the verified request which contains the derived keys needed to sign a + * [`Bolt12Invoice`] for the request if they could be extracted from the metadata. + * + * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice */ -MUST_USE_RES struct LDKCVec_u8Z ShutdownScript_into_inner(struct LDKShutdownScript this_arg); +MUST_USE_RES struct LDKCResult_VerifiedInvoiceRequestNoneZ InvoiceRequest_verify_using_metadata(struct LDKInvoiceRequest this_arg, const struct LDKExpandedKey *NONNULL_PTR key); /** - * Returns the [`PublicKey`] used for a P2WPKH shutdown script if constructed directly from it. + * Verifies that the request was for an offer created using the given key by checking a nonce + * included with the [`BlindedMessagePath`] for which the request was sent through. * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Returns the verified request which contains the derived keys needed to sign a + * [`Bolt12Invoice`] for the request if they could be extracted from the metadata. + * + * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice */ -MUST_USE_RES struct LDKPublicKey ShutdownScript_as_legacy_pubkey(const struct LDKShutdownScript *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_VerifiedInvoiceRequestNoneZ InvoiceRequest_verify_using_recipient_data(struct LDKInvoiceRequest this_arg, struct LDKNonce nonce, const struct LDKExpandedKey *NONNULL_PTR key); /** - * Returns whether the shutdown script is compatible with the features as defined by BOLT #2. + * Signature of the invoice request using [`payer_id`]. * - * Specifically, checks for compliance with feature `option_shutdown_anysegwit`. + * [`payer_id`]: Self::payer_id */ -MUST_USE_RES bool ShutdownScript_is_compatible(const struct LDKShutdownScript *NONNULL_PTR this_arg, const struct LDKInitFeatures *NONNULL_PTR features); +MUST_USE_RES struct LDKSchnorrSignature InvoiceRequest_signature(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); /** - * Get the string representation of a ShutdownScript object + * 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. */ -struct LDKStr ShutdownScript_to_str(const struct LDKShutdownScript *NONNULL_PTR o); +MUST_USE_RES struct LDKCVec_ThirtyTwoBytesZ VerifiedInvoiceRequest_chains(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); /** - * Frees any resources used by the ChannelId, if is_owned is set and inner is non-NULL. + * 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 ChannelId_free(struct LDKChannelId this_obj); +MUST_USE_RES struct LDKCOption_CVec_u8ZZ VerifiedInvoiceRequest_metadata(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); -const uint8_t (*ChannelId_get_a(const struct LDKChannelId *NONNULL_PTR this_ptr))[32]; +/** + * The minimum amount required for a successful payment of a single item. + */ +MUST_USE_RES struct LDKCOption_AmountZ VerifiedInvoiceRequest_amount(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); -void ChannelId_set_a(struct LDKChannelId *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +/** + * 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. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +MUST_USE_RES struct LDKPrintableString VerifiedInvoiceRequest_description(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); /** - * Constructs a new ChannelId given each field + * Features pertaining to the offer. */ -MUST_USE_RES struct LDKChannelId ChannelId_new(struct LDKThirtyTwoBytes a_arg); +MUST_USE_RES struct LDKOfferFeatures VerifiedInvoiceRequest_offer_features(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); /** - * Creates a copy of the ChannelId + * Duration since the Unix epoch when an invoice should no longer be requested. + * + * If `None`, the offer does not expire. */ -struct LDKChannelId ChannelId_clone(const struct LDKChannelId *NONNULL_PTR orig); +MUST_USE_RES struct LDKCOption_u64Z VerifiedInvoiceRequest_absolute_expiry(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); /** - * Checks if two ChannelIds 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 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 */ -bool ChannelId_eq(const struct LDKChannelId *NONNULL_PTR a, const struct LDKChannelId *NONNULL_PTR b); +MUST_USE_RES struct LDKPrintableString VerifiedInvoiceRequest_issuer(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); /** - * Generates a non-cryptographic 64-bit hash of the ChannelId. + * Paths to the recipient originating from publicly reachable nodes. Blinded paths provide + * recipient privacy by obfuscating its node id. */ -uint64_t ChannelId_hash(const struct LDKChannelId *NONNULL_PTR o); +MUST_USE_RES struct LDKCVec_BlindedMessagePathZ VerifiedInvoiceRequest_paths(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); /** - * Create _v1_ channel ID based on a funding TX ID and output index + * The quantity of items supported. */ -MUST_USE_RES struct LDKChannelId ChannelId_v1_from_funding_txid(const uint8_t (*txid)[32], uint16_t output_index); +MUST_USE_RES struct LDKQuantity VerifiedInvoiceRequest_supported_quantity(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); /** - * Create _v1_ channel ID from a funding tx outpoint + * The public key used by the recipient to sign invoices. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKChannelId ChannelId_v1_from_funding_outpoint(struct LDKOutPoint outpoint); +MUST_USE_RES struct LDKPublicKey VerifiedInvoiceRequest_signing_pubkey(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); /** - * Create a _temporary_ channel ID randomly, based on an entropy source. + * An unpredictable series of bytes, typically containing information about the derivation of + * [`payer_id`]. + * + * [`payer_id`]: Self::payer_id */ -MUST_USE_RES struct LDKChannelId ChannelId_temporary_from_entropy_source(const struct LDKEntropySource *NONNULL_PTR entropy_source); +MUST_USE_RES struct LDKu8slice VerifiedInvoiceRequest_payer_metadata(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); /** - * Generic constructor; create a new channel ID from the provided data. - * Use a more specific `*_from_*` constructor when possible. + * A chain from [`Offer::chains`] that the offer is valid for. */ -MUST_USE_RES struct LDKChannelId ChannelId_from_bytes(struct LDKThirtyTwoBytes data); +MUST_USE_RES struct LDKThirtyTwoBytes VerifiedInvoiceRequest_chain(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); /** - * Create a channel ID consisting of all-zeros data (e.g. when uninitialized or a placeholder). + * 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 */ -MUST_USE_RES struct LDKChannelId ChannelId_new_zero(void); +MUST_USE_RES struct LDKCOption_u64Z VerifiedInvoiceRequest_amount_msats(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); /** - * Check whether ID is consisting of all zeros (uninitialized) + * Features pertaining to requesting an invoice. */ -MUST_USE_RES bool ChannelId_is_zero(const struct LDKChannelId *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKInvoiceRequestFeatures VerifiedInvoiceRequest_invoice_request_features(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); /** - * Create _v2_ channel ID by concatenating the holder revocation basepoint with the counterparty - * revocation basepoint and hashing the result. The basepoints will be concatenated in increasing - * sorted order. + * The quantity of the offer's item conforming to [`Offer::is_valid_quantity`]. */ -MUST_USE_RES struct LDKChannelId ChannelId_v2_from_revocation_basepoints(const struct LDKRevocationBasepoint *NONNULL_PTR ours, const struct LDKRevocationBasepoint *NONNULL_PTR theirs); +MUST_USE_RES struct LDKCOption_u64Z VerifiedInvoiceRequest_quantity(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); /** - * Create temporary _v2_ channel ID by concatenating a zeroed out basepoint with the holder - * revocation basepoint and hashing the result. + * A possibly transient pubkey used to sign the invoice request. */ -MUST_USE_RES struct LDKChannelId ChannelId_temporary_v2_from_revocation_basepoint(const struct LDKRevocationBasepoint *NONNULL_PTR our_revocation_basepoint); +MUST_USE_RES struct LDKPublicKey VerifiedInvoiceRequest_payer_id(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); /** - * Serialize the ChannelId object into a byte array which can be read by ChannelId_read + * 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 */ -struct LDKCVec_u8Z ChannelId_write(const struct LDKChannelId *NONNULL_PTR obj); +MUST_USE_RES struct LDKPrintableString VerifiedInvoiceRequest_payer_note(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); /** - * Read a ChannelId from a byte array, created by ChannelId_write + * Creates an [`InvoiceBuilder`] for the request with the given required fields and using the + * [`Duration`] since [`std::time::SystemTime::UNIX_EPOCH`] as the creation time. + * + * See [`InvoiceRequest::respond_with_no_std`] for further details where the aforementioned + * creation time is used for the `created_at` parameter. + * + * [`Duration`]: core::time::Duration */ -struct LDKCResult_ChannelIdDecodeErrorZ ChannelId_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKCResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ VerifiedInvoiceRequest_respond_with(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg, struct LDKCVec_BlindedPaymentPathZ payment_paths, struct LDKThirtyTwoBytes payment_hash); /** - * Get the string representation of a ChannelId object + * Creates an [`InvoiceBuilder`] for the request with the given required fields. + * + * Unless [`InvoiceBuilder::relative_expiry`] is set, the invoice will expire two hours after + * `created_at`, which is used to set [`Bolt12Invoice::created_at`]. Useful for `no-std` builds + * where [`std::time::SystemTime`] is not available. + * + * The caller is expected to remember the preimage of `payment_hash` in order to claim a payment + * for the invoice. + * + * The `payment_paths` parameter is useful for maintaining the payment recipient's privacy. It + * must contain one or more elements ordered from most-preferred to least-preferred, if there's + * a preference. Note, however, that any privacy is lost if a public node id was used for + * [`Offer::signing_pubkey`]. + * + * Errors if the request contains unknown required features. + * + * # Note + * + * If the originating [`Offer`] was created using [`OfferBuilder::deriving_signing_pubkey`], + * then first use [`InvoiceRequest::verify_using_metadata`] or + * [`InvoiceRequest::verify_using_recipient_data`] and then [`VerifiedInvoiceRequest`] methods + * instead. + * + * [`Bolt12Invoice::created_at`]: crate::offers::invoice::Bolt12Invoice::created_at + * [`OfferBuilder::deriving_signing_pubkey`]: crate::offers::offer::OfferBuilder::deriving_signing_pubkey */ -struct LDKStr ChannelId_to_str(const struct LDKChannelId *NONNULL_PTR o); +MUST_USE_RES struct LDKCResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ VerifiedInvoiceRequest_respond_with_no_std(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg, struct LDKCVec_BlindedPaymentPathZ payment_paths, struct LDKThirtyTwoBytes payment_hash, uint64_t created_at); /** - * Frees any resources used by the Retry + * Creates an [`InvoiceBuilder`] for the request using the given required fields and that uses + * derived signing keys from the originating [`Offer`] to sign the [`Bolt12Invoice`]. Must use + * the same [`ExpandedKey`] as the one used to create the offer. + * + * See [`InvoiceRequest::respond_with`] for further details. + * + * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice */ -void Retry_free(struct LDKRetry this_ptr); +MUST_USE_RES struct LDKCResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ VerifiedInvoiceRequest_respond_using_derived_keys(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg, struct LDKCVec_BlindedPaymentPathZ payment_paths, struct LDKThirtyTwoBytes payment_hash); /** - * Creates a copy of the Retry + * Creates an [`InvoiceBuilder`] for the request using the given required fields and that uses + * derived signing keys from the originating [`Offer`] to sign the [`Bolt12Invoice`]. Must use + * the same [`ExpandedKey`] as the one used to create the offer. + * + * See [`InvoiceRequest::respond_with_no_std`] for further details. + * + * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice */ -struct LDKRetry Retry_clone(const struct LDKRetry *NONNULL_PTR orig); +MUST_USE_RES struct LDKCResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ VerifiedInvoiceRequest_respond_using_derived_keys_no_std(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg, struct LDKCVec_BlindedPaymentPathZ payment_paths, struct LDKThirtyTwoBytes payment_hash, uint64_t created_at); /** - * Utility method to constructs a new Attempts-variant Retry + * Serialize the UnsignedInvoiceRequest object into a byte array which can be read by UnsignedInvoiceRequest_read */ -struct LDKRetry Retry_attempts(uint32_t a); +struct LDKCVec_u8Z UnsignedInvoiceRequest_write(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR obj); /** - * Utility method to constructs a new Timeout-variant Retry + * Serialize the InvoiceRequest object into a byte array which can be read by InvoiceRequest_read */ -struct LDKRetry Retry_timeout(uint64_t a); +struct LDKCVec_u8Z InvoiceRequest_write(const struct LDKInvoiceRequest *NONNULL_PTR obj); /** - * Checks if two Retrys contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Frees any resources used by the InvoiceRequestFields, if is_owned is set and inner is non-NULL. */ -bool Retry_eq(const struct LDKRetry *NONNULL_PTR a, const struct LDKRetry *NONNULL_PTR b); +void InvoiceRequestFields_free(struct LDKInvoiceRequestFields this_obj); /** - * Generates a non-cryptographic 64-bit hash of the Retry. + * A possibly transient pubkey used to sign the invoice request. */ -uint64_t Retry_hash(const struct LDKRetry *NONNULL_PTR o); +struct LDKPublicKey InvoiceRequestFields_get_payer_id(const struct LDKInvoiceRequestFields *NONNULL_PTR this_ptr); /** - * Serialize the Retry object into a byte array which can be read by Retry_read + * A possibly transient pubkey used to sign the invoice request. */ -struct LDKCVec_u8Z Retry_write(const struct LDKRetry *NONNULL_PTR obj); +void InvoiceRequestFields_set_payer_id(struct LDKInvoiceRequestFields *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Read a Retry from a byte array, created by Retry_write + * The quantity of the offer's item conforming to [`Offer::is_valid_quantity`]. */ -struct LDKCResult_RetryDecodeErrorZ Retry_read(struct LDKu8slice ser); +struct LDKCOption_u64Z InvoiceRequestFields_get_quantity(const struct LDKInvoiceRequestFields *NONNULL_PTR this_ptr); /** - * Creates a copy of the RetryableSendFailure + * The quantity of the offer's item conforming to [`Offer::is_valid_quantity`]. */ -enum LDKRetryableSendFailure RetryableSendFailure_clone(const enum LDKRetryableSendFailure *NONNULL_PTR orig); +void InvoiceRequestFields_set_quantity(struct LDKInvoiceRequestFields *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); /** - * Utility method to constructs a new PaymentExpired-variant RetryableSendFailure + * A payer-provided note which will be seen by the recipient and reflected back in the invoice + * response. Truncated to [`PAYER_NOTE_LIMIT`] characters. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -enum LDKRetryableSendFailure RetryableSendFailure_payment_expired(void); +struct LDKUntrustedString InvoiceRequestFields_get_payer_note_truncated(const struct LDKInvoiceRequestFields *NONNULL_PTR this_ptr); /** - * Utility method to constructs a new RouteNotFound-variant RetryableSendFailure + * A payer-provided note which will be seen by the recipient and reflected back in the invoice + * response. Truncated to [`PAYER_NOTE_LIMIT`] characters. + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -enum LDKRetryableSendFailure RetryableSendFailure_route_not_found(void); +void InvoiceRequestFields_set_payer_note_truncated(struct LDKInvoiceRequestFields *NONNULL_PTR this_ptr, struct LDKUntrustedString val); /** - * Utility method to constructs a new DuplicatePayment-variant RetryableSendFailure + * Constructs a new InvoiceRequestFields given each field + * + * Note that payer_note_truncated_arg (or a relevant inner pointer) may be NULL or all-0s to represent None */ -enum LDKRetryableSendFailure RetryableSendFailure_duplicate_payment(void); +MUST_USE_RES struct LDKInvoiceRequestFields InvoiceRequestFields_new(struct LDKPublicKey payer_id_arg, struct LDKCOption_u64Z quantity_arg, struct LDKUntrustedString payer_note_truncated_arg); /** - * Checks if two RetryableSendFailures contain equal inner contents. + * Creates a copy of the InvoiceRequestFields + */ +struct LDKInvoiceRequestFields InvoiceRequestFields_clone(const struct LDKInvoiceRequestFields *NONNULL_PTR orig); + +/** + * Checks if two InvoiceRequestFieldss 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 RetryableSendFailure_eq(const enum LDKRetryableSendFailure *NONNULL_PTR a, const enum LDKRetryableSendFailure *NONNULL_PTR b); +bool InvoiceRequestFields_eq(const struct LDKInvoiceRequestFields *NONNULL_PTR a, const struct LDKInvoiceRequestFields *NONNULL_PTR b); /** - * Frees any resources used by the PaymentSendFailure + * Serialize the InvoiceRequestFields object into a byte array which can be read by InvoiceRequestFields_read */ -void PaymentSendFailure_free(struct LDKPaymentSendFailure this_ptr); +struct LDKCVec_u8Z InvoiceRequestFields_write(const struct LDKInvoiceRequestFields *NONNULL_PTR obj); /** - * Creates a copy of the PaymentSendFailure + * Read a InvoiceRequestFields from a byte array, created by InvoiceRequestFields_write */ -struct LDKPaymentSendFailure PaymentSendFailure_clone(const struct LDKPaymentSendFailure *NONNULL_PTR orig); +struct LDKCResult_InvoiceRequestFieldsDecodeErrorZ InvoiceRequestFields_read(struct LDKu8slice ser); /** - * Utility method to constructs a new ParameterError-variant PaymentSendFailure + * Frees any resources used by the TaggedHash, if is_owned is set and inner is non-NULL. */ -struct LDKPaymentSendFailure PaymentSendFailure_parameter_error(struct LDKAPIError a); +void TaggedHash_free(struct LDKTaggedHash this_obj); /** - * Utility method to constructs a new PathParameterError-variant PaymentSendFailure + * Creates a copy of the TaggedHash */ -struct LDKPaymentSendFailure PaymentSendFailure_path_parameter_error(struct LDKCVec_CResult_NoneAPIErrorZZ a); +struct LDKTaggedHash TaggedHash_clone(const struct LDKTaggedHash *NONNULL_PTR orig); /** - * Utility method to constructs a new AllFailedResendSafe-variant PaymentSendFailure + * Returns the digest to sign. */ -struct LDKPaymentSendFailure PaymentSendFailure_all_failed_resend_safe(struct LDKCVec_APIErrorZ a); +MUST_USE_RES const uint8_t (*TaggedHash_as_digest(const struct LDKTaggedHash *NONNULL_PTR this_arg))[32]; /** - * Utility method to constructs a new DuplicatePayment-variant PaymentSendFailure + * Returns the tag used in the tagged hash. */ -struct LDKPaymentSendFailure PaymentSendFailure_duplicate_payment(void); +MUST_USE_RES struct LDKStr TaggedHash_tag(const struct LDKTaggedHash *NONNULL_PTR this_arg); /** - * Utility method to constructs a new PartialFailure-variant PaymentSendFailure + * Returns the merkle root used in the tagged hash. */ -struct LDKPaymentSendFailure PaymentSendFailure_partial_failure(struct LDKCVec_CResult_NoneAPIErrorZZ results, struct LDKRouteParameters failed_paths_retry, struct LDKThirtyTwoBytes payment_id); +MUST_USE_RES struct LDKThirtyTwoBytes TaggedHash_merkle_root(const struct LDKTaggedHash *NONNULL_PTR this_arg); /** - * Checks if two PaymentSendFailures contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Frees any resources used by the SignError */ -bool PaymentSendFailure_eq(const struct LDKPaymentSendFailure *NONNULL_PTR a, const struct LDKPaymentSendFailure *NONNULL_PTR b); +void SignError_free(struct LDKSignError this_ptr); /** - * Frees any resources used by the ProbeSendFailure + * Creates a copy of the SignError */ -void ProbeSendFailure_free(struct LDKProbeSendFailure this_ptr); +struct LDKSignError SignError_clone(const struct LDKSignError *NONNULL_PTR orig); /** - * Creates a copy of the ProbeSendFailure + * Utility method to constructs a new Signing-variant SignError */ -struct LDKProbeSendFailure ProbeSendFailure_clone(const struct LDKProbeSendFailure *NONNULL_PTR orig); +struct LDKSignError SignError_signing(void); /** - * Utility method to constructs a new RouteNotFound-variant ProbeSendFailure + * Utility method to constructs a new Verification-variant SignError */ -struct LDKProbeSendFailure ProbeSendFailure_route_not_found(void); +struct LDKSignError SignError_verification(enum LDKSecp256k1Error a); /** - * Utility method to constructs a new SendingFailed-variant ProbeSendFailure + * Frees any resources used by the Nonce, if is_owned is set and inner is non-NULL. */ -struct LDKProbeSendFailure ProbeSendFailure_sending_failed(struct LDKPaymentSendFailure a); +void Nonce_free(struct LDKNonce this_obj); /** - * Checks if two ProbeSendFailures contain equal inner contents. + * Creates a copy of the Nonce + */ +struct LDKNonce Nonce_clone(const struct LDKNonce *NONNULL_PTR orig); + +/** + * Checks if two Nonces 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 ProbeSendFailure_eq(const struct LDKProbeSendFailure *NONNULL_PTR a, const struct LDKProbeSendFailure *NONNULL_PTR b); +bool Nonce_eq(const struct LDKNonce *NONNULL_PTR a, const struct LDKNonce *NONNULL_PTR b); /** - * Frees any resources used by the RecipientOnionFields, if is_owned is set and inner is non-NULL. + * Creates a `Nonce` from the given [`EntropySource`]. */ -void RecipientOnionFields_free(struct LDKRecipientOnionFields this_obj); +MUST_USE_RES struct LDKNonce Nonce_from_entropy_source(struct LDKEntropySource entropy_source); /** - * 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. + * Returns a slice of the underlying bytes of size [`Nonce::LENGTH`]. */ -struct LDKCOption_ThirtyTwoBytesZ RecipientOnionFields_get_payment_secret(const struct LDKRecipientOnionFields *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKu8slice Nonce_as_slice(const struct LDKNonce *NONNULL_PTR this_arg); /** - * 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. + * Serialize the Nonce object into a byte array which can be read by Nonce_read */ -void RecipientOnionFields_set_payment_secret(struct LDKRecipientOnionFields *NONNULL_PTR this_ptr, struct LDKCOption_ThirtyTwoBytesZ val); +struct LDKCVec_u8Z Nonce_write(const struct LDKNonce *NONNULL_PTR obj); /** - * 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. + * Read a Nonce from a byte array, created by Nonce_write */ -struct LDKCOption_CVec_u8ZZ RecipientOnionFields_get_payment_metadata(const struct LDKRecipientOnionFields *NONNULL_PTR this_ptr); +struct LDKCResult_NonceDecodeErrorZ Nonce_read(struct LDKu8slice ser); /** - * 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. + * Frees any resources used by the Bolt12ParseError, if is_owned is set and inner is non-NULL. */ -void RecipientOnionFields_set_payment_metadata(struct LDKRecipientOnionFields *NONNULL_PTR this_ptr, struct LDKCOption_CVec_u8ZZ val); +void Bolt12ParseError_free(struct LDKBolt12ParseError this_obj); /** - * Creates a copy of the RecipientOnionFields + * Creates a copy of the Bolt12ParseError */ -struct LDKRecipientOnionFields RecipientOnionFields_clone(const struct LDKRecipientOnionFields *NONNULL_PTR orig); +struct LDKBolt12ParseError Bolt12ParseError_clone(const struct LDKBolt12ParseError *NONNULL_PTR orig); /** - * 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. + * Creates a copy of the Bolt12SemanticError */ -bool RecipientOnionFields_eq(const struct LDKRecipientOnionFields *NONNULL_PTR a, const struct LDKRecipientOnionFields *NONNULL_PTR b); +enum LDKBolt12SemanticError Bolt12SemanticError_clone(const enum LDKBolt12SemanticError *NONNULL_PTR orig); /** - * Serialize the RecipientOnionFields object into a byte array which can be read by RecipientOnionFields_read + * Utility method to constructs a new AlreadyExpired-variant Bolt12SemanticError */ -struct LDKCVec_u8Z RecipientOnionFields_write(const struct LDKRecipientOnionFields *NONNULL_PTR obj); +enum LDKBolt12SemanticError Bolt12SemanticError_already_expired(void); /** - * Read a RecipientOnionFields from a byte array, created by RecipientOnionFields_write + * Utility method to constructs a new UnsupportedChain-variant Bolt12SemanticError */ -struct LDKCResult_RecipientOnionFieldsDecodeErrorZ RecipientOnionFields_read(struct LDKu8slice ser); +enum LDKBolt12SemanticError Bolt12SemanticError_unsupported_chain(void); /** - * 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. + * Utility method to constructs a new UnexpectedChain-variant Bolt12SemanticError */ -MUST_USE_RES struct LDKRecipientOnionFields RecipientOnionFields_secret_only(struct LDKThirtyTwoBytes payment_secret); +enum LDKBolt12SemanticError Bolt12SemanticError_unexpected_chain(void); /** - * 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 + * Utility method to constructs a new MissingAmount-variant Bolt12SemanticError */ -MUST_USE_RES struct LDKRecipientOnionFields RecipientOnionFields_spontaneous_empty(void); +enum LDKBolt12SemanticError Bolt12SemanticError_missing_amount(void); /** - * Creates a new [`RecipientOnionFields`] from an existing one, adding custom TLVs. Each - * TLV is provided as a `(u64, Vec)` for the type number and serialized value - * respectively. TLV type numbers must be unique and within the range - * reserved for custom types, i.e. >= 2^16, otherwise this method will return `Err(())`. - * - * This method will also error for types in the experimental range which have been - * standardized within the protocol, which only includes 5482373484 (keysend) for now. - * - * See [`Self::custom_tlvs`] for more info. + * Utility method to constructs a new InvalidAmount-variant Bolt12SemanticError */ -MUST_USE_RES struct LDKCResult_RecipientOnionFieldsNoneZ RecipientOnionFields_with_custom_tlvs(struct LDKRecipientOnionFields this_arg, struct LDKCVec_C2Tuple_u64CVec_u8ZZZ custom_tlvs); +enum LDKBolt12SemanticError Bolt12SemanticError_invalid_amount(void); /** - * Gets the custom TLVs that will be sent or have been received. - * - * Custom TLVs allow sending extra application-specific data with a payment. They provide - * additional flexibility on top of payment metadata, as while other implementations may - * require `payment_metadata` to reflect metadata provided in an invoice, custom TLVs - * do not have this restriction. - * - * Note that if this field is non-empty, it will contain strictly increasing TLVs, each - * represented by a `(u64, Vec)` for its type number and serialized value respectively. - * This is validated when setting this field using [`Self::with_custom_tlvs`]. + * Utility method to constructs a new InsufficientAmount-variant Bolt12SemanticError */ -MUST_USE_RES struct LDKCVec_C2Tuple_u64CVec_u8ZZZ RecipientOnionFields_custom_tlvs(const struct LDKRecipientOnionFields *NONNULL_PTR this_arg); +enum LDKBolt12SemanticError Bolt12SemanticError_insufficient_amount(void); /** - * Calls the free function if one is set + * Utility method to constructs a new UnexpectedAmount-variant Bolt12SemanticError */ -void CustomMessageReader_free(struct LDKCustomMessageReader this_ptr); +enum LDKBolt12SemanticError Bolt12SemanticError_unexpected_amount(void); /** - * Creates a copy of a Type + * Utility method to constructs a new UnsupportedCurrency-variant Bolt12SemanticError */ -struct LDKType Type_clone(const struct LDKType *NONNULL_PTR orig); +enum LDKBolt12SemanticError Bolt12SemanticError_unsupported_currency(void); /** - * Calls the free function if one is set + * Utility method to constructs a new UnknownRequiredFeatures-variant Bolt12SemanticError */ -void Type_free(struct LDKType this_ptr); +enum LDKBolt12SemanticError Bolt12SemanticError_unknown_required_features(void); /** - * Frees any resources used by the OfferId, if is_owned is set and inner is non-NULL. + * Utility method to constructs a new UnexpectedFeatures-variant Bolt12SemanticError */ -void OfferId_free(struct LDKOfferId this_obj); - -const uint8_t (*OfferId_get_a(const struct LDKOfferId *NONNULL_PTR this_ptr))[32]; +enum LDKBolt12SemanticError Bolt12SemanticError_unexpected_features(void); -void OfferId_set_a(struct LDKOfferId *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +/** + * Utility method to constructs a new MissingDescription-variant Bolt12SemanticError + */ +enum LDKBolt12SemanticError Bolt12SemanticError_missing_description(void); /** - * Constructs a new OfferId given each field + * Utility method to constructs a new MissingSigningPubkey-variant Bolt12SemanticError */ -MUST_USE_RES struct LDKOfferId OfferId_new(struct LDKThirtyTwoBytes a_arg); +enum LDKBolt12SemanticError Bolt12SemanticError_missing_signing_pubkey(void); /** - * Creates a copy of the OfferId + * Utility method to constructs a new InvalidSigningPubkey-variant Bolt12SemanticError */ -struct LDKOfferId OfferId_clone(const struct LDKOfferId *NONNULL_PTR orig); +enum LDKBolt12SemanticError Bolt12SemanticError_invalid_signing_pubkey(void); /** - * Checks if two OfferIds 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 UnexpectedSigningPubkey-variant Bolt12SemanticError */ -bool OfferId_eq(const struct LDKOfferId *NONNULL_PTR a, const struct LDKOfferId *NONNULL_PTR b); +enum LDKBolt12SemanticError Bolt12SemanticError_unexpected_signing_pubkey(void); /** - * Serialize the OfferId object into a byte array which can be read by OfferId_read + * Utility method to constructs a new MissingQuantity-variant Bolt12SemanticError */ -struct LDKCVec_u8Z OfferId_write(const struct LDKOfferId *NONNULL_PTR obj); +enum LDKBolt12SemanticError Bolt12SemanticError_missing_quantity(void); /** - * Read a OfferId from a byte array, created by OfferId_write + * Utility method to constructs a new InvalidQuantity-variant Bolt12SemanticError */ -struct LDKCResult_OfferIdDecodeErrorZ OfferId_read(struct LDKu8slice ser); +enum LDKBolt12SemanticError Bolt12SemanticError_invalid_quantity(void); /** - * Frees any resources used by the OfferWithExplicitMetadataBuilder, if is_owned is set and inner is non-NULL. + * Utility method to constructs a new UnexpectedQuantity-variant Bolt12SemanticError */ -void OfferWithExplicitMetadataBuilder_free(struct LDKOfferWithExplicitMetadataBuilder this_obj); +enum LDKBolt12SemanticError Bolt12SemanticError_unexpected_quantity(void); /** - * Creates a copy of the OfferWithExplicitMetadataBuilder + * Utility method to constructs a new InvalidMetadata-variant Bolt12SemanticError */ -struct LDKOfferWithExplicitMetadataBuilder OfferWithExplicitMetadataBuilder_clone(const struct LDKOfferWithExplicitMetadataBuilder *NONNULL_PTR orig); +enum LDKBolt12SemanticError Bolt12SemanticError_invalid_metadata(void); /** - * Frees any resources used by the OfferWithDerivedMetadataBuilder, if is_owned is set and inner is non-NULL. + * Utility method to constructs a new UnexpectedMetadata-variant Bolt12SemanticError */ -void OfferWithDerivedMetadataBuilder_free(struct LDKOfferWithDerivedMetadataBuilder this_obj); +enum LDKBolt12SemanticError Bolt12SemanticError_unexpected_metadata(void); /** - * Creates a copy of the OfferWithDerivedMetadataBuilder + * Utility method to constructs a new MissingPayerMetadata-variant Bolt12SemanticError */ -struct LDKOfferWithDerivedMetadataBuilder OfferWithDerivedMetadataBuilder_clone(const struct LDKOfferWithDerivedMetadataBuilder *NONNULL_PTR orig); +enum LDKBolt12SemanticError Bolt12SemanticError_missing_payer_metadata(void); /** - * Creates a new builder for an offer using the [`Offer::signing_pubkey`] for signing invoices. - * The associated secret key must be remembered while the offer is valid. - * - * Use a different pubkey per offer to avoid correlating offers. - * - * # Note - * - * If constructing an [`Offer`] for use with a [`ChannelManager`], use - * [`ChannelManager::create_offer_builder`] instead of [`OfferBuilder::new`]. - * - * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager - * [`ChannelManager::create_offer_builder`]: crate::ln::channelmanager::ChannelManager::create_offer_builder + * Utility method to constructs a new MissingPayerId-variant Bolt12SemanticError */ -MUST_USE_RES struct LDKOfferWithExplicitMetadataBuilder OfferWithExplicitMetadataBuilder_new(struct LDKPublicKey signing_pubkey); +enum LDKBolt12SemanticError Bolt12SemanticError_missing_payer_id(void); /** - * Sets the [`Offer::metadata`] to the given bytes. - * - * Successive calls to this method will override the previous setting. + * Utility method to constructs a new DuplicatePaymentId-variant Bolt12SemanticError */ -MUST_USE_RES struct LDKCResult_NoneBolt12SemanticErrorZ OfferWithExplicitMetadataBuilder_metadata(struct LDKOfferWithExplicitMetadataBuilder this_arg, struct LDKCVec_u8Z metadata); +enum LDKBolt12SemanticError Bolt12SemanticError_duplicate_payment_id(void); /** - * Adds the chain hash of the given [`Network`] to [`Offer::chains`]. If not called, - * the chain hash of [`Network::Bitcoin`] is assumed to be the only one supported. - * - * See [`Offer::chains`] on how this relates to the payment currency. - * - * Successive calls to this method will add another chain hash. + * Utility method to constructs a new MissingPaths-variant Bolt12SemanticError */ -MUST_USE_RES void OfferWithExplicitMetadataBuilder_chain(struct LDKOfferWithExplicitMetadataBuilder this_arg, enum LDKNetwork network); +enum LDKBolt12SemanticError Bolt12SemanticError_missing_paths(void); /** - * Sets the [`Offer::amount`] as an [`Amount::Bitcoin`]. - * - * Successive calls to this method will override the previous setting. + * Utility method to constructs a new UnexpectedPaths-variant Bolt12SemanticError */ -MUST_USE_RES void OfferWithExplicitMetadataBuilder_amount_msats(struct LDKOfferWithExplicitMetadataBuilder this_arg, uint64_t amount_msats); +enum LDKBolt12SemanticError Bolt12SemanticError_unexpected_paths(void); /** - * Sets the [`Offer::absolute_expiry`] as seconds since the Unix epoch. Any expiry that has - * already passed is valid and can be checked for using [`Offer::is_expired`]. - * - * Successive calls to this method will override the previous setting. + * Utility method to constructs a new InvalidPayInfo-variant Bolt12SemanticError */ -MUST_USE_RES void OfferWithExplicitMetadataBuilder_absolute_expiry(struct LDKOfferWithExplicitMetadataBuilder this_arg, uint64_t absolute_expiry); +enum LDKBolt12SemanticError Bolt12SemanticError_invalid_pay_info(void); /** - * Sets the [`Offer::description`]. - * - * Successive calls to this method will override the previous setting. + * Utility method to constructs a new MissingCreationTime-variant Bolt12SemanticError */ -MUST_USE_RES void OfferWithExplicitMetadataBuilder_description(struct LDKOfferWithExplicitMetadataBuilder this_arg, struct LDKStr description); +enum LDKBolt12SemanticError Bolt12SemanticError_missing_creation_time(void); /** - * Sets the [`Offer::issuer`]. - * - * Successive calls to this method will override the previous setting. + * Utility method to constructs a new MissingPaymentHash-variant Bolt12SemanticError */ -MUST_USE_RES void OfferWithExplicitMetadataBuilder_issuer(struct LDKOfferWithExplicitMetadataBuilder this_arg, struct LDKStr issuer); +enum LDKBolt12SemanticError Bolt12SemanticError_missing_payment_hash(void); /** - * Adds a blinded path to [`Offer::paths`]. Must include at least one path if only connected by - * private channels or if [`Offer::signing_pubkey`] is not a public node id. - * - * Successive calls to this method will add another blinded path. Caller is responsible for not - * adding duplicate paths. + * Utility method to constructs a new UnexpectedPaymentHash-variant Bolt12SemanticError */ -MUST_USE_RES void OfferWithExplicitMetadataBuilder_path(struct LDKOfferWithExplicitMetadataBuilder this_arg, struct LDKBlindedPath path); +enum LDKBolt12SemanticError Bolt12SemanticError_unexpected_payment_hash(void); /** - * Sets the quantity of items for [`Offer::supported_quantity`]. If not called, defaults to - * [`Quantity::One`]. - * - * Successive calls to this method will override the previous setting. + * Utility method to constructs a new MissingSignature-variant Bolt12SemanticError */ -MUST_USE_RES void OfferWithExplicitMetadataBuilder_supported_quantity(struct LDKOfferWithExplicitMetadataBuilder this_arg, struct LDKQuantity quantity); +enum LDKBolt12SemanticError Bolt12SemanticError_missing_signature(void); /** - * Builds an [`Offer`] from the builder's settings. + * Frees any resources used by the RefundMaybeWithDerivedMetadataBuilder, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKCResult_OfferBolt12SemanticErrorZ OfferWithExplicitMetadataBuilder_build(struct LDKOfferWithExplicitMetadataBuilder this_arg); +void RefundMaybeWithDerivedMetadataBuilder_free(struct LDKRefundMaybeWithDerivedMetadataBuilder this_obj); /** - * Similar to [`OfferBuilder::new`] except, if [`OfferBuilder::path`] is called, the signing - * pubkey is derived from the given [`ExpandedKey`] and [`EntropySource`]. This provides - * recipient privacy by using a different signing pubkey for each offer. Otherwise, the - * provided `node_id` is used for the signing pubkey. - * - * Also, sets the metadata when [`OfferBuilder::build`] is called such that it can be used by - * [`InvoiceRequest::verify`] to determine if the request was produced for the offer given an - * [`ExpandedKey`]. - * - * [`InvoiceRequest::verify`]: crate::offers::invoice_request::InvoiceRequest::verify - * [`ExpandedKey`]: crate::ln::inbound_payment::ExpandedKey + * Creates a copy of the RefundMaybeWithDerivedMetadataBuilder */ -MUST_USE_RES struct LDKOfferWithDerivedMetadataBuilder OfferWithDerivedMetadataBuilder_deriving_signing_pubkey(struct LDKPublicKey node_id, const struct LDKExpandedKey *NONNULL_PTR expanded_key, struct LDKEntropySource entropy_source); +struct LDKRefundMaybeWithDerivedMetadataBuilder RefundMaybeWithDerivedMetadataBuilder_clone(const struct LDKRefundMaybeWithDerivedMetadataBuilder *NONNULL_PTR orig); /** - * Adds the chain hash of the given [`Network`] to [`Offer::chains`]. If not called, - * the chain hash of [`Network::Bitcoin`] is assumed to be the only one supported. + * Creates a new builder for a refund using the [`Refund::payer_id`] for the public node id to + * send to if no [`Refund::paths`] are set. Otherwise, it may be a transient pubkey. * - * See [`Offer::chains`] on how this relates to the payment currency. + * Additionally, sets the required (empty) [`Refund::description`], [`Refund::payer_metadata`], + * and [`Refund::amount_msats`]. * - * Successive calls to this method will add another chain hash. + * # Note + * + * If constructing a [`Refund`] for use with a [`ChannelManager`], use + * [`ChannelManager::create_refund_builder`] instead of [`RefundBuilder::new`]. + * + * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager + * [`ChannelManager::create_refund_builder`]: crate::ln::channelmanager::ChannelManager::create_refund_builder */ -MUST_USE_RES void OfferWithDerivedMetadataBuilder_chain(struct LDKOfferWithDerivedMetadataBuilder this_arg, enum LDKNetwork network); +MUST_USE_RES struct LDKCResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ RefundMaybeWithDerivedMetadataBuilder_new(struct LDKCVec_u8Z metadata, struct LDKPublicKey payer_id, uint64_t amount_msats); /** - * Sets the [`Offer::amount`] as an [`Amount::Bitcoin`]. + * Similar to [`RefundBuilder::new`] except, if [`RefundBuilder::path`] is called, the payer id + * is derived from the given [`ExpandedKey`] and nonce. This provides sender privacy by using a + * different payer id for each refund, assuming a different nonce is used. Otherwise, the + * provided `node_id` is used for the payer id. * - * Successive calls to this method will override the previous setting. + * Also, sets the metadata when [`RefundBuilder::build`] is called such that it can be used by + * [`Bolt12Invoice::verify_using_metadata`] to determine if the invoice was produced for the + * refund given an [`ExpandedKey`]. However, if [`RefundBuilder::path`] is called, then the + * metadata must be included in each [`BlindedMessagePath`] instead. In this case, use + * [`Bolt12Invoice::verify_using_payer_data`]. + * + * The `payment_id` is encrypted in the metadata and should be unique. This ensures that only + * one invoice will be paid for the refund and that payments can be uniquely identified. + * + * [`Bolt12Invoice::verify_using_metadata`]: crate::offers::invoice::Bolt12Invoice::verify_using_metadata + * [`Bolt12Invoice::verify_using_payer_data`]: crate::offers::invoice::Bolt12Invoice::verify_using_payer_data + * [`ExpandedKey`]: crate::ln::inbound_payment::ExpandedKey */ -MUST_USE_RES void OfferWithDerivedMetadataBuilder_amount_msats(struct LDKOfferWithDerivedMetadataBuilder this_arg, uint64_t amount_msats); +MUST_USE_RES struct LDKCResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ RefundMaybeWithDerivedMetadataBuilder_deriving_payer_id(struct LDKPublicKey node_id, const struct LDKExpandedKey *NONNULL_PTR expanded_key, struct LDKNonce nonce, uint64_t amount_msats, struct LDKThirtyTwoBytes payment_id); /** - * Sets the [`Offer::absolute_expiry`] as seconds since the Unix epoch. Any expiry that has - * already passed is valid and can be checked for using [`Offer::is_expired`]. + * Sets the [`Refund::description`]. * * Successive calls to this method will override the previous setting. */ -MUST_USE_RES void OfferWithDerivedMetadataBuilder_absolute_expiry(struct LDKOfferWithDerivedMetadataBuilder this_arg, uint64_t absolute_expiry); +MUST_USE_RES void RefundMaybeWithDerivedMetadataBuilder_description(struct LDKRefundMaybeWithDerivedMetadataBuilder this_arg, struct LDKStr description); /** - * Sets the [`Offer::description`]. + * Sets the [`Refund::absolute_expiry`] as seconds since the Unix epoch. Any expiry that has + * already passed is valid and can be checked for using [`Refund::is_expired`]. * * Successive calls to this method will override the previous setting. */ -MUST_USE_RES void OfferWithDerivedMetadataBuilder_description(struct LDKOfferWithDerivedMetadataBuilder this_arg, struct LDKStr description); +MUST_USE_RES void RefundMaybeWithDerivedMetadataBuilder_absolute_expiry(struct LDKRefundMaybeWithDerivedMetadataBuilder this_arg, uint64_t absolute_expiry); /** - * Sets the [`Offer::issuer`]. + * Sets the [`Refund::issuer`]. * * Successive calls to this method will override the previous setting. */ -MUST_USE_RES void OfferWithDerivedMetadataBuilder_issuer(struct LDKOfferWithDerivedMetadataBuilder this_arg, struct LDKStr issuer); +MUST_USE_RES void RefundMaybeWithDerivedMetadataBuilder_issuer(struct LDKRefundMaybeWithDerivedMetadataBuilder this_arg, struct LDKStr issuer); /** - * Adds a blinded path to [`Offer::paths`]. Must include at least one path if only connected by - * private channels or if [`Offer::signing_pubkey`] is not a public node id. + * Adds a blinded path to [`Refund::paths`]. Must include at least one path if only connected + * by private channels or if [`Refund::payer_id`] is not a public node id. * * Successive calls to this method will add another blinded path. Caller is responsible for not * adding duplicate paths. */ -MUST_USE_RES void OfferWithDerivedMetadataBuilder_path(struct LDKOfferWithDerivedMetadataBuilder this_arg, struct LDKBlindedPath path); +MUST_USE_RES void RefundMaybeWithDerivedMetadataBuilder_path(struct LDKRefundMaybeWithDerivedMetadataBuilder this_arg, struct LDKBlindedMessagePath path); /** - * Sets the quantity of items for [`Offer::supported_quantity`]. If not called, defaults to - * [`Quantity::One`]. + * Sets the [`Refund::chain`] of the given [`Network`] for paying an invoice. If not + * called, [`Network::Bitcoin`] is assumed. * * Successive calls to this method will override the previous setting. */ -MUST_USE_RES void OfferWithDerivedMetadataBuilder_supported_quantity(struct LDKOfferWithDerivedMetadataBuilder this_arg, struct LDKQuantity quantity); +MUST_USE_RES void RefundMaybeWithDerivedMetadataBuilder_chain(struct LDKRefundMaybeWithDerivedMetadataBuilder this_arg, enum LDKNetwork network); /** - * Builds an [`Offer`] from the builder's settings. + * Sets [`Refund::quantity`] of items. This is purely for informational purposes. It is useful + * when the refund pertains to a [`Bolt12Invoice`] that paid for more than one item from an + * [`Offer`] as specified by [`InvoiceRequest::quantity`]. + * + * Successive calls to this method will override the previous setting. + * + * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice + * [`InvoiceRequest::quantity`]: crate::offers::invoice_request::InvoiceRequest::quantity + * [`Offer`]: crate::offers::offer::Offer */ -MUST_USE_RES struct LDKCResult_OfferBolt12SemanticErrorZ OfferWithDerivedMetadataBuilder_build(struct LDKOfferWithDerivedMetadataBuilder this_arg); +MUST_USE_RES void RefundMaybeWithDerivedMetadataBuilder_quantity(struct LDKRefundMaybeWithDerivedMetadataBuilder this_arg, uint64_t quantity); /** - * Frees any resources used by the Offer, if is_owned is set and inner is non-NULL. + * Sets the [`Refund::payer_note`]. + * + * Successive calls to this method will override the previous setting. */ -void Offer_free(struct LDKOffer this_obj); +MUST_USE_RES void RefundMaybeWithDerivedMetadataBuilder_payer_note(struct LDKRefundMaybeWithDerivedMetadataBuilder this_arg, struct LDKStr payer_note); /** - * Creates a copy of the Offer + * Builds a [`Refund`] after checking for valid semantics. */ -struct LDKOffer Offer_clone(const struct LDKOffer *NONNULL_PTR orig); +MUST_USE_RES struct LDKCResult_RefundBolt12SemanticErrorZ RefundMaybeWithDerivedMetadataBuilder_build(struct LDKRefundMaybeWithDerivedMetadataBuilder this_arg); /** - * 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. + * Frees any resources used by the Refund, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKCVec_ThirtyTwoBytesZ Offer_chains(const struct LDKOffer *NONNULL_PTR this_arg); +void Refund_free(struct LDKRefund this_obj); /** - * 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`. + * Creates a copy of the Refund */ -MUST_USE_RES struct LDKCOption_CVec_u8ZZ Offer_metadata(const struct LDKOffer *NONNULL_PTR this_arg); +struct LDKRefund Refund_clone(const struct LDKRefund *NONNULL_PTR orig); /** - * The minimum amount required for a successful payment of a single item. + * 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. */ -MUST_USE_RES struct LDKCOption_AmountZ Offer_amount(const struct LDKOffer *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKPrintableString Refund_description(const struct LDKRefund *NONNULL_PTR this_arg); /** - * 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. + * Duration since the Unix epoch when an invoice should no longer be sent. * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * If `None`, the refund does not expire. */ -MUST_USE_RES struct LDKPrintableString Offer_description(const struct LDKOffer *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCOption_u64Z Refund_absolute_expiry(const struct LDKRefund *NONNULL_PTR this_arg); /** - * Features pertaining to the offer. + * Whether the refund has expired. */ -MUST_USE_RES struct LDKOfferFeatures Offer_offer_features(const struct LDKOffer *NONNULL_PTR this_arg); +MUST_USE_RES bool Refund_is_expired(const struct LDKRefund *NONNULL_PTR this_arg); /** - * Duration since the Unix epoch when an invoice should no longer be requested. - * - * If `None`, the offer does not expire. + * Whether the refund has expired given the duration since the Unix epoch. */ -MUST_USE_RES struct LDKCOption_u64Z Offer_absolute_expiry(const struct LDKOffer *NONNULL_PTR this_arg); +MUST_USE_RES bool Refund_is_expired_no_std(const struct LDKRefund *NONNULL_PTR this_arg, uint64_t duration_since_epoch); /** - * The issuer of the offer, possibly beginning with `user@domain` or `domain`. Intended to be + * 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 */ -MUST_USE_RES struct LDKPrintableString Offer_issuer(const struct LDKOffer *NONNULL_PTR this_arg); - -/** - * Paths to the recipient originating from publicly reachable nodes. Blinded paths provide - * recipient privacy by obfuscating its node id. - */ -MUST_USE_RES struct LDKCVec_BlindedPathZ Offer_paths(const struct LDKOffer *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKPrintableString Refund_issuer(const struct LDKRefund *NONNULL_PTR this_arg); /** - * The quantity of items supported. + * Paths to the sender originating from publicly reachable nodes. Blinded paths provide sender + * privacy by obfuscating its node id. */ -MUST_USE_RES struct LDKQuantity Offer_supported_quantity(const struct LDKOffer *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCVec_BlindedMessagePathZ Refund_paths(const struct LDKRefund *NONNULL_PTR this_arg); /** - * The public key used by the recipient to sign invoices. + * An unpredictable series of bytes, typically containing information about the derivation of + * [`payer_id`]. * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None - */ -MUST_USE_RES struct LDKPublicKey Offer_signing_pubkey(const struct LDKOffer *NONNULL_PTR this_arg); - -/** - * Returns the id of the offer. + * [`payer_id`]: Self::payer_id */ -MUST_USE_RES struct LDKOfferId Offer_id(const struct LDKOffer *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKu8slice Refund_payer_metadata(const struct LDKRefund *NONNULL_PTR this_arg); /** - * Returns whether the given chain is supported by the offer. + * A chain that the refund is valid for. */ -MUST_USE_RES bool Offer_supports_chain(const struct LDKOffer *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes chain); +MUST_USE_RES struct LDKThirtyTwoBytes Refund_chain(const struct LDKRefund *NONNULL_PTR this_arg); /** - * Whether the offer has expired. + * The amount to refund in msats (i.e., the minimum lightning-payable unit for [`chain`]). + * + * [`chain`]: Self::chain */ -MUST_USE_RES bool Offer_is_expired(const struct LDKOffer *NONNULL_PTR this_arg); +MUST_USE_RES uint64_t Refund_amount_msats(const struct LDKRefund *NONNULL_PTR this_arg); /** - * Whether the offer has expired given the duration since the Unix epoch. + * Features pertaining to requesting an invoice. */ -MUST_USE_RES bool Offer_is_expired_no_std(const struct LDKOffer *NONNULL_PTR this_arg, uint64_t duration_since_epoch); +MUST_USE_RES struct LDKInvoiceRequestFeatures Refund_features(const struct LDKRefund *NONNULL_PTR this_arg); /** - * Returns whether the given quantity is valid for the offer. + * The quantity of an item that refund is for. */ -MUST_USE_RES bool Offer_is_valid_quantity(const struct LDKOffer *NONNULL_PTR this_arg, uint64_t quantity); +MUST_USE_RES struct LDKCOption_u64Z Refund_quantity(const struct LDKRefund *NONNULL_PTR this_arg); /** - * Returns whether a quantity is expected in an [`InvoiceRequest`] for the offer. + * A public node id to send to in the case where there are no [`paths`]. Otherwise, a possibly + * transient pubkey. * - * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest + * [`paths`]: Self::paths */ -MUST_USE_RES bool Offer_expects_quantity(const struct LDKOffer *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKPublicKey Refund_payer_id(const struct LDKRefund *NONNULL_PTR this_arg); /** - * Similar to [`Offer::request_invoice`] except it: - * - derives the [`InvoiceRequest::payer_id`] such that a different key can be used for each - * request, - * - sets [`InvoiceRequest::payer_metadata`] when [`InvoiceRequestBuilder::build`] is called - * such that it can be used by [`Bolt12Invoice::verify`] to determine if the invoice was - * requested using a base [`ExpandedKey`] from which the payer id was derived, and - * - includes the [`PaymentId`] encrypted in [`InvoiceRequest::payer_metadata`] so that it can - * be used when sending the payment for the requested invoice. - * - * Useful to protect the sender's privacy. + * Payer provided note to include in the invoice. * - * [`InvoiceRequest::payer_id`]: crate::offers::invoice_request::InvoiceRequest::payer_id - * [`InvoiceRequest::payer_metadata`]: crate::offers::invoice_request::InvoiceRequest::payer_metadata - * [`Bolt12Invoice::verify`]: crate::offers::invoice::Bolt12Invoice::verify - * [`ExpandedKey`]: crate::ln::inbound_payment::ExpandedKey + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKCResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ Offer_request_invoice_deriving_payer_id(const struct LDKOffer *NONNULL_PTR this_arg, const struct LDKExpandedKey *NONNULL_PTR expanded_key, struct LDKEntropySource entropy_source, struct LDKThirtyTwoBytes payment_id); +MUST_USE_RES struct LDKPrintableString Refund_payer_note(const struct LDKRefund *NONNULL_PTR this_arg); /** - * Similar to [`Offer::request_invoice_deriving_payer_id`] except uses `payer_id` for the - * [`InvoiceRequest::payer_id`] instead of deriving a different key for each request. - * - * Useful for recurring payments using the same `payer_id` with different invoices. - * - * [`InvoiceRequest::payer_id`]: crate::offers::invoice_request::InvoiceRequest::payer_id + * Generates a non-cryptographic 64-bit hash of the Refund. */ -MUST_USE_RES struct LDKCResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ Offer_request_invoice_deriving_metadata(const struct LDKOffer *NONNULL_PTR this_arg, struct LDKPublicKey payer_id, const struct LDKExpandedKey *NONNULL_PTR expanded_key, struct LDKEntropySource entropy_source, struct LDKThirtyTwoBytes payment_id); +uint64_t Refund_hash(const struct LDKRefund *NONNULL_PTR o); /** - * Creates an [`InvoiceRequestBuilder`] for the offer with the given `metadata` and `payer_id`, - * which will be reflected in the `Bolt12Invoice` response. - * - * The `metadata` is useful for including information about the derivation of `payer_id` such - * that invoice response handling can be stateless. Also serves as payer-provided entropy while - * hashing in the signature calculation. - * - * This should not leak any information such as by using a simple BIP-32 derivation path. - * Otherwise, payments may be correlated. - * - * Errors if the offer contains unknown required features. - * - * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest + * Read a Refund from a byte array, created by Refund_write */ -MUST_USE_RES struct LDKCResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ Offer_request_invoice(const struct LDKOffer *NONNULL_PTR this_arg, struct LDKCVec_u8Z metadata, struct LDKPublicKey payer_id); +struct LDKCResult_RefundDecodeErrorZ Refund_read(struct LDKu8slice ser); /** - * Generates a non-cryptographic 64-bit hash of the Offer. + * Serialize the Refund object into a byte array which can be read by Refund_read */ -uint64_t Offer_hash(const struct LDKOffer *NONNULL_PTR o); +struct LDKCVec_u8Z Refund_write(const struct LDKRefund *NONNULL_PTR obj); /** - * Serialize the Offer object into a byte array which can be read by Offer_read + * Read a Refund object from a string */ -struct LDKCVec_u8Z Offer_write(const struct LDKOffer *NONNULL_PTR obj); +struct LDKCResult_RefundBolt12ParseErrorZ Refund_from_str(struct LDKStr s); /** - * Frees any resources used by the Amount + * Get the string representation of a Refund object */ -void Amount_free(struct LDKAmount this_ptr); +struct LDKStr Refund_to_str(const struct LDKRefund *NONNULL_PTR o); /** - * Creates a copy of the Amount + * Creates a copy of the UtxoLookupError */ -struct LDKAmount Amount_clone(const struct LDKAmount *NONNULL_PTR orig); +enum LDKUtxoLookupError UtxoLookupError_clone(const enum LDKUtxoLookupError *NONNULL_PTR orig); /** - * Utility method to constructs a new Bitcoin-variant Amount + * Utility method to constructs a new UnknownChain-variant UtxoLookupError */ -struct LDKAmount Amount_bitcoin(uint64_t amount_msats); +enum LDKUtxoLookupError UtxoLookupError_unknown_chain(void); /** - * Utility method to constructs a new Currency-variant Amount + * Utility method to constructs a new UnknownTx-variant UtxoLookupError */ -struct LDKAmount Amount_currency(struct LDKThreeBytes iso4217_code, uint64_t amount); +enum LDKUtxoLookupError UtxoLookupError_unknown_tx(void); /** - * Frees any resources used by the Quantity + * Frees any resources used by the UtxoResult */ -void Quantity_free(struct LDKQuantity this_ptr); +void UtxoResult_free(struct LDKUtxoResult this_ptr); /** - * Creates a copy of the Quantity + * Creates a copy of the UtxoResult */ -struct LDKQuantity Quantity_clone(const struct LDKQuantity *NONNULL_PTR orig); +struct LDKUtxoResult UtxoResult_clone(const struct LDKUtxoResult *NONNULL_PTR orig); /** - * Utility method to constructs a new Bounded-variant Quantity + * Utility method to constructs a new Sync-variant UtxoResult */ -struct LDKQuantity Quantity_bounded(uint64_t a); +struct LDKUtxoResult UtxoResult_sync(struct LDKCResult_TxOutUtxoLookupErrorZ a); /** - * Utility method to constructs a new Unbounded-variant Quantity + * Utility method to constructs a new Async-variant UtxoResult */ -struct LDKQuantity Quantity_unbounded(void); +struct LDKUtxoResult UtxoResult_async(struct LDKUtxoFuture a); /** - * Utility method to constructs a new One-variant Quantity + * Calls the free function if one is set */ -struct LDKQuantity Quantity_one(void); +void UtxoLookup_free(struct LDKUtxoLookup this_ptr); /** - * Read a Offer object from a string + * Frees any resources used by the UtxoFuture, if is_owned is set and inner is non-NULL. */ -struct LDKCResult_OfferBolt12ParseErrorZ Offer_from_str(struct LDKStr s); +void UtxoFuture_free(struct LDKUtxoFuture this_obj); /** - * Get the string representation of a Offer object + * Creates a copy of the UtxoFuture */ -struct LDKStr Offer_to_str(const struct LDKOffer *NONNULL_PTR o); +struct LDKUtxoFuture UtxoFuture_clone(const struct LDKUtxoFuture *NONNULL_PTR orig); /** - * Frees any resources used by the InvoiceWithExplicitSigningPubkeyBuilder, if is_owned is set and inner is non-NULL. + * Builds a new future for later resolution. */ -void InvoiceWithExplicitSigningPubkeyBuilder_free(struct LDKInvoiceWithExplicitSigningPubkeyBuilder this_obj); +MUST_USE_RES struct LDKUtxoFuture UtxoFuture_new(void); /** - * Frees any resources used by the InvoiceWithDerivedSigningPubkeyBuilder, if is_owned is set and inner is non-NULL. + * 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 */ -void InvoiceWithDerivedSigningPubkeyBuilder_free(struct LDKInvoiceWithDerivedSigningPubkeyBuilder this_obj); +void UtxoFuture_resolve_without_forwarding(const struct LDKUtxoFuture *NONNULL_PTR this_arg, const struct LDKNetworkGraph *NONNULL_PTR graph, struct LDKCResult_TxOutUtxoLookupErrorZ result); /** - * Builds an unsigned [`Bolt12Invoice`] after checking for valid semantics. It can be signed by - * [`UnsignedBolt12Invoice::sign`]. + * 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 */ -MUST_USE_RES struct LDKCResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ InvoiceWithExplicitSigningPubkeyBuilder_build(struct LDKInvoiceWithExplicitSigningPubkeyBuilder 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); /** - * Sets the [`Bolt12Invoice::relative_expiry`] as seconds since [`Bolt12Invoice::created_at`]. - * Any expiry that has already passed is valid and can be checked for using - * [`Bolt12Invoice::is_expired`]. - * - * Successive calls to this method will override the previous setting. + * Frees any resources used by the NodeId, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES void InvoiceWithExplicitSigningPubkeyBuilder_relative_expiry(struct LDKInvoiceWithExplicitSigningPubkeyBuilder this_arg, uint32_t relative_expiry_secs); +void NodeId_free(struct LDKNodeId this_obj); /** - * Adds a P2WSH address to [`Bolt12Invoice::fallbacks`]. - * - * Successive calls to this method will add another address. Caller is responsible for not - * adding duplicate addresses and only calling if capable of receiving to P2WSH addresses. + * Creates a copy of the NodeId */ -MUST_USE_RES void InvoiceWithExplicitSigningPubkeyBuilder_fallback_v0_p2wsh(struct LDKInvoiceWithExplicitSigningPubkeyBuilder this_arg, const uint8_t (*script_hash)[32]); +struct LDKNodeId NodeId_clone(const struct LDKNodeId *NONNULL_PTR orig); /** - * Adds a P2WPKH address to [`Bolt12Invoice::fallbacks`]. - * - * Successive calls to this method will add another address. Caller is responsible for not - * adding duplicate addresses and only calling if capable of receiving to P2WPKH addresses. + * Checks if two NodeIds 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 void InvoiceWithExplicitSigningPubkeyBuilder_fallback_v0_p2wpkh(struct LDKInvoiceWithExplicitSigningPubkeyBuilder this_arg, const uint8_t (*pubkey_hash)[20]); +bool NodeId_eq(const struct LDKNodeId *NONNULL_PTR a, const struct LDKNodeId *NONNULL_PTR b); /** - * Adds a P2TR address to [`Bolt12Invoice::fallbacks`]. - * - * Successive calls to this method will add another address. Caller is responsible for not - * adding duplicate addresses and only calling if capable of receiving to P2TR addresses. + * Create a new NodeId from a public key */ -MUST_USE_RES void InvoiceWithExplicitSigningPubkeyBuilder_fallback_v1_p2tr_tweaked(struct LDKInvoiceWithExplicitSigningPubkeyBuilder this_arg, struct LDKTweakedPublicKey output_key); +MUST_USE_RES struct LDKNodeId NodeId_from_pubkey(struct LDKPublicKey pubkey); /** - * Sets [`Bolt12Invoice::invoice_features`] to indicate MPP may be used. Otherwise, MPP is - * disallowed. + * Create a new NodeId from a slice of bytes */ -MUST_USE_RES void InvoiceWithExplicitSigningPubkeyBuilder_allow_mpp(struct LDKInvoiceWithExplicitSigningPubkeyBuilder this_arg); +MUST_USE_RES struct LDKCResult_NodeIdDecodeErrorZ NodeId_from_slice(struct LDKu8slice bytes); /** - * Builds a signed [`Bolt12Invoice`] after checking for valid semantics. + * Get the public key slice from this NodeId */ -MUST_USE_RES struct LDKCResult_Bolt12InvoiceBolt12SemanticErrorZ InvoiceWithDerivedSigningPubkeyBuilder_build_and_sign(struct LDKInvoiceWithDerivedSigningPubkeyBuilder this_arg); +MUST_USE_RES struct LDKu8slice NodeId_as_slice(const struct LDKNodeId *NONNULL_PTR this_arg); /** - * Sets the [`Bolt12Invoice::relative_expiry`] as seconds since [`Bolt12Invoice::created_at`]. - * Any expiry that has already passed is valid and can be checked for using - * [`Bolt12Invoice::is_expired`]. - * - * Successive calls to this method will override the previous setting. + * Get the public key as an array from this NodeId */ -MUST_USE_RES void InvoiceWithDerivedSigningPubkeyBuilder_relative_expiry(struct LDKInvoiceWithDerivedSigningPubkeyBuilder this_arg, uint32_t relative_expiry_secs); +MUST_USE_RES const uint8_t (*NodeId_as_array(const struct LDKNodeId *NONNULL_PTR this_arg))[33]; /** - * Adds a P2WSH address to [`Bolt12Invoice::fallbacks`]. - * - * Successive calls to this method will add another address. Caller is responsible for not - * adding duplicate addresses and only calling if capable of receiving to P2WSH addresses. + * Get the public key from this NodeId */ -MUST_USE_RES void InvoiceWithDerivedSigningPubkeyBuilder_fallback_v0_p2wsh(struct LDKInvoiceWithDerivedSigningPubkeyBuilder this_arg, const uint8_t (*script_hash)[32]); +MUST_USE_RES struct LDKCResult_PublicKeySecp256k1ErrorZ NodeId_as_pubkey(const struct LDKNodeId *NONNULL_PTR this_arg); /** - * Adds a P2WPKH address to [`Bolt12Invoice::fallbacks`]. - * - * Successive calls to this method will add another address. Caller is responsible for not - * adding duplicate addresses and only calling if capable of receiving to P2WPKH addresses. + * Get the string representation of a NodeId object */ -MUST_USE_RES void InvoiceWithDerivedSigningPubkeyBuilder_fallback_v0_p2wpkh(struct LDKInvoiceWithDerivedSigningPubkeyBuilder this_arg, const uint8_t (*pubkey_hash)[20]); +struct LDKStr NodeId_to_str(const struct LDKNodeId *NONNULL_PTR o); /** - * Adds a P2TR address to [`Bolt12Invoice::fallbacks`]. - * - * Successive calls to this method will add another address. Caller is responsible for not - * adding duplicate addresses and only calling if capable of receiving to P2TR addresses. + * Generates a non-cryptographic 64-bit hash of the NodeId. */ -MUST_USE_RES void InvoiceWithDerivedSigningPubkeyBuilder_fallback_v1_p2tr_tweaked(struct LDKInvoiceWithDerivedSigningPubkeyBuilder this_arg, struct LDKTweakedPublicKey output_key); +uint64_t NodeId_hash(const struct LDKNodeId *NONNULL_PTR o); /** - * Sets [`Bolt12Invoice::invoice_features`] to indicate MPP may be used. Otherwise, MPP is - * disallowed. + * Serialize the NodeId object into a byte array which can be read by NodeId_read */ -MUST_USE_RES void InvoiceWithDerivedSigningPubkeyBuilder_allow_mpp(struct LDKInvoiceWithDerivedSigningPubkeyBuilder this_arg); +struct LDKCVec_u8Z NodeId_write(const struct LDKNodeId *NONNULL_PTR obj); /** - * Frees any resources used by the UnsignedBolt12Invoice, if is_owned is set and inner is non-NULL. + * Read a NodeId from a byte array, created by NodeId_write */ -void UnsignedBolt12Invoice_free(struct LDKUnsignedBolt12Invoice this_obj); +struct LDKCResult_NodeIdDecodeErrorZ NodeId_read(struct LDKu8slice ser); /** - * Creates a copy of the UnsignedBolt12Invoice + * Frees any resources used by the NetworkGraph, if is_owned is set and inner is non-NULL. */ -struct LDKUnsignedBolt12Invoice UnsignedBolt12Invoice_clone(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR orig); +void NetworkGraph_free(struct LDKNetworkGraph this_obj); /** - * Calls the free function if one is set + * Frees any resources used by the ReadOnlyNetworkGraph, if is_owned is set and inner is non-NULL. */ -void SignBolt12InvoiceFn_free(struct LDKSignBolt12InvoiceFn this_ptr); +void ReadOnlyNetworkGraph_free(struct LDKReadOnlyNetworkGraph this_obj); /** - * Returns the [`TaggedHash`] of the invoice to sign. + * Frees any resources used by the NetworkUpdate */ -MUST_USE_RES struct LDKTaggedHash UnsignedBolt12Invoice_tagged_hash(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +void NetworkUpdate_free(struct LDKNetworkUpdate this_ptr); /** - * Frees any resources used by the Bolt12Invoice, if is_owned is set and inner is non-NULL. + * Creates a copy of the NetworkUpdate */ -void Bolt12Invoice_free(struct LDKBolt12Invoice this_obj); +struct LDKNetworkUpdate NetworkUpdate_clone(const struct LDKNetworkUpdate *NONNULL_PTR orig); /** - * Creates a copy of the Bolt12Invoice + * Utility method to constructs a new ChannelFailure-variant NetworkUpdate */ -struct LDKBolt12Invoice Bolt12Invoice_clone(const struct LDKBolt12Invoice *NONNULL_PTR orig); +struct LDKNetworkUpdate NetworkUpdate_channel_failure(uint64_t short_channel_id, bool is_permanent); /** - * The chains that may be used when paying a requested invoice. - * - * From [`Offer::chains`]; `None` if the invoice was created in response to a [`Refund`]. - * - * [`Offer::chains`]: crate::offers::offer::Offer::chains + * Utility method to constructs a new NodeFailure-variant NetworkUpdate */ -MUST_USE_RES struct LDKCOption_CVec_ThirtyTwoBytesZZ UnsignedBolt12Invoice_offer_chains(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +struct LDKNetworkUpdate NetworkUpdate_node_failure(struct LDKPublicKey node_id, bool is_permanent); /** - * The chain that must be used when paying the invoice; selected from [`offer_chains`] if the - * invoice originated from an offer. - * - * From [`InvoiceRequest::chain`] or [`Refund::chain`]. - * - * [`offer_chains`]: Self::offer_chains - * [`InvoiceRequest::chain`]: crate::offers::invoice_request::InvoiceRequest::chain + * Checks if two NetworkUpdates contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -MUST_USE_RES struct LDKThirtyTwoBytes UnsignedBolt12Invoice_chain(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +bool NetworkUpdate_eq(const struct LDKNetworkUpdate *NONNULL_PTR a, const struct LDKNetworkUpdate *NONNULL_PTR b); /** - * Opaque bytes set by the originating [`Offer`]. - * - * From [`Offer::metadata`]; `None` if the invoice was created in response to a [`Refund`] or - * if the [`Offer`] did not set it. - * - * [`Offer`]: crate::offers::offer::Offer - * [`Offer::metadata`]: crate::offers::offer::Offer::metadata + * Serialize the NetworkUpdate object into a byte array which can be read by NetworkUpdate_read */ -MUST_USE_RES struct LDKCOption_CVec_u8ZZ UnsignedBolt12Invoice_metadata(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +struct LDKCVec_u8Z NetworkUpdate_write(const struct LDKNetworkUpdate *NONNULL_PTR obj); /** - * The minimum amount required for a successful payment of a single item. - * - * From [`Offer::amount`]; `None` if the invoice was created in response to a [`Refund`] or if - * the [`Offer`] did not set it. - * - * [`Offer`]: crate::offers::offer::Offer - * [`Offer::amount`]: crate::offers::offer::Offer::amount + * Read a NetworkUpdate from a byte array, created by NetworkUpdate_write */ -MUST_USE_RES struct LDKCOption_AmountZ UnsignedBolt12Invoice_amount(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +struct LDKCResult_COption_NetworkUpdateZDecodeErrorZ NetworkUpdate_read(struct LDKu8slice ser); /** - * Features pertaining to the originating [`Offer`]. - * - * From [`Offer::offer_features`]; `None` if the invoice was created in response to a - * [`Refund`]. - * - * [`Offer`]: crate::offers::offer::Offer - * [`Offer::offer_features`]: crate::offers::offer::Offer::offer_features - * - * 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 P2PGossipSync, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKOfferFeatures UnsignedBolt12Invoice_offer_features(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +void P2PGossipSync_free(struct LDKP2PGossipSync this_obj); /** - * A complete description of the purpose of the originating offer or refund. - * - * From [`Offer::description`] or [`Refund::description`]. - * - * [`Offer::description`]: crate::offers::offer::Offer::description - * - * 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. */ -MUST_USE_RES struct LDKPrintableString UnsignedBolt12Invoice_description(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKP2PGossipSync P2PGossipSync_new(const struct LDKNetworkGraph *NONNULL_PTR network_graph, struct LDKCOption_UtxoLookupZ utxo_lookup, struct LDKLogger logger); /** - * Duration since the Unix epoch when an invoice should no longer be requested. - * - * From [`Offer::absolute_expiry`] or [`Refund::absolute_expiry`]. - * - * [`Offer::absolute_expiry`]: crate::offers::offer::Offer::absolute_expiry + * 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. */ -MUST_USE_RES struct LDKCOption_u64Z UnsignedBolt12Invoice_absolute_expiry(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +void P2PGossipSync_add_utxo_lookup(const struct LDKP2PGossipSync *NONNULL_PTR this_arg, struct LDKCOption_UtxoLookupZ utxo_lookup); /** - * The issuer of the offer or refund. - * - * From [`Offer::issuer`] or [`Refund::issuer`]. - * - * [`Offer::issuer`]: crate::offers::offer::Offer::issuer + * Handles any network updates originating from [`Event`]s. * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * [`Event`]: crate::events::Event */ -MUST_USE_RES struct LDKPrintableString UnsignedBolt12Invoice_issuer(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +void NetworkGraph_handle_network_update(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKNetworkUpdate *NONNULL_PTR network_update); /** - * Paths to the recipient originating from publicly reachable nodes. - * - * From [`Offer::paths`] or [`Refund::paths`]. - * - * [`Offer::paths`]: crate::offers::offer::Offer::paths + * Gets the chain hash for this network graph. */ -MUST_USE_RES struct LDKCVec_BlindedPathZ UnsignedBolt12Invoice_message_paths(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKThirtyTwoBytes NetworkGraph_get_chain_hash(const struct LDKNetworkGraph *NONNULL_PTR this_arg); /** - * The quantity of items supported. - * - * From [`Offer::supported_quantity`]; `None` if the invoice was created in response to a - * [`Refund`]. + * Verifies the signature of a [`NodeAnnouncement`]. * - * [`Offer::supported_quantity`]: crate::offers::offer::Offer::supported_quantity + * Returns an error if it is invalid. */ -MUST_USE_RES struct LDKCOption_QuantityZ UnsignedBolt12Invoice_supported_quantity(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +struct LDKCResult_NoneLightningErrorZ verify_node_announcement(const struct LDKNodeAnnouncement *NONNULL_PTR msg); /** - * An unpredictable series of bytes from the payer. + * Verifies all signatures included in a [`ChannelAnnouncement`]. * - * From [`InvoiceRequest::payer_metadata`] or [`Refund::payer_metadata`]. + * Returns an error if one of the signatures is invalid. */ -MUST_USE_RES struct LDKu8slice UnsignedBolt12Invoice_payer_metadata(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +struct LDKCResult_NoneLightningErrorZ verify_channel_announcement(const struct LDKChannelAnnouncement *NONNULL_PTR msg); /** - * Features pertaining to requesting an invoice. - * - * From [`InvoiceRequest::invoice_request_features`] or [`Refund::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 */ -MUST_USE_RES struct LDKInvoiceRequestFeatures UnsignedBolt12Invoice_invoice_request_features(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +struct LDKRoutingMessageHandler P2PGossipSync_as_RoutingMessageHandler(const struct LDKP2PGossipSync *NONNULL_PTR this_arg); /** - * The quantity of items requested or refunded for. - * - * From [`InvoiceRequest::quantity`] or [`Refund::quantity`]. + * 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 */ -MUST_USE_RES struct LDKCOption_u64Z UnsignedBolt12Invoice_quantity(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +struct LDKMessageSendEventsProvider P2PGossipSync_as_MessageSendEventsProvider(const struct LDKP2PGossipSync *NONNULL_PTR this_arg); /** - * A possibly transient pubkey used to sign the invoice request or to send an invoice for a - * refund in case there are no [`message_paths`]. - * - * [`message_paths`]: Self::message_paths + * Frees any resources used by the ChannelUpdateInfo, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKPublicKey UnsignedBolt12Invoice_payer_id(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +void ChannelUpdateInfo_free(struct LDKChannelUpdateInfo this_obj); /** - * A payer-provided note reflected back in the invoice. - * - * From [`InvoiceRequest::payer_note`] or [`Refund::payer_note`]. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * The minimum value, which must be relayed to the next hop via the channel */ -MUST_USE_RES struct LDKPrintableString UnsignedBolt12Invoice_payer_note(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +uint64_t ChannelUpdateInfo_get_htlc_minimum_msat(const struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr); /** - * Duration since the Unix epoch when the invoice was created. + * The minimum value, which must be relayed to the next hop via the channel */ -MUST_USE_RES uint64_t UnsignedBolt12Invoice_created_at(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +void ChannelUpdateInfo_set_htlc_minimum_msat(struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr, uint64_t val); /** - * Duration since [`Bolt12Invoice::created_at`] when the invoice has expired and therefore - * should no longer be paid. + * The maximum value which may be relayed to the next hop via the channel. */ -MUST_USE_RES uint64_t UnsignedBolt12Invoice_relative_expiry(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +uint64_t ChannelUpdateInfo_get_htlc_maximum_msat(const struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr); /** - * Whether the invoice has expired. + * The maximum value which may be relayed to the next hop via the channel. */ -MUST_USE_RES bool UnsignedBolt12Invoice_is_expired(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +void ChannelUpdateInfo_set_htlc_maximum_msat(struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr, uint64_t val); /** - * SHA256 hash of the payment preimage that will be given in return for paying the invoice. + * Fees charged when the channel is used for routing */ -MUST_USE_RES struct LDKThirtyTwoBytes UnsignedBolt12Invoice_payment_hash(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +struct LDKRoutingFees ChannelUpdateInfo_get_fees(const struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr); /** - * The minimum amount required for a successful payment of the invoice. + * Fees charged when the channel is used for routing */ -MUST_USE_RES uint64_t UnsignedBolt12Invoice_amount_msats(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +void ChannelUpdateInfo_set_fees(struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr, struct LDKRoutingFees val); /** - * Features pertaining to paying an invoice. + * When the last update to the channel direction was issued. + * Value is opaque, as set in the announcement. */ -MUST_USE_RES struct LDKBolt12InvoiceFeatures UnsignedBolt12Invoice_invoice_features(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +uint32_t ChannelUpdateInfo_get_last_update(const struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr); /** - * The public key corresponding to the key used to sign the invoice. + * When the last update to the channel direction was issued. + * Value is opaque, as set in the announcement. */ -MUST_USE_RES struct LDKPublicKey UnsignedBolt12Invoice_signing_pubkey(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +void ChannelUpdateInfo_set_last_update(struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr, uint32_t val); /** - * The chains that may be used when paying a requested invoice. - * - * From [`Offer::chains`]; `None` if the invoice was created in response to a [`Refund`]. - * - * [`Offer::chains`]: crate::offers::offer::Offer::chains + * The difference in CLTV values that you must have when routing through this channel. */ -MUST_USE_RES struct LDKCOption_CVec_ThirtyTwoBytesZZ Bolt12Invoice_offer_chains(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); +uint16_t ChannelUpdateInfo_get_cltv_expiry_delta(const struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr); /** - * The chain that must be used when paying the invoice; selected from [`offer_chains`] if the - * invoice originated from an offer. - * - * From [`InvoiceRequest::chain`] or [`Refund::chain`]. - * - * [`offer_chains`]: Self::offer_chains - * [`InvoiceRequest::chain`]: crate::offers::invoice_request::InvoiceRequest::chain + * The difference in CLTV values that you must have when routing through this channel. */ -MUST_USE_RES struct LDKThirtyTwoBytes Bolt12Invoice_chain(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); +void ChannelUpdateInfo_set_cltv_expiry_delta(struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr, uint16_t val); /** - * Opaque bytes set by the originating [`Offer`]. - * - * From [`Offer::metadata`]; `None` if the invoice was created in response to a [`Refund`] or - * if the [`Offer`] did not set it. - * - * [`Offer`]: crate::offers::offer::Offer - * [`Offer::metadata`]: crate::offers::offer::Offer::metadata + * Whether the channel can be currently used for payments (in this one direction). */ -MUST_USE_RES struct LDKCOption_CVec_u8ZZ Bolt12Invoice_metadata(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); +bool ChannelUpdateInfo_get_enabled(const struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr); /** - * The minimum amount required for a successful payment of a single item. - * - * From [`Offer::amount`]; `None` if the invoice was created in response to a [`Refund`] or if - * the [`Offer`] did not set it. - * - * [`Offer`]: crate::offers::offer::Offer - * [`Offer::amount`]: crate::offers::offer::Offer::amount + * Whether the channel can be currently used for payments (in this one direction). */ -MUST_USE_RES struct LDKCOption_AmountZ Bolt12Invoice_amount(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); +void ChannelUpdateInfo_set_enabled(struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr, bool val); /** - * Features pertaining to the originating [`Offer`]. - * - * From [`Offer::offer_features`]; `None` if the invoice was created in response to a - * [`Refund`]. - * - * [`Offer`]: crate::offers::offer::Offer - * [`Offer::offer_features`]: crate::offers::offer::Offer::offer_features + * 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 */ -MUST_USE_RES struct LDKOfferFeatures Bolt12Invoice_offer_features(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); +struct LDKChannelUpdate ChannelUpdateInfo_get_last_update_message(const struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr); /** - * A complete description of the purpose of the originating offer or refund. - * - * From [`Offer::description`] or [`Refund::description`]. - * - * [`Offer::description`]: crate::offers::offer::Offer::description + * 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 + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKPrintableString Bolt12Invoice_description(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); +void ChannelUpdateInfo_set_last_update_message(struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr, struct LDKChannelUpdate val); /** - * Duration since the Unix epoch when an invoice should no longer be requested. - * - * From [`Offer::absolute_expiry`] or [`Refund::absolute_expiry`]. + * Constructs a new ChannelUpdateInfo given each field * - * [`Offer::absolute_expiry`]: crate::offers::offer::Offer::absolute_expiry + * Note that last_update_message_arg (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKCOption_u64Z Bolt12Invoice_absolute_expiry(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKChannelUpdateInfo ChannelUpdateInfo_new(uint64_t htlc_minimum_msat_arg, uint64_t htlc_maximum_msat_arg, struct LDKRoutingFees fees_arg, uint32_t last_update_arg, uint16_t cltv_expiry_delta_arg, bool enabled_arg, struct LDKChannelUpdate last_update_message_arg); /** - * The issuer of the offer or refund. - * - * From [`Offer::issuer`] or [`Refund::issuer`]. - * - * [`Offer::issuer`]: crate::offers::offer::Offer::issuer - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Creates a copy of the ChannelUpdateInfo */ -MUST_USE_RES struct LDKPrintableString Bolt12Invoice_issuer(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); +struct LDKChannelUpdateInfo ChannelUpdateInfo_clone(const struct LDKChannelUpdateInfo *NONNULL_PTR orig); /** - * Paths to the recipient originating from publicly reachable nodes. - * - * From [`Offer::paths`] or [`Refund::paths`]. - * - * [`Offer::paths`]: crate::offers::offer::Offer::paths + * 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. */ -MUST_USE_RES struct LDKCVec_BlindedPathZ Bolt12Invoice_message_paths(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); +bool ChannelUpdateInfo_eq(const struct LDKChannelUpdateInfo *NONNULL_PTR a, const struct LDKChannelUpdateInfo *NONNULL_PTR b); /** - * The quantity of items supported. - * - * From [`Offer::supported_quantity`]; `None` if the invoice was created in response to a - * [`Refund`]. - * - * [`Offer::supported_quantity`]: crate::offers::offer::Offer::supported_quantity + * Get the string representation of a ChannelUpdateInfo object */ -MUST_USE_RES struct LDKCOption_QuantityZ Bolt12Invoice_supported_quantity(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); +struct LDKStr ChannelUpdateInfo_to_str(const struct LDKChannelUpdateInfo *NONNULL_PTR o); /** - * An unpredictable series of bytes from the payer. - * - * From [`InvoiceRequest::payer_metadata`] or [`Refund::payer_metadata`]. + * Serialize the ChannelUpdateInfo object into a byte array which can be read by ChannelUpdateInfo_read */ -MUST_USE_RES struct LDKu8slice Bolt12Invoice_payer_metadata(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); +struct LDKCVec_u8Z ChannelUpdateInfo_write(const struct LDKChannelUpdateInfo *NONNULL_PTR obj); /** - * Features pertaining to requesting an invoice. - * - * From [`InvoiceRequest::invoice_request_features`] or [`Refund::features`]. + * Read a ChannelUpdateInfo from a byte array, created by ChannelUpdateInfo_write */ -MUST_USE_RES struct LDKInvoiceRequestFeatures Bolt12Invoice_invoice_request_features(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); +struct LDKCResult_ChannelUpdateInfoDecodeErrorZ ChannelUpdateInfo_read(struct LDKu8slice ser); /** - * The quantity of items requested or refunded for. - * - * From [`InvoiceRequest::quantity`] or [`Refund::quantity`]. + * Frees any resources used by the ChannelInfo, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKCOption_u64Z Bolt12Invoice_quantity(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); +void ChannelInfo_free(struct LDKChannelInfo this_obj); /** - * A possibly transient pubkey used to sign the invoice request or to send an invoice for a - * refund in case there are no [`message_paths`]. - * - * [`message_paths`]: Self::message_paths + * Protocol features of a channel communicated during its announcement */ -MUST_USE_RES struct LDKPublicKey Bolt12Invoice_payer_id(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); +struct LDKChannelFeatures ChannelInfo_get_features(const struct LDKChannelInfo *NONNULL_PTR this_ptr); /** - * A payer-provided note reflected back in the invoice. - * - * From [`InvoiceRequest::payer_note`] or [`Refund::payer_note`]. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Protocol features of a channel communicated during its announcement */ -MUST_USE_RES struct LDKPrintableString Bolt12Invoice_payer_note(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); +void ChannelInfo_set_features(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKChannelFeatures val); /** - * Duration since the Unix epoch when the invoice was created. + * Source node of the first direction of a channel */ -MUST_USE_RES uint64_t Bolt12Invoice_created_at(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); +struct LDKNodeId ChannelInfo_get_node_one(const struct LDKChannelInfo *NONNULL_PTR this_ptr); /** - * Duration since [`Bolt12Invoice::created_at`] when the invoice has expired and therefore - * should no longer be paid. + * Source node of the first direction of a channel */ -MUST_USE_RES uint64_t Bolt12Invoice_relative_expiry(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); +void ChannelInfo_set_node_one(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKNodeId val); /** - * Whether the invoice has expired. + * Source node of the second direction of a channel */ -MUST_USE_RES bool Bolt12Invoice_is_expired(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); +struct LDKNodeId ChannelInfo_get_node_two(const struct LDKChannelInfo *NONNULL_PTR this_ptr); /** - * SHA256 hash of the payment preimage that will be given in return for paying the invoice. + * Source node of the second direction of a channel */ -MUST_USE_RES struct LDKThirtyTwoBytes Bolt12Invoice_payment_hash(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); +void ChannelInfo_set_node_two(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKNodeId val); /** - * The minimum amount required for a successful payment of the invoice. + * The channel capacity as seen on-chain, if chain lookup is available. */ -MUST_USE_RES uint64_t Bolt12Invoice_amount_msats(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); +struct LDKCOption_u64Z ChannelInfo_get_capacity_sats(const struct LDKChannelInfo *NONNULL_PTR this_ptr); /** - * Features pertaining to paying an invoice. + * The channel capacity as seen on-chain, if chain lookup is available. */ -MUST_USE_RES struct LDKBolt12InvoiceFeatures Bolt12Invoice_invoice_features(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); +void ChannelInfo_set_capacity_sats(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); /** - * The public key corresponding to the key used to sign the invoice. + * 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 */ -MUST_USE_RES struct LDKPublicKey Bolt12Invoice_signing_pubkey(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); +struct LDKChannelUpdateInfo ChannelInfo_get_one_to_two(const struct LDKChannelInfo *NONNULL_PTR this_ptr); /** - * Signature of the invoice verified using [`Bolt12Invoice::signing_pubkey`]. + * 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 */ -MUST_USE_RES struct LDKSchnorrSignature Bolt12Invoice_signature(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); +void ChannelInfo_set_one_to_two(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKChannelUpdateInfo val); /** - * Hash that was used for signing the invoice. + * 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 */ -MUST_USE_RES struct LDKThirtyTwoBytes Bolt12Invoice_signable_hash(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); +struct LDKChannelUpdateInfo ChannelInfo_get_two_to_one(const struct LDKChannelInfo *NONNULL_PTR this_ptr); /** - * Verifies that the invoice was for a request or refund created using the given key. Returns - * the associated [`PaymentId`] to use when sending the payment. + * 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 */ -MUST_USE_RES struct LDKCResult_ThirtyTwoBytesNoneZ Bolt12Invoice_verify(const struct LDKBolt12Invoice *NONNULL_PTR this_arg, const struct LDKExpandedKey *NONNULL_PTR key); +void ChannelInfo_set_two_to_one(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKChannelUpdateInfo val); /** - * Generates a non-cryptographic 64-bit hash of the Bolt12Invoice. + * 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 */ -uint64_t Bolt12Invoice_hash(const struct LDKBolt12Invoice *NONNULL_PTR o); +struct LDKChannelAnnouncement ChannelInfo_get_announcement_message(const struct LDKChannelInfo *NONNULL_PTR this_ptr); /** - * Serialize the UnsignedBolt12Invoice object into a byte array which can be read by UnsignedBolt12Invoice_read + * 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 */ -struct LDKCVec_u8Z UnsignedBolt12Invoice_write(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR obj); +void ChannelInfo_set_announcement_message(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKChannelAnnouncement val); /** - * Serialize the Bolt12Invoice object into a byte array which can be read by Bolt12Invoice_read + * Creates a copy of the ChannelInfo */ -struct LDKCVec_u8Z Bolt12Invoice_write(const struct LDKBolt12Invoice *NONNULL_PTR obj); +struct LDKChannelInfo ChannelInfo_clone(const struct LDKChannelInfo *NONNULL_PTR orig); /** - * Frees any resources used by the BlindedPayInfo, 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 BlindedPayInfo_free(struct LDKBlindedPayInfo this_obj); +bool ChannelInfo_eq(const struct LDKChannelInfo *NONNULL_PTR a, const struct LDKChannelInfo *NONNULL_PTR b); /** - * Base fee charged (in millisatoshi) for the entire blinded path. + * 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 */ -uint32_t BlindedPayInfo_get_fee_base_msat(const struct LDKBlindedPayInfo *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKChannelUpdateInfo ChannelInfo_get_directional_info(const struct LDKChannelInfo *NONNULL_PTR this_arg, uint8_t channel_flags); /** - * Base fee charged (in millisatoshi) for the entire blinded path. + * Get the string representation of a ChannelInfo object */ -void BlindedPayInfo_set_fee_base_msat(struct LDKBlindedPayInfo *NONNULL_PTR this_ptr, uint32_t val); +struct LDKStr ChannelInfo_to_str(const struct LDKChannelInfo *NONNULL_PTR o); /** - * Liquidity fee charged (in millionths of the amount transferred) for the entire blinded path - * (i.e., 10,000 is 1%). + * Serialize the ChannelInfo object into a byte array which can be read by ChannelInfo_read */ -uint32_t BlindedPayInfo_get_fee_proportional_millionths(const struct LDKBlindedPayInfo *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z ChannelInfo_write(const struct LDKChannelInfo *NONNULL_PTR obj); /** - * Liquidity fee charged (in millionths of the amount transferred) for the entire blinded path - * (i.e., 10,000 is 1%). + * Read a ChannelInfo from a byte array, created by ChannelInfo_write */ -void BlindedPayInfo_set_fee_proportional_millionths(struct LDKBlindedPayInfo *NONNULL_PTR this_ptr, uint32_t val); +struct LDKCResult_ChannelInfoDecodeErrorZ ChannelInfo_read(struct LDKu8slice ser); /** - * Number of blocks subtracted from an incoming HTLC's `cltv_expiry` for the entire blinded - * path. + * Frees any resources used by the DirectedChannelInfo, if is_owned is set and inner is non-NULL. */ -uint16_t BlindedPayInfo_get_cltv_expiry_delta(const struct LDKBlindedPayInfo *NONNULL_PTR this_ptr); +void DirectedChannelInfo_free(struct LDKDirectedChannelInfo this_obj); /** - * Number of blocks subtracted from an incoming HTLC's `cltv_expiry` for the entire blinded - * path. + * Creates a copy of the DirectedChannelInfo */ -void BlindedPayInfo_set_cltv_expiry_delta(struct LDKBlindedPayInfo *NONNULL_PTR this_ptr, uint16_t val); +struct LDKDirectedChannelInfo DirectedChannelInfo_clone(const struct LDKDirectedChannelInfo *NONNULL_PTR orig); /** - * 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. + * Returns information for the channel. */ -uint64_t BlindedPayInfo_get_htlc_minimum_msat(const struct LDKBlindedPayInfo *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKChannelInfo DirectedChannelInfo_channel(const struct LDKDirectedChannelInfo *NONNULL_PTR this_arg); /** - * 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. + * 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. */ -void BlindedPayInfo_set_htlc_minimum_msat(struct LDKBlindedPayInfo *NONNULL_PTR this_ptr, uint64_t val); +MUST_USE_RES struct LDKEffectiveCapacity DirectedChannelInfo_effective_capacity(const struct LDKDirectedChannelInfo *NONNULL_PTR this_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. + * Returns the `node_id` of the source hop. + * + * Refers to the `node_id` forwarding the payment to the next hop. */ -uint64_t BlindedPayInfo_get_htlc_maximum_msat(const struct LDKBlindedPayInfo *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKNodeId DirectedChannelInfo_source(const struct LDKDirectedChannelInfo *NONNULL_PTR this_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. + * Returns the `node_id` of the target hop. + * + * Refers to the `node_id` receiving the payment from the previous hop. */ -void BlindedPayInfo_set_htlc_maximum_msat(struct LDKBlindedPayInfo *NONNULL_PTR this_ptr, uint64_t val); +MUST_USE_RES struct LDKNodeId DirectedChannelInfo_target(const struct LDKDirectedChannelInfo *NONNULL_PTR this_arg); /** - * Features set in `encrypted_data_tlv` for the `encrypted_recipient_data` TLV record in an - * onion payload. + * Frees any resources used by the EffectiveCapacity */ -struct LDKBlindedHopFeatures BlindedPayInfo_get_features(const struct LDKBlindedPayInfo *NONNULL_PTR this_ptr); +void EffectiveCapacity_free(struct LDKEffectiveCapacity this_ptr); /** - * Features set in `encrypted_data_tlv` for the `encrypted_recipient_data` TLV record in an - * onion payload. + * Creates a copy of the EffectiveCapacity */ -void BlindedPayInfo_set_features(struct LDKBlindedPayInfo *NONNULL_PTR this_ptr, struct LDKBlindedHopFeatures val); +struct LDKEffectiveCapacity EffectiveCapacity_clone(const struct LDKEffectiveCapacity *NONNULL_PTR orig); /** - * Constructs a new BlindedPayInfo given each field + * Utility method to constructs a new ExactLiquidity-variant EffectiveCapacity */ -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); +struct LDKEffectiveCapacity EffectiveCapacity_exact_liquidity(uint64_t liquidity_msat); /** - * Creates a copy of the BlindedPayInfo + * Utility method to constructs a new AdvertisedMaxHTLC-variant EffectiveCapacity */ -struct LDKBlindedPayInfo BlindedPayInfo_clone(const struct LDKBlindedPayInfo *NONNULL_PTR orig); +struct LDKEffectiveCapacity EffectiveCapacity_advertised_max_htlc(uint64_t amount_msat); /** - * Generates a non-cryptographic 64-bit hash of the BlindedPayInfo. + * Utility method to constructs a new Total-variant EffectiveCapacity */ -uint64_t BlindedPayInfo_hash(const struct LDKBlindedPayInfo *NONNULL_PTR o); +struct LDKEffectiveCapacity EffectiveCapacity_total(uint64_t capacity_msat, uint64_t htlc_maximum_msat); /** - * 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. + * Utility method to constructs a new Infinite-variant EffectiveCapacity */ -bool BlindedPayInfo_eq(const struct LDKBlindedPayInfo *NONNULL_PTR a, const struct LDKBlindedPayInfo *NONNULL_PTR b); +struct LDKEffectiveCapacity EffectiveCapacity_infinite(void); /** - * Serialize the BlindedPayInfo object into a byte array which can be read by BlindedPayInfo_read + * Utility method to constructs a new HintMaxHTLC-variant EffectiveCapacity */ -struct LDKCVec_u8Z BlindedPayInfo_write(const struct LDKBlindedPayInfo *NONNULL_PTR obj); +struct LDKEffectiveCapacity EffectiveCapacity_hint_max_htlc(uint64_t amount_msat); /** - * Read a BlindedPayInfo from a byte array, created by BlindedPayInfo_write + * Utility method to constructs a new Unknown-variant EffectiveCapacity */ -struct LDKCResult_BlindedPayInfoDecodeErrorZ BlindedPayInfo_read(struct LDKu8slice ser); +struct LDKEffectiveCapacity EffectiveCapacity_unknown(void); /** - * Frees any resources used by the InvoiceError, if is_owned is set and inner is non-NULL. + * Returns the effective capacity denominated in millisatoshi. */ -void InvoiceError_free(struct LDKInvoiceError this_obj); +MUST_USE_RES uint64_t EffectiveCapacity_as_msat(const struct LDKEffectiveCapacity *NONNULL_PTR this_arg); /** - * 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 + * Serialize the RoutingFees object into a byte array which can be read by RoutingFees_read */ -struct LDKErroneousField InvoiceError_get_erroneous_field(const struct LDKInvoiceError *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z RoutingFees_write(const struct LDKRoutingFees *NONNULL_PTR obj); /** - * 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 + * Read a RoutingFees from a byte array, created by RoutingFees_write */ -void InvoiceError_set_erroneous_field(struct LDKInvoiceError *NONNULL_PTR this_ptr, struct LDKErroneousField val); +struct LDKCResult_RoutingFeesDecodeErrorZ RoutingFees_read(struct LDKu8slice ser); /** - * An explanation of the error. + * Frees any resources used by the NodeAnnouncementDetails, if is_owned is set and inner is non-NULL. */ -struct LDKUntrustedString InvoiceError_get_message(const struct LDKInvoiceError *NONNULL_PTR this_ptr); +void NodeAnnouncementDetails_free(struct LDKNodeAnnouncementDetails this_obj); /** - * An explanation of the error. + * Protocol features the node announced support for */ -void InvoiceError_set_message(struct LDKInvoiceError *NONNULL_PTR this_ptr, struct LDKUntrustedString val); +struct LDKNodeFeatures NodeAnnouncementDetails_get_features(const struct LDKNodeAnnouncementDetails *NONNULL_PTR this_ptr); /** - * Constructs a new InvoiceError given each field - * - * Note that erroneous_field_arg (or a relevant inner pointer) may be NULL or all-0s to represent None + * Protocol features the node announced support for */ -MUST_USE_RES struct LDKInvoiceError InvoiceError_new(struct LDKErroneousField erroneous_field_arg, struct LDKUntrustedString message_arg); +void NodeAnnouncementDetails_set_features(struct LDKNodeAnnouncementDetails *NONNULL_PTR this_ptr, struct LDKNodeFeatures val); /** - * Creates a copy of the InvoiceError + * When the last known update to the node state was issued. + * Value is opaque, as set in the announcement. */ -struct LDKInvoiceError InvoiceError_clone(const struct LDKInvoiceError *NONNULL_PTR orig); +uint32_t NodeAnnouncementDetails_get_last_update(const struct LDKNodeAnnouncementDetails *NONNULL_PTR this_ptr); /** - * Frees any resources used by the ErroneousField, if is_owned is set and inner is non-NULL. + * When the last known update to the node state was issued. + * Value is opaque, as set in the announcement. */ -void ErroneousField_free(struct LDKErroneousField this_obj); +void NodeAnnouncementDetails_set_last_update(struct LDKNodeAnnouncementDetails *NONNULL_PTR this_ptr, uint32_t val); /** - * The type number of the TLV field containing the error. + * Color assigned to the node */ -uint64_t ErroneousField_get_tlv_fieldnum(const struct LDKErroneousField *NONNULL_PTR this_ptr); +const uint8_t (*NodeAnnouncementDetails_get_rgb(const struct LDKNodeAnnouncementDetails *NONNULL_PTR this_ptr))[3]; /** - * The type number of the TLV field containing the error. + * Color assigned to the node */ -void ErroneousField_set_tlv_fieldnum(struct LDKErroneousField *NONNULL_PTR this_ptr, uint64_t val); +void NodeAnnouncementDetails_set_rgb(struct LDKNodeAnnouncementDetails *NONNULL_PTR this_ptr, struct LDKThreeBytes val); /** - * A value to use for the TLV field to avoid the error. + * Moniker assigned to the node. + * May be invalid or malicious (eg control chars), + * should not be exposed to the user. + */ +struct LDKNodeAlias NodeAnnouncementDetails_get_alias(const struct LDKNodeAnnouncementDetails *NONNULL_PTR this_ptr); + +/** + * Moniker assigned to the node. + * May be invalid or malicious (eg control chars), + * should not be exposed to the user. + */ +void NodeAnnouncementDetails_set_alias(struct LDKNodeAnnouncementDetails *NONNULL_PTR this_ptr, struct LDKNodeAlias val); + +/** + * Internet-level addresses via which one can connect to the node * * Returns a copy of the field. */ -struct LDKCOption_CVec_u8ZZ ErroneousField_get_suggested_value(const struct LDKErroneousField *NONNULL_PTR this_ptr); +struct LDKCVec_SocketAddressZ NodeAnnouncementDetails_get_addresses(const struct LDKNodeAnnouncementDetails *NONNULL_PTR this_ptr); /** - * A value to use for the TLV field to avoid the error. + * Internet-level addresses via which one can connect to the node */ -void ErroneousField_set_suggested_value(struct LDKErroneousField *NONNULL_PTR this_ptr, struct LDKCOption_CVec_u8ZZ val); +void NodeAnnouncementDetails_set_addresses(struct LDKNodeAnnouncementDetails *NONNULL_PTR this_ptr, struct LDKCVec_SocketAddressZ val); /** - * Constructs a new ErroneousField given each field + * Constructs a new NodeAnnouncementDetails given each field */ -MUST_USE_RES struct LDKErroneousField ErroneousField_new(uint64_t tlv_fieldnum_arg, struct LDKCOption_CVec_u8ZZ suggested_value_arg); +MUST_USE_RES struct LDKNodeAnnouncementDetails NodeAnnouncementDetails_new(struct LDKNodeFeatures features_arg, uint32_t last_update_arg, struct LDKThreeBytes rgb_arg, struct LDKNodeAlias alias_arg, struct LDKCVec_SocketAddressZ addresses_arg); /** - * Creates a copy of the ErroneousField + * Creates a copy of the NodeAnnouncementDetails */ -struct LDKErroneousField ErroneousField_clone(const struct LDKErroneousField *NONNULL_PTR orig); +struct LDKNodeAnnouncementDetails NodeAnnouncementDetails_clone(const struct LDKNodeAnnouncementDetails *NONNULL_PTR orig); /** - * Creates an [`InvoiceError`] with the given message. + * Checks if two NodeAnnouncementDetailss 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 LDKInvoiceError InvoiceError_from_string(struct LDKStr s); +bool NodeAnnouncementDetails_eq(const struct LDKNodeAnnouncementDetails *NONNULL_PTR a, const struct LDKNodeAnnouncementDetails *NONNULL_PTR b); /** - * Get the string representation of a InvoiceError object + * Frees any resources used by the NodeAnnouncementInfo */ -struct LDKStr InvoiceError_to_str(const struct LDKInvoiceError *NONNULL_PTR o); +void NodeAnnouncementInfo_free(struct LDKNodeAnnouncementInfo this_ptr); /** - * Serialize the InvoiceError object into a byte array which can be read by InvoiceError_read + * Creates a copy of the NodeAnnouncementInfo */ -struct LDKCVec_u8Z InvoiceError_write(const struct LDKInvoiceError *NONNULL_PTR obj); +struct LDKNodeAnnouncementInfo NodeAnnouncementInfo_clone(const struct LDKNodeAnnouncementInfo *NONNULL_PTR orig); /** - * Read a InvoiceError from a byte array, created by InvoiceError_write + * Utility method to constructs a new Relayed-variant NodeAnnouncementInfo */ -struct LDKCResult_InvoiceErrorDecodeErrorZ InvoiceError_read(struct LDKu8slice ser); +struct LDKNodeAnnouncementInfo NodeAnnouncementInfo_relayed(struct LDKNodeAnnouncement a); /** - * Frees any resources used by the InvoiceRequestWithExplicitPayerIdBuilder, if is_owned is set and inner is non-NULL. + * Utility method to constructs a new Local-variant NodeAnnouncementInfo */ -void InvoiceRequestWithExplicitPayerIdBuilder_free(struct LDKInvoiceRequestWithExplicitPayerIdBuilder this_obj); +struct LDKNodeAnnouncementInfo NodeAnnouncementInfo_local(struct LDKNodeAnnouncementDetails a); /** - * Frees any resources used by the InvoiceRequestWithDerivedPayerIdBuilder, if is_owned is set and inner is non-NULL. + * Checks if two NodeAnnouncementInfos contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -void InvoiceRequestWithDerivedPayerIdBuilder_free(struct LDKInvoiceRequestWithDerivedPayerIdBuilder this_obj); +bool NodeAnnouncementInfo_eq(const struct LDKNodeAnnouncementInfo *NONNULL_PTR a, const struct LDKNodeAnnouncementInfo *NONNULL_PTR b); /** - * Builds an unsigned [`InvoiceRequest`] after checking for valid semantics. It can be signed - * by [`UnsignedInvoiceRequest::sign`]. + * Protocol features the node announced support for */ -MUST_USE_RES struct LDKCResult_UnsignedInvoiceRequestBolt12SemanticErrorZ InvoiceRequestWithExplicitPayerIdBuilder_build(struct LDKInvoiceRequestWithExplicitPayerIdBuilder this_arg); +MUST_USE_RES struct LDKNodeFeatures NodeAnnouncementInfo_features(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_arg); /** - * Sets the [`InvoiceRequest::chain`] of the given [`Network`] for paying an invoice. If not - * called, [`Network::Bitcoin`] is assumed. Errors if the chain for `network` is not supported - * by the offer. + * When the last known update to the node state was issued. * - * Successive calls to this method will override the previous setting. + * Value may or may not be a timestamp, depending on the policy of the origin node. */ -MUST_USE_RES struct LDKCResult_NoneBolt12SemanticErrorZ InvoiceRequestWithExplicitPayerIdBuilder_chain(struct LDKInvoiceRequestWithExplicitPayerIdBuilder this_arg, enum LDKNetwork network); +MUST_USE_RES uint32_t NodeAnnouncementInfo_last_update(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_arg); /** - * Sets the [`InvoiceRequest::amount_msats`] for paying an invoice. Errors if `amount_msats` is - * not at least the expected invoice amount (i.e., [`Offer::amount`] times [`quantity`]). - * - * Successive calls to this method will override the previous setting. - * - * [`quantity`]: Self::quantity + * Color assigned to the node */ -MUST_USE_RES struct LDKCResult_NoneBolt12SemanticErrorZ InvoiceRequestWithExplicitPayerIdBuilder_amount_msats(struct LDKInvoiceRequestWithExplicitPayerIdBuilder this_arg, uint64_t amount_msats); +MUST_USE_RES struct LDKThreeBytes NodeAnnouncementInfo_rgb(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_arg); /** - * Sets [`InvoiceRequest::quantity`] of items. If not set, `1` is assumed. Errors if `quantity` - * does not conform to [`Offer::is_valid_quantity`]. + * Moniker assigned to the node. * - * Successive calls to this method will override the previous setting. + * May be invalid or malicious (eg control chars), should not be exposed to the user. */ -MUST_USE_RES struct LDKCResult_NoneBolt12SemanticErrorZ InvoiceRequestWithExplicitPayerIdBuilder_quantity(struct LDKInvoiceRequestWithExplicitPayerIdBuilder this_arg, uint64_t quantity); +MUST_USE_RES struct LDKNodeAlias NodeAnnouncementInfo_alias(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_arg); /** - * Sets the [`InvoiceRequest::payer_note`]. + * Internet-level addresses via which one can connect to the node + */ +MUST_USE_RES struct LDKCVec_SocketAddressZ NodeAnnouncementInfo_addresses(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_arg); + +/** + * An initial announcement of the node * - * Successive calls to this method will override the previous setting. + * 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 void InvoiceRequestWithExplicitPayerIdBuilder_payer_note(struct LDKInvoiceRequestWithExplicitPayerIdBuilder this_arg, struct LDKStr payer_note); +MUST_USE_RES struct LDKNodeAnnouncement NodeAnnouncementInfo_announcement_message(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_arg); /** - * Builds a signed [`InvoiceRequest`] after checking for valid semantics. + * Serialize the NodeAnnouncementInfo object into a byte array which can be read by NodeAnnouncementInfo_read */ -MUST_USE_RES struct LDKCResult_InvoiceRequestBolt12SemanticErrorZ InvoiceRequestWithDerivedPayerIdBuilder_build_and_sign(struct LDKInvoiceRequestWithDerivedPayerIdBuilder this_arg); +struct LDKCVec_u8Z NodeAnnouncementInfo_write(const struct LDKNodeAnnouncementInfo *NONNULL_PTR obj); /** - * Sets the [`InvoiceRequest::chain`] of the given [`Network`] for paying an invoice. If not - * called, [`Network::Bitcoin`] is assumed. Errors if the chain for `network` is not supported - * by the offer. - * - * Successive calls to this method will override the previous setting. + * Read a NodeAnnouncementInfo from a byte array, created by NodeAnnouncementInfo_write */ -MUST_USE_RES struct LDKCResult_NoneBolt12SemanticErrorZ InvoiceRequestWithDerivedPayerIdBuilder_chain(struct LDKInvoiceRequestWithDerivedPayerIdBuilder this_arg, enum LDKNetwork network); +struct LDKCResult_NodeAnnouncementInfoDecodeErrorZ NodeAnnouncementInfo_read(struct LDKu8slice ser); /** - * Sets the [`InvoiceRequest::amount_msats`] for paying an invoice. Errors if `amount_msats` is - * not at least the expected invoice amount (i.e., [`Offer::amount`] times [`quantity`]). - * - * Successive calls to this method will override the previous setting. - * - * [`quantity`]: Self::quantity + * Frees any resources used by the NodeAlias, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKCResult_NoneBolt12SemanticErrorZ InvoiceRequestWithDerivedPayerIdBuilder_amount_msats(struct LDKInvoiceRequestWithDerivedPayerIdBuilder this_arg, uint64_t amount_msats); +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); /** - * Sets [`InvoiceRequest::quantity`] of items. If not set, `1` is assumed. Errors if `quantity` - * does not conform to [`Offer::is_valid_quantity`]. + * Constructs a new NodeAlias given each field + */ +MUST_USE_RES struct LDKNodeAlias NodeAlias_new(struct LDKThirtyTwoBytes a_arg); + +/** + * Creates a copy of the NodeAlias + */ +struct LDKNodeAlias NodeAlias_clone(const struct LDKNodeAlias *NONNULL_PTR orig); + +/** + * Generates a non-cryptographic 64-bit hash of the NodeAlias. + */ +uint64_t NodeAlias_hash(const struct LDKNodeAlias *NONNULL_PTR o); + +/** + * 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. + */ +bool NodeAlias_eq(const struct LDKNodeAlias *NONNULL_PTR a, const struct LDKNodeAlias *NONNULL_PTR b); + +/** + * Get the string representation of a NodeAlias object + */ +struct LDKStr NodeAlias_to_str(const struct LDKNodeAlias *NONNULL_PTR o); + +/** + * Serialize the NodeAlias object into a byte array which can be read by NodeAlias_read + */ +struct LDKCVec_u8Z NodeAlias_write(const struct LDKNodeAlias *NONNULL_PTR obj); + +/** + * Read a NodeAlias from a byte array, created by NodeAlias_write + */ +struct LDKCResult_NodeAliasDecodeErrorZ NodeAlias_read(struct LDKu8slice ser); + +/** + * Frees any resources used by the NodeInfo, if is_owned is set and inner is non-NULL. + */ +void NodeInfo_free(struct LDKNodeInfo this_obj); + +/** + * All valid channels a node has announced * - * Successive calls to this method will override the previous setting. + * Returns a copy of the field. */ -MUST_USE_RES struct LDKCResult_NoneBolt12SemanticErrorZ InvoiceRequestWithDerivedPayerIdBuilder_quantity(struct LDKInvoiceRequestWithDerivedPayerIdBuilder this_arg, uint64_t quantity); +struct LDKCVec_u64Z NodeInfo_get_channels(const struct LDKNodeInfo *NONNULL_PTR this_ptr); /** - * Sets the [`InvoiceRequest::payer_note`]. + * All valid channels a node has announced + */ +void NodeInfo_set_channels(struct LDKNodeInfo *NONNULL_PTR this_ptr, struct LDKCVec_u64Z 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. * - * Successive calls to this method will override the previous setting. + * Returns a copy of the field. */ -MUST_USE_RES void InvoiceRequestWithDerivedPayerIdBuilder_payer_note(struct LDKInvoiceRequestWithDerivedPayerIdBuilder this_arg, struct LDKStr payer_note); +struct LDKCOption_NodeAnnouncementInfoZ NodeInfo_get_announcement_info(const struct LDKNodeInfo *NONNULL_PTR this_ptr); /** - * Frees any resources used by the UnsignedInvoiceRequest, if is_owned is set and inner is non-NULL. + * 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. */ -void UnsignedInvoiceRequest_free(struct LDKUnsignedInvoiceRequest this_obj); +void NodeInfo_set_announcement_info(struct LDKNodeInfo *NONNULL_PTR this_ptr, struct LDKCOption_NodeAnnouncementInfoZ val); /** - * Creates a copy of the UnsignedInvoiceRequest + * Creates a copy of the NodeInfo */ -struct LDKUnsignedInvoiceRequest UnsignedInvoiceRequest_clone(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR orig); +struct LDKNodeInfo NodeInfo_clone(const struct LDKNodeInfo *NONNULL_PTR orig); /** - * Calls the free function if one is set + * 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 SignInvoiceRequestFn_free(struct LDKSignInvoiceRequestFn this_ptr); +bool NodeInfo_eq(const struct LDKNodeInfo *NONNULL_PTR a, const struct LDKNodeInfo *NONNULL_PTR b); /** - * Returns the [`TaggedHash`] of the invoice to sign. + * Returns whether the node has only announced Tor addresses. */ -MUST_USE_RES struct LDKTaggedHash UnsignedInvoiceRequest_tagged_hash(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); +MUST_USE_RES bool NodeInfo_is_tor_only(const struct LDKNodeInfo *NONNULL_PTR this_arg); /** - * Frees any resources used by the InvoiceRequest, if is_owned is set and inner is non-NULL. + * Get the string representation of a NodeInfo object */ -void InvoiceRequest_free(struct LDKInvoiceRequest this_obj); +struct LDKStr NodeInfo_to_str(const struct LDKNodeInfo *NONNULL_PTR o); /** - * Creates a copy of the InvoiceRequest + * Serialize the NodeInfo object into a byte array which can be read by NodeInfo_read */ -struct LDKInvoiceRequest InvoiceRequest_clone(const struct LDKInvoiceRequest *NONNULL_PTR orig); +struct LDKCVec_u8Z NodeInfo_write(const struct LDKNodeInfo *NONNULL_PTR obj); /** - * Frees any resources used by the VerifiedInvoiceRequest, if is_owned is set and inner is non-NULL. + * Read a NodeInfo from a byte array, created by NodeInfo_write */ -void VerifiedInvoiceRequest_free(struct LDKVerifiedInvoiceRequest this_obj); +struct LDKCResult_NodeInfoDecodeErrorZ NodeInfo_read(struct LDKu8slice ser); /** - * The identifier of the [`Offer`] for which the [`InvoiceRequest`] was made. + * Serialize the NetworkGraph object into a byte array which can be read by NetworkGraph_read */ -struct LDKOfferId VerifiedInvoiceRequest_get_offer_id(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z NetworkGraph_write(const struct LDKNetworkGraph *NONNULL_PTR obj); /** - * The identifier of the [`Offer`] for which the [`InvoiceRequest`] was made. + * Read a NetworkGraph from a byte array, created by NetworkGraph_write */ -void VerifiedInvoiceRequest_set_offer_id(struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_ptr, struct LDKOfferId val); +struct LDKCResult_NetworkGraphDecodeErrorZ NetworkGraph_read(struct LDKu8slice ser, struct LDKLogger arg); /** - * Keys used for signing a [`Bolt12Invoice`] if they can be derived. - * - * If `Some`, must call [`respond_using_derived_keys`] when responding. Otherwise, call - * [`respond_with`]. - * - * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice - * [`respond_using_derived_keys`]: Self::respond_using_derived_keys - * [`respond_with`]: Self::respond_with + * Get the string representation of a NetworkGraph object */ -struct LDKCOption_SecretKeyZ VerifiedInvoiceRequest_get_keys(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_ptr); +struct LDKStr NetworkGraph_to_str(const struct LDKNetworkGraph *NONNULL_PTR o); /** - * Keys used for signing a [`Bolt12Invoice`] if they can be derived. - * - * If `Some`, must call [`respond_using_derived_keys`] when responding. Otherwise, call - * [`respond_with`]. - * - * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice - * [`respond_using_derived_keys`]: Self::respond_using_derived_keys - * [`respond_with`]: Self::respond_with + * Creates a new, empty, network graph. */ -void VerifiedInvoiceRequest_set_keys(struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_ptr, struct LDKCOption_SecretKeyZ val); +MUST_USE_RES struct LDKNetworkGraph NetworkGraph_new(enum LDKNetwork network, struct LDKLogger logger); /** - * Creates a copy of the VerifiedInvoiceRequest + * Returns a read-only view of the network graph. */ -struct LDKVerifiedInvoiceRequest VerifiedInvoiceRequest_clone(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR orig); +MUST_USE_RES struct LDKReadOnlyNetworkGraph NetworkGraph_read_only(const struct LDKNetworkGraph *NONNULL_PTR this_arg); /** - * 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. + * The unix timestamp provided by the most recent rapid gossip sync. + * It will be set by the rapid sync process after every sync completion. */ -MUST_USE_RES struct LDKCVec_ThirtyTwoBytesZ UnsignedInvoiceRequest_chains(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCOption_u32Z NetworkGraph_get_last_rapid_gossip_sync_timestamp(const struct LDKNetworkGraph *NONNULL_PTR this_arg); /** - * 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`. + * 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. */ -MUST_USE_RES struct LDKCOption_CVec_u8ZZ UnsignedInvoiceRequest_metadata(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); +void NetworkGraph_set_last_rapid_gossip_sync_timestamp(const struct LDKNetworkGraph *NONNULL_PTR this_arg, uint32_t last_rapid_gossip_sync_timestamp); /** - * The minimum amount required for a successful payment of a single item. + * 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 LDKCOption_AmountZ UnsignedInvoiceRequest_amount(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_node_from_announcement(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKNodeAnnouncement *NONNULL_PTR msg); /** - * 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. + * 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. + */ +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); + +/** + * Store or update channel info from a channel announcement. * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * 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. */ -MUST_USE_RES struct LDKPrintableString UnsignedInvoiceRequest_description(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); +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); /** - * Features pertaining to the offer. + * 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_RES struct LDKOfferFeatures UnsignedInvoiceRequest_offer_features(const struct LDKUnsignedInvoiceRequest *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); /** - * Duration since the Unix epoch when an invoice should no longer be requested. + * 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 `None`, the offer does not expire. + * 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. */ -MUST_USE_RES struct LDKCOption_u64Z UnsignedInvoiceRequest_absolute_expiry(const struct LDKUnsignedInvoiceRequest *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); /** - * 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. + * Update channel from partial announcement data received via rapid gossip sync * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * `timestamp: u64`: Timestamp emulating the backdated original announcement receipt (by the + * rapid gossip sync server) + * + * All other parameters as used in [`msgs::UnsignedChannelAnnouncement`] fields. */ -MUST_USE_RES struct LDKPrintableString UnsignedInvoiceRequest_issuer(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); +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); /** - * Paths to the recipient originating from publicly reachable nodes. Blinded paths provide - * recipient privacy by obfuscating its node id. + * 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. */ -MUST_USE_RES struct LDKCVec_BlindedPathZ UnsignedInvoiceRequest_paths(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); +void NetworkGraph_channel_failed_permanent(const struct LDKNetworkGraph *NONNULL_PTR this_arg, uint64_t short_channel_id); /** - * The quantity of items supported. + * Marks a node in the graph as permanently failed, effectively removing it and its channels + * from local storage. */ -MUST_USE_RES struct LDKQuantity UnsignedInvoiceRequest_supported_quantity(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); +void NetworkGraph_node_failed_permanent(const struct LDKNetworkGraph *NONNULL_PTR this_arg, struct LDKPublicKey node_id); /** - * The public key used by the recipient to sign invoices. + * 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. * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * 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. */ -MUST_USE_RES struct LDKPublicKey UnsignedInvoiceRequest_signing_pubkey(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); +void NetworkGraph_remove_stale_channels_and_tracking(const struct LDKNetworkGraph *NONNULL_PTR this_arg); /** - * An unpredictable series of bytes, typically containing information about the derivation of - * [`payer_id`]. + * 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. * - * [`payer_id`]: Self::payer_id + * 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. */ -MUST_USE_RES struct LDKu8slice UnsignedInvoiceRequest_payer_metadata(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); +void NetworkGraph_remove_stale_channels_and_tracking_with_time(const struct LDKNetworkGraph *NONNULL_PTR this_arg, uint64_t current_time_unix); /** - * A chain from [`Offer::chains`] that the offer is valid for. + * 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. */ -MUST_USE_RES struct LDKThirtyTwoBytes UnsignedInvoiceRequest_chain(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKChannelUpdate *NONNULL_PTR msg); /** - * 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. + * 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. * - * [`chain`]: Self::chain + * 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. */ -MUST_USE_RES struct LDKCOption_u64Z UnsignedInvoiceRequest_amount_msats(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_unsigned(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKUnsignedChannelUpdate *NONNULL_PTR msg); /** - * Features pertaining to requesting an invoice. + * For an already known (from announcement) channel, verify the given [`ChannelUpdate`]. + * + * This checks whether the update currently is applicable by [`Self::update_channel`]. + * + * 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. */ -MUST_USE_RES struct LDKInvoiceRequestFeatures UnsignedInvoiceRequest_invoice_request_features(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_verify_channel_update(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKChannelUpdate *NONNULL_PTR msg); /** - * The quantity of the offer's item conforming to [`Offer::is_valid_quantity`]. + * 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 */ -MUST_USE_RES struct LDKCOption_u64Z UnsignedInvoiceRequest_quantity(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKChannelInfo ReadOnlyNetworkGraph_channel(const struct LDKReadOnlyNetworkGraph *NONNULL_PTR this_arg, uint64_t short_channel_id); /** - * A possibly transient pubkey used to sign the invoice request. + * Returns the list of channels in the graph */ -MUST_USE_RES struct LDKPublicKey UnsignedInvoiceRequest_payer_id(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCVec_u64Z ReadOnlyNetworkGraph_list_channels(const struct LDKReadOnlyNetworkGraph *NONNULL_PTR this_arg); /** - * A payer-provided note which will be seen by the recipient and reflected back in the invoice - * response. + * 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 */ -MUST_USE_RES struct LDKPrintableString UnsignedInvoiceRequest_payer_note(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKNodeInfo ReadOnlyNetworkGraph_node(const struct LDKReadOnlyNetworkGraph *NONNULL_PTR this_arg, const struct LDKNodeId *NONNULL_PTR node_id); /** - * 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. + * Returns the list of nodes in the graph */ -MUST_USE_RES struct LDKCVec_ThirtyTwoBytesZ InvoiceRequest_chains(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCVec_NodeIdZ ReadOnlyNetworkGraph_list_nodes(const struct LDKReadOnlyNetworkGraph *NONNULL_PTR this_arg); /** - * 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`. + * 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. */ -MUST_USE_RES struct LDKCOption_CVec_u8ZZ InvoiceRequest_metadata(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCOption_CVec_SocketAddressZZ ReadOnlyNetworkGraph_get_addresses(const struct LDKReadOnlyNetworkGraph *NONNULL_PTR this_arg, struct LDKPublicKey pubkey); /** - * The minimum amount required for a successful payment of a single item. + * Frees any resources used by the DefaultRouter, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKCOption_AmountZ InvoiceRequest_amount(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); +void DefaultRouter_free(struct LDKDefaultRouter this_obj); /** - * 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. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Creates a new router. */ -MUST_USE_RES struct LDKPrintableString InvoiceRequest_description(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKDefaultRouter DefaultRouter_new(const struct LDKNetworkGraph *NONNULL_PTR network_graph, struct LDKLogger logger, struct LDKEntropySource entropy_source, struct LDKLockableScore scorer, struct LDKProbabilisticScoringFeeParameters score_params); /** - * Features pertaining to the offer. + * 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 */ -MUST_USE_RES struct LDKOfferFeatures InvoiceRequest_offer_features(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); +struct LDKRouter DefaultRouter_as_Router(const struct LDKDefaultRouter *NONNULL_PTR this_arg); /** - * Duration since the Unix epoch when an invoice should no longer be requested. + * 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 + */ +struct LDKMessageRouter DefaultRouter_as_MessageRouter(const struct LDKDefaultRouter *NONNULL_PTR this_arg); + +/** + * Calls the free function if one is set + */ +void Router_free(struct LDKRouter this_ptr); + +/** + * Frees any resources used by the ScorerAccountingForInFlightHtlcs, if is_owned is set and inner is non-NULL. + */ +void ScorerAccountingForInFlightHtlcs_free(struct LDKScorerAccountingForInFlightHtlcs this_obj); + +/** + * Initialize a new `ScorerAccountingForInFlightHtlcs`. + */ +MUST_USE_RES struct LDKScorerAccountingForInFlightHtlcs ScorerAccountingForInFlightHtlcs_new(struct LDKScoreLookUp scorer, const struct LDKInFlightHtlcs *NONNULL_PTR inflight_htlcs); + +/** + * Constructs a new ScoreLookUp which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned ScoreLookUp must be freed before this_arg is + */ +struct LDKScoreLookUp ScorerAccountingForInFlightHtlcs_as_ScoreLookUp(const struct LDKScorerAccountingForInFlightHtlcs *NONNULL_PTR this_arg); + +/** + * Frees any resources used by the InFlightHtlcs, if is_owned is set and inner is non-NULL. + */ +void InFlightHtlcs_free(struct LDKInFlightHtlcs this_obj); + +/** + * Creates a copy of the InFlightHtlcs + */ +struct LDKInFlightHtlcs InFlightHtlcs_clone(const struct LDKInFlightHtlcs *NONNULL_PTR orig); + +/** + * Constructs an empty `InFlightHtlcs`. + */ +MUST_USE_RES struct LDKInFlightHtlcs InFlightHtlcs_new(void); + +/** + * Takes in a path with payer's node id and adds the path's details to `InFlightHtlcs`. + */ +void InFlightHtlcs_process_path(struct LDKInFlightHtlcs *NONNULL_PTR this_arg, const struct LDKPath *NONNULL_PTR path, struct LDKPublicKey payer_node_id); + +/** + * Adds a known HTLC given the public key of the HTLC source, target, and short channel + * id. + */ +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); + +/** + * Returns liquidity in msat given the public key of the HTLC source, target, and short channel + * id. + */ +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); + +/** + * Serialize the InFlightHtlcs object into a byte array which can be read by InFlightHtlcs_read + */ +struct LDKCVec_u8Z InFlightHtlcs_write(const struct LDKInFlightHtlcs *NONNULL_PTR obj); + +/** + * Read a InFlightHtlcs from a byte array, created by InFlightHtlcs_write + */ +struct LDKCResult_InFlightHtlcsDecodeErrorZ InFlightHtlcs_read(struct LDKu8slice ser); + +/** + * Frees any resources used by the RouteHop, if is_owned is set and inner is non-NULL. + */ +void RouteHop_free(struct LDKRouteHop this_obj); + +/** + * The node_id of the node at this hop. + */ +struct LDKPublicKey RouteHop_get_pubkey(const struct LDKRouteHop *NONNULL_PTR this_ptr); + +/** + * The node_id of the node at this hop. + */ +void RouteHop_set_pubkey(struct LDKRouteHop *NONNULL_PTR this_ptr, struct LDKPublicKey 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. + */ +struct LDKNodeFeatures RouteHop_get_node_features(const struct LDKRouteHop *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. + */ +void RouteHop_set_node_features(struct LDKRouteHop *NONNULL_PTR this_ptr, struct LDKNodeFeatures val); + +/** + * The channel that should be used from the previous hop to reach this node. + */ +uint64_t RouteHop_get_short_channel_id(const struct LDKRouteHop *NONNULL_PTR this_ptr); + +/** + * The channel that should be used from the previous hop to reach this node. + */ +void RouteHop_set_short_channel_id(struct LDKRouteHop *NONNULL_PTR this_ptr, uint64_t val); + +/** + * The channel_announcement features of the channel that should be used from the previous hop + * to reach this node. + */ +struct LDKChannelFeatures RouteHop_get_channel_features(const struct LDKRouteHop *NONNULL_PTR this_ptr); + +/** + * The channel_announcement features of the channel that should be used from the previous hop + * to reach this node. + */ +void RouteHop_set_channel_features(struct LDKRouteHop *NONNULL_PTR this_ptr, struct LDKChannelFeatures 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 [`BlindedPaymentPath`], 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 + */ +uint64_t RouteHop_get_fee_msat(const struct LDKRouteHop *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 [`BlindedPaymentPath`], 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 + */ +void RouteHop_set_fee_msat(struct LDKRouteHop *NONNULL_PTR this_ptr, uint64_t val); + +/** + * The CLTV delta added for this hop. + * If this is the last hop in [`Path::hops`]: + * * if we're sending to a [`BlindedPaymentPath`], this is the CLTV delta for the entire blinded + * path + * * otherwise, this is the CLTV delta expected at the destination + */ +uint32_t RouteHop_get_cltv_expiry_delta(const struct LDKRouteHop *NONNULL_PTR this_ptr); + +/** + * The CLTV delta added for this hop. + * If this is the last hop in [`Path::hops`]: + * * if we're sending to a [`BlindedPaymentPath`], this is the CLTV delta for the entire blinded + * path + * * otherwise, this is the CLTV delta expected at the destination + */ +void RouteHop_set_cltv_expiry_delta(struct LDKRouteHop *NONNULL_PTR this_ptr, uint32_t val); + +/** + * Indicates whether this hop is possibly announced in the public network graph. + * + * Will be `true` if there is a possibility that the channel is publicly known, i.e., if we + * either know for sure it's announced in the public graph, or if any public channels exist + * for which the given `short_channel_id` could be an alias for. Will be `false` if we believe + * the channel to be unannounced. + * + * Will be `true` for objects serialized with LDK version 0.0.116 and before. + */ +bool RouteHop_get_maybe_announced_channel(const struct LDKRouteHop *NONNULL_PTR this_ptr); + +/** + * Indicates whether this hop is possibly announced in the public network graph. + * + * Will be `true` if there is a possibility that the channel is publicly known, i.e., if we + * either know for sure it's announced in the public graph, or if any public channels exist + * for which the given `short_channel_id` could be an alias for. Will be `false` if we believe + * the channel to be unannounced. + * + * Will be `true` for objects serialized with LDK version 0.0.116 and before. + */ +void RouteHop_set_maybe_announced_channel(struct LDKRouteHop *NONNULL_PTR this_ptr, bool val); + +/** + * Constructs a new RouteHop given each field + */ +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, bool maybe_announced_channel_arg); + +/** + * Creates a copy of the RouteHop + */ +struct LDKRouteHop RouteHop_clone(const struct LDKRouteHop *NONNULL_PTR orig); + +/** + * Generates a non-cryptographic 64-bit hash of the RouteHop. + */ +uint64_t RouteHop_hash(const struct LDKRouteHop *NONNULL_PTR o); + +/** + * 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. + */ +bool RouteHop_eq(const struct LDKRouteHop *NONNULL_PTR a, const struct LDKRouteHop *NONNULL_PTR b); + +/** + * Serialize the RouteHop object into a byte array which can be read by RouteHop_read + */ +struct LDKCVec_u8Z RouteHop_write(const struct LDKRouteHop *NONNULL_PTR obj); + +/** + * Read a RouteHop from a byte array, created by RouteHop_write + */ +struct LDKCResult_RouteHopDecodeErrorZ RouteHop_read(struct LDKu8slice ser); + +/** + * Frees any resources used by the BlindedTail, if is_owned is set and inner is non-NULL. + */ +void BlindedTail_free(struct LDKBlindedTail this_obj); + +/** + * The hops of the [`BlindedPaymentPath`] provided by the recipient. + */ +struct LDKCVec_BlindedHopZ BlindedTail_get_hops(const struct LDKBlindedTail *NONNULL_PTR this_ptr); + +/** + * The hops of the [`BlindedPaymentPath`] provided by the recipient. + */ +void BlindedTail_set_hops(struct LDKBlindedTail *NONNULL_PTR this_ptr, struct LDKCVec_BlindedHopZ val); + +/** + * The blinding point of the [`BlindedPaymentPath`] provided by the recipient. + */ +struct LDKPublicKey BlindedTail_get_blinding_point(const struct LDKBlindedTail *NONNULL_PTR this_ptr); + +/** + * The blinding point of the [`BlindedPaymentPath`] provided by the recipient. + */ +void BlindedTail_set_blinding_point(struct LDKBlindedTail *NONNULL_PTR this_ptr, struct LDKPublicKey val); + +/** + * Excess CLTV delta added to the recipient's CLTV expiry to deter intermediate nodes from + * inferring the destination. May be 0. + */ +uint32_t BlindedTail_get_excess_final_cltv_expiry_delta(const struct LDKBlindedTail *NONNULL_PTR this_ptr); + +/** + * Excess CLTV delta added to the recipient's CLTV expiry to deter intermediate nodes from + * inferring the destination. May be 0. + */ +void BlindedTail_set_excess_final_cltv_expiry_delta(struct LDKBlindedTail *NONNULL_PTR this_ptr, uint32_t val); + +/** + * The total amount paid on this [`Path`], excluding the fees. + */ +uint64_t BlindedTail_get_final_value_msat(const struct LDKBlindedTail *NONNULL_PTR this_ptr); + +/** + * The total amount paid on this [`Path`], excluding the fees. + */ +void BlindedTail_set_final_value_msat(struct LDKBlindedTail *NONNULL_PTR this_ptr, uint64_t val); + +/** + * Constructs a new BlindedTail given each field + */ +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); + +/** + * Creates a copy of the BlindedTail + */ +struct LDKBlindedTail BlindedTail_clone(const struct LDKBlindedTail *NONNULL_PTR orig); + +/** + * Generates a non-cryptographic 64-bit hash of the BlindedTail. + */ +uint64_t BlindedTail_hash(const struct LDKBlindedTail *NONNULL_PTR o); + +/** + * 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 BlindedTail_eq(const struct LDKBlindedTail *NONNULL_PTR a, const struct LDKBlindedTail *NONNULL_PTR b); + +/** + * Serialize the BlindedTail object into a byte array which can be read by BlindedTail_read + */ +struct LDKCVec_u8Z BlindedTail_write(const struct LDKBlindedTail *NONNULL_PTR obj); + +/** + * Read a BlindedTail from a byte array, created by BlindedTail_write + */ +struct LDKCResult_BlindedTailDecodeErrorZ BlindedTail_read(struct LDKu8slice ser); + +/** + * Frees any resources used by the Path, if is_owned is set and inner is non-NULL. + */ +void Path_free(struct LDKPath this_obj); + +/** + * The list of unblinded hops in this [`Path`]. Must be at least length one. + */ +struct LDKCVec_RouteHopZ Path_get_hops(const struct LDKPath *NONNULL_PTR this_ptr); + +/** + * The list of unblinded hops in this [`Path`]. Must be at least length one. + */ +void Path_set_hops(struct LDKPath *NONNULL_PTR this_ptr, struct LDKCVec_RouteHopZ 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 + */ +struct LDKBlindedTail Path_get_blinded_tail(const struct LDKPath *NONNULL_PTR this_ptr); + +/** + * 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 Path_set_blinded_tail(struct LDKPath *NONNULL_PTR this_ptr, struct LDKBlindedTail val); + +/** + * Constructs a new Path given each field + * + * Note that blinded_tail_arg (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +MUST_USE_RES struct LDKPath Path_new(struct LDKCVec_RouteHopZ hops_arg, struct LDKBlindedTail blinded_tail_arg); + +/** + * Creates a copy of the Path + */ +struct LDKPath Path_clone(const struct LDKPath *NONNULL_PTR orig); + +/** + * Generates a non-cryptographic 64-bit hash of the Path. + */ +uint64_t Path_hash(const struct LDKPath *NONNULL_PTR o); + +/** + * 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. + */ +bool Path_eq(const struct LDKPath *NONNULL_PTR a, const struct LDKPath *NONNULL_PTR b); + +/** + * Gets the fees for a given path, excluding any excess paid to the recipient. + */ +MUST_USE_RES uint64_t Path_fee_msat(const struct LDKPath *NONNULL_PTR this_arg); + +/** + * Gets the total amount paid on this [`Path`], excluding the fees. + */ +MUST_USE_RES uint64_t Path_final_value_msat(const struct LDKPath *NONNULL_PTR this_arg); + +/** + * Gets the final hop's CLTV expiry delta. + */ +MUST_USE_RES struct LDKCOption_u32Z Path_final_cltv_expiry_delta(const struct LDKPath *NONNULL_PTR this_arg); + +/** + * Frees any resources used by the Route, if is_owned is set and inner is non-NULL. + */ +void Route_free(struct LDKRoute 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. + */ +struct LDKCVec_PathZ Route_get_paths(const struct LDKRoute *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. + */ +void Route_set_paths(struct LDKRoute *NONNULL_PTR this_ptr, struct LDKCVec_PathZ val); + +/** + * The `route_params` parameter passed to [`find_route`]. + * + * This is used by `ChannelManager` to track information which may be required for retries. + * + * Will be `None` for objects serialized with LDK versions prior to 0.0.117. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +struct LDKRouteParameters Route_get_route_params(const struct LDKRoute *NONNULL_PTR this_ptr); + +/** + * The `route_params` parameter passed to [`find_route`]. + * + * This is used by `ChannelManager` to track information which may be required for retries. + * + * Will be `None` for objects serialized with LDK versions prior to 0.0.117. + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +void Route_set_route_params(struct LDKRoute *NONNULL_PTR this_ptr, struct LDKRouteParameters val); + +/** + * Constructs a new Route given each field + * + * Note that route_params_arg (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +MUST_USE_RES struct LDKRoute Route_new(struct LDKCVec_PathZ paths_arg, struct LDKRouteParameters route_params_arg); + +/** + * Creates a copy of the Route + */ +struct LDKRoute Route_clone(const struct LDKRoute *NONNULL_PTR orig); + +/** + * Generates a non-cryptographic 64-bit hash of the Route. + */ +uint64_t Route_hash(const struct LDKRoute *NONNULL_PTR o); + +/** + * 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. + */ +bool Route_eq(const struct LDKRoute *NONNULL_PTR a, const struct LDKRoute *NONNULL_PTR b); + +/** + * Returns the total amount of fees paid on this [`Route`]. + * + * For objects serialized with LDK 0.0.117 and after, this includes any extra payment made to + * the recipient, which can happen in excess of the amount passed to [`find_route`] via + * [`RouteParameters::final_value_msat`], if we had to reach the [`htlc_minimum_msat`] limits. + * + * [`htlc_minimum_msat`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_update-message + */ +MUST_USE_RES uint64_t Route_get_total_fees(const struct LDKRoute *NONNULL_PTR this_arg); + +/** + * Returns the total amount paid on this [`Route`], excluding the fees. + * + * Might be more than requested as part of the given [`RouteParameters::final_value_msat`] if + * we had to reach the [`htlc_minimum_msat`] limits. + * + * [`htlc_minimum_msat`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_update-message + */ +MUST_USE_RES uint64_t Route_get_total_amount(const struct LDKRoute *NONNULL_PTR this_arg); + +/** + * Get the string representation of a Route object + */ +struct LDKStr Route_to_str(const struct LDKRoute *NONNULL_PTR o); + +/** + * Serialize the Route object into a byte array which can be read by Route_read + */ +struct LDKCVec_u8Z Route_write(const struct LDKRoute *NONNULL_PTR obj); + +/** + * Read a Route from a byte array, created by Route_write + */ +struct LDKCResult_RouteDecodeErrorZ Route_read(struct LDKu8slice ser); + +/** + * Frees any resources used by the RouteParameters, if is_owned is set and inner is non-NULL. + */ +void RouteParameters_free(struct LDKRouteParameters this_obj); + +/** + * The parameters of the failed payment path. + */ +struct LDKPaymentParameters RouteParameters_get_payment_params(const struct LDKRouteParameters *NONNULL_PTR this_ptr); + +/** + * The parameters of the failed payment path. + */ +void RouteParameters_set_payment_params(struct LDKRouteParameters *NONNULL_PTR this_ptr, struct LDKPaymentParameters val); + +/** + * The amount in msats sent on the failed payment path. + */ +uint64_t RouteParameters_get_final_value_msat(const struct LDKRouteParameters *NONNULL_PTR this_ptr); + +/** + * The amount in msats sent on the failed payment path. + */ +void RouteParameters_set_final_value_msat(struct LDKRouteParameters *NONNULL_PTR this_ptr, uint64_t val); + +/** + * The maximum total fees, in millisatoshi, that may accrue during route finding. + * + * This limit also applies to the total fees that may arise while retrying failed payment + * paths. + * + * Note that values below a few sats may result in some paths being spuriously ignored. + */ +struct LDKCOption_u64Z RouteParameters_get_max_total_routing_fee_msat(const struct LDKRouteParameters *NONNULL_PTR this_ptr); + +/** + * The maximum total fees, in millisatoshi, that may accrue during route finding. + * + * This limit also applies to the total fees that may arise while retrying failed payment + * paths. + * + * Note that values below a few sats may result in some paths being spuriously ignored. + */ +void RouteParameters_set_max_total_routing_fee_msat(struct LDKRouteParameters *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); + +/** + * Constructs a new RouteParameters given each field + */ +MUST_USE_RES struct LDKRouteParameters RouteParameters_new(struct LDKPaymentParameters payment_params_arg, uint64_t final_value_msat_arg, struct LDKCOption_u64Z max_total_routing_fee_msat_arg); + +/** + * Creates a copy of the RouteParameters + */ +struct LDKRouteParameters RouteParameters_clone(const struct LDKRouteParameters *NONNULL_PTR orig); + +/** + * Generates a non-cryptographic 64-bit hash of the RouteParameters. + */ +uint64_t RouteParameters_hash(const struct LDKRouteParameters *NONNULL_PTR o); + +/** + * 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 RouteParameters_eq(const struct LDKRouteParameters *NONNULL_PTR a, const struct LDKRouteParameters *NONNULL_PTR b); + +/** + * Constructs [`RouteParameters`] from the given [`PaymentParameters`] and a payment amount. + * + * [`Self::max_total_routing_fee_msat`] defaults to 1% of the payment amount + 50 sats + */ +MUST_USE_RES struct LDKRouteParameters RouteParameters_from_payment_params_and_value(struct LDKPaymentParameters payment_params, uint64_t final_value_msat); + +/** + * Sets the maximum number of hops that can be included in a payment path, based on the provided + * [`RecipientOnionFields`] and blinded paths. + */ +MUST_USE_RES struct LDKCResult_NoneNoneZ RouteParameters_set_max_path_length(struct LDKRouteParameters *NONNULL_PTR this_arg, const struct LDKRecipientOnionFields *NONNULL_PTR recipient_onion, bool is_keysend, uint32_t best_block_height); + +/** + * Serialize the RouteParameters object into a byte array which can be read by RouteParameters_read + */ +struct LDKCVec_u8Z RouteParameters_write(const struct LDKRouteParameters *NONNULL_PTR obj); + +/** + * Read a RouteParameters from a byte array, created by RouteParameters_write + */ +struct LDKCResult_RouteParametersDecodeErrorZ RouteParameters_read(struct LDKu8slice ser); + +/** + * Frees any resources used by the PaymentParameters, if is_owned is set and inner is non-NULL. + */ +void PaymentParameters_free(struct LDKPaymentParameters this_obj); + +/** + * Information about the payee, such as their features and route hints for their channels. + */ +struct LDKPayee PaymentParameters_get_payee(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); + +/** + * Information about the payee, such as their features and route hints for their channels. + */ +void PaymentParameters_set_payee(struct LDKPaymentParameters *NONNULL_PTR this_ptr, struct LDKPayee val); + +/** + * Expiration of a payment to the payee, in seconds relative to the UNIX epoch. + */ +struct LDKCOption_u64Z PaymentParameters_get_expiry_time(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); + +/** + * Expiration of a payment to the payee, in seconds relative to the UNIX epoch. + */ +void PaymentParameters_set_expiry_time(struct LDKPaymentParameters *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); + +/** + * The maximum total CLTV delta we accept for the route. + * Defaults to [`DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA`]. + */ +uint32_t PaymentParameters_get_max_total_cltv_expiry_delta(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); + +/** + * The maximum total CLTV delta we accept for the route. + * Defaults to [`DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA`]. + */ +void PaymentParameters_set_max_total_cltv_expiry_delta(struct LDKPaymentParameters *NONNULL_PTR this_ptr, uint32_t val); + +/** + * The maximum number of paths that may be used by (MPP) payments. + * Defaults to [`DEFAULT_MAX_PATH_COUNT`]. + */ +uint8_t PaymentParameters_get_max_path_count(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); + +/** + * The maximum number of paths that may be used by (MPP) payments. + * Defaults to [`DEFAULT_MAX_PATH_COUNT`]. + */ +void PaymentParameters_set_max_path_count(struct LDKPaymentParameters *NONNULL_PTR this_ptr, uint8_t val); + +/** + * The maximum number of [`Path::hops`] in any returned path. + * Defaults to [`MAX_PATH_LENGTH_ESTIMATE`]. + */ +uint8_t PaymentParameters_get_max_path_length(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); + +/** + * The maximum number of [`Path::hops`] in any returned path. + * Defaults to [`MAX_PATH_LENGTH_ESTIMATE`]. + */ +void PaymentParameters_set_max_path_length(struct LDKPaymentParameters *NONNULL_PTR this_ptr, uint8_t val); + +/** + * 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 + */ +uint8_t PaymentParameters_get_max_channel_saturation_power_of_half(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); + +/** + * 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 + */ +void PaymentParameters_set_max_channel_saturation_power_of_half(struct LDKPaymentParameters *NONNULL_PTR this_ptr, uint8_t val); + +/** + * 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. + */ +struct LDKCVec_u64Z PaymentParameters_get_previously_failed_channels(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); + +/** + * 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 PaymentParameters_set_previously_failed_channels(struct LDKPaymentParameters *NONNULL_PTR this_ptr, struct LDKCVec_u64Z val); + +/** + * A list of indices corresponding to blinded paths in [`Payee::Blinded::route_hints`] 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 blinded paths. + * + * Returns a copy of the field. + */ +struct LDKCVec_u64Z PaymentParameters_get_previously_failed_blinded_path_idxs(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); + +/** + * A list of indices corresponding to blinded paths in [`Payee::Blinded::route_hints`] 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 blinded paths. + */ +void PaymentParameters_set_previously_failed_blinded_path_idxs(struct LDKPaymentParameters *NONNULL_PTR this_ptr, struct LDKCVec_u64Z val); + +/** + * Constructs a new PaymentParameters given each field + */ +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_path_length_arg, uint8_t max_channel_saturation_power_of_half_arg, struct LDKCVec_u64Z previously_failed_channels_arg, struct LDKCVec_u64Z previously_failed_blinded_path_idxs_arg); + +/** + * Creates a copy of the PaymentParameters + */ +struct LDKPaymentParameters PaymentParameters_clone(const struct LDKPaymentParameters *NONNULL_PTR orig); + +/** + * Generates a non-cryptographic 64-bit hash of the PaymentParameters. + */ +uint64_t PaymentParameters_hash(const struct LDKPaymentParameters *NONNULL_PTR o); + +/** + * 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. + */ +bool PaymentParameters_eq(const struct LDKPaymentParameters *NONNULL_PTR a, const struct LDKPaymentParameters *NONNULL_PTR b); + +/** + * Serialize the PaymentParameters object into a byte array which can be read by PaymentParameters_read + */ +struct LDKCVec_u8Z PaymentParameters_write(const struct LDKPaymentParameters *NONNULL_PTR obj); + +/** + * Read a PaymentParameters from a byte array, created by PaymentParameters_write + */ +struct LDKCResult_PaymentParametersDecodeErrorZ PaymentParameters_read(struct LDKu8slice ser, uint32_t arg); + +/** + * 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. + */ +MUST_USE_RES struct LDKPaymentParameters PaymentParameters_from_node_id(struct LDKPublicKey payee_pubkey, uint32_t final_cltv_expiry_delta); + +/** + * 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 LDKPaymentParameters PaymentParameters_for_keysend(struct LDKPublicKey payee_pubkey, uint32_t final_cltv_expiry_delta, bool allow_mpp); + +/** + * 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 LDKPaymentParameters PaymentParameters_from_bolt12_invoice(const struct LDKBolt12Invoice *NONNULL_PTR invoice); + +/** + * Creates parameters for paying to a blinded payee from the provided blinded route hints. + */ +MUST_USE_RES struct LDKPaymentParameters PaymentParameters_blinded(struct LDKCVec_BlindedPaymentPathZ blinded_route_hints); + +/** + * Frees any resources used by the Payee + */ +void Payee_free(struct LDKPayee this_ptr); + +/** + * Creates a copy of the Payee + */ +struct LDKPayee Payee_clone(const struct LDKPayee *NONNULL_PTR orig); + +/** + * Utility method to constructs a new Blinded-variant Payee + */ +struct LDKPayee Payee_blinded(struct LDKCVec_BlindedPaymentPathZ route_hints, struct LDKBolt12InvoiceFeatures features); + +/** + * Utility method to constructs a new Clear-variant Payee + */ +struct LDKPayee Payee_clear(struct LDKPublicKey node_id, struct LDKCVec_RouteHintZ route_hints, struct LDKBolt11InvoiceFeatures features, uint32_t final_cltv_expiry_delta); + +/** + * Generates a non-cryptographic 64-bit hash of the Payee. + */ +uint64_t Payee_hash(const struct LDKPayee *NONNULL_PTR o); + +/** + * Checks if two Payees contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + */ +bool Payee_eq(const struct LDKPayee *NONNULL_PTR a, const struct LDKPayee *NONNULL_PTR b); + +/** + * Serialize the RouteHint object into a byte array which can be read by RouteHint_read + */ +struct LDKCVec_u8Z RouteHint_write(const struct LDKRouteHint *NONNULL_PTR obj); + +/** + * Read a RouteHint from a byte array, created by RouteHint_write + */ +struct LDKCResult_RouteHintDecodeErrorZ RouteHint_read(struct LDKu8slice ser); + +/** + * Serialize the RouteHintHop object into a byte array which can be read by RouteHintHop_read + */ +struct LDKCVec_u8Z RouteHintHop_write(const struct LDKRouteHintHop *NONNULL_PTR obj); + +/** + * Read a RouteHintHop from a byte array, created by RouteHintHop_write + */ +struct LDKCResult_RouteHintHopDecodeErrorZ RouteHintHop_read(struct LDKu8slice ser); + +/** + * Frees any resources used by the FirstHopCandidate, if is_owned is set and inner is non-NULL. + */ +void FirstHopCandidate_free(struct LDKFirstHopCandidate this_obj); + +/** + * Creates a copy of the FirstHopCandidate + */ +struct LDKFirstHopCandidate FirstHopCandidate_clone(const struct LDKFirstHopCandidate *NONNULL_PTR orig); + +/** + * Frees any resources used by the PublicHopCandidate, if is_owned is set and inner is non-NULL. + */ +void PublicHopCandidate_free(struct LDKPublicHopCandidate this_obj); + +/** + * The short channel ID of the channel, i.e. the identifier by which we refer to this + * channel. + */ +uint64_t PublicHopCandidate_get_short_channel_id(const struct LDKPublicHopCandidate *NONNULL_PTR this_ptr); + +/** + * The short channel ID of the channel, i.e. the identifier by which we refer to this + * channel. + */ +void PublicHopCandidate_set_short_channel_id(struct LDKPublicHopCandidate *NONNULL_PTR this_ptr, uint64_t val); + +/** + * Creates a copy of the PublicHopCandidate + */ +struct LDKPublicHopCandidate PublicHopCandidate_clone(const struct LDKPublicHopCandidate *NONNULL_PTR orig); + +/** + * Frees any resources used by the PrivateHopCandidate, if is_owned is set and inner is non-NULL. + */ +void PrivateHopCandidate_free(struct LDKPrivateHopCandidate this_obj); + +/** + * Creates a copy of the PrivateHopCandidate + */ +struct LDKPrivateHopCandidate PrivateHopCandidate_clone(const struct LDKPrivateHopCandidate *NONNULL_PTR orig); + +/** + * Frees any resources used by the BlindedPathCandidate, if is_owned is set and inner is non-NULL. + */ +void BlindedPathCandidate_free(struct LDKBlindedPathCandidate this_obj); + +/** + * Creates a copy of the BlindedPathCandidate + */ +struct LDKBlindedPathCandidate BlindedPathCandidate_clone(const struct LDKBlindedPathCandidate *NONNULL_PTR orig); + +/** + * Frees any resources used by the OneHopBlindedPathCandidate, if is_owned is set and inner is non-NULL. + */ +void OneHopBlindedPathCandidate_free(struct LDKOneHopBlindedPathCandidate this_obj); + +/** + * Creates a copy of the OneHopBlindedPathCandidate + */ +struct LDKOneHopBlindedPathCandidate OneHopBlindedPathCandidate_clone(const struct LDKOneHopBlindedPathCandidate *NONNULL_PTR orig); + +/** + * Frees any resources used by the CandidateRouteHop + */ +void CandidateRouteHop_free(struct LDKCandidateRouteHop this_ptr); + +/** + * Creates a copy of the CandidateRouteHop + */ +struct LDKCandidateRouteHop CandidateRouteHop_clone(const struct LDKCandidateRouteHop *NONNULL_PTR orig); + +/** + * Utility method to constructs a new FirstHop-variant CandidateRouteHop + */ +struct LDKCandidateRouteHop CandidateRouteHop_first_hop(struct LDKFirstHopCandidate a); + +/** + * Utility method to constructs a new PublicHop-variant CandidateRouteHop + */ +struct LDKCandidateRouteHop CandidateRouteHop_public_hop(struct LDKPublicHopCandidate a); + +/** + * Utility method to constructs a new PrivateHop-variant CandidateRouteHop + */ +struct LDKCandidateRouteHop CandidateRouteHop_private_hop(struct LDKPrivateHopCandidate a); + +/** + * Utility method to constructs a new Blinded-variant CandidateRouteHop + */ +struct LDKCandidateRouteHop CandidateRouteHop_blinded(struct LDKBlindedPathCandidate a); + +/** + * Utility method to constructs a new OneHopBlinded-variant CandidateRouteHop + */ +struct LDKCandidateRouteHop CandidateRouteHop_one_hop_blinded(struct LDKOneHopBlindedPathCandidate a); + +/** + * Returns the globally unique short channel ID for this hop, if one is known. + * + * This only returns `Some` if the channel is public (either our own, or one we've learned + * from the public network graph), and thus the short channel ID we have for this channel is + * globally unique and identifies this channel in a global namespace. + */ +MUST_USE_RES struct LDKCOption_u64Z CandidateRouteHop_globally_unique_short_channel_id(const struct LDKCandidateRouteHop *NONNULL_PTR this_arg); + +/** + * Returns the required difference in HTLC CLTV expiry between the [`Self::source`] and the + * next-hop for an HTLC taking this hop. + * + * This is the time that the node(s) in this hop have to claim the HTLC on-chain if the + * next-hop goes on chain with a payment preimage. + */ +MUST_USE_RES uint32_t CandidateRouteHop_cltv_expiry_delta(const struct LDKCandidateRouteHop *NONNULL_PTR this_arg); + +/** + * Returns the minimum amount that can be sent over this hop, in millisatoshis. + */ +MUST_USE_RES uint64_t CandidateRouteHop_htlc_minimum_msat(const struct LDKCandidateRouteHop *NONNULL_PTR this_arg); + +/** + * Returns the fees that must be paid to route an HTLC over this channel. + */ +MUST_USE_RES struct LDKRoutingFees CandidateRouteHop_fees(const struct LDKCandidateRouteHop *NONNULL_PTR this_arg); + +/** + * Returns the source node id of current hop. + * + * Source node id refers to the node forwarding the HTLC through this hop. + * + * For [`Self::FirstHop`] we return payer's node id. + */ +MUST_USE_RES struct LDKNodeId CandidateRouteHop_source(const struct LDKCandidateRouteHop *NONNULL_PTR this_arg); + +/** + * Returns the target node id of this hop, if known. + * + * Target node id refers to the node receiving the HTLC after this hop. + * + * For [`Self::Blinded`] we return `None` because the ultimate destination after the blinded + * path is unknown. + * + * For [`Self::OneHopBlinded`] we return `None` because the target is the same as the source, + * and such a return value would be somewhat nonsensical. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +MUST_USE_RES struct LDKNodeId CandidateRouteHop_target(const struct LDKCandidateRouteHop *NONNULL_PTR this_arg); + +/** + * 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 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 LDKScoreLookUp *NONNULL_PTR scorer, const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR score_params, const uint8_t (*random_seed_bytes)[32]); + +/** + * 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_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]); + +/** + * Calls the free function if one is set + */ +void ScoreLookUp_free(struct LDKScoreLookUp this_ptr); + +/** + * Calls the free function if one is set + */ +void ScoreUpdate_free(struct LDKScoreUpdate this_ptr); + +/** + * Calls the free function if one is set + */ +void Score_free(struct LDKScore this_ptr); + +/** + * Calls the free function if one is set + */ +void LockableScore_free(struct LDKLockableScore this_ptr); + +/** + * Calls the free function if one is set + */ +void WriteableScore_free(struct LDKWriteableScore this_ptr); + +/** + * Frees any resources used by the MultiThreadedLockableScore, if is_owned is set and inner is non-NULL. + */ +void MultiThreadedLockableScore_free(struct LDKMultiThreadedLockableScore this_obj); + +/** + * 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 + */ +struct LDKLockableScore MultiThreadedLockableScore_as_LockableScore(const struct LDKMultiThreadedLockableScore *NONNULL_PTR this_arg); + +/** + * Serialize the MultiThreadedLockableScore object into a byte array which can be read by MultiThreadedLockableScore_read + */ +struct LDKCVec_u8Z MultiThreadedLockableScore_write(const struct LDKMultiThreadedLockableScore *NONNULL_PTR 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 + */ +struct LDKWriteableScore MultiThreadedLockableScore_as_WriteableScore(const struct LDKMultiThreadedLockableScore *NONNULL_PTR this_arg); + +/** + * Creates a new [`MultiThreadedLockableScore`] given an underlying [`Score`]. + */ +MUST_USE_RES struct LDKMultiThreadedLockableScore MultiThreadedLockableScore_new(struct LDKScore score); + +/** + * Frees any resources used by the MultiThreadedScoreLockRead, if is_owned is set and inner is non-NULL. + */ +void MultiThreadedScoreLockRead_free(struct LDKMultiThreadedScoreLockRead this_obj); + +/** + * Frees any resources used by the MultiThreadedScoreLockWrite, if is_owned is set and inner is non-NULL. + */ +void MultiThreadedScoreLockWrite_free(struct LDKMultiThreadedScoreLockWrite this_obj); + +/** + * Constructs a new ScoreLookUp which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned ScoreLookUp must be freed before this_arg is + */ +struct LDKScoreLookUp MultiThreadedScoreLockRead_as_ScoreLookUp(const struct LDKMultiThreadedScoreLockRead *NONNULL_PTR this_arg); + +/** + * Serialize the MultiThreadedScoreLockWrite object into a byte array which can be read by MultiThreadedScoreLockWrite_read + */ +struct LDKCVec_u8Z MultiThreadedScoreLockWrite_write(const struct LDKMultiThreadedScoreLockWrite *NONNULL_PTR obj); + +/** + * Constructs a new ScoreUpdate which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned ScoreUpdate must be freed before this_arg is + */ +struct LDKScoreUpdate MultiThreadedScoreLockWrite_as_ScoreUpdate(const struct LDKMultiThreadedScoreLockWrite *NONNULL_PTR this_arg); + +/** + * Frees any resources used by the ChannelUsage, if is_owned is set and inner is non-NULL. + */ +void ChannelUsage_free(struct LDKChannelUsage this_obj); + +/** + * The amount to send through the channel, denominated in millisatoshis. + */ +uint64_t ChannelUsage_get_amount_msat(const struct LDKChannelUsage *NONNULL_PTR this_ptr); + +/** + * The amount to send through the channel, denominated in millisatoshis. + */ +void ChannelUsage_set_amount_msat(struct LDKChannelUsage *NONNULL_PTR this_ptr, uint64_t val); + +/** + * Total amount, denominated in millisatoshis, already allocated to send through the channel + * as part of a multi-path payment. + */ +uint64_t ChannelUsage_get_inflight_htlc_msat(const struct LDKChannelUsage *NONNULL_PTR this_ptr); + +/** + * Total amount, denominated in millisatoshis, already allocated to send through the channel + * as part of a multi-path payment. + */ +void ChannelUsage_set_inflight_htlc_msat(struct LDKChannelUsage *NONNULL_PTR this_ptr, uint64_t val); + +/** + * The effective capacity of the channel. + */ +struct LDKEffectiveCapacity ChannelUsage_get_effective_capacity(const struct LDKChannelUsage *NONNULL_PTR this_ptr); + +/** + * The effective capacity of the channel. + */ +void ChannelUsage_set_effective_capacity(struct LDKChannelUsage *NONNULL_PTR this_ptr, struct LDKEffectiveCapacity val); + +/** + * Constructs a new ChannelUsage given each field + */ +MUST_USE_RES struct LDKChannelUsage ChannelUsage_new(uint64_t amount_msat_arg, uint64_t inflight_htlc_msat_arg, struct LDKEffectiveCapacity effective_capacity_arg); + +/** + * Creates a copy of the ChannelUsage + */ +struct LDKChannelUsage ChannelUsage_clone(const struct LDKChannelUsage *NONNULL_PTR orig); + +/** + * Frees any resources used by the FixedPenaltyScorer, if is_owned is set and inner is non-NULL. + */ +void FixedPenaltyScorer_free(struct LDKFixedPenaltyScorer this_obj); + +/** + * Creates a copy of the FixedPenaltyScorer + */ +struct LDKFixedPenaltyScorer FixedPenaltyScorer_clone(const struct LDKFixedPenaltyScorer *NONNULL_PTR orig); + +/** + * Creates a new scorer using `penalty_msat`. + */ +MUST_USE_RES struct LDKFixedPenaltyScorer FixedPenaltyScorer_with_penalty(uint64_t penalty_msat); + +/** + * Constructs a new ScoreLookUp which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned ScoreLookUp must be freed before this_arg is + */ +struct LDKScoreLookUp FixedPenaltyScorer_as_ScoreLookUp(const struct LDKFixedPenaltyScorer *NONNULL_PTR this_arg); + +/** + * Constructs a new ScoreUpdate which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned ScoreUpdate must be freed before this_arg is + */ +struct LDKScoreUpdate FixedPenaltyScorer_as_ScoreUpdate(const struct LDKFixedPenaltyScorer *NONNULL_PTR this_arg); + +/** + * Serialize the FixedPenaltyScorer object into a byte array which can be read by FixedPenaltyScorer_read + */ +struct LDKCVec_u8Z FixedPenaltyScorer_write(const struct LDKFixedPenaltyScorer *NONNULL_PTR obj); + +/** + * Read a FixedPenaltyScorer from a byte array, created by FixedPenaltyScorer_write + */ +struct LDKCResult_FixedPenaltyScorerDecodeErrorZ FixedPenaltyScorer_read(struct LDKu8slice ser, uint64_t arg); + +/** + * Frees any resources used by the ProbabilisticScorer, if is_owned is set and inner is non-NULL. + */ +void ProbabilisticScorer_free(struct LDKProbabilisticScorer this_obj); + +/** + * Frees any resources used by the ProbabilisticScoringFeeParameters, if is_owned is set and inner is non-NULL. + */ +void ProbabilisticScoringFeeParameters_free(struct LDKProbabilisticScoringFeeParameters this_obj); + +/** + * A fixed penalty in msats to apply to each channel. + * + * Default value: 500 msat + */ +uint64_t ProbabilisticScoringFeeParameters_get_base_penalty_msat(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr); + +/** + * A fixed penalty in msats to apply to each channel. + * + * Default value: 500 msat + */ +void ProbabilisticScoringFeeParameters_set_base_penalty_msat(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr, uint64_t val); + +/** + * A multiplier used with the total amount flowing over a channel 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 total amount flowing over a channel (i.e. the payment + * amount plus the amount of any other HTLCs flowing we sent over the same channel). + * + * ie `base_penalty_amount_multiplier_msat * amount_msat / 2^30` + * + * Default value: 8,192 msat + * + * [`base_penalty_msat`]: Self::base_penalty_msat + */ +uint64_t ProbabilisticScoringFeeParameters_get_base_penalty_amount_multiplier_msat(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr); + +/** + * A multiplier used with the total amount flowing over a channel 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 total amount flowing over a channel (i.e. the payment + * amount plus the amount of any other HTLCs flowing we sent over the same channel). + * + * ie `base_penalty_amount_multiplier_msat * amount_msat / 2^30` + * + * Default value: 8,192 msat + * + * [`base_penalty_msat`]: Self::base_penalty_msat + */ +void ProbabilisticScoringFeeParameters_set_base_penalty_amount_multiplier_msat(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr, uint64_t val); + +/** + * 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 + */ +uint64_t ProbabilisticScoringFeeParameters_get_liquidity_penalty_multiplier_msat(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr); + +/** + * 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 + */ +void ProbabilisticScoringFeeParameters_set_liquidity_penalty_multiplier_msat(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr, uint64_t val); + +/** + * A multiplier used in conjunction with the total amount flowing over a channel 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 amount flowing over this channel, 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 ProbabilisticScoringFeeParameters_get_liquidity_penalty_amount_multiplier_msat(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr); + +/** + * A multiplier used in conjunction with the total amount flowing over a channel 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 amount flowing over this channel, 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 + */ +void ProbabilisticScoringFeeParameters_set_liquidity_penalty_amount_multiplier_msat(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr, uint64_t val); + +/** + * 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 + */ +uint64_t ProbabilisticScoringFeeParameters_get_historical_liquidity_penalty_multiplier_msat(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr); + +/** + * 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 + */ +void ProbabilisticScoringFeeParameters_set_historical_liquidity_penalty_multiplier_msat(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr, uint64_t val); + +/** + * A multiplier used in conjunction with the total amount flowing over a channel 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 `2^20`ths + * of the amount flowing over this channel, 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 + */ +uint64_t ProbabilisticScoringFeeParameters_get_historical_liquidity_penalty_amount_multiplier_msat(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr); + +/** + * A multiplier used in conjunction with the total amount flowing over a channel 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 `2^20`ths + * of the amount flowing over this channel, 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 + */ +void ProbabilisticScoringFeeParameters_set_historical_liquidity_penalty_amount_multiplier_msat(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr, uint64_t val); + +/** + * 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 + */ +uint64_t ProbabilisticScoringFeeParameters_get_anti_probing_penalty_msat(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr); + +/** + * 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 ProbabilisticScoringFeeParameters_set_anti_probing_penalty_msat(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr, uint64_t val); + +/** + * This penalty is applied when the total amount flowing over a channel exceeds our current + * estimate of the channel's available liquidity. The total amount is the amount of the + * current HTLC plus any HTLCs which we've sent over the same channel. + * + * 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 ProbabilisticScoringFeeParameters_get_considered_impossible_penalty_msat(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr); + +/** + * This penalty is applied when the total amount flowing over a channel exceeds our current + * estimate of the channel's available liquidity. The total amount is the amount of the + * current HTLC plus any HTLCs which we've sent over the same channel. + * + * 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 ProbabilisticScoringFeeParameters_set_considered_impossible_penalty_msat(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr, uint64_t val); + +/** + * In order to calculate most of the scores above, we must first convert a lower and upper + * bound on the available liquidity in a channel into the probability that we think a payment + * will succeed. That probability is derived from a Probability Density Function for where we + * think the liquidity in a channel likely lies, given such bounds. + * + * If this flag is set, that PDF is simply a constant - we assume that the actual available + * liquidity in a channel is just as likely to be at any point between our lower and upper + * bounds. + * + * If this flag is *not* set, that PDF is `(x - 0.5*capacity) ^ 2`. That is, we use an + * exponential curve which expects the liquidity of a channel to lie \"at the edges\". This + * matches experimental results - most routing nodes do not aggressively rebalance their + * channels and flows in the network are often unbalanced, leaving liquidity usually + * unavailable. + * + * Thus, for the \"best\" routes, leave this flag `false`. However, the flag does imply a number + * of floating-point multiplications in the hottest routing code, which may lead to routing + * performance degradation on some machines. + * + * Default value: false + */ +bool ProbabilisticScoringFeeParameters_get_linear_success_probability(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr); + +/** + * In order to calculate most of the scores above, we must first convert a lower and upper + * bound on the available liquidity in a channel into the probability that we think a payment + * will succeed. That probability is derived from a Probability Density Function for where we + * think the liquidity in a channel likely lies, given such bounds. + * + * If this flag is set, that PDF is simply a constant - we assume that the actual available + * liquidity in a channel is just as likely to be at any point between our lower and upper + * bounds. * - * If `None`, the offer does not expire. - */ -MUST_USE_RES struct LDKCOption_u64Z InvoiceRequest_absolute_expiry(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); - -/** - * 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. + * If this flag is *not* set, that PDF is `(x - 0.5*capacity) ^ 2`. That is, we use an + * exponential curve which expects the liquidity of a channel to lie \"at the edges\". This + * matches experimental results - most routing nodes do not aggressively rebalance their + * channels and flows in the network are often unbalanced, leaving liquidity usually + * unavailable. * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Thus, for the \"best\" routes, leave this flag `false`. However, the flag does imply a number + * of floating-point multiplications in the hottest routing code, which may lead to routing + * performance degradation on some machines. + * + * Default value: false */ -MUST_USE_RES struct LDKPrintableString InvoiceRequest_issuer(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); +void ProbabilisticScoringFeeParameters_set_linear_success_probability(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr, bool val); /** - * Paths to the recipient originating from publicly reachable nodes. Blinded paths provide - * recipient privacy by obfuscating its node id. + * Creates a copy of the ProbabilisticScoringFeeParameters */ -MUST_USE_RES struct LDKCVec_BlindedPathZ InvoiceRequest_paths(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); +struct LDKProbabilisticScoringFeeParameters ProbabilisticScoringFeeParameters_clone(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR orig); /** - * The quantity of items supported. + * Creates a "default" ProbabilisticScoringFeeParameters. See struct and individual field documentaiton for details on which values are used. */ -MUST_USE_RES struct LDKQuantity InvoiceRequest_supported_quantity(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKProbabilisticScoringFeeParameters ProbabilisticScoringFeeParameters_default(void); /** - * The public key used by the recipient to sign invoices. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Marks the node with the given `node_id` as banned, + * i.e it will be avoided during path finding. */ -MUST_USE_RES struct LDKPublicKey InvoiceRequest_signing_pubkey(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); +void ProbabilisticScoringFeeParameters_add_banned(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_arg, const struct LDKNodeId *NONNULL_PTR node_id); /** - * An unpredictable series of bytes, typically containing information about the derivation of - * [`payer_id`]. - * - * [`payer_id`]: Self::payer_id + * Marks all nodes in the given list as banned, i.e., + * they will be avoided during path finding. */ -MUST_USE_RES struct LDKu8slice InvoiceRequest_payer_metadata(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); +void ProbabilisticScoringFeeParameters_add_banned_from_list(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_arg, struct LDKCVec_NodeIdZ node_ids); /** - * A chain from [`Offer::chains`] that the offer is valid for. + * Removes the node with the given `node_id` from the list of nodes to avoid. */ -MUST_USE_RES struct LDKThirtyTwoBytes InvoiceRequest_chain(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); +void ProbabilisticScoringFeeParameters_remove_banned(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_arg, const struct LDKNodeId *NONNULL_PTR node_id); /** - * 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 + * Sets a manual penalty for the given node. */ -MUST_USE_RES struct LDKCOption_u64Z InvoiceRequest_amount_msats(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); +void ProbabilisticScoringFeeParameters_set_manual_penalty(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_arg, const struct LDKNodeId *NONNULL_PTR node_id, uint64_t penalty); /** - * Features pertaining to requesting an invoice. + * Removes the node with the given `node_id` from the list of manual penalties. */ -MUST_USE_RES struct LDKInvoiceRequestFeatures InvoiceRequest_invoice_request_features(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); +void ProbabilisticScoringFeeParameters_remove_manual_penalty(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_arg, const struct LDKNodeId *NONNULL_PTR node_id); /** - * The quantity of the offer's item conforming to [`Offer::is_valid_quantity`]. + * Clears the list of manual penalties that are applied during path finding. */ -MUST_USE_RES struct LDKCOption_u64Z InvoiceRequest_quantity(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); +void ProbabilisticScoringFeeParameters_clear_manual_penalties(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_arg); /** - * A possibly transient pubkey used to sign the invoice request. + * Frees any resources used by the ProbabilisticScoringDecayParameters, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKPublicKey InvoiceRequest_payer_id(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); +void ProbabilisticScoringDecayParameters_free(struct LDKProbabilisticScoringDecayParameters this_obj); /** - * A payer-provided note which will be seen by the recipient and reflected back in the invoice - * response. + * 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 the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Note that after 16 or more half lives all historical data will be completely gone. + * + * Default value: 14 days + * + * [`historical_estimated_channel_liquidity_probabilities`]: ProbabilisticScorer::historical_estimated_channel_liquidity_probabilities */ -MUST_USE_RES struct LDKPrintableString InvoiceRequest_payer_note(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); +uint64_t ProbabilisticScoringDecayParameters_get_historical_no_updates_half_life(const struct LDKProbabilisticScoringDecayParameters *NONNULL_PTR this_ptr); /** - * Creates an [`InvoiceBuilder`] for the request with the given required fields and using the - * [`Duration`] since [`std::time::SystemTime::UNIX_EPOCH`] as the creation time. + * 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`] * - * See [`InvoiceRequest::respond_with_no_std`] for further details where the aforementioned - * creation time is used for the `created_at` parameter. + * Note that after 16 or more half lives all historical data will be completely gone. * - * [`Duration`]: core::time::Duration + * Default value: 14 days + * + * [`historical_estimated_channel_liquidity_probabilities`]: ProbabilisticScorer::historical_estimated_channel_liquidity_probabilities */ -MUST_USE_RES struct LDKCResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ InvoiceRequest_respond_with(const struct LDKInvoiceRequest *NONNULL_PTR this_arg, struct LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ payment_paths, struct LDKThirtyTwoBytes payment_hash); +void ProbabilisticScoringDecayParameters_set_historical_no_updates_half_life(struct LDKProbabilisticScoringDecayParameters *NONNULL_PTR this_ptr, uint64_t val); /** - * Creates an [`InvoiceBuilder`] for the request with the given required fields. - * - * Unless [`InvoiceBuilder::relative_expiry`] is set, the invoice will expire two hours after - * `created_at`, which is used to set [`Bolt12Invoice::created_at`]. Useful for `no-std` builds - * where [`std::time::SystemTime`] is not available. + * 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. * - * The caller is expected to remember the preimage of `payment_hash` in order to claim a payment - * for the invoice. + * 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. * - * The `payment_paths` parameter is useful for maintaining the payment recipient's privacy. It - * must contain one or more elements ordered from most-preferred to least-preferred, if there's - * a preference. Note, however, that any privacy is lost if a public node id was used for - * [`Offer::signing_pubkey`]. + * 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. * - * Errors if the request contains unknown required features. + * Default value: 6 hours * * # Note * - * If the originating [`Offer`] was created using [`OfferBuilder::deriving_signing_pubkey`], - * then use [`InvoiceRequest::verify`] and [`VerifiedInvoiceRequest`] methods instead. - * - * [`Bolt12Invoice::created_at`]: crate::offers::invoice::Bolt12Invoice::created_at - * [`OfferBuilder::deriving_signing_pubkey`]: crate::offers::offer::OfferBuilder::deriving_signing_pubkey + * When built with the `no-std` feature, time will never elapse. Therefore, the channel + * liquidity knowledge will never decay except when the bounds cross. */ -MUST_USE_RES struct LDKCResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ InvoiceRequest_respond_with_no_std(const struct LDKInvoiceRequest *NONNULL_PTR this_arg, struct LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ payment_paths, struct LDKThirtyTwoBytes payment_hash, uint64_t created_at); +uint64_t ProbabilisticScoringDecayParameters_get_liquidity_offset_half_life(const struct LDKProbabilisticScoringDecayParameters *NONNULL_PTR this_ptr); /** - * Verifies that the request was for an offer created using the given key. Returns the verified - * request which contains the derived keys needed to sign a [`Bolt12Invoice`] for the request - * if they could be extracted from the metadata. + * 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. * - * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice + * 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. */ -MUST_USE_RES struct LDKCResult_VerifiedInvoiceRequestNoneZ InvoiceRequest_verify(struct LDKInvoiceRequest this_arg, const struct LDKExpandedKey *NONNULL_PTR key); +void ProbabilisticScoringDecayParameters_set_liquidity_offset_half_life(struct LDKProbabilisticScoringDecayParameters *NONNULL_PTR this_ptr, uint64_t val); /** - * Signature of the invoice request using [`payer_id`]. - * - * [`payer_id`]: Self::payer_id + * Constructs a new ProbabilisticScoringDecayParameters given each field */ -MUST_USE_RES struct LDKSchnorrSignature InvoiceRequest_signature(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKProbabilisticScoringDecayParameters ProbabilisticScoringDecayParameters_new(uint64_t historical_no_updates_half_life_arg, uint64_t liquidity_offset_half_life_arg); /** - * 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. + * Creates a copy of the ProbabilisticScoringDecayParameters */ -MUST_USE_RES struct LDKCVec_ThirtyTwoBytesZ VerifiedInvoiceRequest_chains(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); +struct LDKProbabilisticScoringDecayParameters ProbabilisticScoringDecayParameters_clone(const struct LDKProbabilisticScoringDecayParameters *NONNULL_PTR orig); /** - * 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`. + * Creates a "default" ProbabilisticScoringDecayParameters. See struct and individual field documentaiton for details on which values are used. */ -MUST_USE_RES struct LDKCOption_CVec_u8ZZ VerifiedInvoiceRequest_metadata(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKProbabilisticScoringDecayParameters ProbabilisticScoringDecayParameters_default(void); /** - * The minimum amount required for a successful payment of a single item. + * Creates a new scorer using the given scoring parameters for sending payments from a node + * through a network graph. */ -MUST_USE_RES struct LDKCOption_AmountZ VerifiedInvoiceRequest_amount(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKProbabilisticScorer ProbabilisticScorer_new(struct LDKProbabilisticScoringDecayParameters decay_params, const struct LDKNetworkGraph *NONNULL_PTR network_graph, struct LDKLogger logger); /** - * 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. + * Dump the contents of this scorer into the configured logger. * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * 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. */ -MUST_USE_RES struct LDKPrintableString VerifiedInvoiceRequest_description(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); +void ProbabilisticScorer_debug_log_liquidity_stats(const struct LDKProbabilisticScorer *NONNULL_PTR this_arg); /** - * Features pertaining to the offer. + * Query the estimated minimum and maximum liquidity available for sending a payment over the + * channel with `scid` towards the given `target` node. */ -MUST_USE_RES struct LDKOfferFeatures VerifiedInvoiceRequest_offer_features(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); +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); /** - * Duration since the Unix epoch when an invoice should no longer be requested. + * Query the historical estimated minimum and maximum liquidity available for sending a + * payment over the channel with `scid` towards the given `target` node. * - * If `None`, the offer does not expire. - */ -MUST_USE_RES struct LDKCOption_u64Z VerifiedInvoiceRequest_absolute_expiry(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); - -/** - * 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. + * Returns two sets of 32 buckets. The first set describes the lower-bound liquidity history, + * the second set describes the upper-bound liquidity history. Each bucket describes the + * relative frequency at which we've seen a liquidity bound in the bucket's range 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. * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Note that the range of each bucket varies by its location to provide more granular results + * at the edges of a channel's capacity, where it is more likely to sit. + * + * When scoring, the estimated probability that an upper-/lower-bound lies in a given bucket + * is calculated by dividing that bucket's value with the total value of all buckets. + * + * For example, using a lower bucket count for illustrative purposes, a value of + * `[0, 0, 0, ..., 0, 32]` indicates that we believe the probability of a bound being very + * close to the channel's capacity to be 100%, and have never (recently) seen it in any other + * bucket. A value of `[31, 0, 0, ..., 0, 0, 32]` indicates we've seen the bound being both + * in the top and bottom bucket, and roughly with similar (recent) frequency. + * + * Because the datapoints are decayed slowly over time, values will eventually return to + * `Some(([0; 32], [0; 32]))` or `None` if no data remains for a channel. + * + * In order to fetch a single success probability from the buckets provided here, as used in + * the scoring model, see [`Self::historical_estimated_payment_success_probability`]. */ -MUST_USE_RES struct LDKPrintableString VerifiedInvoiceRequest_issuer(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCOption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ ProbabilisticScorer_historical_estimated_channel_liquidity_probabilities(const struct LDKProbabilisticScorer *NONNULL_PTR this_arg, uint64_t scid, const struct LDKNodeId *NONNULL_PTR target); /** - * Paths to the recipient originating from publicly reachable nodes. Blinded paths provide - * recipient privacy by obfuscating its node id. + * Query the probability of payment success sending the given `amount_msat` over the channel + * with `scid` towards the given `target` node, based on the historical estimated liquidity + * bounds. + * + * These are the same bounds as returned by + * [`Self::historical_estimated_channel_liquidity_probabilities`] (but not those returned by + * [`Self::estimated_channel_liquidity_range`]). */ -MUST_USE_RES struct LDKCVec_BlindedPathZ VerifiedInvoiceRequest_paths(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCOption_f64Z ProbabilisticScorer_historical_estimated_payment_success_probability(const struct LDKProbabilisticScorer *NONNULL_PTR this_arg, uint64_t scid, const struct LDKNodeId *NONNULL_PTR target, uint64_t amount_msat, const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR params); /** - * The quantity of items supported. + * Constructs a new ScoreLookUp which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned ScoreLookUp must be freed before this_arg is */ -MUST_USE_RES struct LDKQuantity VerifiedInvoiceRequest_supported_quantity(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); +struct LDKScoreLookUp ProbabilisticScorer_as_ScoreLookUp(const struct LDKProbabilisticScorer *NONNULL_PTR this_arg); /** - * The public key used by the recipient to sign invoices. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Constructs a new ScoreUpdate which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned ScoreUpdate must be freed before this_arg is */ -MUST_USE_RES struct LDKPublicKey VerifiedInvoiceRequest_signing_pubkey(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); +struct LDKScoreUpdate ProbabilisticScorer_as_ScoreUpdate(const struct LDKProbabilisticScorer *NONNULL_PTR this_arg); /** - * An unpredictable series of bytes, typically containing information about the derivation of - * [`payer_id`]. - * - * [`payer_id`]: Self::payer_id + * 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 */ -MUST_USE_RES struct LDKu8slice VerifiedInvoiceRequest_payer_metadata(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); +struct LDKScore ProbabilisticScorer_as_Score(const struct LDKProbabilisticScorer *NONNULL_PTR this_arg); /** - * A chain from [`Offer::chains`] that the offer is valid for. + * Serialize the ProbabilisticScorer object into a byte array which can be read by ProbabilisticScorer_read */ -MUST_USE_RES struct LDKThirtyTwoBytes VerifiedInvoiceRequest_chain(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); +struct LDKCVec_u8Z ProbabilisticScorer_write(const struct LDKProbabilisticScorer *NONNULL_PTR obj); /** - * 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 + * Read a ProbabilisticScorer from a byte array, created by ProbabilisticScorer_write */ -MUST_USE_RES struct LDKCOption_u64Z VerifiedInvoiceRequest_amount_msats(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); +struct LDKCResult_ProbabilisticScorerDecodeErrorZ ProbabilisticScorer_read(struct LDKu8slice ser, struct LDKProbabilisticScoringDecayParameters arg_a, const struct LDKNetworkGraph *NONNULL_PTR arg_b, struct LDKLogger arg_c); /** - * Features pertaining to requesting an invoice. + * Frees any resources used by the DelayedPaymentOutputDescriptor, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKInvoiceRequestFeatures VerifiedInvoiceRequest_invoice_request_features(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); +void DelayedPaymentOutputDescriptor_free(struct LDKDelayedPaymentOutputDescriptor this_obj); /** - * The quantity of the offer's item conforming to [`Offer::is_valid_quantity`]. + * The outpoint which is spendable. */ -MUST_USE_RES struct LDKCOption_u64Z VerifiedInvoiceRequest_quantity(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); +struct LDKOutPoint DelayedPaymentOutputDescriptor_get_outpoint(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); /** - * A possibly transient pubkey used to sign the invoice request. + * The outpoint which is spendable. */ -MUST_USE_RES struct LDKPublicKey VerifiedInvoiceRequest_payer_id(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); +void DelayedPaymentOutputDescriptor_set_outpoint(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKOutPoint val); /** - * 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 + * Per commitment point to derive the delayed payment key by key holder. */ -MUST_USE_RES struct LDKPrintableString VerifiedInvoiceRequest_payer_note(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); +struct LDKPublicKey DelayedPaymentOutputDescriptor_get_per_commitment_point(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); /** - * Creates an [`InvoiceBuilder`] for the request with the given required fields and using the - * [`Duration`] since [`std::time::SystemTime::UNIX_EPOCH`] as the creation time. - * - * See [`InvoiceRequest::respond_with_no_std`] for further details where the aforementioned - * creation time is used for the `created_at` parameter. - * - * [`Duration`]: core::time::Duration + * Per commitment point to derive the delayed payment key by key holder. */ -MUST_USE_RES struct LDKCResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ VerifiedInvoiceRequest_respond_with(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg, struct LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ payment_paths, struct LDKThirtyTwoBytes payment_hash); +void DelayedPaymentOutputDescriptor_set_per_commitment_point(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Creates an [`InvoiceBuilder`] for the request with the given required fields. - * - * Unless [`InvoiceBuilder::relative_expiry`] is set, the invoice will expire two hours after - * `created_at`, which is used to set [`Bolt12Invoice::created_at`]. Useful for `no-std` builds - * where [`std::time::SystemTime`] is not available. - * - * The caller is expected to remember the preimage of `payment_hash` in order to claim a payment - * for the invoice. - * - * The `payment_paths` parameter is useful for maintaining the payment recipient's privacy. It - * must contain one or more elements ordered from most-preferred to least-preferred, if there's - * a preference. Note, however, that any privacy is lost if a public node id was used for - * [`Offer::signing_pubkey`]. - * - * Errors if the request contains unknown required features. - * - * # Note - * - * If the originating [`Offer`] was created using [`OfferBuilder::deriving_signing_pubkey`], - * then use [`InvoiceRequest::verify`] and [`VerifiedInvoiceRequest`] methods instead. - * - * [`Bolt12Invoice::created_at`]: crate::offers::invoice::Bolt12Invoice::created_at - * [`OfferBuilder::deriving_signing_pubkey`]: crate::offers::offer::OfferBuilder::deriving_signing_pubkey + * The `nSequence` value which must be set in the spending input to satisfy the `OP_CSV` in + * the witness_script. */ -MUST_USE_RES struct LDKCResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ VerifiedInvoiceRequest_respond_with_no_std(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg, struct LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ payment_paths, struct LDKThirtyTwoBytes payment_hash, uint64_t created_at); +uint16_t DelayedPaymentOutputDescriptor_get_to_self_delay(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); /** - * Creates an [`InvoiceBuilder`] for the request using the given required fields and that uses - * derived signing keys from the originating [`Offer`] to sign the [`Bolt12Invoice`]. Must use - * the same [`ExpandedKey`] as the one used to create the offer. - * - * See [`InvoiceRequest::respond_with`] for further details. - * - * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice + * The `nSequence` value which must be set in the spending input to satisfy the `OP_CSV` in + * the witness_script. */ -MUST_USE_RES struct LDKCResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ VerifiedInvoiceRequest_respond_using_derived_keys(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg, struct LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ payment_paths, struct LDKThirtyTwoBytes payment_hash); +void DelayedPaymentOutputDescriptor_set_to_self_delay(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, uint16_t val); /** - * Creates an [`InvoiceBuilder`] for the request using the given required fields and that uses - * derived signing keys from the originating [`Offer`] to sign the [`Bolt12Invoice`]. Must use - * the same [`ExpandedKey`] as the one used to create the offer. - * - * See [`InvoiceRequest::respond_with_no_std`] for further details. - * - * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice + * The output which is referenced by the given outpoint. */ -MUST_USE_RES struct LDKCResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ VerifiedInvoiceRequest_respond_using_derived_keys_no_std(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg, struct LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ payment_paths, struct LDKThirtyTwoBytes payment_hash, uint64_t created_at); +struct LDKTxOut DelayedPaymentOutputDescriptor_get_output(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); /** - * Serialize the UnsignedInvoiceRequest object into a byte array which can be read by UnsignedInvoiceRequest_read + * The output which is referenced by the given outpoint. */ -struct LDKCVec_u8Z UnsignedInvoiceRequest_write(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR obj); +void DelayedPaymentOutputDescriptor_set_output(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKTxOut val); /** - * Serialize the InvoiceRequest object into a byte array which can be read by InvoiceRequest_read + * The revocation point specific to the commitment transaction which was broadcast. Used to + * derive the witnessScript for this output. */ -struct LDKCVec_u8Z InvoiceRequest_write(const struct LDKInvoiceRequest *NONNULL_PTR obj); +struct LDKRevocationKey DelayedPaymentOutputDescriptor_get_revocation_pubkey(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); /** - * Frees any resources used by the InvoiceRequestFields, if is_owned is set and inner is non-NULL. + * The revocation point specific to the commitment transaction which was broadcast. Used to + * derive the witnessScript for this output. */ -void InvoiceRequestFields_free(struct LDKInvoiceRequestFields this_obj); +void DelayedPaymentOutputDescriptor_set_revocation_pubkey(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKRevocationKey val); /** - * A possibly transient pubkey used to sign the invoice request. + * 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 LDKPublicKey InvoiceRequestFields_get_payer_id(const struct LDKInvoiceRequestFields *NONNULL_PTR this_ptr); +const uint8_t (*DelayedPaymentOutputDescriptor_get_channel_keys_id(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr))[32]; /** - * A possibly transient pubkey used to sign the invoice request. + * 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 InvoiceRequestFields_set_payer_id(struct LDKInvoiceRequestFields *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void DelayedPaymentOutputDescriptor_set_channel_keys_id(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The quantity of the offer's item conforming to [`Offer::is_valid_quantity`]. + * The value of the channel which this output originated from, possibly indirectly. */ -struct LDKCOption_u64Z InvoiceRequestFields_get_quantity(const struct LDKInvoiceRequestFields *NONNULL_PTR this_ptr); +uint64_t DelayedPaymentOutputDescriptor_get_channel_value_satoshis(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); /** - * The quantity of the offer's item conforming to [`Offer::is_valid_quantity`]. + * The value of the channel which this output originated from, possibly indirectly. */ -void InvoiceRequestFields_set_quantity(struct LDKInvoiceRequestFields *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); +void DelayedPaymentOutputDescriptor_set_channel_value_satoshis(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, uint64_t val); /** - * A payer-provided note which will be seen by the recipient and reflected back in the invoice - * response. Truncated to [`PAYER_NOTE_LIMIT`] characters. + * The channel public keys and other parameters needed to generate a spending transaction or + * to provide to a re-derived signer through [`ChannelSigner::provide_channel_parameters`]. + * + * Added as optional, but always `Some` if the descriptor was produced in v0.0.123 or later. * * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKUntrustedString InvoiceRequestFields_get_payer_note_truncated(const struct LDKInvoiceRequestFields *NONNULL_PTR this_ptr); +struct LDKChannelTransactionParameters DelayedPaymentOutputDescriptor_get_channel_transaction_parameters(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); /** - * A payer-provided note which will be seen by the recipient and reflected back in the invoice - * response. Truncated to [`PAYER_NOTE_LIMIT`] characters. + * The channel public keys and other parameters needed to generate a spending transaction or + * to provide to a re-derived signer through [`ChannelSigner::provide_channel_parameters`]. + * + * Added as optional, but always `Some` if the descriptor was produced in v0.0.123 or later. * * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void InvoiceRequestFields_set_payer_note_truncated(struct LDKInvoiceRequestFields *NONNULL_PTR this_ptr, struct LDKUntrustedString val); +void DelayedPaymentOutputDescriptor_set_channel_transaction_parameters(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKChannelTransactionParameters val); /** - * Constructs a new InvoiceRequestFields given each field + * Constructs a new DelayedPaymentOutputDescriptor given each field * - * Note that payer_note_truncated_arg (or a relevant inner pointer) may be NULL or all-0s to represent None - */ -MUST_USE_RES struct LDKInvoiceRequestFields InvoiceRequestFields_new(struct LDKPublicKey payer_id_arg, struct LDKCOption_u64Z quantity_arg, struct LDKUntrustedString payer_note_truncated_arg); - -/** - * Creates a copy of the InvoiceRequestFields - */ -struct LDKInvoiceRequestFields InvoiceRequestFields_clone(const struct LDKInvoiceRequestFields *NONNULL_PTR orig); - -/** - * Checks if two InvoiceRequestFieldss 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 InvoiceRequestFields_eq(const struct LDKInvoiceRequestFields *NONNULL_PTR a, const struct LDKInvoiceRequestFields *NONNULL_PTR b); - -/** - * Serialize the InvoiceRequestFields object into a byte array which can be read by InvoiceRequestFields_read - */ -struct LDKCVec_u8Z InvoiceRequestFields_write(const struct LDKInvoiceRequestFields *NONNULL_PTR obj); - -/** - * Read a InvoiceRequestFields from a byte array, created by InvoiceRequestFields_write - */ -struct LDKCResult_InvoiceRequestFieldsDecodeErrorZ InvoiceRequestFields_read(struct LDKu8slice ser); - -/** - * Frees any resources used by the TaggedHash, if is_owned is set and inner is non-NULL. - */ -void TaggedHash_free(struct LDKTaggedHash this_obj); - -/** - * Creates a copy of the TaggedHash - */ -struct LDKTaggedHash TaggedHash_clone(const struct LDKTaggedHash *NONNULL_PTR orig); - -/** - * Returns the digest to sign. - */ -MUST_USE_RES const uint8_t (*TaggedHash_as_digest(const struct LDKTaggedHash *NONNULL_PTR this_arg))[32]; - -/** - * Returns the tag used in the tagged hash. - */ -MUST_USE_RES struct LDKStr TaggedHash_tag(const struct LDKTaggedHash *NONNULL_PTR this_arg); - -/** - * Returns the merkle root used in the tagged hash. + * Note that channel_transaction_parameters_arg (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKThirtyTwoBytes TaggedHash_merkle_root(const struct LDKTaggedHash *NONNULL_PTR this_arg); +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 LDKRevocationKey revocation_pubkey_arg, struct LDKThirtyTwoBytes channel_keys_id_arg, uint64_t channel_value_satoshis_arg, struct LDKChannelTransactionParameters channel_transaction_parameters_arg); /** - * Frees any resources used by the SignError + * Creates a copy of the DelayedPaymentOutputDescriptor */ -void SignError_free(struct LDKSignError this_ptr); +struct LDKDelayedPaymentOutputDescriptor DelayedPaymentOutputDescriptor_clone(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR orig); /** - * Creates a copy of the SignError + * Generates a non-cryptographic 64-bit hash of the DelayedPaymentOutputDescriptor. */ -struct LDKSignError SignError_clone(const struct LDKSignError *NONNULL_PTR orig); +uint64_t DelayedPaymentOutputDescriptor_hash(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR o); /** - * Utility method to constructs a new Signing-variant SignError + * 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. */ -struct LDKSignError SignError_signing(void); +bool DelayedPaymentOutputDescriptor_eq(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR a, const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR b); /** - * Utility method to constructs a new Verification-variant SignError + * Serialize the DelayedPaymentOutputDescriptor object into a byte array which can be read by DelayedPaymentOutputDescriptor_read */ -struct LDKSignError SignError_verification(enum LDKSecp256k1Error a); +struct LDKCVec_u8Z DelayedPaymentOutputDescriptor_write(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR obj); /** - * Frees any resources used by the Bolt12ParseError, if is_owned is set and inner is non-NULL. + * Read a DelayedPaymentOutputDescriptor from a byte array, created by DelayedPaymentOutputDescriptor_write */ -void Bolt12ParseError_free(struct LDKBolt12ParseError this_obj); +struct LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ DelayedPaymentOutputDescriptor_read(struct LDKu8slice ser); /** - * Creates a copy of the Bolt12ParseError + * Frees any resources used by the StaticPaymentOutputDescriptor, if is_owned is set and inner is non-NULL. */ -struct LDKBolt12ParseError Bolt12ParseError_clone(const struct LDKBolt12ParseError *NONNULL_PTR orig); +void StaticPaymentOutputDescriptor_free(struct LDKStaticPaymentOutputDescriptor this_obj); /** - * Creates a copy of the Bolt12SemanticError + * The outpoint which is spendable. */ -enum LDKBolt12SemanticError Bolt12SemanticError_clone(const enum LDKBolt12SemanticError *NONNULL_PTR orig); +struct LDKOutPoint StaticPaymentOutputDescriptor_get_outpoint(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr); /** - * Utility method to constructs a new AlreadyExpired-variant Bolt12SemanticError + * The outpoint which is spendable. */ -enum LDKBolt12SemanticError Bolt12SemanticError_already_expired(void); +void StaticPaymentOutputDescriptor_set_outpoint(struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKOutPoint val); /** - * Utility method to constructs a new UnsupportedChain-variant Bolt12SemanticError + * The output which is referenced by the given outpoint. */ -enum LDKBolt12SemanticError Bolt12SemanticError_unsupported_chain(void); +struct LDKTxOut StaticPaymentOutputDescriptor_get_output(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr); /** - * Utility method to constructs a new UnexpectedChain-variant Bolt12SemanticError + * The output which is referenced by the given outpoint. */ -enum LDKBolt12SemanticError Bolt12SemanticError_unexpected_chain(void); +void StaticPaymentOutputDescriptor_set_output(struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKTxOut val); /** - * Utility method to constructs a new MissingAmount-variant Bolt12SemanticError + * 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. */ -enum LDKBolt12SemanticError Bolt12SemanticError_missing_amount(void); +const uint8_t (*StaticPaymentOutputDescriptor_get_channel_keys_id(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr))[32]; /** - * Utility method to constructs a new InvalidAmount-variant Bolt12SemanticError + * 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. */ -enum LDKBolt12SemanticError Bolt12SemanticError_invalid_amount(void); +void StaticPaymentOutputDescriptor_set_channel_keys_id(struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Utility method to constructs a new InsufficientAmount-variant Bolt12SemanticError + * The value of the channel which this transactions spends. */ -enum LDKBolt12SemanticError Bolt12SemanticError_insufficient_amount(void); +uint64_t StaticPaymentOutputDescriptor_get_channel_value_satoshis(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr); /** - * Utility method to constructs a new UnexpectedAmount-variant Bolt12SemanticError + * The value of the channel which this transactions spends. */ -enum LDKBolt12SemanticError Bolt12SemanticError_unexpected_amount(void); +void StaticPaymentOutputDescriptor_set_channel_value_satoshis(struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr, uint64_t val); /** - * Utility method to constructs a new UnsupportedCurrency-variant Bolt12SemanticError + * The necessary channel parameters that need to be provided to the re-derived signer through + * [`ChannelSigner::provide_channel_parameters`]. + * + * Added as optional, but always `Some` if the descriptor was produced in v0.0.117 or later. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -enum LDKBolt12SemanticError Bolt12SemanticError_unsupported_currency(void); +struct LDKChannelTransactionParameters StaticPaymentOutputDescriptor_get_channel_transaction_parameters(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr); /** - * Utility method to constructs a new UnknownRequiredFeatures-variant Bolt12SemanticError + * The necessary channel parameters that need to be provided to the re-derived signer through + * [`ChannelSigner::provide_channel_parameters`]. + * + * Added as optional, but always `Some` if the descriptor was produced in v0.0.117 or later. + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -enum LDKBolt12SemanticError Bolt12SemanticError_unknown_required_features(void); +void StaticPaymentOutputDescriptor_set_channel_transaction_parameters(struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKChannelTransactionParameters val); /** - * Utility method to constructs a new UnexpectedFeatures-variant Bolt12SemanticError + * Constructs a new StaticPaymentOutputDescriptor given each field + * + * Note that channel_transaction_parameters_arg (or a relevant inner pointer) may be NULL or all-0s to represent None */ -enum LDKBolt12SemanticError Bolt12SemanticError_unexpected_features(void); +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, struct LDKChannelTransactionParameters channel_transaction_parameters_arg); /** - * Utility method to constructs a new MissingDescription-variant Bolt12SemanticError + * Creates a copy of the StaticPaymentOutputDescriptor */ -enum LDKBolt12SemanticError Bolt12SemanticError_missing_description(void); +struct LDKStaticPaymentOutputDescriptor StaticPaymentOutputDescriptor_clone(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR orig); /** - * Utility method to constructs a new MissingSigningPubkey-variant Bolt12SemanticError + * Generates a non-cryptographic 64-bit hash of the StaticPaymentOutputDescriptor. */ -enum LDKBolt12SemanticError Bolt12SemanticError_missing_signing_pubkey(void); +uint64_t StaticPaymentOutputDescriptor_hash(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR o); /** - * Utility method to constructs a new InvalidSigningPubkey-variant Bolt12SemanticError + * 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. */ -enum LDKBolt12SemanticError Bolt12SemanticError_invalid_signing_pubkey(void); +bool StaticPaymentOutputDescriptor_eq(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR a, const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR b); /** - * Utility method to constructs a new UnexpectedSigningPubkey-variant Bolt12SemanticError + * Returns the `witness_script` of the spendable output. + * + * Note that this will only return `Some` for [`StaticPaymentOutputDescriptor`]s that + * originated from an anchor outputs channel, as they take the form of a P2WSH script. */ -enum LDKBolt12SemanticError Bolt12SemanticError_unexpected_signing_pubkey(void); +MUST_USE_RES struct LDKCOption_CVec_u8ZZ StaticPaymentOutputDescriptor_witness_script(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_arg); /** - * Utility method to constructs a new MissingQuantity-variant Bolt12SemanticError + * The maximum length a well-formed witness spending one of these should have. + * Note: If you have the grind_signatures feature enabled, this will be at least 1 byte + * shorter. */ -enum LDKBolt12SemanticError Bolt12SemanticError_missing_quantity(void); +MUST_USE_RES uint64_t StaticPaymentOutputDescriptor_max_witness_length(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_arg); /** - * Utility method to constructs a new InvalidQuantity-variant Bolt12SemanticError + * Serialize the StaticPaymentOutputDescriptor object into a byte array which can be read by StaticPaymentOutputDescriptor_read */ -enum LDKBolt12SemanticError Bolt12SemanticError_invalid_quantity(void); +struct LDKCVec_u8Z StaticPaymentOutputDescriptor_write(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR obj); /** - * Utility method to constructs a new UnexpectedQuantity-variant Bolt12SemanticError + * Read a StaticPaymentOutputDescriptor from a byte array, created by StaticPaymentOutputDescriptor_write */ -enum LDKBolt12SemanticError Bolt12SemanticError_unexpected_quantity(void); +struct LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ StaticPaymentOutputDescriptor_read(struct LDKu8slice ser); /** - * Utility method to constructs a new InvalidMetadata-variant Bolt12SemanticError + * Frees any resources used by the SpendableOutputDescriptor */ -enum LDKBolt12SemanticError Bolt12SemanticError_invalid_metadata(void); +void SpendableOutputDescriptor_free(struct LDKSpendableOutputDescriptor this_ptr); /** - * Utility method to constructs a new UnexpectedMetadata-variant Bolt12SemanticError + * Creates a copy of the SpendableOutputDescriptor */ -enum LDKBolt12SemanticError Bolt12SemanticError_unexpected_metadata(void); +struct LDKSpendableOutputDescriptor SpendableOutputDescriptor_clone(const struct LDKSpendableOutputDescriptor *NONNULL_PTR orig); /** - * Utility method to constructs a new MissingPayerMetadata-variant Bolt12SemanticError + * Utility method to constructs a new StaticOutput-variant SpendableOutputDescriptor */ -enum LDKBolt12SemanticError Bolt12SemanticError_missing_payer_metadata(void); +struct LDKSpendableOutputDescriptor SpendableOutputDescriptor_static_output(struct LDKOutPoint outpoint, struct LDKTxOut output, struct LDKThirtyTwoBytes channel_keys_id); /** - * Utility method to constructs a new MissingPayerId-variant Bolt12SemanticError + * Utility method to constructs a new DelayedPaymentOutput-variant SpendableOutputDescriptor */ -enum LDKBolt12SemanticError Bolt12SemanticError_missing_payer_id(void); +struct LDKSpendableOutputDescriptor SpendableOutputDescriptor_delayed_payment_output(struct LDKDelayedPaymentOutputDescriptor a); /** - * Utility method to constructs a new DuplicatePaymentId-variant Bolt12SemanticError + * Utility method to constructs a new StaticPaymentOutput-variant SpendableOutputDescriptor */ -enum LDKBolt12SemanticError Bolt12SemanticError_duplicate_payment_id(void); +struct LDKSpendableOutputDescriptor SpendableOutputDescriptor_static_payment_output(struct LDKStaticPaymentOutputDescriptor a); /** - * Utility method to constructs a new MissingPaths-variant Bolt12SemanticError + * Generates a non-cryptographic 64-bit hash of the SpendableOutputDescriptor. */ -enum LDKBolt12SemanticError Bolt12SemanticError_missing_paths(void); +uint64_t SpendableOutputDescriptor_hash(const struct LDKSpendableOutputDescriptor *NONNULL_PTR o); /** - * Utility method to constructs a new UnexpectedPaths-variant Bolt12SemanticError + * Checks if two SpendableOutputDescriptors contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -enum LDKBolt12SemanticError Bolt12SemanticError_unexpected_paths(void); +bool SpendableOutputDescriptor_eq(const struct LDKSpendableOutputDescriptor *NONNULL_PTR a, const struct LDKSpendableOutputDescriptor *NONNULL_PTR b); /** - * Utility method to constructs a new InvalidPayInfo-variant Bolt12SemanticError + * Serialize the SpendableOutputDescriptor object into a byte array which can be read by SpendableOutputDescriptor_read */ -enum LDKBolt12SemanticError Bolt12SemanticError_invalid_pay_info(void); +struct LDKCVec_u8Z SpendableOutputDescriptor_write(const struct LDKSpendableOutputDescriptor *NONNULL_PTR obj); /** - * Utility method to constructs a new MissingCreationTime-variant Bolt12SemanticError + * Read a SpendableOutputDescriptor from a byte array, created by SpendableOutputDescriptor_write */ -enum LDKBolt12SemanticError Bolt12SemanticError_missing_creation_time(void); +struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ SpendableOutputDescriptor_read(struct LDKu8slice ser); /** - * Utility method to constructs a new MissingPaymentHash-variant Bolt12SemanticError + * Creates an unsigned [`Psbt`] 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. */ -enum LDKBolt12SemanticError Bolt12SemanticError_missing_payment_hash(void); +MUST_USE_RES struct LDKCResult_C2Tuple_CVec_u8Zu64ZNoneZ 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_u32Z locktime); /** - * Utility method to constructs a new MissingSignature-variant Bolt12SemanticError + * Frees any resources used by the ChannelDerivationParameters, if is_owned is set and inner is non-NULL. */ -enum LDKBolt12SemanticError Bolt12SemanticError_missing_signature(void); +void ChannelDerivationParameters_free(struct LDKChannelDerivationParameters this_obj); /** - * Frees any resources used by the RefundMaybeWithDerivedMetadataBuilder, if is_owned is set and inner is non-NULL. + * The value in satoshis of the channel we're attempting to spend the anchor output of. */ -void RefundMaybeWithDerivedMetadataBuilder_free(struct LDKRefundMaybeWithDerivedMetadataBuilder this_obj); +uint64_t ChannelDerivationParameters_get_value_satoshis(const struct LDKChannelDerivationParameters *NONNULL_PTR this_ptr); /** - * Creates a copy of the RefundMaybeWithDerivedMetadataBuilder + * The value in satoshis of the channel we're attempting to spend the anchor output of. */ -struct LDKRefundMaybeWithDerivedMetadataBuilder RefundMaybeWithDerivedMetadataBuilder_clone(const struct LDKRefundMaybeWithDerivedMetadataBuilder *NONNULL_PTR orig); +void ChannelDerivationParameters_set_value_satoshis(struct LDKChannelDerivationParameters *NONNULL_PTR this_ptr, uint64_t val); /** - * Creates a new builder for a refund using the [`Refund::payer_id`] for the public node id to - * send to if no [`Refund::paths`] are set. Otherwise, it may be a transient pubkey. - * - * Additionally, sets the required (empty) [`Refund::description`], [`Refund::payer_metadata`], - * and [`Refund::amount_msats`]. - * - * # Note - * - * If constructing a [`Refund`] for use with a [`ChannelManager`], use - * [`ChannelManager::create_refund_builder`] instead of [`RefundBuilder::new`]. - * - * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager - * [`ChannelManager::create_refund_builder`]: crate::ln::channelmanager::ChannelManager::create_refund_builder + * The unique identifier to re-derive the signer for the associated channel. */ -MUST_USE_RES struct LDKCResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ RefundMaybeWithDerivedMetadataBuilder_new(struct LDKCVec_u8Z metadata, struct LDKPublicKey payer_id, uint64_t amount_msats); +const uint8_t (*ChannelDerivationParameters_get_keys_id(const struct LDKChannelDerivationParameters *NONNULL_PTR this_ptr))[32]; /** - * Similar to [`RefundBuilder::new`] except, if [`RefundBuilder::path`] is called, the payer id - * is derived from the given [`ExpandedKey`] and nonce. This provides sender privacy by using a - * different payer id for each refund, assuming a different nonce is used. Otherwise, the - * provided `node_id` is used for the payer id. - * - * Also, sets the metadata when [`RefundBuilder::build`] is called such that it can be used to - * verify that an [`InvoiceRequest`] was produced for the refund given an [`ExpandedKey`]. - * - * The `payment_id` is encrypted in the metadata and should be unique. This ensures that only - * one invoice will be paid for the refund and that payments can be uniquely identified. - * - * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest - * [`ExpandedKey`]: crate::ln::inbound_payment::ExpandedKey + * The unique identifier to re-derive the signer for the associated channel. */ -MUST_USE_RES struct LDKCResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ RefundMaybeWithDerivedMetadataBuilder_deriving_payer_id(struct LDKPublicKey node_id, const struct LDKExpandedKey *NONNULL_PTR expanded_key, struct LDKEntropySource entropy_source, uint64_t amount_msats, struct LDKThirtyTwoBytes payment_id); +void ChannelDerivationParameters_set_keys_id(struct LDKChannelDerivationParameters *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Sets the [`Refund::description`]. - * - * Successive calls to this method will override the previous setting. + * The necessary channel parameters that need to be provided to the re-derived signer through + * [`ChannelSigner::provide_channel_parameters`]. */ -MUST_USE_RES void RefundMaybeWithDerivedMetadataBuilder_description(struct LDKRefundMaybeWithDerivedMetadataBuilder this_arg, struct LDKStr description); +struct LDKChannelTransactionParameters ChannelDerivationParameters_get_transaction_parameters(const struct LDKChannelDerivationParameters *NONNULL_PTR this_ptr); /** - * Sets the [`Refund::absolute_expiry`] as seconds since the Unix epoch. Any expiry that has - * already passed is valid and can be checked for using [`Refund::is_expired`]. - * - * Successive calls to this method will override the previous setting. + * The necessary channel parameters that need to be provided to the re-derived signer through + * [`ChannelSigner::provide_channel_parameters`]. */ -MUST_USE_RES void RefundMaybeWithDerivedMetadataBuilder_absolute_expiry(struct LDKRefundMaybeWithDerivedMetadataBuilder this_arg, uint64_t absolute_expiry); +void ChannelDerivationParameters_set_transaction_parameters(struct LDKChannelDerivationParameters *NONNULL_PTR this_ptr, struct LDKChannelTransactionParameters val); /** - * Sets the [`Refund::issuer`]. - * - * Successive calls to this method will override the previous setting. + * Constructs a new ChannelDerivationParameters given each field */ -MUST_USE_RES void RefundMaybeWithDerivedMetadataBuilder_issuer(struct LDKRefundMaybeWithDerivedMetadataBuilder this_arg, struct LDKStr issuer); +MUST_USE_RES struct LDKChannelDerivationParameters ChannelDerivationParameters_new(uint64_t value_satoshis_arg, struct LDKThirtyTwoBytes keys_id_arg, struct LDKChannelTransactionParameters transaction_parameters_arg); /** - * Adds a blinded path to [`Refund::paths`]. Must include at least one path if only connected - * by private channels or if [`Refund::payer_id`] is not a public node id. - * - * Successive calls to this method will add another blinded path. Caller is responsible for not - * adding duplicate paths. + * Creates a copy of the ChannelDerivationParameters */ -MUST_USE_RES void RefundMaybeWithDerivedMetadataBuilder_path(struct LDKRefundMaybeWithDerivedMetadataBuilder this_arg, struct LDKBlindedPath path); +struct LDKChannelDerivationParameters ChannelDerivationParameters_clone(const struct LDKChannelDerivationParameters *NONNULL_PTR orig); /** - * Sets the [`Refund::chain`] of the given [`Network`] for paying an invoice. If not - * called, [`Network::Bitcoin`] is assumed. - * - * Successive calls to this method will override the previous setting. + * 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. */ -MUST_USE_RES void RefundMaybeWithDerivedMetadataBuilder_chain(struct LDKRefundMaybeWithDerivedMetadataBuilder this_arg, enum LDKNetwork network); +bool ChannelDerivationParameters_eq(const struct LDKChannelDerivationParameters *NONNULL_PTR a, const struct LDKChannelDerivationParameters *NONNULL_PTR b); /** - * Sets [`Refund::quantity`] of items. This is purely for informational purposes. It is useful - * when the refund pertains to a [`Bolt12Invoice`] that paid for more than one item from an - * [`Offer`] as specified by [`InvoiceRequest::quantity`]. - * - * Successive calls to this method will override the previous setting. - * - * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice - * [`InvoiceRequest::quantity`]: crate::offers::invoice_request::InvoiceRequest::quantity - * [`Offer`]: crate::offers::offer::Offer + * Serialize the ChannelDerivationParameters object into a byte array which can be read by ChannelDerivationParameters_read */ -MUST_USE_RES void RefundMaybeWithDerivedMetadataBuilder_quantity(struct LDKRefundMaybeWithDerivedMetadataBuilder this_arg, uint64_t quantity); +struct LDKCVec_u8Z ChannelDerivationParameters_write(const struct LDKChannelDerivationParameters *NONNULL_PTR obj); /** - * Sets the [`Refund::payer_note`]. - * - * Successive calls to this method will override the previous setting. + * Read a ChannelDerivationParameters from a byte array, created by ChannelDerivationParameters_write */ -MUST_USE_RES void RefundMaybeWithDerivedMetadataBuilder_payer_note(struct LDKRefundMaybeWithDerivedMetadataBuilder this_arg, struct LDKStr payer_note); +struct LDKCResult_ChannelDerivationParametersDecodeErrorZ ChannelDerivationParameters_read(struct LDKu8slice ser); /** - * Builds a [`Refund`] after checking for valid semantics. + * Frees any resources used by the HTLCDescriptor, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKCResult_RefundBolt12SemanticErrorZ RefundMaybeWithDerivedMetadataBuilder_build(struct LDKRefundMaybeWithDerivedMetadataBuilder this_arg); +void HTLCDescriptor_free(struct LDKHTLCDescriptor this_obj); /** - * Frees any resources used by the Refund, if is_owned is set and inner is non-NULL. + * The parameters required to derive the signer for the HTLC input. */ -void Refund_free(struct LDKRefund this_obj); +struct LDKChannelDerivationParameters HTLCDescriptor_get_channel_derivation_parameters(const struct LDKHTLCDescriptor *NONNULL_PTR this_ptr); /** - * Creates a copy of the Refund + * The parameters required to derive the signer for the HTLC input. */ -struct LDKRefund Refund_clone(const struct LDKRefund *NONNULL_PTR orig); +void HTLCDescriptor_set_channel_derivation_parameters(struct LDKHTLCDescriptor *NONNULL_PTR this_ptr, struct LDKChannelDerivationParameters 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. + * The txid of the commitment transaction in which the HTLC output lives. */ -MUST_USE_RES struct LDKPrintableString Refund_description(const struct LDKRefund *NONNULL_PTR this_arg); +const uint8_t (*HTLCDescriptor_get_commitment_txid(const struct LDKHTLCDescriptor *NONNULL_PTR this_ptr))[32]; /** - * Duration since the Unix epoch when an invoice should no longer be sent. - * - * If `None`, the refund does not expire. + * The txid of the commitment transaction in which the HTLC output lives. */ -MUST_USE_RES struct LDKCOption_u64Z Refund_absolute_expiry(const struct LDKRefund *NONNULL_PTR this_arg); +void HTLCDescriptor_set_commitment_txid(struct LDKHTLCDescriptor *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Whether the refund has expired. + * The number of the commitment transaction in which the HTLC output lives. */ -MUST_USE_RES bool Refund_is_expired(const struct LDKRefund *NONNULL_PTR this_arg); +uint64_t HTLCDescriptor_get_per_commitment_number(const struct LDKHTLCDescriptor *NONNULL_PTR this_ptr); /** - * Whether the refund has expired given the duration since the Unix epoch. + * The number of the commitment transaction in which the HTLC output lives. */ -MUST_USE_RES bool Refund_is_expired_no_std(const struct LDKRefund *NONNULL_PTR this_arg, uint64_t duration_since_epoch); +void HTLCDescriptor_set_per_commitment_number(struct LDKHTLCDescriptor *NONNULL_PTR this_ptr, uint64_t val); /** - * 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. + * 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. * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None - */ -MUST_USE_RES struct LDKPrintableString Refund_issuer(const struct LDKRefund *NONNULL_PTR this_arg); - -/** - * Paths to the sender originating from publicly reachable nodes. Blinded paths provide sender - * privacy by obfuscating its node id. + * See for more info. */ -MUST_USE_RES struct LDKCVec_BlindedPathZ Refund_paths(const struct LDKRefund *NONNULL_PTR this_arg); +struct LDKPublicKey HTLCDescriptor_get_per_commitment_point(const struct LDKHTLCDescriptor *NONNULL_PTR this_ptr); /** - * An unpredictable series of bytes, typically containing information about the derivation of - * [`payer_id`]. + * 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. * - * [`payer_id`]: Self::payer_id + * See for more info. */ -MUST_USE_RES struct LDKu8slice Refund_payer_metadata(const struct LDKRefund *NONNULL_PTR this_arg); +void HTLCDescriptor_set_per_commitment_point(struct LDKHTLCDescriptor *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * A chain that the refund is valid for. + * The feerate to use on the HTLC claiming transaction. This is always `0` for HTLCs + * originating from a channel supporting anchor outputs, otherwise it is the channel's + * negotiated feerate at the time the commitment transaction was built. */ -MUST_USE_RES struct LDKThirtyTwoBytes Refund_chain(const struct LDKRefund *NONNULL_PTR this_arg); +uint32_t HTLCDescriptor_get_feerate_per_kw(const struct LDKHTLCDescriptor *NONNULL_PTR this_ptr); /** - * The amount to refund in msats (i.e., the minimum lightning-payable unit for [`chain`]). - * - * [`chain`]: Self::chain + * The feerate to use on the HTLC claiming transaction. This is always `0` for HTLCs + * originating from a channel supporting anchor outputs, otherwise it is the channel's + * negotiated feerate at the time the commitment transaction was built. */ -MUST_USE_RES uint64_t Refund_amount_msats(const struct LDKRefund *NONNULL_PTR this_arg); +void HTLCDescriptor_set_feerate_per_kw(struct LDKHTLCDescriptor *NONNULL_PTR this_ptr, uint32_t val); /** - * Features pertaining to requesting an invoice. + * The details of the HTLC as it appears in the commitment transaction. */ -MUST_USE_RES struct LDKInvoiceRequestFeatures Refund_features(const struct LDKRefund *NONNULL_PTR this_arg); +struct LDKHTLCOutputInCommitment HTLCDescriptor_get_htlc(const struct LDKHTLCDescriptor *NONNULL_PTR this_ptr); /** - * The quantity of an item that refund is for. + * The details of the HTLC as it appears in the commitment transaction. */ -MUST_USE_RES struct LDKCOption_u64Z Refund_quantity(const struct LDKRefund *NONNULL_PTR this_arg); +void HTLCDescriptor_set_htlc(struct LDKHTLCDescriptor *NONNULL_PTR this_ptr, struct LDKHTLCOutputInCommitment val); /** - * A public node id to send to in the case where there are no [`paths`]. Otherwise, a possibly - * transient pubkey. - * - * [`paths`]: Self::paths + * The preimage, if `Some`, to claim the HTLC output with. If `None`, the timeout path must be + * taken. */ -MUST_USE_RES struct LDKPublicKey Refund_payer_id(const struct LDKRefund *NONNULL_PTR this_arg); +struct LDKCOption_ThirtyTwoBytesZ HTLCDescriptor_get_preimage(const struct LDKHTLCDescriptor *NONNULL_PTR this_ptr); /** - * 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 + * The preimage, if `Some`, to claim the HTLC output with. If `None`, the timeout path must be + * taken. */ -MUST_USE_RES struct LDKPrintableString Refund_payer_note(const struct LDKRefund *NONNULL_PTR this_arg); +void HTLCDescriptor_set_preimage(struct LDKHTLCDescriptor *NONNULL_PTR this_ptr, struct LDKCOption_ThirtyTwoBytesZ val); /** - * Generates a non-cryptographic 64-bit hash of the Refund. + * The counterparty's signature required to spend the HTLC output. */ -uint64_t Refund_hash(const struct LDKRefund *NONNULL_PTR o); +struct LDKECDSASignature HTLCDescriptor_get_counterparty_sig(const struct LDKHTLCDescriptor *NONNULL_PTR this_ptr); /** - * Serialize the Refund object into a byte array which can be read by Refund_read + * The counterparty's signature required to spend the HTLC output. */ -struct LDKCVec_u8Z Refund_write(const struct LDKRefund *NONNULL_PTR obj); +void HTLCDescriptor_set_counterparty_sig(struct LDKHTLCDescriptor *NONNULL_PTR this_ptr, struct LDKECDSASignature val); /** - * Read a Refund object from a string + * Constructs a new HTLCDescriptor given each field */ -struct LDKCResult_RefundBolt12ParseErrorZ Refund_from_str(struct LDKStr s); +MUST_USE_RES struct LDKHTLCDescriptor HTLCDescriptor_new(struct LDKChannelDerivationParameters channel_derivation_parameters_arg, struct LDKThirtyTwoBytes commitment_txid_arg, uint64_t per_commitment_number_arg, struct LDKPublicKey per_commitment_point_arg, uint32_t feerate_per_kw_arg, struct LDKHTLCOutputInCommitment htlc_arg, struct LDKCOption_ThirtyTwoBytesZ preimage_arg, struct LDKECDSASignature counterparty_sig_arg); /** - * Get the string representation of a Refund object + * Creates a copy of the HTLCDescriptor */ -struct LDKStr Refund_to_str(const struct LDKRefund *NONNULL_PTR o); +struct LDKHTLCDescriptor HTLCDescriptor_clone(const struct LDKHTLCDescriptor *NONNULL_PTR orig); /** - * Creates a copy of the UtxoLookupError + * 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. */ -enum LDKUtxoLookupError UtxoLookupError_clone(const enum LDKUtxoLookupError *NONNULL_PTR orig); +bool HTLCDescriptor_eq(const struct LDKHTLCDescriptor *NONNULL_PTR a, const struct LDKHTLCDescriptor *NONNULL_PTR b); /** - * Utility method to constructs a new UnknownChain-variant UtxoLookupError + * Serialize the HTLCDescriptor object into a byte array which can be read by HTLCDescriptor_read */ -enum LDKUtxoLookupError UtxoLookupError_unknown_chain(void); +struct LDKCVec_u8Z HTLCDescriptor_write(const struct LDKHTLCDescriptor *NONNULL_PTR obj); /** - * Utility method to constructs a new UnknownTx-variant UtxoLookupError + * Read a HTLCDescriptor from a byte array, created by HTLCDescriptor_write */ -enum LDKUtxoLookupError UtxoLookupError_unknown_tx(void); +struct LDKCResult_HTLCDescriptorDecodeErrorZ HTLCDescriptor_read(struct LDKu8slice ser); /** - * Frees any resources used by the UtxoResult + * 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. */ -void UtxoResult_free(struct LDKUtxoResult this_ptr); +MUST_USE_RES struct LDKOutPoint HTLCDescriptor_outpoint(const struct LDKHTLCDescriptor *NONNULL_PTR this_arg); /** - * Creates a copy of the UtxoResult + * Returns the UTXO to be spent by the HTLC input, which can be obtained via + * [`Self::unsigned_tx_input`]. */ -struct LDKUtxoResult UtxoResult_clone(const struct LDKUtxoResult *NONNULL_PTR orig); +MUST_USE_RES struct LDKTxOut HTLCDescriptor_previous_utxo(const struct LDKHTLCDescriptor *NONNULL_PTR this_arg); /** - * Utility method to constructs a new Sync-variant UtxoResult + * Returns the unsigned transaction input spending the HTLC output in the commitment + * transaction. */ -struct LDKUtxoResult UtxoResult_sync(struct LDKCResult_TxOutUtxoLookupErrorZ a); +MUST_USE_RES struct LDKTxIn HTLCDescriptor_unsigned_tx_input(const struct LDKHTLCDescriptor *NONNULL_PTR this_arg); /** - * Utility method to constructs a new Async-variant UtxoResult + * Returns the delayed output created as a result of spending the HTLC output in the commitment + * transaction. */ -struct LDKUtxoResult UtxoResult_async(struct LDKUtxoFuture a); +MUST_USE_RES struct LDKTxOut HTLCDescriptor_tx_output(const struct LDKHTLCDescriptor *NONNULL_PTR this_arg); /** - * Calls the free function if one is set + * Returns the witness script of the HTLC output in the commitment transaction. */ -void UtxoLookup_free(struct LDKUtxoLookup this_ptr); +MUST_USE_RES struct LDKCVec_u8Z HTLCDescriptor_witness_script(const struct LDKHTLCDescriptor *NONNULL_PTR this_arg); /** - * Frees any resources used by the UtxoFuture, if is_owned is set and inner is non-NULL. + * Returns the fully signed witness required to spend the HTLC output in the commitment + * transaction. */ -void UtxoFuture_free(struct LDKUtxoFuture this_obj); +MUST_USE_RES struct LDKWitness HTLCDescriptor_tx_input_witness(const struct LDKHTLCDescriptor *NONNULL_PTR this_arg, struct LDKECDSASignature signature, struct LDKu8slice witness_script); /** - * Creates a copy of the UtxoFuture + * Derives the channel signer required to sign the HTLC input. */ -struct LDKUtxoFuture UtxoFuture_clone(const struct LDKUtxoFuture *NONNULL_PTR orig); +MUST_USE_RES struct LDKEcdsaChannelSigner HTLCDescriptor_derive_channel_signer(const struct LDKHTLCDescriptor *NONNULL_PTR this_arg, const struct LDKSignerProvider *NONNULL_PTR signer_provider); /** - * Builds a new future for later resolution. + * Calls the free function if one is set */ -MUST_USE_RES struct LDKUtxoFuture UtxoFuture_new(void); +void ChannelSigner_free(struct LDKChannelSigner this_ptr); /** - * 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 + * Creates a copy of the Recipient */ -void UtxoFuture_resolve_without_forwarding(const struct LDKUtxoFuture *NONNULL_PTR this_arg, const struct LDKNetworkGraph *NONNULL_PTR graph, struct LDKCResult_TxOutUtxoLookupErrorZ result); +enum LDKRecipient Recipient_clone(const enum LDKRecipient *NONNULL_PTR orig); /** - * 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 + * Utility method to constructs a new Node-variant Recipient */ -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); +enum LDKRecipient Recipient_node(void); /** - * Frees any resources used by the NodeId, if is_owned is set and inner is non-NULL. + * Utility method to constructs a new PhantomNode-variant Recipient */ -void NodeId_free(struct LDKNodeId this_obj); +enum LDKRecipient Recipient_phantom_node(void); /** - * Creates a copy of the NodeId + * Calls the free function if one is set */ -struct LDKNodeId NodeId_clone(const struct LDKNodeId *NONNULL_PTR orig); +void EntropySource_free(struct LDKEntropySource this_ptr); /** - * Create a new NodeId from a public key + * Calls the free function if one is set */ -MUST_USE_RES struct LDKNodeId NodeId_from_pubkey(struct LDKPublicKey pubkey); +void NodeSigner_free(struct LDKNodeSigner this_ptr); /** - * Create a new NodeId from a slice of bytes + * Calls the free function if one is set */ -MUST_USE_RES struct LDKCResult_NodeIdDecodeErrorZ NodeId_from_slice(struct LDKu8slice bytes); +void OutputSpender_free(struct LDKOutputSpender this_ptr); /** - * Get the public key slice from this NodeId + * Calls the free function if one is set */ -MUST_USE_RES struct LDKu8slice NodeId_as_slice(const struct LDKNodeId *NONNULL_PTR this_arg); +void SignerProvider_free(struct LDKSignerProvider this_ptr); /** - * Get the public key as an array from this NodeId + * Calls the free function if one is set */ -MUST_USE_RES const uint8_t (*NodeId_as_array(const struct LDKNodeId *NONNULL_PTR this_arg))[33]; +void ChangeDestinationSource_free(struct LDKChangeDestinationSource this_ptr); /** - * Get the public key from this NodeId + * Frees any resources used by the InMemorySigner, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKCResult_PublicKeySecp256k1ErrorZ NodeId_as_pubkey(const struct LDKNodeId *NONNULL_PTR this_arg); +void InMemorySigner_free(struct LDKInMemorySigner this_obj); /** - * Get the string representation of a NodeId object + * 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 LDKStr NodeId_to_str(const struct LDKNodeId *NONNULL_PTR o); +const uint8_t (*InMemorySigner_get_funding_key(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; /** - * Generates a non-cryptographic 64-bit hash of the NodeId. + * 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. */ -uint64_t NodeId_hash(const struct LDKNodeId *NONNULL_PTR o); +void InMemorySigner_set_funding_key(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKSecretKey val); /** - * Serialize the NodeId object into a byte array which can be read by NodeId_read + * Holder secret key for blinded revocation pubkey. */ -struct LDKCVec_u8Z NodeId_write(const struct LDKNodeId *NONNULL_PTR obj); +const uint8_t (*InMemorySigner_get_revocation_base_key(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; /** - * Read a NodeId from a byte array, created by NodeId_write + * Holder secret key for blinded revocation pubkey. */ -struct LDKCResult_NodeIdDecodeErrorZ NodeId_read(struct LDKu8slice ser); +void InMemorySigner_set_revocation_base_key(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKSecretKey val); /** - * Frees any resources used by the NetworkGraph, if is_owned is set and inner is non-NULL. + * Holder secret key used for our balance in counterparty-broadcasted commitment transactions. */ -void NetworkGraph_free(struct LDKNetworkGraph this_obj); +const uint8_t (*InMemorySigner_get_payment_key(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; /** - * Frees any resources used by the ReadOnlyNetworkGraph, if is_owned is set and inner is non-NULL. + * Holder secret key used for our balance in counterparty-broadcasted commitment transactions. */ -void ReadOnlyNetworkGraph_free(struct LDKReadOnlyNetworkGraph this_obj); +void InMemorySigner_set_payment_key(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKSecretKey val); /** - * Frees any resources used by the NetworkUpdate + * Holder secret key used in an HTLC transaction. */ -void NetworkUpdate_free(struct LDKNetworkUpdate this_ptr); +const uint8_t (*InMemorySigner_get_delayed_payment_base_key(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; /** - * Creates a copy of the NetworkUpdate + * Holder secret key used in an HTLC transaction. */ -struct LDKNetworkUpdate NetworkUpdate_clone(const struct LDKNetworkUpdate *NONNULL_PTR orig); +void InMemorySigner_set_delayed_payment_base_key(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKSecretKey val); /** - * Utility method to constructs a new ChannelUpdateMessage-variant NetworkUpdate + * Holder HTLC secret key used in commitment transaction HTLC outputs. */ -struct LDKNetworkUpdate NetworkUpdate_channel_update_message(struct LDKChannelUpdate msg); +const uint8_t (*InMemorySigner_get_htlc_base_key(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; /** - * Utility method to constructs a new ChannelFailure-variant NetworkUpdate + * Holder HTLC secret key used in commitment transaction HTLC outputs. */ -struct LDKNetworkUpdate NetworkUpdate_channel_failure(uint64_t short_channel_id, bool is_permanent); +void InMemorySigner_set_htlc_base_key(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKSecretKey val); /** - * Utility method to constructs a new NodeFailure-variant NetworkUpdate + * Commitment seed. */ -struct LDKNetworkUpdate NetworkUpdate_node_failure(struct LDKPublicKey node_id, bool is_permanent); +const uint8_t (*InMemorySigner_get_commitment_seed(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; /** - * Checks if two NetworkUpdates contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Commitment seed. */ -bool NetworkUpdate_eq(const struct LDKNetworkUpdate *NONNULL_PTR a, const struct LDKNetworkUpdate *NONNULL_PTR b); +void InMemorySigner_set_commitment_seed(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Serialize the NetworkUpdate object into a byte array which can be read by NetworkUpdate_read + * Creates a copy of the InMemorySigner */ -struct LDKCVec_u8Z NetworkUpdate_write(const struct LDKNetworkUpdate *NONNULL_PTR obj); +struct LDKInMemorySigner InMemorySigner_clone(const struct LDKInMemorySigner *NONNULL_PTR orig); /** - * Read a NetworkUpdate from a byte array, created by NetworkUpdate_write + * Creates a new [`InMemorySigner`]. */ -struct LDKCResult_COption_NetworkUpdateZDecodeErrorZ NetworkUpdate_read(struct LDKu8slice ser); +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); /** - * Frees any resources used by the P2PGossipSync, if is_owned is set and inner is non-NULL. + * Returns the counterparty's pubkeys. + * + * Will return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called. + * In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void P2PGossipSync_free(struct LDKP2PGossipSync this_obj); +MUST_USE_RES struct LDKChannelPublicKeys InMemorySigner_counterparty_pubkeys(const struct LDKInMemorySigner *NONNULL_PTR this_arg); /** - * 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. + * 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 return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called. + * In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation. */ -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 LDKCOption_u16Z InMemorySigner_counterparty_selected_contest_delay(const struct LDKInMemorySigner *NONNULL_PTR this_arg); /** - * 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. + * 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 return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called. + * In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation. */ -void P2PGossipSync_add_utxo_lookup(const struct LDKP2PGossipSync *NONNULL_PTR this_arg, struct LDKCOption_UtxoLookupZ utxo_lookup); +MUST_USE_RES struct LDKCOption_u16Z InMemorySigner_holder_selected_contest_delay(const struct LDKInMemorySigner *NONNULL_PTR this_arg); /** - * Handles any network updates originating from [`Event`]s. - * Note that this will skip applying any [`NetworkUpdate::ChannelUpdateMessage`] to avoid - * leaking possibly identifying information of the sender to the public network. + * Returns whether the holder is the initiator. * - * [`Event`]: crate::events::Event + * Will return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called. + * In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation. */ -void NetworkGraph_handle_network_update(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKNetworkUpdate *NONNULL_PTR network_update); +MUST_USE_RES struct LDKCOption_boolZ InMemorySigner_is_outbound(const struct LDKInMemorySigner *NONNULL_PTR this_arg); /** - * Gets the chain hash for this network graph. + * Funding outpoint + * + * Will return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called. + * In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKThirtyTwoBytes NetworkGraph_get_chain_hash(const struct LDKNetworkGraph *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKOutPoint InMemorySigner_funding_outpoint(const struct LDKInMemorySigner *NONNULL_PTR this_arg); /** - * Verifies the signature of a [`NodeAnnouncement`]. + * Returns a [`ChannelTransactionParameters`] for this channel, to be used when verifying or + * building transactions. + * + * Will return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called. + * In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation. * - * Returns an error if it is invalid. + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKCResult_NoneLightningErrorZ verify_node_announcement(const struct LDKNodeAnnouncement *NONNULL_PTR msg); +MUST_USE_RES struct LDKChannelTransactionParameters InMemorySigner_get_channel_parameters(const struct LDKInMemorySigner *NONNULL_PTR this_arg); /** - * Verifies all signatures included in a [`ChannelAnnouncement`]. + * Returns the channel type features of the channel parameters. Should be helpful for + * determining a channel's category, i. e. legacy/anchors/taproot/etc. * - * Returns an error if one of the signatures is invalid. + * Will return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called. + * In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKCResult_NoneLightningErrorZ verify_channel_announcement(const struct LDKChannelAnnouncement *NONNULL_PTR msg); +MUST_USE_RES struct LDKChannelTypeFeatures InMemorySigner_channel_type_features(const struct LDKInMemorySigner *NONNULL_PTR this_arg); /** - * 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 + * 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 */ -struct LDKRoutingMessageHandler P2PGossipSync_as_RoutingMessageHandler(const struct LDKP2PGossipSync *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_WitnessNoneZ 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); /** - * 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 + * 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 */ -struct LDKMessageSendEventsProvider P2PGossipSync_as_MessageSendEventsProvider(const struct LDKP2PGossipSync *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_WitnessNoneZ 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); /** - * Frees any resources used by the ChannelUpdateInfo, if is_owned is set and inner is non-NULL. + * 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 */ -void ChannelUpdateInfo_free(struct LDKChannelUpdateInfo this_obj); +struct LDKEntropySource InMemorySigner_as_EntropySource(const struct LDKInMemorySigner *NONNULL_PTR this_arg); /** - * When the last update to the channel direction was issued. - * Value is opaque, as set in the announcement. + * 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 */ -uint32_t ChannelUpdateInfo_get_last_update(const struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr); +struct LDKChannelSigner InMemorySigner_as_ChannelSigner(const struct LDKInMemorySigner *NONNULL_PTR this_arg); /** - * When the last update to the channel direction was issued. - * Value is opaque, as set in the announcement. + * 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 */ -void ChannelUpdateInfo_set_last_update(struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr, uint32_t val); +struct LDKEcdsaChannelSigner InMemorySigner_as_EcdsaChannelSigner(const struct LDKInMemorySigner *NONNULL_PTR this_arg); /** - * Whether the channel can be currently used for payments (in this one direction). + * Serialize the InMemorySigner object into a byte array which can be read by InMemorySigner_read */ -bool ChannelUpdateInfo_get_enabled(const struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z InMemorySigner_write(const struct LDKInMemorySigner *NONNULL_PTR obj); /** - * Whether the channel can be currently used for payments (in this one direction). + * Read a InMemorySigner from a byte array, created by InMemorySigner_write */ -void ChannelUpdateInfo_set_enabled(struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr, bool val); +struct LDKCResult_InMemorySignerDecodeErrorZ InMemorySigner_read(struct LDKu8slice ser, struct LDKEntropySource arg); /** - * The difference in CLTV values that you must have when routing through this channel. + * Frees any resources used by the KeysManager, if is_owned is set and inner is non-NULL. */ -uint16_t ChannelUpdateInfo_get_cltv_expiry_delta(const struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr); +void KeysManager_free(struct LDKKeysManager this_obj); /** - * The difference in CLTV values that you must have when routing through this channel. + * 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 */ -void ChannelUpdateInfo_set_cltv_expiry_delta(struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr, uint16_t val); +MUST_USE_RES struct LDKKeysManager KeysManager_new(const uint8_t (*seed)[32], uint64_t starting_time_secs, uint32_t starting_time_nanos); /** - * The minimum value, which must be relayed to the next hop via the channel + * Gets the \"node_id\" secret key used to sign gossip announcements, decode onion data, etc. */ -uint64_t ChannelUpdateInfo_get_htlc_minimum_msat(const struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKSecretKey KeysManager_get_node_secret_key(const struct LDKKeysManager *NONNULL_PTR this_arg); /** - * The minimum value, which must be relayed to the next hop via the channel + * Derive an old [`EcdsaChannelSigner`] containing per-channel secrets based on a key derivation parameters. */ -void ChannelUpdateInfo_set_htlc_minimum_msat(struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr, uint64_t val); +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]); /** - * The maximum value which may be relayed to the next hop via the channel. + * Signs the given [`Psbt`] 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`]. */ -uint64_t ChannelUpdateInfo_get_htlc_maximum_msat(const struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCResult_CVec_u8ZNoneZ KeysManager_sign_spendable_outputs_psbt(const struct LDKKeysManager *NONNULL_PTR this_arg, struct LDKCVec_SpendableOutputDescriptorZ descriptors, struct LDKCVec_u8Z psbt); /** - * The maximum value which may be relayed to the next hop via the channel. + * 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 */ -void ChannelUpdateInfo_set_htlc_maximum_msat(struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr, uint64_t val); +struct LDKEntropySource KeysManager_as_EntropySource(const struct LDKKeysManager *NONNULL_PTR this_arg); /** - * Fees charged when the channel is used for routing + * 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 LDKRoutingFees ChannelUpdateInfo_get_fees(const struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr); +struct LDKNodeSigner KeysManager_as_NodeSigner(const struct LDKKeysManager *NONNULL_PTR this_arg); /** - * Fees charged when the channel is used for routing + * Constructs a new OutputSpender which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned OutputSpender must be freed before this_arg is */ -void ChannelUpdateInfo_set_fees(struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr, struct LDKRoutingFees val); +struct LDKOutputSpender KeysManager_as_OutputSpender(const struct LDKKeysManager *NONNULL_PTR this_arg); /** - * 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 + * 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 LDKChannelUpdate ChannelUpdateInfo_get_last_update_message(const struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr); +struct LDKSignerProvider KeysManager_as_SignerProvider(const struct LDKKeysManager *NONNULL_PTR this_arg); /** - * 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 + * Frees any resources used by the PhantomKeysManager, if is_owned is set and inner is non-NULL. */ -void ChannelUpdateInfo_set_last_update_message(struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr, struct LDKChannelUpdate val); +void PhantomKeysManager_free(struct LDKPhantomKeysManager this_obj); /** - * Constructs a new ChannelUpdateInfo given each field - * - * Note that last_update_message_arg (or a relevant inner pointer) may be NULL or all-0s to represent None + * 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 */ -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); +struct LDKEntropySource PhantomKeysManager_as_EntropySource(const struct LDKPhantomKeysManager *NONNULL_PTR this_arg); /** - * Creates a copy of the ChannelUpdateInfo + * 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 LDKChannelUpdateInfo ChannelUpdateInfo_clone(const struct LDKChannelUpdateInfo *NONNULL_PTR orig); +struct LDKNodeSigner PhantomKeysManager_as_NodeSigner(const struct LDKPhantomKeysManager *NONNULL_PTR this_arg); /** - * 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. + * Constructs a new OutputSpender which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned OutputSpender must be freed before this_arg is */ -bool ChannelUpdateInfo_eq(const struct LDKChannelUpdateInfo *NONNULL_PTR a, const struct LDKChannelUpdateInfo *NONNULL_PTR b); +struct LDKOutputSpender PhantomKeysManager_as_OutputSpender(const struct LDKPhantomKeysManager *NONNULL_PTR this_arg); /** - * Get the string representation of a ChannelUpdateInfo object + * 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 LDKStr ChannelUpdateInfo_to_str(const struct LDKChannelUpdateInfo *NONNULL_PTR o); +struct LDKSignerProvider PhantomKeysManager_as_SignerProvider(const struct LDKPhantomKeysManager *NONNULL_PTR this_arg); /** - * Serialize the ChannelUpdateInfo object into a byte array which can be read by ChannelUpdateInfo_read + * 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 */ -struct LDKCVec_u8Z ChannelUpdateInfo_write(const struct LDKChannelUpdateInfo *NONNULL_PTR obj); +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]); /** - * Read a ChannelUpdateInfo from a byte array, created by ChannelUpdateInfo_write + * See [`KeysManager::derive_channel_keys`] for documentation on this method. */ -struct LDKCResult_ChannelUpdateInfoDecodeErrorZ ChannelUpdateInfo_read(struct LDKu8slice ser); +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]); /** - * Frees any resources used by the ChannelInfo, if is_owned is set and inner is non-NULL. + * Gets the \"node_id\" secret key used to sign gossip announcements, decode onion data, etc. */ -void ChannelInfo_free(struct LDKChannelInfo this_obj); +MUST_USE_RES struct LDKSecretKey PhantomKeysManager_get_node_secret_key(const struct LDKPhantomKeysManager *NONNULL_PTR this_arg); /** - * Protocol features of a channel communicated during its announcement + * Gets the \"node_id\" secret key of the phantom node used to sign invoices, decode the + * last-hop onion data, etc. */ -struct LDKChannelFeatures ChannelInfo_get_features(const struct LDKChannelInfo *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKSecretKey PhantomKeysManager_get_phantom_node_secret_key(const struct LDKPhantomKeysManager *NONNULL_PTR this_arg); /** - * Protocol features of a channel communicated during its announcement + * Frees any resources used by the RandomBytes, if is_owned is set and inner is non-NULL. */ -void ChannelInfo_set_features(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKChannelFeatures val); +void RandomBytes_free(struct LDKRandomBytes this_obj); /** - * Source node of the first direction of a channel + * Creates a new instance using the given seed. */ -struct LDKNodeId ChannelInfo_get_node_one(const struct LDKChannelInfo *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKRandomBytes RandomBytes_new(struct LDKThirtyTwoBytes seed); /** - * Source node of the first direction of a channel + * 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 */ -void ChannelInfo_set_node_one(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKNodeId val); +struct LDKEntropySource RandomBytes_as_EntropySource(const struct LDKRandomBytes *NONNULL_PTR this_arg); /** - * 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 + * Creates a copy of a EcdsaChannelSigner */ -struct LDKChannelUpdateInfo ChannelInfo_get_one_to_two(const struct LDKChannelInfo *NONNULL_PTR this_ptr); +struct LDKEcdsaChannelSigner EcdsaChannelSigner_clone(const struct LDKEcdsaChannelSigner *NONNULL_PTR orig); /** - * 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 + * Calls the free function if one is set */ -void ChannelInfo_set_one_to_two(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKChannelUpdateInfo val); +void EcdsaChannelSigner_free(struct LDKEcdsaChannelSigner this_ptr); /** - * Source node of the second direction of a channel + * Calls the free function if one is set */ -struct LDKNodeId ChannelInfo_get_node_two(const struct LDKChannelInfo *NONNULL_PTR this_ptr); +void AsyncPaymentsMessageHandler_free(struct LDKAsyncPaymentsMessageHandler this_ptr); /** - * Source node of the second direction of a channel + * Frees any resources used by the AsyncPaymentsMessage */ -void ChannelInfo_set_node_two(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKNodeId val); +void AsyncPaymentsMessage_free(struct LDKAsyncPaymentsMessage this_ptr); /** - * 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 + * Creates a copy of the AsyncPaymentsMessage */ -struct LDKChannelUpdateInfo ChannelInfo_get_two_to_one(const struct LDKChannelInfo *NONNULL_PTR this_ptr); +struct LDKAsyncPaymentsMessage AsyncPaymentsMessage_clone(const struct LDKAsyncPaymentsMessage *NONNULL_PTR orig); /** - * 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 + * Utility method to constructs a new HeldHtlcAvailable-variant AsyncPaymentsMessage */ -void ChannelInfo_set_two_to_one(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKChannelUpdateInfo val); +struct LDKAsyncPaymentsMessage AsyncPaymentsMessage_held_htlc_available(struct LDKHeldHtlcAvailable a); /** - * The channel capacity as seen on-chain, if chain lookup is available. + * Utility method to constructs a new ReleaseHeldHtlc-variant AsyncPaymentsMessage */ -struct LDKCOption_u64Z ChannelInfo_get_capacity_sats(const struct LDKChannelInfo *NONNULL_PTR this_ptr); +struct LDKAsyncPaymentsMessage AsyncPaymentsMessage_release_held_htlc(struct LDKReleaseHeldHtlc a); /** - * The channel capacity as seen on-chain, if chain lookup is available. + * Frees any resources used by the HeldHtlcAvailable, if is_owned is set and inner is non-NULL. */ -void ChannelInfo_set_capacity_sats(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); +void HeldHtlcAvailable_free(struct LDKHeldHtlcAvailable this_obj); /** - * 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 secret that will be used by the recipient of this message to release the held HTLC. */ -struct LDKChannelAnnouncement ChannelInfo_get_announcement_message(const struct LDKChannelInfo *NONNULL_PTR this_ptr); +const uint8_t (*HeldHtlcAvailable_get_payment_release_secret(const struct LDKHeldHtlcAvailable *NONNULL_PTR this_ptr))[32]; /** - * 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 secret that will be used by the recipient of this message to release the held HTLC. */ -void ChannelInfo_set_announcement_message(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKChannelAnnouncement val); +void HeldHtlcAvailable_set_payment_release_secret(struct LDKHeldHtlcAvailable *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Creates a copy of the ChannelInfo + * Constructs a new HeldHtlcAvailable given each field */ -struct LDKChannelInfo ChannelInfo_clone(const struct LDKChannelInfo *NONNULL_PTR orig); +MUST_USE_RES struct LDKHeldHtlcAvailable HeldHtlcAvailable_new(struct LDKThirtyTwoBytes payment_release_secret_arg); /** - * 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. + * Creates a copy of the HeldHtlcAvailable */ -bool ChannelInfo_eq(const struct LDKChannelInfo *NONNULL_PTR a, const struct LDKChannelInfo *NONNULL_PTR b); +struct LDKHeldHtlcAvailable HeldHtlcAvailable_clone(const struct LDKHeldHtlcAvailable *NONNULL_PTR orig); /** - * 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 + * Frees any resources used by the ReleaseHeldHtlc, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKChannelUpdateInfo ChannelInfo_get_directional_info(const struct LDKChannelInfo *NONNULL_PTR this_arg, uint8_t channel_flags); +void ReleaseHeldHtlc_free(struct LDKReleaseHeldHtlc this_obj); /** - * Get the string representation of a ChannelInfo object + * Used to release the HTLC held upstream if it matches the corresponding + * [`HeldHtlcAvailable::payment_release_secret`]. */ -struct LDKStr ChannelInfo_to_str(const struct LDKChannelInfo *NONNULL_PTR o); +const uint8_t (*ReleaseHeldHtlc_get_payment_release_secret(const struct LDKReleaseHeldHtlc *NONNULL_PTR this_ptr))[32]; /** - * Serialize the ChannelInfo object into a byte array which can be read by ChannelInfo_read + * Used to release the HTLC held upstream if it matches the corresponding + * [`HeldHtlcAvailable::payment_release_secret`]. */ -struct LDKCVec_u8Z ChannelInfo_write(const struct LDKChannelInfo *NONNULL_PTR obj); +void ReleaseHeldHtlc_set_payment_release_secret(struct LDKReleaseHeldHtlc *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Read a ChannelInfo from a byte array, created by ChannelInfo_write + * Constructs a new ReleaseHeldHtlc given each field */ -struct LDKCResult_ChannelInfoDecodeErrorZ ChannelInfo_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKReleaseHeldHtlc ReleaseHeldHtlc_new(struct LDKThirtyTwoBytes payment_release_secret_arg); /** - * Frees any resources used by the DirectedChannelInfo, if is_owned is set and inner is non-NULL. + * Creates a copy of the ReleaseHeldHtlc */ -void DirectedChannelInfo_free(struct LDKDirectedChannelInfo this_obj); +struct LDKReleaseHeldHtlc ReleaseHeldHtlc_clone(const struct LDKReleaseHeldHtlc *NONNULL_PTR orig); /** - * Creates a copy of the DirectedChannelInfo + * Constructs a new OnionMessageContents which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned OnionMessageContents must be freed before this_arg is */ -struct LDKDirectedChannelInfo DirectedChannelInfo_clone(const struct LDKDirectedChannelInfo *NONNULL_PTR orig); +struct LDKOnionMessageContents ReleaseHeldHtlc_as_OnionMessageContents(const struct LDKReleaseHeldHtlc *NONNULL_PTR this_arg); /** - * Returns information for the channel. + * Serialize the HeldHtlcAvailable object into a byte array which can be read by HeldHtlcAvailable_read */ -MUST_USE_RES struct LDKChannelInfo DirectedChannelInfo_channel(const struct LDKDirectedChannelInfo *NONNULL_PTR this_arg); +struct LDKCVec_u8Z HeldHtlcAvailable_write(const struct LDKHeldHtlcAvailable *NONNULL_PTR obj); /** - * 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. + * Read a HeldHtlcAvailable from a byte array, created by HeldHtlcAvailable_write */ -MUST_USE_RES struct LDKEffectiveCapacity DirectedChannelInfo_effective_capacity(const struct LDKDirectedChannelInfo *NONNULL_PTR this_arg); +struct LDKCResult_HeldHtlcAvailableDecodeErrorZ HeldHtlcAvailable_read(struct LDKu8slice ser); /** - * Returns the `node_id` of the source hop. - * - * Refers to the `node_id` forwarding the payment to the next hop. + * Serialize the ReleaseHeldHtlc object into a byte array which can be read by ReleaseHeldHtlc_read */ -MUST_USE_RES struct LDKNodeId DirectedChannelInfo_source(const struct LDKDirectedChannelInfo *NONNULL_PTR this_arg); +struct LDKCVec_u8Z ReleaseHeldHtlc_write(const struct LDKReleaseHeldHtlc *NONNULL_PTR obj); /** - * Returns the `node_id` of the target hop. - * - * Refers to the `node_id` receiving the payment from the previous hop. + * Read a ReleaseHeldHtlc from a byte array, created by ReleaseHeldHtlc_write */ -MUST_USE_RES struct LDKNodeId DirectedChannelInfo_target(const struct LDKDirectedChannelInfo *NONNULL_PTR this_arg); +struct LDKCResult_ReleaseHeldHtlcDecodeErrorZ ReleaseHeldHtlc_read(struct LDKu8slice ser); /** - * Frees any resources used by the EffectiveCapacity + * Returns whether `tlv_type` corresponds to a TLV record for async payment messages. */ -void EffectiveCapacity_free(struct LDKEffectiveCapacity this_ptr); +MUST_USE_RES bool AsyncPaymentsMessage_is_known_type(uint64_t tlv_type); /** - * Creates a copy of the EffectiveCapacity + * Constructs a new OnionMessageContents which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned OnionMessageContents must be freed before this_arg is */ -struct LDKEffectiveCapacity EffectiveCapacity_clone(const struct LDKEffectiveCapacity *NONNULL_PTR orig); +struct LDKOnionMessageContents AsyncPaymentsMessage_as_OnionMessageContents(const struct LDKAsyncPaymentsMessage *NONNULL_PTR this_arg); /** - * Utility method to constructs a new ExactLiquidity-variant EffectiveCapacity + * Serialize the AsyncPaymentsMessage object into a byte array which can be read by AsyncPaymentsMessage_read */ -struct LDKEffectiveCapacity EffectiveCapacity_exact_liquidity(uint64_t liquidity_msat); +struct LDKCVec_u8Z AsyncPaymentsMessage_write(const struct LDKAsyncPaymentsMessage *NONNULL_PTR obj); /** - * Utility method to constructs a new AdvertisedMaxHTLC-variant EffectiveCapacity + * Read a AsyncPaymentsMessage from a byte array, created by AsyncPaymentsMessage_write */ -struct LDKEffectiveCapacity EffectiveCapacity_advertised_max_htlc(uint64_t amount_msat); +struct LDKCResult_AsyncPaymentsMessageDecodeErrorZ AsyncPaymentsMessage_read(struct LDKu8slice ser, uint64_t arg); /** - * Utility method to constructs a new Total-variant EffectiveCapacity + * Frees any resources used by the OnionMessenger, if is_owned is set and inner is non-NULL. */ -struct LDKEffectiveCapacity EffectiveCapacity_total(uint64_t capacity_msat, uint64_t htlc_maximum_msat); +void OnionMessenger_free(struct LDKOnionMessenger this_obj); /** - * Utility method to constructs a new Infinite-variant EffectiveCapacity + * Frees any resources used by the Responder, if is_owned is set and inner is non-NULL. */ -struct LDKEffectiveCapacity EffectiveCapacity_infinite(void); +void Responder_free(struct LDKResponder this_obj); /** - * Utility method to constructs a new HintMaxHTLC-variant EffectiveCapacity + * Creates a copy of the Responder */ -struct LDKEffectiveCapacity EffectiveCapacity_hint_max_htlc(uint64_t amount_msat); +struct LDKResponder Responder_clone(const struct LDKResponder *NONNULL_PTR orig); /** - * Utility method to constructs a new Unknown-variant EffectiveCapacity + * Checks if two Responders 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 LDKEffectiveCapacity EffectiveCapacity_unknown(void); +bool Responder_eq(const struct LDKResponder *NONNULL_PTR a, const struct LDKResponder *NONNULL_PTR b); /** - * Returns the effective capacity denominated in millisatoshi. + * Serialize the Responder object into a byte array which can be read by Responder_read */ -MUST_USE_RES uint64_t EffectiveCapacity_as_msat(const struct LDKEffectiveCapacity *NONNULL_PTR this_arg); +struct LDKCVec_u8Z Responder_write(const struct LDKResponder *NONNULL_PTR obj); /** - * Frees any resources used by the RoutingFees, if is_owned is set and inner is non-NULL. + * Read a Responder from a byte array, created by Responder_write */ -void RoutingFees_free(struct LDKRoutingFees this_obj); +struct LDKCResult_ResponderDecodeErrorZ Responder_read(struct LDKu8slice ser); /** - * Flat routing fee in millisatoshis. + * Creates a [`ResponseInstruction`] for responding without including a reply path. + * + * Use when the recipient doesn't need to send back a reply to us. */ -uint32_t RoutingFees_get_base_msat(const struct LDKRoutingFees *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKResponseInstruction Responder_respond(struct LDKResponder this_arg); /** - * Flat routing fee in millisatoshis. + * Creates a [`ResponseInstruction`] for responding including a reply path. + * + * Use when the recipient needs to send back a reply to us. */ -void RoutingFees_set_base_msat(struct LDKRoutingFees *NONNULL_PTR this_ptr, uint32_t val); +MUST_USE_RES struct LDKResponseInstruction Responder_respond_with_reply_path(struct LDKResponder this_arg, struct LDKMessageContext context); /** - * Liquidity-based routing fee in millionths of a routed amount. - * In other words, 10000 is 1%. + * Frees any resources used by the ResponseInstruction, if is_owned is set and inner is non-NULL. */ -uint32_t RoutingFees_get_proportional_millionths(const struct LDKRoutingFees *NONNULL_PTR this_ptr); +void ResponseInstruction_free(struct LDKResponseInstruction this_obj); /** - * Liquidity-based routing fee in millionths of a routed amount. - * In other words, 10000 is 1%. + * Creates a copy of the ResponseInstruction */ -void RoutingFees_set_proportional_millionths(struct LDKRoutingFees *NONNULL_PTR this_ptr, uint32_t val); +struct LDKResponseInstruction ResponseInstruction_clone(const struct LDKResponseInstruction *NONNULL_PTR orig); /** - * Constructs a new RoutingFees given each field + * Frees any resources used by the MessageSendInstructions */ -MUST_USE_RES struct LDKRoutingFees RoutingFees_new(uint32_t base_msat_arg, uint32_t proportional_millionths_arg); +void MessageSendInstructions_free(struct LDKMessageSendInstructions this_ptr); /** - * 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. + * Creates a copy of the MessageSendInstructions */ -bool RoutingFees_eq(const struct LDKRoutingFees *NONNULL_PTR a, const struct LDKRoutingFees *NONNULL_PTR b); +struct LDKMessageSendInstructions MessageSendInstructions_clone(const struct LDKMessageSendInstructions *NONNULL_PTR orig); /** - * Creates a copy of the RoutingFees + * Utility method to constructs a new WithSpecifiedReplyPath-variant MessageSendInstructions */ -struct LDKRoutingFees RoutingFees_clone(const struct LDKRoutingFees *NONNULL_PTR orig); +struct LDKMessageSendInstructions MessageSendInstructions_with_specified_reply_path(struct LDKDestination destination, struct LDKBlindedMessagePath reply_path); /** - * Generates a non-cryptographic 64-bit hash of the RoutingFees. + * Utility method to constructs a new WithReplyPath-variant MessageSendInstructions */ -uint64_t RoutingFees_hash(const struct LDKRoutingFees *NONNULL_PTR o); +struct LDKMessageSendInstructions MessageSendInstructions_with_reply_path(struct LDKDestination destination, struct LDKMessageContext context); /** - * Serialize the RoutingFees object into a byte array which can be read by RoutingFees_read + * Utility method to constructs a new WithoutReplyPath-variant MessageSendInstructions */ -struct LDKCVec_u8Z RoutingFees_write(const struct LDKRoutingFees *NONNULL_PTR obj); +struct LDKMessageSendInstructions MessageSendInstructions_without_reply_path(struct LDKDestination destination); /** - * Read a RoutingFees from a byte array, created by RoutingFees_write + * Utility method to constructs a new ForReply-variant MessageSendInstructions */ -struct LDKCResult_RoutingFeesDecodeErrorZ RoutingFees_read(struct LDKu8slice ser); +struct LDKMessageSendInstructions MessageSendInstructions_for_reply(struct LDKResponseInstruction instructions); /** - * Frees any resources used by the NodeAnnouncementInfo, if is_owned is set and inner is non-NULL. + * Calls the free function if one is set */ -void NodeAnnouncementInfo_free(struct LDKNodeAnnouncementInfo this_obj); +void MessageRouter_free(struct LDKMessageRouter this_ptr); /** - * Protocol features the node announced support for + * Frees any resources used by the DefaultMessageRouter, if is_owned is set and inner is non-NULL. */ -struct LDKNodeFeatures NodeAnnouncementInfo_get_features(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr); +void DefaultMessageRouter_free(struct LDKDefaultMessageRouter this_obj); /** - * Protocol features the node announced support for + * Creates a [`DefaultMessageRouter`] using the given [`NetworkGraph`]. */ -void NodeAnnouncementInfo_set_features(struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr, struct LDKNodeFeatures val); +MUST_USE_RES struct LDKDefaultMessageRouter DefaultMessageRouter_new(const struct LDKNetworkGraph *NONNULL_PTR network_graph, struct LDKEntropySource entropy_source); /** - * When the last known update to the node state was issued. - * Value is opaque, as set in the announcement. + * 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 */ -uint32_t NodeAnnouncementInfo_get_last_update(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr); +struct LDKMessageRouter DefaultMessageRouter_as_MessageRouter(const struct LDKDefaultMessageRouter *NONNULL_PTR this_arg); /** - * When the last known update to the node state was issued. - * Value is opaque, as set in the announcement. + * Frees any resources used by the OnionMessagePath, if is_owned is set and inner is non-NULL. */ -void NodeAnnouncementInfo_set_last_update(struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr, uint32_t val); +void OnionMessagePath_free(struct LDKOnionMessagePath this_obj); /** - * Color assigned to the node + * Nodes on the path between the sender and the destination. + * + * Returns a copy of the field. */ -const uint8_t (*NodeAnnouncementInfo_get_rgb(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr))[3]; +struct LDKCVec_PublicKeyZ OnionMessagePath_get_intermediate_nodes(const struct LDKOnionMessagePath *NONNULL_PTR this_ptr); /** - * Color assigned to the node + * Nodes on the path between the sender and the destination. */ -void NodeAnnouncementInfo_set_rgb(struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr, struct LDKThreeBytes val); +void OnionMessagePath_set_intermediate_nodes(struct LDKOnionMessagePath *NONNULL_PTR this_ptr, struct LDKCVec_PublicKeyZ val); /** - * Moniker assigned to the node. - * May be invalid or malicious (eg control chars), - * should not be exposed to the user. + * The recipient of the message. */ -struct LDKNodeAlias NodeAnnouncementInfo_get_alias(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr); +struct LDKDestination OnionMessagePath_get_destination(const struct LDKOnionMessagePath *NONNULL_PTR this_ptr); /** - * Moniker assigned to the node. - * May be invalid or malicious (eg control chars), - * should not be exposed to the user. + * The recipient of the message. */ -void NodeAnnouncementInfo_set_alias(struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr, struct LDKNodeAlias val); +void OnionMessagePath_set_destination(struct LDKOnionMessagePath *NONNULL_PTR this_ptr, struct LDKDestination val); /** - * 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. + * Addresses that may be used to connect to [`OnionMessagePath::first_node`]. * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Only needs to be set if a connection to the node is required. [`OnionMessenger`] may use + * this to initiate such a connection. + * + * Returns a copy of the field. */ -struct LDKNodeAnnouncement NodeAnnouncementInfo_get_announcement_message(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr); +struct LDKCOption_CVec_SocketAddressZZ OnionMessagePath_get_first_node_addresses(const struct LDKOnionMessagePath *NONNULL_PTR this_ptr); /** - * 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. + * Addresses that may be used to connect to [`OnionMessagePath::first_node`]. * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * Only needs to be set if a connection to the node is required. [`OnionMessenger`] may use + * this to initiate such a connection. */ -void NodeAnnouncementInfo_set_announcement_message(struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr, struct LDKNodeAnnouncement val); +void OnionMessagePath_set_first_node_addresses(struct LDKOnionMessagePath *NONNULL_PTR this_ptr, struct LDKCOption_CVec_SocketAddressZZ val); /** - * Constructs a new NodeAnnouncementInfo given each field - * - * Note that announcement_message_arg (or a relevant inner pointer) may be NULL or all-0s to represent None + * Constructs a new OnionMessagePath given each field */ -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); +MUST_USE_RES struct LDKOnionMessagePath OnionMessagePath_new(struct LDKCVec_PublicKeyZ intermediate_nodes_arg, struct LDKDestination destination_arg, struct LDKCOption_CVec_SocketAddressZZ first_node_addresses_arg); /** - * Creates a copy of the NodeAnnouncementInfo + * Creates a copy of the OnionMessagePath */ -struct LDKNodeAnnouncementInfo NodeAnnouncementInfo_clone(const struct LDKNodeAnnouncementInfo *NONNULL_PTR orig); +struct LDKOnionMessagePath OnionMessagePath_clone(const struct LDKOnionMessagePath *NONNULL_PTR orig); /** - * 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. + * Returns the first node in the path. + * + * 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); +MUST_USE_RES struct LDKPublicKey OnionMessagePath_first_node(const struct LDKOnionMessagePath *NONNULL_PTR this_arg); /** - * Internet-level addresses via which one can connect to the node + * Frees any resources used by the Destination */ -MUST_USE_RES struct LDKCVec_SocketAddressZ NodeAnnouncementInfo_addresses(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_arg); +void Destination_free(struct LDKDestination this_ptr); /** - * Serialize the NodeAnnouncementInfo object into a byte array which can be read by NodeAnnouncementInfo_read + * Creates a copy of the Destination */ -struct LDKCVec_u8Z NodeAnnouncementInfo_write(const struct LDKNodeAnnouncementInfo *NONNULL_PTR obj); +struct LDKDestination Destination_clone(const struct LDKDestination *NONNULL_PTR orig); /** - * Read a NodeAnnouncementInfo from a byte array, created by NodeAnnouncementInfo_write + * Utility method to constructs a new Node-variant Destination */ -struct LDKCResult_NodeAnnouncementInfoDecodeErrorZ NodeAnnouncementInfo_read(struct LDKu8slice ser); +struct LDKDestination Destination_node(struct LDKPublicKey a); /** - * Frees any resources used by the NodeAlias, if is_owned is set and inner is non-NULL. + * Utility method to constructs a new BlindedPath-variant Destination */ -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); +struct LDKDestination Destination_blinded_path(struct LDKBlindedMessagePath a); /** - * Constructs a new NodeAlias given each field + * Generates a non-cryptographic 64-bit hash of the Destination. */ -MUST_USE_RES struct LDKNodeAlias NodeAlias_new(struct LDKThirtyTwoBytes a_arg); +uint64_t Destination_hash(const struct LDKDestination *NONNULL_PTR o); /** - * Creates a copy of the NodeAlias + * Checks if two Destinations contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -struct LDKNodeAlias NodeAlias_clone(const struct LDKNodeAlias *NONNULL_PTR orig); +bool Destination_eq(const struct LDKDestination *NONNULL_PTR a, const struct LDKDestination *NONNULL_PTR b); /** - * Generates a non-cryptographic 64-bit hash of the NodeAlias. + * Attempts to resolve the [`IntroductionNode::DirectedShortChannelId`] of a + * [`Destination::BlindedPath`] to a [`IntroductionNode::NodeId`], if applicable, using the + * provided [`ReadOnlyNetworkGraph`]. */ -uint64_t NodeAlias_hash(const struct LDKNodeAlias *NONNULL_PTR o); +void Destination_resolve(struct LDKDestination *NONNULL_PTR this_arg, const struct LDKReadOnlyNetworkGraph *NONNULL_PTR network_graph); /** - * 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. + * Frees any resources used by the SendSuccess */ -bool NodeAlias_eq(const struct LDKNodeAlias *NONNULL_PTR a, const struct LDKNodeAlias *NONNULL_PTR b); +void SendSuccess_free(struct LDKSendSuccess this_ptr); /** - * Get the string representation of a NodeAlias object + * Creates a copy of the SendSuccess */ -struct LDKStr NodeAlias_to_str(const struct LDKNodeAlias *NONNULL_PTR o); +struct LDKSendSuccess SendSuccess_clone(const struct LDKSendSuccess *NONNULL_PTR orig); /** - * Serialize the NodeAlias object into a byte array which can be read by NodeAlias_read + * Utility method to constructs a new Buffered-variant SendSuccess */ -struct LDKCVec_u8Z NodeAlias_write(const struct LDKNodeAlias *NONNULL_PTR obj); +struct LDKSendSuccess SendSuccess_buffered(void); /** - * Read a NodeAlias from a byte array, created by NodeAlias_write + * Utility method to constructs a new BufferedAwaitingConnection-variant SendSuccess */ -struct LDKCResult_NodeAliasDecodeErrorZ NodeAlias_read(struct LDKu8slice ser); +struct LDKSendSuccess SendSuccess_buffered_awaiting_connection(struct LDKPublicKey a); /** - * Frees any resources used by the NodeInfo, if is_owned is set and inner is non-NULL. + * Generates a non-cryptographic 64-bit hash of the SendSuccess. */ -void NodeInfo_free(struct LDKNodeInfo this_obj); +uint64_t SendSuccess_hash(const struct LDKSendSuccess *NONNULL_PTR o); /** - * All valid channels a node has announced - * - * Returns a copy of the field. + * Checks if two SendSuccesss contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -struct LDKCVec_u64Z NodeInfo_get_channels(const struct LDKNodeInfo *NONNULL_PTR this_ptr); +bool SendSuccess_eq(const struct LDKSendSuccess *NONNULL_PTR a, const struct LDKSendSuccess *NONNULL_PTR b); /** - * All valid channels a node has announced + * Frees any resources used by the SendError */ -void NodeInfo_set_channels(struct LDKNodeInfo *NONNULL_PTR this_ptr, struct LDKCVec_u64Z val); +void SendError_free(struct LDKSendError 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 the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Creates a copy of the SendError */ -struct LDKNodeAnnouncementInfo NodeInfo_get_announcement_info(const struct LDKNodeInfo *NONNULL_PTR this_ptr); +struct LDKSendError SendError_clone(const struct LDKSendError *NONNULL_PTR orig); /** - * 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 + * Utility method to constructs a new Secp256k1-variant SendError */ -void NodeInfo_set_announcement_info(struct LDKNodeInfo *NONNULL_PTR this_ptr, struct LDKNodeAnnouncementInfo val); +struct LDKSendError SendError_secp256k1(enum LDKSecp256k1Error a); /** - * Constructs a new NodeInfo given each field - * - * Note that announcement_info_arg (or a relevant inner pointer) may be NULL or all-0s to represent None + * Utility method to constructs a new TooBigPacket-variant SendError */ -MUST_USE_RES struct LDKNodeInfo NodeInfo_new(struct LDKCVec_u64Z channels_arg, struct LDKNodeAnnouncementInfo announcement_info_arg); +struct LDKSendError SendError_too_big_packet(void); /** - * Creates a copy of the NodeInfo + * Utility method to constructs a new TooFewBlindedHops-variant SendError */ -struct LDKNodeInfo NodeInfo_clone(const struct LDKNodeInfo *NONNULL_PTR orig); +struct LDKSendError SendError_too_few_blinded_hops(void); /** - * 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. + * Utility method to constructs a new InvalidFirstHop-variant SendError */ -bool NodeInfo_eq(const struct LDKNodeInfo *NONNULL_PTR a, const struct LDKNodeInfo *NONNULL_PTR b); +struct LDKSendError SendError_invalid_first_hop(struct LDKPublicKey a); /** - * Returns whether the node has only announced Tor addresses. + * Utility method to constructs a new PathNotFound-variant SendError */ -MUST_USE_RES bool NodeInfo_is_tor_only(const struct LDKNodeInfo *NONNULL_PTR this_arg); +struct LDKSendError SendError_path_not_found(void); /** - * Get the string representation of a NodeInfo object + * Utility method to constructs a new InvalidMessage-variant SendError */ -struct LDKStr NodeInfo_to_str(const struct LDKNodeInfo *NONNULL_PTR o); +struct LDKSendError SendError_invalid_message(void); /** - * Serialize the NodeInfo object into a byte array which can be read by NodeInfo_read + * Utility method to constructs a new BufferFull-variant SendError */ -struct LDKCVec_u8Z NodeInfo_write(const struct LDKNodeInfo *NONNULL_PTR obj); +struct LDKSendError SendError_buffer_full(void); /** - * Read a NodeInfo from a byte array, created by NodeInfo_write + * Utility method to constructs a new GetNodeIdFailed-variant SendError */ -struct LDKCResult_NodeInfoDecodeErrorZ NodeInfo_read(struct LDKu8slice ser); +struct LDKSendError SendError_get_node_id_failed(void); /** - * Serialize the NetworkGraph object into a byte array which can be read by NetworkGraph_read + * Utility method to constructs a new UnresolvedIntroductionNode-variant SendError */ -struct LDKCVec_u8Z NetworkGraph_write(const struct LDKNetworkGraph *NONNULL_PTR obj); +struct LDKSendError SendError_unresolved_introduction_node(void); /** - * Read a NetworkGraph from a byte array, created by NetworkGraph_write + * Utility method to constructs a new BlindedPathAdvanceFailed-variant SendError */ -struct LDKCResult_NetworkGraphDecodeErrorZ NetworkGraph_read(struct LDKu8slice ser, struct LDKLogger arg); +struct LDKSendError SendError_blinded_path_advance_failed(void); /** - * Get the string representation of a NetworkGraph object + * Generates a non-cryptographic 64-bit hash of the SendError. */ -struct LDKStr NetworkGraph_to_str(const struct LDKNetworkGraph *NONNULL_PTR o); +uint64_t SendError_hash(const struct LDKSendError *NONNULL_PTR o); /** - * Creates a new, empty, network graph. + * Checks if two SendErrors contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -MUST_USE_RES struct LDKNetworkGraph NetworkGraph_new(enum LDKNetwork network, struct LDKLogger logger); +bool SendError_eq(const struct LDKSendError *NONNULL_PTR a, const struct LDKSendError *NONNULL_PTR b); /** - * Returns a read-only view of the network graph. + * Calls the free function if one is set */ -MUST_USE_RES struct LDKReadOnlyNetworkGraph NetworkGraph_read_only(const struct LDKNetworkGraph *NONNULL_PTR this_arg); +void CustomOnionMessageHandler_free(struct LDKCustomOnionMessageHandler 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. + * Frees any resources used by the PeeledOnion */ -MUST_USE_RES struct LDKCOption_u32Z NetworkGraph_get_last_rapid_gossip_sync_timestamp(const struct LDKNetworkGraph *NONNULL_PTR this_arg); +void PeeledOnion_free(struct LDKPeeledOnion this_ptr); /** - * 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. + * Creates a copy of the PeeledOnion */ -void NetworkGraph_set_last_rapid_gossip_sync_timestamp(const struct LDKNetworkGraph *NONNULL_PTR this_arg, uint32_t last_rapid_gossip_sync_timestamp); +struct LDKPeeledOnion PeeledOnion_clone(const struct LDKPeeledOnion *NONNULL_PTR orig); /** - * 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. + * Utility method to constructs a new Forward-variant PeeledOnion */ -MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_node_from_announcement(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKNodeAnnouncement *NONNULL_PTR msg); +struct LDKPeeledOnion PeeledOnion_forward(struct LDKNextMessageHop a, struct LDKOnionMessage b); /** - * 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. + * Utility method to constructs a new Receive-variant PeeledOnion */ -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); +struct LDKPeeledOnion PeeledOnion_receive(struct LDKParsedOnionMessageContents a, struct LDKCOption_MessageContextZ b, struct LDKBlindedMessagePath c); /** - * Store or update channel info from a channel announcement. + * Creates an [`OnionMessage`] with the given `contents` for sending to the destination of + * `path`, first calling [`Destination::resolve`] on `path.destination` with the given + * [`ReadOnlyNetworkGraph`]. * - * 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. + * Returns the node id of the peer to send the message to, the message itself, and any addresses + * needed to connect to the first node. * - * 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 reply_path (or a relevant inner pointer) may be NULL or all-0s to represent None */ -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); +struct LDKCResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ create_onion_message_resolving_destination(const struct LDKEntropySource *NONNULL_PTR entropy_source, const struct LDKNodeSigner *NONNULL_PTR node_signer, const struct LDKNodeIdLookUp *NONNULL_PTR node_id_lookup, const struct LDKReadOnlyNetworkGraph *NONNULL_PTR network_graph, struct LDKOnionMessagePath path, struct LDKOnionMessageContents contents, struct LDKBlindedMessagePath reply_path); /** - * Store or update channel info from a channel announcement. + * Creates an [`OnionMessage`] with the given `contents` for sending to the destination of + * `path`. * - * 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. + * Returns the node id of the peer to send the message to, the message itself, and any addresses + * needed to connect to the first node. * - * This will skip verification of if the channel is actually on-chain. + * Returns [`SendError::UnresolvedIntroductionNode`] if: + * - `destination` contains a blinded path with an [`IntroductionNode::DirectedShortChannelId`], + * - unless it can be resolved by [`NodeIdLookUp::next_node_id`]. + * Use [`create_onion_message_resolving_destination`] instead to resolve the introduction node + * first with a [`ReadOnlyNetworkGraph`]. + * + * Note that reply_path (or a relevant inner pointer) may be NULL or all-0s to represent None */ -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); +struct LDKCResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ create_onion_message(const struct LDKEntropySource *NONNULL_PTR entropy_source, const struct LDKNodeSigner *NONNULL_PTR node_signer, const struct LDKNodeIdLookUp *NONNULL_PTR node_id_lookup, struct LDKOnionMessagePath path, struct LDKOnionMessageContents contents, struct LDKBlindedMessagePath reply_path); /** - * 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. + * Decode one layer of an incoming [`OnionMessage`]. * - * 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. + * Returns either the next layer of the onion for forwarding or the decrypted content for the + * receiver. */ -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); +struct LDKCResult_PeeledOnionNoneZ peel_onion_message(const struct LDKOnionMessage *NONNULL_PTR msg, struct LDKNodeSigner node_signer, struct LDKLogger logger, struct LDKCustomOnionMessageHandler custom_handler); /** - * 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. + * Constructs a new `OnionMessenger` to send, forward, and delegate received onion messages to + * their respective handlers. */ -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); +MUST_USE_RES struct LDKOnionMessenger OnionMessenger_new(struct LDKEntropySource entropy_source, struct LDKNodeSigner node_signer, struct LDKLogger logger, struct LDKNodeIdLookUp node_id_lookup, struct LDKMessageRouter message_router, struct LDKOffersMessageHandler offers_handler, struct LDKAsyncPaymentsMessageHandler async_payments_handler, struct LDKCustomOnionMessageHandler custom_handler); /** - * Marks a channel in the graph as failed permanently. + * Similar to [`Self::new`], but rather than dropping onion messages that are + * intended to be forwarded to offline peers, we will intercept them for + * later forwarding. * - * The channel and any node for which this was their last channel are removed from the graph. + * Interception flow: + * 1. If an onion message for an offline peer is received, `OnionMessenger` will + * generate an [`Event::OnionMessageIntercepted`]. Event handlers can + * then choose to persist this onion message for later forwarding, or drop + * it. + * 2. When the offline peer later comes back online, `OnionMessenger` will + * generate an [`Event::OnionMessagePeerConnected`]. Event handlers will + * then fetch all previously intercepted onion messages for this peer. + * 3. Once the stored onion messages are fetched, they can finally be + * forwarded to the now-online peer via [`Self::forward_onion_message`]. + * + * # Note + * + * LDK will not rate limit how many [`Event::OnionMessageIntercepted`]s + * are generated, so it is the caller's responsibility to limit how many + * onion messages are persisted and only persist onion messages for relevant + * peers. */ -void NetworkGraph_channel_failed_permanent(const struct LDKNetworkGraph *NONNULL_PTR this_arg, uint64_t short_channel_id); +MUST_USE_RES struct LDKOnionMessenger OnionMessenger_new_with_offline_peer_interception(struct LDKEntropySource entropy_source, struct LDKNodeSigner node_signer, struct LDKLogger logger, struct LDKNodeIdLookUp node_id_lookup, struct LDKMessageRouter message_router, struct LDKOffersMessageHandler offers_handler, struct LDKAsyncPaymentsMessageHandler async_payments_handler, struct LDKCustomOnionMessageHandler custom_handler); /** - * Marks a node in the graph as permanently failed, effectively removing it and its channels - * from local storage. + * Sends an [`OnionMessage`] based on its [`MessageSendInstructions`]. */ -void NetworkGraph_node_failed_permanent(const struct LDKNetworkGraph *NONNULL_PTR this_arg, struct LDKPublicKey node_id); +MUST_USE_RES struct LDKCResult_SendSuccessSendErrorZ OnionMessenger_send_onion_message(const struct LDKOnionMessenger *NONNULL_PTR this_arg, struct LDKOnionMessageContents contents, struct LDKMessageSendInstructions instructions); /** - * 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. + * Forwards an [`OnionMessage`] to `peer_node_id`. Useful if we initialized + * the [`OnionMessenger`] with [`Self::new_with_offline_peer_interception`] + * and want to forward a previously intercepted onion message to a peer that + * has just come online. */ -void NetworkGraph_remove_stale_channels_and_tracking(const struct LDKNetworkGraph *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_NoneSendErrorZ OnionMessenger_forward_onion_message(const struct LDKOnionMessenger *NONNULL_PTR this_arg, struct LDKOnionMessage message, struct LDKPublicKey peer_node_id); /** - * 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. + * Handles the response to an [`OnionMessage`] based on its [`ResponseInstruction`], + * enqueueing any response for sending. * - * 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. + * This function is useful for asynchronous handling of [`OnionMessage`]s. + * Handlers have the option to return `None`, indicating that no immediate response should be + * sent. Then, they can transfer the associated [`Responder`] to another task responsible for + * generating the response asynchronously. Subsequently, when the response is prepared and + * ready for sending, that task can invoke this method to enqueue the response for delivery. */ -void NetworkGraph_remove_stale_channels_and_tracking_with_time(const struct LDKNetworkGraph *NONNULL_PTR this_arg, uint64_t current_time_unix); +MUST_USE_RES struct LDKCResult_SendSuccessSendErrorZ OnionMessenger_handle_onion_message_response(const struct LDKOnionMessenger *NONNULL_PTR this_arg, struct LDKOnionMessageContents response, struct LDKResponseInstruction instructions); /** - * For an already known (from announcement) channel, update info about one of the directions - * of the channel. + * Gets a [`Future`] that completes when an event is available via + * [`EventsProvider::process_pending_events`] or [`Self::process_pending_events_async`]. * - * 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. + * Note that callbacks registered on the [`Future`] MUST NOT call back into this + * [`OnionMessenger`] and should instead register actions to be taken later. * - * 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. + * [`EventsProvider::process_pending_events`]: crate::events::EventsProvider::process_pending_events */ -MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKChannelUpdate *NONNULL_PTR msg); +MUST_USE_RES struct LDKFuture OnionMessenger_get_update_future(const struct LDKOnionMessenger *NONNULL_PTR this_arg); /** - * 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. + * 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 */ -MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_unsigned(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKUnsignedChannelUpdate *NONNULL_PTR msg); +struct LDKEventsProvider OnionMessenger_as_EventsProvider(const struct LDKOnionMessenger *NONNULL_PTR this_arg); /** - * For an already known (from announcement) channel, verify the given [`ChannelUpdate`]. - * - * This checks whether the update currently is applicable by [`Self::update_channel`]. - * - * 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. + * 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 */ -MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_verify_channel_update(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKChannelUpdate *NONNULL_PTR msg); +struct LDKOnionMessageHandler OnionMessenger_as_OnionMessageHandler(const struct LDKOnionMessenger *NONNULL_PTR this_arg); /** - * 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 + * Calls the free function if one is set */ -MUST_USE_RES struct LDKChannelInfo ReadOnlyNetworkGraph_channel(const struct LDKReadOnlyNetworkGraph *NONNULL_PTR this_arg, uint64_t short_channel_id); +void OffersMessageHandler_free(struct LDKOffersMessageHandler this_ptr); /** - * Returns the list of channels in the graph + * Frees any resources used by the OffersMessage */ -MUST_USE_RES struct LDKCVec_u64Z ReadOnlyNetworkGraph_list_channels(const struct LDKReadOnlyNetworkGraph *NONNULL_PTR this_arg); +void OffersMessage_free(struct LDKOffersMessage this_ptr); /** - * 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 + * Creates a copy of the OffersMessage */ -MUST_USE_RES struct LDKNodeInfo ReadOnlyNetworkGraph_node(const struct LDKReadOnlyNetworkGraph *NONNULL_PTR this_arg, const struct LDKNodeId *NONNULL_PTR node_id); +struct LDKOffersMessage OffersMessage_clone(const struct LDKOffersMessage *NONNULL_PTR orig); /** - * Returns the list of nodes in the graph + * Utility method to constructs a new InvoiceRequest-variant OffersMessage */ -MUST_USE_RES struct LDKCVec_NodeIdZ ReadOnlyNetworkGraph_list_nodes(const struct LDKReadOnlyNetworkGraph *NONNULL_PTR this_arg); +struct LDKOffersMessage OffersMessage_invoice_request(struct LDKInvoiceRequest a); /** - * 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. + * Utility method to constructs a new Invoice-variant OffersMessage */ -MUST_USE_RES struct LDKCOption_CVec_SocketAddressZZ ReadOnlyNetworkGraph_get_addresses(const struct LDKReadOnlyNetworkGraph *NONNULL_PTR this_arg, struct LDKPublicKey pubkey); +struct LDKOffersMessage OffersMessage_invoice(struct LDKBolt12Invoice a); /** - * Frees any resources used by the DefaultRouter, if is_owned is set and inner is non-NULL. + * Utility method to constructs a new InvoiceError-variant OffersMessage */ -void DefaultRouter_free(struct LDKDefaultRouter this_obj); +struct LDKOffersMessage OffersMessage_invoice_error(struct LDKInvoiceError a); /** - * Creates a new router. + * Returns whether `tlv_type` corresponds to a TLV record for Offers. */ -MUST_USE_RES struct LDKDefaultRouter DefaultRouter_new(const struct LDKNetworkGraph *NONNULL_PTR network_graph, struct LDKLogger logger, struct LDKEntropySource entropy_source, struct LDKLockableScore scorer, struct LDKProbabilisticScoringFeeParameters score_params); +MUST_USE_RES bool OffersMessage_is_known_type(uint64_t tlv_type); /** - * 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 + * Constructs a new OnionMessageContents which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned OnionMessageContents must be freed before this_arg is */ -struct LDKRouter DefaultRouter_as_Router(const struct LDKDefaultRouter *NONNULL_PTR this_arg); +struct LDKOnionMessageContents OffersMessage_as_OnionMessageContents(const struct LDKOffersMessage *NONNULL_PTR this_arg); /** - * 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 + * Serialize the OffersMessage object into a byte array which can be read by OffersMessage_read */ -struct LDKMessageRouter DefaultRouter_as_MessageRouter(const struct LDKDefaultRouter *NONNULL_PTR this_arg); +struct LDKCVec_u8Z OffersMessage_write(const struct LDKOffersMessage *NONNULL_PTR obj); /** - * Calls the free function if one is set + * Read a OffersMessage from a byte array, created by OffersMessage_write */ -void Router_free(struct LDKRouter this_ptr); +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 ScorerAccountingForInFlightHtlcs, if is_owned is set and inner is non-NULL. + * Frees any resources used by the Packet, if is_owned is set and inner is non-NULL. */ -void ScorerAccountingForInFlightHtlcs_free(struct LDKScorerAccountingForInFlightHtlcs this_obj); +void Packet_free(struct LDKPacket this_obj); /** - * Initialize a new `ScorerAccountingForInFlightHtlcs`. + * Bolt 04 version number */ -MUST_USE_RES struct LDKScorerAccountingForInFlightHtlcs ScorerAccountingForInFlightHtlcs_new(struct LDKScoreLookUp scorer, const struct LDKInFlightHtlcs *NONNULL_PTR inflight_htlcs); +uint8_t Packet_get_version(const struct LDKPacket *NONNULL_PTR this_ptr); /** - * Constructs a new ScoreLookUp which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned ScoreLookUp must be freed before this_arg is + * Bolt 04 version number */ -struct LDKScoreLookUp ScorerAccountingForInFlightHtlcs_as_ScoreLookUp(const struct LDKScorerAccountingForInFlightHtlcs *NONNULL_PTR this_arg); +void Packet_set_version(struct LDKPacket *NONNULL_PTR this_ptr, uint8_t val); /** - * Frees any resources used by the InFlightHtlcs, if is_owned is set and inner is non-NULL. + * A random sepc256k1 point, used to build the ECDH shared secret to decrypt hop_data */ -void InFlightHtlcs_free(struct LDKInFlightHtlcs this_obj); +struct LDKPublicKey Packet_get_public_key(const struct LDKPacket *NONNULL_PTR this_ptr); /** - * Creates a copy of the InFlightHtlcs + * A random sepc256k1 point, used to build the ECDH shared secret to decrypt hop_data */ -struct LDKInFlightHtlcs InFlightHtlcs_clone(const struct LDKInFlightHtlcs *NONNULL_PTR orig); +void Packet_set_public_key(struct LDKPacket *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Constructs an empty `InFlightHtlcs`. + * Encrypted payload for the next hop + * + * Returns a copy of the field. */ -MUST_USE_RES struct LDKInFlightHtlcs InFlightHtlcs_new(void); +struct LDKCVec_u8Z Packet_get_hop_data(const struct LDKPacket *NONNULL_PTR this_ptr); /** - * Takes in a path with payer's node id and adds the path's details to `InFlightHtlcs`. + * Encrypted payload for the next hop */ -void InFlightHtlcs_process_path(struct LDKInFlightHtlcs *NONNULL_PTR this_arg, const struct LDKPath *NONNULL_PTR path, struct LDKPublicKey payer_node_id); +void Packet_set_hop_data(struct LDKPacket *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); /** - * Adds a known HTLC given the public key of the HTLC source, target, and short channel - * id. + * HMAC to verify the integrity of hop_data */ -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); +const uint8_t (*Packet_get_hmac(const struct LDKPacket *NONNULL_PTR this_ptr))[32]; /** - * Returns liquidity in msat given the public key of the HTLC source, target, and short channel - * id. + * HMAC to verify the integrity of hop_data */ -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); +void Packet_set_hmac(struct LDKPacket *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Serialize the InFlightHtlcs object into a byte array which can be read by InFlightHtlcs_read + * Constructs a new Packet given each field */ -struct LDKCVec_u8Z InFlightHtlcs_write(const struct LDKInFlightHtlcs *NONNULL_PTR obj); +MUST_USE_RES struct LDKPacket Packet_new(uint8_t version_arg, struct LDKPublicKey public_key_arg, struct LDKCVec_u8Z hop_data_arg, struct LDKThirtyTwoBytes hmac_arg); /** - * Read a InFlightHtlcs from a byte array, created by InFlightHtlcs_write + * Creates a copy of the Packet */ -struct LDKCResult_InFlightHtlcsDecodeErrorZ InFlightHtlcs_read(struct LDKu8slice ser); +struct LDKPacket Packet_clone(const struct LDKPacket *NONNULL_PTR orig); /** - * Frees any resources used by the RouteHop, if is_owned is set and inner is non-NULL. + * Generates a non-cryptographic 64-bit hash of the Packet. */ -void RouteHop_free(struct LDKRouteHop this_obj); +uint64_t Packet_hash(const struct LDKPacket *NONNULL_PTR o); /** - * The node_id of the node at this hop. + * Checks if two Packets 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 RouteHop_get_pubkey(const struct LDKRouteHop *NONNULL_PTR this_ptr); +bool Packet_eq(const struct LDKPacket *NONNULL_PTR a, const struct LDKPacket *NONNULL_PTR b); /** - * The node_id of the node at this hop. + * Serialize the Packet object into a byte array which can be read by Packet_read */ -void RouteHop_set_pubkey(struct LDKRouteHop *NONNULL_PTR this_ptr, struct LDKPublicKey val); +struct LDKCVec_u8Z Packet_write(const struct LDKPacket *NONNULL_PTR obj); /** - * 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. + * Frees any resources used by the ParsedOnionMessageContents */ -struct LDKNodeFeatures RouteHop_get_node_features(const struct LDKRouteHop *NONNULL_PTR this_ptr); +void ParsedOnionMessageContents_free(struct LDKParsedOnionMessageContents 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. + * Creates a copy of the ParsedOnionMessageContents */ -void RouteHop_set_node_features(struct LDKRouteHop *NONNULL_PTR this_ptr, struct LDKNodeFeatures val); +struct LDKParsedOnionMessageContents ParsedOnionMessageContents_clone(const struct LDKParsedOnionMessageContents *NONNULL_PTR orig); /** - * The channel that should be used from the previous hop to reach this node. + * Utility method to constructs a new Offers-variant ParsedOnionMessageContents */ -uint64_t RouteHop_get_short_channel_id(const struct LDKRouteHop *NONNULL_PTR this_ptr); +struct LDKParsedOnionMessageContents ParsedOnionMessageContents_offers(struct LDKOffersMessage a); /** - * The channel that should be used from the previous hop to reach this node. + * Utility method to constructs a new Custom-variant ParsedOnionMessageContents */ -void RouteHop_set_short_channel_id(struct LDKRouteHop *NONNULL_PTR this_ptr, uint64_t val); +struct LDKParsedOnionMessageContents ParsedOnionMessageContents_custom(struct LDKOnionMessageContents a); /** - * The channel_announcement features of the channel that should be used from the previous hop - * to reach this node. + * Constructs a new OnionMessageContents which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned OnionMessageContents must be freed before this_arg is */ -struct LDKChannelFeatures RouteHop_get_channel_features(const struct LDKRouteHop *NONNULL_PTR this_ptr); +struct LDKOnionMessageContents ParsedOnionMessageContents_as_OnionMessageContents(const struct LDKParsedOnionMessageContents *NONNULL_PTR this_arg); /** - * The channel_announcement features of the channel that should be used from the previous hop - * to reach this node. + * Serialize the ParsedOnionMessageContents object into a byte array which can be read by ParsedOnionMessageContents_read */ -void RouteHop_set_channel_features(struct LDKRouteHop *NONNULL_PTR this_ptr, struct LDKChannelFeatures val); +struct LDKCVec_u8Z ParsedOnionMessageContents_write(const struct LDKParsedOnionMessageContents *NONNULL_PTR obj); /** - * 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 + * Creates a copy of a OnionMessageContents */ -uint64_t RouteHop_get_fee_msat(const struct LDKRouteHop *NONNULL_PTR this_ptr); +struct LDKOnionMessageContents OnionMessageContents_clone(const struct LDKOnionMessageContents *NONNULL_PTR orig); /** - * 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 + * Calls the free function if one is set */ -void RouteHop_set_fee_msat(struct LDKRouteHop *NONNULL_PTR this_ptr, uint64_t val); +void OnionMessageContents_free(struct LDKOnionMessageContents this_ptr); /** - * 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 + * Frees any resources used by the IntroductionNode */ -uint32_t RouteHop_get_cltv_expiry_delta(const struct LDKRouteHop *NONNULL_PTR this_ptr); +void IntroductionNode_free(struct LDKIntroductionNode this_ptr); /** - * 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 IntroductionNode */ -void RouteHop_set_cltv_expiry_delta(struct LDKRouteHop *NONNULL_PTR this_ptr, uint32_t val); +struct LDKIntroductionNode IntroductionNode_clone(const struct LDKIntroductionNode *NONNULL_PTR orig); /** - * Indicates whether this hop is possibly announced in the public network graph. - * - * Will be `true` if there is a possibility that the channel is publicly known, i.e., if we - * either know for sure it's announced in the public graph, or if any public channels exist - * for which the given `short_channel_id` could be an alias for. Will be `false` if we believe - * the channel to be unannounced. - * - * Will be `true` for objects serialized with LDK version 0.0.116 and before. + * Utility method to constructs a new NodeId-variant IntroductionNode */ -bool RouteHop_get_maybe_announced_channel(const struct LDKRouteHop *NONNULL_PTR this_ptr); +struct LDKIntroductionNode IntroductionNode_node_id(struct LDKPublicKey a); /** - * Indicates whether this hop is possibly announced in the public network graph. - * - * Will be `true` if there is a possibility that the channel is publicly known, i.e., if we - * either know for sure it's announced in the public graph, or if any public channels exist - * for which the given `short_channel_id` could be an alias for. Will be `false` if we believe - * the channel to be unannounced. - * - * Will be `true` for objects serialized with LDK version 0.0.116 and before. + * Utility method to constructs a new DirectedShortChannelId-variant IntroductionNode */ -void RouteHop_set_maybe_announced_channel(struct LDKRouteHop *NONNULL_PTR this_ptr, bool val); +struct LDKIntroductionNode IntroductionNode_directed_short_channel_id(enum LDKDirection a, uint64_t b); /** - * Constructs a new RouteHop given each field + * Generates a non-cryptographic 64-bit hash of the IntroductionNode. */ -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, bool maybe_announced_channel_arg); +uint64_t IntroductionNode_hash(const struct LDKIntroductionNode *NONNULL_PTR o); /** - * Creates a copy of the RouteHop + * Checks if two IntroductionNodes contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -struct LDKRouteHop RouteHop_clone(const struct LDKRouteHop *NONNULL_PTR orig); +bool IntroductionNode_eq(const struct LDKIntroductionNode *NONNULL_PTR a, const struct LDKIntroductionNode *NONNULL_PTR b); /** - * Generates a non-cryptographic 64-bit hash of the RouteHop. + * Creates a copy of the Direction */ -uint64_t RouteHop_hash(const struct LDKRouteHop *NONNULL_PTR o); +enum LDKDirection Direction_clone(const enum LDKDirection *NONNULL_PTR orig); /** - * 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. + * Utility method to constructs a new NodeOne-variant Direction */ -bool RouteHop_eq(const struct LDKRouteHop *NONNULL_PTR a, const struct LDKRouteHop *NONNULL_PTR b); +enum LDKDirection Direction_node_one(void); /** - * Serialize the RouteHop object into a byte array which can be read by RouteHop_read + * Utility method to constructs a new NodeTwo-variant Direction */ -struct LDKCVec_u8Z RouteHop_write(const struct LDKRouteHop *NONNULL_PTR obj); +enum LDKDirection Direction_node_two(void); /** - * Read a RouteHop from a byte array, created by RouteHop_write + * Generates a non-cryptographic 64-bit hash of the Direction. */ -struct LDKCResult_RouteHopDecodeErrorZ RouteHop_read(struct LDKu8slice ser); +uint64_t Direction_hash(const enum LDKDirection *NONNULL_PTR o); /** - * Frees any resources used by the BlindedTail, if is_owned is set and inner is non-NULL. + * Checks if two Directions contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -void BlindedTail_free(struct LDKBlindedTail this_obj); +bool Direction_eq(const enum LDKDirection *NONNULL_PTR a, const enum LDKDirection *NONNULL_PTR b); /** - * 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 NodeIdLookUp_free(struct LDKNodeIdLookUp this_ptr); /** - * The hops of the [`BlindedPath`] provided by the recipient. - * - * [`BlindedPath`]: crate::blinded_path::BlindedPath + * Frees any resources used by the EmptyNodeIdLookUp, if is_owned is set and inner is non-NULL. */ -void BlindedTail_set_hops(struct LDKBlindedTail *NONNULL_PTR this_ptr, struct LDKCVec_BlindedHopZ val); +void EmptyNodeIdLookUp_free(struct LDKEmptyNodeIdLookUp this_obj); /** - * The blinding point of the [`BlindedPath`] provided by the recipient. - * - * [`BlindedPath`]: crate::blinded_path::BlindedPath + * Constructs a new EmptyNodeIdLookUp given each field */ -struct LDKPublicKey BlindedTail_get_blinding_point(const struct LDKBlindedTail *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKEmptyNodeIdLookUp EmptyNodeIdLookUp_new(void); /** - * The blinding point of the [`BlindedPath`] provided by the recipient. - * - * [`BlindedPath`]: crate::blinded_path::BlindedPath + * Constructs a new NodeIdLookUp which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned NodeIdLookUp must be freed before this_arg is */ -void BlindedTail_set_blinding_point(struct LDKBlindedTail *NONNULL_PTR this_ptr, struct LDKPublicKey val); +struct LDKNodeIdLookUp EmptyNodeIdLookUp_as_NodeIdLookUp(const struct LDKEmptyNodeIdLookUp *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. + * Frees any resources used by the BlindedHop, if is_owned is set and inner is non-NULL. */ -uint32_t BlindedTail_get_excess_final_cltv_expiry_delta(const struct LDKBlindedTail *NONNULL_PTR this_ptr); +void BlindedHop_free(struct LDKBlindedHop this_obj); /** - * Excess CLTV delta added to the recipient's CLTV expiry to deter intermediate nodes from - * inferring the destination. May be 0. + * The blinded node id of this hop in a blinded path. */ -void BlindedTail_set_excess_final_cltv_expiry_delta(struct LDKBlindedTail *NONNULL_PTR this_ptr, uint32_t val); +struct LDKPublicKey BlindedHop_get_blinded_node_id(const struct LDKBlindedHop *NONNULL_PTR this_ptr); /** - * The total amount paid on this [`Path`], excluding the fees. + * The blinded node id of this hop in a blinded path. */ -uint64_t BlindedTail_get_final_value_msat(const struct LDKBlindedTail *NONNULL_PTR this_ptr); +void BlindedHop_set_blinded_node_id(struct LDKBlindedHop *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * The total amount paid on this [`Path`], excluding the fees. + * The encrypted payload intended for this hop in a blinded path. + * + * Returns a copy of the field. */ -void BlindedTail_set_final_value_msat(struct LDKBlindedTail *NONNULL_PTR this_ptr, uint64_t val); +struct LDKCVec_u8Z BlindedHop_get_encrypted_payload(const struct LDKBlindedHop *NONNULL_PTR this_ptr); /** - * Constructs a new BlindedTail given each field + * The encrypted payload intended for this hop in a blinded path. */ -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); +void BlindedHop_set_encrypted_payload(struct LDKBlindedHop *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); /** - * Creates a copy of the BlindedTail + * Constructs a new BlindedHop given each field */ -struct LDKBlindedTail BlindedTail_clone(const struct LDKBlindedTail *NONNULL_PTR orig); +MUST_USE_RES struct LDKBlindedHop BlindedHop_new(struct LDKPublicKey blinded_node_id_arg, struct LDKCVec_u8Z encrypted_payload_arg); /** - * Generates a non-cryptographic 64-bit hash of the BlindedTail. + * Creates a copy of the BlindedHop */ -uint64_t BlindedTail_hash(const struct LDKBlindedTail *NONNULL_PTR o); +struct LDKBlindedHop BlindedHop_clone(const struct LDKBlindedHop *NONNULL_PTR orig); /** - * 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. + * Generates a non-cryptographic 64-bit hash of the BlindedHop. */ -bool BlindedTail_eq(const struct LDKBlindedTail *NONNULL_PTR a, const struct LDKBlindedTail *NONNULL_PTR b); +uint64_t BlindedHop_hash(const struct LDKBlindedHop *NONNULL_PTR o); /** - * Serialize the BlindedTail object into a byte array which can be read by BlindedTail_read + * Checks if two BlindedHops 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 BlindedTail_write(const struct LDKBlindedTail *NONNULL_PTR obj); +bool BlindedHop_eq(const struct LDKBlindedHop *NONNULL_PTR a, const struct LDKBlindedHop *NONNULL_PTR b); /** - * Read a BlindedTail from a byte array, created by BlindedTail_write + * Serialize the BlindedHop object into a byte array which can be read by BlindedHop_read */ -struct LDKCResult_BlindedTailDecodeErrorZ BlindedTail_read(struct LDKu8slice ser); +struct LDKCVec_u8Z BlindedHop_write(const struct LDKBlindedHop *NONNULL_PTR obj); /** - * Frees any resources used by the Path, if is_owned is set and inner is non-NULL. + * Read a BlindedHop from a byte array, created by BlindedHop_write */ -void Path_free(struct LDKPath this_obj); +struct LDKCResult_BlindedHopDecodeErrorZ BlindedHop_read(struct LDKu8slice ser); /** - * The list of unblinded hops in this [`Path`]. Must be at least length one. + * Frees any resources used by the BlindedPayInfo, if is_owned is set and inner is non-NULL. */ -struct LDKCVec_RouteHopZ Path_get_hops(const struct LDKPath *NONNULL_PTR this_ptr); +void BlindedPayInfo_free(struct LDKBlindedPayInfo this_obj); /** - * The list of unblinded hops in this [`Path`]. Must be at least length one. + * Base fee charged (in millisatoshi) for the entire blinded path. */ -void Path_set_hops(struct LDKPath *NONNULL_PTR this_ptr, struct LDKCVec_RouteHopZ val); +uint32_t BlindedPayInfo_get_fee_base_msat(const struct LDKBlindedPayInfo *NONNULL_PTR this_ptr); /** - * 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 + * Base fee charged (in millisatoshi) for the entire blinded path. */ -struct LDKBlindedTail Path_get_blinded_tail(const struct LDKPath *NONNULL_PTR this_ptr); +void BlindedPayInfo_set_fee_base_msat(struct LDKBlindedPayInfo *NONNULL_PTR this_ptr, uint32_t val); /** - * 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 + * Liquidity fee charged (in millionths of the amount transferred) for the entire blinded path + * (i.e., 10,000 is 1%). */ -void Path_set_blinded_tail(struct LDKPath *NONNULL_PTR this_ptr, struct LDKBlindedTail val); +uint32_t BlindedPayInfo_get_fee_proportional_millionths(const struct LDKBlindedPayInfo *NONNULL_PTR this_ptr); /** - * Constructs a new Path given each field - * - * Note that blinded_tail_arg (or a relevant inner pointer) may be NULL or all-0s to represent None + * Liquidity fee charged (in millionths of the amount transferred) for the entire blinded path + * (i.e., 10,000 is 1%). */ -MUST_USE_RES struct LDKPath Path_new(struct LDKCVec_RouteHopZ hops_arg, struct LDKBlindedTail blinded_tail_arg); +void BlindedPayInfo_set_fee_proportional_millionths(struct LDKBlindedPayInfo *NONNULL_PTR this_ptr, uint32_t val); /** - * Creates a copy of the Path + * Number of blocks subtracted from an incoming HTLC's `cltv_expiry` for the entire blinded + * path. */ -struct LDKPath Path_clone(const struct LDKPath *NONNULL_PTR orig); +uint16_t BlindedPayInfo_get_cltv_expiry_delta(const struct LDKBlindedPayInfo *NONNULL_PTR this_ptr); /** - * Generates a non-cryptographic 64-bit hash of the Path. + * Number of blocks subtracted from an incoming HTLC's `cltv_expiry` for the entire blinded + * path. */ -uint64_t Path_hash(const struct LDKPath *NONNULL_PTR o); +void BlindedPayInfo_set_cltv_expiry_delta(struct LDKBlindedPayInfo *NONNULL_PTR this_ptr, uint16_t val); /** - * 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. + * 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. */ -bool Path_eq(const struct LDKPath *NONNULL_PTR a, const struct LDKPath *NONNULL_PTR b); +uint64_t BlindedPayInfo_get_htlc_minimum_msat(const struct LDKBlindedPayInfo *NONNULL_PTR this_ptr); /** - * Gets the fees for a given path, excluding any excess paid to the recipient. + * 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 uint64_t Path_fee_msat(const struct LDKPath *NONNULL_PTR this_arg); +void BlindedPayInfo_set_htlc_minimum_msat(struct LDKBlindedPayInfo *NONNULL_PTR this_ptr, uint64_t val); /** - * Gets the total amount paid on this [`Path`], excluding the fees. + * 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. */ -MUST_USE_RES uint64_t Path_final_value_msat(const struct LDKPath *NONNULL_PTR this_arg); +uint64_t BlindedPayInfo_get_htlc_maximum_msat(const struct LDKBlindedPayInfo *NONNULL_PTR this_ptr); /** - * Gets the final hop's CLTV expiry delta. + * 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. */ -MUST_USE_RES struct LDKCOption_u32Z Path_final_cltv_expiry_delta(const struct LDKPath *NONNULL_PTR this_arg); +void BlindedPayInfo_set_htlc_maximum_msat(struct LDKBlindedPayInfo *NONNULL_PTR this_ptr, uint64_t val); /** - * Frees any resources used by the Route, if is_owned is set and inner is non-NULL. + * Features set in `encrypted_data_tlv` for the `encrypted_recipient_data` TLV record in an + * onion payload. */ -void Route_free(struct LDKRoute this_obj); +struct LDKBlindedHopFeatures BlindedPayInfo_get_features(const struct LDKBlindedPayInfo *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. + * Features set in `encrypted_data_tlv` for the `encrypted_recipient_data` TLV record in an + * onion payload. */ -struct LDKCVec_PathZ Route_get_paths(const struct LDKRoute *NONNULL_PTR this_ptr); +void BlindedPayInfo_set_features(struct LDKBlindedPayInfo *NONNULL_PTR this_ptr, struct LDKBlindedHopFeatures val); /** - * 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. + * Constructs a new BlindedPayInfo given each field */ -void Route_set_paths(struct LDKRoute *NONNULL_PTR this_ptr, struct LDKCVec_PathZ val); +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); /** - * The `route_params` parameter passed to [`find_route`]. - * - * This is used by `ChannelManager` to track information which may be required for retries. - * - * Will be `None` for objects serialized with LDK versions prior to 0.0.117. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Creates a copy of the BlindedPayInfo */ -struct LDKRouteParameters Route_get_route_params(const struct LDKRoute *NONNULL_PTR this_ptr); +struct LDKBlindedPayInfo BlindedPayInfo_clone(const struct LDKBlindedPayInfo *NONNULL_PTR orig); /** - * The `route_params` parameter passed to [`find_route`]. - * - * This is used by `ChannelManager` to track information which may be required for retries. - * - * Will be `None` for objects serialized with LDK versions prior to 0.0.117. - * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * Generates a non-cryptographic 64-bit hash of the BlindedPayInfo. */ -void Route_set_route_params(struct LDKRoute *NONNULL_PTR this_ptr, struct LDKRouteParameters val); +uint64_t BlindedPayInfo_hash(const struct LDKBlindedPayInfo *NONNULL_PTR o); /** - * Constructs a new Route given each field - * - * Note that route_params_arg (or a relevant inner pointer) may be NULL or all-0s to represent None + * 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. */ -MUST_USE_RES struct LDKRoute Route_new(struct LDKCVec_PathZ paths_arg, struct LDKRouteParameters route_params_arg); +bool BlindedPayInfo_eq(const struct LDKBlindedPayInfo *NONNULL_PTR a, const struct LDKBlindedPayInfo *NONNULL_PTR b); /** - * Creates a copy of the Route + * Serialize the BlindedPayInfo object into a byte array which can be read by BlindedPayInfo_read */ -struct LDKRoute Route_clone(const struct LDKRoute *NONNULL_PTR orig); +struct LDKCVec_u8Z BlindedPayInfo_write(const struct LDKBlindedPayInfo *NONNULL_PTR obj); /** - * Generates a non-cryptographic 64-bit hash of the Route. + * Read a BlindedPayInfo from a byte array, created by BlindedPayInfo_write */ -uint64_t Route_hash(const struct LDKRoute *NONNULL_PTR o); +struct LDKCResult_BlindedPayInfoDecodeErrorZ BlindedPayInfo_read(struct LDKu8slice ser); /** - * 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. + * Frees any resources used by the BlindedPaymentPath, if is_owned is set and inner is non-NULL. */ -bool Route_eq(const struct LDKRoute *NONNULL_PTR a, const struct LDKRoute *NONNULL_PTR b); +void BlindedPaymentPath_free(struct LDKBlindedPaymentPath this_obj); /** - * Returns the total amount of fees paid on this [`Route`]. - * - * For objects serialized with LDK 0.0.117 and after, this includes any extra payment made to - * the recipient, which can happen in excess of the amount passed to [`find_route`] via - * [`RouteParameters::final_value_msat`], if we had to reach the [`htlc_minimum_msat`] limits. - * - * [`htlc_minimum_msat`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_update-message + * The [`BlindedPayInfo`] used to pay this blinded path. */ -MUST_USE_RES uint64_t Route_get_total_fees(const struct LDKRoute *NONNULL_PTR this_arg); +struct LDKBlindedPayInfo BlindedPaymentPath_get_payinfo(const struct LDKBlindedPaymentPath *NONNULL_PTR this_ptr); /** - * Returns the total amount paid on this [`Route`], excluding the fees. - * - * Might be more than requested as part of the given [`RouteParameters::final_value_msat`] if - * we had to reach the [`htlc_minimum_msat`] limits. - * - * [`htlc_minimum_msat`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_update-message + * The [`BlindedPayInfo`] used to pay this blinded path. */ -MUST_USE_RES uint64_t Route_get_total_amount(const struct LDKRoute *NONNULL_PTR this_arg); +void BlindedPaymentPath_set_payinfo(struct LDKBlindedPaymentPath *NONNULL_PTR this_ptr, struct LDKBlindedPayInfo val); /** - * Get the string representation of a Route object + * Creates a copy of the BlindedPaymentPath */ -struct LDKStr Route_to_str(const struct LDKRoute *NONNULL_PTR o); +struct LDKBlindedPaymentPath BlindedPaymentPath_clone(const struct LDKBlindedPaymentPath *NONNULL_PTR orig); /** - * Serialize the Route object into a byte array which can be read by Route_read + * Generates a non-cryptographic 64-bit hash of the BlindedPaymentPath. */ -struct LDKCVec_u8Z Route_write(const struct LDKRoute *NONNULL_PTR obj); +uint64_t BlindedPaymentPath_hash(const struct LDKBlindedPaymentPath *NONNULL_PTR o); /** - * Read a Route from a byte array, created by Route_write + * Checks if two BlindedPaymentPaths 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_RouteDecodeErrorZ Route_read(struct LDKu8slice ser); +bool BlindedPaymentPath_eq(const struct LDKBlindedPaymentPath *NONNULL_PTR a, const struct LDKBlindedPaymentPath *NONNULL_PTR b); /** - * Frees any resources used by the RouteParameters, if is_owned is set and inner is non-NULL. + * Create a one-hop blinded path for a payment. */ -void RouteParameters_free(struct LDKRouteParameters this_obj); +MUST_USE_RES struct LDKCResult_BlindedPaymentPathNoneZ BlindedPaymentPath_one_hop(struct LDKPublicKey payee_node_id, struct LDKReceiveTlvs payee_tlvs, uint16_t min_final_cltv_expiry_delta, struct LDKEntropySource entropy_source); /** - * The parameters of the failed payment path. + * Create a blinded path for a payment, to be forwarded along `intermediate_nodes`. + * + * Errors if: + * * a provided node id is invalid + * * [`BlindedPayInfo`] calculation results in an integer overflow + * * any unknown features are required in the provided [`ForwardTlvs`] */ -struct LDKPaymentParameters RouteParameters_get_payment_params(const struct LDKRouteParameters *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCResult_BlindedPaymentPathNoneZ BlindedPaymentPath_new(struct LDKCVec_PaymentForwardNodeZ intermediate_nodes, struct LDKPublicKey payee_node_id, struct LDKReceiveTlvs payee_tlvs, uint64_t htlc_maximum_msat, uint16_t min_final_cltv_expiry_delta, struct LDKEntropySource entropy_source); /** - * The parameters of the failed payment path. + * Returns the introduction [`NodeId`] of the blinded path, if it is publicly reachable (i.e., + * it is found in the network graph). + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void RouteParameters_set_payment_params(struct LDKRouteParameters *NONNULL_PTR this_ptr, struct LDKPaymentParameters val); +MUST_USE_RES struct LDKNodeId BlindedPaymentPath_public_introduction_node_id(const struct LDKBlindedPaymentPath *NONNULL_PTR this_arg, const struct LDKReadOnlyNetworkGraph *NONNULL_PTR network_graph); /** - * The amount in msats sent on the failed payment path. + * The [`IntroductionNode`] of the blinded path. */ -uint64_t RouteParameters_get_final_value_msat(const struct LDKRouteParameters *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKIntroductionNode BlindedPaymentPath_introduction_node(const struct LDKBlindedPaymentPath *NONNULL_PTR this_arg); /** - * The amount in msats sent on the failed payment path. + * Used by the [`IntroductionNode`] to decrypt its [`encrypted_payload`] to forward the payment. + * + * [`encrypted_payload`]: BlindedHop::encrypted_payload */ -void RouteParameters_set_final_value_msat(struct LDKRouteParameters *NONNULL_PTR this_ptr, uint64_t val); +MUST_USE_RES struct LDKPublicKey BlindedPaymentPath_blinding_point(const struct LDKBlindedPaymentPath *NONNULL_PTR this_arg); /** - * The maximum total fees, in millisatoshi, that may accrue during route finding. - * - * This limit also applies to the total fees that may arise while retrying failed payment - * paths. - * - * Note that values below a few sats may result in some paths being spuriously ignored. + * The [`BlindedHop`]s within the blinded path. */ -struct LDKCOption_u64Z RouteParameters_get_max_total_routing_fee_msat(const struct LDKRouteParameters *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCVec_BlindedHopZ BlindedPaymentPath_blinded_hops(const struct LDKBlindedPaymentPath *NONNULL_PTR this_arg); /** - * The maximum total fees, in millisatoshi, that may accrue during route finding. - * - * This limit also applies to the total fees that may arise while retrying failed payment - * paths. + * Advance the blinded onion payment path by one hop, making the second hop into the new + * introduction node. * - * Note that values below a few sats may result in some paths being spuriously ignored. + * Will only modify `self` when returning `Ok`. */ -void RouteParameters_set_max_total_routing_fee_msat(struct LDKRouteParameters *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); +MUST_USE_RES struct LDKCResult_NoneNoneZ BlindedPaymentPath_advance_path_by_one(struct LDKBlindedPaymentPath *NONNULL_PTR this_arg, const struct LDKNodeSigner *NONNULL_PTR node_signer, const struct LDKNodeIdLookUp *NONNULL_PTR node_id_lookup); /** - * Constructs a new RouteParameters given each field + * Frees any resources used by the PaymentForwardNode, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKRouteParameters RouteParameters_new(struct LDKPaymentParameters payment_params_arg, uint64_t final_value_msat_arg, struct LDKCOption_u64Z max_total_routing_fee_msat_arg); +void PaymentForwardNode_free(struct LDKPaymentForwardNode this_obj); /** - * Creates a copy of the RouteParameters + * The TLVs for this node's [`BlindedHop`], where the fee parameters contained within are also + * used for [`BlindedPayInfo`] construction. */ -struct LDKRouteParameters RouteParameters_clone(const struct LDKRouteParameters *NONNULL_PTR orig); +struct LDKForwardTlvs PaymentForwardNode_get_tlvs(const struct LDKPaymentForwardNode *NONNULL_PTR this_ptr); /** - * Generates a non-cryptographic 64-bit hash of the RouteParameters. + * The TLVs for this node's [`BlindedHop`], where the fee parameters contained within are also + * used for [`BlindedPayInfo`] construction. */ -uint64_t RouteParameters_hash(const struct LDKRouteParameters *NONNULL_PTR o); +void PaymentForwardNode_set_tlvs(struct LDKPaymentForwardNode *NONNULL_PTR this_ptr, struct LDKForwardTlvs val); /** - * 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. + * This node's pubkey. */ -bool RouteParameters_eq(const struct LDKRouteParameters *NONNULL_PTR a, const struct LDKRouteParameters *NONNULL_PTR b); +struct LDKPublicKey PaymentForwardNode_get_node_id(const struct LDKPaymentForwardNode *NONNULL_PTR this_ptr); /** - * Constructs [`RouteParameters`] from the given [`PaymentParameters`] and a payment amount. - * - * [`Self::max_total_routing_fee_msat`] defaults to 1% of the payment amount + 50 sats + * This node's pubkey. */ -MUST_USE_RES struct LDKRouteParameters RouteParameters_from_payment_params_and_value(struct LDKPaymentParameters payment_params, uint64_t final_value_msat); +void PaymentForwardNode_set_node_id(struct LDKPaymentForwardNode *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Serialize the RouteParameters object into a byte array which can be read by RouteParameters_read + * The maximum value, in msat, that may be accepted by this node. */ -struct LDKCVec_u8Z RouteParameters_write(const struct LDKRouteParameters *NONNULL_PTR obj); +uint64_t PaymentForwardNode_get_htlc_maximum_msat(const struct LDKPaymentForwardNode *NONNULL_PTR this_ptr); /** - * Read a RouteParameters from a byte array, created by RouteParameters_write + * The maximum value, in msat, that may be accepted by this node. */ -struct LDKCResult_RouteParametersDecodeErrorZ RouteParameters_read(struct LDKu8slice ser); +void PaymentForwardNode_set_htlc_maximum_msat(struct LDKPaymentForwardNode *NONNULL_PTR this_ptr, uint64_t val); /** - * Frees any resources used by the PaymentParameters, if is_owned is set and inner is non-NULL. + * Constructs a new PaymentForwardNode given each field */ -void PaymentParameters_free(struct LDKPaymentParameters this_obj); +MUST_USE_RES struct LDKPaymentForwardNode PaymentForwardNode_new(struct LDKForwardTlvs tlvs_arg, struct LDKPublicKey node_id_arg, uint64_t htlc_maximum_msat_arg); /** - * Information about the payee, such as their features and route hints for their channels. + * Creates a copy of the PaymentForwardNode */ -struct LDKPayee PaymentParameters_get_payee(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); +struct LDKPaymentForwardNode PaymentForwardNode_clone(const struct LDKPaymentForwardNode *NONNULL_PTR orig); /** - * Information about the payee, such as their features and route hints for their channels. + * Frees any resources used by the ForwardTlvs, if is_owned is set and inner is non-NULL. */ -void PaymentParameters_set_payee(struct LDKPaymentParameters *NONNULL_PTR this_ptr, struct LDKPayee val); +void ForwardTlvs_free(struct LDKForwardTlvs this_obj); /** - * Expiration of a payment to the payee, in seconds relative to the UNIX epoch. + * The short channel id this payment should be forwarded out over. */ -struct LDKCOption_u64Z PaymentParameters_get_expiry_time(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); +uint64_t ForwardTlvs_get_short_channel_id(const struct LDKForwardTlvs *NONNULL_PTR this_ptr); /** - * Expiration of a payment to the payee, in seconds relative to the UNIX epoch. + * The short channel id this payment should be forwarded out over. */ -void PaymentParameters_set_expiry_time(struct LDKPaymentParameters *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); +void ForwardTlvs_set_short_channel_id(struct LDKForwardTlvs *NONNULL_PTR this_ptr, uint64_t val); /** - * The maximum total CLTV delta we accept for the route. - * Defaults to [`DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA`]. + * Payment parameters for relaying over [`Self::short_channel_id`]. */ -uint32_t PaymentParameters_get_max_total_cltv_expiry_delta(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); +struct LDKPaymentRelay ForwardTlvs_get_payment_relay(const struct LDKForwardTlvs *NONNULL_PTR this_ptr); /** - * The maximum total CLTV delta we accept for the route. - * Defaults to [`DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA`]. + * Payment parameters for relaying over [`Self::short_channel_id`]. */ -void PaymentParameters_set_max_total_cltv_expiry_delta(struct LDKPaymentParameters *NONNULL_PTR this_ptr, uint32_t val); +void ForwardTlvs_set_payment_relay(struct LDKForwardTlvs *NONNULL_PTR this_ptr, struct LDKPaymentRelay val); /** - * The maximum number of paths that may be used by (MPP) payments. - * Defaults to [`DEFAULT_MAX_PATH_COUNT`]. + * Payment constraints for relaying over [`Self::short_channel_id`]. */ -uint8_t PaymentParameters_get_max_path_count(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); +struct LDKPaymentConstraints ForwardTlvs_get_payment_constraints(const struct LDKForwardTlvs *NONNULL_PTR this_ptr); /** - * The maximum number of paths that may be used by (MPP) payments. - * Defaults to [`DEFAULT_MAX_PATH_COUNT`]. + * Payment constraints for relaying over [`Self::short_channel_id`]. */ -void PaymentParameters_set_max_path_count(struct LDKPaymentParameters *NONNULL_PTR this_ptr, uint8_t val); +void ForwardTlvs_set_payment_constraints(struct LDKForwardTlvs *NONNULL_PTR this_ptr, struct LDKPaymentConstraints val); /** - * 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. + * Supported and required features when relaying a payment onion containing this object's + * corresponding [`BlindedHop::encrypted_payload`]. * - * Default value: 2 + * [`BlindedHop::encrypted_payload`]: crate::blinded_path::BlindedHop::encrypted_payload */ -uint8_t PaymentParameters_get_max_channel_saturation_power_of_half(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); +struct LDKBlindedHopFeatures ForwardTlvs_get_features(const struct LDKForwardTlvs *NONNULL_PTR this_ptr); /** - * 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. + * Supported and required features when relaying a payment onion containing this object's + * corresponding [`BlindedHop::encrypted_payload`]. * - * Default value: 2 + * [`BlindedHop::encrypted_payload`]: crate::blinded_path::BlindedHop::encrypted_payload */ -void PaymentParameters_set_max_channel_saturation_power_of_half(struct LDKPaymentParameters *NONNULL_PTR this_ptr, uint8_t val); +void ForwardTlvs_set_features(struct LDKForwardTlvs *NONNULL_PTR this_ptr, struct LDKBlindedHopFeatures val); /** - * 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. + * Set if this [`BlindedPaymentPath`] is concatenated to another, to indicate the + * [`BlindedPaymentPath::blinding_point`] of the appended blinded path. * - * Returns a copy of the field. + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKCVec_u64Z PaymentParameters_get_previously_failed_channels(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); +struct LDKPublicKey ForwardTlvs_get_next_blinding_override(const struct LDKForwardTlvs *NONNULL_PTR this_ptr); /** - * 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. + * Set if this [`BlindedPaymentPath`] is concatenated to another, to indicate the + * [`BlindedPaymentPath::blinding_point`] of the appended blinded path. + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void PaymentParameters_set_previously_failed_channels(struct LDKPaymentParameters *NONNULL_PTR this_ptr, struct LDKCVec_u64Z val); +void ForwardTlvs_set_next_blinding_override(struct LDKForwardTlvs *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * A list of indices corresponding to blinded paths in [`Payee::Blinded::route_hints`] 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 blinded paths. + * Constructs a new ForwardTlvs given each field * - * Returns a copy of the field. + * Note that next_blinding_override_arg (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKCVec_u64Z PaymentParameters_get_previously_failed_blinded_path_idxs(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKForwardTlvs ForwardTlvs_new(uint64_t short_channel_id_arg, struct LDKPaymentRelay payment_relay_arg, struct LDKPaymentConstraints payment_constraints_arg, struct LDKBlindedHopFeatures features_arg, struct LDKPublicKey next_blinding_override_arg); /** - * A list of indices corresponding to blinded paths in [`Payee::Blinded::route_hints`] 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 blinded paths. + * Creates a copy of the ForwardTlvs */ -void PaymentParameters_set_previously_failed_blinded_path_idxs(struct LDKPaymentParameters *NONNULL_PTR this_ptr, struct LDKCVec_u64Z val); +struct LDKForwardTlvs ForwardTlvs_clone(const struct LDKForwardTlvs *NONNULL_PTR orig); /** - * Constructs a new PaymentParameters given each field + * Frees any resources used by the ReceiveTlvs, if is_owned is set and inner is non-NULL. */ -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, struct LDKCVec_u64Z previously_failed_blinded_path_idxs_arg); +void ReceiveTlvs_free(struct LDKReceiveTlvs this_obj); /** - * Creates a copy of the PaymentParameters + * Used to authenticate the sender of a payment to the receiver and tie MPP HTLCs together. */ -struct LDKPaymentParameters PaymentParameters_clone(const struct LDKPaymentParameters *NONNULL_PTR orig); +const uint8_t (*ReceiveTlvs_get_payment_secret(const struct LDKReceiveTlvs *NONNULL_PTR this_ptr))[32]; /** - * Generates a non-cryptographic 64-bit hash of the PaymentParameters. + * Used to authenticate the sender of a payment to the receiver and tie MPP HTLCs together. */ -uint64_t PaymentParameters_hash(const struct LDKPaymentParameters *NONNULL_PTR o); +void ReceiveTlvs_set_payment_secret(struct LDKReceiveTlvs *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes 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. + * Constraints for the receiver of this payment. */ -bool PaymentParameters_eq(const struct LDKPaymentParameters *NONNULL_PTR a, const struct LDKPaymentParameters *NONNULL_PTR b); +struct LDKPaymentConstraints ReceiveTlvs_get_payment_constraints(const struct LDKReceiveTlvs *NONNULL_PTR this_ptr); /** - * Serialize the PaymentParameters object into a byte array which can be read by PaymentParameters_read + * Constraints for the receiver of this payment. */ -struct LDKCVec_u8Z PaymentParameters_write(const struct LDKPaymentParameters *NONNULL_PTR obj); +void ReceiveTlvs_set_payment_constraints(struct LDKReceiveTlvs *NONNULL_PTR this_ptr, struct LDKPaymentConstraints val); /** - * Read a PaymentParameters from a byte array, created by PaymentParameters_write + * Context for the receiver of this payment. */ -struct LDKCResult_PaymentParametersDecodeErrorZ PaymentParameters_read(struct LDKu8slice ser, uint32_t arg); +struct LDKPaymentContext ReceiveTlvs_get_payment_context(const struct LDKReceiveTlvs *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. + * Context for the receiver of this payment. */ -MUST_USE_RES struct LDKPaymentParameters PaymentParameters_from_node_id(struct LDKPublicKey payee_pubkey, uint32_t final_cltv_expiry_delta); +void ReceiveTlvs_set_payment_context(struct LDKReceiveTlvs *NONNULL_PTR this_ptr, struct LDKPaymentContext 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. - * - * 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 + * Constructs a new ReceiveTlvs given each field */ -MUST_USE_RES struct LDKPaymentParameters PaymentParameters_for_keysend(struct LDKPublicKey payee_pubkey, uint32_t final_cltv_expiry_delta, bool allow_mpp); +MUST_USE_RES struct LDKReceiveTlvs ReceiveTlvs_new(struct LDKThirtyTwoBytes payment_secret_arg, struct LDKPaymentConstraints payment_constraints_arg, struct LDKPaymentContext payment_context_arg); /** - * Creates parameters for paying to a blinded payee from the provided invoice. Sets - * [`Payee::Blinded::route_hints`], [`Payee::Blinded::features`], and - * [`PaymentParameters::expiry_time`]. + * Creates a copy of the ReceiveTlvs */ -MUST_USE_RES struct LDKPaymentParameters PaymentParameters_from_bolt12_invoice(const struct LDKBolt12Invoice *NONNULL_PTR invoice); +struct LDKReceiveTlvs ReceiveTlvs_clone(const struct LDKReceiveTlvs *NONNULL_PTR orig); /** - * Creates parameters for paying to a blinded payee from the provided blinded route hints. + * Frees any resources used by the PaymentRelay, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKPaymentParameters PaymentParameters_blinded(struct LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ blinded_route_hints); +void PaymentRelay_free(struct LDKPaymentRelay this_obj); /** - * Frees any resources used by the Payee + * Number of blocks subtracted from an incoming HTLC's `cltv_expiry` for this [`BlindedHop`]. */ -void Payee_free(struct LDKPayee this_ptr); +uint16_t PaymentRelay_get_cltv_expiry_delta(const struct LDKPaymentRelay *NONNULL_PTR this_ptr); /** - * Creates a copy of the Payee + * Number of blocks subtracted from an incoming HTLC's `cltv_expiry` for this [`BlindedHop`]. */ -struct LDKPayee Payee_clone(const struct LDKPayee *NONNULL_PTR orig); +void PaymentRelay_set_cltv_expiry_delta(struct LDKPaymentRelay *NONNULL_PTR this_ptr, uint16_t val); /** - * Utility method to constructs a new Blinded-variant Payee + * Liquidity fee charged (in millionths of the amount transferred) for relaying a payment over + * this [`BlindedHop`], (i.e., 10,000 is 1%). */ -struct LDKPayee Payee_blinded(struct LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ route_hints, struct LDKBolt12InvoiceFeatures features); +uint32_t PaymentRelay_get_fee_proportional_millionths(const struct LDKPaymentRelay *NONNULL_PTR this_ptr); /** - * Utility method to constructs a new Clear-variant Payee + * Liquidity fee charged (in millionths of the amount transferred) for relaying a payment over + * this [`BlindedHop`], (i.e., 10,000 is 1%). */ -struct LDKPayee Payee_clear(struct LDKPublicKey node_id, struct LDKCVec_RouteHintZ route_hints, struct LDKBolt11InvoiceFeatures features, uint32_t final_cltv_expiry_delta); +void PaymentRelay_set_fee_proportional_millionths(struct LDKPaymentRelay *NONNULL_PTR this_ptr, uint32_t val); /** - * Generates a non-cryptographic 64-bit hash of the Payee. + * Base fee charged (in millisatoshi) for relaying a payment over this [`BlindedHop`]. */ -uint64_t Payee_hash(const struct LDKPayee *NONNULL_PTR o); +uint32_t PaymentRelay_get_fee_base_msat(const struct LDKPaymentRelay *NONNULL_PTR this_ptr); /** - * Checks if two Payees contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Base fee charged (in millisatoshi) for relaying a payment over this [`BlindedHop`]. */ -bool Payee_eq(const struct LDKPayee *NONNULL_PTR a, const struct LDKPayee *NONNULL_PTR b); +void PaymentRelay_set_fee_base_msat(struct LDKPaymentRelay *NONNULL_PTR this_ptr, uint32_t val); /** - * Frees any resources used by the RouteHint, if is_owned is set and inner is non-NULL. + * Constructs a new PaymentRelay given each field */ -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); +MUST_USE_RES struct LDKPaymentRelay PaymentRelay_new(uint16_t cltv_expiry_delta_arg, uint32_t fee_proportional_millionths_arg, uint32_t fee_base_msat_arg); /** - * Constructs a new RouteHint given each field + * Creates a copy of the PaymentRelay */ -MUST_USE_RES struct LDKRouteHint RouteHint_new(struct LDKCVec_RouteHintHopZ a_arg); +struct LDKPaymentRelay PaymentRelay_clone(const struct LDKPaymentRelay *NONNULL_PTR orig); /** - * Creates a copy of the RouteHint + * Frees any resources used by the PaymentConstraints, if is_owned is set and inner is non-NULL. */ -struct LDKRouteHint RouteHint_clone(const struct LDKRouteHint *NONNULL_PTR orig); +void PaymentConstraints_free(struct LDKPaymentConstraints this_obj); /** - * Generates a non-cryptographic 64-bit hash of the RouteHint. + * The maximum total CLTV that is acceptable when relaying a payment over this [`BlindedHop`]. */ -uint64_t RouteHint_hash(const struct LDKRouteHint *NONNULL_PTR o); +uint32_t PaymentConstraints_get_max_cltv_expiry(const struct LDKPaymentConstraints *NONNULL_PTR this_ptr); /** - * Checks if two RouteHints contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * The maximum total CLTV that is acceptable when relaying a payment over this [`BlindedHop`]. */ -bool RouteHint_eq(const struct LDKRouteHint *NONNULL_PTR a, const struct LDKRouteHint *NONNULL_PTR b); +void PaymentConstraints_set_max_cltv_expiry(struct LDKPaymentConstraints *NONNULL_PTR this_ptr, uint32_t val); /** - * Serialize the RouteHint object into a byte array which can be read by RouteHint_read + * The minimum value, in msat, that may be accepted by the node corresponding to this + * [`BlindedHop`]. */ -struct LDKCVec_u8Z RouteHint_write(const struct LDKRouteHint *NONNULL_PTR obj); +uint64_t PaymentConstraints_get_htlc_minimum_msat(const struct LDKPaymentConstraints *NONNULL_PTR this_ptr); /** - * Read a RouteHint from a byte array, created by RouteHint_write + * The minimum value, in msat, that may be accepted by the node corresponding to this + * [`BlindedHop`]. */ -struct LDKCResult_RouteHintDecodeErrorZ RouteHint_read(struct LDKu8slice ser); +void PaymentConstraints_set_htlc_minimum_msat(struct LDKPaymentConstraints *NONNULL_PTR this_ptr, uint64_t val); /** - * Frees any resources used by the RouteHintHop, if is_owned is set and inner is non-NULL. + * Constructs a new PaymentConstraints given each field */ -void RouteHintHop_free(struct LDKRouteHintHop this_obj); +MUST_USE_RES struct LDKPaymentConstraints PaymentConstraints_new(uint32_t max_cltv_expiry_arg, uint64_t htlc_minimum_msat_arg); /** - * The node_id of the non-target end of the route + * Creates a copy of the PaymentConstraints */ -struct LDKPublicKey RouteHintHop_get_src_node_id(const struct LDKRouteHintHop *NONNULL_PTR this_ptr); +struct LDKPaymentConstraints PaymentConstraints_clone(const struct LDKPaymentConstraints *NONNULL_PTR orig); /** - * The node_id of the non-target end of the route + * Frees any resources used by the PaymentContext */ -void RouteHintHop_set_src_node_id(struct LDKRouteHintHop *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void PaymentContext_free(struct LDKPaymentContext this_ptr); /** - * The short_channel_id of this channel + * Creates a copy of the PaymentContext */ -uint64_t RouteHintHop_get_short_channel_id(const struct LDKRouteHintHop *NONNULL_PTR this_ptr); +struct LDKPaymentContext PaymentContext_clone(const struct LDKPaymentContext *NONNULL_PTR orig); /** - * The short_channel_id of this channel + * Utility method to constructs a new Unknown-variant PaymentContext */ -void RouteHintHop_set_short_channel_id(struct LDKRouteHintHop *NONNULL_PTR this_ptr, uint64_t val); +struct LDKPaymentContext PaymentContext_unknown(struct LDKUnknownPaymentContext a); /** - * The fees which must be paid to use this channel + * Utility method to constructs a new Bolt12Offer-variant PaymentContext */ -struct LDKRoutingFees RouteHintHop_get_fees(const struct LDKRouteHintHop *NONNULL_PTR this_ptr); +struct LDKPaymentContext PaymentContext_bolt12_offer(struct LDKBolt12OfferContext a); /** - * The fees which must be paid to use this channel + * Utility method to constructs a new Bolt12Refund-variant PaymentContext */ -void RouteHintHop_set_fees(struct LDKRouteHintHop *NONNULL_PTR this_ptr, struct LDKRoutingFees val); +struct LDKPaymentContext PaymentContext_bolt12_refund(struct LDKBolt12RefundContext a); /** - * The difference in CLTV values between this node and the next node. + * Checks if two PaymentContexts contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -uint16_t RouteHintHop_get_cltv_expiry_delta(const struct LDKRouteHintHop *NONNULL_PTR this_ptr); +bool PaymentContext_eq(const struct LDKPaymentContext *NONNULL_PTR a, const struct LDKPaymentContext *NONNULL_PTR b); /** - * The difference in CLTV values between this node and the next node. + * Frees any resources used by the UnknownPaymentContext, if is_owned is set and inner is non-NULL. */ -void RouteHintHop_set_cltv_expiry_delta(struct LDKRouteHintHop *NONNULL_PTR this_ptr, uint16_t val); +void UnknownPaymentContext_free(struct LDKUnknownPaymentContext this_obj); /** - * The minimum value, in msat, which must be relayed to the next hop. + * Creates a copy of the UnknownPaymentContext */ -struct LDKCOption_u64Z RouteHintHop_get_htlc_minimum_msat(const struct LDKRouteHintHop *NONNULL_PTR this_ptr); +struct LDKUnknownPaymentContext UnknownPaymentContext_clone(const struct LDKUnknownPaymentContext *NONNULL_PTR orig); /** - * The minimum value, in msat, which must be relayed to the next hop. + * Checks if two UnknownPaymentContexts 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_htlc_minimum_msat(struct LDKRouteHintHop *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); +bool UnknownPaymentContext_eq(const struct LDKUnknownPaymentContext *NONNULL_PTR a, const struct LDKUnknownPaymentContext *NONNULL_PTR b); /** - * The maximum value in msat available for routing with a single HTLC. + * Frees any resources used by the Bolt12OfferContext, if is_owned is set and inner is non-NULL. */ -struct LDKCOption_u64Z RouteHintHop_get_htlc_maximum_msat(const struct LDKRouteHintHop *NONNULL_PTR this_ptr); +void Bolt12OfferContext_free(struct LDKBolt12OfferContext this_obj); /** - * The maximum value in msat available for routing with a single HTLC. + * The identifier of the [`Offer`]. + * + * [`Offer`]: crate::offers::offer::Offer */ -void RouteHintHop_set_htlc_maximum_msat(struct LDKRouteHintHop *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); +struct LDKOfferId Bolt12OfferContext_get_offer_id(const struct LDKBolt12OfferContext *NONNULL_PTR this_ptr); /** - * Constructs a new RouteHintHop given each field + * The identifier of the [`Offer`]. + * + * [`Offer`]: crate::offers::offer::Offer */ -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); +void Bolt12OfferContext_set_offer_id(struct LDKBolt12OfferContext *NONNULL_PTR this_ptr, struct LDKOfferId val); /** - * Creates a copy of the RouteHintHop + * Fields from an [`InvoiceRequest`] sent for a [`Bolt12Invoice`]. + * + * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest + * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice */ -struct LDKRouteHintHop RouteHintHop_clone(const struct LDKRouteHintHop *NONNULL_PTR orig); +struct LDKInvoiceRequestFields Bolt12OfferContext_get_invoice_request(const struct LDKBolt12OfferContext *NONNULL_PTR this_ptr); /** - * Generates a non-cryptographic 64-bit hash of the RouteHintHop. + * Fields from an [`InvoiceRequest`] sent for a [`Bolt12Invoice`]. + * + * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest + * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice */ -uint64_t RouteHintHop_hash(const struct LDKRouteHintHop *NONNULL_PTR o); +void Bolt12OfferContext_set_invoice_request(struct LDKBolt12OfferContext *NONNULL_PTR this_ptr, struct LDKInvoiceRequestFields val); /** - * 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. + * Constructs a new Bolt12OfferContext given each field */ -bool RouteHintHop_eq(const struct LDKRouteHintHop *NONNULL_PTR a, const struct LDKRouteHintHop *NONNULL_PTR b); +MUST_USE_RES struct LDKBolt12OfferContext Bolt12OfferContext_new(struct LDKOfferId offer_id_arg, struct LDKInvoiceRequestFields invoice_request_arg); /** - * Serialize the RouteHintHop object into a byte array which can be read by RouteHintHop_read + * Creates a copy of the Bolt12OfferContext */ -struct LDKCVec_u8Z RouteHintHop_write(const struct LDKRouteHintHop *NONNULL_PTR obj); +struct LDKBolt12OfferContext Bolt12OfferContext_clone(const struct LDKBolt12OfferContext *NONNULL_PTR orig); /** - * Read a RouteHintHop from a byte array, created by RouteHintHop_write + * Checks if two Bolt12OfferContexts 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_RouteHintHopDecodeErrorZ RouteHintHop_read(struct LDKu8slice ser); +bool Bolt12OfferContext_eq(const struct LDKBolt12OfferContext *NONNULL_PTR a, const struct LDKBolt12OfferContext *NONNULL_PTR b); /** - * Frees any resources used by the FirstHopCandidate, if is_owned is set and inner is non-NULL. + * Frees any resources used by the Bolt12RefundContext, if is_owned is set and inner is non-NULL. */ -void FirstHopCandidate_free(struct LDKFirstHopCandidate this_obj); +void Bolt12RefundContext_free(struct LDKBolt12RefundContext this_obj); /** - * Creates a copy of the FirstHopCandidate + * Constructs a new Bolt12RefundContext given each field */ -struct LDKFirstHopCandidate FirstHopCandidate_clone(const struct LDKFirstHopCandidate *NONNULL_PTR orig); +MUST_USE_RES struct LDKBolt12RefundContext Bolt12RefundContext_new(void); /** - * Frees any resources used by the PublicHopCandidate, if is_owned is set and inner is non-NULL. + * Creates a copy of the Bolt12RefundContext */ -void PublicHopCandidate_free(struct LDKPublicHopCandidate this_obj); +struct LDKBolt12RefundContext Bolt12RefundContext_clone(const struct LDKBolt12RefundContext *NONNULL_PTR orig); /** - * The short channel ID of the channel, i.e. the identifier by which we refer to this - * channel. + * Checks if two Bolt12RefundContexts 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. */ -uint64_t PublicHopCandidate_get_short_channel_id(const struct LDKPublicHopCandidate *NONNULL_PTR this_ptr); +bool Bolt12RefundContext_eq(const struct LDKBolt12RefundContext *NONNULL_PTR a, const struct LDKBolt12RefundContext *NONNULL_PTR b); /** - * The short channel ID of the channel, i.e. the identifier by which we refer to this - * channel. + * Serialize the ForwardTlvs object into a byte array which can be read by ForwardTlvs_read */ -void PublicHopCandidate_set_short_channel_id(struct LDKPublicHopCandidate *NONNULL_PTR this_ptr, uint64_t val); +struct LDKCVec_u8Z ForwardTlvs_write(const struct LDKForwardTlvs *NONNULL_PTR obj); /** - * Creates a copy of the PublicHopCandidate + * Serialize the ReceiveTlvs object into a byte array which can be read by ReceiveTlvs_read */ -struct LDKPublicHopCandidate PublicHopCandidate_clone(const struct LDKPublicHopCandidate *NONNULL_PTR orig); +struct LDKCVec_u8Z ReceiveTlvs_write(const struct LDKReceiveTlvs *NONNULL_PTR obj); /** - * Frees any resources used by the PrivateHopCandidate, if is_owned is set and inner is non-NULL. + * Serialize the PaymentRelay object into a byte array which can be read by PaymentRelay_read */ -void PrivateHopCandidate_free(struct LDKPrivateHopCandidate this_obj); +struct LDKCVec_u8Z PaymentRelay_write(const struct LDKPaymentRelay *NONNULL_PTR obj); /** - * Creates a copy of the PrivateHopCandidate + * Read a PaymentRelay from a byte array, created by PaymentRelay_write */ -struct LDKPrivateHopCandidate PrivateHopCandidate_clone(const struct LDKPrivateHopCandidate *NONNULL_PTR orig); +struct LDKCResult_PaymentRelayDecodeErrorZ PaymentRelay_read(struct LDKu8slice ser); /** - * Frees any resources used by the BlindedPathCandidate, if is_owned is set and inner is non-NULL. + * Serialize the PaymentConstraints object into a byte array which can be read by PaymentConstraints_read */ -void BlindedPathCandidate_free(struct LDKBlindedPathCandidate this_obj); +struct LDKCVec_u8Z PaymentConstraints_write(const struct LDKPaymentConstraints *NONNULL_PTR obj); /** - * Creates a copy of the BlindedPathCandidate + * Read a PaymentConstraints from a byte array, created by PaymentConstraints_write */ -struct LDKBlindedPathCandidate BlindedPathCandidate_clone(const struct LDKBlindedPathCandidate *NONNULL_PTR orig); +struct LDKCResult_PaymentConstraintsDecodeErrorZ PaymentConstraints_read(struct LDKu8slice ser); /** - * Frees any resources used by the OneHopBlindedPathCandidate, if is_owned is set and inner is non-NULL. + * Serialize the PaymentContext object into a byte array which can be read by PaymentContext_read */ -void OneHopBlindedPathCandidate_free(struct LDKOneHopBlindedPathCandidate this_obj); +struct LDKCVec_u8Z PaymentContext_write(const struct LDKPaymentContext *NONNULL_PTR obj); /** - * Creates a copy of the OneHopBlindedPathCandidate + * Read a PaymentContext from a byte array, created by PaymentContext_write */ -struct LDKOneHopBlindedPathCandidate OneHopBlindedPathCandidate_clone(const struct LDKOneHopBlindedPathCandidate *NONNULL_PTR orig); +struct LDKCResult_PaymentContextDecodeErrorZ PaymentContext_read(struct LDKu8slice ser); /** - * Frees any resources used by the CandidateRouteHop + * Serialize the UnknownPaymentContext object into a byte array which can be read by UnknownPaymentContext_read */ -void CandidateRouteHop_free(struct LDKCandidateRouteHop this_ptr); +struct LDKCVec_u8Z UnknownPaymentContext_write(const struct LDKUnknownPaymentContext *NONNULL_PTR obj); /** - * Creates a copy of the CandidateRouteHop + * Read a UnknownPaymentContext from a byte array, created by UnknownPaymentContext_write */ -struct LDKCandidateRouteHop CandidateRouteHop_clone(const struct LDKCandidateRouteHop *NONNULL_PTR orig); +struct LDKCResult_UnknownPaymentContextDecodeErrorZ UnknownPaymentContext_read(struct LDKu8slice ser); /** - * Utility method to constructs a new FirstHop-variant CandidateRouteHop + * Serialize the Bolt12OfferContext object into a byte array which can be read by Bolt12OfferContext_read */ -struct LDKCandidateRouteHop CandidateRouteHop_first_hop(struct LDKFirstHopCandidate a); +struct LDKCVec_u8Z Bolt12OfferContext_write(const struct LDKBolt12OfferContext *NONNULL_PTR obj); /** - * Utility method to constructs a new PublicHop-variant CandidateRouteHop + * Read a Bolt12OfferContext from a byte array, created by Bolt12OfferContext_write */ -struct LDKCandidateRouteHop CandidateRouteHop_public_hop(struct LDKPublicHopCandidate a); +struct LDKCResult_Bolt12OfferContextDecodeErrorZ Bolt12OfferContext_read(struct LDKu8slice ser); /** - * Utility method to constructs a new PrivateHop-variant CandidateRouteHop + * Serialize the Bolt12RefundContext object into a byte array which can be read by Bolt12RefundContext_read */ -struct LDKCandidateRouteHop CandidateRouteHop_private_hop(struct LDKPrivateHopCandidate a); +struct LDKCVec_u8Z Bolt12RefundContext_write(const struct LDKBolt12RefundContext *NONNULL_PTR obj); /** - * Utility method to constructs a new Blinded-variant CandidateRouteHop + * Read a Bolt12RefundContext from a byte array, created by Bolt12RefundContext_write */ -struct LDKCandidateRouteHop CandidateRouteHop_blinded(struct LDKBlindedPathCandidate a); +struct LDKCResult_Bolt12RefundContextDecodeErrorZ Bolt12RefundContext_read(struct LDKu8slice ser); /** - * Utility method to constructs a new OneHopBlinded-variant CandidateRouteHop + * Frees any resources used by the BlindedMessagePath, if is_owned is set and inner is non-NULL. */ -struct LDKCandidateRouteHop CandidateRouteHop_one_hop_blinded(struct LDKOneHopBlindedPathCandidate a); +void BlindedMessagePath_free(struct LDKBlindedMessagePath this_obj); /** - * Returns the globally unique short channel ID for this hop, if one is known. - * - * This only returns `Some` if the channel is public (either our own, or one we've learned - * from the public network graph), and thus the short channel ID we have for this channel is - * globally unique and identifies this channel in a global namespace. + * Creates a copy of the BlindedMessagePath */ -MUST_USE_RES struct LDKCOption_u64Z CandidateRouteHop_globally_unique_short_channel_id(const struct LDKCandidateRouteHop *NONNULL_PTR this_arg); +struct LDKBlindedMessagePath BlindedMessagePath_clone(const struct LDKBlindedMessagePath *NONNULL_PTR orig); /** - * Returns the required difference in HTLC CLTV expiry between the [`Self::source`] and the - * next-hop for an HTLC taking this hop. - * - * This is the time that the node(s) in this hop have to claim the HTLC on-chain if the - * next-hop goes on chain with a payment preimage. + * Generates a non-cryptographic 64-bit hash of the BlindedMessagePath. */ -MUST_USE_RES uint32_t CandidateRouteHop_cltv_expiry_delta(const struct LDKCandidateRouteHop *NONNULL_PTR this_arg); +uint64_t BlindedMessagePath_hash(const struct LDKBlindedMessagePath *NONNULL_PTR o); /** - * Returns the minimum amount that can be sent over this hop, in millisatoshis. + * Checks if two BlindedMessagePaths 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 uint64_t CandidateRouteHop_htlc_minimum_msat(const struct LDKCandidateRouteHop *NONNULL_PTR this_arg); +bool BlindedMessagePath_eq(const struct LDKBlindedMessagePath *NONNULL_PTR a, const struct LDKBlindedMessagePath *NONNULL_PTR b); /** - * Returns the fees that must be paid to route an HTLC over this channel. + * Serialize the BlindedMessagePath object into a byte array which can be read by BlindedMessagePath_read */ -MUST_USE_RES struct LDKRoutingFees CandidateRouteHop_fees(const struct LDKCandidateRouteHop *NONNULL_PTR this_arg); +struct LDKCVec_u8Z BlindedMessagePath_write(const struct LDKBlindedMessagePath *NONNULL_PTR obj); /** - * Returns the source node id of current hop. - * - * Source node id refers to the node forwarding the HTLC through this hop. - * - * For [`Self::FirstHop`] we return payer's node id. + * Read a BlindedMessagePath from a byte array, created by BlindedMessagePath_write */ -MUST_USE_RES struct LDKNodeId CandidateRouteHop_source(const struct LDKCandidateRouteHop *NONNULL_PTR this_arg); +struct LDKCResult_BlindedMessagePathDecodeErrorZ BlindedMessagePath_read(struct LDKu8slice ser); /** - * Returns the target node id of this hop, if known. - * - * Target node id refers to the node receiving the HTLC after this hop. - * - * For [`Self::Blinded`] we return `None` because the ultimate destination after the blinded - * path is unknown. - * - * For [`Self::OneHopBlinded`] we return `None` because the target is the same as the source, - * and such a return value would be somewhat nonsensical. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Create a one-hop blinded path for a message. */ -MUST_USE_RES struct LDKNodeId CandidateRouteHop_target(const struct LDKCandidateRouteHop *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_BlindedMessagePathNoneZ BlindedMessagePath_one_hop(struct LDKPublicKey recipient_node_id, struct LDKMessageContext context, struct LDKEntropySource entropy_source); /** - * 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 + * Create a path for an onion message, to be forwarded along `node_pks`. The last node + * pubkey in `node_pks` will be the destination node. * - * Note that first_hops (or a relevant inner pointer) may be NULL or all-0s to represent None + * Errors if no hops are provided or if `node_pk`(s) are invalid. */ -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 LDKScoreLookUp *NONNULL_PTR scorer, const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR score_params, const uint8_t (*random_seed_bytes)[32]); +MUST_USE_RES struct LDKCResult_BlindedMessagePathNoneZ BlindedMessagePath_new(struct LDKCVec_MessageForwardNodeZ intermediate_nodes, struct LDKPublicKey recipient_node_id, struct LDKMessageContext context, struct LDKEntropySource entropy_source); /** - * 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. + * Attempts to a use a compact representation for the [`IntroductionNode`] by using a directed + * short channel id from a channel in `network_graph` leading to the introduction node. * - * Re-uses logic from `find_route`, so the restrictions described there also apply here. + * While this may result in a smaller encoding, there is a trade off in that the path may + * become invalid if the channel is closed or hasn't been propagated via gossip. Therefore, + * calling this may not be suitable for long-lived blinded paths. */ -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 BlindedMessagePath_use_compact_introduction_node(struct LDKBlindedMessagePath *NONNULL_PTR this_arg, const struct LDKReadOnlyNetworkGraph *NONNULL_PTR network_graph); /** - * Calls the free function if one is set + * Returns the introduction [`NodeId`] of the blinded path, if it is publicly reachable (i.e., + * it is found in the network graph). + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void ScoreLookUp_free(struct LDKScoreLookUp this_ptr); +MUST_USE_RES struct LDKNodeId BlindedMessagePath_public_introduction_node_id(const struct LDKBlindedMessagePath *NONNULL_PTR this_arg, const struct LDKReadOnlyNetworkGraph *NONNULL_PTR network_graph); /** - * Calls the free function if one is set + * The [`IntroductionNode`] of the blinded path. */ -void ScoreUpdate_free(struct LDKScoreUpdate this_ptr); +MUST_USE_RES struct LDKIntroductionNode BlindedMessagePath_introduction_node(const struct LDKBlindedMessagePath *NONNULL_PTR this_arg); /** - * Calls the free function if one is set + * Used by the [`IntroductionNode`] to decrypt its [`encrypted_payload`] to forward the message. + * + * [`encrypted_payload`]: BlindedHop::encrypted_payload */ -void Score_free(struct LDKScore this_ptr); +MUST_USE_RES struct LDKPublicKey BlindedMessagePath_blinding_point(const struct LDKBlindedMessagePath *NONNULL_PTR this_arg); /** - * Calls the free function if one is set + * The [`BlindedHop`]s within the blinded path. */ -void LockableScore_free(struct LDKLockableScore this_ptr); +MUST_USE_RES struct LDKCVec_BlindedHopZ BlindedMessagePath_blinded_hops(const struct LDKBlindedMessagePath *NONNULL_PTR this_arg); /** - * Calls the free function if one is set + * Advance the blinded onion message path by one hop, making the second hop into the new + * introduction node. + * + * Will only modify `self` when returning `Ok`. */ -void WriteableScore_free(struct LDKWriteableScore this_ptr); +MUST_USE_RES struct LDKCResult_NoneNoneZ BlindedMessagePath_advance_path_by_one(struct LDKBlindedMessagePath *NONNULL_PTR this_arg, const struct LDKNodeSigner *NONNULL_PTR node_signer, const struct LDKNodeIdLookUp *NONNULL_PTR node_id_lookup); /** - * Frees any resources used by the MultiThreadedLockableScore, if is_owned is set and inner is non-NULL. + * Frees any resources used by the NextMessageHop */ -void MultiThreadedLockableScore_free(struct LDKMultiThreadedLockableScore this_obj); +void NextMessageHop_free(struct LDKNextMessageHop 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 + * Creates a copy of the NextMessageHop */ -struct LDKLockableScore MultiThreadedLockableScore_as_LockableScore(const struct LDKMultiThreadedLockableScore *NONNULL_PTR this_arg); +struct LDKNextMessageHop NextMessageHop_clone(const struct LDKNextMessageHop *NONNULL_PTR orig); /** - * Serialize the MultiThreadedLockableScore object into a byte array which can be read by MultiThreadedLockableScore_read + * Utility method to constructs a new NodeId-variant NextMessageHop */ -struct LDKCVec_u8Z MultiThreadedLockableScore_write(const struct LDKMultiThreadedLockableScore *NONNULL_PTR obj); +struct LDKNextMessageHop NextMessageHop_node_id(struct LDKPublicKey a); /** - * 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 + * Utility method to constructs a new ShortChannelId-variant NextMessageHop */ -struct LDKWriteableScore MultiThreadedLockableScore_as_WriteableScore(const struct LDKMultiThreadedLockableScore *NONNULL_PTR this_arg); +struct LDKNextMessageHop NextMessageHop_short_channel_id(uint64_t a); /** - * Creates a new [`MultiThreadedLockableScore`] given an underlying [`Score`]. + * Generates a non-cryptographic 64-bit hash of the NextMessageHop. */ -MUST_USE_RES struct LDKMultiThreadedLockableScore MultiThreadedLockableScore_new(struct LDKScore score); +uint64_t NextMessageHop_hash(const struct LDKNextMessageHop *NONNULL_PTR o); /** - * Frees any resources used by the MultiThreadedScoreLockRead, if is_owned is set and inner is non-NULL. + * Checks if two NextMessageHops contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -void MultiThreadedScoreLockRead_free(struct LDKMultiThreadedScoreLockRead this_obj); +bool NextMessageHop_eq(const struct LDKNextMessageHop *NONNULL_PTR a, const struct LDKNextMessageHop *NONNULL_PTR b); /** - * Frees any resources used by the MultiThreadedScoreLockWrite, if is_owned is set and inner is non-NULL. + * Frees any resources used by the MessageForwardNode, if is_owned is set and inner is non-NULL. */ -void MultiThreadedScoreLockWrite_free(struct LDKMultiThreadedScoreLockWrite this_obj); +void MessageForwardNode_free(struct LDKMessageForwardNode this_obj); /** - * Constructs a new ScoreLookUp which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned ScoreLookUp must be freed before this_arg is + * This node's pubkey. */ -struct LDKScoreLookUp MultiThreadedScoreLockRead_as_ScoreLookUp(const struct LDKMultiThreadedScoreLockRead *NONNULL_PTR this_arg); +struct LDKPublicKey MessageForwardNode_get_node_id(const struct LDKMessageForwardNode *NONNULL_PTR this_ptr); /** - * Serialize the MultiThreadedScoreLockWrite object into a byte array which can be read by MultiThreadedScoreLockWrite_read + * This node's pubkey. */ -struct LDKCVec_u8Z MultiThreadedScoreLockWrite_write(const struct LDKMultiThreadedScoreLockWrite *NONNULL_PTR obj); +void MessageForwardNode_set_node_id(struct LDKMessageForwardNode *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Constructs a new ScoreUpdate which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned ScoreUpdate must be freed before this_arg is + * The channel between `node_id` and the next hop. If set, the constructed [`BlindedHop`]'s + * `encrypted_payload` will use this instead of the next [`MessageForwardNode::node_id`] for a + * more compact representation. */ -struct LDKScoreUpdate MultiThreadedScoreLockWrite_as_ScoreUpdate(const struct LDKMultiThreadedScoreLockWrite *NONNULL_PTR this_arg); +struct LDKCOption_u64Z MessageForwardNode_get_short_channel_id(const struct LDKMessageForwardNode *NONNULL_PTR this_ptr); /** - * Frees any resources used by the ChannelUsage, if is_owned is set and inner is non-NULL. + * The channel between `node_id` and the next hop. If set, the constructed [`BlindedHop`]'s + * `encrypted_payload` will use this instead of the next [`MessageForwardNode::node_id`] for a + * more compact representation. */ -void ChannelUsage_free(struct LDKChannelUsage this_obj); +void MessageForwardNode_set_short_channel_id(struct LDKMessageForwardNode *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); /** - * The amount to send through the channel, denominated in millisatoshis. + * Constructs a new MessageForwardNode given each field */ -uint64_t ChannelUsage_get_amount_msat(const struct LDKChannelUsage *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKMessageForwardNode MessageForwardNode_new(struct LDKPublicKey node_id_arg, struct LDKCOption_u64Z short_channel_id_arg); /** - * The amount to send through the channel, denominated in millisatoshis. + * Creates a copy of the MessageForwardNode */ -void ChannelUsage_set_amount_msat(struct LDKChannelUsage *NONNULL_PTR this_ptr, uint64_t val); +struct LDKMessageForwardNode MessageForwardNode_clone(const struct LDKMessageForwardNode *NONNULL_PTR orig); /** - * Total amount, denominated in millisatoshis, already allocated to send through the channel - * as part of a multi-path payment. + * Generates a non-cryptographic 64-bit hash of the MessageForwardNode. */ -uint64_t ChannelUsage_get_inflight_htlc_msat(const struct LDKChannelUsage *NONNULL_PTR this_ptr); +uint64_t MessageForwardNode_hash(const struct LDKMessageForwardNode *NONNULL_PTR o); /** - * Total amount, denominated in millisatoshis, already allocated to send through the channel - * as part of a multi-path payment. + * Checks if two MessageForwardNodes 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 ChannelUsage_set_inflight_htlc_msat(struct LDKChannelUsage *NONNULL_PTR this_ptr, uint64_t val); +bool MessageForwardNode_eq(const struct LDKMessageForwardNode *NONNULL_PTR a, const struct LDKMessageForwardNode *NONNULL_PTR b); /** - * The effective capacity of the channel. + * Frees any resources used by the MessageContext */ -struct LDKEffectiveCapacity ChannelUsage_get_effective_capacity(const struct LDKChannelUsage *NONNULL_PTR this_ptr); +void MessageContext_free(struct LDKMessageContext this_ptr); /** - * The effective capacity of the channel. + * Creates a copy of the MessageContext */ -void ChannelUsage_set_effective_capacity(struct LDKChannelUsage *NONNULL_PTR this_ptr, struct LDKEffectiveCapacity val); +struct LDKMessageContext MessageContext_clone(const struct LDKMessageContext *NONNULL_PTR orig); /** - * Constructs a new ChannelUsage given each field + * Utility method to constructs a new Offers-variant MessageContext */ -MUST_USE_RES struct LDKChannelUsage ChannelUsage_new(uint64_t amount_msat_arg, uint64_t inflight_htlc_msat_arg, struct LDKEffectiveCapacity effective_capacity_arg); +struct LDKMessageContext MessageContext_offers(struct LDKOffersContext a); /** - * Creates a copy of the ChannelUsage + * Utility method to constructs a new Custom-variant MessageContext */ -struct LDKChannelUsage ChannelUsage_clone(const struct LDKChannelUsage *NONNULL_PTR orig); +struct LDKMessageContext MessageContext_custom(struct LDKCVec_u8Z a); /** - * Frees any resources used by the FixedPenaltyScorer, if is_owned is set and inner is non-NULL. + * Frees any resources used by the OffersContext */ -void FixedPenaltyScorer_free(struct LDKFixedPenaltyScorer this_obj); +void OffersContext_free(struct LDKOffersContext this_ptr); /** - * Creates a copy of the FixedPenaltyScorer + * Creates a copy of the OffersContext */ -struct LDKFixedPenaltyScorer FixedPenaltyScorer_clone(const struct LDKFixedPenaltyScorer *NONNULL_PTR orig); +struct LDKOffersContext OffersContext_clone(const struct LDKOffersContext *NONNULL_PTR orig); /** - * Creates a new scorer using `penalty_msat`. + * Utility method to constructs a new InvoiceRequest-variant OffersContext */ -MUST_USE_RES struct LDKFixedPenaltyScorer FixedPenaltyScorer_with_penalty(uint64_t penalty_msat); +struct LDKOffersContext OffersContext_invoice_request(struct LDKNonce nonce); /** - * Constructs a new ScoreLookUp which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned ScoreLookUp must be freed before this_arg is + * Utility method to constructs a new OutboundPayment-variant OffersContext */ -struct LDKScoreLookUp FixedPenaltyScorer_as_ScoreLookUp(const struct LDKFixedPenaltyScorer *NONNULL_PTR this_arg); +struct LDKOffersContext OffersContext_outbound_payment(struct LDKThirtyTwoBytes payment_id, struct LDKNonce nonce, struct LDKThirtyTwoBytes hmac); /** - * Constructs a new ScoreUpdate which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned ScoreUpdate must be freed before this_arg is + * Utility method to constructs a new InboundPayment-variant OffersContext */ -struct LDKScoreUpdate FixedPenaltyScorer_as_ScoreUpdate(const struct LDKFixedPenaltyScorer *NONNULL_PTR this_arg); +struct LDKOffersContext OffersContext_inbound_payment(struct LDKThirtyTwoBytes payment_hash); /** - * Serialize the FixedPenaltyScorer object into a byte array which can be read by FixedPenaltyScorer_read + * Checks if two OffersContexts contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -struct LDKCVec_u8Z FixedPenaltyScorer_write(const struct LDKFixedPenaltyScorer *NONNULL_PTR obj); +bool OffersContext_eq(const struct LDKOffersContext *NONNULL_PTR a, const struct LDKOffersContext *NONNULL_PTR b); /** - * Read a FixedPenaltyScorer from a byte array, created by FixedPenaltyScorer_write + * Serialize the MessageContext object into a byte array which can be read by MessageContext_read */ -struct LDKCResult_FixedPenaltyScorerDecodeErrorZ FixedPenaltyScorer_read(struct LDKu8slice ser, uint64_t arg); +struct LDKCVec_u8Z MessageContext_write(const struct LDKMessageContext *NONNULL_PTR obj); /** - * Frees any resources used by the ProbabilisticScorer, if is_owned is set and inner is non-NULL. + * Read a MessageContext from a byte array, created by MessageContext_write */ -void ProbabilisticScorer_free(struct LDKProbabilisticScorer this_obj); +struct LDKCResult_MessageContextDecodeErrorZ MessageContext_read(struct LDKu8slice ser); /** - * Frees any resources used by the ProbabilisticScoringFeeParameters, if is_owned is set and inner is non-NULL. + * Serialize the OffersContext object into a byte array which can be read by OffersContext_read */ -void ProbabilisticScoringFeeParameters_free(struct LDKProbabilisticScoringFeeParameters this_obj); +struct LDKCVec_u8Z OffersContext_write(const struct LDKOffersContext *NONNULL_PTR obj); /** - * A fixed penalty in msats to apply to each channel. - * - * Default value: 500 msat + * Read a OffersContext from a byte array, created by OffersContext_write */ -uint64_t ProbabilisticScoringFeeParameters_get_base_penalty_msat(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr); +struct LDKCResult_OffersContextDecodeErrorZ OffersContext_read(struct LDKu8slice ser); /** - * A fixed penalty in msats to apply to each channel. - * - * Default value: 500 msat + * Frees any resources used by the FundingInfo */ -void ProbabilisticScoringFeeParameters_set_base_penalty_msat(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr, uint64_t val); +void FundingInfo_free(struct LDKFundingInfo this_ptr); /** - * A multiplier used with the total amount flowing over a channel 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 total amount flowing over a channel (i.e. the payment - * amount plus the amount of any other HTLCs flowing we sent over the same channel). - * - * ie `base_penalty_amount_multiplier_msat * amount_msat / 2^30` - * - * Default value: 8,192 msat - * - * [`base_penalty_msat`]: Self::base_penalty_msat + * Creates a copy of the FundingInfo */ -uint64_t ProbabilisticScoringFeeParameters_get_base_penalty_amount_multiplier_msat(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr); +struct LDKFundingInfo FundingInfo_clone(const struct LDKFundingInfo *NONNULL_PTR orig); /** - * A multiplier used with the total amount flowing over a channel 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 total amount flowing over a channel (i.e. the payment - * amount plus the amount of any other HTLCs flowing we sent over the same channel). - * - * ie `base_penalty_amount_multiplier_msat * amount_msat / 2^30` - * - * Default value: 8,192 msat - * - * [`base_penalty_msat`]: Self::base_penalty_msat + * Utility method to constructs a new Tx-variant FundingInfo */ -void ProbabilisticScoringFeeParameters_set_base_penalty_amount_multiplier_msat(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr, uint64_t val); +struct LDKFundingInfo FundingInfo_tx(struct LDKTransaction transaction); /** - * 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 + * Utility method to constructs a new OutPoint-variant FundingInfo */ -uint64_t ProbabilisticScoringFeeParameters_get_liquidity_penalty_multiplier_msat(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr); +struct LDKFundingInfo FundingInfo_out_point(struct LDKOutPoint outpoint); /** - * 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 + * Checks if two FundingInfos contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -void ProbabilisticScoringFeeParameters_set_liquidity_penalty_multiplier_msat(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr, uint64_t val); +bool FundingInfo_eq(const struct LDKFundingInfo *NONNULL_PTR a, const struct LDKFundingInfo *NONNULL_PTR b); /** - * A multiplier used in conjunction with the total amount flowing over a channel 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 amount flowing over this channel, 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 FundingInfo object into a byte array which can be read by FundingInfo_read */ -uint64_t ProbabilisticScoringFeeParameters_get_liquidity_penalty_amount_multiplier_msat(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z FundingInfo_write(const struct LDKFundingInfo *NONNULL_PTR obj); /** - * A multiplier used in conjunction with the total amount flowing over a channel 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 amount flowing over this channel, 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 FundingInfo from a byte array, created by FundingInfo_write */ -void ProbabilisticScoringFeeParameters_set_liquidity_penalty_amount_multiplier_msat(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr, uint64_t val); +struct LDKCResult_FundingInfoDecodeErrorZ FundingInfo_read(struct LDKu8slice ser); /** - * 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 PaymentPurpose */ -uint64_t ProbabilisticScoringFeeParameters_get_historical_liquidity_penalty_multiplier_msat(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr); +void PaymentPurpose_free(struct LDKPaymentPurpose this_ptr); /** - * 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 + * Creates a copy of the PaymentPurpose */ -void ProbabilisticScoringFeeParameters_set_historical_liquidity_penalty_multiplier_msat(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr, uint64_t val); +struct LDKPaymentPurpose PaymentPurpose_clone(const struct LDKPaymentPurpose *NONNULL_PTR orig); /** - * A multiplier used in conjunction with the total amount flowing over a channel 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 `2^20`ths - * of the amount flowing over this channel, 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 + * Utility method to constructs a new Bolt11InvoicePayment-variant PaymentPurpose */ -uint64_t ProbabilisticScoringFeeParameters_get_historical_liquidity_penalty_amount_multiplier_msat(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr); +struct LDKPaymentPurpose PaymentPurpose_bolt11_invoice_payment(struct LDKCOption_ThirtyTwoBytesZ payment_preimage, struct LDKThirtyTwoBytes payment_secret); /** - * A multiplier used in conjunction with the total amount flowing over a channel 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 `2^20`ths - * of the amount flowing over this channel, 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 + * Utility method to constructs a new Bolt12OfferPayment-variant PaymentPurpose */ -void ProbabilisticScoringFeeParameters_set_historical_liquidity_penalty_amount_multiplier_msat(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr, uint64_t val); +struct LDKPaymentPurpose PaymentPurpose_bolt12_offer_payment(struct LDKCOption_ThirtyTwoBytesZ payment_preimage, struct LDKThirtyTwoBytes payment_secret, struct LDKBolt12OfferContext payment_context); /** - * 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 + * Utility method to constructs a new Bolt12RefundPayment-variant PaymentPurpose */ -uint64_t ProbabilisticScoringFeeParameters_get_anti_probing_penalty_msat(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr); +struct LDKPaymentPurpose PaymentPurpose_bolt12_refund_payment(struct LDKCOption_ThirtyTwoBytesZ payment_preimage, struct LDKThirtyTwoBytes payment_secret, struct LDKBolt12RefundContext payment_context); /** - * 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 + * Utility method to constructs a new SpontaneousPayment-variant PaymentPurpose */ -void ProbabilisticScoringFeeParameters_set_anti_probing_penalty_msat(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr, uint64_t val); +struct LDKPaymentPurpose PaymentPurpose_spontaneous_payment(struct LDKThirtyTwoBytes a); /** - * This penalty is applied when the total amount flowing over a channel exceeds our current - * estimate of the channel's available liquidity. The total amount is the amount of the - * current HTLC plus any HTLCs which we've sent over the same channel. - * - * 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 + * Checks if two PaymentPurposes contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -uint64_t ProbabilisticScoringFeeParameters_get_considered_impossible_penalty_msat(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr); +bool PaymentPurpose_eq(const struct LDKPaymentPurpose *NONNULL_PTR a, const struct LDKPaymentPurpose *NONNULL_PTR b); /** - * This penalty is applied when the total amount flowing over a channel exceeds our current - * estimate of the channel's available liquidity. The total amount is the amount of the - * current HTLC plus any HTLCs which we've sent over the same channel. - * - * 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 + * Returns the preimage for this payment, if it is known. */ -void ProbabilisticScoringFeeParameters_set_considered_impossible_penalty_msat(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr, uint64_t val); +MUST_USE_RES struct LDKCOption_ThirtyTwoBytesZ PaymentPurpose_preimage(const struct LDKPaymentPurpose *NONNULL_PTR this_arg); /** - * In order to calculate most of the scores above, we must first convert a lower and upper - * bound on the available liquidity in a channel into the probability that we think a payment - * will succeed. That probability is derived from a Probability Density Function for where we - * think the liquidity in a channel likely lies, given such bounds. - * - * If this flag is set, that PDF is simply a constant - we assume that the actual available - * liquidity in a channel is just as likely to be at any point between our lower and upper - * bounds. - * - * If this flag is *not* set, that PDF is `(x - 0.5*capacity) ^ 2`. That is, we use an - * exponential curve which expects the liquidity of a channel to lie \"at the edges\". This - * matches experimental results - most routing nodes do not aggressively rebalance their - * channels and flows in the network are often unbalanced, leaving liquidity usually - * unavailable. - * - * Thus, for the \"best\" routes, leave this flag `false`. However, the flag does imply a number - * of floating-point multiplications in the hottest routing code, which may lead to routing - * performance degradation on some machines. - * - * Default value: false + * Serialize the PaymentPurpose object into a byte array which can be read by PaymentPurpose_read */ -bool ProbabilisticScoringFeeParameters_get_linear_success_probability(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z PaymentPurpose_write(const struct LDKPaymentPurpose *NONNULL_PTR obj); /** - * In order to calculate most of the scores above, we must first convert a lower and upper - * bound on the available liquidity in a channel into the probability that we think a payment - * will succeed. That probability is derived from a Probability Density Function for where we - * think the liquidity in a channel likely lies, given such bounds. - * - * If this flag is set, that PDF is simply a constant - we assume that the actual available - * liquidity in a channel is just as likely to be at any point between our lower and upper - * bounds. - * - * If this flag is *not* set, that PDF is `(x - 0.5*capacity) ^ 2`. That is, we use an - * exponential curve which expects the liquidity of a channel to lie \"at the edges\". This - * matches experimental results - most routing nodes do not aggressively rebalance their - * channels and flows in the network are often unbalanced, leaving liquidity usually - * unavailable. - * - * Thus, for the \"best\" routes, leave this flag `false`. However, the flag does imply a number - * of floating-point multiplications in the hottest routing code, which may lead to routing - * performance degradation on some machines. - * - * Default value: false + * Read a PaymentPurpose from a byte array, created by PaymentPurpose_write */ -void ProbabilisticScoringFeeParameters_set_linear_success_probability(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr, bool val); +struct LDKCResult_PaymentPurposeDecodeErrorZ PaymentPurpose_read(struct LDKu8slice ser); /** - * Creates a copy of the ProbabilisticScoringFeeParameters + * Frees any resources used by the ClaimedHTLC, if is_owned is set and inner is non-NULL. */ -struct LDKProbabilisticScoringFeeParameters ProbabilisticScoringFeeParameters_clone(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR orig); +void ClaimedHTLC_free(struct LDKClaimedHTLC this_obj); /** - * Creates a "default" ProbabilisticScoringFeeParameters. See struct and individual field documentaiton for details on which values are used. + * The `channel_id` of the channel over which the HTLC was received. */ -MUST_USE_RES struct LDKProbabilisticScoringFeeParameters ProbabilisticScoringFeeParameters_default(void); +struct LDKChannelId ClaimedHTLC_get_channel_id(const struct LDKClaimedHTLC *NONNULL_PTR this_ptr); /** - * Marks the node with the given `node_id` as banned, - * i.e it will be avoided during path finding. + * The `channel_id` of the channel over which the HTLC was received. */ -void ProbabilisticScoringFeeParameters_add_banned(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_arg, const struct LDKNodeId *NONNULL_PTR node_id); +void ClaimedHTLC_set_channel_id(struct LDKClaimedHTLC *NONNULL_PTR this_ptr, struct LDKChannelId val); /** - * Marks all nodes in the given list as banned, i.e., - * they will be avoided during path finding. + * The `user_channel_id` of the channel over which the HTLC was received. This is the 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. + * + * This field will be zero for a payment that was serialized prior to LDK version 0.0.117. (This + * should only happen in the case that a payment was claimable prior to LDK version 0.0.117, but + * was not actually claimed until after upgrading.) + * + * [`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 */ -void ProbabilisticScoringFeeParameters_add_banned_from_list(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_arg, struct LDKCVec_NodeIdZ node_ids); +struct LDKU128 ClaimedHTLC_get_user_channel_id(const struct LDKClaimedHTLC *NONNULL_PTR this_ptr); /** - * Removes the node with the given `node_id` from the list of nodes to avoid. + * The `user_channel_id` of the channel over which the HTLC was received. This is the 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. + * + * This field will be zero for a payment that was serialized prior to LDK version 0.0.117. (This + * should only happen in the case that a payment was claimable prior to LDK version 0.0.117, but + * was not actually claimed until after upgrading.) + * + * [`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 */ -void ProbabilisticScoringFeeParameters_remove_banned(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_arg, const struct LDKNodeId *NONNULL_PTR node_id); +void ClaimedHTLC_set_user_channel_id(struct LDKClaimedHTLC *NONNULL_PTR this_ptr, struct LDKU128 val); /** - * Sets a manual penalty for the given node. + * The block height at which this HTLC expires. */ -void ProbabilisticScoringFeeParameters_set_manual_penalty(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_arg, const struct LDKNodeId *NONNULL_PTR node_id, uint64_t penalty); +uint32_t ClaimedHTLC_get_cltv_expiry(const struct LDKClaimedHTLC *NONNULL_PTR this_ptr); /** - * Removes the node with the given `node_id` from the list of manual penalties. + * The block height at which this HTLC expires. */ -void ProbabilisticScoringFeeParameters_remove_manual_penalty(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_arg, const struct LDKNodeId *NONNULL_PTR node_id); +void ClaimedHTLC_set_cltv_expiry(struct LDKClaimedHTLC *NONNULL_PTR this_ptr, uint32_t val); /** - * Clears the list of manual penalties that are applied during path finding. + * The amount (in msats) of this part of an MPP. */ -void ProbabilisticScoringFeeParameters_clear_manual_penalties(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_arg); +uint64_t ClaimedHTLC_get_value_msat(const struct LDKClaimedHTLC *NONNULL_PTR this_ptr); /** - * Frees any resources used by the ProbabilisticScoringDecayParameters, if is_owned is set and inner is non-NULL. + * The amount (in msats) of this part of an MPP. */ -void ProbabilisticScoringDecayParameters_free(struct LDKProbabilisticScoringDecayParameters this_obj); +void ClaimedHTLC_set_value_msat(struct LDKClaimedHTLC *NONNULL_PTR this_ptr, uint64_t 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. - * 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 + * The extra fee our counterparty skimmed off the top of this HTLC, if any. * - * [`historical_estimated_channel_liquidity_probabilities`]: ProbabilisticScorer::historical_estimated_channel_liquidity_probabilities + * This value will always be 0 for [`ClaimedHTLC`]s serialized with LDK versions prior to + * 0.0.119. */ -uint64_t ProbabilisticScoringDecayParameters_get_historical_no_updates_half_life(const struct LDKProbabilisticScoringDecayParameters *NONNULL_PTR this_ptr); +uint64_t ClaimedHTLC_get_counterparty_skimmed_fee_msat(const struct LDKClaimedHTLC *NONNULL_PTR this_ptr); /** - * 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 + * The extra fee our counterparty skimmed off the top of this HTLC, if any. * - * [`historical_estimated_channel_liquidity_probabilities`]: ProbabilisticScorer::historical_estimated_channel_liquidity_probabilities + * This value will always be 0 for [`ClaimedHTLC`]s serialized with LDK versions prior to + * 0.0.119. */ -void ProbabilisticScoringDecayParameters_set_historical_no_updates_half_life(struct LDKProbabilisticScoringDecayParameters *NONNULL_PTR this_ptr, uint64_t val); +void ClaimedHTLC_set_counterparty_skimmed_fee_msat(struct LDKClaimedHTLC *NONNULL_PTR this_ptr, uint64_t 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. + * Constructs a new ClaimedHTLC given each field */ -uint64_t ProbabilisticScoringDecayParameters_get_liquidity_offset_half_life(const struct LDKProbabilisticScoringDecayParameters *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKClaimedHTLC ClaimedHTLC_new(struct LDKChannelId channel_id_arg, struct LDKU128 user_channel_id_arg, uint32_t cltv_expiry_arg, uint64_t value_msat_arg, uint64_t counterparty_skimmed_fee_msat_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. + * Creates a copy of the ClaimedHTLC */ -void ProbabilisticScoringDecayParameters_set_liquidity_offset_half_life(struct LDKProbabilisticScoringDecayParameters *NONNULL_PTR this_ptr, uint64_t val); +struct LDKClaimedHTLC ClaimedHTLC_clone(const struct LDKClaimedHTLC *NONNULL_PTR orig); /** - * Constructs a new ProbabilisticScoringDecayParameters given each field + * Checks if two ClaimedHTLCs 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 LDKProbabilisticScoringDecayParameters ProbabilisticScoringDecayParameters_new(uint64_t historical_no_updates_half_life_arg, uint64_t liquidity_offset_half_life_arg); +bool ClaimedHTLC_eq(const struct LDKClaimedHTLC *NONNULL_PTR a, const struct LDKClaimedHTLC *NONNULL_PTR b); /** - * Creates a copy of the ProbabilisticScoringDecayParameters + * Serialize the ClaimedHTLC object into a byte array which can be read by ClaimedHTLC_read */ -struct LDKProbabilisticScoringDecayParameters ProbabilisticScoringDecayParameters_clone(const struct LDKProbabilisticScoringDecayParameters *NONNULL_PTR orig); +struct LDKCVec_u8Z ClaimedHTLC_write(const struct LDKClaimedHTLC *NONNULL_PTR obj); /** - * Creates a "default" ProbabilisticScoringDecayParameters. See struct and individual field documentaiton for details on which values are used. + * Read a ClaimedHTLC from a byte array, created by ClaimedHTLC_write */ -MUST_USE_RES struct LDKProbabilisticScoringDecayParameters ProbabilisticScoringDecayParameters_default(void); +struct LDKCResult_ClaimedHTLCDecodeErrorZ ClaimedHTLC_read(struct LDKu8slice ser); /** - * Creates a new scorer using the given scoring parameters for sending payments from a node - * through a network graph. + * Frees any resources used by the PathFailure */ -MUST_USE_RES struct LDKProbabilisticScorer ProbabilisticScorer_new(struct LDKProbabilisticScoringDecayParameters decay_params, const struct LDKNetworkGraph *NONNULL_PTR network_graph, struct LDKLogger logger); +void PathFailure_free(struct LDKPathFailure this_ptr); /** - * 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. + * Creates a copy of the PathFailure */ -void ProbabilisticScorer_debug_log_liquidity_stats(const struct LDKProbabilisticScorer *NONNULL_PTR this_arg); +struct LDKPathFailure PathFailure_clone(const struct LDKPathFailure *NONNULL_PTR orig); /** - * Query the estimated minimum and maximum liquidity available for sending a payment over the - * channel with `scid` towards the given `target` node. + * Utility method to constructs a new InitialSend-variant PathFailure */ -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); +struct LDKPathFailure PathFailure_initial_send(struct LDKAPIError err); /** - * 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 32 buckets. The first set describes the lower-bound liquidity history, - * the second set describes the upper-bound liquidity history. Each bucket describes the - * relative frequency at which we've seen a liquidity bound in the bucket's range 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. - * - * Note that the range of each bucket varies by its location to provide more granular results - * at the edges of a channel's capacity, where it is more likely to sit. - * - * When scoring, the estimated probability that an upper-/lower-bound lies in a given bucket - * is calculated by dividing that bucket's value with the total value of all buckets. - * - * For example, using a lower bucket count for illustrative purposes, a value of - * `[0, 0, 0, ..., 0, 32]` indicates that we believe the probability of a bound being very - * close to the channel's capacity to be 100%, and have never (recently) seen it in any other - * bucket. A value of `[31, 0, 0, ..., 0, 0, 32]` indicates we've seen the bound being both - * in the top and bottom bucket, and roughly with similar (recent) frequency. - * - * Because the datapoints are decayed slowly over time, values will eventually return to - * `Some(([0; 32], [0; 32]))` or `None` if no data remains for a channel. - * - * In order to fetch a single success probability from the buckets provided here, as used in - * the scoring model, see [`Self::historical_estimated_payment_success_probability`]. + * Utility method to constructs a new OnPath-variant PathFailure */ -MUST_USE_RES struct LDKCOption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ ProbabilisticScorer_historical_estimated_channel_liquidity_probabilities(const struct LDKProbabilisticScorer *NONNULL_PTR this_arg, uint64_t scid, const struct LDKNodeId *NONNULL_PTR target); +struct LDKPathFailure PathFailure_on_path(struct LDKCOption_NetworkUpdateZ network_update); /** - * Query the probability of payment success sending the given `amount_msat` over the channel - * with `scid` towards the given `target` node, based on the historical estimated liquidity - * bounds. - * - * These are the same bounds as returned by - * [`Self::historical_estimated_channel_liquidity_probabilities`] (but not those returned by - * [`Self::estimated_channel_liquidity_range`]). + * Checks if two PathFailures contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -MUST_USE_RES struct LDKCOption_f64Z ProbabilisticScorer_historical_estimated_payment_success_probability(const struct LDKProbabilisticScorer *NONNULL_PTR this_arg, uint64_t scid, const struct LDKNodeId *NONNULL_PTR target, uint64_t amount_msat, const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR params); +bool PathFailure_eq(const struct LDKPathFailure *NONNULL_PTR a, const struct LDKPathFailure *NONNULL_PTR b); /** - * Constructs a new ScoreLookUp which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned ScoreLookUp must be freed before this_arg is + * Serialize the PathFailure object into a byte array which can be read by PathFailure_read */ -struct LDKScoreLookUp ProbabilisticScorer_as_ScoreLookUp(const struct LDKProbabilisticScorer *NONNULL_PTR this_arg); +struct LDKCVec_u8Z PathFailure_write(const struct LDKPathFailure *NONNULL_PTR obj); /** - * Constructs a new ScoreUpdate which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned ScoreUpdate must be freed before this_arg is + * Read a PathFailure from a byte array, created by PathFailure_write */ -struct LDKScoreUpdate ProbabilisticScorer_as_ScoreUpdate(const struct LDKProbabilisticScorer *NONNULL_PTR this_arg); +struct LDKCResult_COption_PathFailureZDecodeErrorZ PathFailure_read(struct LDKu8slice ser); /** - * 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 + * Frees any resources used by the ClosureReason */ -struct LDKScore ProbabilisticScorer_as_Score(const struct LDKProbabilisticScorer *NONNULL_PTR this_arg); +void ClosureReason_free(struct LDKClosureReason this_ptr); /** - * Serialize the ProbabilisticScorer object into a byte array which can be read by ProbabilisticScorer_read + * Creates a copy of the ClosureReason */ -struct LDKCVec_u8Z ProbabilisticScorer_write(const struct LDKProbabilisticScorer *NONNULL_PTR obj); +struct LDKClosureReason ClosureReason_clone(const struct LDKClosureReason *NONNULL_PTR orig); /** - * Read a ProbabilisticScorer from a byte array, created by ProbabilisticScorer_write + * Utility method to constructs a new CounterpartyForceClosed-variant ClosureReason */ -struct LDKCResult_ProbabilisticScorerDecodeErrorZ ProbabilisticScorer_read(struct LDKu8slice ser, struct LDKProbabilisticScoringDecayParameters arg_a, const struct LDKNetworkGraph *NONNULL_PTR arg_b, struct LDKLogger arg_c); +struct LDKClosureReason ClosureReason_counterparty_force_closed(struct LDKUntrustedString peer_msg); /** - * Frees any resources used by the DelayedPaymentOutputDescriptor, if is_owned is set and inner is non-NULL. + * Utility method to constructs a new HolderForceClosed-variant ClosureReason */ -void DelayedPaymentOutputDescriptor_free(struct LDKDelayedPaymentOutputDescriptor this_obj); +struct LDKClosureReason ClosureReason_holder_force_closed(struct LDKCOption_boolZ broadcasted_latest_txn); /** - * The outpoint which is spendable. + * Utility method to constructs a new LegacyCooperativeClosure-variant ClosureReason */ -struct LDKOutPoint DelayedPaymentOutputDescriptor_get_outpoint(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); +struct LDKClosureReason ClosureReason_legacy_cooperative_closure(void); /** - * The outpoint which is spendable. + * Utility method to constructs a new CounterpartyInitiatedCooperativeClosure-variant ClosureReason */ -void DelayedPaymentOutputDescriptor_set_outpoint(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKOutPoint val); +struct LDKClosureReason ClosureReason_counterparty_initiated_cooperative_closure(void); /** - * Per commitment point to derive the delayed payment key by key holder. + * Utility method to constructs a new LocallyInitiatedCooperativeClosure-variant ClosureReason */ -struct LDKPublicKey DelayedPaymentOutputDescriptor_get_per_commitment_point(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); +struct LDKClosureReason ClosureReason_locally_initiated_cooperative_closure(void); /** - * Per commitment point to derive the delayed payment key by key holder. + * Utility method to constructs a new CommitmentTxConfirmed-variant ClosureReason */ -void DelayedPaymentOutputDescriptor_set_per_commitment_point(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKPublicKey val); +struct LDKClosureReason ClosureReason_commitment_tx_confirmed(void); /** - * The `nSequence` value which must be set in the spending input to satisfy the `OP_CSV` in - * the witness_script. + * Utility method to constructs a new FundingTimedOut-variant ClosureReason */ -uint16_t DelayedPaymentOutputDescriptor_get_to_self_delay(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); +struct LDKClosureReason ClosureReason_funding_timed_out(void); /** - * The `nSequence` value which must be set in the spending input to satisfy the `OP_CSV` in - * the witness_script. + * Utility method to constructs a new ProcessingError-variant ClosureReason */ -void DelayedPaymentOutputDescriptor_set_to_self_delay(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, uint16_t val); +struct LDKClosureReason ClosureReason_processing_error(struct LDKStr err); /** - * The output which is referenced by the given outpoint. + * Utility method to constructs a new DisconnectedPeer-variant ClosureReason */ -struct LDKTxOut DelayedPaymentOutputDescriptor_get_output(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); +struct LDKClosureReason ClosureReason_disconnected_peer(void); /** - * The output which is referenced by the given outpoint. + * Utility method to constructs a new OutdatedChannelManager-variant ClosureReason */ -void DelayedPaymentOutputDescriptor_set_output(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKTxOut val); +struct LDKClosureReason ClosureReason_outdated_channel_manager(void); /** - * The revocation point specific to the commitment transaction which was broadcast. Used to - * derive the witnessScript for this output. + * Utility method to constructs a new CounterpartyCoopClosedUnfundedChannel-variant ClosureReason */ -struct LDKRevocationKey DelayedPaymentOutputDescriptor_get_revocation_pubkey(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); +struct LDKClosureReason ClosureReason_counterparty_coop_closed_unfunded_channel(void); /** - * The revocation point specific to the commitment transaction which was broadcast. Used to - * derive the witnessScript for this output. + * Utility method to constructs a new FundingBatchClosure-variant ClosureReason */ -void DelayedPaymentOutputDescriptor_set_revocation_pubkey(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKRevocationKey val); +struct LDKClosureReason ClosureReason_funding_batch_closure(void); /** - * 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. + * Utility method to constructs a new HTLCsTimedOut-variant ClosureReason */ -const uint8_t (*DelayedPaymentOutputDescriptor_get_channel_keys_id(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr))[32]; +struct LDKClosureReason ClosureReason_htlcs_timed_out(void); /** - * 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. + * Utility method to constructs a new PeerFeerateTooLow-variant ClosureReason */ -void DelayedPaymentOutputDescriptor_set_channel_keys_id(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKClosureReason ClosureReason_peer_feerate_too_low(uint32_t peer_feerate_sat_per_kw, uint32_t required_feerate_sat_per_kw); /** - * The value of the channel which this output originated from, possibly indirectly. + * Checks if two ClosureReasons contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -uint64_t DelayedPaymentOutputDescriptor_get_channel_value_satoshis(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); +bool ClosureReason_eq(const struct LDKClosureReason *NONNULL_PTR a, const struct LDKClosureReason *NONNULL_PTR b); /** - * The value of the channel which this output originated from, possibly indirectly. + * Get the string representation of a ClosureReason object */ -void DelayedPaymentOutputDescriptor_set_channel_value_satoshis(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, uint64_t val); +struct LDKStr ClosureReason_to_str(const struct LDKClosureReason *NONNULL_PTR o); /** - * The channel public keys and other parameters needed to generate a spending transaction or - * to provide to a re-derived signer through [`ChannelSigner::provide_channel_parameters`]. - * - * Added as optional, but always `Some` if the descriptor was produced in v0.0.123 or later. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Serialize the ClosureReason object into a byte array which can be read by ClosureReason_read */ -struct LDKChannelTransactionParameters DelayedPaymentOutputDescriptor_get_channel_transaction_parameters(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z ClosureReason_write(const struct LDKClosureReason *NONNULL_PTR obj); /** - * The channel public keys and other parameters needed to generate a spending transaction or - * to provide to a re-derived signer through [`ChannelSigner::provide_channel_parameters`]. - * - * Added as optional, but always `Some` if the descriptor was produced in v0.0.123 or later. - * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * Read a ClosureReason from a byte array, created by ClosureReason_write */ -void DelayedPaymentOutputDescriptor_set_channel_transaction_parameters(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKChannelTransactionParameters val); +struct LDKCResult_COption_ClosureReasonZDecodeErrorZ ClosureReason_read(struct LDKu8slice ser); /** - * Constructs a new DelayedPaymentOutputDescriptor given each field - * - * Note that channel_transaction_parameters_arg (or a relevant inner pointer) may be NULL or all-0s to represent None + * Frees any resources used by the HTLCDestination */ -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 LDKRevocationKey revocation_pubkey_arg, struct LDKThirtyTwoBytes channel_keys_id_arg, uint64_t channel_value_satoshis_arg, struct LDKChannelTransactionParameters channel_transaction_parameters_arg); +void HTLCDestination_free(struct LDKHTLCDestination this_ptr); /** - * Creates a copy of the DelayedPaymentOutputDescriptor + * Creates a copy of the HTLCDestination */ -struct LDKDelayedPaymentOutputDescriptor DelayedPaymentOutputDescriptor_clone(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR orig); +struct LDKHTLCDestination HTLCDestination_clone(const struct LDKHTLCDestination *NONNULL_PTR orig); /** - * Generates a non-cryptographic 64-bit hash of the DelayedPaymentOutputDescriptor. + * Utility method to constructs a new NextHopChannel-variant HTLCDestination */ -uint64_t DelayedPaymentOutputDescriptor_hash(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR o); +struct LDKHTLCDestination HTLCDestination_next_hop_channel(struct LDKPublicKey node_id, struct LDKChannelId channel_id); /** - * 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. + * Utility method to constructs a new UnknownNextHop-variant HTLCDestination */ -bool DelayedPaymentOutputDescriptor_eq(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR a, const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR b); +struct LDKHTLCDestination HTLCDestination_unknown_next_hop(uint64_t requested_forward_scid); /** - * Serialize the DelayedPaymentOutputDescriptor object into a byte array which can be read by DelayedPaymentOutputDescriptor_read + * Utility method to constructs a new InvalidForward-variant HTLCDestination */ -struct LDKCVec_u8Z DelayedPaymentOutputDescriptor_write(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR obj); +struct LDKHTLCDestination HTLCDestination_invalid_forward(uint64_t requested_forward_scid); /** - * Read a DelayedPaymentOutputDescriptor from a byte array, created by DelayedPaymentOutputDescriptor_write + * Utility method to constructs a new InvalidOnion-variant HTLCDestination */ -struct LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ DelayedPaymentOutputDescriptor_read(struct LDKu8slice ser); +struct LDKHTLCDestination HTLCDestination_invalid_onion(void); /** - * Frees any resources used by the StaticPaymentOutputDescriptor, if is_owned is set and inner is non-NULL. + * Utility method to constructs a new FailedPayment-variant HTLCDestination */ -void StaticPaymentOutputDescriptor_free(struct LDKStaticPaymentOutputDescriptor this_obj); +struct LDKHTLCDestination HTLCDestination_failed_payment(struct LDKThirtyTwoBytes payment_hash); /** - * The outpoint which is spendable. + * Checks if two HTLCDestinations contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -struct LDKOutPoint StaticPaymentOutputDescriptor_get_outpoint(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr); +bool HTLCDestination_eq(const struct LDKHTLCDestination *NONNULL_PTR a, const struct LDKHTLCDestination *NONNULL_PTR b); /** - * The outpoint which is spendable. + * Serialize the HTLCDestination object into a byte array which can be read by HTLCDestination_read */ -void StaticPaymentOutputDescriptor_set_outpoint(struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKOutPoint val); +struct LDKCVec_u8Z HTLCDestination_write(const struct LDKHTLCDestination *NONNULL_PTR obj); /** - * The output which is referenced by the given outpoint. + * Read a HTLCDestination from a byte array, created by HTLCDestination_write */ -struct LDKTxOut StaticPaymentOutputDescriptor_get_output(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr); +struct LDKCResult_COption_HTLCDestinationZDecodeErrorZ HTLCDestination_read(struct LDKu8slice ser); /** - * The output which is referenced by the given outpoint. + * Creates a copy of the PaymentFailureReason */ -void StaticPaymentOutputDescriptor_set_output(struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKTxOut val); +enum LDKPaymentFailureReason PaymentFailureReason_clone(const enum LDKPaymentFailureReason *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. + * Utility method to constructs a new RecipientRejected-variant PaymentFailureReason */ -const uint8_t (*StaticPaymentOutputDescriptor_get_channel_keys_id(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr))[32]; +enum LDKPaymentFailureReason PaymentFailureReason_recipient_rejected(void); /** - * 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. + * Utility method to constructs a new UserAbandoned-variant PaymentFailureReason */ -void StaticPaymentOutputDescriptor_set_channel_keys_id(struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +enum LDKPaymentFailureReason PaymentFailureReason_user_abandoned(void); /** - * The value of the channel which this transactions spends. + * Utility method to constructs a new RetriesExhausted-variant PaymentFailureReason */ -uint64_t StaticPaymentOutputDescriptor_get_channel_value_satoshis(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr); +enum LDKPaymentFailureReason PaymentFailureReason_retries_exhausted(void); /** - * The value of the channel which this transactions spends. + * Utility method to constructs a new PaymentExpired-variant PaymentFailureReason */ -void StaticPaymentOutputDescriptor_set_channel_value_satoshis(struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr, uint64_t val); +enum LDKPaymentFailureReason PaymentFailureReason_payment_expired(void); /** - * The necessary channel parameters that need to be provided to the re-derived signer through - * [`ChannelSigner::provide_channel_parameters`]. - * - * Added as optional, but always `Some` if the descriptor was produced in v0.0.117 or later. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Utility method to constructs a new RouteNotFound-variant PaymentFailureReason */ -struct LDKChannelTransactionParameters StaticPaymentOutputDescriptor_get_channel_transaction_parameters(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr); +enum LDKPaymentFailureReason PaymentFailureReason_route_not_found(void); /** - * The necessary channel parameters that need to be provided to the re-derived signer through - * [`ChannelSigner::provide_channel_parameters`]. - * - * Added as optional, but always `Some` if the descriptor was produced in v0.0.117 or later. - * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * Utility method to constructs a new UnexpectedError-variant PaymentFailureReason */ -void StaticPaymentOutputDescriptor_set_channel_transaction_parameters(struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKChannelTransactionParameters val); +enum LDKPaymentFailureReason PaymentFailureReason_unexpected_error(void); /** - * Constructs a new StaticPaymentOutputDescriptor given each field - * - * Note that channel_transaction_parameters_arg (or a relevant inner pointer) may be NULL or all-0s to represent None + * Utility method to constructs a new UnknownRequiredFeatures-variant PaymentFailureReason */ -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, struct LDKChannelTransactionParameters channel_transaction_parameters_arg); +enum LDKPaymentFailureReason PaymentFailureReason_unknown_required_features(void); /** - * Creates a copy of the StaticPaymentOutputDescriptor + * Utility method to constructs a new InvoiceRequestExpired-variant PaymentFailureReason */ -struct LDKStaticPaymentOutputDescriptor StaticPaymentOutputDescriptor_clone(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR orig); +enum LDKPaymentFailureReason PaymentFailureReason_invoice_request_expired(void); /** - * Generates a non-cryptographic 64-bit hash of the StaticPaymentOutputDescriptor. + * Utility method to constructs a new InvoiceRequestRejected-variant PaymentFailureReason */ -uint64_t StaticPaymentOutputDescriptor_hash(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR o); +enum LDKPaymentFailureReason PaymentFailureReason_invoice_request_rejected(void); /** - * Checks if two StaticPaymentOutputDescriptors contain equal inner contents. + * Checks if two PaymentFailureReasons 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 StaticPaymentOutputDescriptor_eq(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR a, const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR b); - -/** - * Returns the `witness_script` of the spendable output. - * - * Note that this will only return `Some` for [`StaticPaymentOutputDescriptor`]s that - * originated from an anchor outputs channel, as they take the form of a P2WSH script. - */ -MUST_USE_RES struct LDKCOption_CVec_u8ZZ StaticPaymentOutputDescriptor_witness_script(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_arg); - -/** - * The maximum length a well-formed witness spending one of these should have. - * Note: If you have the grind_signatures feature enabled, this will be at least 1 byte - * shorter. */ -MUST_USE_RES uint64_t StaticPaymentOutputDescriptor_max_witness_length(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_arg); +bool PaymentFailureReason_eq(const enum LDKPaymentFailureReason *NONNULL_PTR a, const enum LDKPaymentFailureReason *NONNULL_PTR b); /** - * Serialize the StaticPaymentOutputDescriptor object into a byte array which can be read by StaticPaymentOutputDescriptor_read + * Serialize the PaymentFailureReason object into a byte array which can be read by PaymentFailureReason_read */ -struct LDKCVec_u8Z StaticPaymentOutputDescriptor_write(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR obj); +struct LDKCVec_u8Z PaymentFailureReason_write(const enum LDKPaymentFailureReason *NONNULL_PTR obj); /** - * Read a StaticPaymentOutputDescriptor from a byte array, created by StaticPaymentOutputDescriptor_write + * Read a PaymentFailureReason from a byte array, created by PaymentFailureReason_write */ -struct LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ StaticPaymentOutputDescriptor_read(struct LDKu8slice ser); +struct LDKCResult_COption_PaymentFailureReasonZDecodeErrorZ PaymentFailureReason_read(struct LDKu8slice ser); /** - * Frees any resources used by the SpendableOutputDescriptor + * Frees any resources used by the Event */ -void SpendableOutputDescriptor_free(struct LDKSpendableOutputDescriptor this_ptr); +void Event_free(struct LDKEvent this_ptr); /** - * Creates a copy of the SpendableOutputDescriptor + * Creates a copy of the Event */ -struct LDKSpendableOutputDescriptor SpendableOutputDescriptor_clone(const struct LDKSpendableOutputDescriptor *NONNULL_PTR orig); +struct LDKEvent Event_clone(const struct LDKEvent *NONNULL_PTR orig); /** - * Utility method to constructs a new StaticOutput-variant SpendableOutputDescriptor + * Utility method to constructs a new FundingGenerationReady-variant Event */ -struct LDKSpendableOutputDescriptor SpendableOutputDescriptor_static_output(struct LDKOutPoint outpoint, struct LDKTxOut output, struct LDKThirtyTwoBytes channel_keys_id); +struct LDKEvent Event_funding_generation_ready(struct LDKChannelId temporary_channel_id, struct LDKPublicKey counterparty_node_id, uint64_t channel_value_satoshis, struct LDKCVec_u8Z output_script, struct LDKU128 user_channel_id); /** - * Utility method to constructs a new DelayedPaymentOutput-variant SpendableOutputDescriptor + * Utility method to constructs a new FundingTxBroadcastSafe-variant Event */ -struct LDKSpendableOutputDescriptor SpendableOutputDescriptor_delayed_payment_output(struct LDKDelayedPaymentOutputDescriptor a); +struct LDKEvent Event_funding_tx_broadcast_safe(struct LDKChannelId channel_id, struct LDKU128 user_channel_id, struct LDKOutPoint funding_txo, struct LDKPublicKey counterparty_node_id, struct LDKChannelId former_temporary_channel_id); /** - * Utility method to constructs a new StaticPaymentOutput-variant SpendableOutputDescriptor + * Utility method to constructs a new PaymentClaimable-variant Event */ -struct LDKSpendableOutputDescriptor SpendableOutputDescriptor_static_payment_output(struct LDKStaticPaymentOutputDescriptor a); +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 LDKChannelId via_channel_id, struct LDKCOption_U128Z via_user_channel_id, struct LDKCOption_u32Z claim_deadline); /** - * Generates a non-cryptographic 64-bit hash of the SpendableOutputDescriptor. + * Utility method to constructs a new PaymentClaimed-variant Event */ -uint64_t SpendableOutputDescriptor_hash(const struct LDKSpendableOutputDescriptor *NONNULL_PTR o); +struct LDKEvent Event_payment_claimed(struct LDKPublicKey receiver_node_id, struct LDKThirtyTwoBytes payment_hash, uint64_t amount_msat, struct LDKPaymentPurpose purpose, struct LDKCVec_ClaimedHTLCZ htlcs, struct LDKCOption_u64Z sender_intended_total_msat, struct LDKRecipientOnionFields onion_fields); /** - * Checks if two SpendableOutputDescriptors contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Utility method to constructs a new ConnectionNeeded-variant Event */ -bool SpendableOutputDescriptor_eq(const struct LDKSpendableOutputDescriptor *NONNULL_PTR a, const struct LDKSpendableOutputDescriptor *NONNULL_PTR b); +struct LDKEvent Event_connection_needed(struct LDKPublicKey node_id, struct LDKCVec_SocketAddressZ addresses); /** - * Serialize the SpendableOutputDescriptor object into a byte array which can be read by SpendableOutputDescriptor_read + * Utility method to constructs a new InvoiceReceived-variant Event */ -struct LDKCVec_u8Z SpendableOutputDescriptor_write(const struct LDKSpendableOutputDescriptor *NONNULL_PTR obj); +struct LDKEvent Event_invoice_received(struct LDKThirtyTwoBytes payment_id, struct LDKBolt12Invoice invoice, struct LDKCOption_OffersContextZ context, struct LDKResponder responder); /** - * Read a SpendableOutputDescriptor from a byte array, created by SpendableOutputDescriptor_write + * Utility method to constructs a new PaymentSent-variant Event */ -struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ SpendableOutputDescriptor_read(struct LDKu8slice ser); +struct LDKEvent Event_payment_sent(struct LDKCOption_ThirtyTwoBytesZ payment_id, struct LDKThirtyTwoBytes payment_preimage, struct LDKThirtyTwoBytes payment_hash, struct LDKCOption_u64Z fee_paid_msat); /** - * 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. + * Utility method to constructs a new PaymentFailed-variant Event */ -MUST_USE_RES struct LDKCResult_C2Tuple_CVec_u8Zu64ZNoneZ 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_u32Z locktime); +struct LDKEvent Event_payment_failed(struct LDKThirtyTwoBytes payment_id, struct LDKCOption_ThirtyTwoBytesZ payment_hash, struct LDKCOption_PaymentFailureReasonZ reason); /** - * Frees any resources used by the ChannelDerivationParameters, if is_owned is set and inner is non-NULL. + * Utility method to constructs a new PaymentPathSuccessful-variant Event */ -void ChannelDerivationParameters_free(struct LDKChannelDerivationParameters this_obj); +struct LDKEvent Event_payment_path_successful(struct LDKThirtyTwoBytes payment_id, struct LDKCOption_ThirtyTwoBytesZ payment_hash, struct LDKPath path); /** - * The value in satoshis of the channel we're attempting to spend the anchor output of. + * Utility method to constructs a new PaymentPathFailed-variant Event */ -uint64_t ChannelDerivationParameters_get_value_satoshis(const struct LDKChannelDerivationParameters *NONNULL_PTR this_ptr); +struct LDKEvent Event_payment_path_failed(struct LDKCOption_ThirtyTwoBytesZ payment_id, struct LDKThirtyTwoBytes payment_hash, bool payment_failed_permanently, struct LDKPathFailure failure, struct LDKPath path, struct LDKCOption_u64Z short_channel_id); /** - * The value in satoshis of the channel we're attempting to spend the anchor output of. + * Utility method to constructs a new ProbeSuccessful-variant Event */ -void ChannelDerivationParameters_set_value_satoshis(struct LDKChannelDerivationParameters *NONNULL_PTR this_ptr, uint64_t val); +struct LDKEvent Event_probe_successful(struct LDKThirtyTwoBytes payment_id, struct LDKThirtyTwoBytes payment_hash, struct LDKPath path); /** - * The unique identifier to re-derive the signer for the associated channel. + * Utility method to constructs a new ProbeFailed-variant Event */ -const uint8_t (*ChannelDerivationParameters_get_keys_id(const struct LDKChannelDerivationParameters *NONNULL_PTR this_ptr))[32]; +struct LDKEvent Event_probe_failed(struct LDKThirtyTwoBytes payment_id, struct LDKThirtyTwoBytes payment_hash, struct LDKPath path, struct LDKCOption_u64Z short_channel_id); /** - * The unique identifier to re-derive the signer for the associated channel. + * Utility method to constructs a new PendingHTLCsForwardable-variant Event */ -void ChannelDerivationParameters_set_keys_id(struct LDKChannelDerivationParameters *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKEvent Event_pending_htlcs_forwardable(uint64_t time_forwardable); /** - * The necessary channel parameters that need to be provided to the re-derived signer through - * [`ChannelSigner::provide_channel_parameters`]. + * Utility method to constructs a new HTLCIntercepted-variant Event */ -struct LDKChannelTransactionParameters ChannelDerivationParameters_get_transaction_parameters(const struct LDKChannelDerivationParameters *NONNULL_PTR this_ptr); +struct LDKEvent Event_htlcintercepted(struct LDKThirtyTwoBytes intercept_id, uint64_t requested_next_hop_scid, struct LDKThirtyTwoBytes payment_hash, uint64_t inbound_amount_msat, uint64_t expected_outbound_amount_msat); /** - * The necessary channel parameters that need to be provided to the re-derived signer through - * [`ChannelSigner::provide_channel_parameters`]. + * Utility method to constructs a new SpendableOutputs-variant Event */ -void ChannelDerivationParameters_set_transaction_parameters(struct LDKChannelDerivationParameters *NONNULL_PTR this_ptr, struct LDKChannelTransactionParameters val); +struct LDKEvent Event_spendable_outputs(struct LDKCVec_SpendableOutputDescriptorZ outputs, struct LDKChannelId channel_id); /** - * Constructs a new ChannelDerivationParameters given each field + * Utility method to constructs a new PaymentForwarded-variant Event */ -MUST_USE_RES struct LDKChannelDerivationParameters ChannelDerivationParameters_new(uint64_t value_satoshis_arg, struct LDKThirtyTwoBytes keys_id_arg, struct LDKChannelTransactionParameters transaction_parameters_arg); +struct LDKEvent Event_payment_forwarded(struct LDKChannelId prev_channel_id, struct LDKChannelId next_channel_id, struct LDKCOption_U128Z prev_user_channel_id, struct LDKCOption_U128Z next_user_channel_id, struct LDKCOption_u64Z total_fee_earned_msat, struct LDKCOption_u64Z skimmed_fee_msat, bool claim_from_onchain_tx, struct LDKCOption_u64Z outbound_amount_forwarded_msat); /** - * Creates a copy of the ChannelDerivationParameters + * Utility method to constructs a new ChannelPending-variant Event */ -struct LDKChannelDerivationParameters ChannelDerivationParameters_clone(const struct LDKChannelDerivationParameters *NONNULL_PTR orig); +struct LDKEvent Event_channel_pending(struct LDKChannelId channel_id, struct LDKU128 user_channel_id, struct LDKChannelId former_temporary_channel_id, struct LDKPublicKey counterparty_node_id, struct LDKOutPoint funding_txo, struct LDKChannelTypeFeatures channel_type); /** - * 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. + * Utility method to constructs a new ChannelReady-variant Event */ -bool ChannelDerivationParameters_eq(const struct LDKChannelDerivationParameters *NONNULL_PTR a, const struct LDKChannelDerivationParameters *NONNULL_PTR b); +struct LDKEvent Event_channel_ready(struct LDKChannelId channel_id, struct LDKU128 user_channel_id, struct LDKPublicKey counterparty_node_id, struct LDKChannelTypeFeatures channel_type); /** - * Serialize the ChannelDerivationParameters object into a byte array which can be read by ChannelDerivationParameters_read + * Utility method to constructs a new ChannelClosed-variant Event */ -struct LDKCVec_u8Z ChannelDerivationParameters_write(const struct LDKChannelDerivationParameters *NONNULL_PTR obj); +struct LDKEvent Event_channel_closed(struct LDKChannelId channel_id, struct LDKU128 user_channel_id, struct LDKClosureReason reason, struct LDKPublicKey counterparty_node_id, struct LDKCOption_u64Z channel_capacity_sats, struct LDKOutPoint channel_funding_txo); /** - * Read a ChannelDerivationParameters from a byte array, created by ChannelDerivationParameters_write + * Utility method to constructs a new DiscardFunding-variant Event */ -struct LDKCResult_ChannelDerivationParametersDecodeErrorZ ChannelDerivationParameters_read(struct LDKu8slice ser); +struct LDKEvent Event_discard_funding(struct LDKChannelId channel_id, struct LDKFundingInfo funding_info); /** - * Frees any resources used by the HTLCDescriptor, if is_owned is set and inner is non-NULL. + * Utility method to constructs a new OpenChannelRequest-variant Event */ -void HTLCDescriptor_free(struct LDKHTLCDescriptor this_obj); +struct LDKEvent Event_open_channel_request(struct LDKChannelId temporary_channel_id, struct LDKPublicKey counterparty_node_id, uint64_t funding_satoshis, uint64_t push_msat, struct LDKChannelTypeFeatures channel_type, bool is_announced, struct LDKChannelParameters params); /** - * The parameters required to derive the signer for the HTLC input. + * Utility method to constructs a new HTLCHandlingFailed-variant Event */ -struct LDKChannelDerivationParameters HTLCDescriptor_get_channel_derivation_parameters(const struct LDKHTLCDescriptor *NONNULL_PTR this_ptr); +struct LDKEvent Event_htlchandling_failed(struct LDKChannelId prev_channel_id, struct LDKHTLCDestination failed_next_destination); /** - * The parameters required to derive the signer for the HTLC input. + * Utility method to constructs a new BumpTransaction-variant Event */ -void HTLCDescriptor_set_channel_derivation_parameters(struct LDKHTLCDescriptor *NONNULL_PTR this_ptr, struct LDKChannelDerivationParameters val); +struct LDKEvent Event_bump_transaction(struct LDKBumpTransactionEvent a); /** - * The txid of the commitment transaction in which the HTLC output lives. + * Utility method to constructs a new OnionMessageIntercepted-variant Event */ -const uint8_t (*HTLCDescriptor_get_commitment_txid(const struct LDKHTLCDescriptor *NONNULL_PTR this_ptr))[32]; +struct LDKEvent Event_onion_message_intercepted(struct LDKPublicKey peer_node_id, struct LDKOnionMessage message); /** - * The txid of the commitment transaction in which the HTLC output lives. + * Utility method to constructs a new OnionMessagePeerConnected-variant Event */ -void HTLCDescriptor_set_commitment_txid(struct LDKHTLCDescriptor *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKEvent Event_onion_message_peer_connected(struct LDKPublicKey peer_node_id); /** - * The number of the commitment transaction in which the HTLC output lives. + * Checks if two Events contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -uint64_t HTLCDescriptor_get_per_commitment_number(const struct LDKHTLCDescriptor *NONNULL_PTR this_ptr); +bool Event_eq(const struct LDKEvent *NONNULL_PTR a, const struct LDKEvent *NONNULL_PTR b); /** - * The number of the commitment transaction in which the HTLC output lives. + * Serialize the Event object into a byte array which can be read by Event_read */ -void HTLCDescriptor_set_per_commitment_number(struct LDKHTLCDescriptor *NONNULL_PTR this_ptr, uint64_t val); +struct LDKCVec_u8Z Event_write(const struct LDKEvent *NONNULL_PTR obj); /** - * 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. + * Read a Event from a byte array, created by Event_write */ -struct LDKPublicKey HTLCDescriptor_get_per_commitment_point(const struct LDKHTLCDescriptor *NONNULL_PTR this_ptr); +struct LDKCResult_COption_EventZDecodeErrorZ Event_read(struct LDKu8slice ser); /** - * 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. + * Frees any resources used by the MessageSendEvent */ -void HTLCDescriptor_set_per_commitment_point(struct LDKHTLCDescriptor *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void MessageSendEvent_free(struct LDKMessageSendEvent this_ptr); /** - * The feerate to use on the HTLC claiming transaction. This is always `0` for HTLCs - * originating from a channel supporting anchor outputs, otherwise it is the channel's - * negotiated feerate at the time the commitment transaction was built. + * Creates a copy of the MessageSendEvent */ -uint32_t HTLCDescriptor_get_feerate_per_kw(const struct LDKHTLCDescriptor *NONNULL_PTR this_ptr); +struct LDKMessageSendEvent MessageSendEvent_clone(const struct LDKMessageSendEvent *NONNULL_PTR orig); /** - * The feerate to use on the HTLC claiming transaction. This is always `0` for HTLCs - * originating from a channel supporting anchor outputs, otherwise it is the channel's - * negotiated feerate at the time the commitment transaction was built. + * Utility method to constructs a new SendAcceptChannel-variant MessageSendEvent */ -void HTLCDescriptor_set_feerate_per_kw(struct LDKHTLCDescriptor *NONNULL_PTR this_ptr, uint32_t val); +struct LDKMessageSendEvent MessageSendEvent_send_accept_channel(struct LDKPublicKey node_id, struct LDKAcceptChannel msg); /** - * The details of the HTLC as it appears in the commitment transaction. + * Utility method to constructs a new SendAcceptChannelV2-variant MessageSendEvent */ -struct LDKHTLCOutputInCommitment HTLCDescriptor_get_htlc(const struct LDKHTLCDescriptor *NONNULL_PTR this_ptr); +struct LDKMessageSendEvent MessageSendEvent_send_accept_channel_v2(struct LDKPublicKey node_id, struct LDKAcceptChannelV2 msg); /** - * The details of the HTLC as it appears in the commitment transaction. + * Utility method to constructs a new SendOpenChannel-variant MessageSendEvent */ -void HTLCDescriptor_set_htlc(struct LDKHTLCDescriptor *NONNULL_PTR this_ptr, struct LDKHTLCOutputInCommitment val); +struct LDKMessageSendEvent MessageSendEvent_send_open_channel(struct LDKPublicKey node_id, struct LDKOpenChannel msg); /** - * The preimage, if `Some`, to claim the HTLC output with. If `None`, the timeout path must be - * taken. + * Utility method to constructs a new SendOpenChannelV2-variant MessageSendEvent */ -struct LDKCOption_ThirtyTwoBytesZ HTLCDescriptor_get_preimage(const struct LDKHTLCDescriptor *NONNULL_PTR this_ptr); +struct LDKMessageSendEvent MessageSendEvent_send_open_channel_v2(struct LDKPublicKey node_id, struct LDKOpenChannelV2 msg); /** - * The preimage, if `Some`, to claim the HTLC output with. If `None`, the timeout path must be - * taken. + * Utility method to constructs a new SendFundingCreated-variant MessageSendEvent */ -void HTLCDescriptor_set_preimage(struct LDKHTLCDescriptor *NONNULL_PTR this_ptr, struct LDKCOption_ThirtyTwoBytesZ val); +struct LDKMessageSendEvent MessageSendEvent_send_funding_created(struct LDKPublicKey node_id, struct LDKFundingCreated msg); /** - * The counterparty's signature required to spend the HTLC output. + * Utility method to constructs a new SendFundingSigned-variant MessageSendEvent */ -struct LDKECDSASignature HTLCDescriptor_get_counterparty_sig(const struct LDKHTLCDescriptor *NONNULL_PTR this_ptr); +struct LDKMessageSendEvent MessageSendEvent_send_funding_signed(struct LDKPublicKey node_id, struct LDKFundingSigned msg); /** - * The counterparty's signature required to spend the HTLC output. + * Utility method to constructs a new SendStfu-variant MessageSendEvent */ -void HTLCDescriptor_set_counterparty_sig(struct LDKHTLCDescriptor *NONNULL_PTR this_ptr, struct LDKECDSASignature val); +struct LDKMessageSendEvent MessageSendEvent_send_stfu(struct LDKPublicKey node_id, struct LDKStfu msg); /** - * Constructs a new HTLCDescriptor given each field + * Utility method to constructs a new SendSpliceInit-variant MessageSendEvent */ -MUST_USE_RES struct LDKHTLCDescriptor HTLCDescriptor_new(struct LDKChannelDerivationParameters channel_derivation_parameters_arg, struct LDKThirtyTwoBytes commitment_txid_arg, uint64_t per_commitment_number_arg, struct LDKPublicKey per_commitment_point_arg, uint32_t feerate_per_kw_arg, struct LDKHTLCOutputInCommitment htlc_arg, struct LDKCOption_ThirtyTwoBytesZ preimage_arg, struct LDKECDSASignature counterparty_sig_arg); +struct LDKMessageSendEvent MessageSendEvent_send_splice_init(struct LDKPublicKey node_id, struct LDKSpliceInit msg); /** - * Creates a copy of the HTLCDescriptor + * Utility method to constructs a new SendSpliceAck-variant MessageSendEvent */ -struct LDKHTLCDescriptor HTLCDescriptor_clone(const struct LDKHTLCDescriptor *NONNULL_PTR orig); +struct LDKMessageSendEvent MessageSendEvent_send_splice_ack(struct LDKPublicKey node_id, struct LDKSpliceAck msg); /** - * 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. + * Utility method to constructs a new SendSpliceLocked-variant MessageSendEvent */ -bool HTLCDescriptor_eq(const struct LDKHTLCDescriptor *NONNULL_PTR a, const struct LDKHTLCDescriptor *NONNULL_PTR b); +struct LDKMessageSendEvent MessageSendEvent_send_splice_locked(struct LDKPublicKey node_id, struct LDKSpliceLocked msg); /** - * Serialize the HTLCDescriptor object into a byte array which can be read by HTLCDescriptor_read + * Utility method to constructs a new SendTxAddInput-variant MessageSendEvent */ -struct LDKCVec_u8Z HTLCDescriptor_write(const struct LDKHTLCDescriptor *NONNULL_PTR obj); +struct LDKMessageSendEvent MessageSendEvent_send_tx_add_input(struct LDKPublicKey node_id, struct LDKTxAddInput msg); /** - * Read a HTLCDescriptor from a byte array, created by HTLCDescriptor_write + * Utility method to constructs a new SendTxAddOutput-variant MessageSendEvent */ -struct LDKCResult_HTLCDescriptorDecodeErrorZ HTLCDescriptor_read(struct LDKu8slice ser); +struct LDKMessageSendEvent MessageSendEvent_send_tx_add_output(struct LDKPublicKey node_id, struct LDKTxAddOutput msg); /** - * 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. + * Utility method to constructs a new SendTxRemoveInput-variant MessageSendEvent */ -MUST_USE_RES struct LDKOutPoint HTLCDescriptor_outpoint(const struct LDKHTLCDescriptor *NONNULL_PTR this_arg); +struct LDKMessageSendEvent MessageSendEvent_send_tx_remove_input(struct LDKPublicKey node_id, struct LDKTxRemoveInput msg); /** - * Returns the UTXO to be spent by the HTLC input, which can be obtained via - * [`Self::unsigned_tx_input`]. + * Utility method to constructs a new SendTxRemoveOutput-variant MessageSendEvent */ -MUST_USE_RES struct LDKTxOut HTLCDescriptor_previous_utxo(const struct LDKHTLCDescriptor *NONNULL_PTR this_arg); +struct LDKMessageSendEvent MessageSendEvent_send_tx_remove_output(struct LDKPublicKey node_id, struct LDKTxRemoveOutput msg); /** - * Returns the unsigned transaction input spending the HTLC output in the commitment - * transaction. + * Utility method to constructs a new SendTxComplete-variant MessageSendEvent */ -MUST_USE_RES struct LDKTxIn HTLCDescriptor_unsigned_tx_input(const struct LDKHTLCDescriptor *NONNULL_PTR this_arg); +struct LDKMessageSendEvent MessageSendEvent_send_tx_complete(struct LDKPublicKey node_id, struct LDKTxComplete msg); /** - * Returns the delayed output created as a result of spending the HTLC output in the commitment - * transaction. + * Utility method to constructs a new SendTxSignatures-variant MessageSendEvent */ -MUST_USE_RES struct LDKTxOut HTLCDescriptor_tx_output(const struct LDKHTLCDescriptor *NONNULL_PTR this_arg); +struct LDKMessageSendEvent MessageSendEvent_send_tx_signatures(struct LDKPublicKey node_id, struct LDKTxSignatures msg); /** - * Returns the witness script of the HTLC output in the commitment transaction. + * Utility method to constructs a new SendTxInitRbf-variant MessageSendEvent */ -MUST_USE_RES struct LDKCVec_u8Z HTLCDescriptor_witness_script(const struct LDKHTLCDescriptor *NONNULL_PTR this_arg); +struct LDKMessageSendEvent MessageSendEvent_send_tx_init_rbf(struct LDKPublicKey node_id, struct LDKTxInitRbf msg); /** - * Returns the fully signed witness required to spend the HTLC output in the commitment - * transaction. + * Utility method to constructs a new SendTxAckRbf-variant MessageSendEvent */ -MUST_USE_RES struct LDKWitness HTLCDescriptor_tx_input_witness(const struct LDKHTLCDescriptor *NONNULL_PTR this_arg, struct LDKECDSASignature signature, struct LDKu8slice witness_script); +struct LDKMessageSendEvent MessageSendEvent_send_tx_ack_rbf(struct LDKPublicKey node_id, struct LDKTxAckRbf msg); /** - * Derives the channel signer required to sign the HTLC input. + * Utility method to constructs a new SendTxAbort-variant MessageSendEvent */ -MUST_USE_RES struct LDKWriteableEcdsaChannelSigner HTLCDescriptor_derive_channel_signer(const struct LDKHTLCDescriptor *NONNULL_PTR this_arg, const struct LDKSignerProvider *NONNULL_PTR signer_provider); +struct LDKMessageSendEvent MessageSendEvent_send_tx_abort(struct LDKPublicKey node_id, struct LDKTxAbort msg); /** - * Calls the free function if one is set + * Utility method to constructs a new SendChannelReady-variant MessageSendEvent */ -void ChannelSigner_free(struct LDKChannelSigner this_ptr); +struct LDKMessageSendEvent MessageSendEvent_send_channel_ready(struct LDKPublicKey node_id, struct LDKChannelReady msg); /** - * Creates a copy of the Recipient + * Utility method to constructs a new SendAnnouncementSignatures-variant MessageSendEvent */ -enum LDKRecipient Recipient_clone(const enum LDKRecipient *NONNULL_PTR orig); +struct LDKMessageSendEvent MessageSendEvent_send_announcement_signatures(struct LDKPublicKey node_id, struct LDKAnnouncementSignatures msg); /** - * Utility method to constructs a new Node-variant Recipient + * Utility method to constructs a new UpdateHTLCs-variant MessageSendEvent */ -enum LDKRecipient Recipient_node(void); +struct LDKMessageSendEvent MessageSendEvent_update_htlcs(struct LDKPublicKey node_id, struct LDKCommitmentUpdate updates); /** - * Utility method to constructs a new PhantomNode-variant Recipient + * Utility method to constructs a new SendRevokeAndACK-variant MessageSendEvent */ -enum LDKRecipient Recipient_phantom_node(void); +struct LDKMessageSendEvent MessageSendEvent_send_revoke_and_ack(struct LDKPublicKey node_id, struct LDKRevokeAndACK msg); /** - * Calls the free function if one is set + * Utility method to constructs a new SendClosingSigned-variant MessageSendEvent */ -void EntropySource_free(struct LDKEntropySource this_ptr); +struct LDKMessageSendEvent MessageSendEvent_send_closing_signed(struct LDKPublicKey node_id, struct LDKClosingSigned msg); /** - * Calls the free function if one is set + * Utility method to constructs a new SendShutdown-variant MessageSendEvent */ -void NodeSigner_free(struct LDKNodeSigner this_ptr); +struct LDKMessageSendEvent MessageSendEvent_send_shutdown(struct LDKPublicKey node_id, struct LDKShutdown msg); /** - * Calls the free function if one is set + * Utility method to constructs a new SendChannelReestablish-variant MessageSendEvent */ -void OutputSpender_free(struct LDKOutputSpender this_ptr); +struct LDKMessageSendEvent MessageSendEvent_send_channel_reestablish(struct LDKPublicKey node_id, struct LDKChannelReestablish msg); /** - * Calls the free function if one is set + * Utility method to constructs a new SendChannelAnnouncement-variant MessageSendEvent */ -void SignerProvider_free(struct LDKSignerProvider this_ptr); +struct LDKMessageSendEvent MessageSendEvent_send_channel_announcement(struct LDKPublicKey node_id, struct LDKChannelAnnouncement msg, struct LDKChannelUpdate update_msg); /** - * Calls the free function if one is set + * Utility method to constructs a new BroadcastChannelAnnouncement-variant MessageSendEvent */ -void ChangeDestinationSource_free(struct LDKChangeDestinationSource this_ptr); +struct LDKMessageSendEvent MessageSendEvent_broadcast_channel_announcement(struct LDKChannelAnnouncement msg, struct LDKChannelUpdate update_msg); /** - * Frees any resources used by the InMemorySigner, if is_owned is set and inner is non-NULL. + * Utility method to constructs a new BroadcastChannelUpdate-variant MessageSendEvent */ -void InMemorySigner_free(struct LDKInMemorySigner this_obj); +struct LDKMessageSendEvent MessageSendEvent_broadcast_channel_update(struct LDKChannelUpdate msg); /** - * 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. + * Utility method to constructs a new BroadcastNodeAnnouncement-variant MessageSendEvent */ -const uint8_t (*InMemorySigner_get_funding_key(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; +struct LDKMessageSendEvent MessageSendEvent_broadcast_node_announcement(struct LDKNodeAnnouncement msg); /** - * 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. + * Utility method to constructs a new SendChannelUpdate-variant MessageSendEvent */ -void InMemorySigner_set_funding_key(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKSecretKey val); +struct LDKMessageSendEvent MessageSendEvent_send_channel_update(struct LDKPublicKey node_id, struct LDKChannelUpdate msg); /** - * Holder secret key for blinded revocation pubkey. + * Utility method to constructs a new HandleError-variant MessageSendEvent */ -const uint8_t (*InMemorySigner_get_revocation_base_key(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; +struct LDKMessageSendEvent MessageSendEvent_handle_error(struct LDKPublicKey node_id, struct LDKErrorAction action); /** - * Holder secret key for blinded revocation pubkey. + * Utility method to constructs a new SendChannelRangeQuery-variant MessageSendEvent */ -void InMemorySigner_set_revocation_base_key(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKSecretKey val); +struct LDKMessageSendEvent MessageSendEvent_send_channel_range_query(struct LDKPublicKey node_id, struct LDKQueryChannelRange msg); /** - * Holder secret key used for our balance in counterparty-broadcasted commitment transactions. + * Utility method to constructs a new SendShortIdsQuery-variant MessageSendEvent */ -const uint8_t (*InMemorySigner_get_payment_key(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; +struct LDKMessageSendEvent MessageSendEvent_send_short_ids_query(struct LDKPublicKey node_id, struct LDKQueryShortChannelIds msg); /** - * Holder secret key used for our balance in counterparty-broadcasted commitment transactions. + * Utility method to constructs a new SendReplyChannelRange-variant MessageSendEvent */ -void InMemorySigner_set_payment_key(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKSecretKey val); +struct LDKMessageSendEvent MessageSendEvent_send_reply_channel_range(struct LDKPublicKey node_id, struct LDKReplyChannelRange msg); /** - * Holder secret key used in an HTLC transaction. + * Utility method to constructs a new SendGossipTimestampFilter-variant MessageSendEvent */ -const uint8_t (*InMemorySigner_get_delayed_payment_base_key(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; +struct LDKMessageSendEvent MessageSendEvent_send_gossip_timestamp_filter(struct LDKPublicKey node_id, struct LDKGossipTimestampFilter msg); /** - * Holder secret key used in an HTLC transaction. + * Calls the free function if one is set */ -void InMemorySigner_set_delayed_payment_base_key(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKSecretKey val); +void MessageSendEventsProvider_free(struct LDKMessageSendEventsProvider this_ptr); /** - * Holder HTLC secret key used in commitment transaction HTLC outputs. + * Calls the free function if one is set */ -const uint8_t (*InMemorySigner_get_htlc_base_key(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; +void EventsProvider_free(struct LDKEventsProvider this_ptr); /** - * Holder HTLC secret key used in commitment transaction HTLC outputs. + * Frees any resources used by the ReplayEvent, if is_owned is set and inner is non-NULL. */ -void InMemorySigner_set_htlc_base_key(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKSecretKey val); +void ReplayEvent_free(struct LDKReplayEvent this_obj); /** - * Commitment seed. + * Constructs a new ReplayEvent given each field */ -const uint8_t (*InMemorySigner_get_commitment_seed(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; +MUST_USE_RES struct LDKReplayEvent ReplayEvent_new(void); /** - * Commitment seed. + * Creates a copy of the ReplayEvent */ -void InMemorySigner_set_commitment_seed(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKReplayEvent ReplayEvent_clone(const struct LDKReplayEvent *NONNULL_PTR orig); /** - * Creates a copy of the InMemorySigner + * Calls the free function if one is set */ -struct LDKInMemorySigner InMemorySigner_clone(const struct LDKInMemorySigner *NONNULL_PTR orig); +void EventHandler_free(struct LDKEventHandler this_ptr); /** - * Creates a new [`InMemorySigner`]. + * Frees any resources used by the AnchorDescriptor, if is_owned is set and inner is non-NULL. */ -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 AnchorDescriptor_free(struct LDKAnchorDescriptor this_obj); /** - * Returns the counterparty's pubkeys. - * - * Will return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called. - * In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * The parameters required to derive the signer for the anchor input. */ -MUST_USE_RES struct LDKChannelPublicKeys InMemorySigner_counterparty_pubkeys(const struct LDKInMemorySigner *NONNULL_PTR this_arg); +struct LDKChannelDerivationParameters AnchorDescriptor_get_channel_derivation_parameters(const struct LDKAnchorDescriptor *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 return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called. - * In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation. + * The parameters required to derive the signer for the anchor input. */ -MUST_USE_RES struct LDKCOption_u16Z InMemorySigner_counterparty_selected_contest_delay(const struct LDKInMemorySigner *NONNULL_PTR this_arg); +void AnchorDescriptor_set_channel_derivation_parameters(struct LDKAnchorDescriptor *NONNULL_PTR this_ptr, struct LDKChannelDerivationParameters 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 return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called. - * In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation. + * The transaction input's outpoint corresponding to the commitment transaction's anchor + * output. */ -MUST_USE_RES struct LDKCOption_u16Z InMemorySigner_holder_selected_contest_delay(const struct LDKInMemorySigner *NONNULL_PTR this_arg); +struct LDKOutPoint AnchorDescriptor_get_outpoint(const struct LDKAnchorDescriptor *NONNULL_PTR this_ptr); /** - * Returns whether the holder is the initiator. - * - * Will return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called. - * In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation. + * The transaction input's outpoint corresponding to the commitment transaction's anchor + * output. */ -MUST_USE_RES struct LDKCOption_boolZ InMemorySigner_is_outbound(const struct LDKInMemorySigner *NONNULL_PTR this_arg); +void AnchorDescriptor_set_outpoint(struct LDKAnchorDescriptor *NONNULL_PTR this_ptr, struct LDKOutPoint val); /** - * Funding outpoint - * - * Will return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called. - * In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Constructs a new AnchorDescriptor given each field */ -MUST_USE_RES struct LDKOutPoint InMemorySigner_funding_outpoint(const struct LDKInMemorySigner *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKAnchorDescriptor AnchorDescriptor_new(struct LDKChannelDerivationParameters channel_derivation_parameters_arg, struct LDKOutPoint outpoint_arg); /** - * Returns a [`ChannelTransactionParameters`] for this channel, to be used when verifying or - * building transactions. - * - * Will return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called. - * In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Creates a copy of the AnchorDescriptor */ -MUST_USE_RES struct LDKChannelTransactionParameters InMemorySigner_get_channel_parameters(const struct LDKInMemorySigner *NONNULL_PTR this_arg); +struct LDKAnchorDescriptor AnchorDescriptor_clone(const struct LDKAnchorDescriptor *NONNULL_PTR orig); /** - * 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 return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called. - * In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * 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. */ -MUST_USE_RES struct LDKChannelTypeFeatures InMemorySigner_channel_type_features(const struct LDKInMemorySigner *NONNULL_PTR this_arg); +bool AnchorDescriptor_eq(const struct LDKAnchorDescriptor *NONNULL_PTR a, const struct LDKAnchorDescriptor *NONNULL_PTR b); /** - * 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 + * Returns the UTXO to be spent by the anchor input, which can be obtained via + * [`Self::unsigned_tx_input`]. */ -MUST_USE_RES struct LDKCResult_WitnessNoneZ 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); +MUST_USE_RES struct LDKTxOut AnchorDescriptor_previous_utxo(const struct LDKAnchorDescriptor *NONNULL_PTR this_arg); /** - * 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 + * Returns the unsigned transaction input spending the anchor output in the commitment + * transaction. */ -MUST_USE_RES struct LDKCResult_WitnessNoneZ 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); +MUST_USE_RES struct LDKTxIn AnchorDescriptor_unsigned_tx_input(const struct LDKAnchorDescriptor *NONNULL_PTR this_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 + * Returns the witness script of the anchor output in the commitment transaction. */ -struct LDKEntropySource InMemorySigner_as_EntropySource(const struct LDKInMemorySigner *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCVec_u8Z AnchorDescriptor_witness_script(const struct LDKAnchorDescriptor *NONNULL_PTR this_arg); /** - * 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 + * Returns the fully signed witness required to spend the anchor output in the commitment + * transaction. */ -struct LDKChannelSigner InMemorySigner_as_ChannelSigner(const struct LDKInMemorySigner *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKWitness AnchorDescriptor_tx_input_witness(const struct LDKAnchorDescriptor *NONNULL_PTR this_arg, struct LDKECDSASignature signature); /** - * 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 + * Derives the channel signer required to sign the anchor input. */ -struct LDKEcdsaChannelSigner InMemorySigner_as_EcdsaChannelSigner(const struct LDKInMemorySigner *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKEcdsaChannelSigner AnchorDescriptor_derive_channel_signer(const struct LDKAnchorDescriptor *NONNULL_PTR this_arg, const struct LDKSignerProvider *NONNULL_PTR signer_provider); /** - * 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 + * Frees any resources used by the BumpTransactionEvent */ -struct LDKWriteableEcdsaChannelSigner InMemorySigner_as_WriteableEcdsaChannelSigner(const struct LDKInMemorySigner *NONNULL_PTR this_arg); +void BumpTransactionEvent_free(struct LDKBumpTransactionEvent this_ptr); /** - * Serialize the InMemorySigner object into a byte array which can be read by InMemorySigner_read + * Creates a copy of the BumpTransactionEvent */ -struct LDKCVec_u8Z InMemorySigner_write(const struct LDKInMemorySigner *NONNULL_PTR obj); +struct LDKBumpTransactionEvent BumpTransactionEvent_clone(const struct LDKBumpTransactionEvent *NONNULL_PTR orig); /** - * Read a InMemorySigner from a byte array, created by InMemorySigner_write + * Utility method to constructs a new ChannelClose-variant BumpTransactionEvent */ -struct LDKCResult_InMemorySignerDecodeErrorZ InMemorySigner_read(struct LDKu8slice ser, struct LDKEntropySource arg); +struct LDKBumpTransactionEvent BumpTransactionEvent_channel_close(struct LDKChannelId channel_id, struct LDKPublicKey counterparty_node_id, 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); /** - * Frees any resources used by the KeysManager, if is_owned is set and inner is non-NULL. + * Utility method to constructs a new HTLCResolution-variant BumpTransactionEvent */ -void KeysManager_free(struct LDKKeysManager this_obj); +struct LDKBumpTransactionEvent BumpTransactionEvent_htlcresolution(struct LDKChannelId channel_id, struct LDKPublicKey counterparty_node_id, struct LDKThirtyTwoBytes claim_id, uint32_t target_feerate_sat_per_1000_weight, struct LDKCVec_HTLCDescriptorZ htlc_descriptors, uint32_t tx_lock_time); /** - * 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 + * Checks if two BumpTransactionEvents contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -MUST_USE_RES struct LDKKeysManager KeysManager_new(const uint8_t (*seed)[32], uint64_t starting_time_secs, uint32_t starting_time_nanos); +bool BumpTransactionEvent_eq(const struct LDKBumpTransactionEvent *NONNULL_PTR a, const struct LDKBumpTransactionEvent *NONNULL_PTR b); /** - * Gets the \"node_id\" secret key used to sign gossip announcements, decode onion data, etc. + * Frees any resources used by the Input, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKSecretKey KeysManager_get_node_secret_key(const struct LDKKeysManager *NONNULL_PTR this_arg); +void Input_free(struct LDKInput this_obj); /** - * Derive an old [`WriteableEcdsaChannelSigner`] containing per-channel secrets based on a key derivation parameters. + * The unique identifier of the input. */ -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]); +struct LDKOutPoint Input_get_outpoint(const struct LDKInput *NONNULL_PTR this_ptr); /** - * 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`]. + * The unique identifier of the input. */ -MUST_USE_RES struct LDKCResult_CVec_u8ZNoneZ KeysManager_sign_spendable_outputs_psbt(const struct LDKKeysManager *NONNULL_PTR this_arg, struct LDKCVec_SpendableOutputDescriptorZ descriptors, struct LDKCVec_u8Z psbt); +void Input_set_outpoint(struct LDKInput *NONNULL_PTR this_ptr, struct LDKOutPoint 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 UTXO being spent by the input. */ -struct LDKEntropySource KeysManager_as_EntropySource(const struct LDKKeysManager *NONNULL_PTR this_arg); +struct LDKTxOut Input_get_previous_utxo(const struct LDKInput *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 UTXO being spent by the input. */ -struct LDKNodeSigner KeysManager_as_NodeSigner(const struct LDKKeysManager *NONNULL_PTR this_arg); +void Input_set_previous_utxo(struct LDKInput *NONNULL_PTR this_ptr, struct LDKTxOut val); /** - * Constructs a new OutputSpender which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned OutputSpender must be freed before this_arg is + * 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. */ -struct LDKOutputSpender KeysManager_as_OutputSpender(const struct LDKKeysManager *NONNULL_PTR this_arg); +uint64_t Input_get_satisfaction_weight(const struct LDKInput *NONNULL_PTR this_ptr); /** - * 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 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. */ -struct LDKSignerProvider KeysManager_as_SignerProvider(const struct LDKKeysManager *NONNULL_PTR this_arg); +void Input_set_satisfaction_weight(struct LDKInput *NONNULL_PTR this_ptr, uint64_t val); /** - * Frees any resources used by the PhantomKeysManager, if is_owned is set and inner is non-NULL. + * Constructs a new Input given each field */ -void PhantomKeysManager_free(struct LDKPhantomKeysManager this_obj); +MUST_USE_RES struct LDKInput Input_new(struct LDKOutPoint outpoint_arg, struct LDKTxOut previous_utxo_arg, uint64_t satisfaction_weight_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 Input */ -struct LDKEntropySource PhantomKeysManager_as_EntropySource(const struct LDKPhantomKeysManager *NONNULL_PTR this_arg); +struct LDKInput Input_clone(const struct LDKInput *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 + * Generates a non-cryptographic 64-bit hash of the Input. */ -struct LDKNodeSigner PhantomKeysManager_as_NodeSigner(const struct LDKPhantomKeysManager *NONNULL_PTR this_arg); +uint64_t Input_hash(const struct LDKInput *NONNULL_PTR o); /** - * Constructs a new OutputSpender which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned OutputSpender must be freed before this_arg is + * 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. */ -struct LDKOutputSpender PhantomKeysManager_as_OutputSpender(const struct LDKPhantomKeysManager *NONNULL_PTR this_arg); +bool Input_eq(const struct LDKInput *NONNULL_PTR a, const struct LDKInput *NONNULL_PTR b); /** - * 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 + * Frees any resources used by the Utxo, if is_owned is set and inner is non-NULL. */ -struct LDKSignerProvider PhantomKeysManager_as_SignerProvider(const struct LDKPhantomKeysManager *NONNULL_PTR this_arg); +void Utxo_free(struct LDKUtxo this_obj); /** - * 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 unique identifier of the output. */ -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]); +struct LDKOutPoint Utxo_get_outpoint(const struct LDKUtxo *NONNULL_PTR this_ptr); /** - * See [`KeysManager::derive_channel_keys`] for documentation on this method. + * The unique identifier of the output. */ -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]); +void Utxo_set_outpoint(struct LDKUtxo *NONNULL_PTR this_ptr, struct LDKOutPoint val); /** - * Gets the \"node_id\" secret key used to sign gossip announcements, decode onion data, etc. + * The output to spend. */ -MUST_USE_RES struct LDKSecretKey PhantomKeysManager_get_node_secret_key(const struct LDKPhantomKeysManager *NONNULL_PTR this_arg); +struct LDKTxOut Utxo_get_output(const struct LDKUtxo *NONNULL_PTR this_ptr); /** - * Gets the \"node_id\" secret key of the phantom node used to sign invoices, decode the - * last-hop onion data, etc. + * The output to spend. */ -MUST_USE_RES struct LDKSecretKey PhantomKeysManager_get_phantom_node_secret_key(const struct LDKPhantomKeysManager *NONNULL_PTR this_arg); +void Utxo_set_output(struct LDKUtxo *NONNULL_PTR this_ptr, struct LDKTxOut val); /** - * Frees any resources used by the RandomBytes, if is_owned is set and inner is non-NULL. + * 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 RandomBytes_free(struct LDKRandomBytes this_obj); +uint64_t Utxo_get_satisfaction_weight(const struct LDKUtxo *NONNULL_PTR this_ptr); /** - * Creates a new instance using the given seed. + * 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`]. */ -MUST_USE_RES struct LDKRandomBytes RandomBytes_new(struct LDKThirtyTwoBytes seed); +void Utxo_set_satisfaction_weight(struct LDKUtxo *NONNULL_PTR this_ptr, uint64_t 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 + * Constructs a new Utxo given each field */ -struct LDKEntropySource RandomBytes_as_EntropySource(const struct LDKRandomBytes *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKUtxo Utxo_new(struct LDKOutPoint outpoint_arg, struct LDKTxOut output_arg, uint64_t satisfaction_weight_arg); /** - * Calls the free function if one is set + * Creates a copy of the Utxo */ -void EcdsaChannelSigner_free(struct LDKEcdsaChannelSigner this_ptr); +struct LDKUtxo Utxo_clone(const struct LDKUtxo *NONNULL_PTR orig); /** - * Creates a copy of a WriteableEcdsaChannelSigner + * Generates a non-cryptographic 64-bit hash of the Utxo. */ -struct LDKWriteableEcdsaChannelSigner WriteableEcdsaChannelSigner_clone(const struct LDKWriteableEcdsaChannelSigner *NONNULL_PTR orig); +uint64_t Utxo_hash(const struct LDKUtxo *NONNULL_PTR o); /** - * Calls the free function if one is set + * 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. */ -void WriteableEcdsaChannelSigner_free(struct LDKWriteableEcdsaChannelSigner this_ptr); +bool Utxo_eq(const struct LDKUtxo *NONNULL_PTR a, const struct LDKUtxo *NONNULL_PTR b); /** - * Frees any resources used by the OnionMessenger, if is_owned is set and inner is non-NULL. + * Returns a `Utxo` with the `satisfaction_weight` estimate for a legacy P2PKH output. */ -void OnionMessenger_free(struct LDKOnionMessenger this_obj); +MUST_USE_RES struct LDKUtxo Utxo_new_p2pkh(struct LDKOutPoint outpoint, uint64_t value, const uint8_t (*pubkey_hash)[20]); /** - * Calls the free function if one is set + * Frees any resources used by the CoinSelection, if is_owned is set and inner is non-NULL. */ -void MessageRouter_free(struct LDKMessageRouter this_ptr); +void CoinSelection_free(struct LDKCoinSelection this_obj); /** - * Frees any resources used by the DefaultMessageRouter, if is_owned is set and inner is non-NULL. + * The set of UTXOs (with at least 1 confirmation) to spend and use within a transaction + * requiring additional fees. */ -void DefaultMessageRouter_free(struct LDKDefaultMessageRouter this_obj); +struct LDKCVec_UtxoZ CoinSelection_get_confirmed_utxos(const struct LDKCoinSelection *NONNULL_PTR this_ptr); /** - * Creates a [`DefaultMessageRouter`] using the given [`NetworkGraph`]. + * The set of UTXOs (with at least 1 confirmation) to spend and use within a transaction + * requiring additional fees. */ -MUST_USE_RES struct LDKDefaultMessageRouter DefaultMessageRouter_new(const struct LDKNetworkGraph *NONNULL_PTR network_graph, struct LDKEntropySource entropy_source); +void CoinSelection_set_confirmed_utxos(struct LDKCoinSelection *NONNULL_PTR this_ptr, struct LDKCVec_UtxoZ val); /** - * 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 + * 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 LDKMessageRouter DefaultMessageRouter_as_MessageRouter(const struct LDKDefaultMessageRouter *NONNULL_PTR this_arg); +struct LDKCOption_TxOutZ CoinSelection_get_change_output(const struct LDKCoinSelection *NONNULL_PTR this_ptr); /** - * Frees any resources used by the OnionMessagePath, if is_owned is set and inner is non-NULL. + * 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 OnionMessagePath_free(struct LDKOnionMessagePath this_obj); +void CoinSelection_set_change_output(struct LDKCoinSelection *NONNULL_PTR this_ptr, struct LDKCOption_TxOutZ val); /** - * Nodes on the path between the sender and the destination. - * - * Returns a copy of the field. + * Constructs a new CoinSelection given each field */ -struct LDKCVec_PublicKeyZ OnionMessagePath_get_intermediate_nodes(const struct LDKOnionMessagePath *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCoinSelection CoinSelection_new(struct LDKCVec_UtxoZ confirmed_utxos_arg, struct LDKCOption_TxOutZ change_output_arg); /** - * Nodes on the path between the sender and the destination. + * Creates a copy of the CoinSelection */ -void OnionMessagePath_set_intermediate_nodes(struct LDKOnionMessagePath *NONNULL_PTR this_ptr, struct LDKCVec_PublicKeyZ val); +struct LDKCoinSelection CoinSelection_clone(const struct LDKCoinSelection *NONNULL_PTR orig); /** - * The recipient of the message. + * Calls the free function if one is set */ -struct LDKDestination OnionMessagePath_get_destination(const struct LDKOnionMessagePath *NONNULL_PTR this_ptr); +void CoinSelectionSource_free(struct LDKCoinSelectionSource this_ptr); /** - * The recipient of the message. + * Calls the free function if one is set */ -void OnionMessagePath_set_destination(struct LDKOnionMessagePath *NONNULL_PTR this_ptr, struct LDKDestination val); +void WalletSource_free(struct LDKWalletSource this_ptr); /** - * Addresses that may be used to connect to [`OnionMessagePath::first_node`]. - * - * Only needs to be set if a connection to the node is required. [`OnionMessenger`] may use - * this to initiate such a connection. - * - * Returns a copy of the field. + * Frees any resources used by the Wallet, if is_owned is set and inner is non-NULL. */ -struct LDKCOption_CVec_SocketAddressZZ OnionMessagePath_get_first_node_addresses(const struct LDKOnionMessagePath *NONNULL_PTR this_ptr); +void Wallet_free(struct LDKWallet this_obj); /** - * Addresses that may be used to connect to [`OnionMessagePath::first_node`]. - * - * Only needs to be set if a connection to the node is required. [`OnionMessenger`] may use - * this to initiate such a connection. + * Returns a new instance backed by the given [`WalletSource`] that serves as an implementation + * of [`CoinSelectionSource`]. */ -void OnionMessagePath_set_first_node_addresses(struct LDKOnionMessagePath *NONNULL_PTR this_ptr, struct LDKCOption_CVec_SocketAddressZZ val); +MUST_USE_RES struct LDKWallet Wallet_new(struct LDKWalletSource source, struct LDKLogger logger); /** - * Constructs a new OnionMessagePath given each field + * 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 */ -MUST_USE_RES struct LDKOnionMessagePath OnionMessagePath_new(struct LDKCVec_PublicKeyZ intermediate_nodes_arg, struct LDKDestination destination_arg, struct LDKCOption_CVec_SocketAddressZZ first_node_addresses_arg); +struct LDKCoinSelectionSource Wallet_as_CoinSelectionSource(const struct LDKWallet *NONNULL_PTR this_arg); /** - * Creates a copy of the OnionMessagePath + * Frees any resources used by the BumpTransactionEventHandler, if is_owned is set and inner is non-NULL. */ -struct LDKOnionMessagePath OnionMessagePath_clone(const struct LDKOnionMessagePath *NONNULL_PTR orig); +void BumpTransactionEventHandler_free(struct LDKBumpTransactionEventHandler this_obj); /** - * Returns the first node in the path. + * Returns a new instance capable of handling [`Event::BumpTransaction`] events. * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * [`Event::BumpTransaction`]: crate::events::Event::BumpTransaction */ -MUST_USE_RES struct LDKPublicKey OnionMessagePath_first_node(const struct LDKOnionMessagePath *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKBumpTransactionEventHandler BumpTransactionEventHandler_new(struct LDKBroadcasterInterface broadcaster, struct LDKCoinSelectionSource utxo_source, struct LDKSignerProvider signer_provider, struct LDKLogger logger); /** - * Frees any resources used by the Destination + * Handles all variants of [`BumpTransactionEvent`]. */ -void Destination_free(struct LDKDestination this_ptr); +void BumpTransactionEventHandler_handle_event(const struct LDKBumpTransactionEventHandler *NONNULL_PTR this_arg, const struct LDKBumpTransactionEvent *NONNULL_PTR event); /** - * Creates a copy of the Destination + * 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 LDKDestination Destination_clone(const struct LDKDestination *NONNULL_PTR orig); +bool InitFeatures_eq(const struct LDKInitFeatures *NONNULL_PTR a, const struct LDKInitFeatures *NONNULL_PTR b); /** - * Utility method to constructs a new Node-variant Destination + * 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 LDKDestination Destination_node(struct LDKPublicKey a); +bool NodeFeatures_eq(const struct LDKNodeFeatures *NONNULL_PTR a, const struct LDKNodeFeatures *NONNULL_PTR b); /** - * Utility method to constructs a new BlindedPath-variant Destination + * 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. */ -struct LDKDestination Destination_blinded_path(struct LDKBlindedPath a); +bool ChannelFeatures_eq(const struct LDKChannelFeatures *NONNULL_PTR a, const struct LDKChannelFeatures *NONNULL_PTR b); /** - * Generates a non-cryptographic 64-bit hash of the Destination. + * 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. */ -uint64_t Destination_hash(const struct LDKDestination *NONNULL_PTR o); +bool Bolt11InvoiceFeatures_eq(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR a, const struct LDKBolt11InvoiceFeatures *NONNULL_PTR b); /** - * Checks if two Destinations contain equal inner contents. + * 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. */ -bool Destination_eq(const struct LDKDestination *NONNULL_PTR a, const struct LDKDestination *NONNULL_PTR b); +bool OfferFeatures_eq(const struct LDKOfferFeatures *NONNULL_PTR a, const struct LDKOfferFeatures *NONNULL_PTR b); /** - * Attempts to resolve the [`IntroductionNode::DirectedShortChannelId`] of a - * [`Destination::BlindedPath`] to a [`IntroductionNode::NodeId`], if applicable, using the - * provided [`ReadOnlyNetworkGraph`]. + * 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. */ -void Destination_resolve(struct LDKDestination *NONNULL_PTR this_arg, const struct LDKReadOnlyNetworkGraph *NONNULL_PTR network_graph); +bool InvoiceRequestFeatures_eq(const struct LDKInvoiceRequestFeatures *NONNULL_PTR a, const struct LDKInvoiceRequestFeatures *NONNULL_PTR b); /** - * Frees any resources used by the SendSuccess + * 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. */ -void SendSuccess_free(struct LDKSendSuccess this_ptr); +bool Bolt12InvoiceFeatures_eq(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR a, const struct LDKBolt12InvoiceFeatures *NONNULL_PTR b); /** - * Creates a copy of the SendSuccess + * 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 LDKSendSuccess SendSuccess_clone(const struct LDKSendSuccess *NONNULL_PTR orig); +bool BlindedHopFeatures_eq(const struct LDKBlindedHopFeatures *NONNULL_PTR a, const struct LDKBlindedHopFeatures *NONNULL_PTR b); /** - * Utility method to constructs a new Buffered-variant SendSuccess + * 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 LDKSendSuccess SendSuccess_buffered(void); +bool ChannelTypeFeatures_eq(const struct LDKChannelTypeFeatures *NONNULL_PTR a, const struct LDKChannelTypeFeatures *NONNULL_PTR b); /** - * Utility method to constructs a new BufferedAwaitingConnection-variant SendSuccess + * Creates a copy of the InitFeatures */ -struct LDKSendSuccess SendSuccess_buffered_awaiting_connection(struct LDKPublicKey a); +struct LDKInitFeatures InitFeatures_clone(const struct LDKInitFeatures *NONNULL_PTR orig); /** - * Generates a non-cryptographic 64-bit hash of the SendSuccess. + * Creates a copy of the NodeFeatures */ -uint64_t SendSuccess_hash(const struct LDKSendSuccess *NONNULL_PTR o); +struct LDKNodeFeatures NodeFeatures_clone(const struct LDKNodeFeatures *NONNULL_PTR orig); /** - * Checks if two SendSuccesss contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Creates a copy of the ChannelFeatures */ -bool SendSuccess_eq(const struct LDKSendSuccess *NONNULL_PTR a, const struct LDKSendSuccess *NONNULL_PTR b); +struct LDKChannelFeatures ChannelFeatures_clone(const struct LDKChannelFeatures *NONNULL_PTR orig); /** - * Frees any resources used by the SendError + * Creates a copy of the Bolt11InvoiceFeatures */ -void SendError_free(struct LDKSendError this_ptr); +struct LDKBolt11InvoiceFeatures Bolt11InvoiceFeatures_clone(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR orig); /** - * Creates a copy of the SendError + * Creates a copy of the OfferFeatures */ -struct LDKSendError SendError_clone(const struct LDKSendError *NONNULL_PTR orig); +struct LDKOfferFeatures OfferFeatures_clone(const struct LDKOfferFeatures *NONNULL_PTR orig); /** - * Utility method to constructs a new Secp256k1-variant SendError + * Creates a copy of the InvoiceRequestFeatures */ -struct LDKSendError SendError_secp256k1(enum LDKSecp256k1Error a); +struct LDKInvoiceRequestFeatures InvoiceRequestFeatures_clone(const struct LDKInvoiceRequestFeatures *NONNULL_PTR orig); /** - * Utility method to constructs a new TooBigPacket-variant SendError + * Creates a copy of the Bolt12InvoiceFeatures */ -struct LDKSendError SendError_too_big_packet(void); +struct LDKBolt12InvoiceFeatures Bolt12InvoiceFeatures_clone(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR orig); /** - * Utility method to constructs a new TooFewBlindedHops-variant SendError + * Creates a copy of the BlindedHopFeatures */ -struct LDKSendError SendError_too_few_blinded_hops(void); +struct LDKBlindedHopFeatures BlindedHopFeatures_clone(const struct LDKBlindedHopFeatures *NONNULL_PTR orig); /** - * Utility method to constructs a new InvalidFirstHop-variant SendError + * Creates a copy of the ChannelTypeFeatures */ -struct LDKSendError SendError_invalid_first_hop(struct LDKPublicKey a); +struct LDKChannelTypeFeatures ChannelTypeFeatures_clone(const struct LDKChannelTypeFeatures *NONNULL_PTR orig); /** - * Utility method to constructs a new PathNotFound-variant SendError + * Generates a non-cryptographic 64-bit hash of the InitFeatures. */ -struct LDKSendError SendError_path_not_found(void); +uint64_t InitFeatures_hash(const struct LDKInitFeatures *NONNULL_PTR o); /** - * Utility method to constructs a new InvalidMessage-variant SendError + * Generates a non-cryptographic 64-bit hash of the NodeFeatures. */ -struct LDKSendError SendError_invalid_message(void); +uint64_t NodeFeatures_hash(const struct LDKNodeFeatures *NONNULL_PTR o); /** - * Utility method to constructs a new BufferFull-variant SendError + * Generates a non-cryptographic 64-bit hash of the ChannelFeatures. */ -struct LDKSendError SendError_buffer_full(void); +uint64_t ChannelFeatures_hash(const struct LDKChannelFeatures *NONNULL_PTR o); /** - * Utility method to constructs a new GetNodeIdFailed-variant SendError + * Generates a non-cryptographic 64-bit hash of the Bolt11InvoiceFeatures. */ -struct LDKSendError SendError_get_node_id_failed(void); +uint64_t Bolt11InvoiceFeatures_hash(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR o); /** - * Utility method to constructs a new UnresolvedIntroductionNode-variant SendError + * Generates a non-cryptographic 64-bit hash of the OfferFeatures. */ -struct LDKSendError SendError_unresolved_introduction_node(void); +uint64_t OfferFeatures_hash(const struct LDKOfferFeatures *NONNULL_PTR o); /** - * Utility method to constructs a new BlindedPathAdvanceFailed-variant SendError + * Generates a non-cryptographic 64-bit hash of the InvoiceRequestFeatures. */ -struct LDKSendError SendError_blinded_path_advance_failed(void); +uint64_t InvoiceRequestFeatures_hash(const struct LDKInvoiceRequestFeatures *NONNULL_PTR o); /** - * Generates a non-cryptographic 64-bit hash of the SendError. + * Generates a non-cryptographic 64-bit hash of the Bolt12InvoiceFeatures. */ -uint64_t SendError_hash(const struct LDKSendError *NONNULL_PTR o); +uint64_t Bolt12InvoiceFeatures_hash(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR o); /** - * Checks if two SendErrors 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 BlindedHopFeatures. */ -bool SendError_eq(const struct LDKSendError *NONNULL_PTR a, const struct LDKSendError *NONNULL_PTR b); +uint64_t BlindedHopFeatures_hash(const struct LDKBlindedHopFeatures *NONNULL_PTR o); /** - * Calls the free function if one is set + * Generates a non-cryptographic 64-bit hash of the ChannelTypeFeatures. */ -void CustomOnionMessageHandler_free(struct LDKCustomOnionMessageHandler this_ptr); +uint64_t ChannelTypeFeatures_hash(const struct LDKChannelTypeFeatures *NONNULL_PTR o); /** - * Frees any resources used by the PeeledOnion + * Frees any resources used by the InitFeatures, if is_owned is set and inner is non-NULL. */ -void PeeledOnion_free(struct LDKPeeledOnion this_ptr); +void InitFeatures_free(struct LDKInitFeatures this_obj); /** - * Creates a copy of the PeeledOnion + * Frees any resources used by the NodeFeatures, if is_owned is set and inner is non-NULL. */ -struct LDKPeeledOnion PeeledOnion_clone(const struct LDKPeeledOnion *NONNULL_PTR orig); +void NodeFeatures_free(struct LDKNodeFeatures this_obj); /** - * Utility method to constructs a new Forward-variant PeeledOnion + * Frees any resources used by the ChannelFeatures, if is_owned is set and inner is non-NULL. */ -struct LDKPeeledOnion PeeledOnion_forward(struct LDKNextMessageHop a, struct LDKOnionMessage b); +void ChannelFeatures_free(struct LDKChannelFeatures this_obj); /** - * Utility method to constructs a new Receive-variant PeeledOnion + * Frees any resources used by the Bolt11InvoiceFeatures, if is_owned is set and inner is non-NULL. */ -struct LDKPeeledOnion PeeledOnion_receive(struct LDKParsedOnionMessageContents a, struct LDKThirtyTwoBytes b, struct LDKBlindedPath c); +void Bolt11InvoiceFeatures_free(struct LDKBolt11InvoiceFeatures this_obj); /** - * Creates an [`OnionMessage`] with the given `contents` for sending to the destination of - * `path`, first calling [`Destination::resolve`] on `path.destination` with the given - * [`ReadOnlyNetworkGraph`]. - * - * Returns the node id of the peer to send the message to, the message itself, and any addresses - * needed to connect to the first node. - * - * Note that reply_path (or a relevant inner pointer) may be NULL or all-0s to represent None + * Frees any resources used by the OfferFeatures, if is_owned is set and inner is non-NULL. */ -struct LDKCResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ create_onion_message_resolving_destination(const struct LDKEntropySource *NONNULL_PTR entropy_source, const struct LDKNodeSigner *NONNULL_PTR node_signer, const struct LDKNodeIdLookUp *NONNULL_PTR node_id_lookup, const struct LDKReadOnlyNetworkGraph *NONNULL_PTR network_graph, struct LDKOnionMessagePath path, struct LDKOnionMessageContents contents, struct LDKBlindedPath reply_path); +void OfferFeatures_free(struct LDKOfferFeatures this_obj); /** - * Creates an [`OnionMessage`] with the given `contents` for sending to the destination of - * `path`. - * - * Returns the node id of the peer to send the message to, the message itself, and any addresses - * needed to connect to the first node. - * - * Returns [`SendError::UnresolvedIntroductionNode`] if: - * - `destination` contains a blinded path with an [`IntroductionNode::DirectedShortChannelId`], - * - unless it can be resolved by [`NodeIdLookUp::next_node_id`]. - * Use [`create_onion_message_resolving_destination`] instead to resolve the introduction node - * first with a [`ReadOnlyNetworkGraph`]. - * - * Note that reply_path (or a relevant inner pointer) may be NULL or all-0s to represent None + * Frees any resources used by the InvoiceRequestFeatures, if is_owned is set and inner is non-NULL. */ -struct LDKCResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ create_onion_message(const struct LDKEntropySource *NONNULL_PTR entropy_source, const struct LDKNodeSigner *NONNULL_PTR node_signer, const struct LDKNodeIdLookUp *NONNULL_PTR node_id_lookup, struct LDKOnionMessagePath path, struct LDKOnionMessageContents contents, struct LDKBlindedPath reply_path); +void InvoiceRequestFeatures_free(struct LDKInvoiceRequestFeatures this_obj); /** - * Decode one layer of an incoming [`OnionMessage`]. - * - * Returns either the next layer of the onion for forwarding or the decrypted content for the - * receiver. + * Frees any resources used by the Bolt12InvoiceFeatures, if is_owned is set and inner is non-NULL. */ -struct LDKCResult_PeeledOnionNoneZ peel_onion_message(const struct LDKOnionMessage *NONNULL_PTR msg, struct LDKNodeSigner node_signer, struct LDKLogger logger, struct LDKCustomOnionMessageHandler custom_handler); +void Bolt12InvoiceFeatures_free(struct LDKBolt12InvoiceFeatures this_obj); /** - * Constructs a new `OnionMessenger` to send, forward, and delegate received onion messages to - * their respective handlers. + * Frees any resources used by the BlindedHopFeatures, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKOnionMessenger OnionMessenger_new(struct LDKEntropySource entropy_source, struct LDKNodeSigner node_signer, struct LDKLogger logger, struct LDKNodeIdLookUp node_id_lookup, struct LDKMessageRouter message_router, struct LDKOffersMessageHandler offers_handler, struct LDKCustomOnionMessageHandler custom_handler); +void BlindedHopFeatures_free(struct LDKBlindedHopFeatures this_obj); /** - * Sends an [`OnionMessage`] with the given `contents` to `destination`. - * - * See [`OnionMessenger`] for example usage. - * - * Note that reply_path (or a relevant inner pointer) may be NULL or all-0s to represent None + * Frees any resources used by the ChannelTypeFeatures, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKCResult_SendSuccessSendErrorZ OnionMessenger_send_onion_message(const struct LDKOnionMessenger *NONNULL_PTR this_arg, struct LDKOnionMessageContents contents, struct LDKDestination destination, struct LDKBlindedPath reply_path); +void ChannelTypeFeatures_free(struct LDKChannelTypeFeatures this_obj); /** - * 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 + * Getting a route for a keysend payment to a private node requires providing the payee's + * features (since they were not announced in a node announcement). However, keysend payments + * don't have an invoice to pull the payee's features from, so this method is provided for use + * when a [`Bolt11InvoiceFeatures`] is required in a route. + * + * MPP keysend is not widely supported yet, so we parameterize support to allow the user to + * choose whether their router should find multi-part routes. */ -struct LDKOnionMessageHandler OnionMessenger_as_OnionMessageHandler(const struct LDKOnionMessenger *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKBolt11InvoiceFeatures Bolt11InvoiceFeatures_for_keysend(bool allow_mpp); /** - * Calls the free function if one is set + * Constructs a ChannelTypeFeatures with only static_remotekey set */ -void OffersMessageHandler_free(struct LDKOffersMessageHandler this_ptr); +MUST_USE_RES struct LDKChannelTypeFeatures ChannelTypeFeatures_only_static_remote_key(void); /** - * Frees any resources used by the OffersMessage + * Constructs a ChannelTypeFeatures with anchors support */ -void OffersMessage_free(struct LDKOffersMessage this_ptr); +MUST_USE_RES struct LDKChannelTypeFeatures ChannelTypeFeatures_anchors_zero_htlc_fee_and_dependencies(void); /** - * Creates a copy of the OffersMessage + * Create a blank Features with no features set */ -struct LDKOffersMessage OffersMessage_clone(const struct LDKOffersMessage *NONNULL_PTR orig); +MUST_USE_RES struct LDKInitFeatures InitFeatures_empty(void); /** - * Utility method to constructs a new InvoiceRequest-variant OffersMessage + * Returns the feature set as a list of bytes, in little-endian. This is in reverse byte order + * from most on-the-wire encodings. */ -struct LDKOffersMessage OffersMessage_invoice_request(struct LDKInvoiceRequest a); +MUST_USE_RES struct LDKu8slice InitFeatures_le_flags(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new Invoice-variant OffersMessage + * Returns true if this `Features` has any optional flags set */ -struct LDKOffersMessage OffersMessage_invoice(struct LDKBolt12Invoice a); +MUST_USE_RES bool InitFeatures_supports_any_optional_bits(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new InvoiceError-variant OffersMessage + * Returns true if this `Features` object contains required features unknown by `other`. */ -struct LDKOffersMessage OffersMessage_invoice_error(struct LDKInvoiceError a); +MUST_USE_RES bool InitFeatures_requires_unknown_bits_from(const struct LDKInitFeatures *NONNULL_PTR this_arg, const struct LDKInitFeatures *NONNULL_PTR other); /** - * Returns whether `tlv_type` corresponds to a TLV record for Offers. + * Returns the set of required features unknown by `other`, as their bit position. */ -MUST_USE_RES bool OffersMessage_is_known_type(uint64_t tlv_type); +MUST_USE_RES struct LDKCVec_u64Z InitFeatures_required_unknown_bits_from(const struct LDKInitFeatures *NONNULL_PTR this_arg, const struct LDKInitFeatures *NONNULL_PTR other); /** - * Constructs a new OnionMessageContents which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned OnionMessageContents must be freed before this_arg is + * Returns true if this `Features` object contains unknown feature flags which are set as + * \"required\". */ -struct LDKOnionMessageContents OffersMessage_as_OnionMessageContents(const struct LDKOffersMessage *NONNULL_PTR this_arg); +MUST_USE_RES bool InitFeatures_requires_unknown_bits(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Serialize the OffersMessage object into a byte array which can be read by OffersMessage_read + * Returns true if this `Features` supports any bits which we do not know of */ -struct LDKCVec_u8Z OffersMessage_write(const struct LDKOffersMessage *NONNULL_PTR obj); +MUST_USE_RES bool InitFeatures_supports_unknown_bits(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Read a OffersMessage from a byte array, created by OffersMessage_write + * Sets a required feature bit. Errors if `bit` is outside the feature range as defined + * by [BOLT 9]. + * + * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will + * be set instead (i.e., `bit - 1`). + * + * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md */ -struct LDKCResult_OffersMessageDecodeErrorZ OffersMessage_read(struct LDKu8slice ser, uint64_t arg_a, const struct LDKLogger *NONNULL_PTR arg_b); +MUST_USE_RES struct LDKCResult_NoneNoneZ InitFeatures_set_required_feature_bit(struct LDKInitFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Frees any resources used by the Packet, if is_owned is set and inner is non-NULL. + * Sets an optional feature bit. Errors if `bit` is outside the feature range as defined + * by [BOLT 9]. + * + * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be + * set instead (i.e., `bit + 1`). + * + * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md */ -void Packet_free(struct LDKPacket this_obj); +MUST_USE_RES struct LDKCResult_NoneNoneZ InitFeatures_set_optional_feature_bit(struct LDKInitFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Bolt 04 version number + * 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 */ -uint8_t Packet_get_version(const struct LDKPacket *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCResult_NoneNoneZ InitFeatures_set_required_custom_bit(struct LDKInitFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Bolt 04 version number + * 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 Packet_set_version(struct LDKPacket *NONNULL_PTR this_ptr, uint8_t val); +MUST_USE_RES struct LDKCResult_NoneNoneZ InitFeatures_set_optional_custom_bit(struct LDKInitFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * A random sepc256k1 point, used to build the ECDH shared secret to decrypt hop_data + * Create a blank Features with no features set */ -struct LDKPublicKey Packet_get_public_key(const struct LDKPacket *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKNodeFeatures NodeFeatures_empty(void); /** - * A random sepc256k1 point, used to build the ECDH shared secret to decrypt hop_data + * Returns the feature set as a list of bytes, in little-endian. This is in reverse byte order + * from most on-the-wire encodings. */ -void Packet_set_public_key(struct LDKPacket *NONNULL_PTR this_ptr, struct LDKPublicKey val); +MUST_USE_RES struct LDKu8slice NodeFeatures_le_flags(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Encrypted payload for the next hop - * - * Returns a copy of the field. + * Returns true if this `Features` has any optional flags set */ -struct LDKCVec_u8Z Packet_get_hop_data(const struct LDKPacket *NONNULL_PTR this_ptr); +MUST_USE_RES bool NodeFeatures_supports_any_optional_bits(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Encrypted payload for the next hop + * Returns true if this `Features` object contains required features unknown by `other`. */ -void Packet_set_hop_data(struct LDKPacket *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); +MUST_USE_RES bool NodeFeatures_requires_unknown_bits_from(const struct LDKNodeFeatures *NONNULL_PTR this_arg, const struct LDKNodeFeatures *NONNULL_PTR other); /** - * HMAC to verify the integrity of hop_data + * Returns the set of required features unknown by `other`, as their bit position. */ -const uint8_t (*Packet_get_hmac(const struct LDKPacket *NONNULL_PTR this_ptr))[32]; +MUST_USE_RES struct LDKCVec_u64Z NodeFeatures_required_unknown_bits_from(const struct LDKNodeFeatures *NONNULL_PTR this_arg, const struct LDKNodeFeatures *NONNULL_PTR other); /** - * HMAC to verify the integrity of hop_data + * Returns true if this `Features` object contains unknown feature flags which are set as + * \"required\". */ -void Packet_set_hmac(struct LDKPacket *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +MUST_USE_RES bool NodeFeatures_requires_unknown_bits(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Constructs a new Packet given each field + * Returns true if this `Features` supports any bits which we do not know of */ -MUST_USE_RES struct LDKPacket Packet_new(uint8_t version_arg, struct LDKPublicKey public_key_arg, struct LDKCVec_u8Z hop_data_arg, struct LDKThirtyTwoBytes hmac_arg); +MUST_USE_RES bool NodeFeatures_supports_unknown_bits(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the Packet + * Sets a required feature bit. Errors if `bit` is outside the feature range as defined + * by [BOLT 9]. + * + * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will + * be set instead (i.e., `bit - 1`). + * + * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md */ -struct LDKPacket Packet_clone(const struct LDKPacket *NONNULL_PTR orig); +MUST_USE_RES struct LDKCResult_NoneNoneZ NodeFeatures_set_required_feature_bit(struct LDKNodeFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Generates a non-cryptographic 64-bit hash of the Packet. + * Sets an optional feature bit. Errors if `bit` is outside the feature range as defined + * by [BOLT 9]. + * + * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be + * set instead (i.e., `bit + 1`). + * + * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md */ -uint64_t Packet_hash(const struct LDKPacket *NONNULL_PTR o); +MUST_USE_RES struct LDKCResult_NoneNoneZ NodeFeatures_set_optional_feature_bit(struct LDKNodeFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Checks if two Packets 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. + * 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 Packet_eq(const struct LDKPacket *NONNULL_PTR a, const struct LDKPacket *NONNULL_PTR b); +MUST_USE_RES struct LDKCResult_NoneNoneZ NodeFeatures_set_required_custom_bit(struct LDKNodeFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Serialize the Packet object into a byte array which can be read by Packet_read + * 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 LDKCVec_u8Z Packet_write(const struct LDKPacket *NONNULL_PTR obj); +MUST_USE_RES struct LDKCResult_NoneNoneZ NodeFeatures_set_optional_custom_bit(struct LDKNodeFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Frees any resources used by the ParsedOnionMessageContents + * Create a blank Features with no features set */ -void ParsedOnionMessageContents_free(struct LDKParsedOnionMessageContents this_ptr); +MUST_USE_RES struct LDKChannelFeatures ChannelFeatures_empty(void); /** - * Creates a copy of the ParsedOnionMessageContents + * Returns the feature set as a list of bytes, in little-endian. This is in reverse byte order + * from most on-the-wire encodings. */ -struct LDKParsedOnionMessageContents ParsedOnionMessageContents_clone(const struct LDKParsedOnionMessageContents *NONNULL_PTR orig); +MUST_USE_RES struct LDKu8slice ChannelFeatures_le_flags(const struct LDKChannelFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new Offers-variant ParsedOnionMessageContents + * Returns true if this `Features` has any optional flags set */ -struct LDKParsedOnionMessageContents ParsedOnionMessageContents_offers(struct LDKOffersMessage a); +MUST_USE_RES bool ChannelFeatures_supports_any_optional_bits(const struct LDKChannelFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new Custom-variant ParsedOnionMessageContents + * Returns true if this `Features` object contains required features unknown by `other`. */ -struct LDKParsedOnionMessageContents ParsedOnionMessageContents_custom(struct LDKOnionMessageContents a); +MUST_USE_RES bool ChannelFeatures_requires_unknown_bits_from(const struct LDKChannelFeatures *NONNULL_PTR this_arg, const struct LDKChannelFeatures *NONNULL_PTR other); /** - * Constructs a new OnionMessageContents which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned OnionMessageContents must be freed before this_arg is + * Returns the set of required features unknown by `other`, as their bit position. */ -struct LDKOnionMessageContents ParsedOnionMessageContents_as_OnionMessageContents(const struct LDKParsedOnionMessageContents *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCVec_u64Z ChannelFeatures_required_unknown_bits_from(const struct LDKChannelFeatures *NONNULL_PTR this_arg, const struct LDKChannelFeatures *NONNULL_PTR other); /** - * Serialize the ParsedOnionMessageContents object into a byte array which can be read by ParsedOnionMessageContents_read + * Returns true if this `Features` object contains unknown feature flags which are set as + * \"required\". */ -struct LDKCVec_u8Z ParsedOnionMessageContents_write(const struct LDKParsedOnionMessageContents *NONNULL_PTR obj); +MUST_USE_RES bool ChannelFeatures_requires_unknown_bits(const struct LDKChannelFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of a OnionMessageContents + * Returns true if this `Features` supports any bits which we do not know of */ -struct LDKOnionMessageContents OnionMessageContents_clone(const struct LDKOnionMessageContents *NONNULL_PTR orig); +MUST_USE_RES bool ChannelFeatures_supports_unknown_bits(const struct LDKChannelFeatures *NONNULL_PTR this_arg); /** - * Calls the free function if one is set + * Sets a required feature bit. Errors if `bit` is outside the feature range as defined + * by [BOLT 9]. + * + * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will + * be set instead (i.e., `bit - 1`). + * + * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md */ -void OnionMessageContents_free(struct LDKOnionMessageContents this_ptr); +MUST_USE_RES struct LDKCResult_NoneNoneZ ChannelFeatures_set_required_feature_bit(struct LDKChannelFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Frees any resources used by the NextMessageHop + * Sets an optional feature bit. Errors if `bit` is outside the feature range as defined + * by [BOLT 9]. + * + * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be + * set instead (i.e., `bit + 1`). + * + * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md */ -void NextMessageHop_free(struct LDKNextMessageHop this_ptr); +MUST_USE_RES struct LDKCResult_NoneNoneZ ChannelFeatures_set_optional_feature_bit(struct LDKChannelFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Creates a copy of the NextMessageHop + * 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 LDKNextMessageHop NextMessageHop_clone(const struct LDKNextMessageHop *NONNULL_PTR orig); +MUST_USE_RES struct LDKCResult_NoneNoneZ ChannelFeatures_set_required_custom_bit(struct LDKChannelFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Utility method to constructs a new NodeId-variant NextMessageHop + * 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 LDKNextMessageHop NextMessageHop_node_id(struct LDKPublicKey a); +MUST_USE_RES struct LDKCResult_NoneNoneZ ChannelFeatures_set_optional_custom_bit(struct LDKChannelFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Utility method to constructs a new ShortChannelId-variant NextMessageHop + * Create a blank Features with no features set */ -struct LDKNextMessageHop NextMessageHop_short_channel_id(uint64_t a); +MUST_USE_RES struct LDKBolt11InvoiceFeatures Bolt11InvoiceFeatures_empty(void); /** - * Generates a non-cryptographic 64-bit hash of the NextMessageHop. + * Returns the feature set as a list of bytes, in little-endian. This is in reverse byte order + * from most on-the-wire encodings. */ -uint64_t NextMessageHop_hash(const struct LDKNextMessageHop *NONNULL_PTR o); +MUST_USE_RES struct LDKu8slice Bolt11InvoiceFeatures_le_flags(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Checks if two NextMessageHops contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Returns true if this `Features` has any optional flags set */ -bool NextMessageHop_eq(const struct LDKNextMessageHop *NONNULL_PTR a, const struct LDKNextMessageHop *NONNULL_PTR b); +MUST_USE_RES bool Bolt11InvoiceFeatures_supports_any_optional_bits(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the BlindedPath, if is_owned is set and inner is non-NULL. + * Returns true if this `Features` object contains required features unknown by `other`. */ -void BlindedPath_free(struct LDKBlindedPath this_obj); +MUST_USE_RES bool Bolt11InvoiceFeatures_requires_unknown_bits_from(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg, const struct LDKBolt11InvoiceFeatures *NONNULL_PTR other); /** - * To send to a blinded path, the sender first finds a route to the unblinded - * `introduction_node`, which can unblind its [`encrypted_payload`] to find out the onion - * message or payment's next hop and forward it along. - * - * [`encrypted_payload`]: BlindedHop::encrypted_payload + * Returns the set of required features unknown by `other`, as their bit position. */ -struct LDKIntroductionNode BlindedPath_get_introduction_node(const struct LDKBlindedPath *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCVec_u64Z Bolt11InvoiceFeatures_required_unknown_bits_from(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg, const struct LDKBolt11InvoiceFeatures *NONNULL_PTR other); /** - * To send to a blinded path, the sender first finds a route to the unblinded - * `introduction_node`, which can unblind its [`encrypted_payload`] to find out the onion - * message or payment's next hop and forward it along. - * - * [`encrypted_payload`]: BlindedHop::encrypted_payload + * Returns true if this `Features` object contains unknown feature flags which are set as + * \"required\". */ -void BlindedPath_set_introduction_node(struct LDKBlindedPath *NONNULL_PTR this_ptr, struct LDKIntroductionNode val); +MUST_USE_RES bool Bolt11InvoiceFeatures_requires_unknown_bits(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Used by the introduction node to decrypt its [`encrypted_payload`] to forward the onion - * message or payment. - * - * [`encrypted_payload`]: BlindedHop::encrypted_payload + * Returns true if this `Features` supports any bits which we do not know of */ -struct LDKPublicKey BlindedPath_get_blinding_point(const struct LDKBlindedPath *NONNULL_PTR this_ptr); +MUST_USE_RES bool Bolt11InvoiceFeatures_supports_unknown_bits(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Used by the introduction node to decrypt its [`encrypted_payload`] to forward the onion - * message or payment. + * Sets a required feature bit. Errors if `bit` is outside the feature range as defined + * by [BOLT 9]. * - * [`encrypted_payload`]: BlindedHop::encrypted_payload - */ -void BlindedPath_set_blinding_point(struct LDKBlindedPath *NONNULL_PTR this_ptr, struct LDKPublicKey val); - -/** - * The hops composing the blinded path. + * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will + * be set instead (i.e., `bit - 1`). + * + * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md */ -struct LDKCVec_BlindedHopZ BlindedPath_get_blinded_hops(const struct LDKBlindedPath *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCResult_NoneNoneZ Bolt11InvoiceFeatures_set_required_feature_bit(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * The hops composing the blinded path. + * Sets an optional feature bit. Errors if `bit` is outside the feature range as defined + * by [BOLT 9]. + * + * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be + * set instead (i.e., `bit + 1`). + * + * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md */ -void BlindedPath_set_blinded_hops(struct LDKBlindedPath *NONNULL_PTR this_ptr, struct LDKCVec_BlindedHopZ val); +MUST_USE_RES struct LDKCResult_NoneNoneZ Bolt11InvoiceFeatures_set_optional_feature_bit(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Constructs a new BlindedPath given each field + * 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_RES struct LDKBlindedPath BlindedPath_new(struct LDKIntroductionNode introduction_node_arg, struct LDKPublicKey blinding_point_arg, struct LDKCVec_BlindedHopZ blinded_hops_arg); +MUST_USE_RES struct LDKCResult_NoneNoneZ Bolt11InvoiceFeatures_set_required_custom_bit(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Creates a copy of the BlindedPath + * 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 LDKBlindedPath BlindedPath_clone(const struct LDKBlindedPath *NONNULL_PTR orig); +MUST_USE_RES struct LDKCResult_NoneNoneZ Bolt11InvoiceFeatures_set_optional_custom_bit(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Generates a non-cryptographic 64-bit hash of the BlindedPath. + * Create a blank Features with no features set */ -uint64_t BlindedPath_hash(const struct LDKBlindedPath *NONNULL_PTR o); +MUST_USE_RES struct LDKOfferFeatures OfferFeatures_empty(void); /** - * Checks if two BlindedPaths 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 feature set as a list of bytes, in little-endian. This is in reverse byte order + * from most on-the-wire encodings. */ -bool BlindedPath_eq(const struct LDKBlindedPath *NONNULL_PTR a, const struct LDKBlindedPath *NONNULL_PTR b); +MUST_USE_RES struct LDKu8slice OfferFeatures_le_flags(const struct LDKOfferFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the IntroductionNode + * Returns true if this `Features` has any optional flags set */ -void IntroductionNode_free(struct LDKIntroductionNode this_ptr); +MUST_USE_RES bool OfferFeatures_supports_any_optional_bits(const struct LDKOfferFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the IntroductionNode + * Returns true if this `Features` object contains required features unknown by `other`. */ -struct LDKIntroductionNode IntroductionNode_clone(const struct LDKIntroductionNode *NONNULL_PTR orig); +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 NodeId-variant IntroductionNode + * Returns the set of required features unknown by `other`, as their bit position. */ -struct LDKIntroductionNode IntroductionNode_node_id(struct LDKPublicKey a); +MUST_USE_RES struct LDKCVec_u64Z OfferFeatures_required_unknown_bits_from(const struct LDKOfferFeatures *NONNULL_PTR this_arg, const struct LDKOfferFeatures *NONNULL_PTR other); /** - * Utility method to constructs a new DirectedShortChannelId-variant IntroductionNode + * Returns true if this `Features` object contains unknown feature flags which are set as + * \"required\". */ -struct LDKIntroductionNode IntroductionNode_directed_short_channel_id(enum LDKDirection a, uint64_t b); +MUST_USE_RES bool OfferFeatures_requires_unknown_bits(const struct LDKOfferFeatures *NONNULL_PTR this_arg); /** - * Generates a non-cryptographic 64-bit hash of the IntroductionNode. + * Returns true if this `Features` supports any bits which we do not know of */ -uint64_t IntroductionNode_hash(const struct LDKIntroductionNode *NONNULL_PTR o); +MUST_USE_RES bool OfferFeatures_supports_unknown_bits(const struct LDKOfferFeatures *NONNULL_PTR this_arg); /** - * Checks if two IntroductionNodes contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Sets a required feature bit. Errors if `bit` is outside the feature range as defined + * by [BOLT 9]. + * + * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will + * be set instead (i.e., `bit - 1`). + * + * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md */ -bool IntroductionNode_eq(const struct LDKIntroductionNode *NONNULL_PTR a, const struct LDKIntroductionNode *NONNULL_PTR b); +MUST_USE_RES struct LDKCResult_NoneNoneZ OfferFeatures_set_required_feature_bit(struct LDKOfferFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Creates a copy of the Direction + * Sets an optional feature bit. Errors if `bit` is outside the feature range as defined + * by [BOLT 9]. + * + * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be + * set instead (i.e., `bit + 1`). + * + * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md */ -enum LDKDirection Direction_clone(const enum LDKDirection *NONNULL_PTR orig); +MUST_USE_RES struct LDKCResult_NoneNoneZ OfferFeatures_set_optional_feature_bit(struct LDKOfferFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Utility method to constructs a new NodeOne-variant Direction + * 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 LDKDirection Direction_node_one(void); +MUST_USE_RES struct LDKCResult_NoneNoneZ OfferFeatures_set_required_custom_bit(struct LDKOfferFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Utility method to constructs a new NodeTwo-variant Direction + * 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 LDKDirection Direction_node_two(void); +MUST_USE_RES struct LDKCResult_NoneNoneZ OfferFeatures_set_optional_custom_bit(struct LDKOfferFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Generates a non-cryptographic 64-bit hash of the Direction. + * Create a blank Features with no features set */ -uint64_t Direction_hash(const enum LDKDirection *NONNULL_PTR o); +MUST_USE_RES struct LDKInvoiceRequestFeatures InvoiceRequestFeatures_empty(void); /** - * Checks if two Directions contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Returns the feature set as a list of bytes, in little-endian. This is in reverse byte order + * from most on-the-wire encodings. */ -bool Direction_eq(const enum LDKDirection *NONNULL_PTR a, const enum LDKDirection *NONNULL_PTR b); +MUST_USE_RES struct LDKu8slice InvoiceRequestFeatures_le_flags(const struct LDKInvoiceRequestFeatures *NONNULL_PTR this_arg); /** - * Calls the free function if one is set + * Returns true if this `Features` has any optional flags set */ -void NodeIdLookUp_free(struct LDKNodeIdLookUp this_ptr); +MUST_USE_RES bool InvoiceRequestFeatures_supports_any_optional_bits(const struct LDKInvoiceRequestFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the EmptyNodeIdLookUp, if is_owned is set and inner is non-NULL. + * Returns true if this `Features` object contains required features unknown by `other`. */ -void EmptyNodeIdLookUp_free(struct LDKEmptyNodeIdLookUp this_obj); +MUST_USE_RES bool InvoiceRequestFeatures_requires_unknown_bits_from(const struct LDKInvoiceRequestFeatures *NONNULL_PTR this_arg, const struct LDKInvoiceRequestFeatures *NONNULL_PTR other); /** - * Constructs a new EmptyNodeIdLookUp given each field + * Returns the set of required features unknown by `other`, as their bit position. */ -MUST_USE_RES struct LDKEmptyNodeIdLookUp EmptyNodeIdLookUp_new(void); +MUST_USE_RES struct LDKCVec_u64Z InvoiceRequestFeatures_required_unknown_bits_from(const struct LDKInvoiceRequestFeatures *NONNULL_PTR this_arg, const struct LDKInvoiceRequestFeatures *NONNULL_PTR other); /** - * Constructs a new NodeIdLookUp which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned NodeIdLookUp must be freed before this_arg is + * Returns true if this `Features` object contains unknown feature flags which are set as + * \"required\". */ -struct LDKNodeIdLookUp EmptyNodeIdLookUp_as_NodeIdLookUp(const struct LDKEmptyNodeIdLookUp *NONNULL_PTR this_arg); +MUST_USE_RES bool InvoiceRequestFeatures_requires_unknown_bits(const struct LDKInvoiceRequestFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the BlindedHop, if is_owned is set and inner is non-NULL. + * Returns true if this `Features` supports any bits which we do not know of */ -void BlindedHop_free(struct LDKBlindedHop this_obj); +MUST_USE_RES bool InvoiceRequestFeatures_supports_unknown_bits(const struct LDKInvoiceRequestFeatures *NONNULL_PTR this_arg); /** - * The blinded node id of this hop in a [`BlindedPath`]. + * Sets a required feature bit. Errors if `bit` is outside the feature range as defined + * by [BOLT 9]. + * + * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will + * be set instead (i.e., `bit - 1`). + * + * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md */ -struct LDKPublicKey BlindedHop_get_blinded_node_id(const struct LDKBlindedHop *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCResult_NoneNoneZ InvoiceRequestFeatures_set_required_feature_bit(struct LDKInvoiceRequestFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * The blinded node id of this hop in a [`BlindedPath`]. + * Sets an optional feature bit. Errors if `bit` is outside the feature range as defined + * by [BOLT 9]. + * + * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be + * set instead (i.e., `bit + 1`). + * + * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md */ -void BlindedHop_set_blinded_node_id(struct LDKBlindedHop *NONNULL_PTR this_ptr, struct LDKPublicKey val); +MUST_USE_RES struct LDKCResult_NoneNoneZ InvoiceRequestFeatures_set_optional_feature_bit(struct LDKInvoiceRequestFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * The encrypted payload intended for this hop in a [`BlindedPath`]. + * 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. * - * Returns a copy of the field. + * 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 BlindedHop_get_encrypted_payload(const struct LDKBlindedHop *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCResult_NoneNoneZ InvoiceRequestFeatures_set_required_custom_bit(struct LDKInvoiceRequestFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * The encrypted payload intended for this hop in a [`BlindedPath`]. + * 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 BlindedHop_set_encrypted_payload(struct LDKBlindedHop *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); +MUST_USE_RES struct LDKCResult_NoneNoneZ InvoiceRequestFeatures_set_optional_custom_bit(struct LDKInvoiceRequestFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Constructs a new BlindedHop given each field + * Create a blank Features with no features set */ -MUST_USE_RES struct LDKBlindedHop BlindedHop_new(struct LDKPublicKey blinded_node_id_arg, struct LDKCVec_u8Z encrypted_payload_arg); +MUST_USE_RES struct LDKBolt12InvoiceFeatures Bolt12InvoiceFeatures_empty(void); /** - * Creates a copy of the BlindedHop + * Returns the feature set as a list of bytes, in little-endian. This is in reverse byte order + * from most on-the-wire encodings. */ -struct LDKBlindedHop BlindedHop_clone(const struct LDKBlindedHop *NONNULL_PTR orig); +MUST_USE_RES struct LDKu8slice Bolt12InvoiceFeatures_le_flags(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg); /** - * Generates a non-cryptographic 64-bit hash of the BlindedHop. + * Returns true if this `Features` has any optional flags set */ -uint64_t BlindedHop_hash(const struct LDKBlindedHop *NONNULL_PTR o); +MUST_USE_RES bool Bolt12InvoiceFeatures_supports_any_optional_bits(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg); /** - * Checks if two BlindedHops 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 true if this `Features` object contains required features unknown by `other`. */ -bool BlindedHop_eq(const struct LDKBlindedHop *NONNULL_PTR a, const struct LDKBlindedHop *NONNULL_PTR b); +MUST_USE_RES bool Bolt12InvoiceFeatures_requires_unknown_bits_from(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg, const struct LDKBolt12InvoiceFeatures *NONNULL_PTR other); /** - * Create a one-hop blinded path for a message. + * Returns the set of required features unknown by `other`, as their bit position. */ -MUST_USE_RES struct LDKCResult_BlindedPathNoneZ BlindedPath_one_hop_for_message(struct LDKPublicKey recipient_node_id, struct LDKEntropySource entropy_source); +MUST_USE_RES struct LDKCVec_u64Z Bolt12InvoiceFeatures_required_unknown_bits_from(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg, const struct LDKBolt12InvoiceFeatures *NONNULL_PTR other); /** - * Create a blinded path for an onion message, to be forwarded along `node_pks`. The last node - * pubkey in `node_pks` will be the destination node. - * - * Errors if no hops are provided or if `node_pk`(s) are invalid. + * Returns true if this `Features` object contains unknown feature flags which are set as + * \"required\". */ -MUST_USE_RES struct LDKCResult_BlindedPathNoneZ BlindedPath_new_for_message(struct LDKCVec_PublicKeyZ node_pks, struct LDKEntropySource entropy_source); +MUST_USE_RES bool Bolt12InvoiceFeatures_requires_unknown_bits(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg); /** - * Create a one-hop blinded path for a payment. + * Returns true if this `Features` supports any bits which we do not know of */ -MUST_USE_RES struct LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ BlindedPath_one_hop_for_payment(struct LDKPublicKey payee_node_id, struct LDKReceiveTlvs payee_tlvs, uint16_t min_final_cltv_expiry_delta, struct LDKEntropySource entropy_source); +MUST_USE_RES bool Bolt12InvoiceFeatures_supports_unknown_bits(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg); /** - * Create a blinded path for a payment, to be forwarded along `intermediate_nodes`. + * Sets a required feature bit. Errors if `bit` is outside the feature range as defined + * by [BOLT 9]. * - * Errors if: - * * a provided node id is invalid - * * [`BlindedPayInfo`] calculation results in an integer overflow - * * any unknown features are required in the provided [`ForwardTlvs`] + * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will + * be set instead (i.e., `bit - 1`). * - * [`ForwardTlvs`]: crate::blinded_path::payment::ForwardTlvs + * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md */ -MUST_USE_RES struct LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ BlindedPath_new_for_payment(struct LDKCVec_ForwardNodeZ intermediate_nodes, struct LDKPublicKey payee_node_id, struct LDKReceiveTlvs payee_tlvs, uint64_t htlc_maximum_msat, uint16_t min_final_cltv_expiry_delta, struct LDKEntropySource entropy_source); +MUST_USE_RES struct LDKCResult_NoneNoneZ Bolt12InvoiceFeatures_set_required_feature_bit(struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Returns the introduction [`NodeId`] of the blinded path, if it is publicly reachable (i.e., - * it is found in the network graph). + * Sets an optional feature bit. Errors if `bit` is outside the feature range as defined + * by [BOLT 9]. * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be + * set instead (i.e., `bit + 1`). + * + * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md */ -MUST_USE_RES struct LDKNodeId BlindedPath_public_introduction_node_id(const struct LDKBlindedPath *NONNULL_PTR this_arg, const struct LDKReadOnlyNetworkGraph *NONNULL_PTR network_graph); +MUST_USE_RES struct LDKCResult_NoneNoneZ Bolt12InvoiceFeatures_set_optional_feature_bit(struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Serialize the BlindedPath object into a byte array which can be read by BlindedPath_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 BlindedPath_write(const struct LDKBlindedPath *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 BlindedPath from a byte array, created by BlindedPath_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_BlindedPathDecodeErrorZ BlindedPath_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKCResult_NoneNoneZ Bolt12InvoiceFeatures_set_optional_custom_bit(struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Serialize the BlindedHop object into a byte array which can be read by BlindedHop_read + * Create a blank Features with no features set */ -struct LDKCVec_u8Z BlindedHop_write(const struct LDKBlindedHop *NONNULL_PTR obj); +MUST_USE_RES struct LDKBlindedHopFeatures BlindedHopFeatures_empty(void); /** - * Read a BlindedHop from a byte array, created by BlindedHop_write + * Returns the feature set as a list of bytes, in little-endian. This is in reverse byte order + * from most on-the-wire encodings. */ -struct LDKCResult_BlindedHopDecodeErrorZ BlindedHop_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKu8slice BlindedHopFeatures_le_flags(const struct LDKBlindedHopFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the ForwardNode, if is_owned is set and inner is non-NULL. + * Returns true if this `Features` has any optional flags set */ -void ForwardNode_free(struct LDKForwardNode this_obj); +MUST_USE_RES bool BlindedHopFeatures_supports_any_optional_bits(const struct LDKBlindedHopFeatures *NONNULL_PTR this_arg); /** - * The TLVs for this node's [`BlindedHop`], where the fee parameters contained within are also - * used for [`BlindedPayInfo`] construction. + * Returns true if this `Features` object contains required features unknown by `other`. */ -struct LDKForwardTlvs ForwardNode_get_tlvs(const struct LDKForwardNode *NONNULL_PTR this_ptr); +MUST_USE_RES bool BlindedHopFeatures_requires_unknown_bits_from(const struct LDKBlindedHopFeatures *NONNULL_PTR this_arg, const struct LDKBlindedHopFeatures *NONNULL_PTR other); /** - * The TLVs for this node's [`BlindedHop`], where the fee parameters contained within are also - * used for [`BlindedPayInfo`] construction. + * Returns the set of required features unknown by `other`, as their bit position. */ -void ForwardNode_set_tlvs(struct LDKForwardNode *NONNULL_PTR this_ptr, struct LDKForwardTlvs val); +MUST_USE_RES struct LDKCVec_u64Z BlindedHopFeatures_required_unknown_bits_from(const struct LDKBlindedHopFeatures *NONNULL_PTR this_arg, const struct LDKBlindedHopFeatures *NONNULL_PTR other); /** - * This node's pubkey. + * Returns true if this `Features` object contains unknown feature flags which are set as + * \"required\". */ -struct LDKPublicKey ForwardNode_get_node_id(const struct LDKForwardNode *NONNULL_PTR this_ptr); +MUST_USE_RES bool BlindedHopFeatures_requires_unknown_bits(const struct LDKBlindedHopFeatures *NONNULL_PTR this_arg); /** - * This node's pubkey. + * Returns true if this `Features` supports any bits which we do not know of */ -void ForwardNode_set_node_id(struct LDKForwardNode *NONNULL_PTR this_ptr, struct LDKPublicKey val); +MUST_USE_RES bool BlindedHopFeatures_supports_unknown_bits(const struct LDKBlindedHopFeatures *NONNULL_PTR this_arg); /** - * The maximum value, in msat, that may be accepted by this node. + * Sets a required feature bit. Errors if `bit` is outside the feature range as defined + * by [BOLT 9]. + * + * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will + * be set instead (i.e., `bit - 1`). + * + * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md */ -uint64_t ForwardNode_get_htlc_maximum_msat(const struct LDKForwardNode *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCResult_NoneNoneZ BlindedHopFeatures_set_required_feature_bit(struct LDKBlindedHopFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * The maximum value, in msat, that may be accepted by this node. + * Sets an optional feature bit. Errors if `bit` is outside the feature range as defined + * by [BOLT 9]. + * + * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be + * set instead (i.e., `bit + 1`). + * + * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md */ -void ForwardNode_set_htlc_maximum_msat(struct LDKForwardNode *NONNULL_PTR this_ptr, uint64_t val); +MUST_USE_RES struct LDKCResult_NoneNoneZ BlindedHopFeatures_set_optional_feature_bit(struct LDKBlindedHopFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Constructs a new ForwardNode given each field + * 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_RES struct LDKForwardNode ForwardNode_new(struct LDKForwardTlvs tlvs_arg, struct LDKPublicKey node_id_arg, uint64_t htlc_maximum_msat_arg); +MUST_USE_RES struct LDKCResult_NoneNoneZ BlindedHopFeatures_set_required_custom_bit(struct LDKBlindedHopFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Creates a copy of the ForwardNode + * 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 LDKForwardNode ForwardNode_clone(const struct LDKForwardNode *NONNULL_PTR orig); +MUST_USE_RES struct LDKCResult_NoneNoneZ BlindedHopFeatures_set_optional_custom_bit(struct LDKBlindedHopFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Frees any resources used by the ForwardTlvs, if is_owned is set and inner is non-NULL. + * Create a blank Features with no features set */ -void ForwardTlvs_free(struct LDKForwardTlvs this_obj); +MUST_USE_RES struct LDKChannelTypeFeatures ChannelTypeFeatures_empty(void); /** - * The short channel id this payment should be forwarded out over. + * Returns the feature set as a list of bytes, in little-endian. This is in reverse byte order + * from most on-the-wire encodings. */ -uint64_t ForwardTlvs_get_short_channel_id(const struct LDKForwardTlvs *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKu8slice ChannelTypeFeatures_le_flags(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * The short channel id this payment should be forwarded out over. + * Returns true if this `Features` has any optional flags set */ -void ForwardTlvs_set_short_channel_id(struct LDKForwardTlvs *NONNULL_PTR this_ptr, uint64_t val); +MUST_USE_RES bool ChannelTypeFeatures_supports_any_optional_bits(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Payment parameters for relaying over [`Self::short_channel_id`]. + * Returns true if this `Features` object contains required features unknown by `other`. */ -struct LDKPaymentRelay ForwardTlvs_get_payment_relay(const struct LDKForwardTlvs *NONNULL_PTR this_ptr); +MUST_USE_RES bool ChannelTypeFeatures_requires_unknown_bits_from(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg, const struct LDKChannelTypeFeatures *NONNULL_PTR other); /** - * Payment parameters for relaying over [`Self::short_channel_id`]. + * Returns the set of required features unknown by `other`, as their bit position. */ -void ForwardTlvs_set_payment_relay(struct LDKForwardTlvs *NONNULL_PTR this_ptr, struct LDKPaymentRelay val); +MUST_USE_RES struct LDKCVec_u64Z ChannelTypeFeatures_required_unknown_bits_from(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg, const struct LDKChannelTypeFeatures *NONNULL_PTR other); /** - * Payment constraints for relaying over [`Self::short_channel_id`]. + * Returns true if this `Features` object contains unknown feature flags which are set as + * \"required\". */ -struct LDKPaymentConstraints ForwardTlvs_get_payment_constraints(const struct LDKForwardTlvs *NONNULL_PTR this_ptr); +MUST_USE_RES bool ChannelTypeFeatures_requires_unknown_bits(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Payment constraints for relaying over [`Self::short_channel_id`]. + * Returns true if this `Features` supports any bits which we do not know of */ -void ForwardTlvs_set_payment_constraints(struct LDKForwardTlvs *NONNULL_PTR this_ptr, struct LDKPaymentConstraints val); +MUST_USE_RES bool ChannelTypeFeatures_supports_unknown_bits(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Supported and required features when relaying a payment onion containing this object's - * corresponding [`BlindedHop::encrypted_payload`]. + * Sets a required feature bit. Errors if `bit` is outside the feature range as defined + * by [BOLT 9]. * - * [`BlindedHop::encrypted_payload`]: crate::blinded_path::BlindedHop::encrypted_payload - */ -struct LDKBlindedHopFeatures ForwardTlvs_get_features(const struct LDKForwardTlvs *NONNULL_PTR this_ptr); - -/** - * Supported and required features when relaying a payment onion containing this object's - * corresponding [`BlindedHop::encrypted_payload`]. + * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will + * be set instead (i.e., `bit - 1`). * - * [`BlindedHop::encrypted_payload`]: crate::blinded_path::BlindedHop::encrypted_payload - */ -void ForwardTlvs_set_features(struct LDKForwardTlvs *NONNULL_PTR this_ptr, struct LDKBlindedHopFeatures val); - -/** - * Constructs a new ForwardTlvs given each field + * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md */ -MUST_USE_RES struct LDKForwardTlvs ForwardTlvs_new(uint64_t short_channel_id_arg, struct LDKPaymentRelay payment_relay_arg, struct LDKPaymentConstraints payment_constraints_arg, struct LDKBlindedHopFeatures features_arg); +MUST_USE_RES struct LDKCResult_NoneNoneZ ChannelTypeFeatures_set_required_feature_bit(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Creates a copy of the ForwardTlvs + * Sets an optional feature bit. Errors if `bit` is outside the feature range as defined + * by [BOLT 9]. + * + * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be + * set instead (i.e., `bit + 1`). + * + * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md */ -struct LDKForwardTlvs ForwardTlvs_clone(const struct LDKForwardTlvs *NONNULL_PTR orig); +MUST_USE_RES struct LDKCResult_NoneNoneZ ChannelTypeFeatures_set_optional_feature_bit(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Frees any resources used by the ReceiveTlvs, if is_owned is set and inner is non-NULL. + * 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 ReceiveTlvs_free(struct LDKReceiveTlvs this_obj); +MUST_USE_RES struct LDKCResult_NoneNoneZ ChannelTypeFeatures_set_required_custom_bit(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Used to authenticate the sender of a payment to the receiver and tie MPP HTLCs together. + * 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 */ -const uint8_t (*ReceiveTlvs_get_payment_secret(const struct LDKReceiveTlvs *NONNULL_PTR this_ptr))[32]; +MUST_USE_RES struct LDKCResult_NoneNoneZ ChannelTypeFeatures_set_optional_custom_bit(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Used to authenticate the sender of a payment to the receiver and tie MPP HTLCs together. + * Unsets the `upfront_shutdown_script` feature */ -void ReceiveTlvs_set_payment_secret(struct LDKReceiveTlvs *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +MUST_USE_RES struct LDKInitFeatures InitFeatures_clear_upfront_shutdown_script(struct LDKInitFeatures this_arg); /** - * Constraints for the receiver of this payment. + * Unsets the `upfront_shutdown_script` feature */ -struct LDKPaymentConstraints ReceiveTlvs_get_payment_constraints(const struct LDKReceiveTlvs *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKNodeFeatures NodeFeatures_clear_upfront_shutdown_script(struct LDKNodeFeatures this_arg); /** - * Constraints for the receiver of this payment. + * Unsets the `shutdown_anysegwit` feature */ -void ReceiveTlvs_set_payment_constraints(struct LDKReceiveTlvs *NONNULL_PTR this_ptr, struct LDKPaymentConstraints val); +MUST_USE_RES struct LDKInitFeatures InitFeatures_clear_shutdown_anysegwit(struct LDKInitFeatures this_arg); /** - * Context for the receiver of this payment. + * Unsets the `shutdown_anysegwit` feature */ -struct LDKPaymentContext ReceiveTlvs_get_payment_context(const struct LDKReceiveTlvs *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKNodeFeatures NodeFeatures_clear_shutdown_anysegwit(struct LDKNodeFeatures this_arg); /** - * Context for the receiver of this payment. + * Unsets the `wumbo` feature */ -void ReceiveTlvs_set_payment_context(struct LDKReceiveTlvs *NONNULL_PTR this_ptr, struct LDKPaymentContext val); +MUST_USE_RES struct LDKInitFeatures InitFeatures_clear_wumbo(struct LDKInitFeatures this_arg); /** - * Constructs a new ReceiveTlvs given each field + * Unsets the `wumbo` feature */ -MUST_USE_RES struct LDKReceiveTlvs ReceiveTlvs_new(struct LDKThirtyTwoBytes payment_secret_arg, struct LDKPaymentConstraints payment_constraints_arg, struct LDKPaymentContext payment_context_arg); +MUST_USE_RES struct LDKNodeFeatures NodeFeatures_clear_wumbo(struct LDKNodeFeatures this_arg); /** - * Creates a copy of the ReceiveTlvs + * Unsets the `scid_privacy` feature */ -struct LDKReceiveTlvs ReceiveTlvs_clone(const struct LDKReceiveTlvs *NONNULL_PTR orig); +void InitFeatures_clear_scid_privacy(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the PaymentRelay, if is_owned is set and inner is non-NULL. + * Unsets the `scid_privacy` feature */ -void PaymentRelay_free(struct LDKPaymentRelay this_obj); +void NodeFeatures_clear_scid_privacy(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Number of blocks subtracted from an incoming HTLC's `cltv_expiry` for this [`BlindedHop`]. + * Unsets the `scid_privacy` feature */ -uint16_t PaymentRelay_get_cltv_expiry_delta(const struct LDKPaymentRelay *NONNULL_PTR this_ptr); +void ChannelTypeFeatures_clear_scid_privacy(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Number of blocks subtracted from an incoming HTLC's `cltv_expiry` for this [`BlindedHop`]. + * Unsets the `anchors_zero_fee_htlc_tx` feature */ -void PaymentRelay_set_cltv_expiry_delta(struct LDKPaymentRelay *NONNULL_PTR this_ptr, uint16_t val); +void InitFeatures_clear_anchors_zero_fee_htlc_tx(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Liquidity fee charged (in millionths of the amount transferred) for relaying a payment over - * this [`BlindedHop`], (i.e., 10,000 is 1%). + * Unsets the `anchors_zero_fee_htlc_tx` feature */ -uint32_t PaymentRelay_get_fee_proportional_millionths(const struct LDKPaymentRelay *NONNULL_PTR this_ptr); +void NodeFeatures_clear_anchors_zero_fee_htlc_tx(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Liquidity fee charged (in millionths of the amount transferred) for relaying a payment over - * this [`BlindedHop`], (i.e., 10,000 is 1%). + * Unsets the `anchors_zero_fee_htlc_tx` feature */ -void PaymentRelay_set_fee_proportional_millionths(struct LDKPaymentRelay *NONNULL_PTR this_ptr, uint32_t val); +void ChannelTypeFeatures_clear_anchors_zero_fee_htlc_tx(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Base fee charged (in millisatoshi) for relaying a payment over this [`BlindedHop`]. + * Unsets the `route_blinding` feature */ -uint32_t PaymentRelay_get_fee_base_msat(const struct LDKPaymentRelay *NONNULL_PTR this_ptr); +void InitFeatures_clear_route_blinding(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Base fee charged (in millisatoshi) for relaying a payment over this [`BlindedHop`]. + * Unsets the `route_blinding` feature */ -void PaymentRelay_set_fee_base_msat(struct LDKPaymentRelay *NONNULL_PTR this_ptr, uint32_t val); +void NodeFeatures_clear_route_blinding(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Constructs a new PaymentRelay given each field + * Set this feature as optional. */ -MUST_USE_RES struct LDKPaymentRelay PaymentRelay_new(uint16_t cltv_expiry_delta_arg, uint32_t fee_proportional_millionths_arg, uint32_t fee_base_msat_arg); +void InitFeatures_set_data_loss_protect_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the PaymentRelay + * Set this feature as required. */ -struct LDKPaymentRelay PaymentRelay_clone(const struct LDKPaymentRelay *NONNULL_PTR orig); +void InitFeatures_set_data_loss_protect_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the PaymentConstraints, if is_owned is set and inner is non-NULL. + * Checks if this feature is supported. */ -void PaymentConstraints_free(struct LDKPaymentConstraints this_obj); +MUST_USE_RES bool InitFeatures_supports_data_loss_protect(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * The maximum total CLTV that is acceptable when relaying a payment over this [`BlindedHop`]. + * Set this feature as optional. */ -uint32_t PaymentConstraints_get_max_cltv_expiry(const struct LDKPaymentConstraints *NONNULL_PTR this_ptr); +void NodeFeatures_set_data_loss_protect_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * The maximum total CLTV that is acceptable when relaying a payment over this [`BlindedHop`]. + * Set this feature as required. */ -void PaymentConstraints_set_max_cltv_expiry(struct LDKPaymentConstraints *NONNULL_PTR this_ptr, uint32_t val); +void NodeFeatures_set_data_loss_protect_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * The minimum value, in msat, that may be accepted by the node corresponding to this - * [`BlindedHop`]. + * Checks if this feature is supported. */ -uint64_t PaymentConstraints_get_htlc_minimum_msat(const struct LDKPaymentConstraints *NONNULL_PTR this_ptr); +MUST_USE_RES bool NodeFeatures_supports_data_loss_protect(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * The minimum value, in msat, that may be accepted by the node corresponding to this - * [`BlindedHop`]. + * Checks if this feature is required. */ -void PaymentConstraints_set_htlc_minimum_msat(struct LDKPaymentConstraints *NONNULL_PTR this_ptr, uint64_t val); +MUST_USE_RES bool InitFeatures_requires_data_loss_protect(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Constructs a new PaymentConstraints given each field + * Checks if this feature is required. */ -MUST_USE_RES struct LDKPaymentConstraints PaymentConstraints_new(uint32_t max_cltv_expiry_arg, uint64_t htlc_minimum_msat_arg); +MUST_USE_RES bool NodeFeatures_requires_data_loss_protect(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the PaymentConstraints + * Set this feature as optional. */ -struct LDKPaymentConstraints PaymentConstraints_clone(const struct LDKPaymentConstraints *NONNULL_PTR orig); +void InitFeatures_set_initial_routing_sync_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the PaymentContext + * Set this feature as required. */ -void PaymentContext_free(struct LDKPaymentContext this_ptr); +void InitFeatures_set_initial_routing_sync_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the PaymentContext + * Checks if this feature is supported. */ -struct LDKPaymentContext PaymentContext_clone(const struct LDKPaymentContext *NONNULL_PTR orig); +MUST_USE_RES bool InitFeatures_initial_routing_sync(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new Unknown-variant PaymentContext + * Set this feature as optional. */ -struct LDKPaymentContext PaymentContext_unknown(struct LDKUnknownPaymentContext a); +void InitFeatures_set_upfront_shutdown_script_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new Bolt12Offer-variant PaymentContext + * Set this feature as required. */ -struct LDKPaymentContext PaymentContext_bolt12_offer(struct LDKBolt12OfferContext a); +void InitFeatures_set_upfront_shutdown_script_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new Bolt12Refund-variant PaymentContext + * Checks if this feature is supported. */ -struct LDKPaymentContext PaymentContext_bolt12_refund(struct LDKBolt12RefundContext a); +MUST_USE_RES bool InitFeatures_supports_upfront_shutdown_script(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Checks if two PaymentContexts contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Set this feature as optional. */ -bool PaymentContext_eq(const struct LDKPaymentContext *NONNULL_PTR a, const struct LDKPaymentContext *NONNULL_PTR b); +void NodeFeatures_set_upfront_shutdown_script_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the UnknownPaymentContext, if is_owned is set and inner is non-NULL. + * Set this feature as required. */ -void UnknownPaymentContext_free(struct LDKUnknownPaymentContext this_obj); +void NodeFeatures_set_upfront_shutdown_script_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the UnknownPaymentContext + * Checks if this feature is supported. */ -struct LDKUnknownPaymentContext UnknownPaymentContext_clone(const struct LDKUnknownPaymentContext *NONNULL_PTR orig); +MUST_USE_RES bool NodeFeatures_supports_upfront_shutdown_script(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Checks if two UnknownPaymentContexts 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 UnknownPaymentContext_eq(const struct LDKUnknownPaymentContext *NONNULL_PTR a, const struct LDKUnknownPaymentContext *NONNULL_PTR b); +MUST_USE_RES bool InitFeatures_requires_upfront_shutdown_script(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the Bolt12OfferContext, if is_owned is set and inner is non-NULL. + * Checks if this feature is required. */ -void Bolt12OfferContext_free(struct LDKBolt12OfferContext this_obj); +MUST_USE_RES bool NodeFeatures_requires_upfront_shutdown_script(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * The identifier of the [`Offer`]. - * - * [`Offer`]: crate::offers::offer::Offer + * Set this feature as optional. */ -struct LDKOfferId Bolt12OfferContext_get_offer_id(const struct LDKBolt12OfferContext *NONNULL_PTR this_ptr); +void InitFeatures_set_gossip_queries_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * The identifier of the [`Offer`]. - * - * [`Offer`]: crate::offers::offer::Offer + * Set this feature as required. */ -void Bolt12OfferContext_set_offer_id(struct LDKBolt12OfferContext *NONNULL_PTR this_ptr, struct LDKOfferId val); +void InitFeatures_set_gossip_queries_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Fields from an [`InvoiceRequest`] sent for a [`Bolt12Invoice`]. - * - * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest - * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice + * Checks if this feature is supported. */ -struct LDKInvoiceRequestFields Bolt12OfferContext_get_invoice_request(const struct LDKBolt12OfferContext *NONNULL_PTR this_ptr); +MUST_USE_RES bool InitFeatures_supports_gossip_queries(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Fields from an [`InvoiceRequest`] sent for a [`Bolt12Invoice`]. - * - * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest - * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice + * Set this feature as optional. */ -void Bolt12OfferContext_set_invoice_request(struct LDKBolt12OfferContext *NONNULL_PTR this_ptr, struct LDKInvoiceRequestFields val); +void NodeFeatures_set_gossip_queries_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Constructs a new Bolt12OfferContext given each field + * Set this feature as required. */ -MUST_USE_RES struct LDKBolt12OfferContext Bolt12OfferContext_new(struct LDKOfferId offer_id_arg, struct LDKInvoiceRequestFields invoice_request_arg); +void NodeFeatures_set_gossip_queries_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the Bolt12OfferContext + * Checks if this feature is supported. */ -struct LDKBolt12OfferContext Bolt12OfferContext_clone(const struct LDKBolt12OfferContext *NONNULL_PTR orig); +MUST_USE_RES bool NodeFeatures_supports_gossip_queries(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Checks if two Bolt12OfferContexts 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 Bolt12OfferContext_eq(const struct LDKBolt12OfferContext *NONNULL_PTR a, const struct LDKBolt12OfferContext *NONNULL_PTR b); +MUST_USE_RES bool InitFeatures_requires_gossip_queries(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the Bolt12RefundContext, if is_owned is set and inner is non-NULL. + * Checks if this feature is required. */ -void Bolt12RefundContext_free(struct LDKBolt12RefundContext this_obj); +MUST_USE_RES bool NodeFeatures_requires_gossip_queries(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Constructs a new Bolt12RefundContext given each field + * Set this feature as optional. */ -MUST_USE_RES struct LDKBolt12RefundContext Bolt12RefundContext_new(void); +void InitFeatures_set_variable_length_onion_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the Bolt12RefundContext + * Set this feature as required. */ -struct LDKBolt12RefundContext Bolt12RefundContext_clone(const struct LDKBolt12RefundContext *NONNULL_PTR orig); +void InitFeatures_set_variable_length_onion_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Checks if two Bolt12RefundContexts 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 Bolt12RefundContext_eq(const struct LDKBolt12RefundContext *NONNULL_PTR a, const struct LDKBolt12RefundContext *NONNULL_PTR b); +MUST_USE_RES bool InitFeatures_supports_variable_length_onion(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Serialize the ForwardTlvs object into a byte array which can be read by ForwardTlvs_read + * Set this feature as optional. */ -struct LDKCVec_u8Z ForwardTlvs_write(const struct LDKForwardTlvs *NONNULL_PTR obj); +void NodeFeatures_set_variable_length_onion_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Serialize the ReceiveTlvs object into a byte array which can be read by ReceiveTlvs_read + * Set this feature as required. */ -struct LDKCVec_u8Z ReceiveTlvs_write(const struct LDKReceiveTlvs *NONNULL_PTR obj); +void NodeFeatures_set_variable_length_onion_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Serialize the PaymentRelay object into a byte array which can be read by PaymentRelay_read + * Checks if this feature is supported. */ -struct LDKCVec_u8Z PaymentRelay_write(const struct LDKPaymentRelay *NONNULL_PTR obj); +MUST_USE_RES bool NodeFeatures_supports_variable_length_onion(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Read a PaymentRelay from a byte array, created by PaymentRelay_write + * Set this feature as optional. */ -struct LDKCResult_PaymentRelayDecodeErrorZ PaymentRelay_read(struct LDKu8slice ser); +void Bolt11InvoiceFeatures_set_variable_length_onion_optional(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Serialize the PaymentConstraints object into a byte array which can be read by PaymentConstraints_read + * Set this feature as required. */ -struct LDKCVec_u8Z PaymentConstraints_write(const struct LDKPaymentConstraints *NONNULL_PTR obj); +void Bolt11InvoiceFeatures_set_variable_length_onion_required(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Read a PaymentConstraints from a byte array, created by PaymentConstraints_write + * Checks if this feature is supported. */ -struct LDKCResult_PaymentConstraintsDecodeErrorZ PaymentConstraints_read(struct LDKu8slice ser); +MUST_USE_RES bool Bolt11InvoiceFeatures_supports_variable_length_onion(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Serialize the PaymentContext object into a byte array which can be read by PaymentContext_read + * Checks if this feature is required. */ -struct LDKCVec_u8Z PaymentContext_write(const struct LDKPaymentContext *NONNULL_PTR obj); +MUST_USE_RES bool InitFeatures_requires_variable_length_onion(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Read a PaymentContext from a byte array, created by PaymentContext_write + * Checks if this feature is required. */ -struct LDKCResult_PaymentContextDecodeErrorZ PaymentContext_read(struct LDKu8slice ser); +MUST_USE_RES bool NodeFeatures_requires_variable_length_onion(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Serialize the UnknownPaymentContext object into a byte array which can be read by UnknownPaymentContext_read + * Checks if this feature is required. */ -struct LDKCVec_u8Z UnknownPaymentContext_write(const struct LDKUnknownPaymentContext *NONNULL_PTR obj); +MUST_USE_RES bool Bolt11InvoiceFeatures_requires_variable_length_onion(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Read a UnknownPaymentContext from a byte array, created by UnknownPaymentContext_write + * Set this feature as optional. */ -struct LDKCResult_UnknownPaymentContextDecodeErrorZ UnknownPaymentContext_read(struct LDKu8slice ser); +void InitFeatures_set_static_remote_key_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Serialize the Bolt12OfferContext object into a byte array which can be read by Bolt12OfferContext_read + * Set this feature as required. */ -struct LDKCVec_u8Z Bolt12OfferContext_write(const struct LDKBolt12OfferContext *NONNULL_PTR obj); +void InitFeatures_set_static_remote_key_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Read a Bolt12OfferContext from a byte array, created by Bolt12OfferContext_write + * Checks if this feature is supported. */ -struct LDKCResult_Bolt12OfferContextDecodeErrorZ Bolt12OfferContext_read(struct LDKu8slice ser); +MUST_USE_RES bool InitFeatures_supports_static_remote_key(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Serialize the Bolt12RefundContext object into a byte array which can be read by Bolt12RefundContext_read + * Set this feature as optional. */ -struct LDKCVec_u8Z Bolt12RefundContext_write(const struct LDKBolt12RefundContext *NONNULL_PTR obj); +void NodeFeatures_set_static_remote_key_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Read a Bolt12RefundContext from a byte array, created by Bolt12RefundContext_write + * Set this feature as required. */ -struct LDKCResult_Bolt12RefundContextDecodeErrorZ Bolt12RefundContext_read(struct LDKu8slice ser); +void NodeFeatures_set_static_remote_key_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the PaymentPurpose + * Checks if this feature is supported. */ -void PaymentPurpose_free(struct LDKPaymentPurpose this_ptr); +MUST_USE_RES bool NodeFeatures_supports_static_remote_key(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the PaymentPurpose + * Set this feature as optional. */ -struct LDKPaymentPurpose PaymentPurpose_clone(const struct LDKPaymentPurpose *NONNULL_PTR orig); +void ChannelTypeFeatures_set_static_remote_key_optional(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new Bolt11InvoicePayment-variant PaymentPurpose + * Set this feature as required. */ -struct LDKPaymentPurpose PaymentPurpose_bolt11_invoice_payment(struct LDKCOption_ThirtyTwoBytesZ payment_preimage, struct LDKThirtyTwoBytes payment_secret); +void ChannelTypeFeatures_set_static_remote_key_required(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new Bolt12OfferPayment-variant PaymentPurpose + * Checks if this feature is supported. */ -struct LDKPaymentPurpose PaymentPurpose_bolt12_offer_payment(struct LDKCOption_ThirtyTwoBytesZ payment_preimage, struct LDKThirtyTwoBytes payment_secret, struct LDKBolt12OfferContext payment_context); +MUST_USE_RES bool ChannelTypeFeatures_supports_static_remote_key(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new Bolt12RefundPayment-variant PaymentPurpose + * Checks if this feature is required. */ -struct LDKPaymentPurpose PaymentPurpose_bolt12_refund_payment(struct LDKCOption_ThirtyTwoBytesZ payment_preimage, struct LDKThirtyTwoBytes payment_secret, struct LDKBolt12RefundContext payment_context); +MUST_USE_RES bool InitFeatures_requires_static_remote_key(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SpontaneousPayment-variant PaymentPurpose + * Checks if this feature is required. */ -struct LDKPaymentPurpose PaymentPurpose_spontaneous_payment(struct LDKThirtyTwoBytes a); +MUST_USE_RES bool NodeFeatures_requires_static_remote_key(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Checks if two PaymentPurposes contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Checks if this feature is required. */ -bool PaymentPurpose_eq(const struct LDKPaymentPurpose *NONNULL_PTR a, const struct LDKPaymentPurpose *NONNULL_PTR b); +MUST_USE_RES bool ChannelTypeFeatures_requires_static_remote_key(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Returns the preimage for this payment, if it is known. + * Set this feature as optional. */ -MUST_USE_RES struct LDKCOption_ThirtyTwoBytesZ PaymentPurpose_preimage(const struct LDKPaymentPurpose *NONNULL_PTR this_arg); +void InitFeatures_set_payment_secret_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Serialize the PaymentPurpose object into a byte array which can be read by PaymentPurpose_read + * Set this feature as required. */ -struct LDKCVec_u8Z PaymentPurpose_write(const struct LDKPaymentPurpose *NONNULL_PTR obj); +void InitFeatures_set_payment_secret_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Read a PaymentPurpose from a byte array, created by PaymentPurpose_write + * Checks if this feature is supported. */ -struct LDKCResult_PaymentPurposeDecodeErrorZ PaymentPurpose_read(struct LDKu8slice ser); +MUST_USE_RES bool InitFeatures_supports_payment_secret(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the ClaimedHTLC, if is_owned is set and inner is non-NULL. + * Set this feature as optional. */ -void ClaimedHTLC_free(struct LDKClaimedHTLC this_obj); +void NodeFeatures_set_payment_secret_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * The `channel_id` of the channel over which the HTLC was received. + * Set this feature as required. */ -struct LDKChannelId ClaimedHTLC_get_channel_id(const struct LDKClaimedHTLC *NONNULL_PTR this_ptr); +void NodeFeatures_set_payment_secret_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * The `channel_id` of the channel over which the HTLC was received. + * Checks if this feature is supported. */ -void ClaimedHTLC_set_channel_id(struct LDKClaimedHTLC *NONNULL_PTR this_ptr, struct LDKChannelId val); +MUST_USE_RES bool NodeFeatures_supports_payment_secret(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * The `user_channel_id` of the channel over which the HTLC was received. This is the 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. - * - * This field will be zero for a payment that was serialized prior to LDK version 0.0.117. (This - * should only happen in the case that a payment was claimable prior to LDK version 0.0.117, but - * was not actually claimed until after upgrading.) - * - * [`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 + * Set this feature as optional. */ -struct LDKU128 ClaimedHTLC_get_user_channel_id(const struct LDKClaimedHTLC *NONNULL_PTR this_ptr); +void Bolt11InvoiceFeatures_set_payment_secret_optional(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * The `user_channel_id` of the channel over which the HTLC was received. This is the 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. - * - * This field will be zero for a payment that was serialized prior to LDK version 0.0.117. (This - * should only happen in the case that a payment was claimable prior to LDK version 0.0.117, but - * was not actually claimed until after upgrading.) - * - * [`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 + * Set this feature as required. */ -void ClaimedHTLC_set_user_channel_id(struct LDKClaimedHTLC *NONNULL_PTR this_ptr, struct LDKU128 val); +void Bolt11InvoiceFeatures_set_payment_secret_required(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * The block height at which this HTLC expires. + * Checks if this feature is supported. */ -uint32_t ClaimedHTLC_get_cltv_expiry(const struct LDKClaimedHTLC *NONNULL_PTR this_ptr); +MUST_USE_RES bool Bolt11InvoiceFeatures_supports_payment_secret(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * The block height at which this HTLC expires. + * Checks if this feature is required. */ -void ClaimedHTLC_set_cltv_expiry(struct LDKClaimedHTLC *NONNULL_PTR this_ptr, uint32_t val); +MUST_USE_RES bool InitFeatures_requires_payment_secret(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * The amount (in msats) of this part of an MPP. + * Checks if this feature is required. */ -uint64_t ClaimedHTLC_get_value_msat(const struct LDKClaimedHTLC *NONNULL_PTR this_ptr); +MUST_USE_RES bool NodeFeatures_requires_payment_secret(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * The amount (in msats) of this part of an MPP. + * Checks if this feature is required. */ -void ClaimedHTLC_set_value_msat(struct LDKClaimedHTLC *NONNULL_PTR this_ptr, uint64_t val); +MUST_USE_RES bool Bolt11InvoiceFeatures_requires_payment_secret(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * The extra fee our counterparty skimmed off the top of this HTLC, if any. - * - * This value will always be 0 for [`ClaimedHTLC`]s serialized with LDK versions prior to - * 0.0.119. + * Set this feature as optional. */ -uint64_t ClaimedHTLC_get_counterparty_skimmed_fee_msat(const struct LDKClaimedHTLC *NONNULL_PTR this_ptr); +void InitFeatures_set_basic_mpp_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * The extra fee our counterparty skimmed off the top of this HTLC, if any. - * - * This value will always be 0 for [`ClaimedHTLC`]s serialized with LDK versions prior to - * 0.0.119. + * Set this feature as required. */ -void ClaimedHTLC_set_counterparty_skimmed_fee_msat(struct LDKClaimedHTLC *NONNULL_PTR this_ptr, uint64_t val); +void InitFeatures_set_basic_mpp_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Constructs a new ClaimedHTLC given each field + * Checks if this feature is supported. */ -MUST_USE_RES struct LDKClaimedHTLC ClaimedHTLC_new(struct LDKChannelId channel_id_arg, struct LDKU128 user_channel_id_arg, uint32_t cltv_expiry_arg, uint64_t value_msat_arg, uint64_t counterparty_skimmed_fee_msat_arg); +MUST_USE_RES bool InitFeatures_supports_basic_mpp(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the ClaimedHTLC + * Set this feature as optional. */ -struct LDKClaimedHTLC ClaimedHTLC_clone(const struct LDKClaimedHTLC *NONNULL_PTR orig); +void NodeFeatures_set_basic_mpp_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Checks if two ClaimedHTLCs 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 ClaimedHTLC_eq(const struct LDKClaimedHTLC *NONNULL_PTR a, const struct LDKClaimedHTLC *NONNULL_PTR b); +void NodeFeatures_set_basic_mpp_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Serialize the ClaimedHTLC object into a byte array which can be read by ClaimedHTLC_read + * Checks if this feature is supported. */ -struct LDKCVec_u8Z ClaimedHTLC_write(const struct LDKClaimedHTLC *NONNULL_PTR obj); +MUST_USE_RES bool NodeFeatures_supports_basic_mpp(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Read a ClaimedHTLC from a byte array, created by ClaimedHTLC_write + * Set this feature as optional. */ -struct LDKCResult_ClaimedHTLCDecodeErrorZ ClaimedHTLC_read(struct LDKu8slice ser); +void Bolt11InvoiceFeatures_set_basic_mpp_optional(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the PathFailure + * Set this feature as required. */ -void PathFailure_free(struct LDKPathFailure this_ptr); +void Bolt11InvoiceFeatures_set_basic_mpp_required(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the PathFailure + * Checks if this feature is supported. */ -struct LDKPathFailure PathFailure_clone(const struct LDKPathFailure *NONNULL_PTR orig); +MUST_USE_RES bool Bolt11InvoiceFeatures_supports_basic_mpp(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new InitialSend-variant PathFailure + * Set this feature as optional. */ -struct LDKPathFailure PathFailure_initial_send(struct LDKAPIError err); +void Bolt12InvoiceFeatures_set_basic_mpp_optional(struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new OnPath-variant PathFailure + * Set this feature as required. */ -struct LDKPathFailure PathFailure_on_path(struct LDKCOption_NetworkUpdateZ network_update); +void Bolt12InvoiceFeatures_set_basic_mpp_required(struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg); /** - * Checks if two PathFailures contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Checks if this feature is supported. */ -bool PathFailure_eq(const struct LDKPathFailure *NONNULL_PTR a, const struct LDKPathFailure *NONNULL_PTR b); +MUST_USE_RES bool Bolt12InvoiceFeatures_supports_basic_mpp(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg); /** - * Serialize the PathFailure object into a byte array which can be read by PathFailure_read + * Checks if this feature is required. */ -struct LDKCVec_u8Z PathFailure_write(const struct LDKPathFailure *NONNULL_PTR obj); +MUST_USE_RES bool InitFeatures_requires_basic_mpp(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Read a PathFailure from a byte array, created by PathFailure_write + * Checks if this feature is required. */ -struct LDKCResult_COption_PathFailureZDecodeErrorZ PathFailure_read(struct LDKu8slice ser); +MUST_USE_RES bool NodeFeatures_requires_basic_mpp(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the ClosureReason + * Checks if this feature is required. */ -void ClosureReason_free(struct LDKClosureReason this_ptr); +MUST_USE_RES bool Bolt11InvoiceFeatures_requires_basic_mpp(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the ClosureReason + * Checks if this feature is required. */ -struct LDKClosureReason ClosureReason_clone(const struct LDKClosureReason *NONNULL_PTR orig); +MUST_USE_RES bool Bolt12InvoiceFeatures_requires_basic_mpp(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new CounterpartyForceClosed-variant ClosureReason + * Set this feature as optional. */ -struct LDKClosureReason ClosureReason_counterparty_force_closed(struct LDKUntrustedString peer_msg); +void InitFeatures_set_wumbo_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new HolderForceClosed-variant ClosureReason + * Set this feature as required. */ -struct LDKClosureReason ClosureReason_holder_force_closed(void); +void InitFeatures_set_wumbo_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new LegacyCooperativeClosure-variant ClosureReason + * Checks if this feature is supported. */ -struct LDKClosureReason ClosureReason_legacy_cooperative_closure(void); +MUST_USE_RES bool InitFeatures_supports_wumbo(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new CounterpartyInitiatedCooperativeClosure-variant ClosureReason + * Set this feature as optional. */ -struct LDKClosureReason ClosureReason_counterparty_initiated_cooperative_closure(void); +void NodeFeatures_set_wumbo_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new LocallyInitiatedCooperativeClosure-variant ClosureReason + * Set this feature as required. */ -struct LDKClosureReason ClosureReason_locally_initiated_cooperative_closure(void); +void NodeFeatures_set_wumbo_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new CommitmentTxConfirmed-variant ClosureReason + * Checks if this feature is supported. */ -struct LDKClosureReason ClosureReason_commitment_tx_confirmed(void); +MUST_USE_RES bool NodeFeatures_supports_wumbo(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new FundingTimedOut-variant ClosureReason + * Checks if this feature is required. */ -struct LDKClosureReason ClosureReason_funding_timed_out(void); +MUST_USE_RES bool InitFeatures_requires_wumbo(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new ProcessingError-variant ClosureReason + * Checks if this feature is required. */ -struct LDKClosureReason ClosureReason_processing_error(struct LDKStr err); +MUST_USE_RES bool NodeFeatures_requires_wumbo(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new DisconnectedPeer-variant ClosureReason + * Set this feature as optional. */ -struct LDKClosureReason ClosureReason_disconnected_peer(void); +void InitFeatures_set_anchors_nonzero_fee_htlc_tx_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new OutdatedChannelManager-variant ClosureReason + * Set this feature as required. */ -struct LDKClosureReason ClosureReason_outdated_channel_manager(void); +void InitFeatures_set_anchors_nonzero_fee_htlc_tx_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new CounterpartyCoopClosedUnfundedChannel-variant ClosureReason + * Checks if this feature is supported. */ -struct LDKClosureReason ClosureReason_counterparty_coop_closed_unfunded_channel(void); +MUST_USE_RES bool InitFeatures_supports_anchors_nonzero_fee_htlc_tx(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new FundingBatchClosure-variant ClosureReason + * Set this feature as optional. */ -struct LDKClosureReason ClosureReason_funding_batch_closure(void); +void NodeFeatures_set_anchors_nonzero_fee_htlc_tx_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new HTLCsTimedOut-variant ClosureReason + * Set this feature as required. */ -struct LDKClosureReason ClosureReason_htlcs_timed_out(void); +void NodeFeatures_set_anchors_nonzero_fee_htlc_tx_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Checks if two ClosureReasons contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Checks if this feature is supported. */ -bool ClosureReason_eq(const struct LDKClosureReason *NONNULL_PTR a, const struct LDKClosureReason *NONNULL_PTR b); +MUST_USE_RES bool NodeFeatures_supports_anchors_nonzero_fee_htlc_tx(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Get the string representation of a ClosureReason object + * Set this feature as optional. */ -struct LDKStr ClosureReason_to_str(const struct LDKClosureReason *NONNULL_PTR o); +void ChannelTypeFeatures_set_anchors_nonzero_fee_htlc_tx_optional(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Serialize the ClosureReason object into a byte array which can be read by ClosureReason_read + * Set this feature as required. */ -struct LDKCVec_u8Z ClosureReason_write(const struct LDKClosureReason *NONNULL_PTR obj); +void ChannelTypeFeatures_set_anchors_nonzero_fee_htlc_tx_required(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Read a ClosureReason from a byte array, created by ClosureReason_write + * Checks if this feature is supported. */ -struct LDKCResult_COption_ClosureReasonZDecodeErrorZ ClosureReason_read(struct LDKu8slice ser); +MUST_USE_RES bool ChannelTypeFeatures_supports_anchors_nonzero_fee_htlc_tx(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the HTLCDestination + * Checks if this feature is required. */ -void HTLCDestination_free(struct LDKHTLCDestination this_ptr); +MUST_USE_RES bool InitFeatures_requires_anchors_nonzero_fee_htlc_tx(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the HTLCDestination + * Checks if this feature is required. */ -struct LDKHTLCDestination HTLCDestination_clone(const struct LDKHTLCDestination *NONNULL_PTR orig); +MUST_USE_RES bool NodeFeatures_requires_anchors_nonzero_fee_htlc_tx(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new NextHopChannel-variant HTLCDestination + * Checks if this feature is required. */ -struct LDKHTLCDestination HTLCDestination_next_hop_channel(struct LDKPublicKey node_id, struct LDKChannelId channel_id); +MUST_USE_RES bool ChannelTypeFeatures_requires_anchors_nonzero_fee_htlc_tx(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new UnknownNextHop-variant HTLCDestination + * Set this feature as optional. */ -struct LDKHTLCDestination HTLCDestination_unknown_next_hop(uint64_t requested_forward_scid); +void InitFeatures_set_anchors_zero_fee_htlc_tx_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new InvalidForward-variant HTLCDestination + * Set this feature as required. */ -struct LDKHTLCDestination HTLCDestination_invalid_forward(uint64_t requested_forward_scid); +void InitFeatures_set_anchors_zero_fee_htlc_tx_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new InvalidOnion-variant HTLCDestination + * Checks if this feature is supported. */ -struct LDKHTLCDestination HTLCDestination_invalid_onion(void); +MUST_USE_RES bool InitFeatures_supports_anchors_zero_fee_htlc_tx(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new FailedPayment-variant HTLCDestination + * Set this feature as optional. */ -struct LDKHTLCDestination HTLCDestination_failed_payment(struct LDKThirtyTwoBytes payment_hash); +void NodeFeatures_set_anchors_zero_fee_htlc_tx_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Checks if two HTLCDestinations contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Set this feature as required. */ -bool HTLCDestination_eq(const struct LDKHTLCDestination *NONNULL_PTR a, const struct LDKHTLCDestination *NONNULL_PTR b); +void NodeFeatures_set_anchors_zero_fee_htlc_tx_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Serialize the HTLCDestination object into a byte array which can be read by HTLCDestination_read + * Checks if this feature is supported. */ -struct LDKCVec_u8Z HTLCDestination_write(const struct LDKHTLCDestination *NONNULL_PTR obj); +MUST_USE_RES bool NodeFeatures_supports_anchors_zero_fee_htlc_tx(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Read a HTLCDestination from a byte array, created by HTLCDestination_write + * Set this feature as optional. */ -struct LDKCResult_COption_HTLCDestinationZDecodeErrorZ HTLCDestination_read(struct LDKu8slice ser); +void ChannelTypeFeatures_set_anchors_zero_fee_htlc_tx_optional(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the PaymentFailureReason + * Set this feature as required. */ -enum LDKPaymentFailureReason PaymentFailureReason_clone(const enum LDKPaymentFailureReason *NONNULL_PTR orig); +void ChannelTypeFeatures_set_anchors_zero_fee_htlc_tx_required(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new RecipientRejected-variant PaymentFailureReason + * Checks if this feature is supported. */ -enum LDKPaymentFailureReason PaymentFailureReason_recipient_rejected(void); +MUST_USE_RES bool ChannelTypeFeatures_supports_anchors_zero_fee_htlc_tx(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new UserAbandoned-variant PaymentFailureReason + * Checks if this feature is required. */ -enum LDKPaymentFailureReason PaymentFailureReason_user_abandoned(void); +MUST_USE_RES bool InitFeatures_requires_anchors_zero_fee_htlc_tx(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new RetriesExhausted-variant PaymentFailureReason + * Checks if this feature is required. */ -enum LDKPaymentFailureReason PaymentFailureReason_retries_exhausted(void); +MUST_USE_RES bool NodeFeatures_requires_anchors_zero_fee_htlc_tx(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new PaymentExpired-variant PaymentFailureReason + * Checks if this feature is required. */ -enum LDKPaymentFailureReason PaymentFailureReason_payment_expired(void); +MUST_USE_RES bool ChannelTypeFeatures_requires_anchors_zero_fee_htlc_tx(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new RouteNotFound-variant PaymentFailureReason + * Set this feature as optional. */ -enum LDKPaymentFailureReason PaymentFailureReason_route_not_found(void); +void InitFeatures_set_route_blinding_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new UnexpectedError-variant PaymentFailureReason + * Set this feature as required. */ -enum LDKPaymentFailureReason PaymentFailureReason_unexpected_error(void); +void InitFeatures_set_route_blinding_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Checks if two PaymentFailureReasons contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Checks if this feature is supported. */ -bool PaymentFailureReason_eq(const enum LDKPaymentFailureReason *NONNULL_PTR a, const enum LDKPaymentFailureReason *NONNULL_PTR b); +MUST_USE_RES bool InitFeatures_supports_route_blinding(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Serialize the PaymentFailureReason object into a byte array which can be read by PaymentFailureReason_read + * Set this feature as optional. */ -struct LDKCVec_u8Z PaymentFailureReason_write(const enum LDKPaymentFailureReason *NONNULL_PTR obj); +void NodeFeatures_set_route_blinding_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Read a PaymentFailureReason from a byte array, created by PaymentFailureReason_write + * Set this feature as required. */ -struct LDKCResult_PaymentFailureReasonDecodeErrorZ PaymentFailureReason_read(struct LDKu8slice ser); +void NodeFeatures_set_route_blinding_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the Event + * Checks if this feature is supported. */ -void Event_free(struct LDKEvent this_ptr); +MUST_USE_RES bool NodeFeatures_supports_route_blinding(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the Event + * Checks if this feature is required. */ -struct LDKEvent Event_clone(const struct LDKEvent *NONNULL_PTR orig); +MUST_USE_RES bool InitFeatures_requires_route_blinding(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new FundingGenerationReady-variant Event + * Checks if this feature is required. */ -struct LDKEvent Event_funding_generation_ready(struct LDKChannelId temporary_channel_id, struct LDKPublicKey counterparty_node_id, uint64_t channel_value_satoshis, struct LDKCVec_u8Z output_script, struct LDKU128 user_channel_id); +MUST_USE_RES bool NodeFeatures_requires_route_blinding(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new PaymentClaimable-variant Event + * Set this feature as optional. */ -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 LDKChannelId via_channel_id, struct LDKCOption_U128Z via_user_channel_id, struct LDKCOption_u32Z claim_deadline); +void InitFeatures_set_shutdown_any_segwit_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new PaymentClaimed-variant Event + * Set this feature as required. */ -struct LDKEvent Event_payment_claimed(struct LDKPublicKey receiver_node_id, struct LDKThirtyTwoBytes payment_hash, uint64_t amount_msat, struct LDKPaymentPurpose purpose, struct LDKCVec_ClaimedHTLCZ htlcs, struct LDKCOption_u64Z sender_intended_total_msat); +void InitFeatures_set_shutdown_any_segwit_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new ConnectionNeeded-variant Event + * Checks if this feature is supported. */ -struct LDKEvent Event_connection_needed(struct LDKPublicKey node_id, struct LDKCVec_SocketAddressZ addresses); +MUST_USE_RES bool InitFeatures_supports_shutdown_anysegwit(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new InvoiceRequestFailed-variant Event + * Set this feature as optional. */ -struct LDKEvent Event_invoice_request_failed(struct LDKThirtyTwoBytes payment_id); +void NodeFeatures_set_shutdown_any_segwit_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new PaymentSent-variant Event + * Set this feature as required. */ -struct LDKEvent Event_payment_sent(struct LDKCOption_ThirtyTwoBytesZ payment_id, struct LDKThirtyTwoBytes payment_preimage, struct LDKThirtyTwoBytes payment_hash, struct LDKCOption_u64Z fee_paid_msat); +void NodeFeatures_set_shutdown_any_segwit_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new PaymentFailed-variant Event + * Checks if this feature is supported. */ -struct LDKEvent Event_payment_failed(struct LDKThirtyTwoBytes payment_id, struct LDKThirtyTwoBytes payment_hash, struct LDKCOption_PaymentFailureReasonZ reason); +MUST_USE_RES bool NodeFeatures_supports_shutdown_anysegwit(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new PaymentPathSuccessful-variant Event + * Checks if this feature is required. */ -struct LDKEvent Event_payment_path_successful(struct LDKThirtyTwoBytes payment_id, struct LDKCOption_ThirtyTwoBytesZ payment_hash, struct LDKPath path); +MUST_USE_RES bool InitFeatures_requires_shutdown_anysegwit(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new PaymentPathFailed-variant Event + * Checks if this feature is required. */ -struct LDKEvent Event_payment_path_failed(struct LDKCOption_ThirtyTwoBytesZ payment_id, struct LDKThirtyTwoBytes payment_hash, bool payment_failed_permanently, struct LDKPathFailure failure, struct LDKPath path, struct LDKCOption_u64Z short_channel_id); +MUST_USE_RES bool NodeFeatures_requires_shutdown_anysegwit(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new ProbeSuccessful-variant Event + * Set this feature as optional. */ -struct LDKEvent Event_probe_successful(struct LDKThirtyTwoBytes payment_id, struct LDKThirtyTwoBytes payment_hash, struct LDKPath path); +void InitFeatures_set_taproot_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new ProbeFailed-variant Event + * Set this feature as required. */ -struct LDKEvent Event_probe_failed(struct LDKThirtyTwoBytes payment_id, struct LDKThirtyTwoBytes payment_hash, struct LDKPath path, struct LDKCOption_u64Z short_channel_id); +void InitFeatures_set_taproot_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new PendingHTLCsForwardable-variant Event + * Checks if this feature is supported. */ -struct LDKEvent Event_pending_htlcs_forwardable(uint64_t time_forwardable); +MUST_USE_RES bool InitFeatures_supports_taproot(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new HTLCIntercepted-variant Event + * Set this feature as optional. */ -struct LDKEvent Event_htlcintercepted(struct LDKThirtyTwoBytes intercept_id, uint64_t requested_next_hop_scid, struct LDKThirtyTwoBytes payment_hash, uint64_t inbound_amount_msat, uint64_t expected_outbound_amount_msat); +void NodeFeatures_set_taproot_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SpendableOutputs-variant Event + * Set this feature as required. */ -struct LDKEvent Event_spendable_outputs(struct LDKCVec_SpendableOutputDescriptorZ outputs, struct LDKChannelId channel_id); +void NodeFeatures_set_taproot_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new PaymentForwarded-variant Event + * Checks if this feature is supported. */ -struct LDKEvent Event_payment_forwarded(struct LDKChannelId prev_channel_id, struct LDKChannelId next_channel_id, struct LDKCOption_U128Z prev_user_channel_id, struct LDKCOption_U128Z next_user_channel_id, struct LDKCOption_u64Z total_fee_earned_msat, struct LDKCOption_u64Z skimmed_fee_msat, bool claim_from_onchain_tx, struct LDKCOption_u64Z outbound_amount_forwarded_msat); +MUST_USE_RES bool NodeFeatures_supports_taproot(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new ChannelPending-variant Event + * Set this feature as optional. */ -struct LDKEvent Event_channel_pending(struct LDKChannelId channel_id, struct LDKU128 user_channel_id, struct LDKChannelId former_temporary_channel_id, struct LDKPublicKey counterparty_node_id, struct LDKOutPoint funding_txo, struct LDKChannelTypeFeatures channel_type); +void ChannelTypeFeatures_set_taproot_optional(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new ChannelReady-variant Event + * Set this feature as required. */ -struct LDKEvent Event_channel_ready(struct LDKChannelId channel_id, struct LDKU128 user_channel_id, struct LDKPublicKey counterparty_node_id, struct LDKChannelTypeFeatures channel_type); +void ChannelTypeFeatures_set_taproot_required(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new ChannelClosed-variant Event + * Checks if this feature is supported. */ -struct LDKEvent Event_channel_closed(struct LDKChannelId channel_id, struct LDKU128 user_channel_id, struct LDKClosureReason reason, struct LDKPublicKey counterparty_node_id, struct LDKCOption_u64Z channel_capacity_sats, struct LDKOutPoint channel_funding_txo); +MUST_USE_RES bool ChannelTypeFeatures_supports_taproot(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new DiscardFunding-variant Event + * Checks if this feature is required. */ -struct LDKEvent Event_discard_funding(struct LDKChannelId channel_id, struct LDKTransaction transaction); +MUST_USE_RES bool InitFeatures_requires_taproot(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new OpenChannelRequest-variant Event + * Checks if this feature is required. */ -struct LDKEvent Event_open_channel_request(struct LDKChannelId temporary_channel_id, struct LDKPublicKey counterparty_node_id, uint64_t funding_satoshis, uint64_t push_msat, struct LDKChannelTypeFeatures channel_type); +MUST_USE_RES bool NodeFeatures_requires_taproot(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new HTLCHandlingFailed-variant Event + * Checks if this feature is required. */ -struct LDKEvent Event_htlchandling_failed(struct LDKChannelId prev_channel_id, struct LDKHTLCDestination failed_next_destination); +MUST_USE_RES bool ChannelTypeFeatures_requires_taproot(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new BumpTransaction-variant Event + * Set this feature as optional. */ -struct LDKEvent Event_bump_transaction(struct LDKBumpTransactionEvent a); +void InitFeatures_set_onion_messages_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Checks if two Events contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Set this feature as required. */ -bool Event_eq(const struct LDKEvent *NONNULL_PTR a, const struct LDKEvent *NONNULL_PTR b); +void InitFeatures_set_onion_messages_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Serialize the Event object into a byte array which can be read by Event_read + * Checks if this feature is supported. */ -struct LDKCVec_u8Z Event_write(const struct LDKEvent *NONNULL_PTR obj); +MUST_USE_RES bool InitFeatures_supports_onion_messages(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Read a Event from a byte array, created by Event_write + * Set this feature as optional. */ -struct LDKCResult_COption_EventZDecodeErrorZ Event_read(struct LDKu8slice ser); +void NodeFeatures_set_onion_messages_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the MessageSendEvent + * Set this feature as required. */ -void MessageSendEvent_free(struct LDKMessageSendEvent this_ptr); +void NodeFeatures_set_onion_messages_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the MessageSendEvent + * Checks if this feature is supported. */ -struct LDKMessageSendEvent MessageSendEvent_clone(const struct LDKMessageSendEvent *NONNULL_PTR orig); +MUST_USE_RES bool NodeFeatures_supports_onion_messages(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendAcceptChannel-variant MessageSendEvent + * Checks if this feature is required. */ -struct LDKMessageSendEvent MessageSendEvent_send_accept_channel(struct LDKPublicKey node_id, struct LDKAcceptChannel msg); +MUST_USE_RES bool InitFeatures_requires_onion_messages(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendAcceptChannelV2-variant MessageSendEvent + * Checks if this feature is required. */ -struct LDKMessageSendEvent MessageSendEvent_send_accept_channel_v2(struct LDKPublicKey node_id, struct LDKAcceptChannelV2 msg); +MUST_USE_RES bool NodeFeatures_requires_onion_messages(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendOpenChannel-variant MessageSendEvent + * Set this feature as optional. */ -struct LDKMessageSendEvent MessageSendEvent_send_open_channel(struct LDKPublicKey node_id, struct LDKOpenChannel msg); +void InitFeatures_set_channel_type_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendOpenChannelV2-variant MessageSendEvent + * Set this feature as required. */ -struct LDKMessageSendEvent MessageSendEvent_send_open_channel_v2(struct LDKPublicKey node_id, struct LDKOpenChannelV2 msg); +void InitFeatures_set_channel_type_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendFundingCreated-variant MessageSendEvent + * Checks if this feature is supported. */ -struct LDKMessageSendEvent MessageSendEvent_send_funding_created(struct LDKPublicKey node_id, struct LDKFundingCreated msg); +MUST_USE_RES bool InitFeatures_supports_channel_type(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendFundingSigned-variant MessageSendEvent + * Set this feature as optional. */ -struct LDKMessageSendEvent MessageSendEvent_send_funding_signed(struct LDKPublicKey node_id, struct LDKFundingSigned msg); +void NodeFeatures_set_channel_type_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendStfu-variant MessageSendEvent + * Set this feature as required. */ -struct LDKMessageSendEvent MessageSendEvent_send_stfu(struct LDKPublicKey node_id, struct LDKStfu msg); +void NodeFeatures_set_channel_type_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendSplice-variant MessageSendEvent + * Checks if this feature is supported. */ -struct LDKMessageSendEvent MessageSendEvent_send_splice(struct LDKPublicKey node_id, struct LDKSplice msg); +MUST_USE_RES bool NodeFeatures_supports_channel_type(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendSpliceAck-variant MessageSendEvent + * Checks if this feature is required. */ -struct LDKMessageSendEvent MessageSendEvent_send_splice_ack(struct LDKPublicKey node_id, struct LDKSpliceAck msg); +MUST_USE_RES bool InitFeatures_requires_channel_type(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendSpliceLocked-variant MessageSendEvent + * Checks if this feature is required. */ -struct LDKMessageSendEvent MessageSendEvent_send_splice_locked(struct LDKPublicKey node_id, struct LDKSpliceLocked msg); +MUST_USE_RES bool NodeFeatures_requires_channel_type(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendTxAddInput-variant MessageSendEvent + * Set this feature as optional. */ -struct LDKMessageSendEvent MessageSendEvent_send_tx_add_input(struct LDKPublicKey node_id, struct LDKTxAddInput msg); +void InitFeatures_set_scid_privacy_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendTxAddOutput-variant MessageSendEvent + * Set this feature as required. */ -struct LDKMessageSendEvent MessageSendEvent_send_tx_add_output(struct LDKPublicKey node_id, struct LDKTxAddOutput msg); +void InitFeatures_set_scid_privacy_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendTxRemoveInput-variant MessageSendEvent + * Checks if this feature is supported. */ -struct LDKMessageSendEvent MessageSendEvent_send_tx_remove_input(struct LDKPublicKey node_id, struct LDKTxRemoveInput msg); +MUST_USE_RES bool InitFeatures_supports_scid_privacy(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendTxRemoveOutput-variant MessageSendEvent + * Set this feature as optional. */ -struct LDKMessageSendEvent MessageSendEvent_send_tx_remove_output(struct LDKPublicKey node_id, struct LDKTxRemoveOutput msg); +void NodeFeatures_set_scid_privacy_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendTxComplete-variant MessageSendEvent + * Set this feature as required. */ -struct LDKMessageSendEvent MessageSendEvent_send_tx_complete(struct LDKPublicKey node_id, struct LDKTxComplete msg); +void NodeFeatures_set_scid_privacy_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendTxSignatures-variant MessageSendEvent + * Checks if this feature is supported. */ -struct LDKMessageSendEvent MessageSendEvent_send_tx_signatures(struct LDKPublicKey node_id, struct LDKTxSignatures msg); +MUST_USE_RES bool NodeFeatures_supports_scid_privacy(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendTxInitRbf-variant MessageSendEvent + * Set this feature as optional. */ -struct LDKMessageSendEvent MessageSendEvent_send_tx_init_rbf(struct LDKPublicKey node_id, struct LDKTxInitRbf msg); +void ChannelTypeFeatures_set_scid_privacy_optional(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendTxAckRbf-variant MessageSendEvent + * Set this feature as required. */ -struct LDKMessageSendEvent MessageSendEvent_send_tx_ack_rbf(struct LDKPublicKey node_id, struct LDKTxAckRbf msg); +void ChannelTypeFeatures_set_scid_privacy_required(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendTxAbort-variant MessageSendEvent + * Checks if this feature is supported. */ -struct LDKMessageSendEvent MessageSendEvent_send_tx_abort(struct LDKPublicKey node_id, struct LDKTxAbort msg); +MUST_USE_RES bool ChannelTypeFeatures_supports_scid_privacy(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendChannelReady-variant MessageSendEvent + * Checks if this feature is required. */ -struct LDKMessageSendEvent MessageSendEvent_send_channel_ready(struct LDKPublicKey node_id, struct LDKChannelReady msg); +MUST_USE_RES bool InitFeatures_requires_scid_privacy(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendAnnouncementSignatures-variant MessageSendEvent + * Checks if this feature is required. */ -struct LDKMessageSendEvent MessageSendEvent_send_announcement_signatures(struct LDKPublicKey node_id, struct LDKAnnouncementSignatures msg); +MUST_USE_RES bool NodeFeatures_requires_scid_privacy(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new UpdateHTLCs-variant MessageSendEvent + * Checks if this feature is required. */ -struct LDKMessageSendEvent MessageSendEvent_update_htlcs(struct LDKPublicKey node_id, struct LDKCommitmentUpdate updates); +MUST_USE_RES bool ChannelTypeFeatures_requires_scid_privacy(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendRevokeAndACK-variant MessageSendEvent + * Set this feature as optional. */ -struct LDKMessageSendEvent MessageSendEvent_send_revoke_and_ack(struct LDKPublicKey node_id, struct LDKRevokeAndACK msg); +void Bolt11InvoiceFeatures_set_payment_metadata_optional(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendClosingSigned-variant MessageSendEvent + * Set this feature as required. */ -struct LDKMessageSendEvent MessageSendEvent_send_closing_signed(struct LDKPublicKey node_id, struct LDKClosingSigned msg); +void Bolt11InvoiceFeatures_set_payment_metadata_required(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendShutdown-variant MessageSendEvent + * Checks if this feature is supported. */ -struct LDKMessageSendEvent MessageSendEvent_send_shutdown(struct LDKPublicKey node_id, struct LDKShutdown msg); +MUST_USE_RES bool Bolt11InvoiceFeatures_supports_payment_metadata(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendChannelReestablish-variant MessageSendEvent + * Checks if this feature is required. */ -struct LDKMessageSendEvent MessageSendEvent_send_channel_reestablish(struct LDKPublicKey node_id, struct LDKChannelReestablish msg); +MUST_USE_RES bool Bolt11InvoiceFeatures_requires_payment_metadata(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendChannelAnnouncement-variant MessageSendEvent + * Set this feature as optional. */ -struct LDKMessageSendEvent MessageSendEvent_send_channel_announcement(struct LDKPublicKey node_id, struct LDKChannelAnnouncement msg, struct LDKChannelUpdate update_msg); +void InitFeatures_set_zero_conf_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new BroadcastChannelAnnouncement-variant MessageSendEvent + * Set this feature as required. */ -struct LDKMessageSendEvent MessageSendEvent_broadcast_channel_announcement(struct LDKChannelAnnouncement msg, struct LDKChannelUpdate update_msg); +void InitFeatures_set_zero_conf_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new BroadcastChannelUpdate-variant MessageSendEvent + * Checks if this feature is supported. */ -struct LDKMessageSendEvent MessageSendEvent_broadcast_channel_update(struct LDKChannelUpdate msg); +MUST_USE_RES bool InitFeatures_supports_zero_conf(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new BroadcastNodeAnnouncement-variant MessageSendEvent + * Set this feature as optional. */ -struct LDKMessageSendEvent MessageSendEvent_broadcast_node_announcement(struct LDKNodeAnnouncement msg); +void NodeFeatures_set_zero_conf_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendChannelUpdate-variant MessageSendEvent + * Set this feature as required. */ -struct LDKMessageSendEvent MessageSendEvent_send_channel_update(struct LDKPublicKey node_id, struct LDKChannelUpdate msg); +void NodeFeatures_set_zero_conf_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new HandleError-variant MessageSendEvent + * Checks if this feature is supported. */ -struct LDKMessageSendEvent MessageSendEvent_handle_error(struct LDKPublicKey node_id, struct LDKErrorAction action); +MUST_USE_RES bool NodeFeatures_supports_zero_conf(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendChannelRangeQuery-variant MessageSendEvent + * Set this feature as optional. */ -struct LDKMessageSendEvent MessageSendEvent_send_channel_range_query(struct LDKPublicKey node_id, struct LDKQueryChannelRange msg); +void ChannelTypeFeatures_set_zero_conf_optional(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendShortIdsQuery-variant MessageSendEvent + * Set this feature as required. */ -struct LDKMessageSendEvent MessageSendEvent_send_short_ids_query(struct LDKPublicKey node_id, struct LDKQueryShortChannelIds msg); +void ChannelTypeFeatures_set_zero_conf_required(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendReplyChannelRange-variant MessageSendEvent + * Checks if this feature is supported. */ -struct LDKMessageSendEvent MessageSendEvent_send_reply_channel_range(struct LDKPublicKey node_id, struct LDKReplyChannelRange msg); +MUST_USE_RES bool ChannelTypeFeatures_supports_zero_conf(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendGossipTimestampFilter-variant MessageSendEvent + * Checks if this feature is required. */ -struct LDKMessageSendEvent MessageSendEvent_send_gossip_timestamp_filter(struct LDKPublicKey node_id, struct LDKGossipTimestampFilter msg); +MUST_USE_RES bool InitFeatures_requires_zero_conf(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Calls the free function if one is set + * Checks if this feature is required. */ -void MessageSendEventsProvider_free(struct LDKMessageSendEventsProvider this_ptr); +MUST_USE_RES bool NodeFeatures_requires_zero_conf(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Calls the free function if one is set + * Checks if this feature is required. */ -void EventsProvider_free(struct LDKEventsProvider this_ptr); +MUST_USE_RES bool ChannelTypeFeatures_requires_zero_conf(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Calls the free function if one is set + * Set this feature as optional. */ -void EventHandler_free(struct LDKEventHandler this_ptr); +void NodeFeatures_set_keysend_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the AnchorDescriptor, if is_owned is set and inner is non-NULL. + * Set this feature as required. */ -void AnchorDescriptor_free(struct LDKAnchorDescriptor this_obj); +void NodeFeatures_set_keysend_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * The parameters required to derive the signer for the anchor input. + * Checks if this feature is supported. */ -struct LDKChannelDerivationParameters AnchorDescriptor_get_channel_derivation_parameters(const struct LDKAnchorDescriptor *NONNULL_PTR this_ptr); +MUST_USE_RES bool NodeFeatures_supports_keysend(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * The parameters required to derive the signer for the anchor input. + * Checks if this feature is required. */ -void AnchorDescriptor_set_channel_derivation_parameters(struct LDKAnchorDescriptor *NONNULL_PTR this_ptr, struct LDKChannelDerivationParameters val); +MUST_USE_RES bool NodeFeatures_requires_keysend(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * The transaction input's outpoint corresponding to the commitment transaction's anchor - * output. + * Set this feature as optional. */ -struct LDKOutPoint AnchorDescriptor_get_outpoint(const struct LDKAnchorDescriptor *NONNULL_PTR this_ptr); +void InitFeatures_set_trampoline_routing_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * The transaction input's outpoint corresponding to the commitment transaction's anchor - * output. + * Set this feature as required. */ -void AnchorDescriptor_set_outpoint(struct LDKAnchorDescriptor *NONNULL_PTR this_ptr, struct LDKOutPoint val); +void InitFeatures_set_trampoline_routing_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Constructs a new AnchorDescriptor given each field + * Checks if this feature is supported. */ -MUST_USE_RES struct LDKAnchorDescriptor AnchorDescriptor_new(struct LDKChannelDerivationParameters channel_derivation_parameters_arg, struct LDKOutPoint outpoint_arg); +MUST_USE_RES bool InitFeatures_supports_trampoline_routing(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the AnchorDescriptor + * Set this feature as optional. */ -struct LDKAnchorDescriptor AnchorDescriptor_clone(const struct LDKAnchorDescriptor *NONNULL_PTR orig); +void NodeFeatures_set_trampoline_routing_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * 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. + * Set this feature as required. */ -bool AnchorDescriptor_eq(const struct LDKAnchorDescriptor *NONNULL_PTR a, const struct LDKAnchorDescriptor *NONNULL_PTR b); +void NodeFeatures_set_trampoline_routing_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Returns the UTXO to be spent by the anchor input, which can be obtained via - * [`Self::unsigned_tx_input`]. + * Checks if this feature is supported. */ -MUST_USE_RES struct LDKTxOut AnchorDescriptor_previous_utxo(const struct LDKAnchorDescriptor *NONNULL_PTR this_arg); +MUST_USE_RES bool NodeFeatures_supports_trampoline_routing(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Returns the unsigned transaction input spending the anchor output in the commitment - * transaction. + * Set this feature as optional. */ -MUST_USE_RES struct LDKTxIn AnchorDescriptor_unsigned_tx_input(const struct LDKAnchorDescriptor *NONNULL_PTR this_arg); +void Bolt11InvoiceFeatures_set_trampoline_routing_optional(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Returns the witness script of the anchor output in the commitment transaction. + * Set this feature as required. */ -MUST_USE_RES struct LDKCVec_u8Z AnchorDescriptor_witness_script(const struct LDKAnchorDescriptor *NONNULL_PTR this_arg); +void Bolt11InvoiceFeatures_set_trampoline_routing_required(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Returns the fully signed witness required to spend the anchor output in the commitment - * transaction. + * Checks if this feature is supported. */ -MUST_USE_RES struct LDKWitness AnchorDescriptor_tx_input_witness(const struct LDKAnchorDescriptor *NONNULL_PTR this_arg, struct LDKECDSASignature signature); +MUST_USE_RES bool Bolt11InvoiceFeatures_supports_trampoline_routing(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Derives the channel signer required to sign the anchor input. + * Checks if this feature is required. */ -MUST_USE_RES struct LDKWriteableEcdsaChannelSigner AnchorDescriptor_derive_channel_signer(const struct LDKAnchorDescriptor *NONNULL_PTR this_arg, const struct LDKSignerProvider *NONNULL_PTR signer_provider); +MUST_USE_RES bool InitFeatures_requires_trampoline_routing(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the BumpTransactionEvent + * Checks if this feature is required. */ -void BumpTransactionEvent_free(struct LDKBumpTransactionEvent this_ptr); +MUST_USE_RES bool NodeFeatures_requires_trampoline_routing(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the BumpTransactionEvent + * Checks if this feature is required. */ -struct LDKBumpTransactionEvent BumpTransactionEvent_clone(const struct LDKBumpTransactionEvent *NONNULL_PTR orig); +MUST_USE_RES bool Bolt11InvoiceFeatures_requires_trampoline_routing(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new ChannelClose-variant BumpTransactionEvent + * Frees any resources used by the RoutingFees, if is_owned is set and inner is non-NULL. */ -struct LDKBumpTransactionEvent BumpTransactionEvent_channel_close(struct LDKChannelId channel_id, struct LDKPublicKey counterparty_node_id, 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); +void RoutingFees_free(struct LDKRoutingFees this_obj); /** - * Utility method to constructs a new HTLCResolution-variant BumpTransactionEvent + * Flat routing fee in millisatoshis. */ -struct LDKBumpTransactionEvent BumpTransactionEvent_htlcresolution(struct LDKChannelId channel_id, struct LDKPublicKey counterparty_node_id, struct LDKThirtyTwoBytes claim_id, uint32_t target_feerate_sat_per_1000_weight, struct LDKCVec_HTLCDescriptorZ htlc_descriptors, uint32_t tx_lock_time); +uint32_t RoutingFees_get_base_msat(const struct LDKRoutingFees *NONNULL_PTR this_ptr); /** - * Checks if two BumpTransactionEvents contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Flat routing fee in millisatoshis. */ -bool BumpTransactionEvent_eq(const struct LDKBumpTransactionEvent *NONNULL_PTR a, const struct LDKBumpTransactionEvent *NONNULL_PTR b); +void RoutingFees_set_base_msat(struct LDKRoutingFees *NONNULL_PTR this_ptr, uint32_t val); /** - * Frees any resources used by the Input, 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 Input_free(struct LDKInput this_obj); +uint32_t RoutingFees_get_proportional_millionths(const struct LDKRoutingFees *NONNULL_PTR this_ptr); /** - * The unique identifier of the input. + * Liquidity-based routing fee in millionths of a routed amount. + * In other words, 10000 is 1%. */ -struct LDKOutPoint Input_get_outpoint(const struct LDKInput *NONNULL_PTR this_ptr); +void RoutingFees_set_proportional_millionths(struct LDKRoutingFees *NONNULL_PTR this_ptr, uint32_t val); /** - * The unique identifier of the input. + * Constructs a new RoutingFees given each field */ -void Input_set_outpoint(struct LDKInput *NONNULL_PTR this_ptr, struct LDKOutPoint val); +MUST_USE_RES struct LDKRoutingFees RoutingFees_new(uint32_t base_msat_arg, uint32_t proportional_millionths_arg); /** - * The UTXO being spent by the input. + * 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. */ -struct LDKTxOut Input_get_previous_utxo(const struct LDKInput *NONNULL_PTR this_ptr); +bool RoutingFees_eq(const struct LDKRoutingFees *NONNULL_PTR a, const struct LDKRoutingFees *NONNULL_PTR b); /** - * The UTXO being spent by the input. + * Creates a copy of the RoutingFees */ -void Input_set_previous_utxo(struct LDKInput *NONNULL_PTR this_ptr, struct LDKTxOut val); +struct LDKRoutingFees RoutingFees_clone(const struct LDKRoutingFees *NONNULL_PTR orig); /** - * 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. + * Generates a non-cryptographic 64-bit hash of the RoutingFees. */ -uint64_t Input_get_satisfaction_weight(const struct LDKInput *NONNULL_PTR this_ptr); +uint64_t RoutingFees_hash(const struct LDKRoutingFees *NONNULL_PTR o); /** - * 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. + * Frees any resources used by the RouteHint, if is_owned is set and inner is non-NULL. */ -void Input_set_satisfaction_weight(struct LDKInput *NONNULL_PTR this_ptr, uint64_t val); +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 Input given each field + * Constructs a new RouteHint given each field */ -MUST_USE_RES struct LDKInput Input_new(struct LDKOutPoint outpoint_arg, struct LDKTxOut previous_utxo_arg, uint64_t satisfaction_weight_arg); +MUST_USE_RES struct LDKRouteHint RouteHint_new(struct LDKCVec_RouteHintHopZ a_arg); /** - * Creates a copy of the Input + * Creates a copy of the RouteHint */ -struct LDKInput Input_clone(const struct LDKInput *NONNULL_PTR orig); +struct LDKRouteHint RouteHint_clone(const struct LDKRouteHint *NONNULL_PTR orig); /** - * Generates a non-cryptographic 64-bit hash of the Input. + * Generates a non-cryptographic 64-bit hash of the RouteHint. */ -uint64_t Input_hash(const struct LDKInput *NONNULL_PTR o); +uint64_t RouteHint_hash(const struct LDKRouteHint *NONNULL_PTR o); /** - * Checks if two Inputs contain equal inner contents. + * 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. */ -bool Input_eq(const struct LDKInput *NONNULL_PTR a, const struct LDKInput *NONNULL_PTR b); +bool RouteHint_eq(const struct LDKRouteHint *NONNULL_PTR a, const struct LDKRouteHint *NONNULL_PTR b); /** - * Frees any resources used by the Utxo, if is_owned is set and inner is non-NULL. + * Frees any resources used by the RouteHintHop, if is_owned is set and inner is non-NULL. */ -void Utxo_free(struct LDKUtxo this_obj); +void RouteHintHop_free(struct LDKRouteHintHop this_obj); /** - * The unique identifier of the output. + * The node_id of the non-target end of the route */ -struct LDKOutPoint Utxo_get_outpoint(const struct LDKUtxo *NONNULL_PTR this_ptr); +struct LDKPublicKey RouteHintHop_get_src_node_id(const struct LDKRouteHintHop *NONNULL_PTR this_ptr); /** - * The unique identifier of the output. + * The node_id of the non-target end of the route */ -void Utxo_set_outpoint(struct LDKUtxo *NONNULL_PTR this_ptr, struct LDKOutPoint val); +void RouteHintHop_set_src_node_id(struct LDKRouteHintHop *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * The output to spend. + * The short_channel_id of this channel */ -struct LDKTxOut Utxo_get_output(const struct LDKUtxo *NONNULL_PTR this_ptr); +uint64_t RouteHintHop_get_short_channel_id(const struct LDKRouteHintHop *NONNULL_PTR this_ptr); /** - * The output to spend. + * The short_channel_id of this channel */ -void Utxo_set_output(struct LDKUtxo *NONNULL_PTR this_ptr, struct LDKTxOut val); +void RouteHintHop_set_short_channel_id(struct LDKRouteHintHop *NONNULL_PTR this_ptr, uint64_t 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`]. + * The fees which must be paid to use this channel */ -uint64_t Utxo_get_satisfaction_weight(const struct LDKUtxo *NONNULL_PTR this_ptr); +struct LDKRoutingFees RouteHintHop_get_fees(const struct LDKRouteHintHop *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`]. + * The fees which must be paid to use this channel */ -void Utxo_set_satisfaction_weight(struct LDKUtxo *NONNULL_PTR this_ptr, uint64_t val); +void RouteHintHop_set_fees(struct LDKRouteHintHop *NONNULL_PTR this_ptr, struct LDKRoutingFees val); /** - * Constructs a new Utxo given each field + * The difference in CLTV values between this node and the next node. */ -MUST_USE_RES struct LDKUtxo Utxo_new(struct LDKOutPoint outpoint_arg, struct LDKTxOut output_arg, uint64_t satisfaction_weight_arg); +uint16_t RouteHintHop_get_cltv_expiry_delta(const struct LDKRouteHintHop *NONNULL_PTR this_ptr); /** - * Creates a copy of the Utxo + * The difference in CLTV values between this node and the next node. */ -struct LDKUtxo Utxo_clone(const struct LDKUtxo *NONNULL_PTR orig); +void RouteHintHop_set_cltv_expiry_delta(struct LDKRouteHintHop *NONNULL_PTR this_ptr, uint16_t val); /** - * Generates a non-cryptographic 64-bit hash of the Utxo. + * The minimum value, in msat, which must be relayed to the next hop. */ -uint64_t Utxo_hash(const struct LDKUtxo *NONNULL_PTR o); +struct LDKCOption_u64Z RouteHintHop_get_htlc_minimum_msat(const struct LDKRouteHintHop *NONNULL_PTR this_ptr); /** - * 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. + * The minimum value, in msat, which must be relayed to the next hop. */ -bool Utxo_eq(const struct LDKUtxo *NONNULL_PTR a, const struct LDKUtxo *NONNULL_PTR b); +void RouteHintHop_set_htlc_minimum_msat(struct LDKRouteHintHop *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); /** - * Returns a `Utxo` with the `satisfaction_weight` estimate for a legacy P2PKH output. + * The maximum value in msat available for routing with a single HTLC. */ -MUST_USE_RES struct LDKUtxo Utxo_new_p2pkh(struct LDKOutPoint outpoint, uint64_t value, const uint8_t (*pubkey_hash)[20]); +struct LDKCOption_u64Z RouteHintHop_get_htlc_maximum_msat(const struct LDKRouteHintHop *NONNULL_PTR this_ptr); /** - * Frees any resources used by the CoinSelection, if is_owned is set and inner is non-NULL. + * The maximum value in msat available for routing with a single HTLC. */ -void CoinSelection_free(struct LDKCoinSelection this_obj); +void RouteHintHop_set_htlc_maximum_msat(struct LDKRouteHintHop *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); /** - * The set of UTXOs (with at least 1 confirmation) to spend and use within a transaction - * requiring additional fees. + * Constructs a new RouteHintHop given each field */ -struct LDKCVec_UtxoZ CoinSelection_get_confirmed_utxos(const struct LDKCoinSelection *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 set of UTXOs (with at least 1 confirmation) to spend and use within a transaction - * requiring additional fees. + * Creates a copy of the RouteHintHop */ -void CoinSelection_set_confirmed_utxos(struct LDKCoinSelection *NONNULL_PTR this_ptr, struct LDKCVec_UtxoZ val); +struct LDKRouteHintHop RouteHintHop_clone(const struct LDKRouteHintHop *NONNULL_PTR orig); /** - * 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. + * Generates a non-cryptographic 64-bit hash of the RouteHintHop. */ -struct LDKCOption_TxOutZ CoinSelection_get_change_output(const struct LDKCoinSelection *NONNULL_PTR this_ptr); +uint64_t RouteHintHop_hash(const struct LDKRouteHintHop *NONNULL_PTR o); /** - * 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. + * 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. */ -void CoinSelection_set_change_output(struct LDKCoinSelection *NONNULL_PTR this_ptr, struct LDKCOption_TxOutZ val); +bool RouteHintHop_eq(const struct LDKRouteHintHop *NONNULL_PTR a, const struct LDKRouteHintHop *NONNULL_PTR b); /** - * Constructs a new CoinSelection given each field + * Frees any resources used by the UntrustedString, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKCoinSelection CoinSelection_new(struct LDKCVec_UtxoZ confirmed_utxos_arg, struct LDKCOption_TxOutZ change_output_arg); +void UntrustedString_free(struct LDKUntrustedString this_obj); -/** - * Creates a copy of the CoinSelection - */ -struct LDKCoinSelection CoinSelection_clone(const struct LDKCoinSelection *NONNULL_PTR orig); +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); /** - * Calls the free function if one is set + * Constructs a new UntrustedString given each field */ -void CoinSelectionSource_free(struct LDKCoinSelectionSource this_ptr); +MUST_USE_RES struct LDKUntrustedString UntrustedString_new(struct LDKStr a_arg); /** - * Calls the free function if one is set + * Creates a copy of the UntrustedString */ -void WalletSource_free(struct LDKWalletSource this_ptr); +struct LDKUntrustedString UntrustedString_clone(const struct LDKUntrustedString *NONNULL_PTR orig); /** - * Frees any resources used by the Wallet, if is_owned is set and inner is non-NULL. + * 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. */ -void Wallet_free(struct LDKWallet this_obj); +bool UntrustedString_eq(const struct LDKUntrustedString *NONNULL_PTR a, const struct LDKUntrustedString *NONNULL_PTR b); /** - * Returns a new instance backed by the given [`WalletSource`] that serves as an implementation - * of [`CoinSelectionSource`]. + * Generates a non-cryptographic 64-bit hash of the UntrustedString. */ -MUST_USE_RES struct LDKWallet Wallet_new(struct LDKWalletSource source, struct LDKLogger logger); +uint64_t UntrustedString_hash(const struct LDKUntrustedString *NONNULL_PTR o); /** - * 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 + * Get the string representation of a UntrustedString object */ -struct LDKCoinSelectionSource Wallet_as_CoinSelectionSource(const struct LDKWallet *NONNULL_PTR this_arg); +struct LDKStr UntrustedString_to_str(const struct LDKUntrustedString *NONNULL_PTR o); /** - * Frees any resources used by the BumpTransactionEventHandler, if is_owned is set and inner is non-NULL. + * Frees any resources used by the PrintableString, if is_owned is set and inner is non-NULL. */ -void BumpTransactionEventHandler_free(struct LDKBumpTransactionEventHandler this_obj); +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); /** - * Returns a new instance capable of handling [`Event::BumpTransaction`] events. - * - * [`Event::BumpTransaction`]: crate::events::Event::BumpTransaction + * Constructs a new PrintableString given each field */ -MUST_USE_RES struct LDKBumpTransactionEventHandler BumpTransactionEventHandler_new(struct LDKBroadcasterInterface broadcaster, struct LDKCoinSelectionSource utxo_source, struct LDKSignerProvider signer_provider, struct LDKLogger logger); +MUST_USE_RES struct LDKPrintableString PrintableString_new(struct LDKStr a_arg); /** - * Handles all variants of [`BumpTransactionEvent`]. + * Get the string representation of a PrintableString object */ -void BumpTransactionEventHandler_handle_event(const struct LDKBumpTransactionEventHandler *NONNULL_PTR this_arg, const struct LDKBumpTransactionEvent *NONNULL_PTR event); +struct LDKStr PrintableString_to_str(const struct LDKPrintableString *NONNULL_PTR o); /** * Frees any resources used by the FilesystemStore, if is_owned is set and inner is non-NULL. @@ -56562,7 +60208,7 @@ struct LDKGossipSync GossipSync_none(void); * [`NetworkGraph`]: lightning::routing::gossip::NetworkGraph * [`NetworkGraph::write`]: lightning::routing::gossip::NetworkGraph#impl-Writeable */ -MUST_USE_RES struct LDKBackgroundProcessor BackgroundProcessor_start(struct LDKPersister persister, struct LDKEventHandler event_handler, const struct LDKChainMonitor *NONNULL_PTR chain_monitor, const struct LDKChannelManager *NONNULL_PTR channel_manager, struct LDKGossipSync gossip_sync, const struct LDKPeerManager *NONNULL_PTR peer_manager, struct LDKLogger logger, struct LDKCOption_WriteableScoreZ scorer); +MUST_USE_RES struct LDKBackgroundProcessor BackgroundProcessor_start(struct LDKPersister persister, struct LDKEventHandler event_handler, const struct LDKChainMonitor *NONNULL_PTR chain_monitor, const struct LDKChannelManager *NONNULL_PTR channel_manager, const struct LDKOnionMessenger *NONNULL_PTR onion_messenger, struct LDKGossipSync gossip_sync, const struct LDKPeerManager *NONNULL_PTR peer_manager, struct LDKLogger logger, struct LDKCOption_WriteableScoreZ scorer); /** * Join `BackgroundProcessor`'s thread, returning any error that occurred while persisting @@ -57110,6 +60756,15 @@ bool Fallback_eq(const struct LDKFallback *NONNULL_PTR a, const struct LDKFallba */ void Bolt11InvoiceSignature_free(struct LDKBolt11InvoiceSignature this_obj); +struct LDKRecoverableSignature Bolt11InvoiceSignature_get_a(const struct LDKBolt11InvoiceSignature *NONNULL_PTR this_ptr); + +void Bolt11InvoiceSignature_set_a(struct LDKBolt11InvoiceSignature *NONNULL_PTR this_ptr, struct LDKRecoverableSignature val); + +/** + * Constructs a new Bolt11InvoiceSignature given each field + */ +MUST_USE_RES struct LDKBolt11InvoiceSignature Bolt11InvoiceSignature_new(struct LDKRecoverableSignature a_arg); + /** * Creates a copy of the Bolt11InvoiceSignature */ @@ -57439,8 +61094,8 @@ MUST_USE_RES enum LDKCurrency Bolt11Invoice_currency(const struct LDKBolt11Invoi 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, - * returns [`CreationError::DescriptionTooLong`] otherwise + * Creates a new `Description` if `description` is at most 1023 * 5 bits (i.e., 639 bytes) + * long, and returns [`CreationError::DescriptionTooLong`] otherwise. * * Please note that single characters may use more than one byte due to UTF8 encoding. */ @@ -57451,6 +61106,11 @@ MUST_USE_RES struct LDKCResult_DescriptionCreationErrorZ Description_new(struct */ MUST_USE_RES struct LDKUntrustedString Description_into_inner(struct LDKDescription this_arg); +/** + * Get a reference to the underlying description [`UntrustedString`] + */ +MUST_USE_RES struct LDKUntrustedString Description_as_inner(const struct LDKDescription *NONNULL_PTR this_arg); + /** * Get the string representation of a Description object */ @@ -57629,184 +61289,6 @@ bool SignOrCreationError_eq(const struct LDKSignOrCreationError *NONNULL_PTR a, */ struct LDKStr SignOrCreationError_to_str(const struct LDKSignOrCreationError *NONNULL_PTR o); -/** - * Builds the necessary parameters to pay or pre-flight probe the given zero-amount - * [`Bolt11Invoice`] using [`ChannelManager::send_payment`] or - * [`ChannelManager::send_preflight_probes`]. - * - * Prior to paying, you must ensure that the [`Bolt11Invoice::payment_hash`] is unique and the - * same [`PaymentHash`] has never been paid before. - * - * Will always succeed unless the invoice has an amount specified, in which case - * [`payment_parameters_from_invoice`] should be used. - * - * [`ChannelManager::send_payment`]: lightning::ln::channelmanager::ChannelManager::send_payment - * [`ChannelManager::send_preflight_probes`]: lightning::ln::channelmanager::ChannelManager::send_preflight_probes - */ -struct LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ payment_parameters_from_zero_amount_invoice(const struct LDKBolt11Invoice *NONNULL_PTR invoice, uint64_t amount_msat); - -/** - * Builds the necessary parameters to pay or pre-flight probe the given [`Bolt11Invoice`] using - * [`ChannelManager::send_payment`] or [`ChannelManager::send_preflight_probes`]. - * - * Prior to paying, you must ensure that the [`Bolt11Invoice::payment_hash`] is unique and the - * same [`PaymentHash`] has never been paid before. - * - * Will always succeed unless the invoice has no amount specified, in which case - * [`payment_parameters_from_zero_amount_invoice`] should be used. - * - * [`ChannelManager::send_payment`]: lightning::ln::channelmanager::ChannelManager::send_payment - * [`ChannelManager::send_preflight_probes`]: lightning::ln::channelmanager::ChannelManager::send_preflight_probes - */ -struct LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ payment_parameters_from_invoice(const struct LDKBolt11Invoice *NONNULL_PTR invoice); - -/** - * 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. - * - * `phantom_route_hints` parameter: - * * Contains channel info for all nodes participating in the phantom invoice - * * Entries are retrieved from a call to [`ChannelManager::get_phantom_route_hints`] on each - * 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 - * - * `payment_hash` can be specified if you have a specific need for a custom payment hash (see the difference - * between [`ChannelManager::create_inbound_payment`] and [`ChannelManager::create_inbound_payment_for_hash`]). - * If `None` is provided for `payment_hash`, then one will be created. - * - * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for - * in excess of the current time. - * - * `duration_since_epoch` is the current time since epoch in seconds. - * - * You can specify a custom `min_final_cltv_expiry_delta`, or let LDK default it to - * [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. The provided expiry must be at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`] - 3. - * Note that LDK will add a buffer of 3 blocks to the delta to allow for up to a few new block - * confirmations during routing. - * - * Note that the provided `keys_manager`'s `NodeSigner` implementation must support phantom - * invoices in its `sign_invoice` implementation ([`PhantomKeysManager`] satisfies this - * requirement). - * - * [`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 - * [`PhantomRouteHints::channels`]: lightning::ln::channelmanager::PhantomRouteHints::channels - * [`MIN_FINAL_CLTV_EXPIRY_DETLA`]: lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA - * - * 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. - */ -struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ create_phantom_invoice(struct LDKCOption_u64Z amt_msat, struct LDKCOption_ThirtyTwoBytesZ 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.\" - * See [`PhantomKeysManager`] for more information on phantom node payments. - * - * `phantom_route_hints` parameter: - * * Contains channel info for all nodes participating in the phantom invoice - * * Entries are retrieved from a call to [`ChannelManager::get_phantom_route_hints`] on each - * 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 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 - * - * `payment_hash` can be specified if you have a specific need for a custom payment hash (see the difference - * between [`ChannelManager::create_inbound_payment`] and [`ChannelManager::create_inbound_payment_for_hash`]). - * If `None` is provided for `payment_hash`, then one will be created. - * - * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for - * in excess of the current time. - * - * `duration_since_epoch` is the current time since epoch in seconds. - * - * Note that the provided `keys_manager`'s `NodeSigner` implementation must support phantom - * invoices in its `sign_invoice` implementation ([`PhantomKeysManager`] satisfies this - * requirement). - * - * [`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 - * [`PhantomRouteHints::channels`]: lightning::ln::channelmanager::PhantomRouteHints::channels - * - * 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. - */ -struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ create_phantom_invoice_with_description_hash(struct LDKCOption_u64Z amt_msat, struct LDKCOption_ThirtyTwoBytesZ 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 - * cltv_expiry, this is what you should be using to create an invoice. The reason being, this - * method stores the invoice's payment secret and preimage in `ChannelManager`, so (a) the user - * doesn't have to store preimage/payment secret information and (b) `ChannelManager` can verify - * that the payment secret is valid when the invoice is paid. - * - * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for - * in excess of the current time. - * - * You can specify a custom `min_final_cltv_expiry_delta`, or let LDK default it to - * [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. The provided expiry must be at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. - * Note that LDK will add a buffer of 3 blocks to the delta to allow for up to a few new block - * confirmations during routing. - * - * [`MIN_FINAL_CLTV_EXPIRY_DETLA`]: lightning::ln::channelmanager::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 - * cltv_expiry, this is what you should be using to create an invoice. The reason being, this - * method stores the invoice's payment secret and preimage in `ChannelManager`, so (a) the user - * doesn't have to store preimage/payment secret information and (b) `ChannelManager` can verify - * that the payment secret is valid when the invoice is paid. - * Use this variant if you want to pass the `description_hash` to the invoice. - * - * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for - * in excess of the current time. - * - * You can specify a custom `min_final_cltv_expiry_delta`, or let LDK default it to - * [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. The provided expiry must be at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. - * Note that LDK will add a buffer of 3 blocks to the delta to allow for up to a few new block - * confirmations during routing. - * - * [`MIN_FINAL_CLTV_EXPIRY_DETLA`]: lightning::ln::channelmanager::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_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_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`] - * This version allows for providing a custom [`PaymentHash`] for the invoice. - * 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_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 */ diff --git a/lightning-c-bindings/include/lightningpp.hpp b/lightning-c-bindings/include/lightningpp.hpp index 0f40b39..0f8d1d7 100644 --- a/lightning-c-bindings/include/lightningpp.hpp +++ b/lightning-c-bindings/include/lightningpp.hpp @@ -7,6 +7,7 @@ class Refund; class Retry; class RetryableSendFailure; class PaymentSendFailure; +class Bolt12PaymentError; class ProbeSendFailure; class RecipientOnionFields; class InvoiceWithExplicitSigningPubkeyBuilder; @@ -14,7 +15,6 @@ class InvoiceWithDerivedSigningPubkeyBuilder; class UnsignedBolt12Invoice; class SignBolt12InvoiceFn; class Bolt12Invoice; -class BlindedPayInfo; class DelayedPaymentOutputDescriptor; class StaticPaymentOutputDescriptor; class SpendableOutputDescriptor; @@ -44,14 +44,14 @@ class Route; class RouteParameters; class PaymentParameters; class Payee; -class RouteHint; -class RouteHintHop; class FirstHopCandidate; class PublicHopCandidate; class PrivateHopCandidate; class BlindedPathCandidate; class OneHopBlindedPathCandidate; class CandidateRouteHop; +class UntrustedString; +class PrintableString; class ScoreLookUp; class ScoreUpdate; class Score; @@ -72,15 +72,6 @@ class ChannelMonitorUpdateStatus; class Watch; class Filter; class WatchedOutput; -class InitFeatures; -class NodeFeatures; -class ChannelFeatures; -class Bolt11InvoiceFeatures; -class OfferFeatures; -class InvoiceRequestFeatures; -class Bolt12InvoiceFeatures; -class BlindedHopFeatures; -class ChannelTypeFeatures; class OfferId; class OfferWithExplicitMetadataBuilder; class OfferWithDerivedMetadataBuilder; @@ -96,7 +87,7 @@ class ChannelUpdateInfo; class ChannelInfo; class DirectedChannelInfo; class EffectiveCapacity; -class RoutingFees; +class NodeAnnouncementDetails; class NodeAnnouncementInfo; class NodeAlias; class NodeInfo; @@ -131,10 +122,10 @@ class APIError; class TaggedHash; class SignError; class EcdsaChannelSigner; -class WriteableEcdsaChannelSigner; class ChannelMonitorUpdate; class MonitorEvent; class HTLCUpdate; +class BalanceSource; class Balance; class ChannelMonitor; class ExpandedKey; @@ -165,6 +156,7 @@ class WarningMessage; class Ping; class Pong; class CommonOpenChannelFields; +class ChannelParameters; class OpenChannel; class OpenChannelV2; class CommonAcceptChannelFields; @@ -174,7 +166,7 @@ class FundingCreated; class FundingSigned; class ChannelReady; class Stfu; -class Splice; +class SpliceInit; class SpliceAck; class SpliceLocked; class TxAddInput; @@ -194,6 +186,7 @@ class OnionMessage; class UpdateFulfillHTLC; class UpdateFailHTLC; class UpdateFailMalformedHTLC; +class CommitmentSignedBatch; class CommitmentSigned; class RevokeAndACK; class UpdateFee; @@ -236,6 +229,10 @@ class ChannelShutdownState; class FutureCallback; class Future; class Sleeper; +class AsyncPaymentsMessageHandler; +class AsyncPaymentsMessage; +class HeldHtlcAvailable; +class ReleaseHeldHtlc; class OffersMessageHandler; class OffersMessage; class HTLCClaim; @@ -262,6 +259,7 @@ class FeeEstimator; class Packet; class ParsedOnionMessageContents; class OnionMessageContents; +class FundingInfo; class PaymentPurpose; class ClaimedHTLC; class PathFailure; @@ -272,7 +270,12 @@ class Event; class MessageSendEvent; class MessageSendEventsProvider; class EventsProvider; +class ReplayEvent; class EventHandler; +class Nonce; +class RoutingFees; +class RouteHint; +class RouteHintHop; class Bolt11ParseError; class ParseOrSemanticError; class Bolt11Invoice; @@ -297,12 +300,12 @@ class OutPoint; class BigSize; class Hostname; class TransactionU16LenLimited; -class UntrustedString; -class PrintableString; class ChannelId; class CustomMessageReader; class Type; -class ForwardNode; +class BlindedPayInfo; +class BlindedPaymentPath; +class PaymentForwardNode; class ForwardTlvs; class ReceiveTlvs; class PaymentRelay; @@ -316,6 +319,9 @@ class UtxoResult; class UtxoLookup; class UtxoFuture; class OnionMessenger; +class Responder; +class ResponseInstruction; +class MessageSendInstructions; class MessageRouter; class DefaultMessageRouter; class OnionMessagePath; @@ -325,8 +331,15 @@ class SendError; class CustomOnionMessageHandler; class PeeledOnion; class FilesystemStore; -class NextMessageHop; -class BlindedPath; +class InitFeatures; +class NodeFeatures; +class ChannelFeatures; +class Bolt11InvoiceFeatures; +class OfferFeatures; +class InvoiceRequestFeatures; +class Bolt12InvoiceFeatures; +class BlindedHopFeatures; +class ChannelTypeFeatures; class IntroductionNode; class Direction; class NodeIdLookUp; @@ -344,15 +357,18 @@ class HtlcBasepoint; class HtlcKey; class RevocationBasepoint; class RevocationKey; -class MonitorUpdateId; class Persist; class LockedChannelMonitor; class ChainMonitor; +class BlindedMessagePath; +class NextMessageHop; +class MessageForwardNode; +class MessageContext; +class OffersContext; class CResult_HtlcKeyDecodeErrorZ; class CResult_TransactionU16LenLimitedNoneZ; class CVec_TrackedSpendableOutputZ; class CResult_LockedChannelMonitorNoneZ; -class CVec_C2Tuple_BlindedPayInfoBlindedPathZZ; class CResult_PhantomRouteHintsDecodeErrorZ; class CResult_FundingCreatedDecodeErrorZ; class CVec_C2Tuple_u32TxOutZZ; @@ -361,12 +377,13 @@ class CResult_BlindedForwardDecodeErrorZ; class CResult_ChannelInfoDecodeErrorZ; class COption_PaymentContextZ; class COption_MaxDustHTLCExposureZ; -class COption_OffersMessageZ; +class CResult_NoneSendErrorZ; class CResult_CVec_u8ZPeerHandleErrorZ; +class CResult_OnionPacketDecodeErrorZ; class COption_NetworkUpdateZ; class COption_u64Z; -class CResult_OnionPacketDecodeErrorZ; class CResult_GossipTimestampFilterDecodeErrorZ; +class C2Tuple_OnionMessageContentsResponseInstructionZ; class CResult_RouteHintDecodeErrorZ; class COption_FilterZ; class C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ; @@ -378,11 +395,13 @@ class CResult_StaticPaymentOutputDescriptorDecodeErrorZ; class COption_u32Z; class CResult_RecipientOnionFieldsNoneZ; class C2Tuple__u1632_u1632Z; +class CVec_C2Tuple_OffersMessageMessageSendInstructionsZZ; +class C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ; +class CResult_TransactionNoneZ; class CResult_CVec_StrZIOErrorZ; +class CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ; class COption_ECDSASignatureZ; -class CResult_TransactionNoneZ; class CResult_ClosingSignedFeeRangeDecodeErrorZ; -class CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ; class CResult_CommitmentSignedDecodeErrorZ; class CResult_CommitmentTransactionDecodeErrorZ; class CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ; @@ -412,69 +431,63 @@ class CResult_COption_NetworkUpdateZDecodeErrorZ; class CVec_UpdateFailMalformedHTLCZ; class CResult_ShutdownScriptNoneZ; class CResult_PendingHTLCInfoInboundHTLCErrZ; +class CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ; class CResult_PendingHTLCInfoDecodeErrorZ; +class CResult_SpliceInitDecodeErrorZ; class CResult_HTLCOutputInCommitmentDecodeErrorZ; -class CResult_ShutdownScriptInvalidShutdownScriptZ; -class COption_HTLCDestinationZ; class CVec_RouteHopZ; -class C2Tuple_PublicKeyCVec_SocketAddressZZ; +class CResult_ShutdownScriptInvalidShutdownScriptZ; class CResult_CVec_UtxoZNoneZ; class CResult_CVec_u8ZIOErrorZ; -class CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ; +class COption_HTLCDestinationZ; class CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ; -class CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ; -class C3Tuple_OffersMessageDestinationBlindedPathZ; class CVec_ThirtyTwoBytesZ; class CResult_ChannelMonitorUpdateStatusNoneZ; class CResult_ClosingSignedDecodeErrorZ; class CVec_CResult_NoneAPIErrorZZ; class CResult_SchnorrSignatureNoneZ; +class C2Tuple_ReleaseHeldHtlcResponseInstructionZ; class CResult_CounterpartyCommitmentSecretsDecodeErrorZ; class CResult_HTLCDescriptorDecodeErrorZ; class CVec_RecentPaymentDetailsZ; class CVec_RouteHintHopZ; -class CVec_C3Tuple_OffersMessageDestinationBlindedPathZZ; class CResult_UntrustedStringDecodeErrorZ; class CVec_C3Tuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZZ; -class CVec_U5Z; class CResult_PaymentParametersDecodeErrorZ; +class CResult_DelayedPaymentBasepointDecodeErrorZ; class C2Tuple_ThirtyTwoBytesChannelMonitorZ; class COption_U128Z; -class CResult_DelayedPaymentBasepointDecodeErrorZ; class C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ; +class CVec_MessageForwardNodeZ; class CResult_TxAckRbfDecodeErrorZ; class CResult_Bolt11InvoiceBolt11SemanticErrorZ; class COption_UtxoLookupZ; +class CResult__u832NoneZ; class CResult_PongDecodeErrorZ; class CResult_UnsignedChannelAnnouncementDecodeErrorZ; -class C2Tuple_OutPointCVec_MonitorUpdateIdZZ; class CResult_ChannelIdAPIErrorZ; class CResult_CVec_u8ZNoneZ; class CVec_C2Tuple_ChannelIdPublicKeyZZ; class C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ; class CResult_ChannelTransactionParametersDecodeErrorZ; -class CResult_WriteableEcdsaChannelSignerDecodeErrorZ; class CResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ; class CResult_DelayedPaymentOutputDescriptorDecodeErrorZ; class CResult_InFlightHtlcsDecodeErrorZ; +class CResult_CommitmentSignedBatchDecodeErrorZ; class CResult_COption_HTLCDestinationZDecodeErrorZ; class CResult_Bolt12OfferContextDecodeErrorZ; class CResult_ThirtyTwoBytesNoneZ; -class C3Tuple_OnionMessageContentsDestinationBlindedPathZ; class C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ; class CResult_SendSuccessSendErrorZ; -class CVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ; +class CResult_NoneReplayEventZ; class C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ; class CResult_BlindedHopDecodeErrorZ; class CResult_NoneLightningErrorZ; class CResult_FixedPenaltyScorerDecodeErrorZ; -class CVec_BlindedPathZ; class CResult_NonePeerHandleErrorZ; -class CResult_FinalOnionHopDataDecodeErrorZ; class CResult_TrustedCommitmentTransactionNoneZ; +class CResult_FinalOnionHopDataDecodeErrorZ; class CResult_COption_EventZDecodeErrorZ; -class CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ; -class CResult_PaymentFailureReasonDecodeErrorZ; class COption_SocketAddressZ; class CResult_COption_MonitorEventZDecodeErrorZ; class COption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ; @@ -490,10 +503,12 @@ class COption_OutboundHTLCStateDetailsZ; class COption_MonitorEventZ; class COption_TypeZ; class CResult_COption_TypeZDecodeErrorZ; +class CResult_OfferDecodeErrorZ; class CResult_COption_PathFailureZDecodeErrorZ; class CResult_Bolt11InvoiceSignOrCreationErrorZ; +class CResult_BlindedMessagePathNoneZ; class CResult_UpdateFailHTLCDecodeErrorZ; -class CResult_CVec_BlindedPathZNoneZ; +class CResult_BlindedPaymentPathNoneZ; class CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ; class CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZ; class CResult_SpendableOutputDescriptorDecodeErrorZ; @@ -501,18 +516,24 @@ class CResult_RevokeAndACKDecodeErrorZ; class CResult_UnsignedChannelUpdateDecodeErrorZ; class CResult_PayeePubKeySecp256k1ErrorZ; class C2Tuple__u832u16Z; +class CResult_BlindedMessagePathDecodeErrorZ; +class CResult_CVec_BlindedMessagePathZNoneZ; class COption_BigEndianScalarZ; class CVec_ChannelIdZ; class CResult_PublicKeySecp256k1ErrorZ; -class CResult_CVec_ECDSASignatureZNoneZ; +class C2Tuple_OnionMessageContentsMessageSendInstructionsZ; class CVec_BlindedHopZ; +class CResult_ReleaseHeldHtlcDecodeErrorZ; +class CResult_CVec_ECDSASignatureZNoneZ; class CResult_COption_ClosureReasonZDecodeErrorZ; -class CResult_InvoiceErrorDecodeErrorZ; -class C2Tuple_BestBlockOutputSweeperZ; class C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ; +class CResult_NonceDecodeErrorZ; class CResult_RouteParametersDecodeErrorZ; class CResult_PrivateRouteCreationErrorZ; +class CResult_InvoiceErrorDecodeErrorZ; class CResult_NodeAliasDecodeErrorZ; +class C2Tuple_BestBlockOutputSweeperZ; +class C2Tuple_OutPointCVec_u64ZZ; class CVec_UpdateFulfillHTLCZ; class CVec_C2Tuple_u32CVec_u8ZZZ; class C3Tuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZ; @@ -525,7 +546,7 @@ class CResult_TxSignaturesDecodeErrorZ; class CVec_HTLCDescriptorZ; class CResult_ReplyShortChannelIdsEndDecodeErrorZ; class COption_PathFailureZ; -class CResult_StrSecp256k1ErrorZ; +class COption_MessageContextZ; class CVec_ECDSASignatureZ; class CResult_ChannelUpdateInfoDecodeErrorZ; class CVec_UpdateFailHTLCZ; @@ -533,23 +554,26 @@ class CVec_TxOutZ; class CVec_InboundHTLCDetailsZ; class CVec_OutboundHTLCDetailsZ; class CResult_BuiltCommitmentTransactionDecodeErrorZ; +class CVec_PaymentForwardNodeZ; class CResult_TrackedSpendableOutputDecodeErrorZ; class CVec_SpendableOutputDescriptorZ; +class CResult_ResponderDecodeErrorZ; class C2Tuple_OutPointCVec_u8ZZ; class CResult_WitnessNoneZ; class COption_C2Tuple_u64u64ZZ; class CResult_ChannelAnnouncementDecodeErrorZ; class CResult_HTLCUpdateDecodeErrorZ; class CResult_TxAddInputDecodeErrorZ; -class CResult_PeeledOnionNoneZ; +class CResult_HeldHtlcAvailableDecodeErrorZ; class CResult_TxInitRbfDecodeErrorZ; class COption_WriteableScoreZ; class CVec_StrZ; +class CResult_AsyncPaymentsMessageDecodeErrorZ; class CResult_SpliceAckDecodeErrorZ; class CResult_PositiveTimestampCreationErrorZ; +class CResult_PeeledOnionNoneZ; class CVec_C2Tuple_OutPointChannelIdZZ; class CResult_ChannelMonitorUpdateDecodeErrorZ; -class C2Tuple_BlindedPayInfoBlindedPathZ; class CResult_ReplyChannelRangeDecodeErrorZ; class CResult_UnsignedNodeAnnouncementDecodeErrorZ; class CResult_TrustedClosingTransactionNoneZ; @@ -559,32 +583,34 @@ class CResult_TxRemoveOutputDecodeErrorZ; class CResult_ChannelReestablishDecodeErrorZ; class CResult_OnionMessageDecodeErrorZ; class CResult_Bolt11InvoiceParseOrSemanticErrorZ; +class CResult_MessageContextDecodeErrorZ; class CResult_InitFeaturesDecodeErrorZ; class CResult_PublicKeyNoneZ; class CResult_PingDecodeErrorZ; class CResult_RevocationKeyDecodeErrorZ; -class CResult_ChannelIdDecodeErrorZ; +class C2Tuple_OffersMessageMessageSendInstructionsZ; class CResult_BlindedHopFeaturesDecodeErrorZ; +class CResult_ChannelIdDecodeErrorZ; class CVec_TransactionOutputsZ; class COption_HTLCClaimZ; class COption_boolZ; -class COption_StrZ; +class CVec_BlindedPaymentPathZ; class CResult_ProbabilisticScorerDecodeErrorZ; -class CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ; -class CResult_ShutdownScriptDecodeErrorZ; -class CResult_SiPrefixBolt11ParseErrorZ; +class COption_StrZ; +class CResult_CVec_BlindedPaymentPathZNoneZ; +class COption_C2Tuple_OffersMessageResponseInstructionZZ; class C2Tuple_usizeTransactionZ; +class COption_OffersContextZ; class CResult_NodeAnnouncementDecodeErrorZ; -class CVec_FutureZ; class CVec_ChannelMonitorZ; -class CVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ; class CResult_AcceptChannelV2DecodeErrorZ; +class CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ; class CResult_RouteHopDecodeErrorZ; class CResult_OfferIdDecodeErrorZ; class CVec_HTLCOutputInCommitmentZ; class CResult_CoinSelectionNoneZ; +class CVec_FutureZ; class CResult_TxCreationKeysDecodeErrorZ; -class CResult_BlindedPathDecodeErrorZ; class CResult_RefundBolt12SemanticErrorZ; class CResult_NoneIOErrorZ; class CResult_MaxDustHTLCExposureDecodeErrorZ; @@ -594,7 +620,9 @@ class CResult_FundingSignedDecodeErrorZ; class CResult_RecoverableSignatureNoneZ; class CResult_SocketAddressDecodeErrorZ; class C2Tuple_Z; +class CResult_ShutdownScriptDecodeErrorZ; class CResult_InboundHTLCDetailsDecodeErrorZ; +class CResult_SiPrefixBolt11ParseErrorZ; class C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ; class CVec_PathZ; class CResult_NetworkGraphDecodeErrorZ; @@ -613,20 +641,18 @@ class CResult_ThirtyTwoBytesPaymentSendFailureZ; class CResult_WarningMessageDecodeErrorZ; class CResult_ChannelCounterpartyDecodeErrorZ; class CResult_HolderCommitmentTransactionDecodeErrorZ; -class CVec_ForwardNodeZ; class CResult_DelayedPaymentKeyDecodeErrorZ; -class CResult_InitDecodeErrorZ; +class C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ; class CResult_OfferBolt12SemanticErrorZ; class CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ; -class CResult_SpliceDecodeErrorZ; +class CResult_InitDecodeErrorZ; class CResult_PaymentPurposeDecodeErrorZ; class CResult_ClaimedHTLCDecodeErrorZ; class CResult_OutPointDecodeErrorZ; class CVec_ChannelDetailsZ; -class C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ; class CResult_Bolt11InvoiceFeaturesDecodeErrorZ; class CVec_MessageSendEventZ; -class CVec_MonitorUpdateIdZ; +class CVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ; class CResult_RouteHintHopDecodeErrorZ; class CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ; class CResult_UpdateFailMalformedHTLCDecodeErrorZ; @@ -636,16 +662,16 @@ class COption_ChannelShutdownStateZ; class CResult_Bolt12InvoiceBolt12SemanticErrorZ; class CResult_InvoiceRequestFieldsDecodeErrorZ; class CResult_AcceptChannelDecodeErrorZ; +class CResult_RefundDecodeErrorZ; class CResult_HostnameDecodeErrorZ; class C2Tuple_u64u16Z; class COption_ThirtyTwoBytesZ; class CVec_u64Z; class CResult_NoneBolt12SemanticErrorZ; -class COption_SecretKeyZ; -class COption_InboundHTLCStateDetailsZ; class CResult_UnknownPaymentContextDecodeErrorZ; -class CResult_C2Tuple_CVec_u8Zu64ZNoneZ; +class COption_InboundHTLCStateDetailsZ; class CResult_OutputSweeperDecodeErrorZ; +class CResult_C2Tuple_CVec_u8Zu64ZNoneZ; class COption_EventZ; class CResult_ChannelTypeFeaturesDecodeErrorZ; class COption_CVec_SocketAddressZZ; @@ -654,16 +680,17 @@ class COption_u16Z; class COption_PaymentFailureReasonZ; class CResult_Bolt12RefundContextDecodeErrorZ; class CResult_ECDSASignatureNoneZ; -class CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ; class C2Tuple_ChannelIdPublicKeyZ; -class CVec_WitnessZ; +class C2Tuple_OffersMessageResponseInstructionZ; +class CResult_EcdsaChannelSignerDecodeErrorZ; class CResult_BlindedTailDecodeErrorZ; -class CResult_SocketAddressSocketAddressParseErrorZ; +class CVec_WitnessZ; class COption_C2Tuple_u64u16ZZ; -class CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ; +class CResult_SocketAddressSocketAddressParseErrorZ; +class CResult_COption_PaymentFailureReasonZDecodeErrorZ; class CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ; class CResult_ChannelDerivationParametersDecodeErrorZ; -class CResult_PaymentConstraintsDecodeErrorZ; +class CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ; class CResult_UnsignedInvoiceRequestBolt12SemanticErrorZ; class CResult_OnionMessagePathNoneZ; class C2Tuple_u32CVec_u8ZZ; @@ -672,8 +699,8 @@ class CResult_OutboundHTLCDetailsDecodeErrorZ; class CResult_RefundBolt12ParseErrorZ; class CResult_u32GraphSyncErrorZ; class CVec_C2Tuple_u64CVec_u8ZZZ; -class CVec_PhantomRouteHintsZ; class CResult_OffersMessageDecodeErrorZ; +class CResult_PaymentConstraintsDecodeErrorZ; class CResult_NoneAPIErrorZ; class CResult_Bolt12InvoiceFeaturesDecodeErrorZ; class COption_f64Z; @@ -682,19 +709,24 @@ class CVec_PublicKeyZ; class C2Tuple_CVec_u8Zu64Z; class CVec_C2Tuple_usizeTransactionZZ; class CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZ; -class CResult_PendingHTLCRoutingDecodeErrorZ; +class CResult_Bolt12InvoiceDecodeErrorZ; class C2Tuple_u64u64Z; -class CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ; -class CResult_ChannelDetailsDecodeErrorZ; -class CResult_CounterpartyChannelTransactionParametersDecodeErrorZ; +class COption_NodeAnnouncementInfoZ; +class CResult_PendingHTLCRoutingDecodeErrorZ; +class COption_C2Tuple_OnionMessageContentsResponseInstructionZZ; class CResult_RecipientOnionFieldsDecodeErrorZ; class C2Tuple_u32TxOutZ; class CResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ; -class CResult_PaymentContextDecodeErrorZ; +class CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ; +class CResult_ChannelDetailsDecodeErrorZ; class CVec_UtxoZ; +class CResult_CounterpartyChannelTransactionParametersDecodeErrorZ; class CResult_ChannelConfigDecodeErrorZ; class CVec_PrivateRouteZ; class COption_i64Z; +class CResult_PaymentContextDecodeErrorZ; +class CVec_PhantomRouteHintsZ; +class CVec_C2Tuple_OutPointCVec_u64ZZZ; class C2Tuple_ThirtyTwoBytesChannelManagerZ; class CResult_COption_OnionMessageContentsZDecodeErrorZ; class C2Tuple_u64CVec_u8ZZ; @@ -704,17 +736,21 @@ class CVec_MonitorEventZ; class CResult_ShutdownDecodeErrorZ; class CResult_BigSizeDecodeErrorZ; class CResult_TxOutUtxoLookupErrorZ; -class CResult_BlindedPathNoneZ; class COption_usizeZ; +class CVec_BlindedMessagePathZ; +class CResult_OffersContextDecodeErrorZ; class CResult_NoneNoneZ; class CResult_boolPeerHandleErrorZ; class CResult_ChannelUpdateDecodeErrorZ; class CVec_APIErrorZ; class COption_TxOutZ; class COption_ClosureReasonZ; +class CVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ; class CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ; class CResult_TransactionU16LenLimitedDecodeErrorZ; +class CResult_FundingInfoDecodeErrorZ; class COption_AmountZ; +class COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ; class CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ; class CResult_OpenChannelV2DecodeErrorZ; class CResult_BestBlockDecodeErrorZ; @@ -822,6 +858,21 @@ public: const LDKPaymentSendFailure* operator &() const { return &self; } const LDKPaymentSendFailure* operator ->() const { return &self; } }; +class Bolt12PaymentError { +private: + LDKBolt12PaymentError self; +public: + Bolt12PaymentError(const Bolt12PaymentError&) = delete; + Bolt12PaymentError(Bolt12PaymentError&& o) : self(o.self) { memset(&o, 0, sizeof(Bolt12PaymentError)); } + Bolt12PaymentError(LDKBolt12PaymentError&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBolt12PaymentError)); } + operator LDKBolt12PaymentError() && { LDKBolt12PaymentError res = self; memset(&self, 0, sizeof(LDKBolt12PaymentError)); return res; } + ~Bolt12PaymentError() { Bolt12PaymentError_free(self); } + Bolt12PaymentError& operator=(Bolt12PaymentError&& o) { Bolt12PaymentError_free(self); self = o.self; memset(&o, 0, sizeof(Bolt12PaymentError)); return *this; } + LDKBolt12PaymentError* operator &() { return &self; } + LDKBolt12PaymentError* operator ->() { return &self; } + const LDKBolt12PaymentError* operator &() const { return &self; } + const LDKBolt12PaymentError* operator ->() const { return &self; } +}; class ProbeSendFailure { private: LDKProbeSendFailure self; @@ -931,21 +982,6 @@ public: const LDKBolt12Invoice* operator &() const { return &self; } const LDKBolt12Invoice* operator ->() const { return &self; } }; -class BlindedPayInfo { -private: - LDKBlindedPayInfo self; -public: - BlindedPayInfo(const BlindedPayInfo&) = delete; - BlindedPayInfo(BlindedPayInfo&& o) : self(o.self) { memset(&o, 0, sizeof(BlindedPayInfo)); } - BlindedPayInfo(LDKBlindedPayInfo&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBlindedPayInfo)); } - operator LDKBlindedPayInfo() && { LDKBlindedPayInfo res = self; memset(&self, 0, sizeof(LDKBlindedPayInfo)); return res; } - ~BlindedPayInfo() { BlindedPayInfo_free(self); } - BlindedPayInfo& operator=(BlindedPayInfo&& o) { BlindedPayInfo_free(self); self = o.self; memset(&o, 0, sizeof(BlindedPayInfo)); return *this; } - LDKBlindedPayInfo* operator &() { return &self; } - LDKBlindedPayInfo* operator ->() { return &self; } - const LDKBlindedPayInfo* operator &() const { return &self; } - const LDKBlindedPayInfo* operator ->() const { return &self; } -}; class DelayedPaymentOutputDescriptor { private: LDKDelayedPaymentOutputDescriptor self; @@ -1039,8 +1075,13 @@ public: * Gets the per-commitment point for a specific commitment number * * Note that the commitment number starts at `(1 << 48) - 1` and counts backwards. + * + * If the signer returns `Err`, then the user is responsible for either force-closing the channel + * or calling `ChannelManager::signer_unblocked` (this method is only available when the + * `async_signing` cfg flag is enabled) once the signature is ready. + * */ - inline LDKPublicKey get_per_commitment_point(uint64_t idx); + inline LDK::CResult_PublicKeyNoneZ get_per_commitment_point(uint64_t idx); /** * Gets the commitment secret for a specific commitment number as part of the revocation process * @@ -1051,7 +1092,7 @@ public: * * Note that the commitment number starts at `(1 << 48) - 1` and counts backwards. */ - inline LDKThirtyTwoBytes release_commitment_secret(uint64_t idx); + inline LDK::CResult__u832NoneZ release_commitment_secret(uint64_t idx); /** * Validate the counterparty's signatures on the holder commitment transaction and HTLCs. * @@ -1187,7 +1228,7 @@ public: * * Errors if the [`Recipient`] variant is not supported by the implementation. */ - inline LDK::CResult_RecoverableSignatureNoneZ sign_invoice(struct LDKu8slice hrp_bytes, struct LDKCVec_U5Z invoice_data, enum LDKRecipient recipient); + inline LDK::CResult_RecoverableSignatureNoneZ sign_invoice(const struct LDKRawBolt11Invoice *NONNULL_PTR invoice, enum LDKRecipient recipient); /** * Signs the [`TaggedHash`] of a BOLT 12 invoice request. * @@ -1287,11 +1328,11 @@ public: * 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); + inline LDK::EcdsaChannelSigner 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). + * [`EcdsaChannelSigner`]-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. @@ -1303,7 +1344,7 @@ public: * [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager */ - inline LDK::CResult_WriteableEcdsaChannelSignerDecodeErrorZ read_chan_signer(struct LDKu8slice reader); + inline LDK::CResult_EcdsaChannelSignerDecodeErrorZ read_chan_signer(struct LDKu8slice reader); /** * Get a script pubkey which we send funds to when claiming on-chain contestable outputs. * @@ -1490,11 +1531,11 @@ public: */ 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); /** - * Creates [`BlindedPath`]s for payment to the `recipient` node. The channels in `first_hops` + * Creates [`BlindedPaymentPath`]s for payment to the `recipient` node. The channels in `first_hops` * are assumed to be with the `recipient`'s peers. The payment secret and any constraints are * given in `tlvs`. */ - inline LDK::CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ create_blinded_payment_paths(struct LDKPublicKey recipient, struct LDKCVec_ChannelDetailsZ first_hops, struct LDKReceiveTlvs tlvs, uint64_t amount_msats); + inline LDK::CResult_CVec_BlindedPaymentPathZNoneZ create_blinded_payment_paths(struct LDKPublicKey recipient, struct LDKCVec_ChannelDetailsZ first_hops, struct LDKReceiveTlvs tlvs, uint64_t amount_msats); }; class ScorerAccountingForInFlightHtlcs { private: @@ -1631,36 +1672,6 @@ public: const LDKPayee* operator &() const { return &self; } const LDKPayee* 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 FirstHopCandidate { private: LDKFirstHopCandidate self; @@ -1751,6 +1762,36 @@ public: const LDKCandidateRouteHop* operator &() const { return &self; } const LDKCandidateRouteHop* operator ->() const { return &self; } }; +class UntrustedString { +private: + LDKUntrustedString 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; } +}; +class PrintableString { +private: + LDKPrintableString 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; } +}; class ScoreLookUp { private: LDKScoreLookUp self; @@ -2199,6 +2240,11 @@ public: /** * Registers interest in a transaction with `txid` and having an output with `script_pubkey` as * a spending condition. + * + * This may be used, for example, to monitor for when a funding transaction confirms. + * + * The `script_pubkey` is provided for informational purposes and may be useful for block + * sources which only support filtering on scripts. */ inline void register_tx(const uint8_t (*txid)[32], struct LDKu8slice script_pubkey); /** @@ -2208,6 +2254,9 @@ public: * 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. + * + * This may be used, for example, to monitor for when a funding output is spent (by any + * transaction). */ inline void register_output(struct LDKWatchedOutput output); }; @@ -2226,189 +2275,54 @@ public: const LDKWatchedOutput* operator &() const { return &self; } const LDKWatchedOutput* operator ->() const { return &self; } }; -class InitFeatures { +class OfferId { private: - LDKInitFeatures self; + LDKOfferId 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; } + OfferId(const OfferId&) = delete; + OfferId(OfferId&& o) : self(o.self) { memset(&o, 0, sizeof(OfferId)); } + OfferId(LDKOfferId&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKOfferId)); } + operator LDKOfferId() && { LDKOfferId res = self; memset(&self, 0, sizeof(LDKOfferId)); return res; } + ~OfferId() { OfferId_free(self); } + OfferId& operator=(OfferId&& o) { OfferId_free(self); self = o.self; memset(&o, 0, sizeof(OfferId)); return *this; } + LDKOfferId* operator &() { return &self; } + LDKOfferId* operator ->() { return &self; } + const LDKOfferId* operator &() const { return &self; } + const LDKOfferId* operator ->() const { return &self; } }; -class NodeFeatures { +class OfferWithExplicitMetadataBuilder { private: - LDKNodeFeatures self; + LDKOfferWithExplicitMetadataBuilder 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; } + OfferWithExplicitMetadataBuilder(const OfferWithExplicitMetadataBuilder&) = delete; + OfferWithExplicitMetadataBuilder(OfferWithExplicitMetadataBuilder&& o) : self(o.self) { memset(&o, 0, sizeof(OfferWithExplicitMetadataBuilder)); } + OfferWithExplicitMetadataBuilder(LDKOfferWithExplicitMetadataBuilder&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKOfferWithExplicitMetadataBuilder)); } + operator LDKOfferWithExplicitMetadataBuilder() && { LDKOfferWithExplicitMetadataBuilder res = self; memset(&self, 0, sizeof(LDKOfferWithExplicitMetadataBuilder)); return res; } + ~OfferWithExplicitMetadataBuilder() { OfferWithExplicitMetadataBuilder_free(self); } + OfferWithExplicitMetadataBuilder& operator=(OfferWithExplicitMetadataBuilder&& o) { OfferWithExplicitMetadataBuilder_free(self); self = o.self; memset(&o, 0, sizeof(OfferWithExplicitMetadataBuilder)); return *this; } + LDKOfferWithExplicitMetadataBuilder* operator &() { return &self; } + LDKOfferWithExplicitMetadataBuilder* operator ->() { return &self; } + const LDKOfferWithExplicitMetadataBuilder* operator &() const { return &self; } + const LDKOfferWithExplicitMetadataBuilder* operator ->() const { return &self; } }; -class ChannelFeatures { +class OfferWithDerivedMetadataBuilder { private: - LDKChannelFeatures self; + LDKOfferWithDerivedMetadataBuilder 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; } + OfferWithDerivedMetadataBuilder(const OfferWithDerivedMetadataBuilder&) = delete; + OfferWithDerivedMetadataBuilder(OfferWithDerivedMetadataBuilder&& o) : self(o.self) { memset(&o, 0, sizeof(OfferWithDerivedMetadataBuilder)); } + OfferWithDerivedMetadataBuilder(LDKOfferWithDerivedMetadataBuilder&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKOfferWithDerivedMetadataBuilder)); } + operator LDKOfferWithDerivedMetadataBuilder() && { LDKOfferWithDerivedMetadataBuilder res = self; memset(&self, 0, sizeof(LDKOfferWithDerivedMetadataBuilder)); return res; } + ~OfferWithDerivedMetadataBuilder() { OfferWithDerivedMetadataBuilder_free(self); } + OfferWithDerivedMetadataBuilder& operator=(OfferWithDerivedMetadataBuilder&& o) { OfferWithDerivedMetadataBuilder_free(self); self = o.self; memset(&o, 0, sizeof(OfferWithDerivedMetadataBuilder)); return *this; } + LDKOfferWithDerivedMetadataBuilder* operator &() { return &self; } + LDKOfferWithDerivedMetadataBuilder* operator ->() { return &self; } + const LDKOfferWithDerivedMetadataBuilder* operator &() const { return &self; } + const LDKOfferWithDerivedMetadataBuilder* operator ->() const { return &self; } }; -class Bolt11InvoiceFeatures { +class Offer { 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 OfferId { -private: - LDKOfferId self; -public: - OfferId(const OfferId&) = delete; - OfferId(OfferId&& o) : self(o.self) { memset(&o, 0, sizeof(OfferId)); } - OfferId(LDKOfferId&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKOfferId)); } - operator LDKOfferId() && { LDKOfferId res = self; memset(&self, 0, sizeof(LDKOfferId)); return res; } - ~OfferId() { OfferId_free(self); } - OfferId& operator=(OfferId&& o) { OfferId_free(self); self = o.self; memset(&o, 0, sizeof(OfferId)); return *this; } - LDKOfferId* operator &() { return &self; } - LDKOfferId* operator ->() { return &self; } - const LDKOfferId* operator &() const { return &self; } - const LDKOfferId* operator ->() const { return &self; } -}; -class OfferWithExplicitMetadataBuilder { -private: - LDKOfferWithExplicitMetadataBuilder self; -public: - OfferWithExplicitMetadataBuilder(const OfferWithExplicitMetadataBuilder&) = delete; - OfferWithExplicitMetadataBuilder(OfferWithExplicitMetadataBuilder&& o) : self(o.self) { memset(&o, 0, sizeof(OfferWithExplicitMetadataBuilder)); } - OfferWithExplicitMetadataBuilder(LDKOfferWithExplicitMetadataBuilder&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKOfferWithExplicitMetadataBuilder)); } - operator LDKOfferWithExplicitMetadataBuilder() && { LDKOfferWithExplicitMetadataBuilder res = self; memset(&self, 0, sizeof(LDKOfferWithExplicitMetadataBuilder)); return res; } - ~OfferWithExplicitMetadataBuilder() { OfferWithExplicitMetadataBuilder_free(self); } - OfferWithExplicitMetadataBuilder& operator=(OfferWithExplicitMetadataBuilder&& o) { OfferWithExplicitMetadataBuilder_free(self); self = o.self; memset(&o, 0, sizeof(OfferWithExplicitMetadataBuilder)); return *this; } - LDKOfferWithExplicitMetadataBuilder* operator &() { return &self; } - LDKOfferWithExplicitMetadataBuilder* operator ->() { return &self; } - const LDKOfferWithExplicitMetadataBuilder* operator &() const { return &self; } - const LDKOfferWithExplicitMetadataBuilder* operator ->() const { return &self; } -}; -class OfferWithDerivedMetadataBuilder { -private: - LDKOfferWithDerivedMetadataBuilder self; -public: - OfferWithDerivedMetadataBuilder(const OfferWithDerivedMetadataBuilder&) = delete; - OfferWithDerivedMetadataBuilder(OfferWithDerivedMetadataBuilder&& o) : self(o.self) { memset(&o, 0, sizeof(OfferWithDerivedMetadataBuilder)); } - OfferWithDerivedMetadataBuilder(LDKOfferWithDerivedMetadataBuilder&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKOfferWithDerivedMetadataBuilder)); } - operator LDKOfferWithDerivedMetadataBuilder() && { LDKOfferWithDerivedMetadataBuilder res = self; memset(&self, 0, sizeof(LDKOfferWithDerivedMetadataBuilder)); return res; } - ~OfferWithDerivedMetadataBuilder() { OfferWithDerivedMetadataBuilder_free(self); } - OfferWithDerivedMetadataBuilder& operator=(OfferWithDerivedMetadataBuilder&& o) { OfferWithDerivedMetadataBuilder_free(self); self = o.self; memset(&o, 0, sizeof(OfferWithDerivedMetadataBuilder)); return *this; } - LDKOfferWithDerivedMetadataBuilder* operator &() { return &self; } - LDKOfferWithDerivedMetadataBuilder* operator ->() { return &self; } - const LDKOfferWithDerivedMetadataBuilder* operator &() const { return &self; } - const LDKOfferWithDerivedMetadataBuilder* operator ->() const { return &self; } -}; -class Offer { -private: - LDKOffer self; + LDKOffer self; public: Offer(const Offer&) = delete; Offer(Offer&& o) : self(o.self) { memset(&o, 0, sizeof(Offer)); } @@ -2586,20 +2500,20 @@ public: const LDKEffectiveCapacity* operator &() const { return &self; } const LDKEffectiveCapacity* operator ->() const { return &self; } }; -class RoutingFees { +class NodeAnnouncementDetails { private: - LDKRoutingFees self; + LDKNodeAnnouncementDetails self; public: - RoutingFees(const RoutingFees&) = delete; - RoutingFees(RoutingFees&& o) : self(o.self) { memset(&o, 0, sizeof(RoutingFees)); } - RoutingFees(LDKRoutingFees&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKRoutingFees)); } - operator LDKRoutingFees() && { LDKRoutingFees res = self; memset(&self, 0, sizeof(LDKRoutingFees)); return res; } - ~RoutingFees() { RoutingFees_free(self); } - RoutingFees& operator=(RoutingFees&& o) { RoutingFees_free(self); self = o.self; memset(&o, 0, sizeof(RoutingFees)); return *this; } - LDKRoutingFees* operator &() { return &self; } - LDKRoutingFees* operator ->() { return &self; } - const LDKRoutingFees* operator &() const { return &self; } - const LDKRoutingFees* operator ->() const { return &self; } + NodeAnnouncementDetails(const NodeAnnouncementDetails&) = delete; + NodeAnnouncementDetails(NodeAnnouncementDetails&& o) : self(o.self) { memset(&o, 0, sizeof(NodeAnnouncementDetails)); } + NodeAnnouncementDetails(LDKNodeAnnouncementDetails&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKNodeAnnouncementDetails)); } + operator LDKNodeAnnouncementDetails() && { LDKNodeAnnouncementDetails res = self; memset(&self, 0, sizeof(LDKNodeAnnouncementDetails)); return res; } + ~NodeAnnouncementDetails() { NodeAnnouncementDetails_free(self); } + NodeAnnouncementDetails& operator=(NodeAnnouncementDetails&& o) { NodeAnnouncementDetails_free(self); self = o.self; memset(&o, 0, sizeof(NodeAnnouncementDetails)); return *this; } + LDKNodeAnnouncementDetails* operator &() { return &self; } + LDKNodeAnnouncementDetails* operator ->() { return &self; } + const LDKNodeAnnouncementDetails* operator &() const { return &self; } + const LDKNodeAnnouncementDetails* operator ->() const { return &self; } }; class NodeAnnouncementInfo { private: @@ -3331,21 +3245,6 @@ public: */ inline LDK::CResult_ECDSASignatureNoneZ sign_channel_announcement_with_funding_key(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR msg); }; -class WriteableEcdsaChannelSigner { -private: - LDKWriteableEcdsaChannelSigner 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; } -}; class ChannelMonitorUpdate { private: LDKChannelMonitorUpdate self; @@ -3391,6 +3290,20 @@ public: const LDKHTLCUpdate* operator &() const { return &self; } const LDKHTLCUpdate* operator ->() const { return &self; } }; +class BalanceSource { +private: + LDKBalanceSource self; +public: + BalanceSource(const BalanceSource&) = delete; + BalanceSource(BalanceSource&& o) : self(o.self) { memset(&o, 0, sizeof(BalanceSource)); } + BalanceSource(LDKBalanceSource&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBalanceSource)); } + operator LDKBalanceSource() && { LDKBalanceSource res = self; memset(&self, 0, sizeof(LDKBalanceSource)); return res; } + BalanceSource& operator=(BalanceSource&& o) { self = o.self; memset(&o, 0, sizeof(BalanceSource)); return *this; } + LDKBalanceSource* operator &() { return &self; } + LDKBalanceSource* operator ->() { return &self; } + const LDKBalanceSource* operator &() const { return &self; } + const LDKBalanceSource* operator ->() const { return &self; } +}; class Balance { private: LDKBalance self; @@ -3462,6 +3375,18 @@ public: * connection to the node exists, then the message is simply not sent. */ inline LDK::CVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg(); + /** + * Indicates a peer disconnected. + */ + inline void peer_disconnected(struct LDKPublicKey their_node_id); + /** + * Handle a peer connecting. + * + * 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); /** * 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`] @@ -3964,6 +3889,21 @@ public: const LDKCommonOpenChannelFields* operator &() const { return &self; } const LDKCommonOpenChannelFields* operator ->() const { return &self; } }; +class ChannelParameters { +private: + LDKChannelParameters self; +public: + ChannelParameters(const ChannelParameters&) = delete; + ChannelParameters(ChannelParameters&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelParameters)); } + ChannelParameters(LDKChannelParameters&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelParameters)); } + operator LDKChannelParameters() && { LDKChannelParameters res = self; memset(&self, 0, sizeof(LDKChannelParameters)); return res; } + ~ChannelParameters() { ChannelParameters_free(self); } + ChannelParameters& operator=(ChannelParameters&& o) { ChannelParameters_free(self); self = o.self; memset(&o, 0, sizeof(ChannelParameters)); return *this; } + LDKChannelParameters* operator &() { return &self; } + LDKChannelParameters* operator ->() { return &self; } + const LDKChannelParameters* operator &() const { return &self; } + const LDKChannelParameters* operator ->() const { return &self; } +}; class OpenChannel { private: LDKOpenChannel self; @@ -4099,20 +4039,20 @@ public: const LDKStfu* operator &() const { return &self; } const LDKStfu* operator ->() const { return &self; } }; -class Splice { +class SpliceInit { private: - LDKSplice self; + LDKSpliceInit self; public: - Splice(const Splice&) = delete; - Splice(Splice&& o) : self(o.self) { memset(&o, 0, sizeof(Splice)); } - Splice(LDKSplice&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKSplice)); } - operator LDKSplice() && { LDKSplice res = self; memset(&self, 0, sizeof(LDKSplice)); return res; } - ~Splice() { Splice_free(self); } - Splice& operator=(Splice&& o) { Splice_free(self); self = o.self; memset(&o, 0, sizeof(Splice)); return *this; } - LDKSplice* operator &() { return &self; } - LDKSplice* operator ->() { return &self; } - const LDKSplice* operator &() const { return &self; } - const LDKSplice* operator ->() const { return &self; } + SpliceInit(const SpliceInit&) = delete; + SpliceInit(SpliceInit&& o) : self(o.self) { memset(&o, 0, sizeof(SpliceInit)); } + SpliceInit(LDKSpliceInit&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKSpliceInit)); } + operator LDKSpliceInit() && { LDKSpliceInit res = self; memset(&self, 0, sizeof(LDKSpliceInit)); return res; } + ~SpliceInit() { SpliceInit_free(self); } + SpliceInit& operator=(SpliceInit&& o) { SpliceInit_free(self); self = o.self; memset(&o, 0, sizeof(SpliceInit)); return *this; } + LDKSpliceInit* operator &() { return &self; } + LDKSpliceInit* operator ->() { return &self; } + const LDKSpliceInit* operator &() const { return &self; } + const LDKSpliceInit* operator ->() const { return &self; } }; class SpliceAck { private: @@ -4399,6 +4339,21 @@ public: const LDKUpdateFailMalformedHTLC* operator &() const { return &self; } const LDKUpdateFailMalformedHTLC* operator ->() const { return &self; } }; +class CommitmentSignedBatch { +private: + LDKCommitmentSignedBatch self; +public: + CommitmentSignedBatch(const CommitmentSignedBatch&) = delete; + CommitmentSignedBatch(CommitmentSignedBatch&& o) : self(o.self) { memset(&o, 0, sizeof(CommitmentSignedBatch)); } + CommitmentSignedBatch(LDKCommitmentSignedBatch&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCommitmentSignedBatch)); } + operator LDKCommitmentSignedBatch() && { LDKCommitmentSignedBatch res = self; memset(&self, 0, sizeof(LDKCommitmentSignedBatch)); return res; } + ~CommitmentSignedBatch() { CommitmentSignedBatch_free(self); } + CommitmentSignedBatch& operator=(CommitmentSignedBatch&& o) { CommitmentSignedBatch_free(self); self = o.self; memset(&o, 0, sizeof(CommitmentSignedBatch)); return *this; } + LDKCommitmentSignedBatch* operator &() { return &self; } + LDKCommitmentSignedBatch* operator ->() { return &self; } + const LDKCommitmentSignedBatch* operator &() const { return &self; } + const LDKCommitmentSignedBatch* operator ->() const { return &self; } +}; class CommitmentSigned { private: LDKCommitmentSigned self; @@ -5010,16 +4965,6 @@ public: LDKOnionMessageHandler* operator ->() { return &self; } const LDKOnionMessageHandler* operator &() const { return &self; } const LDKOnionMessageHandler* operator ->() const { return &self; } - /** - * Because much of the lightning network does not yet support forwarding onion messages, we - * may need to directly connect to a node which will forward a message for us. In such a case, - * this method will return the set of nodes which need connection by node_id and the - * corresponding socket addresses where they may accept incoming connections. - * - * Thus, this method should be polled regularly to detect messages await such a direct - * connection. - */ - inline LDK::CVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ get_and_clear_connections_needed(); /** * Handle an incoming `onion_message` message from the given peer. */ @@ -5323,6 +5268,85 @@ public: const LDKSleeper* operator &() const { return &self; } const LDKSleeper* operator ->() const { return &self; } }; +class AsyncPaymentsMessageHandler { +private: + LDKAsyncPaymentsMessageHandler self; +public: + AsyncPaymentsMessageHandler(const AsyncPaymentsMessageHandler&) = delete; + AsyncPaymentsMessageHandler(AsyncPaymentsMessageHandler&& o) : self(o.self) { memset(&o, 0, sizeof(AsyncPaymentsMessageHandler)); } + AsyncPaymentsMessageHandler(LDKAsyncPaymentsMessageHandler&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKAsyncPaymentsMessageHandler)); } + operator LDKAsyncPaymentsMessageHandler() && { LDKAsyncPaymentsMessageHandler res = self; memset(&self, 0, sizeof(LDKAsyncPaymentsMessageHandler)); return res; } + ~AsyncPaymentsMessageHandler() { AsyncPaymentsMessageHandler_free(self); } + AsyncPaymentsMessageHandler& operator=(AsyncPaymentsMessageHandler&& o) { AsyncPaymentsMessageHandler_free(self); self = o.self; memset(&o, 0, sizeof(AsyncPaymentsMessageHandler)); return *this; } + LDKAsyncPaymentsMessageHandler* operator &() { return &self; } + LDKAsyncPaymentsMessageHandler* operator ->() { return &self; } + const LDKAsyncPaymentsMessageHandler* operator &() const { return &self; } + const LDKAsyncPaymentsMessageHandler* operator ->() const { return &self; } + /** + * Handle a [`HeldHtlcAvailable`] message. A [`ReleaseHeldHtlc`] should be returned to release + * the held funds. + * + * Note that responder (or a relevant inner pointer) may be NULL or all-0s to represent None + */ + inline LDK::COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ held_htlc_available(struct LDKHeldHtlcAvailable message, struct LDKResponder responder); + /** + * Handle a [`ReleaseHeldHtlc`] message. If authentication of the message succeeds, an HTLC + * should be released to the corresponding payee. + */ + inline void release_held_htlc(struct LDKReleaseHeldHtlc message); + /** + * Release any [`AsyncPaymentsMessage`]s that need to be sent. + * + * Typically, this is used for messages initiating an async payment flow rather than in response + * to another message. + */ + inline LDK::CVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ release_pending_messages(); +}; +class AsyncPaymentsMessage { +private: + LDKAsyncPaymentsMessage self; +public: + AsyncPaymentsMessage(const AsyncPaymentsMessage&) = delete; + AsyncPaymentsMessage(AsyncPaymentsMessage&& o) : self(o.self) { memset(&o, 0, sizeof(AsyncPaymentsMessage)); } + AsyncPaymentsMessage(LDKAsyncPaymentsMessage&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKAsyncPaymentsMessage)); } + operator LDKAsyncPaymentsMessage() && { LDKAsyncPaymentsMessage res = self; memset(&self, 0, sizeof(LDKAsyncPaymentsMessage)); return res; } + ~AsyncPaymentsMessage() { AsyncPaymentsMessage_free(self); } + AsyncPaymentsMessage& operator=(AsyncPaymentsMessage&& o) { AsyncPaymentsMessage_free(self); self = o.self; memset(&o, 0, sizeof(AsyncPaymentsMessage)); return *this; } + LDKAsyncPaymentsMessage* operator &() { return &self; } + LDKAsyncPaymentsMessage* operator ->() { return &self; } + const LDKAsyncPaymentsMessage* operator &() const { return &self; } + const LDKAsyncPaymentsMessage* operator ->() const { return &self; } +}; +class HeldHtlcAvailable { +private: + LDKHeldHtlcAvailable self; +public: + HeldHtlcAvailable(const HeldHtlcAvailable&) = delete; + HeldHtlcAvailable(HeldHtlcAvailable&& o) : self(o.self) { memset(&o, 0, sizeof(HeldHtlcAvailable)); } + HeldHtlcAvailable(LDKHeldHtlcAvailable&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKHeldHtlcAvailable)); } + operator LDKHeldHtlcAvailable() && { LDKHeldHtlcAvailable res = self; memset(&self, 0, sizeof(LDKHeldHtlcAvailable)); return res; } + ~HeldHtlcAvailable() { HeldHtlcAvailable_free(self); } + HeldHtlcAvailable& operator=(HeldHtlcAvailable&& o) { HeldHtlcAvailable_free(self); self = o.self; memset(&o, 0, sizeof(HeldHtlcAvailable)); return *this; } + LDKHeldHtlcAvailable* operator &() { return &self; } + LDKHeldHtlcAvailable* operator ->() { return &self; } + const LDKHeldHtlcAvailable* operator &() const { return &self; } + const LDKHeldHtlcAvailable* operator ->() const { return &self; } +}; +class ReleaseHeldHtlc { +private: + LDKReleaseHeldHtlc self; +public: + ReleaseHeldHtlc(const ReleaseHeldHtlc&) = delete; + ReleaseHeldHtlc(ReleaseHeldHtlc&& o) : self(o.self) { memset(&o, 0, sizeof(ReleaseHeldHtlc)); } + ReleaseHeldHtlc(LDKReleaseHeldHtlc&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKReleaseHeldHtlc)); } + operator LDKReleaseHeldHtlc() && { LDKReleaseHeldHtlc res = self; memset(&self, 0, sizeof(LDKReleaseHeldHtlc)); return res; } + ~ReleaseHeldHtlc() { ReleaseHeldHtlc_free(self); } + ReleaseHeldHtlc& operator=(ReleaseHeldHtlc&& o) { ReleaseHeldHtlc_free(self); self = o.self; memset(&o, 0, sizeof(ReleaseHeldHtlc)); return *this; } + LDKReleaseHeldHtlc* operator &() { return &self; } + LDKReleaseHeldHtlc* operator ->() { return &self; } + const LDKReleaseHeldHtlc* operator &() const { return &self; } + const LDKReleaseHeldHtlc* operator ->() const { return &self; } +}; class OffersMessageHandler { private: LDKOffersMessageHandler self; @@ -5344,15 +5368,17 @@ public: * The returned [`OffersMessage`], if any, is enqueued to be sent by [`OnionMessenger`]. * * [`OnionMessenger`]: crate::onion_message::messenger::OnionMessenger + * + * Note that responder (or a relevant inner pointer) may be NULL or all-0s to represent None */ - inline LDK::COption_OffersMessageZ handle_message(struct LDKOffersMessage message); + inline LDK::COption_C2Tuple_OffersMessageResponseInstructionZZ handle_message(struct LDKOffersMessage message, struct LDKCOption_OffersContextZ context, struct LDKResponder responder); /** * Releases any [`OffersMessage`]s that need to be sent. * * Typically, this is used for messages initiating a payment flow rather than in response to * another message. The latter should use the return value of [`Self::handle_message`]. */ - inline LDK::CVec_C3Tuple_OffersMessageDestinationBlindedPathZZ release_pending_messages(); + inline LDK::CVec_C2Tuple_OffersMessageMessageSendInstructionsZZ release_pending_messages(); }; class OffersMessage { private: @@ -5756,11 +5782,30 @@ public: * Returns the TLV type identifying the message contents. MUST be >= 64. */ inline uint64_t tlv_type(); + /** + * Returns the message type + */ + inline LDK::Str msg_type(); /** * Return a human-readable "debug" string describing this object */ inline LDK::Str debug_str(); }; +class FundingInfo { +private: + LDKFundingInfo self; +public: + FundingInfo(const FundingInfo&) = delete; + FundingInfo(FundingInfo&& o) : self(o.self) { memset(&o, 0, sizeof(FundingInfo)); } + FundingInfo(LDKFundingInfo&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKFundingInfo)); } + operator LDKFundingInfo() && { LDKFundingInfo res = self; memset(&self, 0, sizeof(LDKFundingInfo)); return res; } + ~FundingInfo() { FundingInfo_free(self); } + FundingInfo& operator=(FundingInfo&& o) { FundingInfo_free(self); self = o.self; memset(&o, 0, sizeof(FundingInfo)); return *this; } + LDKFundingInfo* operator &() { return &self; } + LDKFundingInfo* operator ->() { return &self; } + const LDKFundingInfo* operator &() const { return &self; } + const LDKFundingInfo* operator ->() const { return &self; } +}; class PaymentPurpose { private: LDKPaymentPurpose self; @@ -5921,6 +5966,21 @@ public: */ inline void process_pending_events(struct LDKEventHandler handler); }; +class ReplayEvent { +private: + LDKReplayEvent self; +public: + ReplayEvent(const ReplayEvent&) = delete; + ReplayEvent(ReplayEvent&& o) : self(o.self) { memset(&o, 0, sizeof(ReplayEvent)); } + ReplayEvent(LDKReplayEvent&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKReplayEvent)); } + operator LDKReplayEvent() && { LDKReplayEvent res = self; memset(&self, 0, sizeof(LDKReplayEvent)); return res; } + ~ReplayEvent() { ReplayEvent_free(self); } + ReplayEvent& operator=(ReplayEvent&& o) { ReplayEvent_free(self); self = o.self; memset(&o, 0, sizeof(ReplayEvent)); return *this; } + LDKReplayEvent* operator &() { return &self; } + LDKReplayEvent* operator ->() { return &self; } + const LDKReplayEvent* operator &() const { return &self; } + const LDKReplayEvent* operator ->() const { return &self; } +}; class EventHandler { private: LDKEventHandler self; @@ -5940,7 +6000,67 @@ public: * * See [`EventsProvider`] for details that must be considered when implementing this method. */ - inline void handle_event(struct LDKEvent event); + inline LDK::CResult_NoneReplayEventZ handle_event(struct LDKEvent event); +}; +class Nonce { +private: + LDKNonce self; +public: + Nonce(const Nonce&) = delete; + Nonce(Nonce&& o) : self(o.self) { memset(&o, 0, sizeof(Nonce)); } + Nonce(LDKNonce&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKNonce)); } + operator LDKNonce() && { LDKNonce res = self; memset(&self, 0, sizeof(LDKNonce)); return res; } + ~Nonce() { Nonce_free(self); } + Nonce& operator=(Nonce&& o) { Nonce_free(self); self = o.self; memset(&o, 0, sizeof(Nonce)); return *this; } + LDKNonce* operator &() { return &self; } + LDKNonce* operator ->() { return &self; } + const LDKNonce* operator &() const { return &self; } + const LDKNonce* operator ->() const { return &self; } +}; +class RoutingFees { +private: + LDKRoutingFees self; +public: + RoutingFees(const RoutingFees&) = delete; + RoutingFees(RoutingFees&& o) : self(o.self) { memset(&o, 0, sizeof(RoutingFees)); } + RoutingFees(LDKRoutingFees&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKRoutingFees)); } + operator LDKRoutingFees() && { LDKRoutingFees res = self; memset(&self, 0, sizeof(LDKRoutingFees)); return res; } + ~RoutingFees() { RoutingFees_free(self); } + RoutingFees& operator=(RoutingFees&& o) { RoutingFees_free(self); self = o.self; memset(&o, 0, sizeof(RoutingFees)); return *this; } + LDKRoutingFees* operator &() { return &self; } + LDKRoutingFees* operator ->() { return &self; } + const LDKRoutingFees* operator &() const { return &self; } + const LDKRoutingFees* 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 Bolt11ParseError { private: @@ -6298,39 +6418,9 @@ public: const LDKTransactionU16LenLimited* operator &() const { return &self; } const LDKTransactionU16LenLimited* operator ->() const { return &self; } }; -class UntrustedString { +class ChannelId { private: - LDKUntrustedString 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; } -}; -class PrintableString { -private: - LDKPrintableString 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; } -}; -class ChannelId { -private: - LDKChannelId self; + LDKChannelId self; public: ChannelId(const ChannelId&) = delete; ChannelId(ChannelId&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelId)); } @@ -6388,20 +6478,50 @@ public: */ inline LDK::Str debug_str(); }; -class ForwardNode { +class BlindedPayInfo { +private: + LDKBlindedPayInfo self; +public: + BlindedPayInfo(const BlindedPayInfo&) = delete; + BlindedPayInfo(BlindedPayInfo&& o) : self(o.self) { memset(&o, 0, sizeof(BlindedPayInfo)); } + BlindedPayInfo(LDKBlindedPayInfo&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBlindedPayInfo)); } + operator LDKBlindedPayInfo() && { LDKBlindedPayInfo res = self; memset(&self, 0, sizeof(LDKBlindedPayInfo)); return res; } + ~BlindedPayInfo() { BlindedPayInfo_free(self); } + BlindedPayInfo& operator=(BlindedPayInfo&& o) { BlindedPayInfo_free(self); self = o.self; memset(&o, 0, sizeof(BlindedPayInfo)); return *this; } + LDKBlindedPayInfo* operator &() { return &self; } + LDKBlindedPayInfo* operator ->() { return &self; } + const LDKBlindedPayInfo* operator &() const { return &self; } + const LDKBlindedPayInfo* operator ->() const { return &self; } +}; +class BlindedPaymentPath { +private: + LDKBlindedPaymentPath self; +public: + BlindedPaymentPath(const BlindedPaymentPath&) = delete; + BlindedPaymentPath(BlindedPaymentPath&& o) : self(o.self) { memset(&o, 0, sizeof(BlindedPaymentPath)); } + BlindedPaymentPath(LDKBlindedPaymentPath&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBlindedPaymentPath)); } + operator LDKBlindedPaymentPath() && { LDKBlindedPaymentPath res = self; memset(&self, 0, sizeof(LDKBlindedPaymentPath)); return res; } + ~BlindedPaymentPath() { BlindedPaymentPath_free(self); } + BlindedPaymentPath& operator=(BlindedPaymentPath&& o) { BlindedPaymentPath_free(self); self = o.self; memset(&o, 0, sizeof(BlindedPaymentPath)); return *this; } + LDKBlindedPaymentPath* operator &() { return &self; } + LDKBlindedPaymentPath* operator ->() { return &self; } + const LDKBlindedPaymentPath* operator &() const { return &self; } + const LDKBlindedPaymentPath* operator ->() const { return &self; } +}; +class PaymentForwardNode { private: - LDKForwardNode self; + LDKPaymentForwardNode self; public: - ForwardNode(const ForwardNode&) = delete; - ForwardNode(ForwardNode&& o) : self(o.self) { memset(&o, 0, sizeof(ForwardNode)); } - ForwardNode(LDKForwardNode&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKForwardNode)); } - operator LDKForwardNode() && { LDKForwardNode res = self; memset(&self, 0, sizeof(LDKForwardNode)); return res; } - ~ForwardNode() { ForwardNode_free(self); } - ForwardNode& operator=(ForwardNode&& o) { ForwardNode_free(self); self = o.self; memset(&o, 0, sizeof(ForwardNode)); return *this; } - LDKForwardNode* operator &() { return &self; } - LDKForwardNode* operator ->() { return &self; } - const LDKForwardNode* operator &() const { return &self; } - const LDKForwardNode* operator ->() const { return &self; } + PaymentForwardNode(const PaymentForwardNode&) = delete; + PaymentForwardNode(PaymentForwardNode&& o) : self(o.self) { memset(&o, 0, sizeof(PaymentForwardNode)); } + PaymentForwardNode(LDKPaymentForwardNode&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPaymentForwardNode)); } + operator LDKPaymentForwardNode() && { LDKPaymentForwardNode res = self; memset(&self, 0, sizeof(LDKPaymentForwardNode)); return res; } + ~PaymentForwardNode() { PaymentForwardNode_free(self); } + PaymentForwardNode& operator=(PaymentForwardNode&& o) { PaymentForwardNode_free(self); self = o.self; memset(&o, 0, sizeof(PaymentForwardNode)); return *this; } + LDKPaymentForwardNode* operator &() { return &self; } + LDKPaymentForwardNode* operator ->() { return &self; } + const LDKPaymentForwardNode* operator &() const { return &self; } + const LDKPaymentForwardNode* operator ->() const { return &self; } }; class ForwardTlvs { private: @@ -6605,6 +6725,51 @@ public: const LDKOnionMessenger* operator &() const { return &self; } const LDKOnionMessenger* operator ->() const { return &self; } }; +class Responder { +private: + LDKResponder self; +public: + Responder(const Responder&) = delete; + Responder(Responder&& o) : self(o.self) { memset(&o, 0, sizeof(Responder)); } + Responder(LDKResponder&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKResponder)); } + operator LDKResponder() && { LDKResponder res = self; memset(&self, 0, sizeof(LDKResponder)); return res; } + ~Responder() { Responder_free(self); } + Responder& operator=(Responder&& o) { Responder_free(self); self = o.self; memset(&o, 0, sizeof(Responder)); return *this; } + LDKResponder* operator &() { return &self; } + LDKResponder* operator ->() { return &self; } + const LDKResponder* operator &() const { return &self; } + const LDKResponder* operator ->() const { return &self; } +}; +class ResponseInstruction { +private: + LDKResponseInstruction self; +public: + ResponseInstruction(const ResponseInstruction&) = delete; + ResponseInstruction(ResponseInstruction&& o) : self(o.self) { memset(&o, 0, sizeof(ResponseInstruction)); } + ResponseInstruction(LDKResponseInstruction&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKResponseInstruction)); } + operator LDKResponseInstruction() && { LDKResponseInstruction res = self; memset(&self, 0, sizeof(LDKResponseInstruction)); return res; } + ~ResponseInstruction() { ResponseInstruction_free(self); } + ResponseInstruction& operator=(ResponseInstruction&& o) { ResponseInstruction_free(self); self = o.self; memset(&o, 0, sizeof(ResponseInstruction)); return *this; } + LDKResponseInstruction* operator &() { return &self; } + LDKResponseInstruction* operator ->() { return &self; } + const LDKResponseInstruction* operator &() const { return &self; } + const LDKResponseInstruction* operator ->() const { return &self; } +}; +class MessageSendInstructions { +private: + LDKMessageSendInstructions self; +public: + MessageSendInstructions(const MessageSendInstructions&) = delete; + MessageSendInstructions(MessageSendInstructions&& o) : self(o.self) { memset(&o, 0, sizeof(MessageSendInstructions)); } + MessageSendInstructions(LDKMessageSendInstructions&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKMessageSendInstructions)); } + operator LDKMessageSendInstructions() && { LDKMessageSendInstructions res = self; memset(&self, 0, sizeof(LDKMessageSendInstructions)); return res; } + ~MessageSendInstructions() { MessageSendInstructions_free(self); } + MessageSendInstructions& operator=(MessageSendInstructions&& o) { MessageSendInstructions_free(self); self = o.self; memset(&o, 0, sizeof(MessageSendInstructions)); return *this; } + LDKMessageSendInstructions* operator &() { return &self; } + LDKMessageSendInstructions* operator ->() { return &self; } + const LDKMessageSendInstructions* operator &() const { return &self; } + const LDKMessageSendInstructions* operator ->() const { return &self; } +}; class MessageRouter { private: LDKMessageRouter self; @@ -6624,10 +6789,26 @@ public: */ inline LDK::CResult_OnionMessagePathNoneZ find_path(struct LDKPublicKey sender, struct LDKCVec_PublicKeyZ peers, struct LDKDestination destination); /** - * Creates [`BlindedPath`]s to the `recipient` node. The nodes in `peers` are assumed to be - * direct peers with the `recipient`. + * Creates [`BlindedMessagePath`]s to the `recipient` node. The nodes in `peers` are assumed to + * be direct peers with the `recipient`. + */ + inline LDK::CResult_CVec_BlindedMessagePathZNoneZ create_blinded_paths(struct LDKPublicKey recipient, struct LDKMessageContext context, struct LDKCVec_PublicKeyZ peers); + /** + * Creates compact [`BlindedMessagePath`]s to the `recipient` node. The nodes in `peers` are + * assumed to be direct peers with the `recipient`. + * + * Compact blinded paths use short channel ids instead of pubkeys for a smaller serialization, + * which is beneficial when a QR code is used to transport the data. The SCID is passed using + * a [`MessageForwardNode`] but may be `None` for graceful degradation. + * + * Implementations using additional intermediate nodes are responsible for using a + * [`MessageForwardNode`] with `Some` short channel id, if possible. Similarly, implementations + * should call [`BlindedMessagePath::use_compact_introduction_node`]. + * + * The provided implementation simply delegates to [`MessageRouter::create_blinded_paths`], + * ignoring the short channel ids. */ - inline LDK::CResult_CVec_BlindedPathZNoneZ create_blinded_paths(struct LDKPublicKey recipient, struct LDKCVec_PublicKeyZ peers); + inline LDK::CResult_CVec_BlindedMessagePathZNoneZ create_compact_blinded_paths(struct LDKPublicKey recipient, struct LDKMessageContext context, struct LDKCVec_MessageForwardNodeZ peers); }; class DefaultMessageRouter { private: @@ -6722,8 +6903,10 @@ public: * Called with the custom message that was received, returning a response to send, if any. * * The returned [`Self::CustomMessage`], if any, is enqueued to be sent by [`OnionMessenger`]. + * + * Note that responder (or a relevant inner pointer) may be NULL or all-0s to represent None */ - inline LDK::COption_OnionMessageContentsZ handle_custom_message(struct LDKOnionMessageContents msg); + inline LDK::COption_C2Tuple_OnionMessageContentsResponseInstructionZZ handle_custom_message(struct LDKOnionMessageContents message, struct LDKCOption_CVec_u8ZZ context, struct LDKResponder responder); /** * Read a custom message of type `message_type` from `buffer`, returning `Ok(None)` if the * message type is unknown. @@ -6735,7 +6918,7 @@ public: * Typically, this is used for messages initiating a message flow rather than in response to * another message. The latter should use the return value of [`Self::handle_custom_message`]. */ - inline LDK::CVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ release_pending_custom_messages(); + inline LDK::CVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ release_pending_custom_messages(); }; class PeeledOnion { private: @@ -6767,35 +6950,140 @@ public: const LDKFilesystemStore* operator &() const { return &self; } const LDKFilesystemStore* operator ->() const { return &self; } }; -class NextMessageHop { +class InitFeatures { private: - LDKNextMessageHop self; + LDKInitFeatures self; public: - NextMessageHop(const NextMessageHop&) = delete; - NextMessageHop(NextMessageHop&& o) : self(o.self) { memset(&o, 0, sizeof(NextMessageHop)); } - NextMessageHop(LDKNextMessageHop&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKNextMessageHop)); } - operator LDKNextMessageHop() && { LDKNextMessageHop res = self; memset(&self, 0, sizeof(LDKNextMessageHop)); return res; } - ~NextMessageHop() { NextMessageHop_free(self); } - NextMessageHop& operator=(NextMessageHop&& o) { NextMessageHop_free(self); self = o.self; memset(&o, 0, sizeof(NextMessageHop)); return *this; } - LDKNextMessageHop* operator &() { return &self; } - LDKNextMessageHop* operator ->() { return &self; } - const LDKNextMessageHop* operator &() const { return &self; } - const LDKNextMessageHop* operator ->() const { return &self; } + 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 BlindedPath { +class ChannelTypeFeatures { private: - LDKBlindedPath self; + LDKChannelTypeFeatures 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; } + 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 IntroductionNode { private: @@ -7062,21 +7350,6 @@ public: const LDKRevocationKey* operator &() const { return &self; } const LDKRevocationKey* operator ->() const { return &self; } }; -class MonitorUpdateId { -private: - LDKMonitorUpdateId self; -public: - MonitorUpdateId(const MonitorUpdateId&) = delete; - MonitorUpdateId(MonitorUpdateId&& o) : self(o.self) { memset(&o, 0, sizeof(MonitorUpdateId)); } - MonitorUpdateId(LDKMonitorUpdateId&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKMonitorUpdateId)); } - operator LDKMonitorUpdateId() && { LDKMonitorUpdateId res = self; memset(&self, 0, sizeof(LDKMonitorUpdateId)); return res; } - ~MonitorUpdateId() { MonitorUpdateId_free(self); } - MonitorUpdateId& operator=(MonitorUpdateId&& o) { MonitorUpdateId_free(self); self = o.self; memset(&o, 0, sizeof(MonitorUpdateId)); return *this; } - LDKMonitorUpdateId* operator &() { return &self; } - LDKMonitorUpdateId* operator ->() { return &self; } - const LDKMonitorUpdateId* operator &() const { return &self; } - const LDKMonitorUpdateId* operator ->() const { return &self; } -}; class Persist { private: LDKPersist self; @@ -7099,8 +7372,9 @@ public: * 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`]. + * The [`ChannelMonitor::get_latest_update_id`] uniquely links this call to [`ChainMonitor::channel_monitor_updated`]. + * For [`Persist::persist_new_channel`], it is only necessary to call [`ChainMonitor::channel_monitor_updated`] + * when you return [`ChannelMonitorUpdateStatus::InProgress`]. * * See [`Writeable::write`] on [`ChannelMonitor`] for writing out a `ChannelMonitor` * and [`ChannelMonitorUpdateStatus`] for requirements when returning errors. @@ -7108,7 +7382,7 @@ public: * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager * [`Writeable::write`]: crate::util::ser::Writeable::write */ - inline LDK::ChannelMonitorUpdateStatus persist_new_channel(struct LDKOutPoint channel_funding_outpoint, const struct LDKChannelMonitor *NONNULL_PTR data, struct LDKMonitorUpdateId update_id); + inline LDK::ChannelMonitorUpdateStatus persist_new_channel(struct LDKOutPoint channel_funding_outpoint, const struct LDKChannelMonitor *NONNULL_PTR monitor); /** * Update one channel's data. The provided [`ChannelMonitor`] has already applied the given * update. @@ -7126,7 +7400,9 @@ public: * 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 + * deserialization routine. If there are any gaps in the persisted [`ChannelMonitorUpdate`]s, + * implementer can safely ignore [`ChannelMonitorUpdate`]s after the gap and load without them. + * 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. * @@ -7135,8 +7411,10 @@ public: * 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`]. + * The [`ChannelMonitorUpdate::update_id`] or [`ChannelMonitor::get_latest_update_id`] uniquely + * links this call to [`ChainMonitor::channel_monitor_updated`]. + * For [`Persist::update_persisted_channel`], it is only necessary to call [`ChainMonitor::channel_monitor_updated`] + * when a [`ChannelMonitorUpdate`] is provided and when you return [`ChannelMonitorUpdateStatus::InProgress`]. * * See [`Writeable::write`] on [`ChannelMonitor`] for writing out a `ChannelMonitor`, * [`Writeable::write`] on [`ChannelMonitorUpdate`] for writing out an update, and @@ -7144,9 +7422,9 @@ public: * * [`Writeable::write`]: crate::util::ser::Writeable::write * - * Note that update (or a relevant inner pointer) may be NULL or all-0s to represent None + * Note that monitor_update (or a relevant inner pointer) may be NULL or all-0s to represent None */ - inline LDK::ChannelMonitorUpdateStatus update_persisted_channel(struct LDKOutPoint channel_funding_outpoint, struct LDKChannelMonitorUpdate update, const struct LDKChannelMonitor *NONNULL_PTR data, struct LDKMonitorUpdateId update_id); + inline LDK::ChannelMonitorUpdateStatus update_persisted_channel(struct LDKOutPoint channel_funding_outpoint, struct LDKChannelMonitorUpdate monitor_update, const struct LDKChannelMonitor *NONNULL_PTR monitor); /** * Prevents the channel monitor from being loaded on startup. * @@ -7185,6 +7463,81 @@ public: const LDKChainMonitor* operator &() const { return &self; } const LDKChainMonitor* operator ->() const { return &self; } }; +class BlindedMessagePath { +private: + LDKBlindedMessagePath self; +public: + BlindedMessagePath(const BlindedMessagePath&) = delete; + BlindedMessagePath(BlindedMessagePath&& o) : self(o.self) { memset(&o, 0, sizeof(BlindedMessagePath)); } + BlindedMessagePath(LDKBlindedMessagePath&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBlindedMessagePath)); } + operator LDKBlindedMessagePath() && { LDKBlindedMessagePath res = self; memset(&self, 0, sizeof(LDKBlindedMessagePath)); return res; } + ~BlindedMessagePath() { BlindedMessagePath_free(self); } + BlindedMessagePath& operator=(BlindedMessagePath&& o) { BlindedMessagePath_free(self); self = o.self; memset(&o, 0, sizeof(BlindedMessagePath)); return *this; } + LDKBlindedMessagePath* operator &() { return &self; } + LDKBlindedMessagePath* operator ->() { return &self; } + const LDKBlindedMessagePath* operator &() const { return &self; } + const LDKBlindedMessagePath* operator ->() const { return &self; } +}; +class NextMessageHop { +private: + LDKNextMessageHop self; +public: + NextMessageHop(const NextMessageHop&) = delete; + NextMessageHop(NextMessageHop&& o) : self(o.self) { memset(&o, 0, sizeof(NextMessageHop)); } + NextMessageHop(LDKNextMessageHop&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKNextMessageHop)); } + operator LDKNextMessageHop() && { LDKNextMessageHop res = self; memset(&self, 0, sizeof(LDKNextMessageHop)); return res; } + ~NextMessageHop() { NextMessageHop_free(self); } + NextMessageHop& operator=(NextMessageHop&& o) { NextMessageHop_free(self); self = o.self; memset(&o, 0, sizeof(NextMessageHop)); return *this; } + LDKNextMessageHop* operator &() { return &self; } + LDKNextMessageHop* operator ->() { return &self; } + const LDKNextMessageHop* operator &() const { return &self; } + const LDKNextMessageHop* operator ->() const { return &self; } +}; +class MessageForwardNode { +private: + LDKMessageForwardNode self; +public: + MessageForwardNode(const MessageForwardNode&) = delete; + MessageForwardNode(MessageForwardNode&& o) : self(o.self) { memset(&o, 0, sizeof(MessageForwardNode)); } + MessageForwardNode(LDKMessageForwardNode&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKMessageForwardNode)); } + operator LDKMessageForwardNode() && { LDKMessageForwardNode res = self; memset(&self, 0, sizeof(LDKMessageForwardNode)); return res; } + ~MessageForwardNode() { MessageForwardNode_free(self); } + MessageForwardNode& operator=(MessageForwardNode&& o) { MessageForwardNode_free(self); self = o.self; memset(&o, 0, sizeof(MessageForwardNode)); return *this; } + LDKMessageForwardNode* operator &() { return &self; } + LDKMessageForwardNode* operator ->() { return &self; } + const LDKMessageForwardNode* operator &() const { return &self; } + const LDKMessageForwardNode* operator ->() const { return &self; } +}; +class MessageContext { +private: + LDKMessageContext self; +public: + MessageContext(const MessageContext&) = delete; + MessageContext(MessageContext&& o) : self(o.self) { memset(&o, 0, sizeof(MessageContext)); } + MessageContext(LDKMessageContext&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKMessageContext)); } + operator LDKMessageContext() && { LDKMessageContext res = self; memset(&self, 0, sizeof(LDKMessageContext)); return res; } + ~MessageContext() { MessageContext_free(self); } + MessageContext& operator=(MessageContext&& o) { MessageContext_free(self); self = o.self; memset(&o, 0, sizeof(MessageContext)); return *this; } + LDKMessageContext* operator &() { return &self; } + LDKMessageContext* operator ->() { return &self; } + const LDKMessageContext* operator &() const { return &self; } + const LDKMessageContext* operator ->() const { return &self; } +}; +class OffersContext { +private: + LDKOffersContext self; +public: + OffersContext(const OffersContext&) = delete; + OffersContext(OffersContext&& o) : self(o.self) { memset(&o, 0, sizeof(OffersContext)); } + OffersContext(LDKOffersContext&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKOffersContext)); } + operator LDKOffersContext() && { LDKOffersContext res = self; memset(&self, 0, sizeof(LDKOffersContext)); return res; } + ~OffersContext() { OffersContext_free(self); } + OffersContext& operator=(OffersContext&& o) { OffersContext_free(self); self = o.self; memset(&o, 0, sizeof(OffersContext)); return *this; } + LDKOffersContext* operator &() { return &self; } + LDKOffersContext* operator ->() { return &self; } + const LDKOffersContext* operator &() const { return &self; } + const LDKOffersContext* operator ->() const { return &self; } +}; class CResult_HtlcKeyDecodeErrorZ { private: LDKCResult_HtlcKeyDecodeErrorZ self; @@ -7245,21 +7598,6 @@ public: const LDKCResult_LockedChannelMonitorNoneZ* operator &() const { return &self; } const LDKCResult_LockedChannelMonitorNoneZ* operator ->() const { return &self; } }; -class CVec_C2Tuple_BlindedPayInfoBlindedPathZZ { -private: - LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ self; -public: - CVec_C2Tuple_BlindedPayInfoBlindedPathZZ(const CVec_C2Tuple_BlindedPayInfoBlindedPathZZ&) = delete; - CVec_C2Tuple_BlindedPayInfoBlindedPathZZ(CVec_C2Tuple_BlindedPayInfoBlindedPathZZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_C2Tuple_BlindedPayInfoBlindedPathZZ)); } - CVec_C2Tuple_BlindedPayInfoBlindedPathZZ(LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ)); } - operator LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ() && { LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ res = self; memset(&self, 0, sizeof(LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ)); return res; } - ~CVec_C2Tuple_BlindedPayInfoBlindedPathZZ() { CVec_C2Tuple_BlindedPayInfoBlindedPathZZ_free(self); } - CVec_C2Tuple_BlindedPayInfoBlindedPathZZ& operator=(CVec_C2Tuple_BlindedPayInfoBlindedPathZZ&& o) { CVec_C2Tuple_BlindedPayInfoBlindedPathZZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_C2Tuple_BlindedPayInfoBlindedPathZZ)); return *this; } - LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ* operator &() { return &self; } - LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ* operator ->() { return &self; } - const LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ* operator &() const { return &self; } - const LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ* operator ->() const { return &self; } -}; class CResult_PhantomRouteHintsDecodeErrorZ { private: LDKCResult_PhantomRouteHintsDecodeErrorZ self; @@ -7380,20 +7718,20 @@ public: const LDKCOption_MaxDustHTLCExposureZ* operator &() const { return &self; } const LDKCOption_MaxDustHTLCExposureZ* operator ->() const { return &self; } }; -class COption_OffersMessageZ { +class CResult_NoneSendErrorZ { private: - LDKCOption_OffersMessageZ self; + LDKCResult_NoneSendErrorZ 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; } + CResult_NoneSendErrorZ(const CResult_NoneSendErrorZ&) = delete; + CResult_NoneSendErrorZ(CResult_NoneSendErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_NoneSendErrorZ)); } + CResult_NoneSendErrorZ(LDKCResult_NoneSendErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_NoneSendErrorZ)); } + operator LDKCResult_NoneSendErrorZ() && { LDKCResult_NoneSendErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_NoneSendErrorZ)); return res; } + ~CResult_NoneSendErrorZ() { CResult_NoneSendErrorZ_free(self); } + CResult_NoneSendErrorZ& operator=(CResult_NoneSendErrorZ&& o) { CResult_NoneSendErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_NoneSendErrorZ)); return *this; } + LDKCResult_NoneSendErrorZ* operator &() { return &self; } + LDKCResult_NoneSendErrorZ* operator ->() { return &self; } + const LDKCResult_NoneSendErrorZ* operator &() const { return &self; } + const LDKCResult_NoneSendErrorZ* operator ->() const { return &self; } }; class CResult_CVec_u8ZPeerHandleErrorZ { private: @@ -7410,6 +7748,21 @@ public: const LDKCResult_CVec_u8ZPeerHandleErrorZ* operator &() const { return &self; } const LDKCResult_CVec_u8ZPeerHandleErrorZ* operator ->() const { return &self; } }; +class CResult_OnionPacketDecodeErrorZ { +private: + LDKCResult_OnionPacketDecodeErrorZ self; +public: + CResult_OnionPacketDecodeErrorZ(const CResult_OnionPacketDecodeErrorZ&) = delete; + CResult_OnionPacketDecodeErrorZ(CResult_OnionPacketDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_OnionPacketDecodeErrorZ)); } + CResult_OnionPacketDecodeErrorZ(LDKCResult_OnionPacketDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_OnionPacketDecodeErrorZ)); } + operator LDKCResult_OnionPacketDecodeErrorZ() && { LDKCResult_OnionPacketDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_OnionPacketDecodeErrorZ)); return res; } + ~CResult_OnionPacketDecodeErrorZ() { CResult_OnionPacketDecodeErrorZ_free(self); } + CResult_OnionPacketDecodeErrorZ& operator=(CResult_OnionPacketDecodeErrorZ&& o) { CResult_OnionPacketDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_OnionPacketDecodeErrorZ)); return *this; } + LDKCResult_OnionPacketDecodeErrorZ* operator &() { return &self; } + LDKCResult_OnionPacketDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_OnionPacketDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_OnionPacketDecodeErrorZ* operator ->() const { return &self; } +}; class COption_NetworkUpdateZ { private: LDKCOption_NetworkUpdateZ self; @@ -7440,21 +7793,6 @@ public: const LDKCOption_u64Z* operator &() const { return &self; } const LDKCOption_u64Z* operator ->() const { return &self; } }; -class CResult_OnionPacketDecodeErrorZ { -private: - LDKCResult_OnionPacketDecodeErrorZ self; -public: - CResult_OnionPacketDecodeErrorZ(const CResult_OnionPacketDecodeErrorZ&) = delete; - CResult_OnionPacketDecodeErrorZ(CResult_OnionPacketDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_OnionPacketDecodeErrorZ)); } - CResult_OnionPacketDecodeErrorZ(LDKCResult_OnionPacketDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_OnionPacketDecodeErrorZ)); } - operator LDKCResult_OnionPacketDecodeErrorZ() && { LDKCResult_OnionPacketDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_OnionPacketDecodeErrorZ)); return res; } - ~CResult_OnionPacketDecodeErrorZ() { CResult_OnionPacketDecodeErrorZ_free(self); } - CResult_OnionPacketDecodeErrorZ& operator=(CResult_OnionPacketDecodeErrorZ&& o) { CResult_OnionPacketDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_OnionPacketDecodeErrorZ)); return *this; } - LDKCResult_OnionPacketDecodeErrorZ* operator &() { return &self; } - LDKCResult_OnionPacketDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_OnionPacketDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_OnionPacketDecodeErrorZ* operator ->() const { return &self; } -}; class CResult_GossipTimestampFilterDecodeErrorZ { private: LDKCResult_GossipTimestampFilterDecodeErrorZ self; @@ -7470,6 +7808,21 @@ public: const LDKCResult_GossipTimestampFilterDecodeErrorZ* operator &() const { return &self; } const LDKCResult_GossipTimestampFilterDecodeErrorZ* operator ->() const { return &self; } }; +class C2Tuple_OnionMessageContentsResponseInstructionZ { +private: + LDKC2Tuple_OnionMessageContentsResponseInstructionZ self; +public: + C2Tuple_OnionMessageContentsResponseInstructionZ(const C2Tuple_OnionMessageContentsResponseInstructionZ&) = delete; + C2Tuple_OnionMessageContentsResponseInstructionZ(C2Tuple_OnionMessageContentsResponseInstructionZ&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_OnionMessageContentsResponseInstructionZ)); } + C2Tuple_OnionMessageContentsResponseInstructionZ(LDKC2Tuple_OnionMessageContentsResponseInstructionZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_OnionMessageContentsResponseInstructionZ)); } + operator LDKC2Tuple_OnionMessageContentsResponseInstructionZ() && { LDKC2Tuple_OnionMessageContentsResponseInstructionZ res = self; memset(&self, 0, sizeof(LDKC2Tuple_OnionMessageContentsResponseInstructionZ)); return res; } + ~C2Tuple_OnionMessageContentsResponseInstructionZ() { C2Tuple_OnionMessageContentsResponseInstructionZ_free(self); } + C2Tuple_OnionMessageContentsResponseInstructionZ& operator=(C2Tuple_OnionMessageContentsResponseInstructionZ&& o) { C2Tuple_OnionMessageContentsResponseInstructionZ_free(self); self = o.self; memset(&o, 0, sizeof(C2Tuple_OnionMessageContentsResponseInstructionZ)); return *this; } + LDKC2Tuple_OnionMessageContentsResponseInstructionZ* operator &() { return &self; } + LDKC2Tuple_OnionMessageContentsResponseInstructionZ* operator ->() { return &self; } + const LDKC2Tuple_OnionMessageContentsResponseInstructionZ* operator &() const { return &self; } + const LDKC2Tuple_OnionMessageContentsResponseInstructionZ* operator ->() const { return &self; } +}; class CResult_RouteHintDecodeErrorZ { private: LDKCResult_RouteHintDecodeErrorZ self; @@ -7635,35 +7988,35 @@ public: const LDKC2Tuple__u1632_u1632Z* operator &() const { return &self; } const LDKC2Tuple__u1632_u1632Z* operator ->() const { return &self; } }; -class CResult_CVec_StrZIOErrorZ { +class CVec_C2Tuple_OffersMessageMessageSendInstructionsZZ { private: - LDKCResult_CVec_StrZIOErrorZ self; + LDKCVec_C2Tuple_OffersMessageMessageSendInstructionsZZ self; public: - CResult_CVec_StrZIOErrorZ(const CResult_CVec_StrZIOErrorZ&) = delete; - CResult_CVec_StrZIOErrorZ(CResult_CVec_StrZIOErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_CVec_StrZIOErrorZ)); } - CResult_CVec_StrZIOErrorZ(LDKCResult_CVec_StrZIOErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_CVec_StrZIOErrorZ)); } - operator LDKCResult_CVec_StrZIOErrorZ() && { LDKCResult_CVec_StrZIOErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_CVec_StrZIOErrorZ)); return res; } - ~CResult_CVec_StrZIOErrorZ() { CResult_CVec_StrZIOErrorZ_free(self); } - CResult_CVec_StrZIOErrorZ& operator=(CResult_CVec_StrZIOErrorZ&& o) { CResult_CVec_StrZIOErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_CVec_StrZIOErrorZ)); return *this; } - LDKCResult_CVec_StrZIOErrorZ* operator &() { return &self; } - LDKCResult_CVec_StrZIOErrorZ* operator ->() { return &self; } - const LDKCResult_CVec_StrZIOErrorZ* operator &() const { return &self; } - const LDKCResult_CVec_StrZIOErrorZ* operator ->() const { return &self; } + CVec_C2Tuple_OffersMessageMessageSendInstructionsZZ(const CVec_C2Tuple_OffersMessageMessageSendInstructionsZZ&) = delete; + CVec_C2Tuple_OffersMessageMessageSendInstructionsZZ(CVec_C2Tuple_OffersMessageMessageSendInstructionsZZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_C2Tuple_OffersMessageMessageSendInstructionsZZ)); } + CVec_C2Tuple_OffersMessageMessageSendInstructionsZZ(LDKCVec_C2Tuple_OffersMessageMessageSendInstructionsZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_C2Tuple_OffersMessageMessageSendInstructionsZZ)); } + operator LDKCVec_C2Tuple_OffersMessageMessageSendInstructionsZZ() && { LDKCVec_C2Tuple_OffersMessageMessageSendInstructionsZZ res = self; memset(&self, 0, sizeof(LDKCVec_C2Tuple_OffersMessageMessageSendInstructionsZZ)); return res; } + ~CVec_C2Tuple_OffersMessageMessageSendInstructionsZZ() { CVec_C2Tuple_OffersMessageMessageSendInstructionsZZ_free(self); } + CVec_C2Tuple_OffersMessageMessageSendInstructionsZZ& operator=(CVec_C2Tuple_OffersMessageMessageSendInstructionsZZ&& o) { CVec_C2Tuple_OffersMessageMessageSendInstructionsZZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_C2Tuple_OffersMessageMessageSendInstructionsZZ)); return *this; } + LDKCVec_C2Tuple_OffersMessageMessageSendInstructionsZZ* operator &() { return &self; } + LDKCVec_C2Tuple_OffersMessageMessageSendInstructionsZZ* operator ->() { return &self; } + const LDKCVec_C2Tuple_OffersMessageMessageSendInstructionsZZ* operator &() const { return &self; } + const LDKCVec_C2Tuple_OffersMessageMessageSendInstructionsZZ* operator ->() const { return &self; } }; -class COption_ECDSASignatureZ { +class C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ { private: - LDKCOption_ECDSASignatureZ self; + LDKC2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ self; public: - COption_ECDSASignatureZ(const COption_ECDSASignatureZ&) = delete; - COption_ECDSASignatureZ(COption_ECDSASignatureZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_ECDSASignatureZ)); } - COption_ECDSASignatureZ(LDKCOption_ECDSASignatureZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_ECDSASignatureZ)); } - operator LDKCOption_ECDSASignatureZ() && { LDKCOption_ECDSASignatureZ res = self; memset(&self, 0, sizeof(LDKCOption_ECDSASignatureZ)); return res; } - ~COption_ECDSASignatureZ() { COption_ECDSASignatureZ_free(self); } - COption_ECDSASignatureZ& operator=(COption_ECDSASignatureZ&& o) { COption_ECDSASignatureZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_ECDSASignatureZ)); return *this; } - LDKCOption_ECDSASignatureZ* operator &() { return &self; } - LDKCOption_ECDSASignatureZ* operator ->() { return &self; } - const LDKCOption_ECDSASignatureZ* operator &() const { return &self; } - const LDKCOption_ECDSASignatureZ* operator ->() const { return &self; } + C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ(const C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ&) = delete; + C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ(C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ)); } + C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ(LDKC2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ)); } + operator LDKC2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ() && { LDKC2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ res = self; memset(&self, 0, sizeof(LDKC2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ)); return res; } + ~C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ() { C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ_free(self); } + C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ& operator=(C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ&& o) { C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ_free(self); self = o.self; memset(&o, 0, sizeof(C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ)); return *this; } + LDKC2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ* operator &() { return &self; } + LDKC2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ* operator ->() { return &self; } + const LDKC2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ* operator &() const { return &self; } + const LDKC2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ* operator ->() const { return &self; } }; class CResult_TransactionNoneZ { private: @@ -7680,20 +8033,20 @@ public: const LDKCResult_TransactionNoneZ* operator &() const { return &self; } const LDKCResult_TransactionNoneZ* operator ->() const { return &self; } }; -class CResult_ClosingSignedFeeRangeDecodeErrorZ { +class CResult_CVec_StrZIOErrorZ { private: - LDKCResult_ClosingSignedFeeRangeDecodeErrorZ self; + LDKCResult_CVec_StrZIOErrorZ 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_CVec_StrZIOErrorZ(const CResult_CVec_StrZIOErrorZ&) = delete; + CResult_CVec_StrZIOErrorZ(CResult_CVec_StrZIOErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_CVec_StrZIOErrorZ)); } + CResult_CVec_StrZIOErrorZ(LDKCResult_CVec_StrZIOErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_CVec_StrZIOErrorZ)); } + operator LDKCResult_CVec_StrZIOErrorZ() && { LDKCResult_CVec_StrZIOErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_CVec_StrZIOErrorZ)); return res; } + ~CResult_CVec_StrZIOErrorZ() { CResult_CVec_StrZIOErrorZ_free(self); } + CResult_CVec_StrZIOErrorZ& operator=(CResult_CVec_StrZIOErrorZ&& o) { CResult_CVec_StrZIOErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_CVec_StrZIOErrorZ)); return *this; } + LDKCResult_CVec_StrZIOErrorZ* operator &() { return &self; } + LDKCResult_CVec_StrZIOErrorZ* operator ->() { return &self; } + const LDKCResult_CVec_StrZIOErrorZ* operator &() const { return &self; } + const LDKCResult_CVec_StrZIOErrorZ* operator ->() const { return &self; } }; class CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ { private: @@ -7710,6 +8063,36 @@ public: const LDKCResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ* operator &() const { return &self; } const LDKCResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ* operator ->() const { return &self; } }; +class COption_ECDSASignatureZ { +private: + LDKCOption_ECDSASignatureZ self; +public: + COption_ECDSASignatureZ(const COption_ECDSASignatureZ&) = delete; + COption_ECDSASignatureZ(COption_ECDSASignatureZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_ECDSASignatureZ)); } + COption_ECDSASignatureZ(LDKCOption_ECDSASignatureZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_ECDSASignatureZ)); } + operator LDKCOption_ECDSASignatureZ() && { LDKCOption_ECDSASignatureZ res = self; memset(&self, 0, sizeof(LDKCOption_ECDSASignatureZ)); return res; } + ~COption_ECDSASignatureZ() { COption_ECDSASignatureZ_free(self); } + COption_ECDSASignatureZ& operator=(COption_ECDSASignatureZ&& o) { COption_ECDSASignatureZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_ECDSASignatureZ)); return *this; } + LDKCOption_ECDSASignatureZ* operator &() { return &self; } + LDKCOption_ECDSASignatureZ* operator ->() { return &self; } + const LDKCOption_ECDSASignatureZ* operator &() const { return &self; } + const LDKCOption_ECDSASignatureZ* operator ->() const { return &self; } +}; +class CResult_ClosingSignedFeeRangeDecodeErrorZ { +private: + LDKCResult_ClosingSignedFeeRangeDecodeErrorZ 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; } +}; class CResult_CommitmentSignedDecodeErrorZ { private: LDKCResult_CommitmentSignedDecodeErrorZ self; @@ -8145,6 +8528,21 @@ public: const LDKCResult_PendingHTLCInfoInboundHTLCErrZ* operator &() const { return &self; } const LDKCResult_PendingHTLCInfoInboundHTLCErrZ* operator ->() const { return &self; } }; +class CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ { +private: + LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ self; +public: + CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ(const CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ&) = delete; + CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ(CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ)); } + CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ(LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ)); } + operator LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ() && { LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ)); return res; } + ~CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ() { CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ_free(self); } + CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ& operator=(CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ&& o) { CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ)); return *this; } + LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ* operator &() { return &self; } + LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ* operator ->() { return &self; } + const LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ* operator &() const { return &self; } + const LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ* operator ->() const { return &self; } +}; class CResult_PendingHTLCInfoDecodeErrorZ { private: LDKCResult_PendingHTLCInfoDecodeErrorZ self; @@ -8160,6 +8558,21 @@ public: const LDKCResult_PendingHTLCInfoDecodeErrorZ* operator &() const { return &self; } const LDKCResult_PendingHTLCInfoDecodeErrorZ* operator ->() const { return &self; } }; +class CResult_SpliceInitDecodeErrorZ { +private: + LDKCResult_SpliceInitDecodeErrorZ self; +public: + CResult_SpliceInitDecodeErrorZ(const CResult_SpliceInitDecodeErrorZ&) = delete; + CResult_SpliceInitDecodeErrorZ(CResult_SpliceInitDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_SpliceInitDecodeErrorZ)); } + CResult_SpliceInitDecodeErrorZ(LDKCResult_SpliceInitDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_SpliceInitDecodeErrorZ)); } + operator LDKCResult_SpliceInitDecodeErrorZ() && { LDKCResult_SpliceInitDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_SpliceInitDecodeErrorZ)); return res; } + ~CResult_SpliceInitDecodeErrorZ() { CResult_SpliceInitDecodeErrorZ_free(self); } + CResult_SpliceInitDecodeErrorZ& operator=(CResult_SpliceInitDecodeErrorZ&& o) { CResult_SpliceInitDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_SpliceInitDecodeErrorZ)); return *this; } + LDKCResult_SpliceInitDecodeErrorZ* operator &() { return &self; } + LDKCResult_SpliceInitDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_SpliceInitDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_SpliceInitDecodeErrorZ* operator ->() const { return &self; } +}; class CResult_HTLCOutputInCommitmentDecodeErrorZ { private: LDKCResult_HTLCOutputInCommitmentDecodeErrorZ self; @@ -8175,36 +8588,6 @@ public: 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 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 CVec_RouteHopZ { private: LDKCVec_RouteHopZ self; @@ -8220,20 +8603,20 @@ public: const LDKCVec_RouteHopZ* operator &() const { return &self; } const LDKCVec_RouteHopZ* operator ->() const { return &self; } }; -class C2Tuple_PublicKeyCVec_SocketAddressZZ { +class CResult_ShutdownScriptInvalidShutdownScriptZ { private: - LDKC2Tuple_PublicKeyCVec_SocketAddressZZ self; + LDKCResult_ShutdownScriptInvalidShutdownScriptZ self; public: - C2Tuple_PublicKeyCVec_SocketAddressZZ(const C2Tuple_PublicKeyCVec_SocketAddressZZ&) = delete; - C2Tuple_PublicKeyCVec_SocketAddressZZ(C2Tuple_PublicKeyCVec_SocketAddressZZ&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_PublicKeyCVec_SocketAddressZZ)); } - C2Tuple_PublicKeyCVec_SocketAddressZZ(LDKC2Tuple_PublicKeyCVec_SocketAddressZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_PublicKeyCVec_SocketAddressZZ)); } - operator LDKC2Tuple_PublicKeyCVec_SocketAddressZZ() && { LDKC2Tuple_PublicKeyCVec_SocketAddressZZ res = self; memset(&self, 0, sizeof(LDKC2Tuple_PublicKeyCVec_SocketAddressZZ)); return res; } - ~C2Tuple_PublicKeyCVec_SocketAddressZZ() { C2Tuple_PublicKeyCVec_SocketAddressZZ_free(self); } - C2Tuple_PublicKeyCVec_SocketAddressZZ& operator=(C2Tuple_PublicKeyCVec_SocketAddressZZ&& o) { C2Tuple_PublicKeyCVec_SocketAddressZZ_free(self); self = o.self; memset(&o, 0, sizeof(C2Tuple_PublicKeyCVec_SocketAddressZZ)); return *this; } - LDKC2Tuple_PublicKeyCVec_SocketAddressZZ* operator &() { return &self; } - LDKC2Tuple_PublicKeyCVec_SocketAddressZZ* operator ->() { return &self; } - const LDKC2Tuple_PublicKeyCVec_SocketAddressZZ* operator &() const { return &self; } - const LDKC2Tuple_PublicKeyCVec_SocketAddressZZ* operator ->() const { return &self; } + 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 CResult_CVec_UtxoZNoneZ { private: @@ -8265,20 +8648,20 @@ public: const LDKCResult_CVec_u8ZIOErrorZ* operator &() const { return &self; } const LDKCResult_CVec_u8ZIOErrorZ* operator ->() const { return &self; } }; -class CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ { +class COption_HTLCDestinationZ { private: - LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ self; + LDKCOption_HTLCDestinationZ self; public: - CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ(const CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ&) = delete; - CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ(CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ)); } - CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ(LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ)); } - operator LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ() && { LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ)); return res; } - ~CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ() { CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ_free(self); } - CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ& operator=(CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ&& o) { CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ)); return *this; } - LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ* operator &() { return &self; } - LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ* operator ->() { return &self; } - const LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ* operator &() const { return &self; } - const LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ* 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 CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ { private: @@ -8295,36 +8678,6 @@ public: const LDKCResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ* operator &() const { return &self; } const LDKCResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ* operator ->() const { return &self; } }; -class CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ { -private: - LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ self; -public: - CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ(const CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ&) = delete; - CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ(CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ)); } - CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ(LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ)); } - operator LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ() && { LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ res = self; memset(&self, 0, sizeof(LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ)); return res; } - ~CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ() { CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ_free(self); } - CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ& operator=(CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ&& o) { CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ)); return *this; } - LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ* operator &() { return &self; } - LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ* operator ->() { return &self; } - const LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ* operator &() const { return &self; } - const LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ* operator ->() const { return &self; } -}; -class C3Tuple_OffersMessageDestinationBlindedPathZ { -private: - LDKC3Tuple_OffersMessageDestinationBlindedPathZ self; -public: - C3Tuple_OffersMessageDestinationBlindedPathZ(const C3Tuple_OffersMessageDestinationBlindedPathZ&) = delete; - C3Tuple_OffersMessageDestinationBlindedPathZ(C3Tuple_OffersMessageDestinationBlindedPathZ&& o) : self(o.self) { memset(&o, 0, sizeof(C3Tuple_OffersMessageDestinationBlindedPathZ)); } - C3Tuple_OffersMessageDestinationBlindedPathZ(LDKC3Tuple_OffersMessageDestinationBlindedPathZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC3Tuple_OffersMessageDestinationBlindedPathZ)); } - operator LDKC3Tuple_OffersMessageDestinationBlindedPathZ() && { LDKC3Tuple_OffersMessageDestinationBlindedPathZ res = self; memset(&self, 0, sizeof(LDKC3Tuple_OffersMessageDestinationBlindedPathZ)); return res; } - ~C3Tuple_OffersMessageDestinationBlindedPathZ() { C3Tuple_OffersMessageDestinationBlindedPathZ_free(self); } - C3Tuple_OffersMessageDestinationBlindedPathZ& operator=(C3Tuple_OffersMessageDestinationBlindedPathZ&& o) { C3Tuple_OffersMessageDestinationBlindedPathZ_free(self); self = o.self; memset(&o, 0, sizeof(C3Tuple_OffersMessageDestinationBlindedPathZ)); return *this; } - LDKC3Tuple_OffersMessageDestinationBlindedPathZ* operator &() { return &self; } - LDKC3Tuple_OffersMessageDestinationBlindedPathZ* operator ->() { return &self; } - const LDKC3Tuple_OffersMessageDestinationBlindedPathZ* operator &() const { return &self; } - const LDKC3Tuple_OffersMessageDestinationBlindedPathZ* operator ->() const { return &self; } -}; class CVec_ThirtyTwoBytesZ { private: LDKCVec_ThirtyTwoBytesZ self; @@ -8400,6 +8753,21 @@ public: const LDKCResult_SchnorrSignatureNoneZ* operator &() const { return &self; } const LDKCResult_SchnorrSignatureNoneZ* operator ->() const { return &self; } }; +class C2Tuple_ReleaseHeldHtlcResponseInstructionZ { +private: + LDKC2Tuple_ReleaseHeldHtlcResponseInstructionZ self; +public: + C2Tuple_ReleaseHeldHtlcResponseInstructionZ(const C2Tuple_ReleaseHeldHtlcResponseInstructionZ&) = delete; + C2Tuple_ReleaseHeldHtlcResponseInstructionZ(C2Tuple_ReleaseHeldHtlcResponseInstructionZ&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_ReleaseHeldHtlcResponseInstructionZ)); } + C2Tuple_ReleaseHeldHtlcResponseInstructionZ(LDKC2Tuple_ReleaseHeldHtlcResponseInstructionZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_ReleaseHeldHtlcResponseInstructionZ)); } + operator LDKC2Tuple_ReleaseHeldHtlcResponseInstructionZ() && { LDKC2Tuple_ReleaseHeldHtlcResponseInstructionZ res = self; memset(&self, 0, sizeof(LDKC2Tuple_ReleaseHeldHtlcResponseInstructionZ)); return res; } + ~C2Tuple_ReleaseHeldHtlcResponseInstructionZ() { C2Tuple_ReleaseHeldHtlcResponseInstructionZ_free(self); } + C2Tuple_ReleaseHeldHtlcResponseInstructionZ& operator=(C2Tuple_ReleaseHeldHtlcResponseInstructionZ&& o) { C2Tuple_ReleaseHeldHtlcResponseInstructionZ_free(self); self = o.self; memset(&o, 0, sizeof(C2Tuple_ReleaseHeldHtlcResponseInstructionZ)); return *this; } + LDKC2Tuple_ReleaseHeldHtlcResponseInstructionZ* operator &() { return &self; } + LDKC2Tuple_ReleaseHeldHtlcResponseInstructionZ* operator ->() { return &self; } + const LDKC2Tuple_ReleaseHeldHtlcResponseInstructionZ* operator &() const { return &self; } + const LDKC2Tuple_ReleaseHeldHtlcResponseInstructionZ* operator ->() const { return &self; } +}; class CResult_CounterpartyCommitmentSecretsDecodeErrorZ { private: LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ self; @@ -8460,21 +8828,6 @@ public: const LDKCVec_RouteHintHopZ* operator &() const { return &self; } const LDKCVec_RouteHintHopZ* operator ->() const { return &self; } }; -class CVec_C3Tuple_OffersMessageDestinationBlindedPathZZ { -private: - LDKCVec_C3Tuple_OffersMessageDestinationBlindedPathZZ self; -public: - CVec_C3Tuple_OffersMessageDestinationBlindedPathZZ(const CVec_C3Tuple_OffersMessageDestinationBlindedPathZZ&) = delete; - CVec_C3Tuple_OffersMessageDestinationBlindedPathZZ(CVec_C3Tuple_OffersMessageDestinationBlindedPathZZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_C3Tuple_OffersMessageDestinationBlindedPathZZ)); } - CVec_C3Tuple_OffersMessageDestinationBlindedPathZZ(LDKCVec_C3Tuple_OffersMessageDestinationBlindedPathZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_C3Tuple_OffersMessageDestinationBlindedPathZZ)); } - operator LDKCVec_C3Tuple_OffersMessageDestinationBlindedPathZZ() && { LDKCVec_C3Tuple_OffersMessageDestinationBlindedPathZZ res = self; memset(&self, 0, sizeof(LDKCVec_C3Tuple_OffersMessageDestinationBlindedPathZZ)); return res; } - ~CVec_C3Tuple_OffersMessageDestinationBlindedPathZZ() { CVec_C3Tuple_OffersMessageDestinationBlindedPathZZ_free(self); } - CVec_C3Tuple_OffersMessageDestinationBlindedPathZZ& operator=(CVec_C3Tuple_OffersMessageDestinationBlindedPathZZ&& o) { CVec_C3Tuple_OffersMessageDestinationBlindedPathZZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_C3Tuple_OffersMessageDestinationBlindedPathZZ)); return *this; } - LDKCVec_C3Tuple_OffersMessageDestinationBlindedPathZZ* operator &() { return &self; } - LDKCVec_C3Tuple_OffersMessageDestinationBlindedPathZZ* operator ->() { return &self; } - const LDKCVec_C3Tuple_OffersMessageDestinationBlindedPathZZ* operator &() const { return &self; } - const LDKCVec_C3Tuple_OffersMessageDestinationBlindedPathZZ* operator ->() const { return &self; } -}; class CResult_UntrustedStringDecodeErrorZ { private: LDKCResult_UntrustedStringDecodeErrorZ self; @@ -8505,21 +8858,6 @@ public: const LDKCVec_C3Tuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZZ* operator &() const { return &self; } const LDKCVec_C3Tuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZZ* 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; @@ -8535,6 +8873,21 @@ public: const LDKCResult_PaymentParametersDecodeErrorZ* operator &() const { return &self; } const LDKCResult_PaymentParametersDecodeErrorZ* operator ->() const { return &self; } }; +class CResult_DelayedPaymentBasepointDecodeErrorZ { +private: + LDKCResult_DelayedPaymentBasepointDecodeErrorZ self; +public: + CResult_DelayedPaymentBasepointDecodeErrorZ(const CResult_DelayedPaymentBasepointDecodeErrorZ&) = delete; + CResult_DelayedPaymentBasepointDecodeErrorZ(CResult_DelayedPaymentBasepointDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_DelayedPaymentBasepointDecodeErrorZ)); } + CResult_DelayedPaymentBasepointDecodeErrorZ(LDKCResult_DelayedPaymentBasepointDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_DelayedPaymentBasepointDecodeErrorZ)); } + operator LDKCResult_DelayedPaymentBasepointDecodeErrorZ() && { LDKCResult_DelayedPaymentBasepointDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_DelayedPaymentBasepointDecodeErrorZ)); return res; } + ~CResult_DelayedPaymentBasepointDecodeErrorZ() { CResult_DelayedPaymentBasepointDecodeErrorZ_free(self); } + CResult_DelayedPaymentBasepointDecodeErrorZ& operator=(CResult_DelayedPaymentBasepointDecodeErrorZ&& o) { CResult_DelayedPaymentBasepointDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_DelayedPaymentBasepointDecodeErrorZ)); return *this; } + LDKCResult_DelayedPaymentBasepointDecodeErrorZ* operator &() { return &self; } + LDKCResult_DelayedPaymentBasepointDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_DelayedPaymentBasepointDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_DelayedPaymentBasepointDecodeErrorZ* operator ->() const { return &self; } +}; class C2Tuple_ThirtyTwoBytesChannelMonitorZ { private: LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ self; @@ -8565,21 +8918,6 @@ public: const LDKCOption_U128Z* operator &() const { return &self; } const LDKCOption_U128Z* operator ->() const { return &self; } }; -class CResult_DelayedPaymentBasepointDecodeErrorZ { -private: - LDKCResult_DelayedPaymentBasepointDecodeErrorZ self; -public: - CResult_DelayedPaymentBasepointDecodeErrorZ(const CResult_DelayedPaymentBasepointDecodeErrorZ&) = delete; - CResult_DelayedPaymentBasepointDecodeErrorZ(CResult_DelayedPaymentBasepointDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_DelayedPaymentBasepointDecodeErrorZ)); } - CResult_DelayedPaymentBasepointDecodeErrorZ(LDKCResult_DelayedPaymentBasepointDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_DelayedPaymentBasepointDecodeErrorZ)); } - operator LDKCResult_DelayedPaymentBasepointDecodeErrorZ() && { LDKCResult_DelayedPaymentBasepointDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_DelayedPaymentBasepointDecodeErrorZ)); return res; } - ~CResult_DelayedPaymentBasepointDecodeErrorZ() { CResult_DelayedPaymentBasepointDecodeErrorZ_free(self); } - CResult_DelayedPaymentBasepointDecodeErrorZ& operator=(CResult_DelayedPaymentBasepointDecodeErrorZ&& o) { CResult_DelayedPaymentBasepointDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_DelayedPaymentBasepointDecodeErrorZ)); return *this; } - LDKCResult_DelayedPaymentBasepointDecodeErrorZ* operator &() { return &self; } - LDKCResult_DelayedPaymentBasepointDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_DelayedPaymentBasepointDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_DelayedPaymentBasepointDecodeErrorZ* operator ->() const { return &self; } -}; class C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ { private: LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ self; @@ -8595,6 +8933,21 @@ public: const LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ* operator &() const { return &self; } const LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ* operator ->() const { return &self; } }; +class CVec_MessageForwardNodeZ { +private: + LDKCVec_MessageForwardNodeZ self; +public: + CVec_MessageForwardNodeZ(const CVec_MessageForwardNodeZ&) = delete; + CVec_MessageForwardNodeZ(CVec_MessageForwardNodeZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_MessageForwardNodeZ)); } + CVec_MessageForwardNodeZ(LDKCVec_MessageForwardNodeZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_MessageForwardNodeZ)); } + operator LDKCVec_MessageForwardNodeZ() && { LDKCVec_MessageForwardNodeZ res = self; memset(&self, 0, sizeof(LDKCVec_MessageForwardNodeZ)); return res; } + ~CVec_MessageForwardNodeZ() { CVec_MessageForwardNodeZ_free(self); } + CVec_MessageForwardNodeZ& operator=(CVec_MessageForwardNodeZ&& o) { CVec_MessageForwardNodeZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_MessageForwardNodeZ)); return *this; } + LDKCVec_MessageForwardNodeZ* operator &() { return &self; } + LDKCVec_MessageForwardNodeZ* operator ->() { return &self; } + const LDKCVec_MessageForwardNodeZ* operator &() const { return &self; } + const LDKCVec_MessageForwardNodeZ* operator ->() const { return &self; } +}; class CResult_TxAckRbfDecodeErrorZ { private: LDKCResult_TxAckRbfDecodeErrorZ self; @@ -8640,6 +8993,21 @@ public: const LDKCOption_UtxoLookupZ* operator &() const { return &self; } const LDKCOption_UtxoLookupZ* operator ->() const { return &self; } }; +class CResult__u832NoneZ { +private: + LDKCResult__u832NoneZ self; +public: + CResult__u832NoneZ(const CResult__u832NoneZ&) = delete; + CResult__u832NoneZ(CResult__u832NoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult__u832NoneZ)); } + CResult__u832NoneZ(LDKCResult__u832NoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult__u832NoneZ)); } + operator LDKCResult__u832NoneZ() && { LDKCResult__u832NoneZ res = self; memset(&self, 0, sizeof(LDKCResult__u832NoneZ)); return res; } + ~CResult__u832NoneZ() { CResult__u832NoneZ_free(self); } + CResult__u832NoneZ& operator=(CResult__u832NoneZ&& o) { CResult__u832NoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult__u832NoneZ)); return *this; } + LDKCResult__u832NoneZ* operator &() { return &self; } + LDKCResult__u832NoneZ* operator ->() { return &self; } + const LDKCResult__u832NoneZ* operator &() const { return &self; } + const LDKCResult__u832NoneZ* operator ->() const { return &self; } +}; class CResult_PongDecodeErrorZ { private: LDKCResult_PongDecodeErrorZ self; @@ -8670,21 +9038,6 @@ public: const LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* operator &() const { return &self; } const LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* operator ->() const { return &self; } }; -class C2Tuple_OutPointCVec_MonitorUpdateIdZZ { -private: - LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ self; -public: - C2Tuple_OutPointCVec_MonitorUpdateIdZZ(const C2Tuple_OutPointCVec_MonitorUpdateIdZZ&) = delete; - C2Tuple_OutPointCVec_MonitorUpdateIdZZ(C2Tuple_OutPointCVec_MonitorUpdateIdZZ&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_OutPointCVec_MonitorUpdateIdZZ)); } - C2Tuple_OutPointCVec_MonitorUpdateIdZZ(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ)); } - operator LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ() && { LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ res = self; memset(&self, 0, sizeof(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ)); return res; } - ~C2Tuple_OutPointCVec_MonitorUpdateIdZZ() { C2Tuple_OutPointCVec_MonitorUpdateIdZZ_free(self); } - C2Tuple_OutPointCVec_MonitorUpdateIdZZ& operator=(C2Tuple_OutPointCVec_MonitorUpdateIdZZ&& o) { C2Tuple_OutPointCVec_MonitorUpdateIdZZ_free(self); self = o.self; memset(&o, 0, sizeof(C2Tuple_OutPointCVec_MonitorUpdateIdZZ)); return *this; } - LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* operator &() { return &self; } - LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* operator ->() { return &self; } - const LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* operator &() const { return &self; } - const LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* operator ->() const { return &self; } -}; class CResult_ChannelIdAPIErrorZ { private: LDKCResult_ChannelIdAPIErrorZ self; @@ -8760,21 +9113,6 @@ public: const LDKCResult_ChannelTransactionParametersDecodeErrorZ* operator &() const { return &self; } const LDKCResult_ChannelTransactionParametersDecodeErrorZ* operator ->() const { return &self; } }; -class CResult_WriteableEcdsaChannelSignerDecodeErrorZ { -private: - LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ self; -public: - CResult_WriteableEcdsaChannelSignerDecodeErrorZ(const CResult_WriteableEcdsaChannelSignerDecodeErrorZ&) = delete; - CResult_WriteableEcdsaChannelSignerDecodeErrorZ(CResult_WriteableEcdsaChannelSignerDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_WriteableEcdsaChannelSignerDecodeErrorZ)); } - CResult_WriteableEcdsaChannelSignerDecodeErrorZ(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ)); } - operator LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ() && { LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ)); return res; } - ~CResult_WriteableEcdsaChannelSignerDecodeErrorZ() { CResult_WriteableEcdsaChannelSignerDecodeErrorZ_free(self); } - CResult_WriteableEcdsaChannelSignerDecodeErrorZ& operator=(CResult_WriteableEcdsaChannelSignerDecodeErrorZ&& o) { CResult_WriteableEcdsaChannelSignerDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_WriteableEcdsaChannelSignerDecodeErrorZ)); return *this; } - LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* operator &() { return &self; } - LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* operator ->() const { return &self; } -}; class CResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ { private: LDKCResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ self; @@ -8820,6 +9158,21 @@ public: const LDKCResult_InFlightHtlcsDecodeErrorZ* operator &() const { return &self; } const LDKCResult_InFlightHtlcsDecodeErrorZ* operator ->() const { return &self; } }; +class CResult_CommitmentSignedBatchDecodeErrorZ { +private: + LDKCResult_CommitmentSignedBatchDecodeErrorZ self; +public: + CResult_CommitmentSignedBatchDecodeErrorZ(const CResult_CommitmentSignedBatchDecodeErrorZ&) = delete; + CResult_CommitmentSignedBatchDecodeErrorZ(CResult_CommitmentSignedBatchDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_CommitmentSignedBatchDecodeErrorZ)); } + CResult_CommitmentSignedBatchDecodeErrorZ(LDKCResult_CommitmentSignedBatchDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_CommitmentSignedBatchDecodeErrorZ)); } + operator LDKCResult_CommitmentSignedBatchDecodeErrorZ() && { LDKCResult_CommitmentSignedBatchDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_CommitmentSignedBatchDecodeErrorZ)); return res; } + ~CResult_CommitmentSignedBatchDecodeErrorZ() { CResult_CommitmentSignedBatchDecodeErrorZ_free(self); } + CResult_CommitmentSignedBatchDecodeErrorZ& operator=(CResult_CommitmentSignedBatchDecodeErrorZ&& o) { CResult_CommitmentSignedBatchDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_CommitmentSignedBatchDecodeErrorZ)); return *this; } + LDKCResult_CommitmentSignedBatchDecodeErrorZ* operator &() { return &self; } + LDKCResult_CommitmentSignedBatchDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_CommitmentSignedBatchDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_CommitmentSignedBatchDecodeErrorZ* operator ->() const { return &self; } +}; class CResult_COption_HTLCDestinationZDecodeErrorZ { private: LDKCResult_COption_HTLCDestinationZDecodeErrorZ self; @@ -8865,21 +9218,6 @@ public: const LDKCResult_ThirtyTwoBytesNoneZ* operator &() const { return &self; } const LDKCResult_ThirtyTwoBytesNoneZ* operator ->() const { return &self; } }; -class C3Tuple_OnionMessageContentsDestinationBlindedPathZ { -private: - LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ self; -public: - C3Tuple_OnionMessageContentsDestinationBlindedPathZ(const C3Tuple_OnionMessageContentsDestinationBlindedPathZ&) = delete; - C3Tuple_OnionMessageContentsDestinationBlindedPathZ(C3Tuple_OnionMessageContentsDestinationBlindedPathZ&& o) : self(o.self) { memset(&o, 0, sizeof(C3Tuple_OnionMessageContentsDestinationBlindedPathZ)); } - C3Tuple_OnionMessageContentsDestinationBlindedPathZ(LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ)); } - operator LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ() && { LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ res = self; memset(&self, 0, sizeof(LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ)); return res; } - ~C3Tuple_OnionMessageContentsDestinationBlindedPathZ() { C3Tuple_OnionMessageContentsDestinationBlindedPathZ_free(self); } - C3Tuple_OnionMessageContentsDestinationBlindedPathZ& operator=(C3Tuple_OnionMessageContentsDestinationBlindedPathZ&& o) { C3Tuple_OnionMessageContentsDestinationBlindedPathZ_free(self); self = o.self; memset(&o, 0, sizeof(C3Tuple_OnionMessageContentsDestinationBlindedPathZ)); return *this; } - LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ* operator &() { return &self; } - LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ* operator ->() { return &self; } - const LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ* operator &() const { return &self; } - const LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ* operator ->() const { return &self; } -}; class C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ { private: LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ self; @@ -8910,20 +9248,20 @@ public: const LDKCResult_SendSuccessSendErrorZ* operator &() const { return &self; } const LDKCResult_SendSuccessSendErrorZ* operator ->() const { return &self; } }; -class CVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ { +class CResult_NoneReplayEventZ { private: - LDKCVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ self; + LDKCResult_NoneReplayEventZ self; public: - CVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ(const CVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ&) = delete; - CVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ(CVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ)); } - CVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ(LDKCVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ)); } - operator LDKCVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ() && { LDKCVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ res = self; memset(&self, 0, sizeof(LDKCVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ)); return res; } - ~CVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ() { CVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ_free(self); } - CVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ& operator=(CVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ&& o) { CVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ)); return *this; } - LDKCVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ* operator &() { return &self; } - LDKCVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ* operator ->() { return &self; } - const LDKCVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ* operator &() const { return &self; } - const LDKCVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ* operator ->() const { return &self; } + CResult_NoneReplayEventZ(const CResult_NoneReplayEventZ&) = delete; + CResult_NoneReplayEventZ(CResult_NoneReplayEventZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_NoneReplayEventZ)); } + CResult_NoneReplayEventZ(LDKCResult_NoneReplayEventZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_NoneReplayEventZ)); } + operator LDKCResult_NoneReplayEventZ() && { LDKCResult_NoneReplayEventZ res = self; memset(&self, 0, sizeof(LDKCResult_NoneReplayEventZ)); return res; } + ~CResult_NoneReplayEventZ() { CResult_NoneReplayEventZ_free(self); } + CResult_NoneReplayEventZ& operator=(CResult_NoneReplayEventZ&& o) { CResult_NoneReplayEventZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_NoneReplayEventZ)); return *this; } + LDKCResult_NoneReplayEventZ* operator &() { return &self; } + LDKCResult_NoneReplayEventZ* operator ->() { return &self; } + const LDKCResult_NoneReplayEventZ* operator &() const { return &self; } + const LDKCResult_NoneReplayEventZ* operator ->() const { return &self; } }; class C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ { private: @@ -8985,21 +9323,6 @@ public: const LDKCResult_FixedPenaltyScorerDecodeErrorZ* operator &() const { return &self; } const LDKCResult_FixedPenaltyScorerDecodeErrorZ* operator ->() const { return &self; } }; -class CVec_BlindedPathZ { -private: - LDKCVec_BlindedPathZ self; -public: - CVec_BlindedPathZ(const CVec_BlindedPathZ&) = delete; - CVec_BlindedPathZ(CVec_BlindedPathZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_BlindedPathZ)); } - CVec_BlindedPathZ(LDKCVec_BlindedPathZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_BlindedPathZ)); } - operator LDKCVec_BlindedPathZ() && { LDKCVec_BlindedPathZ res = self; memset(&self, 0, sizeof(LDKCVec_BlindedPathZ)); return res; } - ~CVec_BlindedPathZ() { CVec_BlindedPathZ_free(self); } - CVec_BlindedPathZ& operator=(CVec_BlindedPathZ&& o) { CVec_BlindedPathZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_BlindedPathZ)); return *this; } - LDKCVec_BlindedPathZ* operator &() { return &self; } - LDKCVec_BlindedPathZ* operator ->() { return &self; } - const LDKCVec_BlindedPathZ* operator &() const { return &self; } - const LDKCVec_BlindedPathZ* operator ->() const { return &self; } -}; class CResult_NonePeerHandleErrorZ { private: LDKCResult_NonePeerHandleErrorZ self; @@ -9015,21 +9338,6 @@ public: const LDKCResult_NonePeerHandleErrorZ* operator &() const { return &self; } const LDKCResult_NonePeerHandleErrorZ* operator ->() const { return &self; } }; -class CResult_FinalOnionHopDataDecodeErrorZ { -private: - LDKCResult_FinalOnionHopDataDecodeErrorZ self; -public: - CResult_FinalOnionHopDataDecodeErrorZ(const CResult_FinalOnionHopDataDecodeErrorZ&) = delete; - CResult_FinalOnionHopDataDecodeErrorZ(CResult_FinalOnionHopDataDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_FinalOnionHopDataDecodeErrorZ)); } - CResult_FinalOnionHopDataDecodeErrorZ(LDKCResult_FinalOnionHopDataDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_FinalOnionHopDataDecodeErrorZ)); } - operator LDKCResult_FinalOnionHopDataDecodeErrorZ() && { LDKCResult_FinalOnionHopDataDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_FinalOnionHopDataDecodeErrorZ)); return res; } - ~CResult_FinalOnionHopDataDecodeErrorZ() { CResult_FinalOnionHopDataDecodeErrorZ_free(self); } - CResult_FinalOnionHopDataDecodeErrorZ& operator=(CResult_FinalOnionHopDataDecodeErrorZ&& o) { CResult_FinalOnionHopDataDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_FinalOnionHopDataDecodeErrorZ)); return *this; } - LDKCResult_FinalOnionHopDataDecodeErrorZ* operator &() { return &self; } - LDKCResult_FinalOnionHopDataDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_FinalOnionHopDataDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_FinalOnionHopDataDecodeErrorZ* operator ->() const { return &self; } -}; class CResult_TrustedCommitmentTransactionNoneZ { private: LDKCResult_TrustedCommitmentTransactionNoneZ self; @@ -9045,6 +9353,21 @@ public: const LDKCResult_TrustedCommitmentTransactionNoneZ* operator &() const { return &self; } const LDKCResult_TrustedCommitmentTransactionNoneZ* operator ->() const { return &self; } }; +class CResult_FinalOnionHopDataDecodeErrorZ { +private: + LDKCResult_FinalOnionHopDataDecodeErrorZ self; +public: + CResult_FinalOnionHopDataDecodeErrorZ(const CResult_FinalOnionHopDataDecodeErrorZ&) = delete; + CResult_FinalOnionHopDataDecodeErrorZ(CResult_FinalOnionHopDataDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_FinalOnionHopDataDecodeErrorZ)); } + CResult_FinalOnionHopDataDecodeErrorZ(LDKCResult_FinalOnionHopDataDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_FinalOnionHopDataDecodeErrorZ)); } + operator LDKCResult_FinalOnionHopDataDecodeErrorZ() && { LDKCResult_FinalOnionHopDataDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_FinalOnionHopDataDecodeErrorZ)); return res; } + ~CResult_FinalOnionHopDataDecodeErrorZ() { CResult_FinalOnionHopDataDecodeErrorZ_free(self); } + CResult_FinalOnionHopDataDecodeErrorZ& operator=(CResult_FinalOnionHopDataDecodeErrorZ&& o) { CResult_FinalOnionHopDataDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_FinalOnionHopDataDecodeErrorZ)); return *this; } + LDKCResult_FinalOnionHopDataDecodeErrorZ* operator &() { return &self; } + LDKCResult_FinalOnionHopDataDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_FinalOnionHopDataDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_FinalOnionHopDataDecodeErrorZ* operator ->() const { return &self; } +}; class CResult_COption_EventZDecodeErrorZ { private: LDKCResult_COption_EventZDecodeErrorZ self; @@ -9060,39 +9383,9 @@ public: const LDKCResult_COption_EventZDecodeErrorZ* operator &() const { return &self; } const LDKCResult_COption_EventZDecodeErrorZ* operator ->() const { return &self; } }; -class CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ { +class COption_SocketAddressZ { private: - LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ self; -public: - CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ(const CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ&) = delete; - CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ(CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ)); } - CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ(LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ)); } - operator LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ() && { LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ)); return res; } - ~CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ() { CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ_free(self); } - CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ& operator=(CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ&& o) { CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ)); return *this; } - LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ* operator &() { return &self; } - LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ* operator ->() { return &self; } - const LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ* operator &() const { return &self; } - const LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ* operator ->() const { return &self; } -}; -class CResult_PaymentFailureReasonDecodeErrorZ { -private: - LDKCResult_PaymentFailureReasonDecodeErrorZ self; -public: - CResult_PaymentFailureReasonDecodeErrorZ(const CResult_PaymentFailureReasonDecodeErrorZ&) = delete; - CResult_PaymentFailureReasonDecodeErrorZ(CResult_PaymentFailureReasonDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_PaymentFailureReasonDecodeErrorZ)); } - CResult_PaymentFailureReasonDecodeErrorZ(LDKCResult_PaymentFailureReasonDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_PaymentFailureReasonDecodeErrorZ)); } - operator LDKCResult_PaymentFailureReasonDecodeErrorZ() && { LDKCResult_PaymentFailureReasonDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_PaymentFailureReasonDecodeErrorZ)); return res; } - ~CResult_PaymentFailureReasonDecodeErrorZ() { CResult_PaymentFailureReasonDecodeErrorZ_free(self); } - CResult_PaymentFailureReasonDecodeErrorZ& operator=(CResult_PaymentFailureReasonDecodeErrorZ&& o) { CResult_PaymentFailureReasonDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_PaymentFailureReasonDecodeErrorZ)); return *this; } - LDKCResult_PaymentFailureReasonDecodeErrorZ* operator &() { return &self; } - LDKCResult_PaymentFailureReasonDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_PaymentFailureReasonDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_PaymentFailureReasonDecodeErrorZ* operator ->() const { return &self; } -}; -class COption_SocketAddressZ { -private: - LDKCOption_SocketAddressZ self; + LDKCOption_SocketAddressZ self; public: COption_SocketAddressZ(const COption_SocketAddressZ&) = delete; COption_SocketAddressZ(COption_SocketAddressZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_SocketAddressZ)); } @@ -9315,6 +9608,21 @@ public: const LDKCResult_COption_TypeZDecodeErrorZ* operator &() const { return &self; } const LDKCResult_COption_TypeZDecodeErrorZ* operator ->() const { return &self; } }; +class CResult_OfferDecodeErrorZ { +private: + LDKCResult_OfferDecodeErrorZ self; +public: + CResult_OfferDecodeErrorZ(const CResult_OfferDecodeErrorZ&) = delete; + CResult_OfferDecodeErrorZ(CResult_OfferDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_OfferDecodeErrorZ)); } + CResult_OfferDecodeErrorZ(LDKCResult_OfferDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_OfferDecodeErrorZ)); } + operator LDKCResult_OfferDecodeErrorZ() && { LDKCResult_OfferDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_OfferDecodeErrorZ)); return res; } + ~CResult_OfferDecodeErrorZ() { CResult_OfferDecodeErrorZ_free(self); } + CResult_OfferDecodeErrorZ& operator=(CResult_OfferDecodeErrorZ&& o) { CResult_OfferDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_OfferDecodeErrorZ)); return *this; } + LDKCResult_OfferDecodeErrorZ* operator &() { return &self; } + LDKCResult_OfferDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_OfferDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_OfferDecodeErrorZ* operator ->() const { return &self; } +}; class CResult_COption_PathFailureZDecodeErrorZ { private: LDKCResult_COption_PathFailureZDecodeErrorZ self; @@ -9345,6 +9653,21 @@ public: const LDKCResult_Bolt11InvoiceSignOrCreationErrorZ* operator &() const { return &self; } const LDKCResult_Bolt11InvoiceSignOrCreationErrorZ* operator ->() const { return &self; } }; +class CResult_BlindedMessagePathNoneZ { +private: + LDKCResult_BlindedMessagePathNoneZ self; +public: + CResult_BlindedMessagePathNoneZ(const CResult_BlindedMessagePathNoneZ&) = delete; + CResult_BlindedMessagePathNoneZ(CResult_BlindedMessagePathNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_BlindedMessagePathNoneZ)); } + CResult_BlindedMessagePathNoneZ(LDKCResult_BlindedMessagePathNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_BlindedMessagePathNoneZ)); } + operator LDKCResult_BlindedMessagePathNoneZ() && { LDKCResult_BlindedMessagePathNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_BlindedMessagePathNoneZ)); return res; } + ~CResult_BlindedMessagePathNoneZ() { CResult_BlindedMessagePathNoneZ_free(self); } + CResult_BlindedMessagePathNoneZ& operator=(CResult_BlindedMessagePathNoneZ&& o) { CResult_BlindedMessagePathNoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_BlindedMessagePathNoneZ)); return *this; } + LDKCResult_BlindedMessagePathNoneZ* operator &() { return &self; } + LDKCResult_BlindedMessagePathNoneZ* operator ->() { return &self; } + const LDKCResult_BlindedMessagePathNoneZ* operator &() const { return &self; } + const LDKCResult_BlindedMessagePathNoneZ* operator ->() const { return &self; } +}; class CResult_UpdateFailHTLCDecodeErrorZ { private: LDKCResult_UpdateFailHTLCDecodeErrorZ self; @@ -9360,20 +9683,20 @@ public: const LDKCResult_UpdateFailHTLCDecodeErrorZ* operator &() const { return &self; } const LDKCResult_UpdateFailHTLCDecodeErrorZ* operator ->() const { return &self; } }; -class CResult_CVec_BlindedPathZNoneZ { +class CResult_BlindedPaymentPathNoneZ { private: - LDKCResult_CVec_BlindedPathZNoneZ self; + LDKCResult_BlindedPaymentPathNoneZ self; public: - CResult_CVec_BlindedPathZNoneZ(const CResult_CVec_BlindedPathZNoneZ&) = delete; - CResult_CVec_BlindedPathZNoneZ(CResult_CVec_BlindedPathZNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_CVec_BlindedPathZNoneZ)); } - CResult_CVec_BlindedPathZNoneZ(LDKCResult_CVec_BlindedPathZNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_CVec_BlindedPathZNoneZ)); } - operator LDKCResult_CVec_BlindedPathZNoneZ() && { LDKCResult_CVec_BlindedPathZNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_CVec_BlindedPathZNoneZ)); return res; } - ~CResult_CVec_BlindedPathZNoneZ() { CResult_CVec_BlindedPathZNoneZ_free(self); } - CResult_CVec_BlindedPathZNoneZ& operator=(CResult_CVec_BlindedPathZNoneZ&& o) { CResult_CVec_BlindedPathZNoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_CVec_BlindedPathZNoneZ)); return *this; } - LDKCResult_CVec_BlindedPathZNoneZ* operator &() { return &self; } - LDKCResult_CVec_BlindedPathZNoneZ* operator ->() { return &self; } - const LDKCResult_CVec_BlindedPathZNoneZ* operator &() const { return &self; } - const LDKCResult_CVec_BlindedPathZNoneZ* operator ->() const { return &self; } + CResult_BlindedPaymentPathNoneZ(const CResult_BlindedPaymentPathNoneZ&) = delete; + CResult_BlindedPaymentPathNoneZ(CResult_BlindedPaymentPathNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_BlindedPaymentPathNoneZ)); } + CResult_BlindedPaymentPathNoneZ(LDKCResult_BlindedPaymentPathNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_BlindedPaymentPathNoneZ)); } + operator LDKCResult_BlindedPaymentPathNoneZ() && { LDKCResult_BlindedPaymentPathNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_BlindedPaymentPathNoneZ)); return res; } + ~CResult_BlindedPaymentPathNoneZ() { CResult_BlindedPaymentPathNoneZ_free(self); } + CResult_BlindedPaymentPathNoneZ& operator=(CResult_BlindedPaymentPathNoneZ&& o) { CResult_BlindedPaymentPathNoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_BlindedPaymentPathNoneZ)); return *this; } + LDKCResult_BlindedPaymentPathNoneZ* operator &() { return &self; } + LDKCResult_BlindedPaymentPathNoneZ* operator ->() { return &self; } + const LDKCResult_BlindedPaymentPathNoneZ* operator &() const { return &self; } + const LDKCResult_BlindedPaymentPathNoneZ* operator ->() const { return &self; } }; class CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ { private: @@ -9480,6 +9803,36 @@ public: const LDKC2Tuple__u832u16Z* operator &() const { return &self; } const LDKC2Tuple__u832u16Z* operator ->() const { return &self; } }; +class CResult_BlindedMessagePathDecodeErrorZ { +private: + LDKCResult_BlindedMessagePathDecodeErrorZ self; +public: + CResult_BlindedMessagePathDecodeErrorZ(const CResult_BlindedMessagePathDecodeErrorZ&) = delete; + CResult_BlindedMessagePathDecodeErrorZ(CResult_BlindedMessagePathDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_BlindedMessagePathDecodeErrorZ)); } + CResult_BlindedMessagePathDecodeErrorZ(LDKCResult_BlindedMessagePathDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_BlindedMessagePathDecodeErrorZ)); } + operator LDKCResult_BlindedMessagePathDecodeErrorZ() && { LDKCResult_BlindedMessagePathDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_BlindedMessagePathDecodeErrorZ)); return res; } + ~CResult_BlindedMessagePathDecodeErrorZ() { CResult_BlindedMessagePathDecodeErrorZ_free(self); } + CResult_BlindedMessagePathDecodeErrorZ& operator=(CResult_BlindedMessagePathDecodeErrorZ&& o) { CResult_BlindedMessagePathDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_BlindedMessagePathDecodeErrorZ)); return *this; } + LDKCResult_BlindedMessagePathDecodeErrorZ* operator &() { return &self; } + LDKCResult_BlindedMessagePathDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_BlindedMessagePathDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_BlindedMessagePathDecodeErrorZ* operator ->() const { return &self; } +}; +class CResult_CVec_BlindedMessagePathZNoneZ { +private: + LDKCResult_CVec_BlindedMessagePathZNoneZ self; +public: + CResult_CVec_BlindedMessagePathZNoneZ(const CResult_CVec_BlindedMessagePathZNoneZ&) = delete; + CResult_CVec_BlindedMessagePathZNoneZ(CResult_CVec_BlindedMessagePathZNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_CVec_BlindedMessagePathZNoneZ)); } + CResult_CVec_BlindedMessagePathZNoneZ(LDKCResult_CVec_BlindedMessagePathZNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_CVec_BlindedMessagePathZNoneZ)); } + operator LDKCResult_CVec_BlindedMessagePathZNoneZ() && { LDKCResult_CVec_BlindedMessagePathZNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_CVec_BlindedMessagePathZNoneZ)); return res; } + ~CResult_CVec_BlindedMessagePathZNoneZ() { CResult_CVec_BlindedMessagePathZNoneZ_free(self); } + CResult_CVec_BlindedMessagePathZNoneZ& operator=(CResult_CVec_BlindedMessagePathZNoneZ&& o) { CResult_CVec_BlindedMessagePathZNoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_CVec_BlindedMessagePathZNoneZ)); return *this; } + LDKCResult_CVec_BlindedMessagePathZNoneZ* operator &() { return &self; } + LDKCResult_CVec_BlindedMessagePathZNoneZ* operator ->() { return &self; } + const LDKCResult_CVec_BlindedMessagePathZNoneZ* operator &() const { return &self; } + const LDKCResult_CVec_BlindedMessagePathZNoneZ* operator ->() const { return &self; } +}; class COption_BigEndianScalarZ { private: LDKCOption_BigEndianScalarZ self; @@ -9525,20 +9878,20 @@ public: const LDKCResult_PublicKeySecp256k1ErrorZ* operator &() const { return &self; } const LDKCResult_PublicKeySecp256k1ErrorZ* operator ->() const { return &self; } }; -class CResult_CVec_ECDSASignatureZNoneZ { +class C2Tuple_OnionMessageContentsMessageSendInstructionsZ { private: - LDKCResult_CVec_ECDSASignatureZNoneZ self; + LDKC2Tuple_OnionMessageContentsMessageSendInstructionsZ self; public: - CResult_CVec_ECDSASignatureZNoneZ(const CResult_CVec_ECDSASignatureZNoneZ&) = delete; - CResult_CVec_ECDSASignatureZNoneZ(CResult_CVec_ECDSASignatureZNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_CVec_ECDSASignatureZNoneZ)); } - CResult_CVec_ECDSASignatureZNoneZ(LDKCResult_CVec_ECDSASignatureZNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_CVec_ECDSASignatureZNoneZ)); } - operator LDKCResult_CVec_ECDSASignatureZNoneZ() && { LDKCResult_CVec_ECDSASignatureZNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_CVec_ECDSASignatureZNoneZ)); return res; } - ~CResult_CVec_ECDSASignatureZNoneZ() { CResult_CVec_ECDSASignatureZNoneZ_free(self); } - CResult_CVec_ECDSASignatureZNoneZ& operator=(CResult_CVec_ECDSASignatureZNoneZ&& o) { CResult_CVec_ECDSASignatureZNoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_CVec_ECDSASignatureZNoneZ)); return *this; } - LDKCResult_CVec_ECDSASignatureZNoneZ* operator &() { return &self; } - LDKCResult_CVec_ECDSASignatureZNoneZ* operator ->() { return &self; } - const LDKCResult_CVec_ECDSASignatureZNoneZ* operator &() const { return &self; } - const LDKCResult_CVec_ECDSASignatureZNoneZ* operator ->() const { return &self; } + C2Tuple_OnionMessageContentsMessageSendInstructionsZ(const C2Tuple_OnionMessageContentsMessageSendInstructionsZ&) = delete; + C2Tuple_OnionMessageContentsMessageSendInstructionsZ(C2Tuple_OnionMessageContentsMessageSendInstructionsZ&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_OnionMessageContentsMessageSendInstructionsZ)); } + C2Tuple_OnionMessageContentsMessageSendInstructionsZ(LDKC2Tuple_OnionMessageContentsMessageSendInstructionsZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_OnionMessageContentsMessageSendInstructionsZ)); } + operator LDKC2Tuple_OnionMessageContentsMessageSendInstructionsZ() && { LDKC2Tuple_OnionMessageContentsMessageSendInstructionsZ res = self; memset(&self, 0, sizeof(LDKC2Tuple_OnionMessageContentsMessageSendInstructionsZ)); return res; } + ~C2Tuple_OnionMessageContentsMessageSendInstructionsZ() { C2Tuple_OnionMessageContentsMessageSendInstructionsZ_free(self); } + C2Tuple_OnionMessageContentsMessageSendInstructionsZ& operator=(C2Tuple_OnionMessageContentsMessageSendInstructionsZ&& o) { C2Tuple_OnionMessageContentsMessageSendInstructionsZ_free(self); self = o.self; memset(&o, 0, sizeof(C2Tuple_OnionMessageContentsMessageSendInstructionsZ)); return *this; } + LDKC2Tuple_OnionMessageContentsMessageSendInstructionsZ* operator &() { return &self; } + LDKC2Tuple_OnionMessageContentsMessageSendInstructionsZ* operator ->() { return &self; } + const LDKC2Tuple_OnionMessageContentsMessageSendInstructionsZ* operator &() const { return &self; } + const LDKC2Tuple_OnionMessageContentsMessageSendInstructionsZ* operator ->() const { return &self; } }; class CVec_BlindedHopZ { private: @@ -9555,6 +9908,36 @@ public: const LDKCVec_BlindedHopZ* operator &() const { return &self; } const LDKCVec_BlindedHopZ* operator ->() const { return &self; } }; +class CResult_ReleaseHeldHtlcDecodeErrorZ { +private: + LDKCResult_ReleaseHeldHtlcDecodeErrorZ self; +public: + CResult_ReleaseHeldHtlcDecodeErrorZ(const CResult_ReleaseHeldHtlcDecodeErrorZ&) = delete; + CResult_ReleaseHeldHtlcDecodeErrorZ(CResult_ReleaseHeldHtlcDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_ReleaseHeldHtlcDecodeErrorZ)); } + CResult_ReleaseHeldHtlcDecodeErrorZ(LDKCResult_ReleaseHeldHtlcDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_ReleaseHeldHtlcDecodeErrorZ)); } + operator LDKCResult_ReleaseHeldHtlcDecodeErrorZ() && { LDKCResult_ReleaseHeldHtlcDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_ReleaseHeldHtlcDecodeErrorZ)); return res; } + ~CResult_ReleaseHeldHtlcDecodeErrorZ() { CResult_ReleaseHeldHtlcDecodeErrorZ_free(self); } + CResult_ReleaseHeldHtlcDecodeErrorZ& operator=(CResult_ReleaseHeldHtlcDecodeErrorZ&& o) { CResult_ReleaseHeldHtlcDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_ReleaseHeldHtlcDecodeErrorZ)); return *this; } + LDKCResult_ReleaseHeldHtlcDecodeErrorZ* operator &() { return &self; } + LDKCResult_ReleaseHeldHtlcDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_ReleaseHeldHtlcDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_ReleaseHeldHtlcDecodeErrorZ* operator ->() const { return &self; } +}; +class CResult_CVec_ECDSASignatureZNoneZ { +private: + LDKCResult_CVec_ECDSASignatureZNoneZ self; +public: + CResult_CVec_ECDSASignatureZNoneZ(const CResult_CVec_ECDSASignatureZNoneZ&) = delete; + CResult_CVec_ECDSASignatureZNoneZ(CResult_CVec_ECDSASignatureZNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_CVec_ECDSASignatureZNoneZ)); } + CResult_CVec_ECDSASignatureZNoneZ(LDKCResult_CVec_ECDSASignatureZNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_CVec_ECDSASignatureZNoneZ)); } + operator LDKCResult_CVec_ECDSASignatureZNoneZ() && { LDKCResult_CVec_ECDSASignatureZNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_CVec_ECDSASignatureZNoneZ)); return res; } + ~CResult_CVec_ECDSASignatureZNoneZ() { CResult_CVec_ECDSASignatureZNoneZ_free(self); } + CResult_CVec_ECDSASignatureZNoneZ& operator=(CResult_CVec_ECDSASignatureZNoneZ&& o) { CResult_CVec_ECDSASignatureZNoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_CVec_ECDSASignatureZNoneZ)); return *this; } + LDKCResult_CVec_ECDSASignatureZNoneZ* operator &() { return &self; } + LDKCResult_CVec_ECDSASignatureZNoneZ* operator ->() { return &self; } + const LDKCResult_CVec_ECDSASignatureZNoneZ* operator &() const { return &self; } + const LDKCResult_CVec_ECDSASignatureZNoneZ* operator ->() const { return &self; } +}; class CResult_COption_ClosureReasonZDecodeErrorZ { private: LDKCResult_COption_ClosureReasonZDecodeErrorZ self; @@ -9570,36 +9953,6 @@ public: const LDKCResult_COption_ClosureReasonZDecodeErrorZ* operator &() const { return &self; } const LDKCResult_COption_ClosureReasonZDecodeErrorZ* 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 C2Tuple_BestBlockOutputSweeperZ { -private: - LDKC2Tuple_BestBlockOutputSweeperZ self; -public: - C2Tuple_BestBlockOutputSweeperZ(const C2Tuple_BestBlockOutputSweeperZ&) = delete; - C2Tuple_BestBlockOutputSweeperZ(C2Tuple_BestBlockOutputSweeperZ&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_BestBlockOutputSweeperZ)); } - C2Tuple_BestBlockOutputSweeperZ(LDKC2Tuple_BestBlockOutputSweeperZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_BestBlockOutputSweeperZ)); } - operator LDKC2Tuple_BestBlockOutputSweeperZ() && { LDKC2Tuple_BestBlockOutputSweeperZ res = self; memset(&self, 0, sizeof(LDKC2Tuple_BestBlockOutputSweeperZ)); return res; } - ~C2Tuple_BestBlockOutputSweeperZ() { C2Tuple_BestBlockOutputSweeperZ_free(self); } - C2Tuple_BestBlockOutputSweeperZ& operator=(C2Tuple_BestBlockOutputSweeperZ&& o) { C2Tuple_BestBlockOutputSweeperZ_free(self); self = o.self; memset(&o, 0, sizeof(C2Tuple_BestBlockOutputSweeperZ)); return *this; } - LDKC2Tuple_BestBlockOutputSweeperZ* operator &() { return &self; } - LDKC2Tuple_BestBlockOutputSweeperZ* operator ->() { return &self; } - const LDKC2Tuple_BestBlockOutputSweeperZ* operator &() const { return &self; } - const LDKC2Tuple_BestBlockOutputSweeperZ* operator ->() const { return &self; } -}; class C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ { private: LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ self; @@ -9615,6 +9968,21 @@ public: const LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* operator &() const { return &self; } const LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* operator ->() const { return &self; } }; +class CResult_NonceDecodeErrorZ { +private: + LDKCResult_NonceDecodeErrorZ self; +public: + CResult_NonceDecodeErrorZ(const CResult_NonceDecodeErrorZ&) = delete; + CResult_NonceDecodeErrorZ(CResult_NonceDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_NonceDecodeErrorZ)); } + CResult_NonceDecodeErrorZ(LDKCResult_NonceDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_NonceDecodeErrorZ)); } + operator LDKCResult_NonceDecodeErrorZ() && { LDKCResult_NonceDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_NonceDecodeErrorZ)); return res; } + ~CResult_NonceDecodeErrorZ() { CResult_NonceDecodeErrorZ_free(self); } + CResult_NonceDecodeErrorZ& operator=(CResult_NonceDecodeErrorZ&& o) { CResult_NonceDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_NonceDecodeErrorZ)); return *this; } + LDKCResult_NonceDecodeErrorZ* operator &() { return &self; } + LDKCResult_NonceDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_NonceDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_NonceDecodeErrorZ* operator ->() const { return &self; } +}; class CResult_RouteParametersDecodeErrorZ { private: LDKCResult_RouteParametersDecodeErrorZ self; @@ -9645,6 +10013,21 @@ public: const LDKCResult_PrivateRouteCreationErrorZ* operator &() const { return &self; } const LDKCResult_PrivateRouteCreationErrorZ* 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 CResult_NodeAliasDecodeErrorZ { private: LDKCResult_NodeAliasDecodeErrorZ self; @@ -9660,6 +10043,36 @@ public: const LDKCResult_NodeAliasDecodeErrorZ* operator &() const { return &self; } const LDKCResult_NodeAliasDecodeErrorZ* operator ->() const { return &self; } }; +class C2Tuple_BestBlockOutputSweeperZ { +private: + LDKC2Tuple_BestBlockOutputSweeperZ self; +public: + C2Tuple_BestBlockOutputSweeperZ(const C2Tuple_BestBlockOutputSweeperZ&) = delete; + C2Tuple_BestBlockOutputSweeperZ(C2Tuple_BestBlockOutputSweeperZ&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_BestBlockOutputSweeperZ)); } + C2Tuple_BestBlockOutputSweeperZ(LDKC2Tuple_BestBlockOutputSweeperZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_BestBlockOutputSweeperZ)); } + operator LDKC2Tuple_BestBlockOutputSweeperZ() && { LDKC2Tuple_BestBlockOutputSweeperZ res = self; memset(&self, 0, sizeof(LDKC2Tuple_BestBlockOutputSweeperZ)); return res; } + ~C2Tuple_BestBlockOutputSweeperZ() { C2Tuple_BestBlockOutputSweeperZ_free(self); } + C2Tuple_BestBlockOutputSweeperZ& operator=(C2Tuple_BestBlockOutputSweeperZ&& o) { C2Tuple_BestBlockOutputSweeperZ_free(self); self = o.self; memset(&o, 0, sizeof(C2Tuple_BestBlockOutputSweeperZ)); return *this; } + LDKC2Tuple_BestBlockOutputSweeperZ* operator &() { return &self; } + LDKC2Tuple_BestBlockOutputSweeperZ* operator ->() { return &self; } + const LDKC2Tuple_BestBlockOutputSweeperZ* operator &() const { return &self; } + const LDKC2Tuple_BestBlockOutputSweeperZ* operator ->() const { return &self; } +}; +class C2Tuple_OutPointCVec_u64ZZ { +private: + LDKC2Tuple_OutPointCVec_u64ZZ self; +public: + C2Tuple_OutPointCVec_u64ZZ(const C2Tuple_OutPointCVec_u64ZZ&) = delete; + C2Tuple_OutPointCVec_u64ZZ(C2Tuple_OutPointCVec_u64ZZ&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_OutPointCVec_u64ZZ)); } + C2Tuple_OutPointCVec_u64ZZ(LDKC2Tuple_OutPointCVec_u64ZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_OutPointCVec_u64ZZ)); } + operator LDKC2Tuple_OutPointCVec_u64ZZ() && { LDKC2Tuple_OutPointCVec_u64ZZ res = self; memset(&self, 0, sizeof(LDKC2Tuple_OutPointCVec_u64ZZ)); return res; } + ~C2Tuple_OutPointCVec_u64ZZ() { C2Tuple_OutPointCVec_u64ZZ_free(self); } + C2Tuple_OutPointCVec_u64ZZ& operator=(C2Tuple_OutPointCVec_u64ZZ&& o) { C2Tuple_OutPointCVec_u64ZZ_free(self); self = o.self; memset(&o, 0, sizeof(C2Tuple_OutPointCVec_u64ZZ)); return *this; } + LDKC2Tuple_OutPointCVec_u64ZZ* operator &() { return &self; } + LDKC2Tuple_OutPointCVec_u64ZZ* operator ->() { return &self; } + const LDKC2Tuple_OutPointCVec_u64ZZ* operator &() const { return &self; } + const LDKC2Tuple_OutPointCVec_u64ZZ* operator ->() const { return &self; } +}; class CVec_UpdateFulfillHTLCZ { private: LDKCVec_UpdateFulfillHTLCZ self; @@ -9840,20 +10253,20 @@ public: const LDKCOption_PathFailureZ* operator &() const { return &self; } const LDKCOption_PathFailureZ* operator ->() const { return &self; } }; -class CResult_StrSecp256k1ErrorZ { +class COption_MessageContextZ { private: - LDKCResult_StrSecp256k1ErrorZ self; + LDKCOption_MessageContextZ self; public: - CResult_StrSecp256k1ErrorZ(const CResult_StrSecp256k1ErrorZ&) = delete; - CResult_StrSecp256k1ErrorZ(CResult_StrSecp256k1ErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_StrSecp256k1ErrorZ)); } - CResult_StrSecp256k1ErrorZ(LDKCResult_StrSecp256k1ErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_StrSecp256k1ErrorZ)); } - operator LDKCResult_StrSecp256k1ErrorZ() && { LDKCResult_StrSecp256k1ErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_StrSecp256k1ErrorZ)); return res; } - ~CResult_StrSecp256k1ErrorZ() { CResult_StrSecp256k1ErrorZ_free(self); } - CResult_StrSecp256k1ErrorZ& operator=(CResult_StrSecp256k1ErrorZ&& o) { CResult_StrSecp256k1ErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_StrSecp256k1ErrorZ)); return *this; } - LDKCResult_StrSecp256k1ErrorZ* operator &() { return &self; } - LDKCResult_StrSecp256k1ErrorZ* operator ->() { return &self; } - const LDKCResult_StrSecp256k1ErrorZ* operator &() const { return &self; } - const LDKCResult_StrSecp256k1ErrorZ* operator ->() const { return &self; } + COption_MessageContextZ(const COption_MessageContextZ&) = delete; + COption_MessageContextZ(COption_MessageContextZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_MessageContextZ)); } + COption_MessageContextZ(LDKCOption_MessageContextZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_MessageContextZ)); } + operator LDKCOption_MessageContextZ() && { LDKCOption_MessageContextZ res = self; memset(&self, 0, sizeof(LDKCOption_MessageContextZ)); return res; } + ~COption_MessageContextZ() { COption_MessageContextZ_free(self); } + COption_MessageContextZ& operator=(COption_MessageContextZ&& o) { COption_MessageContextZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_MessageContextZ)); return *this; } + LDKCOption_MessageContextZ* operator &() { return &self; } + LDKCOption_MessageContextZ* operator ->() { return &self; } + const LDKCOption_MessageContextZ* operator &() const { return &self; } + const LDKCOption_MessageContextZ* operator ->() const { return &self; } }; class CVec_ECDSASignatureZ { private: @@ -9960,6 +10373,21 @@ public: const LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* operator &() const { return &self; } const LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* operator ->() const { return &self; } }; +class CVec_PaymentForwardNodeZ { +private: + LDKCVec_PaymentForwardNodeZ self; +public: + CVec_PaymentForwardNodeZ(const CVec_PaymentForwardNodeZ&) = delete; + CVec_PaymentForwardNodeZ(CVec_PaymentForwardNodeZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_PaymentForwardNodeZ)); } + CVec_PaymentForwardNodeZ(LDKCVec_PaymentForwardNodeZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_PaymentForwardNodeZ)); } + operator LDKCVec_PaymentForwardNodeZ() && { LDKCVec_PaymentForwardNodeZ res = self; memset(&self, 0, sizeof(LDKCVec_PaymentForwardNodeZ)); return res; } + ~CVec_PaymentForwardNodeZ() { CVec_PaymentForwardNodeZ_free(self); } + CVec_PaymentForwardNodeZ& operator=(CVec_PaymentForwardNodeZ&& o) { CVec_PaymentForwardNodeZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_PaymentForwardNodeZ)); return *this; } + LDKCVec_PaymentForwardNodeZ* operator &() { return &self; } + LDKCVec_PaymentForwardNodeZ* operator ->() { return &self; } + const LDKCVec_PaymentForwardNodeZ* operator &() const { return &self; } + const LDKCVec_PaymentForwardNodeZ* operator ->() const { return &self; } +}; class CResult_TrackedSpendableOutputDecodeErrorZ { private: LDKCResult_TrackedSpendableOutputDecodeErrorZ self; @@ -9990,6 +10418,21 @@ public: const LDKCVec_SpendableOutputDescriptorZ* operator &() const { return &self; } const LDKCVec_SpendableOutputDescriptorZ* operator ->() const { return &self; } }; +class CResult_ResponderDecodeErrorZ { +private: + LDKCResult_ResponderDecodeErrorZ self; +public: + CResult_ResponderDecodeErrorZ(const CResult_ResponderDecodeErrorZ&) = delete; + CResult_ResponderDecodeErrorZ(CResult_ResponderDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_ResponderDecodeErrorZ)); } + CResult_ResponderDecodeErrorZ(LDKCResult_ResponderDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_ResponderDecodeErrorZ)); } + operator LDKCResult_ResponderDecodeErrorZ() && { LDKCResult_ResponderDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_ResponderDecodeErrorZ)); return res; } + ~CResult_ResponderDecodeErrorZ() { CResult_ResponderDecodeErrorZ_free(self); } + CResult_ResponderDecodeErrorZ& operator=(CResult_ResponderDecodeErrorZ&& o) { CResult_ResponderDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_ResponderDecodeErrorZ)); return *this; } + LDKCResult_ResponderDecodeErrorZ* operator &() { return &self; } + LDKCResult_ResponderDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_ResponderDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_ResponderDecodeErrorZ* operator ->() const { return &self; } +}; class C2Tuple_OutPointCVec_u8ZZ { private: LDKC2Tuple_OutPointCVec_u8ZZ self; @@ -10080,20 +10523,20 @@ public: const LDKCResult_TxAddInputDecodeErrorZ* operator &() const { return &self; } const LDKCResult_TxAddInputDecodeErrorZ* operator ->() const { return &self; } }; -class CResult_PeeledOnionNoneZ { +class CResult_HeldHtlcAvailableDecodeErrorZ { private: - LDKCResult_PeeledOnionNoneZ self; + LDKCResult_HeldHtlcAvailableDecodeErrorZ self; public: - CResult_PeeledOnionNoneZ(const CResult_PeeledOnionNoneZ&) = delete; - CResult_PeeledOnionNoneZ(CResult_PeeledOnionNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_PeeledOnionNoneZ)); } - CResult_PeeledOnionNoneZ(LDKCResult_PeeledOnionNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_PeeledOnionNoneZ)); } - operator LDKCResult_PeeledOnionNoneZ() && { LDKCResult_PeeledOnionNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_PeeledOnionNoneZ)); return res; } - ~CResult_PeeledOnionNoneZ() { CResult_PeeledOnionNoneZ_free(self); } - CResult_PeeledOnionNoneZ& operator=(CResult_PeeledOnionNoneZ&& o) { CResult_PeeledOnionNoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_PeeledOnionNoneZ)); return *this; } - LDKCResult_PeeledOnionNoneZ* operator &() { return &self; } - LDKCResult_PeeledOnionNoneZ* operator ->() { return &self; } - const LDKCResult_PeeledOnionNoneZ* operator &() const { return &self; } - const LDKCResult_PeeledOnionNoneZ* operator ->() const { return &self; } + CResult_HeldHtlcAvailableDecodeErrorZ(const CResult_HeldHtlcAvailableDecodeErrorZ&) = delete; + CResult_HeldHtlcAvailableDecodeErrorZ(CResult_HeldHtlcAvailableDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_HeldHtlcAvailableDecodeErrorZ)); } + CResult_HeldHtlcAvailableDecodeErrorZ(LDKCResult_HeldHtlcAvailableDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_HeldHtlcAvailableDecodeErrorZ)); } + operator LDKCResult_HeldHtlcAvailableDecodeErrorZ() && { LDKCResult_HeldHtlcAvailableDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_HeldHtlcAvailableDecodeErrorZ)); return res; } + ~CResult_HeldHtlcAvailableDecodeErrorZ() { CResult_HeldHtlcAvailableDecodeErrorZ_free(self); } + CResult_HeldHtlcAvailableDecodeErrorZ& operator=(CResult_HeldHtlcAvailableDecodeErrorZ&& o) { CResult_HeldHtlcAvailableDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_HeldHtlcAvailableDecodeErrorZ)); return *this; } + LDKCResult_HeldHtlcAvailableDecodeErrorZ* operator &() { return &self; } + LDKCResult_HeldHtlcAvailableDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_HeldHtlcAvailableDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_HeldHtlcAvailableDecodeErrorZ* operator ->() const { return &self; } }; class CResult_TxInitRbfDecodeErrorZ { private: @@ -10140,6 +10583,21 @@ public: const LDKCVec_StrZ* operator &() const { return &self; } const LDKCVec_StrZ* operator ->() const { return &self; } }; +class CResult_AsyncPaymentsMessageDecodeErrorZ { +private: + LDKCResult_AsyncPaymentsMessageDecodeErrorZ self; +public: + CResult_AsyncPaymentsMessageDecodeErrorZ(const CResult_AsyncPaymentsMessageDecodeErrorZ&) = delete; + CResult_AsyncPaymentsMessageDecodeErrorZ(CResult_AsyncPaymentsMessageDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_AsyncPaymentsMessageDecodeErrorZ)); } + CResult_AsyncPaymentsMessageDecodeErrorZ(LDKCResult_AsyncPaymentsMessageDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_AsyncPaymentsMessageDecodeErrorZ)); } + operator LDKCResult_AsyncPaymentsMessageDecodeErrorZ() && { LDKCResult_AsyncPaymentsMessageDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_AsyncPaymentsMessageDecodeErrorZ)); return res; } + ~CResult_AsyncPaymentsMessageDecodeErrorZ() { CResult_AsyncPaymentsMessageDecodeErrorZ_free(self); } + CResult_AsyncPaymentsMessageDecodeErrorZ& operator=(CResult_AsyncPaymentsMessageDecodeErrorZ&& o) { CResult_AsyncPaymentsMessageDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_AsyncPaymentsMessageDecodeErrorZ)); return *this; } + LDKCResult_AsyncPaymentsMessageDecodeErrorZ* operator &() { return &self; } + LDKCResult_AsyncPaymentsMessageDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_AsyncPaymentsMessageDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_AsyncPaymentsMessageDecodeErrorZ* operator ->() const { return &self; } +}; class CResult_SpliceAckDecodeErrorZ { private: LDKCResult_SpliceAckDecodeErrorZ self; @@ -10170,6 +10628,21 @@ public: const LDKCResult_PositiveTimestampCreationErrorZ* operator &() const { return &self; } const LDKCResult_PositiveTimestampCreationErrorZ* operator ->() const { return &self; } }; +class CResult_PeeledOnionNoneZ { +private: + LDKCResult_PeeledOnionNoneZ self; +public: + CResult_PeeledOnionNoneZ(const CResult_PeeledOnionNoneZ&) = delete; + CResult_PeeledOnionNoneZ(CResult_PeeledOnionNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_PeeledOnionNoneZ)); } + CResult_PeeledOnionNoneZ(LDKCResult_PeeledOnionNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_PeeledOnionNoneZ)); } + operator LDKCResult_PeeledOnionNoneZ() && { LDKCResult_PeeledOnionNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_PeeledOnionNoneZ)); return res; } + ~CResult_PeeledOnionNoneZ() { CResult_PeeledOnionNoneZ_free(self); } + CResult_PeeledOnionNoneZ& operator=(CResult_PeeledOnionNoneZ&& o) { CResult_PeeledOnionNoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_PeeledOnionNoneZ)); return *this; } + LDKCResult_PeeledOnionNoneZ* operator &() { return &self; } + LDKCResult_PeeledOnionNoneZ* operator ->() { return &self; } + const LDKCResult_PeeledOnionNoneZ* operator &() const { return &self; } + const LDKCResult_PeeledOnionNoneZ* operator ->() const { return &self; } +}; class CVec_C2Tuple_OutPointChannelIdZZ { private: LDKCVec_C2Tuple_OutPointChannelIdZZ self; @@ -10200,21 +10673,6 @@ public: const LDKCResult_ChannelMonitorUpdateDecodeErrorZ* operator &() const { return &self; } const LDKCResult_ChannelMonitorUpdateDecodeErrorZ* operator ->() const { return &self; } }; -class C2Tuple_BlindedPayInfoBlindedPathZ { -private: - LDKC2Tuple_BlindedPayInfoBlindedPathZ self; -public: - C2Tuple_BlindedPayInfoBlindedPathZ(const C2Tuple_BlindedPayInfoBlindedPathZ&) = delete; - C2Tuple_BlindedPayInfoBlindedPathZ(C2Tuple_BlindedPayInfoBlindedPathZ&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_BlindedPayInfoBlindedPathZ)); } - C2Tuple_BlindedPayInfoBlindedPathZ(LDKC2Tuple_BlindedPayInfoBlindedPathZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_BlindedPayInfoBlindedPathZ)); } - operator LDKC2Tuple_BlindedPayInfoBlindedPathZ() && { LDKC2Tuple_BlindedPayInfoBlindedPathZ res = self; memset(&self, 0, sizeof(LDKC2Tuple_BlindedPayInfoBlindedPathZ)); return res; } - ~C2Tuple_BlindedPayInfoBlindedPathZ() { C2Tuple_BlindedPayInfoBlindedPathZ_free(self); } - C2Tuple_BlindedPayInfoBlindedPathZ& operator=(C2Tuple_BlindedPayInfoBlindedPathZ&& o) { C2Tuple_BlindedPayInfoBlindedPathZ_free(self); self = o.self; memset(&o, 0, sizeof(C2Tuple_BlindedPayInfoBlindedPathZ)); return *this; } - LDKC2Tuple_BlindedPayInfoBlindedPathZ* operator &() { return &self; } - LDKC2Tuple_BlindedPayInfoBlindedPathZ* operator ->() { return &self; } - const LDKC2Tuple_BlindedPayInfoBlindedPathZ* operator &() const { return &self; } - const LDKC2Tuple_BlindedPayInfoBlindedPathZ* operator ->() const { return &self; } -}; class CResult_ReplyChannelRangeDecodeErrorZ { private: LDKCResult_ReplyChannelRangeDecodeErrorZ self; @@ -10350,6 +10808,21 @@ public: const LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ* operator &() const { return &self; } const LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ* operator ->() const { return &self; } }; +class CResult_MessageContextDecodeErrorZ { +private: + LDKCResult_MessageContextDecodeErrorZ self; +public: + CResult_MessageContextDecodeErrorZ(const CResult_MessageContextDecodeErrorZ&) = delete; + CResult_MessageContextDecodeErrorZ(CResult_MessageContextDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_MessageContextDecodeErrorZ)); } + CResult_MessageContextDecodeErrorZ(LDKCResult_MessageContextDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_MessageContextDecodeErrorZ)); } + operator LDKCResult_MessageContextDecodeErrorZ() && { LDKCResult_MessageContextDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_MessageContextDecodeErrorZ)); return res; } + ~CResult_MessageContextDecodeErrorZ() { CResult_MessageContextDecodeErrorZ_free(self); } + CResult_MessageContextDecodeErrorZ& operator=(CResult_MessageContextDecodeErrorZ&& o) { CResult_MessageContextDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_MessageContextDecodeErrorZ)); return *this; } + LDKCResult_MessageContextDecodeErrorZ* operator &() { return &self; } + LDKCResult_MessageContextDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_MessageContextDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_MessageContextDecodeErrorZ* operator ->() const { return &self; } +}; class CResult_InitFeaturesDecodeErrorZ { private: LDKCResult_InitFeaturesDecodeErrorZ self; @@ -10410,20 +10883,20 @@ public: const LDKCResult_RevocationKeyDecodeErrorZ* operator &() const { return &self; } const LDKCResult_RevocationKeyDecodeErrorZ* operator ->() const { return &self; } }; -class CResult_ChannelIdDecodeErrorZ { +class C2Tuple_OffersMessageMessageSendInstructionsZ { private: - LDKCResult_ChannelIdDecodeErrorZ self; + LDKC2Tuple_OffersMessageMessageSendInstructionsZ self; public: - CResult_ChannelIdDecodeErrorZ(const CResult_ChannelIdDecodeErrorZ&) = delete; - CResult_ChannelIdDecodeErrorZ(CResult_ChannelIdDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_ChannelIdDecodeErrorZ)); } - CResult_ChannelIdDecodeErrorZ(LDKCResult_ChannelIdDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_ChannelIdDecodeErrorZ)); } - operator LDKCResult_ChannelIdDecodeErrorZ() && { LDKCResult_ChannelIdDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_ChannelIdDecodeErrorZ)); return res; } - ~CResult_ChannelIdDecodeErrorZ() { CResult_ChannelIdDecodeErrorZ_free(self); } - CResult_ChannelIdDecodeErrorZ& operator=(CResult_ChannelIdDecodeErrorZ&& o) { CResult_ChannelIdDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_ChannelIdDecodeErrorZ)); return *this; } - LDKCResult_ChannelIdDecodeErrorZ* operator &() { return &self; } - LDKCResult_ChannelIdDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_ChannelIdDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_ChannelIdDecodeErrorZ* operator ->() const { return &self; } + C2Tuple_OffersMessageMessageSendInstructionsZ(const C2Tuple_OffersMessageMessageSendInstructionsZ&) = delete; + C2Tuple_OffersMessageMessageSendInstructionsZ(C2Tuple_OffersMessageMessageSendInstructionsZ&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_OffersMessageMessageSendInstructionsZ)); } + C2Tuple_OffersMessageMessageSendInstructionsZ(LDKC2Tuple_OffersMessageMessageSendInstructionsZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_OffersMessageMessageSendInstructionsZ)); } + operator LDKC2Tuple_OffersMessageMessageSendInstructionsZ() && { LDKC2Tuple_OffersMessageMessageSendInstructionsZ res = self; memset(&self, 0, sizeof(LDKC2Tuple_OffersMessageMessageSendInstructionsZ)); return res; } + ~C2Tuple_OffersMessageMessageSendInstructionsZ() { C2Tuple_OffersMessageMessageSendInstructionsZ_free(self); } + C2Tuple_OffersMessageMessageSendInstructionsZ& operator=(C2Tuple_OffersMessageMessageSendInstructionsZ&& o) { C2Tuple_OffersMessageMessageSendInstructionsZ_free(self); self = o.self; memset(&o, 0, sizeof(C2Tuple_OffersMessageMessageSendInstructionsZ)); return *this; } + LDKC2Tuple_OffersMessageMessageSendInstructionsZ* operator &() { return &self; } + LDKC2Tuple_OffersMessageMessageSendInstructionsZ* operator ->() { return &self; } + const LDKC2Tuple_OffersMessageMessageSendInstructionsZ* operator &() const { return &self; } + const LDKC2Tuple_OffersMessageMessageSendInstructionsZ* operator ->() const { return &self; } }; class CResult_BlindedHopFeaturesDecodeErrorZ { private: @@ -10440,6 +10913,21 @@ public: const LDKCResult_BlindedHopFeaturesDecodeErrorZ* operator &() const { return &self; } const LDKCResult_BlindedHopFeaturesDecodeErrorZ* operator ->() const { return &self; } }; +class CResult_ChannelIdDecodeErrorZ { +private: + LDKCResult_ChannelIdDecodeErrorZ self; +public: + CResult_ChannelIdDecodeErrorZ(const CResult_ChannelIdDecodeErrorZ&) = delete; + CResult_ChannelIdDecodeErrorZ(CResult_ChannelIdDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_ChannelIdDecodeErrorZ)); } + CResult_ChannelIdDecodeErrorZ(LDKCResult_ChannelIdDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_ChannelIdDecodeErrorZ)); } + operator LDKCResult_ChannelIdDecodeErrorZ() && { LDKCResult_ChannelIdDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_ChannelIdDecodeErrorZ)); return res; } + ~CResult_ChannelIdDecodeErrorZ() { CResult_ChannelIdDecodeErrorZ_free(self); } + CResult_ChannelIdDecodeErrorZ& operator=(CResult_ChannelIdDecodeErrorZ&& o) { CResult_ChannelIdDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_ChannelIdDecodeErrorZ)); return *this; } + LDKCResult_ChannelIdDecodeErrorZ* operator &() { return &self; } + LDKCResult_ChannelIdDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_ChannelIdDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_ChannelIdDecodeErrorZ* operator ->() const { return &self; } +}; class CVec_TransactionOutputsZ { private: LDKCVec_TransactionOutputsZ self; @@ -10485,20 +10973,20 @@ public: const LDKCOption_boolZ* operator &() const { return &self; } const LDKCOption_boolZ* operator ->() const { return &self; } }; -class COption_StrZ { +class CVec_BlindedPaymentPathZ { private: - LDKCOption_StrZ self; + LDKCVec_BlindedPaymentPathZ self; public: - COption_StrZ(const COption_StrZ&) = delete; - COption_StrZ(COption_StrZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_StrZ)); } - COption_StrZ(LDKCOption_StrZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_StrZ)); } - operator LDKCOption_StrZ() && { LDKCOption_StrZ res = self; memset(&self, 0, sizeof(LDKCOption_StrZ)); return res; } - ~COption_StrZ() { COption_StrZ_free(self); } - COption_StrZ& operator=(COption_StrZ&& o) { COption_StrZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_StrZ)); return *this; } - LDKCOption_StrZ* operator &() { return &self; } - LDKCOption_StrZ* operator ->() { return &self; } - const LDKCOption_StrZ* operator &() const { return &self; } - const LDKCOption_StrZ* operator ->() const { return &self; } + CVec_BlindedPaymentPathZ(const CVec_BlindedPaymentPathZ&) = delete; + CVec_BlindedPaymentPathZ(CVec_BlindedPaymentPathZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_BlindedPaymentPathZ)); } + CVec_BlindedPaymentPathZ(LDKCVec_BlindedPaymentPathZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_BlindedPaymentPathZ)); } + operator LDKCVec_BlindedPaymentPathZ() && { LDKCVec_BlindedPaymentPathZ res = self; memset(&self, 0, sizeof(LDKCVec_BlindedPaymentPathZ)); return res; } + ~CVec_BlindedPaymentPathZ() { CVec_BlindedPaymentPathZ_free(self); } + CVec_BlindedPaymentPathZ& operator=(CVec_BlindedPaymentPathZ&& o) { CVec_BlindedPaymentPathZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_BlindedPaymentPathZ)); return *this; } + LDKCVec_BlindedPaymentPathZ* operator &() { return &self; } + LDKCVec_BlindedPaymentPathZ* operator ->() { return &self; } + const LDKCVec_BlindedPaymentPathZ* operator &() const { return &self; } + const LDKCVec_BlindedPaymentPathZ* operator ->() const { return &self; } }; class CResult_ProbabilisticScorerDecodeErrorZ { private: @@ -10515,50 +11003,50 @@ public: const LDKCResult_ProbabilisticScorerDecodeErrorZ* operator &() const { return &self; } const LDKCResult_ProbabilisticScorerDecodeErrorZ* operator ->() const { return &self; } }; -class CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ { +class COption_StrZ { private: - LDKCResult_COption_InboundHTLCStateDetailsZDecodeErrorZ self; + LDKCOption_StrZ self; public: - CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ(const CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ&) = delete; - CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ(CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ)); } - CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ(LDKCResult_COption_InboundHTLCStateDetailsZDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_COption_InboundHTLCStateDetailsZDecodeErrorZ)); } - operator LDKCResult_COption_InboundHTLCStateDetailsZDecodeErrorZ() && { LDKCResult_COption_InboundHTLCStateDetailsZDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_COption_InboundHTLCStateDetailsZDecodeErrorZ)); return res; } - ~CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ() { CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ_free(self); } - CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ& operator=(CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ&& o) { CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ)); return *this; } - LDKCResult_COption_InboundHTLCStateDetailsZDecodeErrorZ* operator &() { return &self; } - LDKCResult_COption_InboundHTLCStateDetailsZDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_COption_InboundHTLCStateDetailsZDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_COption_InboundHTLCStateDetailsZDecodeErrorZ* operator ->() const { return &self; } + COption_StrZ(const COption_StrZ&) = delete; + COption_StrZ(COption_StrZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_StrZ)); } + COption_StrZ(LDKCOption_StrZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_StrZ)); } + operator LDKCOption_StrZ() && { LDKCOption_StrZ res = self; memset(&self, 0, sizeof(LDKCOption_StrZ)); return res; } + ~COption_StrZ() { COption_StrZ_free(self); } + COption_StrZ& operator=(COption_StrZ&& o) { COption_StrZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_StrZ)); return *this; } + LDKCOption_StrZ* operator &() { return &self; } + LDKCOption_StrZ* operator ->() { return &self; } + const LDKCOption_StrZ* operator &() const { return &self; } + const LDKCOption_StrZ* operator ->() const { return &self; } }; -class CResult_ShutdownScriptDecodeErrorZ { +class CResult_CVec_BlindedPaymentPathZNoneZ { private: - LDKCResult_ShutdownScriptDecodeErrorZ self; + LDKCResult_CVec_BlindedPaymentPathZNoneZ self; public: - CResult_ShutdownScriptDecodeErrorZ(const CResult_ShutdownScriptDecodeErrorZ&) = delete; - CResult_ShutdownScriptDecodeErrorZ(CResult_ShutdownScriptDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_ShutdownScriptDecodeErrorZ)); } - CResult_ShutdownScriptDecodeErrorZ(LDKCResult_ShutdownScriptDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_ShutdownScriptDecodeErrorZ)); } - operator LDKCResult_ShutdownScriptDecodeErrorZ() && { LDKCResult_ShutdownScriptDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_ShutdownScriptDecodeErrorZ)); return res; } - ~CResult_ShutdownScriptDecodeErrorZ() { CResult_ShutdownScriptDecodeErrorZ_free(self); } - CResult_ShutdownScriptDecodeErrorZ& operator=(CResult_ShutdownScriptDecodeErrorZ&& o) { CResult_ShutdownScriptDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_ShutdownScriptDecodeErrorZ)); return *this; } - LDKCResult_ShutdownScriptDecodeErrorZ* operator &() { return &self; } - LDKCResult_ShutdownScriptDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_ShutdownScriptDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_ShutdownScriptDecodeErrorZ* operator ->() const { return &self; } + CResult_CVec_BlindedPaymentPathZNoneZ(const CResult_CVec_BlindedPaymentPathZNoneZ&) = delete; + CResult_CVec_BlindedPaymentPathZNoneZ(CResult_CVec_BlindedPaymentPathZNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_CVec_BlindedPaymentPathZNoneZ)); } + CResult_CVec_BlindedPaymentPathZNoneZ(LDKCResult_CVec_BlindedPaymentPathZNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_CVec_BlindedPaymentPathZNoneZ)); } + operator LDKCResult_CVec_BlindedPaymentPathZNoneZ() && { LDKCResult_CVec_BlindedPaymentPathZNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_CVec_BlindedPaymentPathZNoneZ)); return res; } + ~CResult_CVec_BlindedPaymentPathZNoneZ() { CResult_CVec_BlindedPaymentPathZNoneZ_free(self); } + CResult_CVec_BlindedPaymentPathZNoneZ& operator=(CResult_CVec_BlindedPaymentPathZNoneZ&& o) { CResult_CVec_BlindedPaymentPathZNoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_CVec_BlindedPaymentPathZNoneZ)); return *this; } + LDKCResult_CVec_BlindedPaymentPathZNoneZ* operator &() { return &self; } + LDKCResult_CVec_BlindedPaymentPathZNoneZ* operator ->() { return &self; } + const LDKCResult_CVec_BlindedPaymentPathZNoneZ* operator &() const { return &self; } + const LDKCResult_CVec_BlindedPaymentPathZNoneZ* operator ->() const { return &self; } }; -class CResult_SiPrefixBolt11ParseErrorZ { +class COption_C2Tuple_OffersMessageResponseInstructionZZ { private: - LDKCResult_SiPrefixBolt11ParseErrorZ self; + LDKCOption_C2Tuple_OffersMessageResponseInstructionZZ self; public: - 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; } + COption_C2Tuple_OffersMessageResponseInstructionZZ(const COption_C2Tuple_OffersMessageResponseInstructionZZ&) = delete; + COption_C2Tuple_OffersMessageResponseInstructionZZ(COption_C2Tuple_OffersMessageResponseInstructionZZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_C2Tuple_OffersMessageResponseInstructionZZ)); } + COption_C2Tuple_OffersMessageResponseInstructionZZ(LDKCOption_C2Tuple_OffersMessageResponseInstructionZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_C2Tuple_OffersMessageResponseInstructionZZ)); } + operator LDKCOption_C2Tuple_OffersMessageResponseInstructionZZ() && { LDKCOption_C2Tuple_OffersMessageResponseInstructionZZ res = self; memset(&self, 0, sizeof(LDKCOption_C2Tuple_OffersMessageResponseInstructionZZ)); return res; } + ~COption_C2Tuple_OffersMessageResponseInstructionZZ() { COption_C2Tuple_OffersMessageResponseInstructionZZ_free(self); } + COption_C2Tuple_OffersMessageResponseInstructionZZ& operator=(COption_C2Tuple_OffersMessageResponseInstructionZZ&& o) { COption_C2Tuple_OffersMessageResponseInstructionZZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_C2Tuple_OffersMessageResponseInstructionZZ)); return *this; } + LDKCOption_C2Tuple_OffersMessageResponseInstructionZZ* operator &() { return &self; } + LDKCOption_C2Tuple_OffersMessageResponseInstructionZZ* operator ->() { return &self; } + const LDKCOption_C2Tuple_OffersMessageResponseInstructionZZ* operator &() const { return &self; } + const LDKCOption_C2Tuple_OffersMessageResponseInstructionZZ* operator ->() const { return &self; } }; class C2Tuple_usizeTransactionZ { private: @@ -10575,6 +11063,21 @@ public: const LDKC2Tuple_usizeTransactionZ* operator &() const { return &self; } const LDKC2Tuple_usizeTransactionZ* operator ->() const { return &self; } }; +class COption_OffersContextZ { +private: + LDKCOption_OffersContextZ self; +public: + COption_OffersContextZ(const COption_OffersContextZ&) = delete; + COption_OffersContextZ(COption_OffersContextZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_OffersContextZ)); } + COption_OffersContextZ(LDKCOption_OffersContextZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_OffersContextZ)); } + operator LDKCOption_OffersContextZ() && { LDKCOption_OffersContextZ res = self; memset(&self, 0, sizeof(LDKCOption_OffersContextZ)); return res; } + ~COption_OffersContextZ() { COption_OffersContextZ_free(self); } + COption_OffersContextZ& operator=(COption_OffersContextZ&& o) { COption_OffersContextZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_OffersContextZ)); return *this; } + LDKCOption_OffersContextZ* operator &() { return &self; } + LDKCOption_OffersContextZ* operator ->() { return &self; } + const LDKCOption_OffersContextZ* operator &() const { return &self; } + const LDKCOption_OffersContextZ* operator ->() const { return &self; } +}; class CResult_NodeAnnouncementDecodeErrorZ { private: LDKCResult_NodeAnnouncementDecodeErrorZ self; @@ -10590,21 +11093,6 @@ 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; @@ -10620,21 +11108,6 @@ public: const LDKCVec_ChannelMonitorZ* operator &() const { return &self; } const LDKCVec_ChannelMonitorZ* operator ->() const { return &self; } }; -class CVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ { -private: - LDKCVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ self; -public: - CVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ(const CVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ&) = delete; - CVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ(CVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ)); } - CVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ(LDKCVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ)); } - operator LDKCVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ() && { LDKCVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ res = self; memset(&self, 0, sizeof(LDKCVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ)); return res; } - ~CVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ() { CVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ_free(self); } - CVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ& operator=(CVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ&& o) { CVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ)); return *this; } - LDKCVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ* operator &() { return &self; } - LDKCVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ* operator ->() { return &self; } - const LDKCVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ* operator &() const { return &self; } - const LDKCVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ* operator ->() const { return &self; } -}; class CResult_AcceptChannelV2DecodeErrorZ { private: LDKCResult_AcceptChannelV2DecodeErrorZ self; @@ -10650,6 +11123,21 @@ public: const LDKCResult_AcceptChannelV2DecodeErrorZ* operator &() const { return &self; } const LDKCResult_AcceptChannelV2DecodeErrorZ* operator ->() const { return &self; } }; +class CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ { +private: + LDKCResult_COption_InboundHTLCStateDetailsZDecodeErrorZ self; +public: + CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ(const CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ&) = delete; + CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ(CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ)); } + CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ(LDKCResult_COption_InboundHTLCStateDetailsZDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_COption_InboundHTLCStateDetailsZDecodeErrorZ)); } + operator LDKCResult_COption_InboundHTLCStateDetailsZDecodeErrorZ() && { LDKCResult_COption_InboundHTLCStateDetailsZDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_COption_InboundHTLCStateDetailsZDecodeErrorZ)); return res; } + ~CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ() { CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ_free(self); } + CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ& operator=(CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ&& o) { CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ)); return *this; } + LDKCResult_COption_InboundHTLCStateDetailsZDecodeErrorZ* operator &() { return &self; } + LDKCResult_COption_InboundHTLCStateDetailsZDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_COption_InboundHTLCStateDetailsZDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_COption_InboundHTLCStateDetailsZDecodeErrorZ* operator ->() const { return &self; } +}; class CResult_RouteHopDecodeErrorZ { private: LDKCResult_RouteHopDecodeErrorZ self; @@ -10710,6 +11198,21 @@ public: const LDKCResult_CoinSelectionNoneZ* operator &() const { return &self; } const LDKCResult_CoinSelectionNoneZ* 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 CResult_TxCreationKeysDecodeErrorZ { private: LDKCResult_TxCreationKeysDecodeErrorZ self; @@ -10725,21 +11228,6 @@ public: const LDKCResult_TxCreationKeysDecodeErrorZ* operator &() const { return &self; } const LDKCResult_TxCreationKeysDecodeErrorZ* 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 CResult_RefundBolt12SemanticErrorZ { private: LDKCResult_RefundBolt12SemanticErrorZ self; @@ -10875,6 +11363,21 @@ public: const LDKC2Tuple_Z* operator &() const { return &self; } const LDKC2Tuple_Z* operator ->() const { return &self; } }; +class CResult_ShutdownScriptDecodeErrorZ { +private: + LDKCResult_ShutdownScriptDecodeErrorZ self; +public: + CResult_ShutdownScriptDecodeErrorZ(const CResult_ShutdownScriptDecodeErrorZ&) = delete; + CResult_ShutdownScriptDecodeErrorZ(CResult_ShutdownScriptDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_ShutdownScriptDecodeErrorZ)); } + CResult_ShutdownScriptDecodeErrorZ(LDKCResult_ShutdownScriptDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_ShutdownScriptDecodeErrorZ)); } + operator LDKCResult_ShutdownScriptDecodeErrorZ() && { LDKCResult_ShutdownScriptDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_ShutdownScriptDecodeErrorZ)); return res; } + ~CResult_ShutdownScriptDecodeErrorZ() { CResult_ShutdownScriptDecodeErrorZ_free(self); } + CResult_ShutdownScriptDecodeErrorZ& operator=(CResult_ShutdownScriptDecodeErrorZ&& o) { CResult_ShutdownScriptDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_ShutdownScriptDecodeErrorZ)); return *this; } + LDKCResult_ShutdownScriptDecodeErrorZ* operator &() { return &self; } + LDKCResult_ShutdownScriptDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_ShutdownScriptDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_ShutdownScriptDecodeErrorZ* operator ->() const { return &self; } +}; class CResult_InboundHTLCDetailsDecodeErrorZ { private: LDKCResult_InboundHTLCDetailsDecodeErrorZ self; @@ -10890,6 +11393,21 @@ public: const LDKCResult_InboundHTLCDetailsDecodeErrorZ* operator &() const { return &self; } const LDKCResult_InboundHTLCDetailsDecodeErrorZ* operator ->() const { return &self; } }; +class CResult_SiPrefixBolt11ParseErrorZ { +private: + LDKCResult_SiPrefixBolt11ParseErrorZ self; +public: + 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_ECDSASignatureCVec_ECDSASignatureZZ { private: LDKC2Tuple_ECDSASignatureCVec_ECDSASignatureZZ self; @@ -11160,21 +11678,6 @@ public: const LDKCResult_HolderCommitmentTransactionDecodeErrorZ* operator &() const { return &self; } const LDKCResult_HolderCommitmentTransactionDecodeErrorZ* operator ->() const { return &self; } }; -class CVec_ForwardNodeZ { -private: - LDKCVec_ForwardNodeZ self; -public: - CVec_ForwardNodeZ(const CVec_ForwardNodeZ&) = delete; - CVec_ForwardNodeZ(CVec_ForwardNodeZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_ForwardNodeZ)); } - CVec_ForwardNodeZ(LDKCVec_ForwardNodeZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_ForwardNodeZ)); } - operator LDKCVec_ForwardNodeZ() && { LDKCVec_ForwardNodeZ res = self; memset(&self, 0, sizeof(LDKCVec_ForwardNodeZ)); return res; } - ~CVec_ForwardNodeZ() { CVec_ForwardNodeZ_free(self); } - CVec_ForwardNodeZ& operator=(CVec_ForwardNodeZ&& o) { CVec_ForwardNodeZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_ForwardNodeZ)); return *this; } - LDKCVec_ForwardNodeZ* operator &() { return &self; } - LDKCVec_ForwardNodeZ* operator ->() { return &self; } - const LDKCVec_ForwardNodeZ* operator &() const { return &self; } - const LDKCVec_ForwardNodeZ* operator ->() const { return &self; } -}; class CResult_DelayedPaymentKeyDecodeErrorZ { private: LDKCResult_DelayedPaymentKeyDecodeErrorZ self; @@ -11190,20 +11693,20 @@ public: const LDKCResult_DelayedPaymentKeyDecodeErrorZ* operator &() const { return &self; } const LDKCResult_DelayedPaymentKeyDecodeErrorZ* operator ->() const { return &self; } }; -class CResult_InitDecodeErrorZ { +class C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ { private: - LDKCResult_InitDecodeErrorZ self; + LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ self; public: - CResult_InitDecodeErrorZ(const CResult_InitDecodeErrorZ&) = delete; - CResult_InitDecodeErrorZ(CResult_InitDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_InitDecodeErrorZ)); } - CResult_InitDecodeErrorZ(LDKCResult_InitDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_InitDecodeErrorZ)); } - operator LDKCResult_InitDecodeErrorZ() && { LDKCResult_InitDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_InitDecodeErrorZ)); return res; } - ~CResult_InitDecodeErrorZ() { CResult_InitDecodeErrorZ_free(self); } - CResult_InitDecodeErrorZ& operator=(CResult_InitDecodeErrorZ&& o) { CResult_InitDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_InitDecodeErrorZ)); return *this; } - LDKCResult_InitDecodeErrorZ* operator &() { return &self; } - LDKCResult_InitDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_InitDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_InitDecodeErrorZ* operator ->() const { return &self; } + C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ(const C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ&) = delete; + C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ(C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ&& o) : self(o.self) { memset(&o, 0, sizeof(C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ)); } + C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ(LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ)); } + operator LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ() && { LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ res = self; memset(&self, 0, sizeof(LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ)); return res; } + ~C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ() { C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ_free(self); } + C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ& operator=(C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ&& o) { C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ_free(self); self = o.self; memset(&o, 0, sizeof(C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ)); return *this; } + LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ* operator &() { return &self; } + LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ* operator ->() { return &self; } + const LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ* operator &() const { return &self; } + const LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ* operator ->() const { return &self; } }; class CResult_OfferBolt12SemanticErrorZ { private: @@ -11235,20 +11738,20 @@ public: const LDKCResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ* operator &() const { return &self; } const LDKCResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ* operator ->() const { return &self; } }; -class CResult_SpliceDecodeErrorZ { +class CResult_InitDecodeErrorZ { private: - LDKCResult_SpliceDecodeErrorZ self; + LDKCResult_InitDecodeErrorZ self; public: - CResult_SpliceDecodeErrorZ(const CResult_SpliceDecodeErrorZ&) = delete; - CResult_SpliceDecodeErrorZ(CResult_SpliceDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_SpliceDecodeErrorZ)); } - CResult_SpliceDecodeErrorZ(LDKCResult_SpliceDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_SpliceDecodeErrorZ)); } - operator LDKCResult_SpliceDecodeErrorZ() && { LDKCResult_SpliceDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_SpliceDecodeErrorZ)); return res; } - ~CResult_SpliceDecodeErrorZ() { CResult_SpliceDecodeErrorZ_free(self); } - CResult_SpliceDecodeErrorZ& operator=(CResult_SpliceDecodeErrorZ&& o) { CResult_SpliceDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_SpliceDecodeErrorZ)); return *this; } - LDKCResult_SpliceDecodeErrorZ* operator &() { return &self; } - LDKCResult_SpliceDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_SpliceDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_SpliceDecodeErrorZ* operator ->() const { return &self; } + CResult_InitDecodeErrorZ(const CResult_InitDecodeErrorZ&) = delete; + CResult_InitDecodeErrorZ(CResult_InitDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_InitDecodeErrorZ)); } + CResult_InitDecodeErrorZ(LDKCResult_InitDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_InitDecodeErrorZ)); } + operator LDKCResult_InitDecodeErrorZ() && { LDKCResult_InitDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_InitDecodeErrorZ)); return res; } + ~CResult_InitDecodeErrorZ() { CResult_InitDecodeErrorZ_free(self); } + CResult_InitDecodeErrorZ& operator=(CResult_InitDecodeErrorZ&& o) { CResult_InitDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_InitDecodeErrorZ)); return *this; } + LDKCResult_InitDecodeErrorZ* operator &() { return &self; } + LDKCResult_InitDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_InitDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_InitDecodeErrorZ* operator ->() const { return &self; } }; class CResult_PaymentPurposeDecodeErrorZ { private: @@ -11310,21 +11813,6 @@ public: const LDKCVec_ChannelDetailsZ* operator &() const { return &self; } const LDKCVec_ChannelDetailsZ* operator ->() const { return &self; } }; -class C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ { -private: - LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ self; -public: - C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ(const C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ&) = delete; - C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ(C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ&& o) : self(o.self) { memset(&o, 0, sizeof(C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ)); } - C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ(LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ)); } - operator LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ() && { LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ res = self; memset(&self, 0, sizeof(LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ)); return res; } - ~C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ() { C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ_free(self); } - C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ& operator=(C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ&& o) { C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ_free(self); self = o.self; memset(&o, 0, sizeof(C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ)); return *this; } - LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ* operator &() { return &self; } - LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ* operator ->() { return &self; } - const LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ* operator &() const { return &self; } - const LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ* operator ->() const { return &self; } -}; class CResult_Bolt11InvoiceFeaturesDecodeErrorZ { private: LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ self; @@ -11355,20 +11843,20 @@ public: const LDKCVec_MessageSendEventZ* operator &() const { return &self; } const LDKCVec_MessageSendEventZ* operator ->() const { return &self; } }; -class CVec_MonitorUpdateIdZ { +class CVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ { private: - LDKCVec_MonitorUpdateIdZ self; + LDKCVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ self; public: - CVec_MonitorUpdateIdZ(const CVec_MonitorUpdateIdZ&) = delete; - CVec_MonitorUpdateIdZ(CVec_MonitorUpdateIdZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_MonitorUpdateIdZ)); } - CVec_MonitorUpdateIdZ(LDKCVec_MonitorUpdateIdZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_MonitorUpdateIdZ)); } - operator LDKCVec_MonitorUpdateIdZ() && { LDKCVec_MonitorUpdateIdZ res = self; memset(&self, 0, sizeof(LDKCVec_MonitorUpdateIdZ)); return res; } - ~CVec_MonitorUpdateIdZ() { CVec_MonitorUpdateIdZ_free(self); } - CVec_MonitorUpdateIdZ& operator=(CVec_MonitorUpdateIdZ&& o) { CVec_MonitorUpdateIdZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_MonitorUpdateIdZ)); return *this; } - LDKCVec_MonitorUpdateIdZ* operator &() { return &self; } - LDKCVec_MonitorUpdateIdZ* operator ->() { return &self; } - const LDKCVec_MonitorUpdateIdZ* operator &() const { return &self; } - const LDKCVec_MonitorUpdateIdZ* operator ->() const { return &self; } + CVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ(const CVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ&) = delete; + CVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ(CVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ)); } + CVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ(LDKCVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ)); } + operator LDKCVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ() && { LDKCVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ res = self; memset(&self, 0, sizeof(LDKCVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ)); return res; } + ~CVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ() { CVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ_free(self); } + CVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ& operator=(CVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ&& o) { CVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ)); return *this; } + LDKCVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ* operator &() { return &self; } + LDKCVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ* operator ->() { return &self; } + const LDKCVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ* operator &() const { return &self; } + const LDKCVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ* operator ->() const { return &self; } }; class CResult_RouteHintHopDecodeErrorZ { private: @@ -11505,6 +11993,21 @@ public: const LDKCResult_AcceptChannelDecodeErrorZ* operator &() const { return &self; } const LDKCResult_AcceptChannelDecodeErrorZ* operator ->() const { return &self; } }; +class CResult_RefundDecodeErrorZ { +private: + LDKCResult_RefundDecodeErrorZ self; +public: + CResult_RefundDecodeErrorZ(const CResult_RefundDecodeErrorZ&) = delete; + CResult_RefundDecodeErrorZ(CResult_RefundDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_RefundDecodeErrorZ)); } + CResult_RefundDecodeErrorZ(LDKCResult_RefundDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_RefundDecodeErrorZ)); } + operator LDKCResult_RefundDecodeErrorZ() && { LDKCResult_RefundDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_RefundDecodeErrorZ)); return res; } + ~CResult_RefundDecodeErrorZ() { CResult_RefundDecodeErrorZ_free(self); } + CResult_RefundDecodeErrorZ& operator=(CResult_RefundDecodeErrorZ&& o) { CResult_RefundDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_RefundDecodeErrorZ)); return *this; } + LDKCResult_RefundDecodeErrorZ* operator &() { return &self; } + LDKCResult_RefundDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_RefundDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_RefundDecodeErrorZ* operator ->() const { return &self; } +}; class CResult_HostnameDecodeErrorZ { private: LDKCResult_HostnameDecodeErrorZ self; @@ -11580,20 +12083,20 @@ public: const LDKCResult_NoneBolt12SemanticErrorZ* operator &() const { return &self; } const LDKCResult_NoneBolt12SemanticErrorZ* operator ->() const { return &self; } }; -class COption_SecretKeyZ { +class CResult_UnknownPaymentContextDecodeErrorZ { private: - LDKCOption_SecretKeyZ self; + LDKCResult_UnknownPaymentContextDecodeErrorZ self; public: - COption_SecretKeyZ(const COption_SecretKeyZ&) = delete; - COption_SecretKeyZ(COption_SecretKeyZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_SecretKeyZ)); } - COption_SecretKeyZ(LDKCOption_SecretKeyZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_SecretKeyZ)); } - operator LDKCOption_SecretKeyZ() && { LDKCOption_SecretKeyZ res = self; memset(&self, 0, sizeof(LDKCOption_SecretKeyZ)); return res; } - ~COption_SecretKeyZ() { COption_SecretKeyZ_free(self); } - COption_SecretKeyZ& operator=(COption_SecretKeyZ&& o) { COption_SecretKeyZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_SecretKeyZ)); return *this; } - LDKCOption_SecretKeyZ* operator &() { return &self; } - LDKCOption_SecretKeyZ* operator ->() { return &self; } - const LDKCOption_SecretKeyZ* operator &() const { return &self; } - const LDKCOption_SecretKeyZ* operator ->() const { return &self; } + CResult_UnknownPaymentContextDecodeErrorZ(const CResult_UnknownPaymentContextDecodeErrorZ&) = delete; + CResult_UnknownPaymentContextDecodeErrorZ(CResult_UnknownPaymentContextDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_UnknownPaymentContextDecodeErrorZ)); } + CResult_UnknownPaymentContextDecodeErrorZ(LDKCResult_UnknownPaymentContextDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_UnknownPaymentContextDecodeErrorZ)); } + operator LDKCResult_UnknownPaymentContextDecodeErrorZ() && { LDKCResult_UnknownPaymentContextDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_UnknownPaymentContextDecodeErrorZ)); return res; } + ~CResult_UnknownPaymentContextDecodeErrorZ() { CResult_UnknownPaymentContextDecodeErrorZ_free(self); } + CResult_UnknownPaymentContextDecodeErrorZ& operator=(CResult_UnknownPaymentContextDecodeErrorZ&& o) { CResult_UnknownPaymentContextDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_UnknownPaymentContextDecodeErrorZ)); return *this; } + LDKCResult_UnknownPaymentContextDecodeErrorZ* operator &() { return &self; } + LDKCResult_UnknownPaymentContextDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_UnknownPaymentContextDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_UnknownPaymentContextDecodeErrorZ* operator ->() const { return &self; } }; class COption_InboundHTLCStateDetailsZ { private: @@ -11610,20 +12113,20 @@ public: const LDKCOption_InboundHTLCStateDetailsZ* operator &() const { return &self; } const LDKCOption_InboundHTLCStateDetailsZ* operator ->() const { return &self; } }; -class CResult_UnknownPaymentContextDecodeErrorZ { +class CResult_OutputSweeperDecodeErrorZ { private: - LDKCResult_UnknownPaymentContextDecodeErrorZ self; + LDKCResult_OutputSweeperDecodeErrorZ self; public: - CResult_UnknownPaymentContextDecodeErrorZ(const CResult_UnknownPaymentContextDecodeErrorZ&) = delete; - CResult_UnknownPaymentContextDecodeErrorZ(CResult_UnknownPaymentContextDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_UnknownPaymentContextDecodeErrorZ)); } - CResult_UnknownPaymentContextDecodeErrorZ(LDKCResult_UnknownPaymentContextDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_UnknownPaymentContextDecodeErrorZ)); } - operator LDKCResult_UnknownPaymentContextDecodeErrorZ() && { LDKCResult_UnknownPaymentContextDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_UnknownPaymentContextDecodeErrorZ)); return res; } - ~CResult_UnknownPaymentContextDecodeErrorZ() { CResult_UnknownPaymentContextDecodeErrorZ_free(self); } - CResult_UnknownPaymentContextDecodeErrorZ& operator=(CResult_UnknownPaymentContextDecodeErrorZ&& o) { CResult_UnknownPaymentContextDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_UnknownPaymentContextDecodeErrorZ)); return *this; } - LDKCResult_UnknownPaymentContextDecodeErrorZ* operator &() { return &self; } - LDKCResult_UnknownPaymentContextDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_UnknownPaymentContextDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_UnknownPaymentContextDecodeErrorZ* operator ->() const { return &self; } + CResult_OutputSweeperDecodeErrorZ(const CResult_OutputSweeperDecodeErrorZ&) = delete; + CResult_OutputSweeperDecodeErrorZ(CResult_OutputSweeperDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_OutputSweeperDecodeErrorZ)); } + CResult_OutputSweeperDecodeErrorZ(LDKCResult_OutputSweeperDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_OutputSweeperDecodeErrorZ)); } + operator LDKCResult_OutputSweeperDecodeErrorZ() && { LDKCResult_OutputSweeperDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_OutputSweeperDecodeErrorZ)); return res; } + ~CResult_OutputSweeperDecodeErrorZ() { CResult_OutputSweeperDecodeErrorZ_free(self); } + CResult_OutputSweeperDecodeErrorZ& operator=(CResult_OutputSweeperDecodeErrorZ&& o) { CResult_OutputSweeperDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_OutputSweeperDecodeErrorZ)); return *this; } + LDKCResult_OutputSweeperDecodeErrorZ* operator &() { return &self; } + LDKCResult_OutputSweeperDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_OutputSweeperDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_OutputSweeperDecodeErrorZ* operator ->() const { return &self; } }; class CResult_C2Tuple_CVec_u8Zu64ZNoneZ { private: @@ -11640,21 +12143,6 @@ public: const LDKCResult_C2Tuple_CVec_u8Zu64ZNoneZ* operator &() const { return &self; } const LDKCResult_C2Tuple_CVec_u8Zu64ZNoneZ* operator ->() const { return &self; } }; -class CResult_OutputSweeperDecodeErrorZ { -private: - LDKCResult_OutputSweeperDecodeErrorZ self; -public: - CResult_OutputSweeperDecodeErrorZ(const CResult_OutputSweeperDecodeErrorZ&) = delete; - CResult_OutputSweeperDecodeErrorZ(CResult_OutputSweeperDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_OutputSweeperDecodeErrorZ)); } - CResult_OutputSweeperDecodeErrorZ(LDKCResult_OutputSweeperDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_OutputSweeperDecodeErrorZ)); } - operator LDKCResult_OutputSweeperDecodeErrorZ() && { LDKCResult_OutputSweeperDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_OutputSweeperDecodeErrorZ)); return res; } - ~CResult_OutputSweeperDecodeErrorZ() { CResult_OutputSweeperDecodeErrorZ_free(self); } - CResult_OutputSweeperDecodeErrorZ& operator=(CResult_OutputSweeperDecodeErrorZ&& o) { CResult_OutputSweeperDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_OutputSweeperDecodeErrorZ)); return *this; } - LDKCResult_OutputSweeperDecodeErrorZ* operator &() { return &self; } - LDKCResult_OutputSweeperDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_OutputSweeperDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_OutputSweeperDecodeErrorZ* operator ->() const { return &self; } -}; class COption_EventZ { private: LDKCOption_EventZ self; @@ -11775,21 +12263,6 @@ public: const LDKCResult_ECDSASignatureNoneZ* operator &() const { return &self; } const LDKCResult_ECDSASignatureNoneZ* operator ->() const { return &self; } }; -class CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ { -private: - LDKCResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ self; -public: - CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ(const CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ&) = delete; - CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ(CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ)); } - CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ(LDKCResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ)); } - operator LDKCResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ() && { LDKCResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ)); return res; } - ~CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ() { CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ_free(self); } - CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ& operator=(CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ&& o) { CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ)); return *this; } - LDKCResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ* operator &() { return &self; } - LDKCResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ* operator ->() { return &self; } - const LDKCResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ* operator &() const { return &self; } - const LDKCResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ* operator ->() const { return &self; } -}; class C2Tuple_ChannelIdPublicKeyZ { private: LDKC2Tuple_ChannelIdPublicKeyZ self; @@ -11805,20 +12278,35 @@ public: const LDKC2Tuple_ChannelIdPublicKeyZ* operator &() const { return &self; } const LDKC2Tuple_ChannelIdPublicKeyZ* operator ->() const { return &self; } }; -class CVec_WitnessZ { +class C2Tuple_OffersMessageResponseInstructionZ { private: - LDKCVec_WitnessZ self; + LDKC2Tuple_OffersMessageResponseInstructionZ 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; } + C2Tuple_OffersMessageResponseInstructionZ(const C2Tuple_OffersMessageResponseInstructionZ&) = delete; + C2Tuple_OffersMessageResponseInstructionZ(C2Tuple_OffersMessageResponseInstructionZ&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_OffersMessageResponseInstructionZ)); } + C2Tuple_OffersMessageResponseInstructionZ(LDKC2Tuple_OffersMessageResponseInstructionZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_OffersMessageResponseInstructionZ)); } + operator LDKC2Tuple_OffersMessageResponseInstructionZ() && { LDKC2Tuple_OffersMessageResponseInstructionZ res = self; memset(&self, 0, sizeof(LDKC2Tuple_OffersMessageResponseInstructionZ)); return res; } + ~C2Tuple_OffersMessageResponseInstructionZ() { C2Tuple_OffersMessageResponseInstructionZ_free(self); } + C2Tuple_OffersMessageResponseInstructionZ& operator=(C2Tuple_OffersMessageResponseInstructionZ&& o) { C2Tuple_OffersMessageResponseInstructionZ_free(self); self = o.self; memset(&o, 0, sizeof(C2Tuple_OffersMessageResponseInstructionZ)); return *this; } + LDKC2Tuple_OffersMessageResponseInstructionZ* operator &() { return &self; } + LDKC2Tuple_OffersMessageResponseInstructionZ* operator ->() { return &self; } + const LDKC2Tuple_OffersMessageResponseInstructionZ* operator &() const { return &self; } + const LDKC2Tuple_OffersMessageResponseInstructionZ* operator ->() const { return &self; } +}; +class CResult_EcdsaChannelSignerDecodeErrorZ { +private: + LDKCResult_EcdsaChannelSignerDecodeErrorZ self; +public: + CResult_EcdsaChannelSignerDecodeErrorZ(const CResult_EcdsaChannelSignerDecodeErrorZ&) = delete; + CResult_EcdsaChannelSignerDecodeErrorZ(CResult_EcdsaChannelSignerDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_EcdsaChannelSignerDecodeErrorZ)); } + CResult_EcdsaChannelSignerDecodeErrorZ(LDKCResult_EcdsaChannelSignerDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_EcdsaChannelSignerDecodeErrorZ)); } + operator LDKCResult_EcdsaChannelSignerDecodeErrorZ() && { LDKCResult_EcdsaChannelSignerDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_EcdsaChannelSignerDecodeErrorZ)); return res; } + ~CResult_EcdsaChannelSignerDecodeErrorZ() { CResult_EcdsaChannelSignerDecodeErrorZ_free(self); } + CResult_EcdsaChannelSignerDecodeErrorZ& operator=(CResult_EcdsaChannelSignerDecodeErrorZ&& o) { CResult_EcdsaChannelSignerDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_EcdsaChannelSignerDecodeErrorZ)); return *this; } + LDKCResult_EcdsaChannelSignerDecodeErrorZ* operator &() { return &self; } + LDKCResult_EcdsaChannelSignerDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_EcdsaChannelSignerDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_EcdsaChannelSignerDecodeErrorZ* operator ->() const { return &self; } }; class CResult_BlindedTailDecodeErrorZ { private: @@ -11835,20 +12323,20 @@ public: const LDKCResult_BlindedTailDecodeErrorZ* operator &() const { return &self; } const LDKCResult_BlindedTailDecodeErrorZ* operator ->() const { return &self; } }; -class CResult_SocketAddressSocketAddressParseErrorZ { +class CVec_WitnessZ { private: - LDKCResult_SocketAddressSocketAddressParseErrorZ self; + LDKCVec_WitnessZ self; public: - CResult_SocketAddressSocketAddressParseErrorZ(const CResult_SocketAddressSocketAddressParseErrorZ&) = delete; - CResult_SocketAddressSocketAddressParseErrorZ(CResult_SocketAddressSocketAddressParseErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_SocketAddressSocketAddressParseErrorZ)); } - CResult_SocketAddressSocketAddressParseErrorZ(LDKCResult_SocketAddressSocketAddressParseErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_SocketAddressSocketAddressParseErrorZ)); } - operator LDKCResult_SocketAddressSocketAddressParseErrorZ() && { LDKCResult_SocketAddressSocketAddressParseErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_SocketAddressSocketAddressParseErrorZ)); return res; } - ~CResult_SocketAddressSocketAddressParseErrorZ() { CResult_SocketAddressSocketAddressParseErrorZ_free(self); } - CResult_SocketAddressSocketAddressParseErrorZ& operator=(CResult_SocketAddressSocketAddressParseErrorZ&& o) { CResult_SocketAddressSocketAddressParseErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_SocketAddressSocketAddressParseErrorZ)); return *this; } - LDKCResult_SocketAddressSocketAddressParseErrorZ* operator &() { return &self; } - LDKCResult_SocketAddressSocketAddressParseErrorZ* operator ->() { return &self; } - const LDKCResult_SocketAddressSocketAddressParseErrorZ* operator &() const { return &self; } - const LDKCResult_SocketAddressSocketAddressParseErrorZ* operator ->() const { return &self; } + 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 COption_C2Tuple_u64u16ZZ { private: @@ -11865,20 +12353,35 @@ public: const LDKCOption_C2Tuple_u64u16ZZ* operator &() const { return &self; } const LDKCOption_C2Tuple_u64u16ZZ* operator ->() const { return &self; } }; -class CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ { +class CResult_SocketAddressSocketAddressParseErrorZ { +private: + LDKCResult_SocketAddressSocketAddressParseErrorZ self; +public: + CResult_SocketAddressSocketAddressParseErrorZ(const CResult_SocketAddressSocketAddressParseErrorZ&) = delete; + CResult_SocketAddressSocketAddressParseErrorZ(CResult_SocketAddressSocketAddressParseErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_SocketAddressSocketAddressParseErrorZ)); } + CResult_SocketAddressSocketAddressParseErrorZ(LDKCResult_SocketAddressSocketAddressParseErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_SocketAddressSocketAddressParseErrorZ)); } + operator LDKCResult_SocketAddressSocketAddressParseErrorZ() && { LDKCResult_SocketAddressSocketAddressParseErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_SocketAddressSocketAddressParseErrorZ)); return res; } + ~CResult_SocketAddressSocketAddressParseErrorZ() { CResult_SocketAddressSocketAddressParseErrorZ_free(self); } + CResult_SocketAddressSocketAddressParseErrorZ& operator=(CResult_SocketAddressSocketAddressParseErrorZ&& o) { CResult_SocketAddressSocketAddressParseErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_SocketAddressSocketAddressParseErrorZ)); return *this; } + LDKCResult_SocketAddressSocketAddressParseErrorZ* operator &() { return &self; } + LDKCResult_SocketAddressSocketAddressParseErrorZ* operator ->() { return &self; } + const LDKCResult_SocketAddressSocketAddressParseErrorZ* operator &() const { return &self; } + const LDKCResult_SocketAddressSocketAddressParseErrorZ* operator ->() const { return &self; } +}; +class CResult_COption_PaymentFailureReasonZDecodeErrorZ { private: - LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ self; + LDKCResult_COption_PaymentFailureReasonZDecodeErrorZ 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; } + CResult_COption_PaymentFailureReasonZDecodeErrorZ(const CResult_COption_PaymentFailureReasonZDecodeErrorZ&) = delete; + CResult_COption_PaymentFailureReasonZDecodeErrorZ(CResult_COption_PaymentFailureReasonZDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_COption_PaymentFailureReasonZDecodeErrorZ)); } + CResult_COption_PaymentFailureReasonZDecodeErrorZ(LDKCResult_COption_PaymentFailureReasonZDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_COption_PaymentFailureReasonZDecodeErrorZ)); } + operator LDKCResult_COption_PaymentFailureReasonZDecodeErrorZ() && { LDKCResult_COption_PaymentFailureReasonZDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_COption_PaymentFailureReasonZDecodeErrorZ)); return res; } + ~CResult_COption_PaymentFailureReasonZDecodeErrorZ() { CResult_COption_PaymentFailureReasonZDecodeErrorZ_free(self); } + CResult_COption_PaymentFailureReasonZDecodeErrorZ& operator=(CResult_COption_PaymentFailureReasonZDecodeErrorZ&& o) { CResult_COption_PaymentFailureReasonZDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_COption_PaymentFailureReasonZDecodeErrorZ)); return *this; } + LDKCResult_COption_PaymentFailureReasonZDecodeErrorZ* operator &() { return &self; } + LDKCResult_COption_PaymentFailureReasonZDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_COption_PaymentFailureReasonZDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_COption_PaymentFailureReasonZDecodeErrorZ* operator ->() const { return &self; } }; class CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ { private: @@ -11910,20 +12413,20 @@ public: const LDKCResult_ChannelDerivationParametersDecodeErrorZ* operator &() const { return &self; } const LDKCResult_ChannelDerivationParametersDecodeErrorZ* operator ->() const { return &self; } }; -class CResult_PaymentConstraintsDecodeErrorZ { +class CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ { private: - LDKCResult_PaymentConstraintsDecodeErrorZ self; + LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ self; public: - CResult_PaymentConstraintsDecodeErrorZ(const CResult_PaymentConstraintsDecodeErrorZ&) = delete; - CResult_PaymentConstraintsDecodeErrorZ(CResult_PaymentConstraintsDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_PaymentConstraintsDecodeErrorZ)); } - CResult_PaymentConstraintsDecodeErrorZ(LDKCResult_PaymentConstraintsDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_PaymentConstraintsDecodeErrorZ)); } - operator LDKCResult_PaymentConstraintsDecodeErrorZ() && { LDKCResult_PaymentConstraintsDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_PaymentConstraintsDecodeErrorZ)); return res; } - ~CResult_PaymentConstraintsDecodeErrorZ() { CResult_PaymentConstraintsDecodeErrorZ_free(self); } - CResult_PaymentConstraintsDecodeErrorZ& operator=(CResult_PaymentConstraintsDecodeErrorZ&& o) { CResult_PaymentConstraintsDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_PaymentConstraintsDecodeErrorZ)); return *this; } - LDKCResult_PaymentConstraintsDecodeErrorZ* operator &() { return &self; } - LDKCResult_PaymentConstraintsDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_PaymentConstraintsDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_PaymentConstraintsDecodeErrorZ* operator ->() const { return &self; } + 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 CResult_UnsignedInvoiceRequestBolt12SemanticErrorZ { private: @@ -12045,21 +12548,6 @@ public: const LDKCVec_C2Tuple_u64CVec_u8ZZZ* operator &() const { return &self; } const LDKCVec_C2Tuple_u64CVec_u8ZZZ* operator ->() const { return &self; } }; -class CVec_PhantomRouteHintsZ { -private: - LDKCVec_PhantomRouteHintsZ self; -public: - CVec_PhantomRouteHintsZ(const CVec_PhantomRouteHintsZ&) = delete; - CVec_PhantomRouteHintsZ(CVec_PhantomRouteHintsZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_PhantomRouteHintsZ)); } - CVec_PhantomRouteHintsZ(LDKCVec_PhantomRouteHintsZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_PhantomRouteHintsZ)); } - operator LDKCVec_PhantomRouteHintsZ() && { LDKCVec_PhantomRouteHintsZ res = self; memset(&self, 0, sizeof(LDKCVec_PhantomRouteHintsZ)); return res; } - ~CVec_PhantomRouteHintsZ() { CVec_PhantomRouteHintsZ_free(self); } - CVec_PhantomRouteHintsZ& operator=(CVec_PhantomRouteHintsZ&& o) { CVec_PhantomRouteHintsZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_PhantomRouteHintsZ)); return *this; } - LDKCVec_PhantomRouteHintsZ* operator &() { return &self; } - LDKCVec_PhantomRouteHintsZ* operator ->() { return &self; } - const LDKCVec_PhantomRouteHintsZ* operator &() const { return &self; } - const LDKCVec_PhantomRouteHintsZ* operator ->() const { return &self; } -}; class CResult_OffersMessageDecodeErrorZ { private: LDKCResult_OffersMessageDecodeErrorZ self; @@ -12075,6 +12563,21 @@ public: const LDKCResult_OffersMessageDecodeErrorZ* operator &() const { return &self; } const LDKCResult_OffersMessageDecodeErrorZ* operator ->() const { return &self; } }; +class CResult_PaymentConstraintsDecodeErrorZ { +private: + LDKCResult_PaymentConstraintsDecodeErrorZ self; +public: + CResult_PaymentConstraintsDecodeErrorZ(const CResult_PaymentConstraintsDecodeErrorZ&) = delete; + CResult_PaymentConstraintsDecodeErrorZ(CResult_PaymentConstraintsDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_PaymentConstraintsDecodeErrorZ)); } + CResult_PaymentConstraintsDecodeErrorZ(LDKCResult_PaymentConstraintsDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_PaymentConstraintsDecodeErrorZ)); } + operator LDKCResult_PaymentConstraintsDecodeErrorZ() && { LDKCResult_PaymentConstraintsDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_PaymentConstraintsDecodeErrorZ)); return res; } + ~CResult_PaymentConstraintsDecodeErrorZ() { CResult_PaymentConstraintsDecodeErrorZ_free(self); } + CResult_PaymentConstraintsDecodeErrorZ& operator=(CResult_PaymentConstraintsDecodeErrorZ&& o) { CResult_PaymentConstraintsDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_PaymentConstraintsDecodeErrorZ)); return *this; } + LDKCResult_PaymentConstraintsDecodeErrorZ* operator &() { return &self; } + LDKCResult_PaymentConstraintsDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_PaymentConstraintsDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_PaymentConstraintsDecodeErrorZ* operator ->() const { return &self; } +}; class CResult_NoneAPIErrorZ { private: LDKCResult_NoneAPIErrorZ self; @@ -12195,20 +12698,20 @@ public: const LDKCVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZ* operator &() const { return &self; } const LDKCVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZ* operator ->() const { return &self; } }; -class CResult_PendingHTLCRoutingDecodeErrorZ { +class CResult_Bolt12InvoiceDecodeErrorZ { private: - LDKCResult_PendingHTLCRoutingDecodeErrorZ self; + LDKCResult_Bolt12InvoiceDecodeErrorZ self; public: - CResult_PendingHTLCRoutingDecodeErrorZ(const CResult_PendingHTLCRoutingDecodeErrorZ&) = delete; - CResult_PendingHTLCRoutingDecodeErrorZ(CResult_PendingHTLCRoutingDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_PendingHTLCRoutingDecodeErrorZ)); } - CResult_PendingHTLCRoutingDecodeErrorZ(LDKCResult_PendingHTLCRoutingDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_PendingHTLCRoutingDecodeErrorZ)); } - operator LDKCResult_PendingHTLCRoutingDecodeErrorZ() && { LDKCResult_PendingHTLCRoutingDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_PendingHTLCRoutingDecodeErrorZ)); return res; } - ~CResult_PendingHTLCRoutingDecodeErrorZ() { CResult_PendingHTLCRoutingDecodeErrorZ_free(self); } - CResult_PendingHTLCRoutingDecodeErrorZ& operator=(CResult_PendingHTLCRoutingDecodeErrorZ&& o) { CResult_PendingHTLCRoutingDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_PendingHTLCRoutingDecodeErrorZ)); return *this; } - LDKCResult_PendingHTLCRoutingDecodeErrorZ* operator &() { return &self; } - LDKCResult_PendingHTLCRoutingDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_PendingHTLCRoutingDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_PendingHTLCRoutingDecodeErrorZ* operator ->() const { return &self; } + CResult_Bolt12InvoiceDecodeErrorZ(const CResult_Bolt12InvoiceDecodeErrorZ&) = delete; + CResult_Bolt12InvoiceDecodeErrorZ(CResult_Bolt12InvoiceDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_Bolt12InvoiceDecodeErrorZ)); } + CResult_Bolt12InvoiceDecodeErrorZ(LDKCResult_Bolt12InvoiceDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_Bolt12InvoiceDecodeErrorZ)); } + operator LDKCResult_Bolt12InvoiceDecodeErrorZ() && { LDKCResult_Bolt12InvoiceDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_Bolt12InvoiceDecodeErrorZ)); return res; } + ~CResult_Bolt12InvoiceDecodeErrorZ() { CResult_Bolt12InvoiceDecodeErrorZ_free(self); } + CResult_Bolt12InvoiceDecodeErrorZ& operator=(CResult_Bolt12InvoiceDecodeErrorZ&& o) { CResult_Bolt12InvoiceDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_Bolt12InvoiceDecodeErrorZ)); return *this; } + LDKCResult_Bolt12InvoiceDecodeErrorZ* operator &() { return &self; } + LDKCResult_Bolt12InvoiceDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_Bolt12InvoiceDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_Bolt12InvoiceDecodeErrorZ* operator ->() const { return &self; } }; class C2Tuple_u64u64Z { private: @@ -12225,50 +12728,50 @@ public: const LDKC2Tuple_u64u64Z* operator &() const { return &self; } const LDKC2Tuple_u64u64Z* operator ->() const { return &self; } }; -class CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ { +class COption_NodeAnnouncementInfoZ { private: - LDKCResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ self; + LDKCOption_NodeAnnouncementInfoZ self; public: - CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ(const CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ&) = delete; - CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ(CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ)); } - CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ(LDKCResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ)); } - operator LDKCResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ() && { LDKCResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ)); return res; } - ~CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ() { CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ_free(self); } - CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ& operator=(CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ&& o) { CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ)); return *this; } - LDKCResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ* operator &() { return &self; } - LDKCResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ* operator ->() { return &self; } - const LDKCResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ* operator &() const { return &self; } - const LDKCResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ* operator ->() const { return &self; } + COption_NodeAnnouncementInfoZ(const COption_NodeAnnouncementInfoZ&) = delete; + COption_NodeAnnouncementInfoZ(COption_NodeAnnouncementInfoZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_NodeAnnouncementInfoZ)); } + COption_NodeAnnouncementInfoZ(LDKCOption_NodeAnnouncementInfoZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_NodeAnnouncementInfoZ)); } + operator LDKCOption_NodeAnnouncementInfoZ() && { LDKCOption_NodeAnnouncementInfoZ res = self; memset(&self, 0, sizeof(LDKCOption_NodeAnnouncementInfoZ)); return res; } + ~COption_NodeAnnouncementInfoZ() { COption_NodeAnnouncementInfoZ_free(self); } + COption_NodeAnnouncementInfoZ& operator=(COption_NodeAnnouncementInfoZ&& o) { COption_NodeAnnouncementInfoZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_NodeAnnouncementInfoZ)); return *this; } + LDKCOption_NodeAnnouncementInfoZ* operator &() { return &self; } + LDKCOption_NodeAnnouncementInfoZ* operator ->() { return &self; } + const LDKCOption_NodeAnnouncementInfoZ* operator &() const { return &self; } + const LDKCOption_NodeAnnouncementInfoZ* operator ->() const { return &self; } }; -class CResult_ChannelDetailsDecodeErrorZ { +class CResult_PendingHTLCRoutingDecodeErrorZ { private: - LDKCResult_ChannelDetailsDecodeErrorZ self; + LDKCResult_PendingHTLCRoutingDecodeErrorZ self; public: - CResult_ChannelDetailsDecodeErrorZ(const CResult_ChannelDetailsDecodeErrorZ&) = delete; - CResult_ChannelDetailsDecodeErrorZ(CResult_ChannelDetailsDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_ChannelDetailsDecodeErrorZ)); } - CResult_ChannelDetailsDecodeErrorZ(LDKCResult_ChannelDetailsDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_ChannelDetailsDecodeErrorZ)); } - operator LDKCResult_ChannelDetailsDecodeErrorZ() && { LDKCResult_ChannelDetailsDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_ChannelDetailsDecodeErrorZ)); return res; } - ~CResult_ChannelDetailsDecodeErrorZ() { CResult_ChannelDetailsDecodeErrorZ_free(self); } - CResult_ChannelDetailsDecodeErrorZ& operator=(CResult_ChannelDetailsDecodeErrorZ&& o) { CResult_ChannelDetailsDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_ChannelDetailsDecodeErrorZ)); return *this; } - LDKCResult_ChannelDetailsDecodeErrorZ* operator &() { return &self; } - LDKCResult_ChannelDetailsDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_ChannelDetailsDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_ChannelDetailsDecodeErrorZ* operator ->() const { return &self; } + CResult_PendingHTLCRoutingDecodeErrorZ(const CResult_PendingHTLCRoutingDecodeErrorZ&) = delete; + CResult_PendingHTLCRoutingDecodeErrorZ(CResult_PendingHTLCRoutingDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_PendingHTLCRoutingDecodeErrorZ)); } + CResult_PendingHTLCRoutingDecodeErrorZ(LDKCResult_PendingHTLCRoutingDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_PendingHTLCRoutingDecodeErrorZ)); } + operator LDKCResult_PendingHTLCRoutingDecodeErrorZ() && { LDKCResult_PendingHTLCRoutingDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_PendingHTLCRoutingDecodeErrorZ)); return res; } + ~CResult_PendingHTLCRoutingDecodeErrorZ() { CResult_PendingHTLCRoutingDecodeErrorZ_free(self); } + CResult_PendingHTLCRoutingDecodeErrorZ& operator=(CResult_PendingHTLCRoutingDecodeErrorZ&& o) { CResult_PendingHTLCRoutingDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_PendingHTLCRoutingDecodeErrorZ)); return *this; } + LDKCResult_PendingHTLCRoutingDecodeErrorZ* operator &() { return &self; } + LDKCResult_PendingHTLCRoutingDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_PendingHTLCRoutingDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_PendingHTLCRoutingDecodeErrorZ* operator ->() const { return &self; } }; -class CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { +class COption_C2Tuple_OnionMessageContentsResponseInstructionZZ { private: - LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ self; + LDKCOption_C2Tuple_OnionMessageContentsResponseInstructionZZ 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; } + COption_C2Tuple_OnionMessageContentsResponseInstructionZZ(const COption_C2Tuple_OnionMessageContentsResponseInstructionZZ&) = delete; + COption_C2Tuple_OnionMessageContentsResponseInstructionZZ(COption_C2Tuple_OnionMessageContentsResponseInstructionZZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_C2Tuple_OnionMessageContentsResponseInstructionZZ)); } + COption_C2Tuple_OnionMessageContentsResponseInstructionZZ(LDKCOption_C2Tuple_OnionMessageContentsResponseInstructionZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_C2Tuple_OnionMessageContentsResponseInstructionZZ)); } + operator LDKCOption_C2Tuple_OnionMessageContentsResponseInstructionZZ() && { LDKCOption_C2Tuple_OnionMessageContentsResponseInstructionZZ res = self; memset(&self, 0, sizeof(LDKCOption_C2Tuple_OnionMessageContentsResponseInstructionZZ)); return res; } + ~COption_C2Tuple_OnionMessageContentsResponseInstructionZZ() { COption_C2Tuple_OnionMessageContentsResponseInstructionZZ_free(self); } + COption_C2Tuple_OnionMessageContentsResponseInstructionZZ& operator=(COption_C2Tuple_OnionMessageContentsResponseInstructionZZ&& o) { COption_C2Tuple_OnionMessageContentsResponseInstructionZZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_C2Tuple_OnionMessageContentsResponseInstructionZZ)); return *this; } + LDKCOption_C2Tuple_OnionMessageContentsResponseInstructionZZ* operator &() { return &self; } + LDKCOption_C2Tuple_OnionMessageContentsResponseInstructionZZ* operator ->() { return &self; } + const LDKCOption_C2Tuple_OnionMessageContentsResponseInstructionZZ* operator &() const { return &self; } + const LDKCOption_C2Tuple_OnionMessageContentsResponseInstructionZZ* operator ->() const { return &self; } }; class CResult_RecipientOnionFieldsDecodeErrorZ { private: @@ -12315,20 +12818,35 @@ public: const LDKCResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ* operator &() const { return &self; } const LDKCResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ* operator ->() const { return &self; } }; -class CResult_PaymentContextDecodeErrorZ { +class CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ { private: - LDKCResult_PaymentContextDecodeErrorZ self; + LDKCResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ self; public: - CResult_PaymentContextDecodeErrorZ(const CResult_PaymentContextDecodeErrorZ&) = delete; - CResult_PaymentContextDecodeErrorZ(CResult_PaymentContextDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_PaymentContextDecodeErrorZ)); } - CResult_PaymentContextDecodeErrorZ(LDKCResult_PaymentContextDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_PaymentContextDecodeErrorZ)); } - operator LDKCResult_PaymentContextDecodeErrorZ() && { LDKCResult_PaymentContextDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_PaymentContextDecodeErrorZ)); return res; } - ~CResult_PaymentContextDecodeErrorZ() { CResult_PaymentContextDecodeErrorZ_free(self); } - CResult_PaymentContextDecodeErrorZ& operator=(CResult_PaymentContextDecodeErrorZ&& o) { CResult_PaymentContextDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_PaymentContextDecodeErrorZ)); return *this; } - LDKCResult_PaymentContextDecodeErrorZ* operator &() { return &self; } - LDKCResult_PaymentContextDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_PaymentContextDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_PaymentContextDecodeErrorZ* operator ->() const { return &self; } + CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ(const CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ&) = delete; + CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ(CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ)); } + CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ(LDKCResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ)); } + operator LDKCResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ() && { LDKCResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ)); return res; } + ~CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ() { CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ_free(self); } + CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ& operator=(CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ&& o) { CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ)); return *this; } + LDKCResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ* operator &() { return &self; } + LDKCResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ* operator ->() { return &self; } + const LDKCResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ* operator &() const { return &self; } + const LDKCResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ* operator ->() const { return &self; } +}; +class CResult_ChannelDetailsDecodeErrorZ { +private: + LDKCResult_ChannelDetailsDecodeErrorZ self; +public: + CResult_ChannelDetailsDecodeErrorZ(const CResult_ChannelDetailsDecodeErrorZ&) = delete; + CResult_ChannelDetailsDecodeErrorZ(CResult_ChannelDetailsDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_ChannelDetailsDecodeErrorZ)); } + CResult_ChannelDetailsDecodeErrorZ(LDKCResult_ChannelDetailsDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_ChannelDetailsDecodeErrorZ)); } + operator LDKCResult_ChannelDetailsDecodeErrorZ() && { LDKCResult_ChannelDetailsDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_ChannelDetailsDecodeErrorZ)); return res; } + ~CResult_ChannelDetailsDecodeErrorZ() { CResult_ChannelDetailsDecodeErrorZ_free(self); } + CResult_ChannelDetailsDecodeErrorZ& operator=(CResult_ChannelDetailsDecodeErrorZ&& o) { CResult_ChannelDetailsDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_ChannelDetailsDecodeErrorZ)); return *this; } + LDKCResult_ChannelDetailsDecodeErrorZ* operator &() { return &self; } + LDKCResult_ChannelDetailsDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_ChannelDetailsDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_ChannelDetailsDecodeErrorZ* operator ->() const { return &self; } }; class CVec_UtxoZ { private: @@ -12345,6 +12863,21 @@ public: const LDKCVec_UtxoZ* operator &() const { return &self; } const LDKCVec_UtxoZ* 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 CResult_ChannelConfigDecodeErrorZ { private: LDKCResult_ChannelConfigDecodeErrorZ self; @@ -12390,6 +12923,51 @@ public: const LDKCOption_i64Z* operator &() const { return &self; } const LDKCOption_i64Z* operator ->() const { return &self; } }; +class CResult_PaymentContextDecodeErrorZ { +private: + LDKCResult_PaymentContextDecodeErrorZ self; +public: + CResult_PaymentContextDecodeErrorZ(const CResult_PaymentContextDecodeErrorZ&) = delete; + CResult_PaymentContextDecodeErrorZ(CResult_PaymentContextDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_PaymentContextDecodeErrorZ)); } + CResult_PaymentContextDecodeErrorZ(LDKCResult_PaymentContextDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_PaymentContextDecodeErrorZ)); } + operator LDKCResult_PaymentContextDecodeErrorZ() && { LDKCResult_PaymentContextDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_PaymentContextDecodeErrorZ)); return res; } + ~CResult_PaymentContextDecodeErrorZ() { CResult_PaymentContextDecodeErrorZ_free(self); } + CResult_PaymentContextDecodeErrorZ& operator=(CResult_PaymentContextDecodeErrorZ&& o) { CResult_PaymentContextDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_PaymentContextDecodeErrorZ)); return *this; } + LDKCResult_PaymentContextDecodeErrorZ* operator &() { return &self; } + LDKCResult_PaymentContextDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_PaymentContextDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_PaymentContextDecodeErrorZ* operator ->() const { return &self; } +}; +class CVec_PhantomRouteHintsZ { +private: + LDKCVec_PhantomRouteHintsZ self; +public: + CVec_PhantomRouteHintsZ(const CVec_PhantomRouteHintsZ&) = delete; + CVec_PhantomRouteHintsZ(CVec_PhantomRouteHintsZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_PhantomRouteHintsZ)); } + CVec_PhantomRouteHintsZ(LDKCVec_PhantomRouteHintsZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_PhantomRouteHintsZ)); } + operator LDKCVec_PhantomRouteHintsZ() && { LDKCVec_PhantomRouteHintsZ res = self; memset(&self, 0, sizeof(LDKCVec_PhantomRouteHintsZ)); return res; } + ~CVec_PhantomRouteHintsZ() { CVec_PhantomRouteHintsZ_free(self); } + CVec_PhantomRouteHintsZ& operator=(CVec_PhantomRouteHintsZ&& o) { CVec_PhantomRouteHintsZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_PhantomRouteHintsZ)); return *this; } + LDKCVec_PhantomRouteHintsZ* operator &() { return &self; } + LDKCVec_PhantomRouteHintsZ* operator ->() { return &self; } + const LDKCVec_PhantomRouteHintsZ* operator &() const { return &self; } + const LDKCVec_PhantomRouteHintsZ* operator ->() const { return &self; } +}; +class CVec_C2Tuple_OutPointCVec_u64ZZZ { +private: + LDKCVec_C2Tuple_OutPointCVec_u64ZZZ self; +public: + CVec_C2Tuple_OutPointCVec_u64ZZZ(const CVec_C2Tuple_OutPointCVec_u64ZZZ&) = delete; + CVec_C2Tuple_OutPointCVec_u64ZZZ(CVec_C2Tuple_OutPointCVec_u64ZZZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_C2Tuple_OutPointCVec_u64ZZZ)); } + CVec_C2Tuple_OutPointCVec_u64ZZZ(LDKCVec_C2Tuple_OutPointCVec_u64ZZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_C2Tuple_OutPointCVec_u64ZZZ)); } + operator LDKCVec_C2Tuple_OutPointCVec_u64ZZZ() && { LDKCVec_C2Tuple_OutPointCVec_u64ZZZ res = self; memset(&self, 0, sizeof(LDKCVec_C2Tuple_OutPointCVec_u64ZZZ)); return res; } + ~CVec_C2Tuple_OutPointCVec_u64ZZZ() { CVec_C2Tuple_OutPointCVec_u64ZZZ_free(self); } + CVec_C2Tuple_OutPointCVec_u64ZZZ& operator=(CVec_C2Tuple_OutPointCVec_u64ZZZ&& o) { CVec_C2Tuple_OutPointCVec_u64ZZZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_C2Tuple_OutPointCVec_u64ZZZ)); return *this; } + LDKCVec_C2Tuple_OutPointCVec_u64ZZZ* operator &() { return &self; } + LDKCVec_C2Tuple_OutPointCVec_u64ZZZ* operator ->() { return &self; } + const LDKCVec_C2Tuple_OutPointCVec_u64ZZZ* operator &() const { return &self; } + const LDKCVec_C2Tuple_OutPointCVec_u64ZZZ* operator ->() const { return &self; } +}; class C2Tuple_ThirtyTwoBytesChannelManagerZ { private: LDKC2Tuple_ThirtyTwoBytesChannelManagerZ self; @@ -12525,21 +13103,6 @@ public: const LDKCResult_TxOutUtxoLookupErrorZ* operator &() const { return &self; } const LDKCResult_TxOutUtxoLookupErrorZ* operator ->() const { return &self; } }; -class CResult_BlindedPathNoneZ { -private: - LDKCResult_BlindedPathNoneZ self; -public: - CResult_BlindedPathNoneZ(const CResult_BlindedPathNoneZ&) = delete; - CResult_BlindedPathNoneZ(CResult_BlindedPathNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_BlindedPathNoneZ)); } - CResult_BlindedPathNoneZ(LDKCResult_BlindedPathNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_BlindedPathNoneZ)); } - operator LDKCResult_BlindedPathNoneZ() && { LDKCResult_BlindedPathNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_BlindedPathNoneZ)); return res; } - ~CResult_BlindedPathNoneZ() { CResult_BlindedPathNoneZ_free(self); } - CResult_BlindedPathNoneZ& operator=(CResult_BlindedPathNoneZ&& o) { CResult_BlindedPathNoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_BlindedPathNoneZ)); return *this; } - LDKCResult_BlindedPathNoneZ* operator &() { return &self; } - LDKCResult_BlindedPathNoneZ* operator ->() { return &self; } - const LDKCResult_BlindedPathNoneZ* operator &() const { return &self; } - const LDKCResult_BlindedPathNoneZ* operator ->() const { return &self; } -}; class COption_usizeZ { private: LDKCOption_usizeZ self; @@ -12555,6 +13118,36 @@ public: const LDKCOption_usizeZ* operator &() const { return &self; } const LDKCOption_usizeZ* operator ->() const { return &self; } }; +class CVec_BlindedMessagePathZ { +private: + LDKCVec_BlindedMessagePathZ self; +public: + CVec_BlindedMessagePathZ(const CVec_BlindedMessagePathZ&) = delete; + CVec_BlindedMessagePathZ(CVec_BlindedMessagePathZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_BlindedMessagePathZ)); } + CVec_BlindedMessagePathZ(LDKCVec_BlindedMessagePathZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_BlindedMessagePathZ)); } + operator LDKCVec_BlindedMessagePathZ() && { LDKCVec_BlindedMessagePathZ res = self; memset(&self, 0, sizeof(LDKCVec_BlindedMessagePathZ)); return res; } + ~CVec_BlindedMessagePathZ() { CVec_BlindedMessagePathZ_free(self); } + CVec_BlindedMessagePathZ& operator=(CVec_BlindedMessagePathZ&& o) { CVec_BlindedMessagePathZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_BlindedMessagePathZ)); return *this; } + LDKCVec_BlindedMessagePathZ* operator &() { return &self; } + LDKCVec_BlindedMessagePathZ* operator ->() { return &self; } + const LDKCVec_BlindedMessagePathZ* operator &() const { return &self; } + const LDKCVec_BlindedMessagePathZ* operator ->() const { return &self; } +}; +class CResult_OffersContextDecodeErrorZ { +private: + LDKCResult_OffersContextDecodeErrorZ self; +public: + CResult_OffersContextDecodeErrorZ(const CResult_OffersContextDecodeErrorZ&) = delete; + CResult_OffersContextDecodeErrorZ(CResult_OffersContextDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_OffersContextDecodeErrorZ)); } + CResult_OffersContextDecodeErrorZ(LDKCResult_OffersContextDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_OffersContextDecodeErrorZ)); } + operator LDKCResult_OffersContextDecodeErrorZ() && { LDKCResult_OffersContextDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_OffersContextDecodeErrorZ)); return res; } + ~CResult_OffersContextDecodeErrorZ() { CResult_OffersContextDecodeErrorZ_free(self); } + CResult_OffersContextDecodeErrorZ& operator=(CResult_OffersContextDecodeErrorZ&& o) { CResult_OffersContextDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_OffersContextDecodeErrorZ)); return *this; } + LDKCResult_OffersContextDecodeErrorZ* operator &() { return &self; } + LDKCResult_OffersContextDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_OffersContextDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_OffersContextDecodeErrorZ* operator ->() const { return &self; } +}; class CResult_NoneNoneZ { private: LDKCResult_NoneNoneZ self; @@ -12645,6 +13238,21 @@ public: const LDKCOption_ClosureReasonZ* operator &() const { return &self; } const LDKCOption_ClosureReasonZ* operator ->() const { return &self; } }; +class CVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ { +private: + LDKCVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ self; +public: + CVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ(const CVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ&) = delete; + CVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ(CVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ)); } + CVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ(LDKCVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ)); } + operator LDKCVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ() && { LDKCVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ res = self; memset(&self, 0, sizeof(LDKCVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ)); return res; } + ~CVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ() { CVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ_free(self); } + CVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ& operator=(CVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ&& o) { CVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ)); return *this; } + LDKCVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ* operator &() { return &self; } + LDKCVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ* operator ->() { return &self; } + const LDKCVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ* operator &() const { return &self; } + const LDKCVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ* operator ->() const { return &self; } +}; class CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ { private: LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ self; @@ -12675,6 +13283,21 @@ public: const LDKCResult_TransactionU16LenLimitedDecodeErrorZ* operator &() const { return &self; } const LDKCResult_TransactionU16LenLimitedDecodeErrorZ* operator ->() const { return &self; } }; +class CResult_FundingInfoDecodeErrorZ { +private: + LDKCResult_FundingInfoDecodeErrorZ self; +public: + CResult_FundingInfoDecodeErrorZ(const CResult_FundingInfoDecodeErrorZ&) = delete; + CResult_FundingInfoDecodeErrorZ(CResult_FundingInfoDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_FundingInfoDecodeErrorZ)); } + CResult_FundingInfoDecodeErrorZ(LDKCResult_FundingInfoDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_FundingInfoDecodeErrorZ)); } + operator LDKCResult_FundingInfoDecodeErrorZ() && { LDKCResult_FundingInfoDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_FundingInfoDecodeErrorZ)); return res; } + ~CResult_FundingInfoDecodeErrorZ() { CResult_FundingInfoDecodeErrorZ_free(self); } + CResult_FundingInfoDecodeErrorZ& operator=(CResult_FundingInfoDecodeErrorZ&& o) { CResult_FundingInfoDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_FundingInfoDecodeErrorZ)); return *this; } + LDKCResult_FundingInfoDecodeErrorZ* operator &() { return &self; } + LDKCResult_FundingInfoDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_FundingInfoDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_FundingInfoDecodeErrorZ* operator ->() const { return &self; } +}; class COption_AmountZ { private: LDKCOption_AmountZ self; @@ -12690,6 +13313,21 @@ public: const LDKCOption_AmountZ* operator &() const { return &self; } const LDKCOption_AmountZ* operator ->() const { return &self; } }; +class COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ { +private: + LDKCOption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ self; +public: + COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ(const COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ&) = delete; + COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ(COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ)); } + COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ(LDKCOption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ)); } + operator LDKCOption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ() && { LDKCOption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ res = self; memset(&self, 0, sizeof(LDKCOption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ)); return res; } + ~COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ() { COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ_free(self); } + COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ& operator=(COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ&& o) { COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ)); return *this; } + LDKCOption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ* operator &() { return &self; } + LDKCOption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ* operator ->() { return &self; } + const LDKCOption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ* operator &() const { return &self; } + const LDKCOption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ* operator ->() const { return &self; } +}; class CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ { private: LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ self; @@ -12950,12 +13588,12 @@ inline LDK::CResult_SchnorrSignatureNoneZ SignBolt12InvoiceFn::sign_invoice(cons LDK::CResult_SchnorrSignatureNoneZ ret = (self.sign_invoice)(self.this_arg, message); return ret; } -inline LDKPublicKey ChannelSigner::get_per_commitment_point(uint64_t idx) { - LDKPublicKey ret = (self.get_per_commitment_point)(self.this_arg, idx); +inline LDK::CResult_PublicKeyNoneZ ChannelSigner::get_per_commitment_point(uint64_t idx) { + LDK::CResult_PublicKeyNoneZ ret = (self.get_per_commitment_point)(self.this_arg, idx); return ret; } -inline LDKThirtyTwoBytes ChannelSigner::release_commitment_secret(uint64_t idx) { - LDKThirtyTwoBytes ret = (self.release_commitment_secret)(self.this_arg, idx); +inline LDK::CResult__u832NoneZ ChannelSigner::release_commitment_secret(uint64_t idx) { + LDK::CResult__u832NoneZ ret = (self.release_commitment_secret)(self.this_arg, idx); return ret; } inline LDK::CResult_NoneNoneZ ChannelSigner::validate_holder_commitment(const struct LDKHolderCommitmentTransaction *NONNULL_PTR holder_tx, struct LDKCVec_ThirtyTwoBytesZ outbound_htlc_preimages) { @@ -12989,8 +13627,8 @@ inline LDK::CResult_ThirtyTwoBytesNoneZ NodeSigner::ecdh(enum LDKRecipient recip LDK::CResult_ThirtyTwoBytesNoneZ ret = (self.ecdh)(self.this_arg, recipient, other_key, tweak); return ret; } -inline LDK::CResult_RecoverableSignatureNoneZ NodeSigner::sign_invoice(struct LDKu8slice hrp_bytes, struct LDKCVec_U5Z invoice_data, enum LDKRecipient recipient) { - LDK::CResult_RecoverableSignatureNoneZ ret = (self.sign_invoice)(self.this_arg, hrp_bytes, invoice_data, recipient); +inline LDK::CResult_RecoverableSignatureNoneZ NodeSigner::sign_invoice(const struct LDKRawBolt11Invoice *NONNULL_PTR invoice, enum LDKRecipient recipient) { + LDK::CResult_RecoverableSignatureNoneZ ret = (self.sign_invoice)(self.this_arg, invoice, recipient); return ret; } inline LDK::CResult_SchnorrSignatureNoneZ NodeSigner::sign_bolt12_invoice_request(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR invoice_request) { @@ -13013,12 +13651,12 @@ inline LDKThirtyTwoBytes SignerProvider::generate_channel_keys_id(bool inbound, LDKThirtyTwoBytes ret = (self.generate_channel_keys_id)(self.this_arg, inbound, channel_value_satoshis, user_channel_id); return ret; } -inline LDK::WriteableEcdsaChannelSigner SignerProvider::derive_channel_signer(uint64_t channel_value_satoshis, struct LDKThirtyTwoBytes channel_keys_id) { - LDK::WriteableEcdsaChannelSigner ret = (self.derive_channel_signer)(self.this_arg, channel_value_satoshis, channel_keys_id); +inline LDK::EcdsaChannelSigner SignerProvider::derive_channel_signer(uint64_t channel_value_satoshis, struct LDKThirtyTwoBytes channel_keys_id) { + LDK::EcdsaChannelSigner ret = (self.derive_channel_signer)(self.this_arg, channel_value_satoshis, channel_keys_id); return ret; } -inline LDK::CResult_WriteableEcdsaChannelSignerDecodeErrorZ SignerProvider::read_chan_signer(struct LDKu8slice reader) { - LDK::CResult_WriteableEcdsaChannelSignerDecodeErrorZ ret = (self.read_chan_signer)(self.this_arg, reader); +inline LDK::CResult_EcdsaChannelSignerDecodeErrorZ SignerProvider::read_chan_signer(struct LDKu8slice reader) { + LDK::CResult_EcdsaChannelSignerDecodeErrorZ ret = (self.read_chan_signer)(self.this_arg, reader); return ret; } inline LDK::CResult_CVec_u8ZNoneZ SignerProvider::get_destination_script(struct LDKThirtyTwoBytes channel_keys_id) { @@ -13041,8 +13679,8 @@ inline LDK::CResult_RouteLightningErrorZ Router::find_route_with_id(struct LDKPu 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::CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ Router::create_blinded_payment_paths(struct LDKPublicKey recipient, struct LDKCVec_ChannelDetailsZ first_hops, struct LDKReceiveTlvs tlvs, uint64_t amount_msats) { - LDK::CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ ret = (self.create_blinded_payment_paths)(self.this_arg, recipient, first_hops, tlvs, amount_msats); +inline LDK::CResult_CVec_BlindedPaymentPathZNoneZ Router::create_blinded_payment_paths(struct LDKPublicKey recipient, struct LDKCVec_ChannelDetailsZ first_hops, struct LDKReceiveTlvs tlvs, uint64_t amount_msats) { + LDK::CResult_CVec_BlindedPaymentPathZNoneZ ret = (self.create_blinded_payment_paths)(self.this_arg, recipient, first_hops, tlvs, amount_msats); return ret; } inline uint64_t ScoreLookUp::channel_penalty_msat(const struct LDKCandidateRouteHop *NONNULL_PTR candidate, struct LDKChannelUsage usage, const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR score_params) { @@ -13176,6 +13814,13 @@ 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 void CustomMessageHandler::peer_disconnected(struct LDKPublicKey their_node_id) { + (self.peer_disconnected)(self.this_arg, their_node_id); +} +inline LDK::CResult_NoneNoneZ CustomMessageHandler::peer_connected(struct LDKPublicKey their_node_id, const struct LDKInit *NONNULL_PTR msg, bool inbound) { + LDK::CResult_NoneNoneZ ret = (self.peer_connected)(self.this_arg, their_node_id, msg, inbound); + return ret; +} inline LDK::NodeFeatures CustomMessageHandler::provided_node_features() { LDK::NodeFeatures ret = (self.provided_node_features)(self.this_arg); return ret; @@ -13392,10 +14037,6 @@ inline LDK::InitFeatures RoutingMessageHandler::provided_init_features(struct LD LDK::InitFeatures ret = (self.provided_init_features)(self.this_arg, their_node_id); return ret; } -inline LDK::CVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ OnionMessageHandler::get_and_clear_connections_needed() { - LDK::CVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ ret = (self.get_and_clear_connections_needed)(self.this_arg); - return ret; -} inline void OnionMessageHandler::handle_onion_message(struct LDKPublicKey peer_node_id, const struct LDKOnionMessage *NONNULL_PTR msg) { (self.handle_onion_message)(self.this_arg, peer_node_id, msg); } @@ -13427,12 +14068,23 @@ inline void Logger::log(struct LDKRecord 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); +inline LDK::COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ AsyncPaymentsMessageHandler::held_htlc_available(struct LDKHeldHtlcAvailable message, struct LDKResponder responder) { + LDK::COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ ret = (self.held_htlc_available)(self.this_arg, message, responder); + return ret; +} +inline void AsyncPaymentsMessageHandler::release_held_htlc(struct LDKReleaseHeldHtlc message) { + (self.release_held_htlc)(self.this_arg, message); +} +inline LDK::CVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ AsyncPaymentsMessageHandler::release_pending_messages() { + LDK::CVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ ret = (self.release_pending_messages)(self.this_arg); + return ret; +} +inline LDK::COption_C2Tuple_OffersMessageResponseInstructionZZ OffersMessageHandler::handle_message(struct LDKOffersMessage message, struct LDKCOption_OffersContextZ context, struct LDKResponder responder) { + LDK::COption_C2Tuple_OffersMessageResponseInstructionZZ ret = (self.handle_message)(self.this_arg, message, context, responder); return ret; } -inline LDK::CVec_C3Tuple_OffersMessageDestinationBlindedPathZZ OffersMessageHandler::release_pending_messages() { - LDK::CVec_C3Tuple_OffersMessageDestinationBlindedPathZZ ret = (self.release_pending_messages)(self.this_arg); +inline LDK::CVec_C2Tuple_OffersMessageMessageSendInstructionsZZ OffersMessageHandler::release_pending_messages() { + LDK::CVec_C2Tuple_OffersMessageMessageSendInstructionsZZ ret = (self.release_pending_messages)(self.this_arg); return ret; } inline void BroadcasterInterface::broadcast_transactions(struct LDKCVec_TransactionZ txs) { @@ -13446,6 +14098,10 @@ inline uint64_t OnionMessageContents::tlv_type() { uint64_t ret = (self.tlv_type)(self.this_arg); return ret; } +inline LDK::Str OnionMessageContents::msg_type() { + LDK::Str ret = (self.msg_type)(self.this_arg); + return ret; +} inline LDK::Str OnionMessageContents::debug_str() { LDK::Str ret = (self.debug_str)(self.this_arg); return ret; @@ -13457,8 +14113,9 @@ inline LDK::CVec_MessageSendEventZ MessageSendEventsProvider::get_and_clear_pend 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_NoneReplayEventZ EventHandler::handle_event(struct LDKEvent event) { + LDK::CResult_NoneReplayEventZ ret = (self.handle_event)(self.this_arg, event); + 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); @@ -13480,32 +14137,36 @@ inline LDK::CResult_OnionMessagePathNoneZ MessageRouter::find_path(struct LDKPub LDK::CResult_OnionMessagePathNoneZ ret = (self.find_path)(self.this_arg, sender, peers, destination); return ret; } -inline LDK::CResult_CVec_BlindedPathZNoneZ MessageRouter::create_blinded_paths(struct LDKPublicKey recipient, struct LDKCVec_PublicKeyZ peers) { - LDK::CResult_CVec_BlindedPathZNoneZ ret = (self.create_blinded_paths)(self.this_arg, recipient, peers); +inline LDK::CResult_CVec_BlindedMessagePathZNoneZ MessageRouter::create_blinded_paths(struct LDKPublicKey recipient, struct LDKMessageContext context, struct LDKCVec_PublicKeyZ peers) { + LDK::CResult_CVec_BlindedMessagePathZNoneZ ret = (self.create_blinded_paths)(self.this_arg, recipient, context, peers); + return ret; +} +inline LDK::CResult_CVec_BlindedMessagePathZNoneZ MessageRouter::create_compact_blinded_paths(struct LDKPublicKey recipient, struct LDKMessageContext context, struct LDKCVec_MessageForwardNodeZ peers) { + LDK::CResult_CVec_BlindedMessagePathZNoneZ ret = (self.create_compact_blinded_paths)(self.this_arg, recipient, context, peers); return ret; } -inline LDK::COption_OnionMessageContentsZ CustomOnionMessageHandler::handle_custom_message(struct LDKOnionMessageContents msg) { - LDK::COption_OnionMessageContentsZ ret = (self.handle_custom_message)(self.this_arg, msg); +inline LDK::COption_C2Tuple_OnionMessageContentsResponseInstructionZZ CustomOnionMessageHandler::handle_custom_message(struct LDKOnionMessageContents message, struct LDKCOption_CVec_u8ZZ context, struct LDKResponder responder) { + LDK::COption_C2Tuple_OnionMessageContentsResponseInstructionZZ ret = (self.handle_custom_message)(self.this_arg, message, context, responder); return ret; } inline LDK::CResult_COption_OnionMessageContentsZDecodeErrorZ CustomOnionMessageHandler::read_custom_message(uint64_t message_type, struct LDKu8slice buffer) { LDK::CResult_COption_OnionMessageContentsZDecodeErrorZ ret = (self.read_custom_message)(self.this_arg, message_type, buffer); return ret; } -inline LDK::CVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ CustomOnionMessageHandler::release_pending_custom_messages() { - LDK::CVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ ret = (self.release_pending_custom_messages)(self.this_arg); +inline LDK::CVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ CustomOnionMessageHandler::release_pending_custom_messages() { + LDK::CVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ ret = (self.release_pending_custom_messages)(self.this_arg); return ret; } inline LDKPublicKey NodeIdLookUp::next_node_id(uint64_t short_channel_id) { LDKPublicKey ret = (self.next_node_id)(self.this_arg, short_channel_id); return ret; } -inline LDK::ChannelMonitorUpdateStatus Persist::persist_new_channel(struct LDKOutPoint channel_funding_outpoint, const struct LDKChannelMonitor *NONNULL_PTR data, struct LDKMonitorUpdateId update_id) { - LDK::ChannelMonitorUpdateStatus ret = (self.persist_new_channel)(self.this_arg, channel_funding_outpoint, data, update_id); +inline LDK::ChannelMonitorUpdateStatus Persist::persist_new_channel(struct LDKOutPoint channel_funding_outpoint, const struct LDKChannelMonitor *NONNULL_PTR monitor) { + LDK::ChannelMonitorUpdateStatus ret = (self.persist_new_channel)(self.this_arg, channel_funding_outpoint, monitor); return ret; } -inline LDK::ChannelMonitorUpdateStatus Persist::update_persisted_channel(struct LDKOutPoint channel_funding_outpoint, struct LDKChannelMonitorUpdate update, const struct LDKChannelMonitor *NONNULL_PTR data, struct LDKMonitorUpdateId update_id) { - LDK::ChannelMonitorUpdateStatus ret = (self.update_persisted_channel)(self.this_arg, channel_funding_outpoint, update, data, update_id); +inline LDK::ChannelMonitorUpdateStatus Persist::update_persisted_channel(struct LDKOutPoint channel_funding_outpoint, struct LDKChannelMonitorUpdate monitor_update, const struct LDKChannelMonitor *NONNULL_PTR monitor) { + LDK::ChannelMonitorUpdateStatus ret = (self.update_persisted_channel)(self.this_arg, channel_funding_outpoint, monitor_update, monitor); return ret; } inline void Persist::archive_persisted_channel(struct LDKOutPoint channel_funding_outpoint) { diff --git a/lightning-c-bindings/src/c_types/derived.rs b/lightning-c-bindings/src/c_types/derived.rs index c15c8d8..1dc119a 100644 --- a/lightning-c-bindings/src/c_types/derived.rs +++ b/lightning-c-bindings/src/c_types/derived.rs @@ -284,29 +284,29 @@ 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)] -/// A dynamically-allocated array of crate::lightning::blinded_path::BlindedPaths of arbitrary size. +/// A dynamically-allocated array of crate::lightning::blinded_path::message::BlindedMessagePaths of arbitrary size. /// This corresponds to std::vector in C++ -pub struct CVec_BlindedPathZ { +pub struct CVec_BlindedMessagePathZ { /// 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::BlindedPath, + pub data: *mut crate::lightning::blinded_path::message::BlindedMessagePath, /// The number of elements pointed to by `data`. pub datalen: usize } -impl CVec_BlindedPathZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { +impl CVec_BlindedMessagePathZ { + #[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::BlindedPath] { + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::blinded_path::message::BlindedMessagePath] { unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl From> for CVec_BlindedPathZ { - fn from(v: Vec) -> Self { +impl From> for CVec_BlindedMessagePathZ { + 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() } } @@ -314,14 +314,14 @@ impl From> for CVec_BlindedPath } #[no_mangle] /// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_BlindedPathZ_free(_res: CVec_BlindedPathZ) { } -impl Drop for CVec_BlindedPathZ { +pub extern "C" fn CVec_BlindedMessagePathZ_free(_res: CVec_BlindedMessagePathZ) { } +impl Drop for CVec_BlindedMessagePathZ { 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_BlindedPathZ { +impl Clone for CVec_BlindedMessagePathZ { fn clone(&self) -> Self { let mut res = Vec::new(); if self.datalen == 0 { return Self::from(res); } @@ -330,6 +330,102 @@ impl Clone for CVec_BlindedPathZ { } } #[repr(C)] +/// The contents of CResult_RefundDecodeErrorZ +pub union CResult_RefundDecodeErrorZPtr { + /// 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::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_RefundDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::offers::refund::Refund 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_RefundDecodeErrorZ { + /// The contents of this CResult_RefundDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_RefundDecodeErrorZPtr, + /// Whether this CResult_RefundDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_RefundDecodeErrorZ in the success state. +pub extern "C" fn CResult_RefundDecodeErrorZ_ok(o: crate::lightning::offers::refund::Refund) -> CResult_RefundDecodeErrorZ { + CResult_RefundDecodeErrorZ { + contents: CResult_RefundDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_RefundDecodeErrorZ in the error state. +pub extern "C" fn CResult_RefundDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_RefundDecodeErrorZ { + CResult_RefundDecodeErrorZ { + contents: CResult_RefundDecodeErrorZPtr { + 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_RefundDecodeErrorZ_is_ok(o: &CResult_RefundDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_RefundDecodeErrorZ. +pub extern "C" fn CResult_RefundDecodeErrorZ_free(_res: CResult_RefundDecodeErrorZ) { } +impl Drop for CResult_RefundDecodeErrorZ { + 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_RefundDecodeErrorZ { + 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_RefundDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_RefundDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_RefundDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_RefundDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_RefundDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_RefundDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_RefundDecodeErrorZ_clone(orig: &CResult_RefundDecodeErrorZ) -> CResult_RefundDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] /// The contents of CResult_RefundBolt12ParseErrorZ pub union CResult_RefundBolt12ParseErrorZPtr { /// A pointer to the contents in the success state. @@ -1340,6 +1436,52 @@ impl Clone for CResult_SchnorrSignatureNoneZ { /// but with all dynamically-allocated buffers duplicated in new buffers. pub extern "C" fn CResult_SchnorrSignatureNoneZ_clone(orig: &CResult_SchnorrSignatureNoneZ) -> CResult_SchnorrSignatureNoneZ { 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_StrZ { + /// 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_StrZ { + #[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_StrZ { + 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_StrZ_free(_res: CVec_StrZ) { } +impl Drop for CVec_StrZ { + 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_StrZ { + 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_ThirtyTwoBytesZ { @@ -1589,41 +1731,41 @@ impl Clone for CResult_ThirtyTwoBytesNoneZ { /// but with all dynamically-allocated buffers duplicated in new buffers. pub extern "C" fn CResult_ThirtyTwoBytesNoneZ_clone(orig: &CResult_ThirtyTwoBytesNoneZ) -> CResult_ThirtyTwoBytesNoneZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_BlindedPayInfoDecodeErrorZ -pub union CResult_BlindedPayInfoDecodeErrorZPtr { +/// The contents of CResult_Bolt12InvoiceDecodeErrorZ +pub union CResult_Bolt12InvoiceDecodeErrorZPtr { /// 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, + pub result: *mut crate::lightning::offers::invoice::Bolt12Invoice, /// 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_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_Bolt12InvoiceDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::offers::invoice::Bolt12Invoice 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 +pub struct CResult_Bolt12InvoiceDecodeErrorZ { + /// The contents of this CResult_Bolt12InvoiceDecodeErrorZ, 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 contents: CResult_Bolt12InvoiceDecodeErrorZPtr, + /// Whether this CResult_Bolt12InvoiceDecodeErrorZ represents a success state. pub result_ok: bool, } #[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 { +/// Creates a new CResult_Bolt12InvoiceDecodeErrorZ in the success state. +pub extern "C" fn CResult_Bolt12InvoiceDecodeErrorZ_ok(o: crate::lightning::offers::invoice::Bolt12Invoice) -> CResult_Bolt12InvoiceDecodeErrorZ { + CResult_Bolt12InvoiceDecodeErrorZ { + contents: CResult_Bolt12InvoiceDecodeErrorZPtr { 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 { +/// Creates a new CResult_Bolt12InvoiceDecodeErrorZ in the error state. +pub extern "C" fn CResult_Bolt12InvoiceDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_Bolt12InvoiceDecodeErrorZ { + CResult_Bolt12InvoiceDecodeErrorZ { + contents: CResult_Bolt12InvoiceDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -1631,13 +1773,13 @@ pub extern "C" fn CResult_BlindedPayInfoDecodeErrorZ_err(e: crate::lightning::ln } /// 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_Bolt12InvoiceDecodeErrorZ_is_ok(o: &CResult_Bolt12InvoiceDecodeErrorZ) -> 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_Bolt12InvoiceDecodeErrorZ. +pub extern "C" fn CResult_Bolt12InvoiceDecodeErrorZ_free(_res: CResult_Bolt12InvoiceDecodeErrorZ) { } +impl Drop for CResult_Bolt12InvoiceDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -1650,16 +1792,16 @@ impl Drop for CResult_BlindedPayInfoDecodeErrorZ { } } } -impl From> for CResult_BlindedPayInfoDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_Bolt12InvoiceDecodeErrorZ { + 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_Bolt12InvoiceDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_BlindedPayInfoDecodeErrorZPtr { err } + CResult_Bolt12InvoiceDecodeErrorZPtr { err } }; Self { contents, @@ -1667,23 +1809,23 @@ 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_Bolt12InvoiceDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_BlindedPayInfoDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_Bolt12InvoiceDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_BlindedPayInfoDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_Bolt12InvoiceDecodeErrorZ 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) } +pub extern "C" fn CResult_Bolt12InvoiceDecodeErrorZ_clone(orig: &CResult_Bolt12InvoiceDecodeErrorZ) -> CResult_Bolt12InvoiceDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] /// The contents of CResult_DelayedPaymentOutputDescriptorDecodeErrorZ pub union CResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr { @@ -2428,39 +2570,40 @@ impl Clone for CResult_HTLCDescriptorDecodeErrorZ { /// but with all dynamically-allocated buffers duplicated in new buffers. pub extern "C" fn CResult_HTLCDescriptorDecodeErrorZ_clone(orig: &CResult_HTLCDescriptorDecodeErrorZ) -> CResult_HTLCDescriptorDecodeErrorZ { Clone::clone(&orig) } #[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, +/// 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::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_NoneNoneZ represents the result of a fallible operation, -/// containing a () 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_NoneNoneZ { - /// The contents of this CResult_NoneNoneZ, 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_NoneNoneZPtr, - /// Whether this CResult_NoneNoneZ 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_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_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_NoneNoneZ in the error state. -pub extern "C" fn CResult_NoneNoneZ_err() -> CResult_NoneNoneZ { - CResult_NoneNoneZ { - contents: CResult_NoneNoneZPtr { +/// 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, @@ -2468,29 +2611,32 @@ pub extern "C" fn CResult_NoneNoneZ_err() -> CResult_NoneNoneZ { } /// 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_PublicKeyNoneZ_is_ok(o: &CResult_PublicKeyNoneZ) -> 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_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() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } } else { } } } -impl From> for CResult_NoneNoneZ { - 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 _ = 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_PublicKeyNoneZPtr { result } } else { let _ = unsafe { Box::from_raw(o.contents.err) }; o.contents.err = core::ptr::null_mut(); - CResult_NoneNoneZPtr { err: core::ptr::null_mut() } + CResult_PublicKeyNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -2498,58 +2644,58 @@ impl From> for CResult_NoneNoneZ { } } } -impl Clone for CResult_NoneNoneZ { +impl Clone for CResult_PublicKeyNoneZ { 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_PublicKeyNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_NoneNoneZPtr { + Self { result_ok: false, contents: CResult_PublicKeyNoneZPtr { err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_NoneNoneZ which has the same data as `orig` +/// 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_NoneNoneZ_clone(orig: &CResult_NoneNoneZ) -> CResult_NoneNoneZ { Clone::clone(&orig) } +pub extern "C" fn CResult_PublicKeyNoneZ_clone(orig: &CResult_PublicKeyNoneZ) -> CResult_PublicKeyNoneZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_PublicKeyNoneZ -pub union CResult_PublicKeyNoneZPtr { +/// The contents of CResult__u832NoneZ +pub union CResult__u832NoneZPtr { /// 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, + 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_PublicKeyNoneZ represents the result of a fallible operation, -/// containing a crate::c_types::PublicKey on success and a () on failure. +/// A CResult__u832NoneZ 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_PublicKeyNoneZ { - /// The contents of this CResult_PublicKeyNoneZ, accessible via either +pub struct CResult__u832NoneZ { + /// The contents of this CResult__u832NoneZ, 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__u832NoneZPtr, + /// Whether this CResult__u832NoneZ 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__u832NoneZ in the success state. +pub extern "C" fn CResult__u832NoneZ_ok(o: crate::c_types::ThirtyTwoBytes) -> CResult__u832NoneZ { + CResult__u832NoneZ { + contents: CResult__u832NoneZPtr { 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 { +/// Creates a new CResult__u832NoneZ in the error state. +pub extern "C" fn CResult__u832NoneZ_err() -> CResult__u832NoneZ { + CResult__u832NoneZ { + contents: CResult__u832NoneZPtr { err: core::ptr::null_mut(), }, result_ok: false, @@ -2557,13 +2703,13 @@ pub extern "C" fn CResult_PublicKeyNoneZ_err() -> CResult_PublicKeyNoneZ { } /// 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__u832NoneZ_is_ok(o: &CResult__u832NoneZ) -> 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__u832NoneZ. +pub extern "C" fn CResult__u832NoneZ_free(_res: CResult__u832NoneZ) { } +impl Drop for CResult__u832NoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -2573,16 +2719,16 @@ impl Drop for CResult_PublicKeyNoneZ { } } } -impl From> for CResult_PublicKeyNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult__u832NoneZ { + 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__u832NoneZPtr { result } } else { let _ = unsafe { Box::from_raw(o.contents.err) }; o.contents.err = core::ptr::null_mut(); - CResult_PublicKeyNoneZPtr { err: core::ptr::null_mut() } + CResult__u832NoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -2590,31 +2736,119 @@ impl From> for CResu } } } -impl Clone for CResult_PublicKeyNoneZ { +impl Clone for CResult__u832NoneZ { 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__u832NoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_PublicKeyNoneZPtr { + Self { result_ok: false, contents: CResult__u832NoneZPtr { err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_PublicKeyNoneZ which has the same data as `orig` +/// Creates a new CResult__u832NoneZ 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__u832NoneZ_clone(orig: &CResult__u832NoneZ) -> CResult__u832NoneZ { Clone::clone(&orig) } #[repr(C)] -#[derive(Clone)] -/// An enum which can either contain a crate::c_types::BigEndianScalar or not -pub enum COption_BigEndianScalarZ { - /// When we're in this state, this COption_BigEndianScalarZ contains a crate::c_types::BigEndianScalar - Some(crate::c_types::BigEndianScalar), - /// When we're in this state, this COption_BigEndianScalarZ contains nothing - None +/// 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_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_NoneNoneZ { + /// The contents of this CResult_NoneNoneZ, 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 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(), + }, + 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(), + }, + 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 { + 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 { + fn drop(&mut self) { + if self.result_ok { + } else { + } + } +} +impl From> for CResult_NoneNoneZ { + 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() } + } else { + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_NoneNoneZPtr { err: core::ptr::null_mut() } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_NoneNoneZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_NoneNoneZPtr { + result: core::ptr::null_mut() + } } + } else { + Self { result_ok: false, contents: CResult_NoneNoneZPtr { + err: core::ptr::null_mut() + } } + } + } +} +#[no_mangle] +/// 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_NoneNoneZ_clone(orig: &CResult_NoneNoneZ) -> CResult_NoneNoneZ { Clone::clone(&orig) } +#[repr(C)] +#[derive(Clone)] +/// An enum which can either contain a crate::c_types::BigEndianScalar or not +pub enum COption_BigEndianScalarZ { + /// When we're in this state, this COption_BigEndianScalarZ contains a crate::c_types::BigEndianScalar + Some(crate::c_types::BigEndianScalar), + /// When we're in this state, this COption_BigEndianScalarZ contains nothing + None } impl COption_BigEndianScalarZ { #[allow(unused)] pub(crate) fn is_some(&self) -> bool { @@ -2645,52 +2879,6 @@ pub extern "C" fn COption_BigEndianScalarZ_free(_res: COption_BigEndianScalarZ) /// but with all dynamically-allocated buffers duplicated in new buffers. pub extern "C" fn COption_BigEndianScalarZ_clone(orig: &COption_BigEndianScalarZ) -> COption_BigEndianScalarZ { 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) } - } -} -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. @@ -2967,41 +3155,41 @@ impl Clone for CResult_TransactionNoneZ { /// 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) } #[repr(C)] -/// The contents of CResult_WriteableEcdsaChannelSignerDecodeErrorZ -pub union CResult_WriteableEcdsaChannelSignerDecodeErrorZPtr { +/// The contents of CResult_EcdsaChannelSignerDecodeErrorZ +pub union CResult_EcdsaChannelSignerDecodeErrorZPtr { /// 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::ecdsa::WriteableEcdsaChannelSigner, + pub result: *mut crate::lightning::sign::ecdsa::EcdsaChannelSigner, /// 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_WriteableEcdsaChannelSignerDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::sign::ecdsa::WriteableEcdsaChannelSigner on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_EcdsaChannelSignerDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::sign::ecdsa::EcdsaChannelSigner 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 +pub struct CResult_EcdsaChannelSignerDecodeErrorZ { + /// The contents of this CResult_EcdsaChannelSignerDecodeErrorZ, 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 contents: CResult_EcdsaChannelSignerDecodeErrorZPtr, + /// Whether this CResult_EcdsaChannelSignerDecodeErrorZ 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::sign::ecdsa::WriteableEcdsaChannelSigner) -> CResult_WriteableEcdsaChannelSignerDecodeErrorZ { - CResult_WriteableEcdsaChannelSignerDecodeErrorZ { - contents: CResult_WriteableEcdsaChannelSignerDecodeErrorZPtr { +/// Creates a new CResult_EcdsaChannelSignerDecodeErrorZ in the success state. +pub extern "C" fn CResult_EcdsaChannelSignerDecodeErrorZ_ok(o: crate::lightning::sign::ecdsa::EcdsaChannelSigner) -> CResult_EcdsaChannelSignerDecodeErrorZ { + CResult_EcdsaChannelSignerDecodeErrorZ { + contents: CResult_EcdsaChannelSignerDecodeErrorZPtr { 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 { +/// Creates a new CResult_EcdsaChannelSignerDecodeErrorZ in the error state. +pub extern "C" fn CResult_EcdsaChannelSignerDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_EcdsaChannelSignerDecodeErrorZ { + CResult_EcdsaChannelSignerDecodeErrorZ { + contents: CResult_EcdsaChannelSignerDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -3009,13 +3197,13 @@ pub extern "C" fn CResult_WriteableEcdsaChannelSignerDecodeErrorZ_err(e: crate:: } /// 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 { +pub extern "C" fn CResult_EcdsaChannelSignerDecodeErrorZ_is_ok(o: &CResult_EcdsaChannelSignerDecodeErrorZ) -> 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 { +/// Frees any resources used by the CResult_EcdsaChannelSignerDecodeErrorZ. +pub extern "C" fn CResult_EcdsaChannelSignerDecodeErrorZ_free(_res: CResult_EcdsaChannelSignerDecodeErrorZ) { } +impl Drop for CResult_EcdsaChannelSignerDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -3028,16 +3216,16 @@ impl Drop for CResult_WriteableEcdsaChannelSignerDecodeErrorZ { } } } -impl From> for CResult_WriteableEcdsaChannelSignerDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_EcdsaChannelSignerDecodeErrorZ { + 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 } + CResult_EcdsaChannelSignerDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_WriteableEcdsaChannelSignerDecodeErrorZPtr { err } + CResult_EcdsaChannelSignerDecodeErrorZPtr { err } }; Self { contents, @@ -3045,23 +3233,23 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_WriteableEcdsaChannelSignerDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_EcdsaChannelSignerDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_WriteableEcdsaChannelSignerDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_EcdsaChannelSignerDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_WriteableEcdsaChannelSignerDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_EcdsaChannelSignerDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_WriteableEcdsaChannelSignerDecodeErrorZ_clone(orig: &CResult_WriteableEcdsaChannelSignerDecodeErrorZ) -> CResult_WriteableEcdsaChannelSignerDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_EcdsaChannelSignerDecodeErrorZ_clone(orig: &CResult_EcdsaChannelSignerDecodeErrorZ) -> CResult_EcdsaChannelSignerDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] /// The contents of CResult_CVec_u8ZNoneZ pub union CResult_CVec_u8ZNoneZPtr { @@ -3813,123 +4001,119 @@ impl Clone for CResult_NoneIOErrorZ { /// but with all dynamically-allocated buffers duplicated in new buffers. pub extern "C" fn CResult_NoneIOErrorZ_clone(orig: &CResult_NoneIOErrorZ) -> CResult_NoneIOErrorZ { Clone::clone(&orig) } #[repr(C)] -/// A dynamically-allocated array of crate::lightning::ln::channel_state::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::channel_state::ChannelDetails, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -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::channel_state::ChannelDetails] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } +/// A tuple of 3 elements. See the individual fields for the types contained. +pub struct C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ { + /// The element at position 0 + pub a: crate::c_types::ThirtyTwoBytes, + /// The element at position 1 + pub b: crate::lightning::ln::outbound_payment::RecipientOnionFields, + /// The element at position 2 + pub c: crate::lightning::routing::router::RouteParameters, } -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() } } +impl From<(crate::c_types::ThirtyTwoBytes, crate::lightning::ln::outbound_payment::RecipientOnionFields, crate::lightning::routing::router::RouteParameters)> for C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ { + fn from (tup: (crate::c_types::ThirtyTwoBytes, crate::lightning::ln::outbound_payment::RecipientOnionFields, crate::lightning::routing::router::RouteParameters)) -> Self { + Self { + a: tup.0, + b: tup.1, + c: tup.2, + } } } -#[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 C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoBytes, crate::lightning::ln::outbound_payment::RecipientOnionFields, crate::lightning::routing::router::RouteParameters) { + (self.a, self.b, self.c) } } -impl Clone for CVec_ChannelDetailsZ { +impl Clone for C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ { 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), + 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_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ_clone(orig: &C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ) -> C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ { Clone::clone(&orig) } +/// Creates a new C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ from the contained elements. +#[no_mangle] +pub extern "C" fn C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ_new(a: crate::c_types::ThirtyTwoBytes, b: crate::lightning::ln::outbound_payment::RecipientOnionFields, c: crate::lightning::routing::router::RouteParameters) -> C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ { + C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ { a, b, c, } +} + +#[no_mangle] +/// Frees any resources used by the C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ. +pub extern "C" fn C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ_free(_res: C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ) { } #[repr(C)] -/// The contents of CResult_RouteLightningErrorZ -pub union CResult_RouteLightningErrorZPtr { +/// The contents of CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ +pub union CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZPtr { /// 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, + pub result: *mut crate::c_types::derived::C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ, + /// 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_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. +/// A CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ on success and a () 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 +pub struct CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ { + /// The contents of this CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ, 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 contents: CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZPtr, + /// Whether this CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ 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 { +/// Creates a new CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ in the success state. +pub extern "C" fn CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ_ok(o: crate::c_types::derived::C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ) -> CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ { + CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ { + contents: CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZPtr { 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)), +/// Creates a new CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ in the error state. +pub extern "C" fn CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ_err() -> CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ { + CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ { + contents: CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZPtr { + 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_RouteLightningErrorZ_is_ok(o: &CResult_RouteLightningErrorZ) -> bool { +pub extern "C" fn CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ_is_ok(o: &CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ) -> 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_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ. +pub extern "C" fn CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ_free(_res: CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ) { } +impl Drop for CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ { 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_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ { + 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_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZPtr { 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_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -3937,89 +4121,189 @@ 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_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZPtr { + 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_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZPtr { + err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_RouteLightningErrorZ which has the same data as `orig` +/// Creates a new CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ 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_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ_clone(orig: &CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ) -> CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ { 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, +/// A dynamically-allocated array of crate::lightning::ln::channel_state::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::channel_state::ChannelDetails, + /// The number of elements pointed to by `data`. + pub datalen: usize } -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 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::channel_state::ChannelDetails] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -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 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] +/// 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 C2Tuple_BlindedPayInfoBlindedPathZ { +impl Clone for CVec_ChannelDetailsZ { fn clone(&self) -> Self { - Self { - a: Clone::clone(&self.a), - b: Clone::clone(&self.b), - } + 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 tuple 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. +/// 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 C2Tuple_BlindedPayInfoBlindedPathZ_new(a: crate::lightning::offers::invoice::BlindedPayInfo, b: crate::lightning::blinded_path::BlindedPath) -> C2Tuple_BlindedPayInfoBlindedPathZ { - C2Tuple_BlindedPayInfoBlindedPathZ { a, b, } +pub extern "C" fn CResult_RouteLightningErrorZ_is_ok(o: &CResult_RouteLightningErrorZ) -> 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 { + 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 { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_RouteLightningErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_RouteLightningErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_RouteLightningErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + 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_RouteLightningErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } } - #[no_mangle] -/// Frees any resources used by the C2Tuple_BlindedPayInfoBlindedPathZ. -pub extern "C" fn C2Tuple_BlindedPayInfoBlindedPathZ_free(_res: C2Tuple_BlindedPayInfoBlindedPathZ) { } +/// 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_RouteLightningErrorZ_clone(orig: &CResult_RouteLightningErrorZ) -> CResult_RouteLightningErrorZ { 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::blinded_path::payment::BlindedPaymentPaths of arbitrary size. /// This corresponds to std::vector in C++ -pub struct CVec_C2Tuple_BlindedPayInfoBlindedPathZZ { +pub struct CVec_BlindedPaymentPathZ { /// 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::blinded_path::payment::BlindedPaymentPath, /// 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_BlindedPaymentPathZ { + #[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::blinded_path::payment::BlindedPaymentPath] { 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_BlindedPaymentPathZ { + 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() } } @@ -4027,14 +4311,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_BlindedPaymentPathZ_free(_res: CVec_BlindedPaymentPathZ) { } +impl Drop for CVec_BlindedPaymentPathZ { 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_BlindedPaymentPathZ { fn clone(&self) -> Self { let mut res = Vec::new(); if self.datalen == 0 { return Self::from(res); } @@ -4043,40 +4327,40 @@ impl Clone for CVec_C2Tuple_BlindedPayInfoBlindedPathZZ { } } #[repr(C)] -/// The contents of CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ -pub union CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZPtr { +/// The contents of CResult_CVec_BlindedPaymentPathZNoneZ +pub union CResult_CVec_BlindedPaymentPathZNoneZPtr { /// 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_BlindedPayInfoBlindedPathZZ, + pub result: *mut crate::c_types::derived::CVec_BlindedPaymentPathZ, /// 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_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::CVec_C2Tuple_BlindedPayInfoBlindedPathZZ on success and a () on failure. +/// A CResult_CVec_BlindedPaymentPathZNoneZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::CVec_BlindedPaymentPathZ on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ { - /// The contents of this CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ, accessible via either +pub struct CResult_CVec_BlindedPaymentPathZNoneZ { + /// The contents of this CResult_CVec_BlindedPaymentPathZNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZPtr, - /// Whether this CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ represents a success state. + pub contents: CResult_CVec_BlindedPaymentPathZNoneZPtr, + /// Whether this CResult_CVec_BlindedPaymentPathZNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ in the success state. -pub extern "C" fn CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ_ok(o: crate::c_types::derived::CVec_C2Tuple_BlindedPayInfoBlindedPathZZ) -> CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ { - CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ { - contents: CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZPtr { +/// Creates a new CResult_CVec_BlindedPaymentPathZNoneZ in the success state. +pub extern "C" fn CResult_CVec_BlindedPaymentPathZNoneZ_ok(o: crate::c_types::derived::CVec_BlindedPaymentPathZ) -> CResult_CVec_BlindedPaymentPathZNoneZ { + CResult_CVec_BlindedPaymentPathZNoneZ { + contents: CResult_CVec_BlindedPaymentPathZNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ in the error state. -pub extern "C" fn CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ_err() -> CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ { - CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ { - contents: CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZPtr { +/// Creates a new CResult_CVec_BlindedPaymentPathZNoneZ in the error state. +pub extern "C" fn CResult_CVec_BlindedPaymentPathZNoneZ_err() -> CResult_CVec_BlindedPaymentPathZNoneZ { + CResult_CVec_BlindedPaymentPathZNoneZ { + contents: CResult_CVec_BlindedPaymentPathZNoneZPtr { err: core::ptr::null_mut(), }, result_ok: false, @@ -4084,13 +4368,13 @@ pub extern "C" fn CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ_err() -> } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ_is_ok(o: &CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ) -> bool { +pub extern "C" fn CResult_CVec_BlindedPaymentPathZNoneZ_is_ok(o: &CResult_CVec_BlindedPaymentPathZNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ. -pub extern "C" fn CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ_free(_res: CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ) { } -impl Drop for CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ { +/// Frees any resources used by the CResult_CVec_BlindedPaymentPathZNoneZ. +pub extern "C" fn CResult_CVec_BlindedPaymentPathZNoneZ_free(_res: CResult_CVec_BlindedPaymentPathZNoneZ) { } +impl Drop for CResult_CVec_BlindedPaymentPathZNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -4100,16 +4384,16 @@ impl Drop for CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ { } } } -impl From> for CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_CVec_BlindedPaymentPathZNoneZ { + 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_BlindedPayInfoBlindedPathZZNoneZPtr { result } + CResult_CVec_BlindedPaymentPathZNoneZPtr { result } } else { let _ = unsafe { Box::from_raw(o.contents.err) }; o.contents.err = core::ptr::null_mut(); - CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZPtr { err: core::ptr::null_mut() } + CResult_CVec_BlindedPaymentPathZNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -4117,23 +4401,23 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_CVec_BlindedPaymentPathZNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZPtr { + Self { result_ok: false, contents: CResult_CVec_BlindedPaymentPathZNoneZPtr { err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ which has the same data as `orig` +/// Creates a new CResult_CVec_BlindedPaymentPathZNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ_clone(orig: &CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ) -> CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ { Clone::clone(&orig) } +pub extern "C" fn CResult_CVec_BlindedPaymentPathZNoneZ_clone(orig: &CResult_CVec_BlindedPaymentPathZNoneZ) -> CResult_CVec_BlindedPaymentPathZNoneZ { Clone::clone(&orig) } #[repr(C)] /// A dynamically-allocated array of crate::c_types::PublicKeys of arbitrary size. /// This corresponds to std::vector in C++ @@ -4273,40 +4557,40 @@ impl Clone for CResult_OnionMessagePathNoneZ { /// but with all dynamically-allocated buffers duplicated in new buffers. pub extern "C" fn CResult_OnionMessagePathNoneZ_clone(orig: &CResult_OnionMessagePathNoneZ) -> CResult_OnionMessagePathNoneZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_CVec_BlindedPathZNoneZ -pub union CResult_CVec_BlindedPathZNoneZPtr { +/// The contents of CResult_CVec_BlindedMessagePathZNoneZ +pub union CResult_CVec_BlindedMessagePathZNoneZPtr { /// 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_BlindedPathZ, + pub result: *mut crate::c_types::derived::CVec_BlindedMessagePathZ, /// 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_BlindedPathZNoneZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::CVec_BlindedPathZ on success and a () on failure. +/// A CResult_CVec_BlindedMessagePathZNoneZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::CVec_BlindedMessagePathZ on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_CVec_BlindedPathZNoneZ { - /// The contents of this CResult_CVec_BlindedPathZNoneZ, accessible via either +pub struct CResult_CVec_BlindedMessagePathZNoneZ { + /// The contents of this CResult_CVec_BlindedMessagePathZNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_CVec_BlindedPathZNoneZPtr, - /// Whether this CResult_CVec_BlindedPathZNoneZ represents a success state. + pub contents: CResult_CVec_BlindedMessagePathZNoneZPtr, + /// Whether this CResult_CVec_BlindedMessagePathZNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_CVec_BlindedPathZNoneZ in the success state. -pub extern "C" fn CResult_CVec_BlindedPathZNoneZ_ok(o: crate::c_types::derived::CVec_BlindedPathZ) -> CResult_CVec_BlindedPathZNoneZ { - CResult_CVec_BlindedPathZNoneZ { - contents: CResult_CVec_BlindedPathZNoneZPtr { +/// Creates a new CResult_CVec_BlindedMessagePathZNoneZ in the success state. +pub extern "C" fn CResult_CVec_BlindedMessagePathZNoneZ_ok(o: crate::c_types::derived::CVec_BlindedMessagePathZ) -> CResult_CVec_BlindedMessagePathZNoneZ { + CResult_CVec_BlindedMessagePathZNoneZ { + contents: CResult_CVec_BlindedMessagePathZNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_CVec_BlindedPathZNoneZ in the error state. -pub extern "C" fn CResult_CVec_BlindedPathZNoneZ_err() -> CResult_CVec_BlindedPathZNoneZ { - CResult_CVec_BlindedPathZNoneZ { - contents: CResult_CVec_BlindedPathZNoneZPtr { +/// Creates a new CResult_CVec_BlindedMessagePathZNoneZ in the error state. +pub extern "C" fn CResult_CVec_BlindedMessagePathZNoneZ_err() -> CResult_CVec_BlindedMessagePathZNoneZ { + CResult_CVec_BlindedMessagePathZNoneZ { + contents: CResult_CVec_BlindedMessagePathZNoneZPtr { err: core::ptr::null_mut(), }, result_ok: false, @@ -4314,13 +4598,13 @@ pub extern "C" fn CResult_CVec_BlindedPathZNoneZ_err() -> CResult_CVec_BlindedPa } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_CVec_BlindedPathZNoneZ_is_ok(o: &CResult_CVec_BlindedPathZNoneZ) -> bool { +pub extern "C" fn CResult_CVec_BlindedMessagePathZNoneZ_is_ok(o: &CResult_CVec_BlindedMessagePathZNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_CVec_BlindedPathZNoneZ. -pub extern "C" fn CResult_CVec_BlindedPathZNoneZ_free(_res: CResult_CVec_BlindedPathZNoneZ) { } -impl Drop for CResult_CVec_BlindedPathZNoneZ { +/// Frees any resources used by the CResult_CVec_BlindedMessagePathZNoneZ. +pub extern "C" fn CResult_CVec_BlindedMessagePathZNoneZ_free(_res: CResult_CVec_BlindedMessagePathZNoneZ) { } +impl Drop for CResult_CVec_BlindedMessagePathZNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -4330,16 +4614,16 @@ impl Drop for CResult_CVec_BlindedPathZNoneZ { } } } -impl From> for CResult_CVec_BlindedPathZNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_CVec_BlindedMessagePathZNoneZ { + 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_BlindedPathZNoneZPtr { result } + CResult_CVec_BlindedMessagePathZNoneZPtr { result } } else { let _ = unsafe { Box::from_raw(o.contents.err) }; o.contents.err = core::ptr::null_mut(); - CResult_CVec_BlindedPathZNoneZPtr { err: core::ptr::null_mut() } + CResult_CVec_BlindedMessagePathZNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -4347,23 +4631,69 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_CVec_BlindedPathZNoneZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_CVec_BlindedMessagePathZNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_CVec_BlindedPathZNoneZPtr { + Self { result_ok: false, contents: CResult_CVec_BlindedMessagePathZNoneZPtr { err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_CVec_BlindedPathZNoneZ which has the same data as `orig` +/// Creates a new CResult_CVec_BlindedMessagePathZNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_CVec_BlindedPathZNoneZ_clone(orig: &CResult_CVec_BlindedPathZNoneZ) -> CResult_CVec_BlindedPathZNoneZ { Clone::clone(&orig) } +pub extern "C" fn CResult_CVec_BlindedMessagePathZNoneZ_clone(orig: &CResult_CVec_BlindedMessagePathZNoneZ) -> CResult_CVec_BlindedMessagePathZNoneZ { Clone::clone(&orig) } +#[repr(C)] +/// A dynamically-allocated array of crate::lightning::blinded_path::message::MessageForwardNodes of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_MessageForwardNodeZ { + /// 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::message::MessageForwardNode, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_MessageForwardNodeZ { + #[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::message::MessageForwardNode] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_MessageForwardNodeZ { + 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_MessageForwardNodeZ_free(_res: CVec_MessageForwardNodeZ) { } +impl Drop for CVec_MessageForwardNodeZ { + 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_MessageForwardNodeZ { + 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_InFlightHtlcsDecodeErrorZ pub union CResult_InFlightHtlcsDecodeErrorZPtr { @@ -5125,29 +5455,29 @@ impl Clone for CResult_PaymentParametersDecodeErrorZ { /// 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 dynamically-allocated array of crate::lightning::routing::router::RouteHints of arbitrary size. +/// A dynamically-allocated array of crate::lightning_types::routing::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, + pub data: *mut crate::lightning_types::routing::RouteHint, /// The number of elements pointed to by `data`. pub datalen: usize } impl CVec_RouteHintZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + #[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::RouteHint] { + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning_types::routing::RouteHint] { unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl From> for CVec_RouteHintZ { - 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() } } @@ -5171,64 +5501,18 @@ impl Clone for CVec_RouteHintZ { } } #[repr(C)] -/// A dynamically-allocated array of crate::lightning::routing::router::RouteHintHops of arbitrary size. -/// This corresponds to std::vector in C++ -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::lightning::routing::router::RouteHintHop, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -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::lightning::routing::router::RouteHintHop] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -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() } } - } -} -#[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 { - 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 { - 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_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::router::RouteHint, + pub result: *mut crate::lightning_types::routing::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_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. +/// containing a crate::lightning_types::routing::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_RouteHintDecodeErrorZ { /// The contents of this CResult_RouteHintDecodeErrorZ, accessible via either @@ -5239,7 +5523,7 @@ pub struct CResult_RouteHintDecodeErrorZ { } #[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 { +pub extern "C" fn CResult_RouteHintDecodeErrorZ_ok(o: crate::lightning_types::routing::RouteHint) -> CResult_RouteHintDecodeErrorZ { CResult_RouteHintDecodeErrorZ { contents: CResult_RouteHintDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), @@ -5278,8 +5562,8 @@ impl Drop for CResult_RouteHintDecodeErrorZ { } } } -impl From> for CResult_RouteHintDecodeErrorZ { - 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() }; @@ -5299,7 +5583,7 @@ impl Clone for CResult_RouteHintDecodeErrorZ { fn clone(&self) -> Self { if self.result_ok { Self { result_ok: true, contents: CResult_RouteHintDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { Self { result_ok: false, contents: CResult_RouteHintDecodeErrorZPtr { @@ -5317,14 +5601,14 @@ pub extern "C" fn CResult_RouteHintDecodeErrorZ_clone(orig: &CResult_RouteHintDe 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, + pub result: *mut crate::lightning_types::routing::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, } #[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. +/// containing a crate::lightning_types::routing::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 @@ -5335,7 +5619,7 @@ pub struct CResult_RouteHintHopDecodeErrorZ { } #[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 { +pub extern "C" fn CResult_RouteHintHopDecodeErrorZ_ok(o: crate::lightning_types::routing::RouteHintHop) -> CResult_RouteHintHopDecodeErrorZ { CResult_RouteHintHopDecodeErrorZ { contents: CResult_RouteHintHopDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), @@ -5374,8 +5658,8 @@ impl Drop for CResult_RouteHintHopDecodeErrorZ { } } } -impl From> for CResult_RouteHintHopDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +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() }; @@ -5395,7 +5679,7 @@ impl Clone for CResult_RouteHintHopDecodeErrorZ { fn clone(&self) -> Self { if self.result_ok { Self { result_ok: true, contents: CResult_RouteHintHopDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { Self { result_ok: false, contents: CResult_RouteHintHopDecodeErrorZPtr { @@ -6352,14 +6636,14 @@ impl Clone for CVec_C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZZ { 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, + pub result: *mut crate::lightning_types::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. +/// containing a crate::lightning_types::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 @@ -6370,7 +6654,7 @@ pub struct CResult_InitFeaturesDecodeErrorZ { } #[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 { +pub extern "C" fn CResult_InitFeaturesDecodeErrorZ_ok(o: crate::lightning_types::features::InitFeatures) -> CResult_InitFeaturesDecodeErrorZ { CResult_InitFeaturesDecodeErrorZ { contents: CResult_InitFeaturesDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), @@ -6409,8 +6693,8 @@ impl Drop for CResult_InitFeaturesDecodeErrorZ { } } } -impl From> for CResult_InitFeaturesDecodeErrorZ { - 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() }; @@ -6430,7 +6714,7 @@ impl Clone for CResult_InitFeaturesDecodeErrorZ { 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 }))) + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { Self { result_ok: false, contents: CResult_InitFeaturesDecodeErrorZPtr { @@ -6448,14 +6732,14 @@ pub extern "C" fn CResult_InitFeaturesDecodeErrorZ_clone(orig: &CResult_InitFeat 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::ln::features::ChannelFeatures, + pub result: *mut crate::lightning_types::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_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. +/// containing a crate::lightning_types::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_ChannelFeaturesDecodeErrorZ { /// The contents of this CResult_ChannelFeaturesDecodeErrorZ, accessible via either @@ -6466,7 +6750,7 @@ pub struct CResult_ChannelFeaturesDecodeErrorZ { } #[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 { +pub extern "C" fn CResult_ChannelFeaturesDecodeErrorZ_ok(o: crate::lightning_types::features::ChannelFeatures) -> CResult_ChannelFeaturesDecodeErrorZ { CResult_ChannelFeaturesDecodeErrorZ { contents: CResult_ChannelFeaturesDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), @@ -6505,8 +6789,8 @@ impl Drop for CResult_ChannelFeaturesDecodeErrorZ { } } } -impl From> for CResult_ChannelFeaturesDecodeErrorZ { - 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() }; @@ -6526,7 +6810,7 @@ impl Clone for CResult_ChannelFeaturesDecodeErrorZ { 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 }))) + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { Self { result_ok: false, contents: CResult_ChannelFeaturesDecodeErrorZPtr { @@ -6544,14 +6828,14 @@ pub extern "C" fn CResult_ChannelFeaturesDecodeErrorZ_clone(orig: &CResult_Chann 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, + pub result: *mut crate::lightning_types::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. +/// containing a crate::lightning_types::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 @@ -6562,7 +6846,7 @@ pub struct CResult_NodeFeaturesDecodeErrorZ { } #[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 { +pub extern "C" fn CResult_NodeFeaturesDecodeErrorZ_ok(o: crate::lightning_types::features::NodeFeatures) -> CResult_NodeFeaturesDecodeErrorZ { CResult_NodeFeaturesDecodeErrorZ { contents: CResult_NodeFeaturesDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), @@ -6601,8 +6885,8 @@ impl Drop for CResult_NodeFeaturesDecodeErrorZ { } } } -impl From> for CResult_NodeFeaturesDecodeErrorZ { - 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() }; @@ -6622,7 +6906,7 @@ impl Clone for CResult_NodeFeaturesDecodeErrorZ { 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 }))) + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { Self { result_ok: false, contents: CResult_NodeFeaturesDecodeErrorZPtr { @@ -6640,14 +6924,14 @@ pub extern "C" fn CResult_NodeFeaturesDecodeErrorZ_clone(orig: &CResult_NodeFeat 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::lightning::ln::features::Bolt11InvoiceFeatures, + pub result: *mut crate::lightning_types::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_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. +/// containing a crate::lightning_types::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_Bolt11InvoiceFeaturesDecodeErrorZ { /// The contents of this CResult_Bolt11InvoiceFeaturesDecodeErrorZ, accessible via either @@ -6658,7 +6942,7 @@ pub struct CResult_Bolt11InvoiceFeaturesDecodeErrorZ { } #[no_mangle] /// Creates a new CResult_Bolt11InvoiceFeaturesDecodeErrorZ in the success state. -pub extern "C" fn CResult_Bolt11InvoiceFeaturesDecodeErrorZ_ok(o: crate::lightning::ln::features::Bolt11InvoiceFeatures) -> CResult_Bolt11InvoiceFeaturesDecodeErrorZ { +pub extern "C" fn CResult_Bolt11InvoiceFeaturesDecodeErrorZ_ok(o: crate::lightning_types::features::Bolt11InvoiceFeatures) -> CResult_Bolt11InvoiceFeaturesDecodeErrorZ { CResult_Bolt11InvoiceFeaturesDecodeErrorZ { contents: CResult_Bolt11InvoiceFeaturesDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), @@ -6697,8 +6981,8 @@ impl Drop for CResult_Bolt11InvoiceFeaturesDecodeErrorZ { } } } -impl From> for CResult_Bolt11InvoiceFeaturesDecodeErrorZ { - 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() }; @@ -6718,7 +7002,7 @@ impl Clone for CResult_Bolt11InvoiceFeaturesDecodeErrorZ { fn clone(&self) -> Self { if self.result_ok { Self { result_ok: true, contents: CResult_Bolt11InvoiceFeaturesDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { Self { result_ok: false, contents: CResult_Bolt11InvoiceFeaturesDecodeErrorZPtr { @@ -6736,14 +7020,14 @@ pub extern "C" fn CResult_Bolt11InvoiceFeaturesDecodeErrorZ_clone(orig: &CResult 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, + pub result: *mut crate::lightning_types::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, } #[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. +/// containing a crate::lightning_types::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 @@ -6754,7 +7038,7 @@ pub struct CResult_Bolt12InvoiceFeaturesDecodeErrorZ { } #[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 { +pub extern "C" fn CResult_Bolt12InvoiceFeaturesDecodeErrorZ_ok(o: crate::lightning_types::features::Bolt12InvoiceFeatures) -> CResult_Bolt12InvoiceFeaturesDecodeErrorZ { CResult_Bolt12InvoiceFeaturesDecodeErrorZ { contents: CResult_Bolt12InvoiceFeaturesDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), @@ -6793,8 +7077,8 @@ impl Drop for CResult_Bolt12InvoiceFeaturesDecodeErrorZ { } } } -impl From> for CResult_Bolt12InvoiceFeaturesDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +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() }; @@ -6814,7 +7098,7 @@ 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 }))) + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { Self { result_ok: false, contents: CResult_Bolt12InvoiceFeaturesDecodeErrorZPtr { @@ -6832,14 +7116,14 @@ pub extern "C" fn CResult_Bolt12InvoiceFeaturesDecodeErrorZ_clone(orig: &CResult 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, + pub result: *mut crate::lightning_types::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_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. +/// containing a crate::lightning_types::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 @@ -6850,7 +7134,7 @@ pub struct CResult_BlindedHopFeaturesDecodeErrorZ { } #[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 { +pub extern "C" fn CResult_BlindedHopFeaturesDecodeErrorZ_ok(o: crate::lightning_types::features::BlindedHopFeatures) -> CResult_BlindedHopFeaturesDecodeErrorZ { CResult_BlindedHopFeaturesDecodeErrorZ { contents: CResult_BlindedHopFeaturesDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), @@ -6889,8 +7173,8 @@ impl Drop for CResult_BlindedHopFeaturesDecodeErrorZ { } } } -impl From> for CResult_BlindedHopFeaturesDecodeErrorZ { - 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() }; @@ -6910,7 +7194,7 @@ impl Clone for CResult_BlindedHopFeaturesDecodeErrorZ { 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 }))) + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { Self { result_ok: false, contents: CResult_BlindedHopFeaturesDecodeErrorZPtr { @@ -6928,14 +7212,14 @@ pub extern "C" fn CResult_BlindedHopFeaturesDecodeErrorZ_clone(orig: &CResult_Bl 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::ln::features::ChannelTypeFeatures, + pub result: *mut crate::lightning_types::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_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. +/// containing a crate::lightning_types::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_ChannelTypeFeaturesDecodeErrorZ { /// The contents of this CResult_ChannelTypeFeaturesDecodeErrorZ, accessible via either @@ -6946,7 +7230,7 @@ pub struct CResult_ChannelTypeFeaturesDecodeErrorZ { } #[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 { +pub extern "C" fn CResult_ChannelTypeFeaturesDecodeErrorZ_ok(o: crate::lightning_types::features::ChannelTypeFeatures) -> CResult_ChannelTypeFeaturesDecodeErrorZ { CResult_ChannelTypeFeaturesDecodeErrorZ { contents: CResult_ChannelTypeFeaturesDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), @@ -6985,8 +7269,8 @@ impl Drop for CResult_ChannelTypeFeaturesDecodeErrorZ { } } } -impl From> for CResult_ChannelTypeFeaturesDecodeErrorZ { - 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() }; @@ -7006,7 +7290,7 @@ impl Clone for CResult_ChannelTypeFeaturesDecodeErrorZ { fn clone(&self) -> Self { if self.result_ok { Self { result_ok: true, contents: CResult_ChannelTypeFeaturesDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { Self { result_ok: false, contents: CResult_ChannelTypeFeaturesDecodeErrorZPtr { @@ -7462,28 +7746,124 @@ impl From CResult_OfferDecodeErrorZ { + CResult_OfferDecodeErrorZ { + contents: CResult_OfferDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_OfferDecodeErrorZ in the error state. +pub extern "C" fn CResult_OfferDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_OfferDecodeErrorZ { + CResult_OfferDecodeErrorZ { + contents: CResult_OfferDecodeErrorZPtr { + 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_OfferDecodeErrorZ_is_ok(o: &CResult_OfferDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_OfferDecodeErrorZ. +pub extern "C" fn CResult_OfferDecodeErrorZ_free(_res: CResult_OfferDecodeErrorZ) { } +impl Drop for CResult_OfferDecodeErrorZ { + 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_OfferDecodeErrorZ { + 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_OfferDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_OfferDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_OfferDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_OfferDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_OfferDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_OfferDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_OfferDecodeErrorZ_clone(orig: &CResult_OfferDecodeErrorZ) -> CResult_OfferDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// 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::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::offers::parse::Bolt12ParseError, +} +#[repr(C)] +/// 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_OfferBolt12ParseErrorZ { + /// The contents of this CResult_OfferBolt12ParseErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_OfferBolt12ParseErrorZPtr, + /// Whether this CResult_OfferBolt12ParseErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// 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 { @@ -8428,14 +8808,14 @@ pub extern "C" fn CResult_ChannelInfoDecodeErrorZ_clone(orig: &CResult_ChannelIn pub union CResult_RoutingFeesDecodeErrorZPtr { /// 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::gossip::RoutingFees, + pub result: *mut crate::lightning_types::routing::RoutingFees, /// 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_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. +/// containing a crate::lightning_types::routing::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`. pub struct CResult_RoutingFeesDecodeErrorZ { /// The contents of this CResult_RoutingFeesDecodeErrorZ, accessible via either @@ -8446,7 +8826,7 @@ pub struct CResult_RoutingFeesDecodeErrorZ { } #[no_mangle] /// Creates a new CResult_RoutingFeesDecodeErrorZ in the success state. -pub extern "C" fn CResult_RoutingFeesDecodeErrorZ_ok(o: crate::lightning::routing::gossip::RoutingFees) -> CResult_RoutingFeesDecodeErrorZ { +pub extern "C" fn CResult_RoutingFeesDecodeErrorZ_ok(o: crate::lightning_types::routing::RoutingFees) -> CResult_RoutingFeesDecodeErrorZ { CResult_RoutingFeesDecodeErrorZ { contents: CResult_RoutingFeesDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), @@ -8485,8 +8865,8 @@ impl Drop for CResult_RoutingFeesDecodeErrorZ { } } } -impl From> for CResult_RoutingFeesDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_RoutingFeesDecodeErrorZ { + 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() }; @@ -8506,7 +8886,7 @@ impl Clone for CResult_RoutingFeesDecodeErrorZ { fn clone(&self) -> Self { if self.result_ok { Self { result_ok: true, contents: CResult_RoutingFeesDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { Self { result_ok: false, contents: CResult_RoutingFeesDecodeErrorZPtr { @@ -8758,6 +9138,43 @@ impl Clone for CResult_NodeAliasDecodeErrorZ { /// but with all dynamically-allocated buffers duplicated in new buffers. pub extern "C" fn CResult_NodeAliasDecodeErrorZ_clone(orig: &CResult_NodeAliasDecodeErrorZ) -> CResult_NodeAliasDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] +#[derive(Clone)] +/// An enum which can either contain a crate::lightning::routing::gossip::NodeAnnouncementInfo or not +pub enum COption_NodeAnnouncementInfoZ { + /// When we're in this state, this COption_NodeAnnouncementInfoZ contains a crate::lightning::routing::gossip::NodeAnnouncementInfo + Some(crate::lightning::routing::gossip::NodeAnnouncementInfo), + /// When we're in this state, this COption_NodeAnnouncementInfoZ contains nothing + None +} +impl COption_NodeAnnouncementInfoZ { + #[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::NodeAnnouncementInfo { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_NodeAnnouncementInfoZ containing a crate::lightning::routing::gossip::NodeAnnouncementInfo +pub extern "C" fn COption_NodeAnnouncementInfoZ_some(o: crate::lightning::routing::gossip::NodeAnnouncementInfo) -> COption_NodeAnnouncementInfoZ { + COption_NodeAnnouncementInfoZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_NodeAnnouncementInfoZ containing nothing +pub extern "C" fn COption_NodeAnnouncementInfoZ_none() -> COption_NodeAnnouncementInfoZ { + COption_NodeAnnouncementInfoZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::lightning::routing::gossip::NodeAnnouncementInfo, if we are in the Some state +pub extern "C" fn COption_NodeAnnouncementInfoZ_free(_res: COption_NodeAnnouncementInfoZ) { } +#[no_mangle] +/// Creates a new COption_NodeAnnouncementInfoZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_NodeAnnouncementInfoZ_clone(orig: &COption_NodeAnnouncementInfoZ) -> COption_NodeAnnouncementInfoZ { Clone::clone(&orig) } +#[repr(C)] /// The contents of CResult_NodeInfoDecodeErrorZ pub union CResult_NodeInfoDecodeErrorZPtr { /// A pointer to the contents in the success state. @@ -10912,111 +11329,186 @@ impl Clone for CResult_ThirtyTwoBytesAPIErrorZ { pub extern "C" fn CResult_ThirtyTwoBytesAPIErrorZ_clone(orig: &CResult_ThirtyTwoBytesAPIErrorZ) -> CResult_ThirtyTwoBytesAPIErrorZ { Clone::clone(&orig) } #[repr(C)] #[derive(Clone)] -/// 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 +/// An enum which can either contain a crate::lightning::blinded_path::message::OffersContext or not +pub enum COption_OffersContextZ { + /// When we're in this state, this COption_OffersContextZ contains a crate::lightning::blinded_path::message::OffersContext + Some(crate::lightning::blinded_path::message::OffersContext), + /// When we're in this state, this COption_OffersContextZ contains nothing None } -impl COption_OffersMessageZ { +impl COption_OffersContextZ { #[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::offers::OffersMessage { + #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::blinded_path::message::OffersContext { if let Self::Some(v) = self { v } else { unreachable!() } } } #[no_mangle] -/// 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) +/// Constructs a new COption_OffersContextZ containing a crate::lightning::blinded_path::message::OffersContext +pub extern "C" fn COption_OffersContextZ_some(o: crate::lightning::blinded_path::message::OffersContext) -> COption_OffersContextZ { + COption_OffersContextZ::Some(o) } #[no_mangle] -/// Constructs a new COption_OffersMessageZ containing nothing -pub extern "C" fn COption_OffersMessageZ_none() -> COption_OffersMessageZ { - COption_OffersMessageZ::None +/// Constructs a new COption_OffersContextZ containing nothing +pub extern "C" fn COption_OffersContextZ_none() -> COption_OffersContextZ { + COption_OffersContextZ::None } #[no_mangle] -/// 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) { } +/// Frees any resources associated with the crate::lightning::blinded_path::message::OffersContext, if we are in the Some state +pub extern "C" fn COption_OffersContextZ_free(_res: COption_OffersContextZ) { } #[no_mangle] -/// Creates a new COption_OffersMessageZ which has the same data as `orig` +/// Creates a new COption_OffersContextZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_OffersMessageZ_clone(orig: &COption_OffersMessageZ) -> COption_OffersMessageZ { Clone::clone(&orig) } +pub extern "C" fn COption_OffersContextZ_clone(orig: &COption_OffersContextZ) -> COption_OffersContextZ { Clone::clone(&orig) } #[repr(C)] -/// A tuple of 3 elements. See the individual fields for the types contained. -pub struct C3Tuple_OffersMessageDestinationBlindedPathZ { +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_OffersMessageResponseInstructionZ { /// The element at position 0 pub a: crate::lightning::onion_message::offers::OffersMessage, /// The element at position 1 - pub b: crate::lightning::onion_message::messenger::Destination, - /// The element at position 2 - pub c: crate::lightning::blinded_path::BlindedPath, + pub b: crate::lightning::onion_message::messenger::ResponseInstruction, } -impl From<(crate::lightning::onion_message::offers::OffersMessage, crate::lightning::onion_message::messenger::Destination, crate::lightning::blinded_path::BlindedPath)> for C3Tuple_OffersMessageDestinationBlindedPathZ { - fn from (tup: (crate::lightning::onion_message::offers::OffersMessage, crate::lightning::onion_message::messenger::Destination, crate::lightning::blinded_path::BlindedPath)) -> Self { +impl From<(crate::lightning::onion_message::offers::OffersMessage, crate::lightning::onion_message::messenger::ResponseInstruction)> for C2Tuple_OffersMessageResponseInstructionZ { + fn from (tup: (crate::lightning::onion_message::offers::OffersMessage, crate::lightning::onion_message::messenger::ResponseInstruction)) -> Self { Self { a: tup.0, b: tup.1, - c: tup.2, } } } -impl C3Tuple_OffersMessageDestinationBlindedPathZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::lightning::onion_message::offers::OffersMessage, crate::lightning::onion_message::messenger::Destination, crate::lightning::blinded_path::BlindedPath) { - (self.a, self.b, self.c) +impl C2Tuple_OffersMessageResponseInstructionZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::lightning::onion_message::offers::OffersMessage, crate::lightning::onion_message::messenger::ResponseInstruction) { + (self.a, self.b) } } -impl Clone for C3Tuple_OffersMessageDestinationBlindedPathZ { +impl Clone for C2Tuple_OffersMessageResponseInstructionZ { + 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_OffersMessageResponseInstructionZ_clone(orig: &C2Tuple_OffersMessageResponseInstructionZ) -> C2Tuple_OffersMessageResponseInstructionZ { Clone::clone(&orig) } +/// Creates a new C2Tuple_OffersMessageResponseInstructionZ from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_OffersMessageResponseInstructionZ_new(a: crate::lightning::onion_message::offers::OffersMessage, b: crate::lightning::onion_message::messenger::ResponseInstruction) -> C2Tuple_OffersMessageResponseInstructionZ { + C2Tuple_OffersMessageResponseInstructionZ { a, b, } +} + +#[no_mangle] +/// Frees any resources used by the C2Tuple_OffersMessageResponseInstructionZ. +pub extern "C" fn C2Tuple_OffersMessageResponseInstructionZ_free(_res: C2Tuple_OffersMessageResponseInstructionZ) { } +#[repr(C)] +#[derive(Clone)] +/// An enum which can either contain a crate::c_types::derived::C2Tuple_OffersMessageResponseInstructionZ or not +pub enum COption_C2Tuple_OffersMessageResponseInstructionZZ { + /// When we're in this state, this COption_C2Tuple_OffersMessageResponseInstructionZZ contains a crate::c_types::derived::C2Tuple_OffersMessageResponseInstructionZ + Some(crate::c_types::derived::C2Tuple_OffersMessageResponseInstructionZ), + /// When we're in this state, this COption_C2Tuple_OffersMessageResponseInstructionZZ contains nothing + None +} +impl COption_C2Tuple_OffersMessageResponseInstructionZZ { + #[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_OffersMessageResponseInstructionZ { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_C2Tuple_OffersMessageResponseInstructionZZ containing a crate::c_types::derived::C2Tuple_OffersMessageResponseInstructionZ +pub extern "C" fn COption_C2Tuple_OffersMessageResponseInstructionZZ_some(o: crate::c_types::derived::C2Tuple_OffersMessageResponseInstructionZ) -> COption_C2Tuple_OffersMessageResponseInstructionZZ { + COption_C2Tuple_OffersMessageResponseInstructionZZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_C2Tuple_OffersMessageResponseInstructionZZ containing nothing +pub extern "C" fn COption_C2Tuple_OffersMessageResponseInstructionZZ_none() -> COption_C2Tuple_OffersMessageResponseInstructionZZ { + COption_C2Tuple_OffersMessageResponseInstructionZZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::c_types::derived::C2Tuple_OffersMessageResponseInstructionZ, if we are in the Some state +pub extern "C" fn COption_C2Tuple_OffersMessageResponseInstructionZZ_free(_res: COption_C2Tuple_OffersMessageResponseInstructionZZ) { } +#[no_mangle] +/// Creates a new COption_C2Tuple_OffersMessageResponseInstructionZZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_C2Tuple_OffersMessageResponseInstructionZZ_clone(orig: &COption_C2Tuple_OffersMessageResponseInstructionZZ) -> COption_C2Tuple_OffersMessageResponseInstructionZZ { Clone::clone(&orig) } +#[repr(C)] +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_OffersMessageMessageSendInstructionsZ { + /// The element at position 0 + pub a: crate::lightning::onion_message::offers::OffersMessage, + /// The element at position 1 + pub b: crate::lightning::onion_message::messenger::MessageSendInstructions, +} +impl From<(crate::lightning::onion_message::offers::OffersMessage, crate::lightning::onion_message::messenger::MessageSendInstructions)> for C2Tuple_OffersMessageMessageSendInstructionsZ { + fn from (tup: (crate::lightning::onion_message::offers::OffersMessage, crate::lightning::onion_message::messenger::MessageSendInstructions)) -> Self { + Self { + a: tup.0, + b: tup.1, + } + } +} +impl C2Tuple_OffersMessageMessageSendInstructionsZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::lightning::onion_message::offers::OffersMessage, crate::lightning::onion_message::messenger::MessageSendInstructions) { + (self.a, self.b) + } +} +impl Clone for C2Tuple_OffersMessageMessageSendInstructionsZ { 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_OffersMessageDestinationBlindedPathZ_clone(orig: &C3Tuple_OffersMessageDestinationBlindedPathZ) -> C3Tuple_OffersMessageDestinationBlindedPathZ { Clone::clone(&orig) } -/// Creates a new C3Tuple_OffersMessageDestinationBlindedPathZ from the contained elements. +pub extern "C" fn C2Tuple_OffersMessageMessageSendInstructionsZ_clone(orig: &C2Tuple_OffersMessageMessageSendInstructionsZ) -> C2Tuple_OffersMessageMessageSendInstructionsZ { Clone::clone(&orig) } +/// Creates a new C2Tuple_OffersMessageMessageSendInstructionsZ from the contained elements. #[no_mangle] -pub extern "C" fn C3Tuple_OffersMessageDestinationBlindedPathZ_new(a: crate::lightning::onion_message::offers::OffersMessage, b: crate::lightning::onion_message::messenger::Destination, c: crate::lightning::blinded_path::BlindedPath) -> C3Tuple_OffersMessageDestinationBlindedPathZ { - C3Tuple_OffersMessageDestinationBlindedPathZ { a, b, c, } +pub extern "C" fn C2Tuple_OffersMessageMessageSendInstructionsZ_new(a: crate::lightning::onion_message::offers::OffersMessage, b: crate::lightning::onion_message::messenger::MessageSendInstructions) -> C2Tuple_OffersMessageMessageSendInstructionsZ { + C2Tuple_OffersMessageMessageSendInstructionsZ { a, b, } } #[no_mangle] -/// Frees any resources used by the C3Tuple_OffersMessageDestinationBlindedPathZ. -pub extern "C" fn C3Tuple_OffersMessageDestinationBlindedPathZ_free(_res: C3Tuple_OffersMessageDestinationBlindedPathZ) { } +/// Frees any resources used by the C2Tuple_OffersMessageMessageSendInstructionsZ. +pub extern "C" fn C2Tuple_OffersMessageMessageSendInstructionsZ_free(_res: C2Tuple_OffersMessageMessageSendInstructionsZ) { } #[repr(C)] -/// A dynamically-allocated array of crate::c_types::derived::C3Tuple_OffersMessageDestinationBlindedPathZs of arbitrary size. +/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_OffersMessageMessageSendInstructionsZs of arbitrary size. /// This corresponds to std::vector in C++ -pub struct CVec_C3Tuple_OffersMessageDestinationBlindedPathZZ { +pub struct CVec_C2Tuple_OffersMessageMessageSendInstructionsZZ { /// 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_OffersMessageDestinationBlindedPathZ, + pub data: *mut crate::c_types::derived::C2Tuple_OffersMessageMessageSendInstructionsZ, /// The number of elements pointed to by `data`. pub datalen: usize } -impl CVec_C3Tuple_OffersMessageDestinationBlindedPathZZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { +impl CVec_C2Tuple_OffersMessageMessageSendInstructionsZZ { + #[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_OffersMessageDestinationBlindedPathZ] { + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_OffersMessageMessageSendInstructionsZ] { unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl From> for CVec_C3Tuple_OffersMessageDestinationBlindedPathZZ { - fn from(v: Vec) -> Self { +impl From> for CVec_C2Tuple_OffersMessageMessageSendInstructionsZZ { + 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() } } @@ -11024,14 +11516,14 @@ impl From Self { let mut res = Vec::new(); if self.datalen == 0 { return Self::from(res); } @@ -11040,110 +11532,277 @@ impl Clone for CVec_C3Tuple_OffersMessageDestinationBlindedPathZZ { } } #[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, -} -#[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, -} -#[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, - } -} -#[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, - } -} -/// 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 +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_ReleaseHeldHtlcResponseInstructionZ { + /// The element at position 0 + pub a: crate::lightning::onion_message::async_payments::ReleaseHeldHtlc, + /// The element at position 1 + pub b: crate::lightning::onion_message::messenger::ResponseInstruction, } -#[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 From<(crate::lightning::onion_message::async_payments::ReleaseHeldHtlc, crate::lightning::onion_message::messenger::ResponseInstruction)> for C2Tuple_ReleaseHeldHtlcResponseInstructionZ { + fn from (tup: (crate::lightning::onion_message::async_payments::ReleaseHeldHtlc, crate::lightning::onion_message::messenger::ResponseInstruction)) -> Self { + Self { + a: tup.0, + b: tup.1, } } } -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 } - }; - Self { - contents, - result_ok: o.result_ok, - } +impl C2Tuple_ReleaseHeldHtlcResponseInstructionZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::lightning::onion_message::async_payments::ReleaseHeldHtlc, crate::lightning::onion_message::messenger::ResponseInstruction) { + (self.a, self.b) } } -impl Clone for CResult_PhantomRouteHintsDecodeErrorZ { +impl Clone for C2Tuple_ReleaseHeldHtlcResponseInstructionZ { 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) } -#[repr(C)] -/// The contents of CResult_BlindedForwardDecodeErrorZ -pub union CResult_BlindedForwardDecodeErrorZPtr { - /// 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::BlindedForward, - /// 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_ReleaseHeldHtlcResponseInstructionZ_clone(orig: &C2Tuple_ReleaseHeldHtlcResponseInstructionZ) -> C2Tuple_ReleaseHeldHtlcResponseInstructionZ { Clone::clone(&orig) } +/// Creates a new C2Tuple_ReleaseHeldHtlcResponseInstructionZ from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_ReleaseHeldHtlcResponseInstructionZ_new(a: crate::lightning::onion_message::async_payments::ReleaseHeldHtlc, b: crate::lightning::onion_message::messenger::ResponseInstruction) -> C2Tuple_ReleaseHeldHtlcResponseInstructionZ { + C2Tuple_ReleaseHeldHtlcResponseInstructionZ { a, b, } +} + +#[no_mangle] +/// Frees any resources used by the C2Tuple_ReleaseHeldHtlcResponseInstructionZ. +pub extern "C" fn C2Tuple_ReleaseHeldHtlcResponseInstructionZ_free(_res: C2Tuple_ReleaseHeldHtlcResponseInstructionZ) { } +#[repr(C)] +#[derive(Clone)] +/// An enum which can either contain a crate::c_types::derived::C2Tuple_ReleaseHeldHtlcResponseInstructionZ or not +pub enum COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ { + /// When we're in this state, this COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ contains a crate::c_types::derived::C2Tuple_ReleaseHeldHtlcResponseInstructionZ + Some(crate::c_types::derived::C2Tuple_ReleaseHeldHtlcResponseInstructionZ), + /// When we're in this state, this COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ contains nothing + None +} +impl COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ { + #[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_ReleaseHeldHtlcResponseInstructionZ { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ containing a crate::c_types::derived::C2Tuple_ReleaseHeldHtlcResponseInstructionZ +pub extern "C" fn COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ_some(o: crate::c_types::derived::C2Tuple_ReleaseHeldHtlcResponseInstructionZ) -> COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ { + COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ containing nothing +pub extern "C" fn COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ_none() -> COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ { + COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::c_types::derived::C2Tuple_ReleaseHeldHtlcResponseInstructionZ, if we are in the Some state +pub extern "C" fn COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ_free(_res: COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ) { } +#[no_mangle] +/// Creates a new COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ_clone(orig: &COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ) -> COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ { Clone::clone(&orig) } +#[repr(C)] +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ { + /// The element at position 0 + pub a: crate::lightning::onion_message::async_payments::AsyncPaymentsMessage, + /// The element at position 1 + pub b: crate::lightning::onion_message::messenger::MessageSendInstructions, +} +impl From<(crate::lightning::onion_message::async_payments::AsyncPaymentsMessage, crate::lightning::onion_message::messenger::MessageSendInstructions)> for C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ { + fn from (tup: (crate::lightning::onion_message::async_payments::AsyncPaymentsMessage, crate::lightning::onion_message::messenger::MessageSendInstructions)) -> Self { + Self { + a: tup.0, + b: tup.1, + } + } +} +impl C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::lightning::onion_message::async_payments::AsyncPaymentsMessage, crate::lightning::onion_message::messenger::MessageSendInstructions) { + (self.a, self.b) + } +} +impl Clone for C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ { + 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_AsyncPaymentsMessageMessageSendInstructionsZ_clone(orig: &C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ) -> C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ { Clone::clone(&orig) } +/// Creates a new C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ_new(a: crate::lightning::onion_message::async_payments::AsyncPaymentsMessage, b: crate::lightning::onion_message::messenger::MessageSendInstructions) -> C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ { + C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ { a, b, } +} + +#[no_mangle] +/// Frees any resources used by the C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ. +pub extern "C" fn C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ_free(_res: C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ) { } +#[repr(C)] +/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZs of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ { + /// 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_AsyncPaymentsMessageMessageSendInstructionsZ, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ { + #[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_AsyncPaymentsMessageMessageSendInstructionsZ] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ { + 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_AsyncPaymentsMessageMessageSendInstructionsZZ_free(_res: CVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ) { } +impl Drop for CVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ { + 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_AsyncPaymentsMessageMessageSendInstructionsZZ { + 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_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, +} +#[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, +} +#[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, + } +} +#[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, + } +} +/// 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 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 } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_PhantomRouteHintsDecodeErrorZ { + 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 }))) + } } + } + } +} +#[no_mangle] +/// 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_PhantomRouteHintsDecodeErrorZ_clone(orig: &CResult_PhantomRouteHintsDecodeErrorZ) -> CResult_PhantomRouteHintsDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_BlindedForwardDecodeErrorZ +pub union CResult_BlindedForwardDecodeErrorZPtr { + /// 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::BlindedForward, + /// 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_BlindedForwardDecodeErrorZ represents the result of a fallible operation, @@ -12580,6 +13239,98 @@ impl Clone for CVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZZ { } } #[repr(C)] +/// The contents of CResult_NoneReplayEventZ +pub union CResult_NoneReplayEventZPtr { + /// 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::events::ReplayEvent, +} +#[repr(C)] +/// A CResult_NoneReplayEventZ represents the result of a fallible operation, +/// containing a () on success and a crate::lightning::events::ReplayEvent on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_NoneReplayEventZ { + /// The contents of this CResult_NoneReplayEventZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_NoneReplayEventZPtr, + /// Whether this CResult_NoneReplayEventZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_NoneReplayEventZ in the success state. +pub extern "C" fn CResult_NoneReplayEventZ_ok() -> CResult_NoneReplayEventZ { + CResult_NoneReplayEventZ { + contents: CResult_NoneReplayEventZPtr { + result: core::ptr::null_mut(), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_NoneReplayEventZ in the error state. +pub extern "C" fn CResult_NoneReplayEventZ_err(e: crate::lightning::events::ReplayEvent) -> CResult_NoneReplayEventZ { + CResult_NoneReplayEventZ { + contents: CResult_NoneReplayEventZPtr { + 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_NoneReplayEventZ_is_ok(o: &CResult_NoneReplayEventZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_NoneReplayEventZ. +pub extern "C" fn CResult_NoneReplayEventZ_free(_res: CResult_NoneReplayEventZ) { } +impl Drop for CResult_NoneReplayEventZ { + 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_NoneReplayEventZ { + fn from(mut o: crate::c_types::CResultTempl<(), crate::lightning::events::ReplayEvent>) -> Self { + let contents = if o.result_ok { + let _ = unsafe { Box::from_raw(o.contents.result) }; + o.contents.result = core::ptr::null_mut(); + CResult_NoneReplayEventZPtr { result: core::ptr::null_mut() } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_NoneReplayEventZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_NoneReplayEventZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_NoneReplayEventZPtr { + result: core::ptr::null_mut() + } } + } else { + Self { result_ok: false, contents: CResult_NoneReplayEventZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_NoneReplayEventZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_NoneReplayEventZ_clone(orig: &CResult_NoneReplayEventZ) -> CResult_NoneReplayEventZ { Clone::clone(&orig) } +#[repr(C)] /// A dynamically-allocated array of crate::lightning::ln::chan_utils::CommitmentTransactions of arbitrary size. /// This corresponds to std::vector in C++ pub struct CVec_CommitmentTransactionZ { @@ -13075,26 +13826,26 @@ impl Clone for CVec_C2Tuple_PublicKeyTypeZZ { } #[repr(C)] /// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple_PublicKeyCVec_SocketAddressZZ { +pub struct C2Tuple_OnionMessageContentsResponseInstructionZ { /// The element at position 0 - pub a: crate::c_types::PublicKey, + pub a: crate::lightning::onion_message::packet::OnionMessageContents, /// The element at position 1 - pub b: crate::c_types::derived::CVec_SocketAddressZ, + pub b: crate::lightning::onion_message::messenger::ResponseInstruction, } -impl From<(crate::c_types::PublicKey, crate::c_types::derived::CVec_SocketAddressZ)> for C2Tuple_PublicKeyCVec_SocketAddressZZ { - fn from (tup: (crate::c_types::PublicKey, crate::c_types::derived::CVec_SocketAddressZ)) -> Self { +impl From<(crate::lightning::onion_message::packet::OnionMessageContents, crate::lightning::onion_message::messenger::ResponseInstruction)> for C2Tuple_OnionMessageContentsResponseInstructionZ { + fn from (tup: (crate::lightning::onion_message::packet::OnionMessageContents, crate::lightning::onion_message::messenger::ResponseInstruction)) -> Self { Self { a: tup.0, b: tup.1, } } } -impl C2Tuple_PublicKeyCVec_SocketAddressZZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::PublicKey, crate::c_types::derived::CVec_SocketAddressZ) { +impl C2Tuple_OnionMessageContentsResponseInstructionZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::lightning::onion_message::packet::OnionMessageContents, crate::lightning::onion_message::messenger::ResponseInstruction) { (self.a, self.b) } } -impl Clone for C2Tuple_PublicKeyCVec_SocketAddressZZ { +impl Clone for C2Tuple_OnionMessageContentsResponseInstructionZ { fn clone(&self) -> Self { Self { a: Clone::clone(&self.a), @@ -13105,62 +13856,53 @@ impl Clone for C2Tuple_PublicKeyCVec_SocketAddressZZ { #[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_PublicKeyCVec_SocketAddressZZ_clone(orig: &C2Tuple_PublicKeyCVec_SocketAddressZZ) -> C2Tuple_PublicKeyCVec_SocketAddressZZ { Clone::clone(&orig) } -/// Creates a new C2Tuple_PublicKeyCVec_SocketAddressZZ from the contained elements. +pub extern "C" fn C2Tuple_OnionMessageContentsResponseInstructionZ_clone(orig: &C2Tuple_OnionMessageContentsResponseInstructionZ) -> C2Tuple_OnionMessageContentsResponseInstructionZ { Clone::clone(&orig) } +/// Creates a new C2Tuple_OnionMessageContentsResponseInstructionZ from the contained elements. #[no_mangle] -pub extern "C" fn C2Tuple_PublicKeyCVec_SocketAddressZZ_new(a: crate::c_types::PublicKey, b: crate::c_types::derived::CVec_SocketAddressZ) -> C2Tuple_PublicKeyCVec_SocketAddressZZ { - C2Tuple_PublicKeyCVec_SocketAddressZZ { a, b, } +pub extern "C" fn C2Tuple_OnionMessageContentsResponseInstructionZ_new(a: crate::lightning::onion_message::packet::OnionMessageContents, b: crate::lightning::onion_message::messenger::ResponseInstruction) -> C2Tuple_OnionMessageContentsResponseInstructionZ { + C2Tuple_OnionMessageContentsResponseInstructionZ { a, b, } } #[no_mangle] -/// Frees any resources used by the C2Tuple_PublicKeyCVec_SocketAddressZZ. -pub extern "C" fn C2Tuple_PublicKeyCVec_SocketAddressZZ_free(_res: C2Tuple_PublicKeyCVec_SocketAddressZZ) { } +/// Frees any resources used by the C2Tuple_OnionMessageContentsResponseInstructionZ. +pub extern "C" fn C2Tuple_OnionMessageContentsResponseInstructionZ_free(_res: C2Tuple_OnionMessageContentsResponseInstructionZ) { } #[repr(C)] -/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_PublicKeyCVec_SocketAddressZZs of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ { - /// 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_PublicKeyCVec_SocketAddressZZ, - /// The number of elements pointed to by `data`. - pub datalen: usize +#[derive(Clone)] +/// An enum which can either contain a crate::c_types::derived::C2Tuple_OnionMessageContentsResponseInstructionZ or not +pub enum COption_C2Tuple_OnionMessageContentsResponseInstructionZZ { + /// When we're in this state, this COption_C2Tuple_OnionMessageContentsResponseInstructionZZ contains a crate::c_types::derived::C2Tuple_OnionMessageContentsResponseInstructionZ + Some(crate::c_types::derived::C2Tuple_OnionMessageContentsResponseInstructionZ), + /// When we're in this state, this COption_C2Tuple_OnionMessageContentsResponseInstructionZZ contains nothing + None } -impl CVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ { - #[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_C2Tuple_OnionMessageContentsResponseInstructionZZ { + #[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_PublicKeyCVec_SocketAddressZZ] { - 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_PublicKeyCVec_SocketAddressZZZ { - 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::derived::C2Tuple_OnionMessageContentsResponseInstructionZ { + 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_PublicKeyCVec_SocketAddressZZZ_free(_res: CVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ) { } -impl Drop for CVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ { - 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_C2Tuple_OnionMessageContentsResponseInstructionZZ containing a crate::c_types::derived::C2Tuple_OnionMessageContentsResponseInstructionZ +pub extern "C" fn COption_C2Tuple_OnionMessageContentsResponseInstructionZZ_some(o: crate::c_types::derived::C2Tuple_OnionMessageContentsResponseInstructionZ) -> COption_C2Tuple_OnionMessageContentsResponseInstructionZZ { + COption_C2Tuple_OnionMessageContentsResponseInstructionZZ::Some(o) } -impl Clone for CVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ { - 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_C2Tuple_OnionMessageContentsResponseInstructionZZ containing nothing +pub extern "C" fn COption_C2Tuple_OnionMessageContentsResponseInstructionZZ_none() -> COption_C2Tuple_OnionMessageContentsResponseInstructionZZ { + COption_C2Tuple_OnionMessageContentsResponseInstructionZZ::None } +#[no_mangle] +/// Frees any resources associated with the crate::c_types::derived::C2Tuple_OnionMessageContentsResponseInstructionZ, if we are in the Some state +pub extern "C" fn COption_C2Tuple_OnionMessageContentsResponseInstructionZZ_free(_res: COption_C2Tuple_OnionMessageContentsResponseInstructionZZ) { } +#[no_mangle] +/// Creates a new COption_C2Tuple_OnionMessageContentsResponseInstructionZZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_C2Tuple_OnionMessageContentsResponseInstructionZZ_clone(orig: &COption_C2Tuple_OnionMessageContentsResponseInstructionZZ) -> COption_C2Tuple_OnionMessageContentsResponseInstructionZZ { Clone::clone(&orig) } #[repr(C)] #[derive(Clone)] /// An enum which can either contain a crate::lightning::onion_message::packet::OnionMessageContents or not @@ -13295,75 +14037,71 @@ impl Clone for CResult_COption_OnionMessageContentsZDecodeErrorZ { /// but with all dynamically-allocated buffers duplicated in new buffers. pub extern "C" fn CResult_COption_OnionMessageContentsZDecodeErrorZ_clone(orig: &CResult_COption_OnionMessageContentsZDecodeErrorZ) -> CResult_COption_OnionMessageContentsZDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// A tuple of 3 elements. See the individual fields for the types contained. -pub struct C3Tuple_OnionMessageContentsDestinationBlindedPathZ { +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_OnionMessageContentsMessageSendInstructionsZ { /// The element at position 0 pub a: crate::lightning::onion_message::packet::OnionMessageContents, /// The element at position 1 - pub b: crate::lightning::onion_message::messenger::Destination, - /// The element at position 2 - pub c: crate::lightning::blinded_path::BlindedPath, + pub b: crate::lightning::onion_message::messenger::MessageSendInstructions, } -impl From<(crate::lightning::onion_message::packet::OnionMessageContents, crate::lightning::onion_message::messenger::Destination, crate::lightning::blinded_path::BlindedPath)> for C3Tuple_OnionMessageContentsDestinationBlindedPathZ { - fn from (tup: (crate::lightning::onion_message::packet::OnionMessageContents, crate::lightning::onion_message::messenger::Destination, crate::lightning::blinded_path::BlindedPath)) -> Self { +impl From<(crate::lightning::onion_message::packet::OnionMessageContents, crate::lightning::onion_message::messenger::MessageSendInstructions)> for C2Tuple_OnionMessageContentsMessageSendInstructionsZ { + fn from (tup: (crate::lightning::onion_message::packet::OnionMessageContents, crate::lightning::onion_message::messenger::MessageSendInstructions)) -> Self { Self { a: tup.0, b: tup.1, - c: tup.2, } } } -impl C3Tuple_OnionMessageContentsDestinationBlindedPathZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::lightning::onion_message::packet::OnionMessageContents, crate::lightning::onion_message::messenger::Destination, crate::lightning::blinded_path::BlindedPath) { - (self.a, self.b, self.c) +impl C2Tuple_OnionMessageContentsMessageSendInstructionsZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::lightning::onion_message::packet::OnionMessageContents, crate::lightning::onion_message::messenger::MessageSendInstructions) { + (self.a, self.b) } } -impl Clone for C3Tuple_OnionMessageContentsDestinationBlindedPathZ { +impl Clone for C2Tuple_OnionMessageContentsMessageSendInstructionsZ { 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_OnionMessageContentsDestinationBlindedPathZ_clone(orig: &C3Tuple_OnionMessageContentsDestinationBlindedPathZ) -> C3Tuple_OnionMessageContentsDestinationBlindedPathZ { Clone::clone(&orig) } -/// Creates a new C3Tuple_OnionMessageContentsDestinationBlindedPathZ from the contained elements. +pub extern "C" fn C2Tuple_OnionMessageContentsMessageSendInstructionsZ_clone(orig: &C2Tuple_OnionMessageContentsMessageSendInstructionsZ) -> C2Tuple_OnionMessageContentsMessageSendInstructionsZ { Clone::clone(&orig) } +/// Creates a new C2Tuple_OnionMessageContentsMessageSendInstructionsZ from the contained elements. #[no_mangle] -pub extern "C" fn C3Tuple_OnionMessageContentsDestinationBlindedPathZ_new(a: crate::lightning::onion_message::packet::OnionMessageContents, b: crate::lightning::onion_message::messenger::Destination, c: crate::lightning::blinded_path::BlindedPath) -> C3Tuple_OnionMessageContentsDestinationBlindedPathZ { - C3Tuple_OnionMessageContentsDestinationBlindedPathZ { a, b, c, } +pub extern "C" fn C2Tuple_OnionMessageContentsMessageSendInstructionsZ_new(a: crate::lightning::onion_message::packet::OnionMessageContents, b: crate::lightning::onion_message::messenger::MessageSendInstructions) -> C2Tuple_OnionMessageContentsMessageSendInstructionsZ { + C2Tuple_OnionMessageContentsMessageSendInstructionsZ { a, b, } } #[no_mangle] -/// Frees any resources used by the C3Tuple_OnionMessageContentsDestinationBlindedPathZ. -pub extern "C" fn C3Tuple_OnionMessageContentsDestinationBlindedPathZ_free(_res: C3Tuple_OnionMessageContentsDestinationBlindedPathZ) { } +/// Frees any resources used by the C2Tuple_OnionMessageContentsMessageSendInstructionsZ. +pub extern "C" fn C2Tuple_OnionMessageContentsMessageSendInstructionsZ_free(_res: C2Tuple_OnionMessageContentsMessageSendInstructionsZ) { } #[repr(C)] -/// A dynamically-allocated array of crate::c_types::derived::C3Tuple_OnionMessageContentsDestinationBlindedPathZs of arbitrary size. +/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_OnionMessageContentsMessageSendInstructionsZs of arbitrary size. /// This corresponds to std::vector in C++ -pub struct CVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ { +pub struct CVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ { /// 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_OnionMessageContentsDestinationBlindedPathZ, + pub data: *mut crate::c_types::derived::C2Tuple_OnionMessageContentsMessageSendInstructionsZ, /// The number of elements pointed to by `data`. pub datalen: usize } -impl CVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { +impl CVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ { + #[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_OnionMessageContentsDestinationBlindedPathZ] { + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_OnionMessageContentsMessageSendInstructionsZ] { unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl From> for CVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ { - fn from(v: Vec) -> Self { +impl From> for CVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ { + 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() } } @@ -13371,14 +14109,14 @@ impl From Self { let mut res = Vec::new(); if self.datalen == 0 { return Self::from(res); } @@ -14054,52 +14792,6 @@ impl Clone for CResult_CVec_u8ZIOErrorZ { /// but with all dynamically-allocated buffers duplicated in new buffers. pub extern "C" fn CResult_CVec_u8ZIOErrorZ_clone(orig: &CResult_CVec_u8ZIOErrorZ) -> CResult_CVec_u8ZIOErrorZ { 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_StrZ { - /// 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_StrZ { - #[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_StrZ { - 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_StrZ_free(_res: CVec_StrZ) { } -impl Drop for CVec_StrZ { - 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_StrZ { - 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_StrZIOErrorZ pub union CResult_CVec_StrZIOErrorZPtr { /// A pointer to the contents in the success state. @@ -14626,43 +15318,6 @@ impl Clone for CResult_InvoiceRequestBolt12SemanticErrorZ { /// but with all dynamically-allocated buffers duplicated in new buffers. pub extern "C" fn CResult_InvoiceRequestBolt12SemanticErrorZ_clone(orig: &CResult_InvoiceRequestBolt12SemanticErrorZ) -> CResult_InvoiceRequestBolt12SemanticErrorZ { Clone::clone(&orig) } #[repr(C)] -#[derive(Clone)] -/// An enum which can either contain a crate::c_types::SecretKey or not -pub enum COption_SecretKeyZ { - /// When we're in this state, this COption_SecretKeyZ contains a crate::c_types::SecretKey - Some(crate::c_types::SecretKey), - /// When we're in this state, this COption_SecretKeyZ contains nothing - None -} -impl COption_SecretKeyZ { - #[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::SecretKey { - if let Self::Some(v) = self { v } else { unreachable!() } - } -} -#[no_mangle] -/// Constructs a new COption_SecretKeyZ containing a crate::c_types::SecretKey -pub extern "C" fn COption_SecretKeyZ_some(o: crate::c_types::SecretKey) -> COption_SecretKeyZ { - COption_SecretKeyZ::Some(o) -} -#[no_mangle] -/// Constructs a new COption_SecretKeyZ containing nothing -pub extern "C" fn COption_SecretKeyZ_none() -> COption_SecretKeyZ { - COption_SecretKeyZ::None -} -#[no_mangle] -/// Frees any resources associated with the crate::c_types::SecretKey, if we are in the Some state -pub extern "C" fn COption_SecretKeyZ_free(_res: COption_SecretKeyZ) { } -#[no_mangle] -/// Creates a new COption_SecretKeyZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_SecretKeyZ_clone(orig: &COption_SecretKeyZ) -> COption_SecretKeyZ { Clone::clone(&orig) } -#[repr(C)] /// The contents of CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ pub union CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZPtr { /// A pointer to the contents in the success state. @@ -15822,41 +16477,41 @@ impl Clone for CResult_StfuDecodeErrorZ { /// but with all dynamically-allocated buffers duplicated in new buffers. pub extern "C" fn CResult_StfuDecodeErrorZ_clone(orig: &CResult_StfuDecodeErrorZ) -> CResult_StfuDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_SpliceDecodeErrorZ -pub union CResult_SpliceDecodeErrorZPtr { +/// The contents of CResult_SpliceInitDecodeErrorZ +pub union CResult_SpliceInitDecodeErrorZPtr { /// 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::Splice, + pub result: *mut crate::lightning::ln::msgs::SpliceInit, /// 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_SpliceDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::Splice on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_SpliceInitDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::SpliceInit 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_SpliceDecodeErrorZ { - /// The contents of this CResult_SpliceDecodeErrorZ, accessible via either +pub struct CResult_SpliceInitDecodeErrorZ { + /// The contents of this CResult_SpliceInitDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_SpliceDecodeErrorZPtr, - /// Whether this CResult_SpliceDecodeErrorZ represents a success state. + pub contents: CResult_SpliceInitDecodeErrorZPtr, + /// Whether this CResult_SpliceInitDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_SpliceDecodeErrorZ in the success state. -pub extern "C" fn CResult_SpliceDecodeErrorZ_ok(o: crate::lightning::ln::msgs::Splice) -> CResult_SpliceDecodeErrorZ { - CResult_SpliceDecodeErrorZ { - contents: CResult_SpliceDecodeErrorZPtr { +/// Creates a new CResult_SpliceInitDecodeErrorZ in the success state. +pub extern "C" fn CResult_SpliceInitDecodeErrorZ_ok(o: crate::lightning::ln::msgs::SpliceInit) -> CResult_SpliceInitDecodeErrorZ { + CResult_SpliceInitDecodeErrorZ { + contents: CResult_SpliceInitDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_SpliceDecodeErrorZ in the error state. -pub extern "C" fn CResult_SpliceDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_SpliceDecodeErrorZ { - CResult_SpliceDecodeErrorZ { - contents: CResult_SpliceDecodeErrorZPtr { +/// Creates a new CResult_SpliceInitDecodeErrorZ in the error state. +pub extern "C" fn CResult_SpliceInitDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_SpliceInitDecodeErrorZ { + CResult_SpliceInitDecodeErrorZ { + contents: CResult_SpliceInitDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -15864,13 +16519,13 @@ pub extern "C" fn CResult_SpliceDecodeErrorZ_err(e: crate::lightning::ln::msgs:: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_SpliceDecodeErrorZ_is_ok(o: &CResult_SpliceDecodeErrorZ) -> bool { +pub extern "C" fn CResult_SpliceInitDecodeErrorZ_is_ok(o: &CResult_SpliceInitDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_SpliceDecodeErrorZ. -pub extern "C" fn CResult_SpliceDecodeErrorZ_free(_res: CResult_SpliceDecodeErrorZ) { } -impl Drop for CResult_SpliceDecodeErrorZ { +/// Frees any resources used by the CResult_SpliceInitDecodeErrorZ. +pub extern "C" fn CResult_SpliceInitDecodeErrorZ_free(_res: CResult_SpliceInitDecodeErrorZ) { } +impl Drop for CResult_SpliceInitDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -15883,16 +16538,16 @@ impl Drop for CResult_SpliceDecodeErrorZ { } } } -impl From> for CResult_SpliceDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_SpliceInitDecodeErrorZ { + 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_SpliceDecodeErrorZPtr { result } + CResult_SpliceInitDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_SpliceDecodeErrorZPtr { err } + CResult_SpliceInitDecodeErrorZPtr { err } }; Self { contents, @@ -15900,23 +16555,23 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_SpliceDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_SpliceInitDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_SpliceDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_SpliceInitDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_SpliceDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_SpliceInitDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_SpliceDecodeErrorZ_clone(orig: &CResult_SpliceDecodeErrorZ) -> CResult_SpliceDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_SpliceInitDecodeErrorZ_clone(orig: &CResult_SpliceInitDecodeErrorZ) -> CResult_SpliceInitDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] /// The contents of CResult_SpliceAckDecodeErrorZ pub union CResult_SpliceAckDecodeErrorZPtr { @@ -17358,6 +18013,102 @@ impl Clone for CResult_ClosingSignedFeeRangeDecodeErrorZ { /// 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_CommitmentSignedBatchDecodeErrorZ +pub union CResult_CommitmentSignedBatchDecodeErrorZPtr { + /// 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::CommitmentSignedBatch, + /// 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_CommitmentSignedBatchDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::CommitmentSignedBatch 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_CommitmentSignedBatchDecodeErrorZ { + /// The contents of this CResult_CommitmentSignedBatchDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_CommitmentSignedBatchDecodeErrorZPtr, + /// Whether this CResult_CommitmentSignedBatchDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_CommitmentSignedBatchDecodeErrorZ in the success state. +pub extern "C" fn CResult_CommitmentSignedBatchDecodeErrorZ_ok(o: crate::lightning::ln::msgs::CommitmentSignedBatch) -> CResult_CommitmentSignedBatchDecodeErrorZ { + CResult_CommitmentSignedBatchDecodeErrorZ { + contents: CResult_CommitmentSignedBatchDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_CommitmentSignedBatchDecodeErrorZ in the error state. +pub extern "C" fn CResult_CommitmentSignedBatchDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_CommitmentSignedBatchDecodeErrorZ { + CResult_CommitmentSignedBatchDecodeErrorZ { + contents: CResult_CommitmentSignedBatchDecodeErrorZPtr { + 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_CommitmentSignedBatchDecodeErrorZ_is_ok(o: &CResult_CommitmentSignedBatchDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_CommitmentSignedBatchDecodeErrorZ. +pub extern "C" fn CResult_CommitmentSignedBatchDecodeErrorZ_free(_res: CResult_CommitmentSignedBatchDecodeErrorZ) { } +impl Drop for CResult_CommitmentSignedBatchDecodeErrorZ { + 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_CommitmentSignedBatchDecodeErrorZ { + 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_CommitmentSignedBatchDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_CommitmentSignedBatchDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_CommitmentSignedBatchDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_CommitmentSignedBatchDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_CommitmentSignedBatchDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_CommitmentSignedBatchDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_CommitmentSignedBatchDecodeErrorZ_clone(orig: &CResult_CommitmentSignedBatchDecodeErrorZ) -> CResult_CommitmentSignedBatchDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] /// The contents of CResult_CommitmentSignedDecodeErrorZ pub union CResult_CommitmentSignedDecodeErrorZPtr { /// A pointer to the contents in the success state. @@ -20430,200 +21181,58 @@ impl Clone for CResult_GossipTimestampFilterDecodeErrorZ { /// 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 +#[derive(Clone)] +/// An enum which can either contain a crate::lightning::ln::channel_state::InboundHTLCStateDetails or not +pub enum COption_InboundHTLCStateDetailsZ { + /// When we're in this state, this COption_InboundHTLCStateDetailsZ contains a crate::lightning::ln::channel_state::InboundHTLCStateDetails + Some(crate::lightning::ln::channel_state::InboundHTLCStateDetails), + /// When we're in this state, this COption_InboundHTLCStateDetailsZ contains nothing + None } -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 +impl COption_InboundHTLCStateDetailsZ { + #[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::ln::channelmanager::PhantomRouteHints] { - 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_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() } } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::ln::channel_state::InboundHTLCStateDetails { + 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_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)) }; - } +/// Constructs a new COption_InboundHTLCStateDetailsZ containing a crate::lightning::ln::channel_state::InboundHTLCStateDetails +pub extern "C" fn COption_InboundHTLCStateDetailsZ_some(o: crate::lightning::ln::channel_state::InboundHTLCStateDetails) -> COption_InboundHTLCStateDetailsZ { + COption_InboundHTLCStateDetailsZ::Some(o) } -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) - } +#[no_mangle] +/// Constructs a new COption_InboundHTLCStateDetailsZ containing nothing +pub extern "C" fn COption_InboundHTLCStateDetailsZ_none() -> COption_InboundHTLCStateDetailsZ { + COption_InboundHTLCStateDetailsZ::None } +#[no_mangle] +/// Frees any resources associated with the crate::lightning::ln::channel_state::InboundHTLCStateDetails, if we are in the Some state +pub extern "C" fn COption_InboundHTLCStateDetailsZ_free(_res: COption_InboundHTLCStateDetailsZ) { } +#[no_mangle] +/// Creates a new COption_InboundHTLCStateDetailsZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_InboundHTLCStateDetailsZ_clone(orig: &COption_InboundHTLCStateDetailsZ) -> COption_InboundHTLCStateDetailsZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_Bolt11InvoiceSignOrCreationErrorZ -pub union CResult_Bolt11InvoiceSignOrCreationErrorZPtr { +/// The contents of CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ +pub union CResult_COption_InboundHTLCStateDetailsZDecodeErrorZPtr { /// 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::Bolt11Invoice, + pub result: *mut crate::c_types::derived::COption_InboundHTLCStateDetailsZ, /// 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_Bolt11InvoiceSignOrCreationErrorZ represents the result of a fallible operation, -/// containing a crate::lightning_invoice::Bolt11Invoice on success and a crate::lightning_invoice::SignOrCreationError on failure. +/// A CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::COption_InboundHTLCStateDetailsZ 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_Bolt11InvoiceSignOrCreationErrorZ { - /// The contents of this CResult_Bolt11InvoiceSignOrCreationErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_Bolt11InvoiceSignOrCreationErrorZPtr, - /// Whether this CResult_Bolt11InvoiceSignOrCreationErrorZ represents a success state. - pub result_ok: bool, -} -#[no_mangle] -/// 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_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, - } -} -/// Checks if the given object is currently in the success state -#[no_mangle] -pub extern "C" fn CResult_Bolt11InvoiceSignOrCreationErrorZ_is_ok(o: &CResult_Bolt11InvoiceSignOrCreationErrorZ) -> bool { - o.result_ok -} -#[no_mangle] -/// 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() } { - 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_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_Bolt11InvoiceSignOrCreationErrorZPtr { result } - } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_Bolt11InvoiceSignOrCreationErrorZPtr { err } - }; - Self { - contents, - result_ok: o.result_ok, - } - } -} -impl Clone for CResult_Bolt11InvoiceSignOrCreationErrorZ { - fn clone(&self) -> Self { - if self.result_ok { - 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_Bolt11InvoiceSignOrCreationErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } - } - } -} -#[no_mangle] -/// 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_Bolt11InvoiceSignOrCreationErrorZ_clone(orig: &CResult_Bolt11InvoiceSignOrCreationErrorZ) -> CResult_Bolt11InvoiceSignOrCreationErrorZ { Clone::clone(&orig) } -#[repr(C)] -#[derive(Clone)] -/// An enum which can either contain a crate::lightning::ln::channel_state::InboundHTLCStateDetails or not -pub enum COption_InboundHTLCStateDetailsZ { - /// When we're in this state, this COption_InboundHTLCStateDetailsZ contains a crate::lightning::ln::channel_state::InboundHTLCStateDetails - Some(crate::lightning::ln::channel_state::InboundHTLCStateDetails), - /// When we're in this state, this COption_InboundHTLCStateDetailsZ contains nothing - None -} -impl COption_InboundHTLCStateDetailsZ { - #[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::channel_state::InboundHTLCStateDetails { - if let Self::Some(v) = self { v } else { unreachable!() } - } -} -#[no_mangle] -/// Constructs a new COption_InboundHTLCStateDetailsZ containing a crate::lightning::ln::channel_state::InboundHTLCStateDetails -pub extern "C" fn COption_InboundHTLCStateDetailsZ_some(o: crate::lightning::ln::channel_state::InboundHTLCStateDetails) -> COption_InboundHTLCStateDetailsZ { - COption_InboundHTLCStateDetailsZ::Some(o) -} -#[no_mangle] -/// Constructs a new COption_InboundHTLCStateDetailsZ containing nothing -pub extern "C" fn COption_InboundHTLCStateDetailsZ_none() -> COption_InboundHTLCStateDetailsZ { - COption_InboundHTLCStateDetailsZ::None -} -#[no_mangle] -/// Frees any resources associated with the crate::lightning::ln::channel_state::InboundHTLCStateDetails, if we are in the Some state -pub extern "C" fn COption_InboundHTLCStateDetailsZ_free(_res: COption_InboundHTLCStateDetailsZ) { } -#[no_mangle] -/// Creates a new COption_InboundHTLCStateDetailsZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_InboundHTLCStateDetailsZ_clone(orig: &COption_InboundHTLCStateDetailsZ) -> COption_InboundHTLCStateDetailsZ { Clone::clone(&orig) } -#[repr(C)] -/// The contents of CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ -pub union CResult_COption_InboundHTLCStateDetailsZDecodeErrorZPtr { - /// 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_InboundHTLCStateDetailsZ, - /// 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_InboundHTLCStateDetailsZDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::COption_InboundHTLCStateDetailsZ 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_InboundHTLCStateDetailsZDecodeErrorZ { - /// The contents of this CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ, accessible via either +pub struct CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ { + /// The contents of this CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. pub contents: CResult_COption_InboundHTLCStateDetailsZDecodeErrorZPtr, /// Whether this CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ represents a success state. @@ -21581,41 +22190,41 @@ impl Drop for CVec_FutureZ { } } #[repr(C)] -/// The contents of CResult_OffersMessageDecodeErrorZ -pub union CResult_OffersMessageDecodeErrorZPtr { +/// The contents of CResult_HeldHtlcAvailableDecodeErrorZ +pub union CResult_HeldHtlcAvailableDecodeErrorZPtr { /// 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::onion_message::offers::OffersMessage, + pub result: *mut crate::lightning::onion_message::async_payments::HeldHtlcAvailable, /// 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_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. +/// A CResult_HeldHtlcAvailableDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::onion_message::async_payments::HeldHtlcAvailable 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_OffersMessageDecodeErrorZ { - /// The contents of this CResult_OffersMessageDecodeErrorZ, accessible via either +pub struct CResult_HeldHtlcAvailableDecodeErrorZ { + /// The contents of this CResult_HeldHtlcAvailableDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_OffersMessageDecodeErrorZPtr, - /// Whether this CResult_OffersMessageDecodeErrorZ represents a success state. + pub contents: CResult_HeldHtlcAvailableDecodeErrorZPtr, + /// Whether this CResult_HeldHtlcAvailableDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// 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 { +/// Creates a new CResult_HeldHtlcAvailableDecodeErrorZ in the success state. +pub extern "C" fn CResult_HeldHtlcAvailableDecodeErrorZ_ok(o: crate::lightning::onion_message::async_payments::HeldHtlcAvailable) -> CResult_HeldHtlcAvailableDecodeErrorZ { + CResult_HeldHtlcAvailableDecodeErrorZ { + contents: CResult_HeldHtlcAvailableDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// 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 { +/// Creates a new CResult_HeldHtlcAvailableDecodeErrorZ in the error state. +pub extern "C" fn CResult_HeldHtlcAvailableDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_HeldHtlcAvailableDecodeErrorZ { + CResult_HeldHtlcAvailableDecodeErrorZ { + contents: CResult_HeldHtlcAvailableDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -21623,13 +22232,13 @@ pub extern "C" fn CResult_OffersMessageDecodeErrorZ_err(e: crate::lightning::ln: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_OffersMessageDecodeErrorZ_is_ok(o: &CResult_OffersMessageDecodeErrorZ) -> bool { +pub extern "C" fn CResult_HeldHtlcAvailableDecodeErrorZ_is_ok(o: &CResult_HeldHtlcAvailableDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_OffersMessageDecodeErrorZ. -pub extern "C" fn CResult_OffersMessageDecodeErrorZ_free(_res: CResult_OffersMessageDecodeErrorZ) { } -impl Drop for CResult_OffersMessageDecodeErrorZ { +/// Frees any resources used by the CResult_HeldHtlcAvailableDecodeErrorZ. +pub extern "C" fn CResult_HeldHtlcAvailableDecodeErrorZ_free(_res: CResult_HeldHtlcAvailableDecodeErrorZ) { } +impl Drop for CResult_HeldHtlcAvailableDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -21642,16 +22251,16 @@ impl Drop for CResult_OffersMessageDecodeErrorZ { } } } -impl From> for CResult_OffersMessageDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_HeldHtlcAvailableDecodeErrorZ { + 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_OffersMessageDecodeErrorZPtr { result } + CResult_HeldHtlcAvailableDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_OffersMessageDecodeErrorZPtr { err } + CResult_HeldHtlcAvailableDecodeErrorZPtr { err } }; Self { contents, @@ -21659,91 +22268,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_OffersMessageDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_HeldHtlcAvailableDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_OffersMessageDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_HeldHtlcAvailableDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_OffersMessageDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_HeldHtlcAvailableDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -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) { } +pub extern "C" fn CResult_HeldHtlcAvailableDecodeErrorZ_clone(orig: &CResult_HeldHtlcAvailableDecodeErrorZ) -> CResult_HeldHtlcAvailableDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_CounterpartyCommitmentSecretsDecodeErrorZ -pub union CResult_CounterpartyCommitmentSecretsDecodeErrorZPtr { +/// The contents of CResult_ReleaseHeldHtlcDecodeErrorZ +pub union CResult_ReleaseHeldHtlcDecodeErrorZPtr { /// 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::onion_message::async_payments::ReleaseHeldHtlc, /// 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_ReleaseHeldHtlcDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::onion_message::async_payments::ReleaseHeldHtlc 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_ReleaseHeldHtlcDecodeErrorZ { + /// The contents of this CResult_ReleaseHeldHtlcDecodeErrorZ, 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_ReleaseHeldHtlcDecodeErrorZPtr, + /// Whether this CResult_ReleaseHeldHtlcDecodeErrorZ 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_ReleaseHeldHtlcDecodeErrorZ in the success state. +pub extern "C" fn CResult_ReleaseHeldHtlcDecodeErrorZ_ok(o: crate::lightning::onion_message::async_payments::ReleaseHeldHtlc) -> CResult_ReleaseHeldHtlcDecodeErrorZ { + CResult_ReleaseHeldHtlcDecodeErrorZ { + contents: CResult_ReleaseHeldHtlcDecodeErrorZPtr { 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_ReleaseHeldHtlcDecodeErrorZ in the error state. +pub extern "C" fn CResult_ReleaseHeldHtlcDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ReleaseHeldHtlcDecodeErrorZ { + CResult_ReleaseHeldHtlcDecodeErrorZ { + contents: CResult_ReleaseHeldHtlcDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -21751,13 +22328,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_ReleaseHeldHtlcDecodeErrorZ_is_ok(o: &CResult_ReleaseHeldHtlcDecodeErrorZ) -> 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_ReleaseHeldHtlcDecodeErrorZ. +pub extern "C" fn CResult_ReleaseHeldHtlcDecodeErrorZ_free(_res: CResult_ReleaseHeldHtlcDecodeErrorZ) { } +impl Drop for CResult_ReleaseHeldHtlcDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -21770,16 +22347,16 @@ impl Drop for CResult_CounterpartyCommitmentSecretsDecodeErrorZ { } } } -impl From> for CResult_CounterpartyCommitmentSecretsDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ReleaseHeldHtlcDecodeErrorZ { + 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_ReleaseHeldHtlcDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_CounterpartyCommitmentSecretsDecodeErrorZPtr { err } + CResult_ReleaseHeldHtlcDecodeErrorZPtr { err } }; Self { contents, @@ -21787,59 +22364,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_ReleaseHeldHtlcDecodeErrorZPtr { + 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_ReleaseHeldHtlcDecodeErrorZPtr { 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_ReleaseHeldHtlcDecodeErrorZ 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_ReleaseHeldHtlcDecodeErrorZ_clone(orig: &CResult_ReleaseHeldHtlcDecodeErrorZ) -> CResult_ReleaseHeldHtlcDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_TxCreationKeysDecodeErrorZ -pub union CResult_TxCreationKeysDecodeErrorZPtr { +/// The contents of CResult_AsyncPaymentsMessageDecodeErrorZ +pub union CResult_AsyncPaymentsMessageDecodeErrorZPtr { /// 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::onion_message::async_payments::AsyncPaymentsMessage, /// 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_AsyncPaymentsMessageDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::onion_message::async_payments::AsyncPaymentsMessage 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_AsyncPaymentsMessageDecodeErrorZ { + /// The contents of this CResult_AsyncPaymentsMessageDecodeErrorZ, 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_AsyncPaymentsMessageDecodeErrorZPtr, + /// Whether this CResult_AsyncPaymentsMessageDecodeErrorZ 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_AsyncPaymentsMessageDecodeErrorZ in the success state. +pub extern "C" fn CResult_AsyncPaymentsMessageDecodeErrorZ_ok(o: crate::lightning::onion_message::async_payments::AsyncPaymentsMessage) -> CResult_AsyncPaymentsMessageDecodeErrorZ { + CResult_AsyncPaymentsMessageDecodeErrorZ { + contents: CResult_AsyncPaymentsMessageDecodeErrorZPtr { 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_AsyncPaymentsMessageDecodeErrorZ in the error state. +pub extern "C" fn CResult_AsyncPaymentsMessageDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_AsyncPaymentsMessageDecodeErrorZ { + CResult_AsyncPaymentsMessageDecodeErrorZ { + contents: CResult_AsyncPaymentsMessageDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -21847,13 +22424,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_AsyncPaymentsMessageDecodeErrorZ_is_ok(o: &CResult_AsyncPaymentsMessageDecodeErrorZ) -> 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_AsyncPaymentsMessageDecodeErrorZ. +pub extern "C" fn CResult_AsyncPaymentsMessageDecodeErrorZ_free(_res: CResult_AsyncPaymentsMessageDecodeErrorZ) { } +impl Drop for CResult_AsyncPaymentsMessageDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -21866,16 +22443,16 @@ impl Drop for CResult_TxCreationKeysDecodeErrorZ { } } } -impl From> for CResult_TxCreationKeysDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_AsyncPaymentsMessageDecodeErrorZ { + 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_AsyncPaymentsMessageDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_TxCreationKeysDecodeErrorZPtr { err } + CResult_AsyncPaymentsMessageDecodeErrorZPtr { err } }; Self { contents, @@ -21883,59 +22460,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_AsyncPaymentsMessageDecodeErrorZPtr { + 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_AsyncPaymentsMessageDecodeErrorZPtr { 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_AsyncPaymentsMessageDecodeErrorZ 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_AsyncPaymentsMessageDecodeErrorZ_clone(orig: &CResult_AsyncPaymentsMessageDecodeErrorZ) -> CResult_AsyncPaymentsMessageDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_ChannelPublicKeysDecodeErrorZ -pub union CResult_ChannelPublicKeysDecodeErrorZPtr { +/// 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::ln::chan_utils::ChannelPublicKeys, + 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_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_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_ChannelPublicKeysDecodeErrorZ { - /// The contents of this CResult_ChannelPublicKeysDecodeErrorZ, 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_ChannelPublicKeysDecodeErrorZPtr, - /// Whether this CResult_ChannelPublicKeysDecodeErrorZ 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_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_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_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_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, @@ -21943,13 +22520,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_OffersMessageDecodeErrorZ_is_ok(o: &CResult_OffersMessageDecodeErrorZ) -> 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_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() } { @@ -21962,16 +22539,16 @@ impl Drop for CResult_ChannelPublicKeysDecodeErrorZ { } } } -impl From> for CResult_ChannelPublicKeysDecodeErrorZ { - 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_ChannelPublicKeysDecodeErrorZPtr { result } + CResult_OffersMessageDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ChannelPublicKeysDecodeErrorZPtr { err } + CResult_OffersMessageDecodeErrorZPtr { err } }; Self { contents, @@ -21979,59 +22556,91 @@ 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_OffersMessageDecodeErrorZPtr { + 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_OffersMessageDecodeErrorZPtr { 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_OffersMessageDecodeErrorZ 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_OffersMessageDecodeErrorZ_clone(orig: &CResult_OffersMessageDecodeErrorZ) -> CResult_OffersMessageDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_HTLCOutputInCommitmentDecodeErrorZ -pub union CResult_HTLCOutputInCommitmentDecodeErrorZPtr { +/// 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_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::ln::chan_utils::HTLCOutputInCommitment, + 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::ln::msgs::DecodeError, } #[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_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_HTLCOutputInCommitmentDecodeErrorZ { - /// The contents of this CResult_HTLCOutputInCommitmentDecodeErrorZ, 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_HTLCOutputInCommitmentDecodeErrorZPtr, - /// Whether this CResult_HTLCOutputInCommitmentDecodeErrorZ 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_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_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_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 { +/// 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, @@ -22039,13 +22648,13 @@ pub extern "C" fn CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e: crate::light } /// 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_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok(o: &CResult_CounterpartyCommitmentSecretsDecodeErrorZ) -> 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_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() } { @@ -22058,16 +22667,16 @@ impl Drop for CResult_HTLCOutputInCommitmentDecodeErrorZ { } } } -impl From> for CResult_HTLCOutputInCommitmentDecodeErrorZ { - 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_HTLCOutputInCommitmentDecodeErrorZPtr { result } + CResult_CounterpartyCommitmentSecretsDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_HTLCOutputInCommitmentDecodeErrorZPtr { err } + CResult_CounterpartyCommitmentSecretsDecodeErrorZPtr { err } }; Self { contents, @@ -22075,59 +22684,59 @@ 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_CounterpartyCommitmentSecretsDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_HTLCOutputInCommitmentDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_CounterpartyCommitmentSecretsDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_HTLCOutputInCommitmentDecodeErrorZ 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_HTLCOutputInCommitmentDecodeErrorZ_clone(orig: &CResult_HTLCOutputInCommitmentDecodeErrorZ) -> CResult_HTLCOutputInCommitmentDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(orig: &CResult_CounterpartyCommitmentSecretsDecodeErrorZ) -> CResult_CounterpartyCommitmentSecretsDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_CounterpartyChannelTransactionParametersDecodeErrorZ -pub union CResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr { +/// 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::ln::chan_utils::CounterpartyChannelTransactionParameters, + 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::ln::msgs::DecodeError, } #[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_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_CounterpartyChannelTransactionParametersDecodeErrorZ { - /// The contents of this CResult_CounterpartyChannelTransactionParametersDecodeErrorZ, 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_CounterpartyChannelTransactionParametersDecodeErrorZPtr, - /// Whether this CResult_CounterpartyChannelTransactionParametersDecodeErrorZ 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_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 { +/// 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_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 { +/// 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, @@ -22135,13 +22744,13 @@ pub extern "C" fn CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_e } /// 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_TxCreationKeysDecodeErrorZ_is_ok(o: &CResult_TxCreationKeysDecodeErrorZ) -> 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_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() } { @@ -22154,16 +22763,16 @@ impl Drop for CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { } } } -impl From> for CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { - 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_CounterpartyChannelTransactionParametersDecodeErrorZPtr { result } + CResult_TxCreationKeysDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr { err } + CResult_TxCreationKeysDecodeErrorZPtr { err } }; Self { contents, @@ -22171,59 +22780,59 @@ 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_TxCreationKeysDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_TxCreationKeysDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_CounterpartyChannelTransactionParametersDecodeErrorZ 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_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig: &CResult_CounterpartyChannelTransactionParametersDecodeErrorZ) -> CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_TxCreationKeysDecodeErrorZ_clone(orig: &CResult_TxCreationKeysDecodeErrorZ) -> CResult_TxCreationKeysDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_ChannelTransactionParametersDecodeErrorZ -pub union CResult_ChannelTransactionParametersDecodeErrorZPtr { +/// 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::ln::chan_utils::ChannelTransactionParameters, + 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::ln::msgs::DecodeError, } #[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. +/// 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_ChannelTransactionParametersDecodeErrorZ { - /// The contents of this CResult_ChannelTransactionParametersDecodeErrorZ, 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_ChannelTransactionParametersDecodeErrorZPtr, - /// Whether this CResult_ChannelTransactionParametersDecodeErrorZ 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_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 { +/// 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_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 { +/// 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, @@ -22231,13 +22840,13 @@ pub extern "C" fn CResult_ChannelTransactionParametersDecodeErrorZ_err(e: crate: } /// 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 { +pub extern "C" fn CResult_ChannelPublicKeysDecodeErrorZ_is_ok(o: &CResult_ChannelPublicKeysDecodeErrorZ) -> bool { o.result_ok } #[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 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() } { @@ -22250,16 +22859,16 @@ impl Drop for CResult_ChannelTransactionParametersDecodeErrorZ { } } } -impl From> for CResult_ChannelTransactionParametersDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +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_ChannelTransactionParametersDecodeErrorZPtr { result } + CResult_ChannelPublicKeysDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ChannelTransactionParametersDecodeErrorZPtr { err } + CResult_ChannelPublicKeysDecodeErrorZPtr { err } }; Self { contents, @@ -22267,59 +22876,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ChannelTransactionParametersDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + 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_ChannelTransactionParametersDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_ChannelPublicKeysDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_ChannelTransactionParametersDecodeErrorZ 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 CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig: &CResult_ChannelTransactionParametersDecodeErrorZ) -> CResult_ChannelTransactionParametersDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_ChannelPublicKeysDecodeErrorZ_clone(orig: &CResult_ChannelPublicKeysDecodeErrorZ) -> CResult_ChannelPublicKeysDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_HolderCommitmentTransactionDecodeErrorZ -pub union CResult_HolderCommitmentTransactionDecodeErrorZPtr { +/// 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::ln::chan_utils::HolderCommitmentTransaction, + 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, } #[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_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_HolderCommitmentTransactionDecodeErrorZ { - /// The contents of this CResult_HolderCommitmentTransactionDecodeErrorZ, 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_HolderCommitmentTransactionDecodeErrorZPtr, - /// Whether this CResult_HolderCommitmentTransactionDecodeErrorZ 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_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_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_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 { +/// 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, @@ -22327,13 +22936,13 @@ pub extern "C" fn CResult_HolderCommitmentTransactionDecodeErrorZ_err(e: crate:: } /// 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_HTLCOutputInCommitmentDecodeErrorZ_is_ok(o: &CResult_HTLCOutputInCommitmentDecodeErrorZ) -> 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_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() } { @@ -22346,16 +22955,16 @@ impl Drop for CResult_HolderCommitmentTransactionDecodeErrorZ { } } } -impl From> for CResult_HolderCommitmentTransactionDecodeErrorZ { - 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_HolderCommitmentTransactionDecodeErrorZPtr { result } + CResult_HTLCOutputInCommitmentDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_HolderCommitmentTransactionDecodeErrorZPtr { err } + CResult_HTLCOutputInCommitmentDecodeErrorZPtr { err } }; Self { contents, @@ -22363,59 +22972,59 @@ 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_HTLCOutputInCommitmentDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_HolderCommitmentTransactionDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_HTLCOutputInCommitmentDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_HolderCommitmentTransactionDecodeErrorZ 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_HolderCommitmentTransactionDecodeErrorZ_clone(orig: &CResult_HolderCommitmentTransactionDecodeErrorZ) -> CResult_HolderCommitmentTransactionDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig: &CResult_HTLCOutputInCommitmentDecodeErrorZ) -> CResult_HTLCOutputInCommitmentDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_BuiltCommitmentTransactionDecodeErrorZ -pub union CResult_BuiltCommitmentTransactionDecodeErrorZPtr { +/// 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::BuiltCommitmentTransaction, + 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, } #[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_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_BuiltCommitmentTransactionDecodeErrorZ { - /// The contents of this CResult_BuiltCommitmentTransactionDecodeErrorZ, 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_BuiltCommitmentTransactionDecodeErrorZPtr, - /// Whether this CResult_BuiltCommitmentTransactionDecodeErrorZ 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_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_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_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 { +/// 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, @@ -22423,13 +23032,13 @@ pub extern "C" fn CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e: crate::l } /// 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_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(o: &CResult_CounterpartyChannelTransactionParametersDecodeErrorZ) -> 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_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() } { @@ -22442,16 +23051,16 @@ impl Drop for CResult_BuiltCommitmentTransactionDecodeErrorZ { } } } -impl From> for CResult_BuiltCommitmentTransactionDecodeErrorZ { - 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_BuiltCommitmentTransactionDecodeErrorZPtr { result } + CResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_BuiltCommitmentTransactionDecodeErrorZPtr { err } + CResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr { err } }; Self { contents, @@ -22459,91 +23068,95 @@ 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_CounterpartyChannelTransactionParametersDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_BuiltCommitmentTransactionDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_BuiltCommitmentTransactionDecodeErrorZ 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_BuiltCommitmentTransactionDecodeErrorZ_clone(orig: &CResult_BuiltCommitmentTransactionDecodeErrorZ) -> CResult_BuiltCommitmentTransactionDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig: &CResult_CounterpartyChannelTransactionParametersDecodeErrorZ) -> CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_TrustedClosingTransactionNoneZ -pub union CResult_TrustedClosingTransactionNoneZPtr { +/// 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::TrustedClosingTransaction, - /// 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::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, } #[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_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_TrustedClosingTransactionNoneZ { - /// The contents of this CResult_TrustedClosingTransactionNoneZ, 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_TrustedClosingTransactionNoneZPtr, - /// Whether this CResult_TrustedClosingTransactionNoneZ 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_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_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_TrustedClosingTransactionNoneZ in the error state. -pub extern "C" fn CResult_TrustedClosingTransactionNoneZ_err() -> CResult_TrustedClosingTransactionNoneZ { - CResult_TrustedClosingTransactionNoneZ { - contents: CResult_TrustedClosingTransactionNoneZPtr { - err: core::ptr::null_mut(), +/// 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, } } /// 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_ChannelTransactionParametersDecodeErrorZ_is_ok(o: &CResult_ChannelTransactionParametersDecodeErrorZ) -> 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_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) }; + } } } } -impl From> for CResult_TrustedClosingTransactionNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +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_TrustedClosingTransactionNoneZPtr { result } + CResult_ChannelTransactionParametersDecodeErrorZPtr { result } } else { - let _ = unsafe { Box::from_raw(o.contents.err) }; - o.contents.err = core::ptr::null_mut(); - CResult_TrustedClosingTransactionNoneZPtr { err: core::ptr::null_mut() } + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_ChannelTransactionParametersDecodeErrorZPtr { err } }; Self { contents, @@ -22551,42 +23164,59 @@ impl From 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 }))) + } } + } + } +} +#[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)] -/// The contents of CResult_CommitmentTransactionDecodeErrorZ -pub union CResult_CommitmentTransactionDecodeErrorZPtr { +/// 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::ln::chan_utils::CommitmentTransaction, + 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, } #[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_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_CommitmentTransactionDecodeErrorZ { - /// The contents of this CResult_CommitmentTransactionDecodeErrorZ, 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_CommitmentTransactionDecodeErrorZPtr, - /// Whether this CResult_CommitmentTransactionDecodeErrorZ 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_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_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_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 { +/// 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, @@ -22594,13 +23224,13 @@ pub extern "C" fn CResult_CommitmentTransactionDecodeErrorZ_err(e: crate::lightn } /// 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_HolderCommitmentTransactionDecodeErrorZ_is_ok(o: &CResult_HolderCommitmentTransactionDecodeErrorZ) -> 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_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() } { @@ -22613,16 +23243,16 @@ impl Drop for CResult_CommitmentTransactionDecodeErrorZ { } } } -impl From> for CResult_CommitmentTransactionDecodeErrorZ { - 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_CommitmentTransactionDecodeErrorZPtr { result } + CResult_HolderCommitmentTransactionDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_CommitmentTransactionDecodeErrorZPtr { err } + CResult_HolderCommitmentTransactionDecodeErrorZPtr { err } }; Self { contents, @@ -22630,91 +23260,95 @@ 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_HolderCommitmentTransactionDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_CommitmentTransactionDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_HolderCommitmentTransactionDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_CommitmentTransactionDecodeErrorZ 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_CommitmentTransactionDecodeErrorZ_clone(orig: &CResult_CommitmentTransactionDecodeErrorZ) -> CResult_CommitmentTransactionDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig: &CResult_HolderCommitmentTransactionDecodeErrorZ) -> CResult_HolderCommitmentTransactionDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_TrustedCommitmentTransactionNoneZ -pub union CResult_TrustedCommitmentTransactionNoneZPtr { +/// 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::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, + 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, } #[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_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_TrustedCommitmentTransactionNoneZ { - /// The contents of this CResult_TrustedCommitmentTransactionNoneZ, 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_TrustedCommitmentTransactionNoneZPtr, - /// Whether this CResult_TrustedCommitmentTransactionNoneZ 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_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_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_TrustedCommitmentTransactionNoneZ in the error state. -pub extern "C" fn CResult_TrustedCommitmentTransactionNoneZ_err() -> CResult_TrustedCommitmentTransactionNoneZ { - CResult_TrustedCommitmentTransactionNoneZ { - contents: CResult_TrustedCommitmentTransactionNoneZPtr { - err: core::ptr::null_mut(), +/// 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, } } /// 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_BuiltCommitmentTransactionDecodeErrorZ_is_ok(o: &CResult_BuiltCommitmentTransactionDecodeErrorZ) -> 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_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() } { 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_TrustedCommitmentTransactionNoneZ { - 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_TrustedCommitmentTransactionNoneZPtr { result } + CResult_BuiltCommitmentTransactionDecodeErrorZPtr { result } } else { - let _ = unsafe { Box::from_raw(o.contents.err) }; - o.contents.err = core::ptr::null_mut(); - CResult_TrustedCommitmentTransactionNoneZPtr { err: core::ptr::null_mut() } + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_BuiltCommitmentTransactionDecodeErrorZPtr { err } }; Self { contents, @@ -22722,41 +23356,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 }))) + } } + } else { + Self { result_ok: false, contents: CResult_BuiltCommitmentTransactionDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// 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_BuiltCommitmentTransactionDecodeErrorZ_clone(orig: &CResult_BuiltCommitmentTransactionDecodeErrorZ) -> CResult_BuiltCommitmentTransactionDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_CVec_ECDSASignatureZNoneZ -pub union CResult_CVec_ECDSASignatureZNoneZPtr { +/// 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::c_types::derived::CVec_ECDSASignatureZ, + 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_CVec_ECDSASignatureZNoneZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::CVec_ECDSASignatureZ on success and a () 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_CVec_ECDSASignatureZNoneZ { - /// The contents of this CResult_CVec_ECDSASignatureZNoneZ, 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_CVec_ECDSASignatureZNoneZPtr, - /// Whether this CResult_CVec_ECDSASignatureZNoneZ 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_CVec_ECDSASignatureZNoneZ in the success state. -pub extern "C" fn CResult_CVec_ECDSASignatureZNoneZ_ok(o: crate::c_types::derived::CVec_ECDSASignatureZ) -> CResult_CVec_ECDSASignatureZNoneZ { - CResult_CVec_ECDSASignatureZNoneZ { - contents: CResult_CVec_ECDSASignatureZNoneZPtr { +/// 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_CVec_ECDSASignatureZNoneZ in the error state. -pub extern "C" fn CResult_CVec_ECDSASignatureZNoneZ_err() -> CResult_CVec_ECDSASignatureZNoneZ { - CResult_CVec_ECDSASignatureZNoneZ { - contents: CResult_CVec_ECDSASignatureZNoneZPtr { +/// 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, @@ -22764,13 +23415,13 @@ pub extern "C" fn CResult_CVec_ECDSASignatureZNoneZ_err() -> CResult_CVec_ECDSAS } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_CVec_ECDSASignatureZNoneZ_is_ok(o: &CResult_CVec_ECDSASignatureZNoneZ) -> 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_CVec_ECDSASignatureZNoneZ. -pub extern "C" fn CResult_CVec_ECDSASignatureZNoneZ_free(_res: CResult_CVec_ECDSASignatureZNoneZ) { } -impl Drop for CResult_CVec_ECDSASignatureZNoneZ { +/// 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() } { @@ -22780,16 +23431,16 @@ impl Drop for CResult_CVec_ECDSASignatureZNoneZ { } } } -impl From> for CResult_CVec_ECDSASignatureZNoneZ { - 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_CVec_ECDSASignatureZNoneZPtr { result } + CResult_TrustedClosingTransactionNoneZPtr { result } } else { let _ = unsafe { Box::from_raw(o.contents.err) }; o.contents.err = core::ptr::null_mut(); - CResult_CVec_ECDSASignatureZNoneZPtr { err: core::ptr::null_mut() } + CResult_TrustedClosingTransactionNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -22797,96 +23448,42 @@ impl From Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_CVec_ECDSASignatureZNoneZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_CVec_ECDSASignatureZNoneZPtr { - err: core::ptr::null_mut() - } } - } - } -} -#[no_mangle] -/// Creates a new CResult_CVec_ECDSASignatureZNoneZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_CVec_ECDSASignatureZNoneZ_clone(orig: &CResult_CVec_ECDSASignatureZNoneZ) -> CResult_CVec_ECDSASignatureZNoneZ { Clone::clone(&orig) } -#[repr(C)] -#[derive(Clone)] -/// An enum which can either contain a usize or not -pub enum COption_usizeZ { - /// When we're in this state, this COption_usizeZ contains a usize - Some(usize), - /// When we're in this state, this COption_usizeZ contains nothing - None -} -impl COption_usizeZ { - #[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) -> usize { - if let Self::Some(v) = self { v } else { unreachable!() } - } -} -#[no_mangle] -/// Constructs a new COption_usizeZ containing a usize -pub extern "C" fn COption_usizeZ_some(o: usize) -> COption_usizeZ { - COption_usizeZ::Some(o) -} -#[no_mangle] -/// Constructs a new COption_usizeZ containing nothing -pub extern "C" fn COption_usizeZ_none() -> COption_usizeZ { - COption_usizeZ::None -} -#[no_mangle] -/// Frees any resources associated with the usize, if we are in the Some state -pub extern "C" fn COption_usizeZ_free(_res: COption_usizeZ) { } -#[no_mangle] -/// Creates a new COption_usizeZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_usizeZ_clone(orig: &COption_usizeZ) -> COption_usizeZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_ShutdownScriptDecodeErrorZ -pub union CResult_ShutdownScriptDecodeErrorZPtr { +/// 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::script::ShutdownScript, + 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_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_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_ShutdownScriptDecodeErrorZ { - /// The contents of this CResult_ShutdownScriptDecodeErrorZ, 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_ShutdownScriptDecodeErrorZPtr, - /// Whether this CResult_ShutdownScriptDecodeErrorZ 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_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_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_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 { +/// 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, @@ -22894,13 +23491,13 @@ pub extern "C" fn CResult_ShutdownScriptDecodeErrorZ_err(e: crate::lightning::ln } /// 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_CommitmentTransactionDecodeErrorZ_is_ok(o: &CResult_CommitmentTransactionDecodeErrorZ) -> 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_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() } { @@ -22913,16 +23510,16 @@ impl Drop for CResult_ShutdownScriptDecodeErrorZ { } } } -impl From> for CResult_ShutdownScriptDecodeErrorZ { - 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_ShutdownScriptDecodeErrorZPtr { result } + CResult_CommitmentTransactionDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ShutdownScriptDecodeErrorZPtr { err } + CResult_CommitmentTransactionDecodeErrorZPtr { err } }; Self { contents, @@ -22930,95 +23527,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_CommitmentTransactionDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_ShutdownScriptDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_CommitmentTransactionDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_ShutdownScriptDecodeErrorZ 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_ShutdownScriptDecodeErrorZ_clone(orig: &CResult_ShutdownScriptDecodeErrorZ) -> CResult_ShutdownScriptDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_CommitmentTransactionDecodeErrorZ_clone(orig: &CResult_CommitmentTransactionDecodeErrorZ) -> CResult_CommitmentTransactionDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_ShutdownScriptInvalidShutdownScriptZ -pub union CResult_ShutdownScriptInvalidShutdownScriptZPtr { +/// 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::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, + 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 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_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_ShutdownScriptInvalidShutdownScriptZ { - /// The contents of this CResult_ShutdownScriptInvalidShutdownScriptZ, accessible via either +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_ShutdownScriptInvalidShutdownScriptZPtr, - /// Whether this CResult_ShutdownScriptInvalidShutdownScriptZ represents a success state. + pub contents: CResult_TrustedCommitmentTransactionNoneZPtr, + /// Whether this CResult_TrustedCommitmentTransactionNoneZ 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_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] -/// 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_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, } } /// 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_TrustedCommitmentTransactionNoneZ_is_ok(o: &CResult_TrustedCommitmentTransactionNoneZ) -> 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_TrustedCommitmentTransactionNoneZ. +pub extern "C" fn CResult_TrustedCommitmentTransactionNoneZ_free(_res: CResult_TrustedCommitmentTransactionNoneZ) { } +impl Drop for CResult_TrustedCommitmentTransactionNoneZ { 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_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_ShutdownScriptInvalidShutdownScriptZPtr { result } + CResult_TrustedCommitmentTransactionNoneZPtr { 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_TrustedCommitmentTransactionNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -23026,141 +23619,74 @@ impl From Self { - if self.result_ok { - 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_ShutdownScriptInvalidShutdownScriptZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } - } - } -} -#[no_mangle] -/// 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_ShutdownScriptInvalidShutdownScriptZ_clone(orig: &CResult_ShutdownScriptInvalidShutdownScriptZ) -> CResult_ShutdownScriptInvalidShutdownScriptZ { Clone::clone(&orig) } -#[repr(C)] -/// 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 -} -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) } - } -} -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] -/// 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)) }; - } -} -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) - } -} #[repr(C)] -/// The contents of CResult_PaymentPurposeDecodeErrorZ -pub union CResult_PaymentPurposeDecodeErrorZPtr { +/// The contents of CResult_CVec_ECDSASignatureZNoneZ +pub union CResult_CVec_ECDSASignatureZNoneZPtr { /// 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, - /// 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_ECDSASignatureZ, + /// 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_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_CVec_ECDSASignatureZNoneZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::CVec_ECDSASignatureZ on success and a () 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_CVec_ECDSASignatureZNoneZ { + /// The contents of this CResult_CVec_ECDSASignatureZNoneZ, 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_CVec_ECDSASignatureZNoneZPtr, + /// Whether this CResult_CVec_ECDSASignatureZNoneZ 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_CVec_ECDSASignatureZNoneZ in the success state. +pub extern "C" fn CResult_CVec_ECDSASignatureZNoneZ_ok(o: crate::c_types::derived::CVec_ECDSASignatureZ) -> CResult_CVec_ECDSASignatureZNoneZ { + CResult_CVec_ECDSASignatureZNoneZ { + contents: CResult_CVec_ECDSASignatureZNoneZPtr { 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)), +/// Creates a new CResult_CVec_ECDSASignatureZNoneZ in the error state. +pub extern "C" fn CResult_CVec_ECDSASignatureZNoneZ_err() -> CResult_CVec_ECDSASignatureZNoneZ { + CResult_CVec_ECDSASignatureZNoneZ { + contents: CResult_CVec_ECDSASignatureZNoneZPtr { + 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_PaymentPurposeDecodeErrorZ_is_ok(o: &CResult_PaymentPurposeDecodeErrorZ) -> bool { +pub extern "C" fn CResult_CVec_ECDSASignatureZNoneZ_is_ok(o: &CResult_CVec_ECDSASignatureZNoneZ) -> 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_CVec_ECDSASignatureZNoneZ. +pub extern "C" fn CResult_CVec_ECDSASignatureZNoneZ_free(_res: CResult_CVec_ECDSASignatureZNoneZ) { } +impl Drop for CResult_CVec_ECDSASignatureZNoneZ { 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_PaymentPurposeDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_CVec_ECDSASignatureZNoneZ { + 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_CVec_ECDSASignatureZNoneZPtr { result } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_PaymentPurposeDecodeErrorZPtr { err } + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_CVec_ECDSASignatureZNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -23168,59 +23694,96 @@ 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_CVec_ECDSASignatureZNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_PaymentPurposeDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_CVec_ECDSASignatureZNoneZPtr { + err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_PaymentPurposeDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_CVec_ECDSASignatureZNoneZ 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) } +pub extern "C" fn CResult_CVec_ECDSASignatureZNoneZ_clone(orig: &CResult_CVec_ECDSASignatureZNoneZ) -> CResult_CVec_ECDSASignatureZNoneZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_ClaimedHTLCDecodeErrorZ -pub union CResult_ClaimedHTLCDecodeErrorZPtr { - /// 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::ClaimedHTLC, - /// 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 usize or not +pub enum COption_usizeZ { + /// When we're in this state, this COption_usizeZ contains a usize + Some(usize), + /// When we're in this state, this COption_usizeZ contains nothing + None } -#[repr(C)] -/// A CResult_ClaimedHTLCDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::events::ClaimedHTLC 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_ClaimedHTLCDecodeErrorZ { - /// The contents of this CResult_ClaimedHTLCDecodeErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ClaimedHTLCDecodeErrorZPtr, - /// Whether this CResult_ClaimedHTLCDecodeErrorZ represents a success state. - pub result_ok: bool, +impl COption_usizeZ { + #[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) -> usize { + if let Self::Some(v) = self { v } else { unreachable!() } + } } #[no_mangle] -/// Creates a new CResult_ClaimedHTLCDecodeErrorZ in the success state. -pub extern "C" fn CResult_ClaimedHTLCDecodeErrorZ_ok(o: crate::lightning::events::ClaimedHTLC) -> CResult_ClaimedHTLCDecodeErrorZ { - CResult_ClaimedHTLCDecodeErrorZ { - contents: CResult_ClaimedHTLCDecodeErrorZPtr { +/// Constructs a new COption_usizeZ containing a usize +pub extern "C" fn COption_usizeZ_some(o: usize) -> COption_usizeZ { + COption_usizeZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_usizeZ containing nothing +pub extern "C" fn COption_usizeZ_none() -> COption_usizeZ { + COption_usizeZ::None +} +#[no_mangle] +/// Frees any resources associated with the usize, if we are in the Some state +pub extern "C" fn COption_usizeZ_free(_res: COption_usizeZ) { } +#[no_mangle] +/// Creates a new COption_usizeZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_usizeZ_clone(orig: &COption_usizeZ) -> COption_usizeZ { Clone::clone(&orig) } +#[repr(C)] +/// 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::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_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_ShutdownScriptDecodeErrorZ { + /// The contents of this CResult_ShutdownScriptDecodeErrorZ, 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 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 { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ClaimedHTLCDecodeErrorZ in the error state. -pub extern "C" fn CResult_ClaimedHTLCDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ClaimedHTLCDecodeErrorZ { - CResult_ClaimedHTLCDecodeErrorZ { - contents: CResult_ClaimedHTLCDecodeErrorZPtr { +/// 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, @@ -23228,13 +23791,13 @@ pub extern "C" fn CResult_ClaimedHTLCDecodeErrorZ_err(e: crate::lightning::ln::m } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ClaimedHTLCDecodeErrorZ_is_ok(o: &CResult_ClaimedHTLCDecodeErrorZ) -> 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_ClaimedHTLCDecodeErrorZ. -pub extern "C" fn CResult_ClaimedHTLCDecodeErrorZ_free(_res: CResult_ClaimedHTLCDecodeErrorZ) { } -impl Drop for CResult_ClaimedHTLCDecodeErrorZ { +/// 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() } { @@ -23247,16 +23810,16 @@ impl Drop for CResult_ClaimedHTLCDecodeErrorZ { } } } -impl From> for CResult_ClaimedHTLCDecodeErrorZ { - 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_ClaimedHTLCDecodeErrorZPtr { result } + CResult_ShutdownScriptDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ClaimedHTLCDecodeErrorZPtr { err } + CResult_ShutdownScriptDecodeErrorZPtr { err } }; Self { contents, @@ -23264,96 +23827,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ClaimedHTLCDecodeErrorZPtr { - 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_ClaimedHTLCDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_ShutdownScriptDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_ClaimedHTLCDecodeErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ClaimedHTLCDecodeErrorZ_clone(orig: &CResult_ClaimedHTLCDecodeErrorZ) -> CResult_ClaimedHTLCDecodeErrorZ { 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_ShutdownScriptDecodeErrorZ 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_ShutdownScriptDecodeErrorZ_clone(orig: &CResult_ShutdownScriptDecodeErrorZ) -> CResult_ShutdownScriptDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_COption_PathFailureZDecodeErrorZ -pub union CResult_COption_PathFailureZDecodeErrorZPtr { +/// 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::c_types::derived::COption_PathFailureZ, + 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_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_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_COption_PathFailureZDecodeErrorZ { - /// The contents of this CResult_COption_PathFailureZDecodeErrorZ, 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_COption_PathFailureZDecodeErrorZPtr, - /// Whether this CResult_COption_PathFailureZDecodeErrorZ 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_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_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_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_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, @@ -23361,13 +23887,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_ShutdownScriptInvalidShutdownScriptZ_is_ok(o: &CResult_ShutdownScriptInvalidShutdownScriptZ) -> 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_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() } { @@ -23380,16 +23906,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_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_COption_PathFailureZDecodeErrorZPtr { result } + CResult_ShutdownScriptInvalidShutdownScriptZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_COption_PathFailureZDecodeErrorZPtr { err } + CResult_ShutdownScriptInvalidShutdownScriptZPtr { err } }; Self { contents, @@ -23397,96 +23923,105 @@ 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_ShutdownScriptInvalidShutdownScriptZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_COption_PathFailureZDecodeErrorZPtr { - 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_COption_PathFailureZDecodeErrorZ 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_COption_PathFailureZDecodeErrorZ_clone(orig: &CResult_COption_PathFailureZDecodeErrorZ) -> CResult_COption_PathFailureZDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_ShutdownScriptInvalidShutdownScriptZ_clone(orig: &CResult_ShutdownScriptInvalidShutdownScriptZ) -> CResult_ShutdownScriptInvalidShutdownScriptZ { 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 +/// 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 } -impl COption_ClosureReasonZ { - #[allow(unused)] pub(crate) fn is_some(&self) -> bool { - if let Self::None = self { false } else { true } +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 is_none(&self) -> bool { - !self.is_some() + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::Transaction] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::events::ClosureReason { - if let Self::Some(v) = self { v } else { unreachable!() } +} +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] -/// 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) +/// 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)) }; + } } -#[no_mangle] -/// Constructs a new COption_ClosureReasonZ containing nothing -pub extern "C" fn COption_ClosureReasonZ_none() -> COption_ClosureReasonZ { - COption_ClosureReasonZ::None +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) + } } -#[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 { +/// The contents of CResult_FundingInfoDecodeErrorZ +pub union CResult_FundingInfoDecodeErrorZPtr { /// 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::events::FundingInfo, /// 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_FundingInfoDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::events::FundingInfo 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_FundingInfoDecodeErrorZ { + /// The contents of this CResult_FundingInfoDecodeErrorZ, 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_FundingInfoDecodeErrorZPtr, + /// Whether this CResult_FundingInfoDecodeErrorZ 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_FundingInfoDecodeErrorZ in the success state. +pub extern "C" fn CResult_FundingInfoDecodeErrorZ_ok(o: crate::lightning::events::FundingInfo) -> CResult_FundingInfoDecodeErrorZ { + CResult_FundingInfoDecodeErrorZ { + contents: CResult_FundingInfoDecodeErrorZPtr { 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_FundingInfoDecodeErrorZ in the error state. +pub extern "C" fn CResult_FundingInfoDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_FundingInfoDecodeErrorZ { + CResult_FundingInfoDecodeErrorZ { + contents: CResult_FundingInfoDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -23494,13 +24029,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_FundingInfoDecodeErrorZ_is_ok(o: &CResult_FundingInfoDecodeErrorZ) -> 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_FundingInfoDecodeErrorZ. +pub extern "C" fn CResult_FundingInfoDecodeErrorZ_free(_res: CResult_FundingInfoDecodeErrorZ) { } +impl Drop for CResult_FundingInfoDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -23513,16 +24048,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_FundingInfoDecodeErrorZ { + 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_FundingInfoDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_COption_ClosureReasonZDecodeErrorZPtr { err } + CResult_FundingInfoDecodeErrorZPtr { err } }; Self { contents, @@ -23530,96 +24065,59 @@ 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_FundingInfoDecodeErrorZPtr { + 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_FundingInfoDecodeErrorZPtr { 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` -/// 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` +/// Creates a new CResult_FundingInfoDecodeErrorZ 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_FundingInfoDecodeErrorZ_clone(orig: &CResult_FundingInfoDecodeErrorZ) -> CResult_FundingInfoDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_COption_HTLCDestinationZDecodeErrorZ -pub union CResult_COption_HTLCDestinationZDecodeErrorZPtr { +/// 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::c_types::derived::COption_HTLCDestinationZ, + 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_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_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_COption_HTLCDestinationZDecodeErrorZ { - /// The contents of this CResult_COption_HTLCDestinationZDecodeErrorZ, 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_COption_HTLCDestinationZDecodeErrorZPtr, - /// Whether this CResult_COption_HTLCDestinationZDecodeErrorZ 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_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_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_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_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, @@ -23627,13 +24125,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_PaymentPurposeDecodeErrorZ_is_ok(o: &CResult_PaymentPurposeDecodeErrorZ) -> 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_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() } { @@ -23646,16 +24144,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_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_COption_HTLCDestinationZDecodeErrorZPtr { result } + CResult_PaymentPurposeDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_COption_HTLCDestinationZDecodeErrorZPtr { err } + CResult_PaymentPurposeDecodeErrorZPtr { err } }; Self { contents, @@ -23663,59 +24161,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_PaymentPurposeDecodeErrorZPtr { + 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_PaymentPurposeDecodeErrorZPtr { 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_PaymentPurposeDecodeErrorZ 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_PaymentPurposeDecodeErrorZ_clone(orig: &CResult_PaymentPurposeDecodeErrorZ) -> CResult_PaymentPurposeDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_PaymentFailureReasonDecodeErrorZ -pub union CResult_PaymentFailureReasonDecodeErrorZPtr { +/// The contents of CResult_ClaimedHTLCDecodeErrorZ +pub union CResult_ClaimedHTLCDecodeErrorZPtr { /// 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::events::ClaimedHTLC, /// 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_ClaimedHTLCDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::events::ClaimedHTLC 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_ClaimedHTLCDecodeErrorZ { + /// The contents of this CResult_ClaimedHTLCDecodeErrorZ, 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_ClaimedHTLCDecodeErrorZPtr, + /// Whether this CResult_ClaimedHTLCDecodeErrorZ 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_ClaimedHTLCDecodeErrorZ in the success state. +pub extern "C" fn CResult_ClaimedHTLCDecodeErrorZ_ok(o: crate::lightning::events::ClaimedHTLC) -> CResult_ClaimedHTLCDecodeErrorZ { + CResult_ClaimedHTLCDecodeErrorZ { + contents: CResult_ClaimedHTLCDecodeErrorZPtr { 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_ClaimedHTLCDecodeErrorZ in the error state. +pub extern "C" fn CResult_ClaimedHTLCDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ClaimedHTLCDecodeErrorZ { + CResult_ClaimedHTLCDecodeErrorZ { + contents: CResult_ClaimedHTLCDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -23723,13 +24221,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_ClaimedHTLCDecodeErrorZ_is_ok(o: &CResult_ClaimedHTLCDecodeErrorZ) -> 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_ClaimedHTLCDecodeErrorZ. +pub extern "C" fn CResult_ClaimedHTLCDecodeErrorZ_free(_res: CResult_ClaimedHTLCDecodeErrorZ) { } +impl Drop for CResult_ClaimedHTLCDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -23742,16 +24240,16 @@ impl Drop for CResult_PaymentFailureReasonDecodeErrorZ { } } } -impl From> for CResult_PaymentFailureReasonDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ClaimedHTLCDecodeErrorZ { + 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_ClaimedHTLCDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_PaymentFailureReasonDecodeErrorZPtr { err } + CResult_ClaimedHTLCDecodeErrorZPtr { err } }; Self { contents, @@ -23759,216 +24257,229 @@ 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_ClaimedHTLCDecodeErrorZPtr { + 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_ClaimedHTLCDecodeErrorZPtr { 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_ClaimedHTLCDecodeErrorZ 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_ClaimedHTLCDecodeErrorZ_clone(orig: &CResult_ClaimedHTLCDecodeErrorZ) -> CResult_ClaimedHTLCDecodeErrorZ { 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 +/// 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_U128Z { +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::c_types::U128 { + #[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_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) +/// 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_U128Z containing nothing -pub extern "C" fn COption_U128Z_none() -> COption_U128Z { - COption_U128Z::None +/// 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::c_types::U128, if we are in the Some state -pub extern "C" fn COption_U128Z_free(_res: COption_U128Z) { } +/// 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_U128Z 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. -pub extern "C" fn COption_U128Z_clone(orig: &COption_U128Z) -> COption_U128Z { Clone::clone(&orig) } +pub extern "C" fn COption_PathFailureZ_clone(orig: &COption_PathFailureZ) -> COption_PathFailureZ { Clone::clone(&orig) } #[repr(C)] -/// A dynamically-allocated array of crate::lightning::events::ClaimedHTLCs of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_ClaimedHTLCZ { - /// 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::ClaimedHTLC, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_ClaimedHTLCZ { - #[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::ClaimedHTLC] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } +/// 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::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, } -impl From> for CVec_ClaimedHTLCZ { - 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_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_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_COption_PathFailureZDecodeErrorZPtr, + /// Whether this CResult_COption_PathFailureZDecodeErrorZ 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_ClaimedHTLCZ_free(_res: CVec_ClaimedHTLCZ) { } -impl Drop for CVec_ClaimedHTLCZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; +/// 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, } } -impl Clone for CVec_ClaimedHTLCZ { - 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] +/// 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, } } -#[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 +/// 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 { + o.result_ok } -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] +/// 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() } { + 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] -/// 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) +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_COption_PathFailureZDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_COption_PathFailureZDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } } -#[no_mangle] -/// Constructs a new COption_PaymentFailureReasonZ containing nothing -pub extern "C" fn COption_PaymentFailureReasonZ_none() -> COption_PaymentFailureReasonZ { - COption_PaymentFailureReasonZ::None +impl Clone for CResult_COption_PathFailureZDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + 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_COption_PathFailureZDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } } #[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` +/// 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 COption_PaymentFailureReasonZ_clone(orig: &COption_PaymentFailureReasonZ) -> COption_PaymentFailureReasonZ { Clone::clone(&orig) } +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::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 +/// 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_EventZ { +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::Event { + #[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_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) +/// 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_EventZ containing nothing -pub extern "C" fn COption_EventZ_none() -> COption_EventZ { - COption_EventZ::None +/// 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::Event, if we are in the Some state -pub extern "C" fn COption_EventZ_free(_res: COption_EventZ) { } +/// 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_EventZ which has the same data as `orig` +/// 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_EventZ_clone(orig: &COption_EventZ) -> COption_EventZ { Clone::clone(&orig) } +pub extern "C" fn COption_ClosureReasonZ_clone(orig: &COption_ClosureReasonZ) -> COption_ClosureReasonZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_COption_EventZDecodeErrorZ -pub union CResult_COption_EventZDecodeErrorZPtr { +/// 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::c_types::derived::COption_EventZ, + 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_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_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_COption_EventZDecodeErrorZ { - /// The contents of this CResult_COption_EventZDecodeErrorZ, 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_COption_EventZDecodeErrorZPtr, - /// Whether this CResult_COption_EventZDecodeErrorZ 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_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_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_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_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, @@ -23976,13 +24487,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_COption_ClosureReasonZDecodeErrorZ_is_ok(o: &CResult_COption_ClosureReasonZDecodeErrorZ) -> 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_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() } { @@ -23995,16 +24506,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_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_COption_EventZDecodeErrorZPtr { result } + CResult_COption_ClosureReasonZDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_COption_EventZDecodeErrorZPtr { err } + CResult_COption_ClosureReasonZDecodeErrorZPtr { err } }; Self { contents, @@ -24012,59 +24523,1347 @@ 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_COption_ClosureReasonZDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_COption_EventZDecodeErrorZPtr { + 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_COption_EventZDecodeErrorZ 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_EventZDecodeErrorZ_clone(orig: &CResult_COption_EventZDecodeErrorZ) -> CResult_COption_EventZDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_COption_ClosureReasonZDecodeErrorZ_clone(orig: &CResult_COption_ClosureReasonZDecodeErrorZ) -> CResult_COption_ClosureReasonZDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_SiPrefixBolt11ParseErrorZ -pub union CResult_SiPrefixBolt11ParseErrorZPtr { +#[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 COption_HTLCDestinationZ_clone(orig: &COption_HTLCDestinationZ) -> COption_HTLCDestinationZ { Clone::clone(&orig) } +#[repr(C)] +/// 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_invoice::SiPrefix, + 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_invoice::Bolt11ParseError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(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. +/// 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_SiPrefixBolt11ParseErrorZ { - /// The contents of this CResult_SiPrefixBolt11ParseErrorZ, 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_COption_HTLCDestinationZDecodeErrorZPtr, + /// Whether this CResult_COption_HTLCDestinationZDecodeErrorZ 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 { + 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 { + 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_HTLCDestinationZDecodeErrorZ_is_ok(o: &CResult_COption_HTLCDestinationZDecodeErrorZ) -> 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 { + 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_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_COption_HTLCDestinationZDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_COption_HTLCDestinationZDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_COption_HTLCDestinationZDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + 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_COption_HTLCDestinationZDecodeErrorZPtr { + 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` +/// 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) } +#[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)] +/// The contents of CResult_COption_PaymentFailureReasonZDecodeErrorZ +pub union CResult_COption_PaymentFailureReasonZDecodeErrorZPtr { + /// 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_PaymentFailureReasonZ, + /// 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_PaymentFailureReasonZDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::COption_PaymentFailureReasonZ 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_PaymentFailureReasonZDecodeErrorZ { + /// The contents of this CResult_COption_PaymentFailureReasonZDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_COption_PaymentFailureReasonZDecodeErrorZPtr, + /// Whether this CResult_COption_PaymentFailureReasonZDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_COption_PaymentFailureReasonZDecodeErrorZ in the success state. +pub extern "C" fn CResult_COption_PaymentFailureReasonZDecodeErrorZ_ok(o: crate::c_types::derived::COption_PaymentFailureReasonZ) -> CResult_COption_PaymentFailureReasonZDecodeErrorZ { + CResult_COption_PaymentFailureReasonZDecodeErrorZ { + contents: CResult_COption_PaymentFailureReasonZDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_COption_PaymentFailureReasonZDecodeErrorZ in the error state. +pub extern "C" fn CResult_COption_PaymentFailureReasonZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_COption_PaymentFailureReasonZDecodeErrorZ { + CResult_COption_PaymentFailureReasonZDecodeErrorZ { + contents: CResult_COption_PaymentFailureReasonZDecodeErrorZPtr { + 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_PaymentFailureReasonZDecodeErrorZ_is_ok(o: &CResult_COption_PaymentFailureReasonZDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_COption_PaymentFailureReasonZDecodeErrorZ. +pub extern "C" fn CResult_COption_PaymentFailureReasonZDecodeErrorZ_free(_res: CResult_COption_PaymentFailureReasonZDecodeErrorZ) { } +impl Drop for CResult_COption_PaymentFailureReasonZDecodeErrorZ { + 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_PaymentFailureReasonZDecodeErrorZ { + 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_PaymentFailureReasonZDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_COption_PaymentFailureReasonZDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_COption_PaymentFailureReasonZDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_COption_PaymentFailureReasonZDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_COption_PaymentFailureReasonZDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_COption_PaymentFailureReasonZDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_COption_PaymentFailureReasonZDecodeErrorZ_clone(orig: &CResult_COption_PaymentFailureReasonZDecodeErrorZ) -> CResult_COption_PaymentFailureReasonZDecodeErrorZ { 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)] +/// A dynamically-allocated array of crate::lightning::events::ClaimedHTLCs of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_ClaimedHTLCZ { + /// 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::ClaimedHTLC, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_ClaimedHTLCZ { + #[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::ClaimedHTLC] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_ClaimedHTLCZ { + 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_ClaimedHTLCZ_free(_res: CVec_ClaimedHTLCZ) { } +impl Drop for CVec_ClaimedHTLCZ { + 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_ClaimedHTLCZ { + 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 { + /// 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, + /// 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_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_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_COption_EventZDecodeErrorZPtr, + /// Whether this CResult_COption_EventZDecodeErrorZ 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 { + 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 { + 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_EventZDecodeErrorZ_is_ok(o: &CResult_COption_EventZDecodeErrorZ) -> 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 { + 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_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_COption_EventZDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_COption_EventZDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_COption_EventZDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + 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_COption_EventZDecodeErrorZPtr { + 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` +/// 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)] +/// The contents of CResult_NonceDecodeErrorZ +pub union CResult_NonceDecodeErrorZPtr { + /// 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::nonce::Nonce, + /// 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_NonceDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::offers::nonce::Nonce 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_NonceDecodeErrorZ { + /// The contents of this CResult_NonceDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_NonceDecodeErrorZPtr, + /// Whether this CResult_NonceDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_NonceDecodeErrorZ in the success state. +pub extern "C" fn CResult_NonceDecodeErrorZ_ok(o: crate::lightning::offers::nonce::Nonce) -> CResult_NonceDecodeErrorZ { + CResult_NonceDecodeErrorZ { + contents: CResult_NonceDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_NonceDecodeErrorZ in the error state. +pub extern "C" fn CResult_NonceDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_NonceDecodeErrorZ { + CResult_NonceDecodeErrorZ { + contents: CResult_NonceDecodeErrorZPtr { + 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_NonceDecodeErrorZ_is_ok(o: &CResult_NonceDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_NonceDecodeErrorZ. +pub extern "C" fn CResult_NonceDecodeErrorZ_free(_res: CResult_NonceDecodeErrorZ) { } +impl Drop for CResult_NonceDecodeErrorZ { + 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_NonceDecodeErrorZ { + 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_NonceDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_NonceDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_NonceDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_NonceDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_NonceDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_NonceDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_NonceDecodeErrorZ_clone(orig: &CResult_NonceDecodeErrorZ) -> CResult_NonceDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// A dynamically-allocated array of crate::lightning_types::routing::RouteHintHops of arbitrary size. +/// This corresponds to std::vector in C++ +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::lightning_types::routing::RouteHintHop, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +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::lightning_types::routing::RouteHintHop] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +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() } } + } +} +#[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 { + 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 { + 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_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_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_invoice::Bolt11ParseError, +} +#[repr(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`. +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_SiPrefixBolt11ParseErrorZPtr, + /// Whether this CResult_SiPrefixBolt11ParseErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// 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_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, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_SiPrefixBolt11ParseErrorZ_is_ok(o: &CResult_SiPrefixBolt11ParseErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// 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() } { + 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_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_SiPrefixBolt11ParseErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_SiPrefixBolt11ParseErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_SiPrefixBolt11ParseErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + 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_SiPrefixBolt11ParseErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// 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_SiPrefixBolt11ParseErrorZ_clone(orig: &CResult_SiPrefixBolt11ParseErrorZ) -> CResult_SiPrefixBolt11ParseErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// 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_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_invoice::ParseOrSemanticError, +} +#[repr(C)] +/// 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_Bolt11InvoiceParseOrSemanticErrorZ { + /// The contents of this CResult_Bolt11InvoiceParseOrSemanticErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_Bolt11InvoiceParseOrSemanticErrorZPtr, + /// Whether this CResult_Bolt11InvoiceParseOrSemanticErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// 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_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, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_Bolt11InvoiceParseOrSemanticErrorZ_is_ok(o: &CResult_Bolt11InvoiceParseOrSemanticErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// 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() } { + 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_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_Bolt11InvoiceParseOrSemanticErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_Bolt11InvoiceParseOrSemanticErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_Bolt11InvoiceParseOrSemanticErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + 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_Bolt11InvoiceParseOrSemanticErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// 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_Bolt11InvoiceParseOrSemanticErrorZ_clone(orig: &CResult_Bolt11InvoiceParseOrSemanticErrorZ) -> CResult_Bolt11InvoiceParseOrSemanticErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// 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_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_invoice::Bolt11ParseError, +} +#[repr(C)] +/// 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_SignedRawBolt11InvoiceBolt11ParseErrorZ { + /// The contents of this CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_SignedRawBolt11InvoiceBolt11ParseErrorZPtr, + /// Whether this CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ represents a success state. + pub result_ok: bool, +} +#[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_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, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_is_ok(o: &CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// 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() } { + 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_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_SignedRawBolt11InvoiceBolt11ParseErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_SignedRawBolt11InvoiceBolt11ParseErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + 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_SignedRawBolt11InvoiceBolt11ParseErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// 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_SignedRawBolt11InvoiceBolt11ParseErrorZ_clone(orig: &CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ) -> CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// 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_PayeePubKeySecp256k1ErrorZ +pub union CResult_PayeePubKeySecp256k1ErrorZPtr { + /// 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, + /// 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, +} +#[repr(C)] +/// A CResult_PayeePubKeySecp256k1ErrorZ 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_PayeePubKeySecp256k1ErrorZ { + /// The contents of this CResult_PayeePubKeySecp256k1ErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_PayeePubKeySecp256k1ErrorZPtr, + /// Whether this CResult_PayeePubKeySecp256k1ErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_PayeePubKeySecp256k1ErrorZ in the success state. +pub extern "C" fn CResult_PayeePubKeySecp256k1ErrorZ_ok(o: crate::lightning_invoice::PayeePubKey) -> CResult_PayeePubKeySecp256k1ErrorZ { + CResult_PayeePubKeySecp256k1ErrorZ { + contents: CResult_PayeePubKeySecp256k1ErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_PayeePubKeySecp256k1ErrorZ in the error state. +pub extern "C" fn CResult_PayeePubKeySecp256k1ErrorZ_err(e: crate::c_types::Secp256k1Error) -> CResult_PayeePubKeySecp256k1ErrorZ { + CResult_PayeePubKeySecp256k1ErrorZ { + contents: CResult_PayeePubKeySecp256k1ErrorZPtr { + 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_PayeePubKeySecp256k1ErrorZ_is_ok(o: &CResult_PayeePubKeySecp256k1ErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_PayeePubKeySecp256k1ErrorZ. +pub extern "C" fn CResult_PayeePubKeySecp256k1ErrorZ_free(_res: CResult_PayeePubKeySecp256k1ErrorZ) { } +impl Drop for CResult_PayeePubKeySecp256k1ErrorZ { + 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_PayeePubKeySecp256k1ErrorZ { + 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_PayeePubKeySecp256k1ErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_PayeePubKeySecp256k1ErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_PayeePubKeySecp256k1ErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_PayeePubKeySecp256k1ErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_PayeePubKeySecp256k1ErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_PayeePubKeySecp256k1ErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_PayeePubKeySecp256k1ErrorZ_clone(orig: &CResult_PayeePubKeySecp256k1ErrorZ) -> CResult_PayeePubKeySecp256k1ErrorZ { 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) + } +} +#[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_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_invoice::CreationError, +} +#[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. +/// `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 + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_PositiveTimestampCreationErrorZPtr, + /// Whether this CResult_PositiveTimestampCreationErrorZ 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 { + 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 { + 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_PositiveTimestampCreationErrorZ_is_ok(o: &CResult_PositiveTimestampCreationErrorZ) -> 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 { + 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_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_PositiveTimestampCreationErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_PositiveTimestampCreationErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_PositiveTimestampCreationErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + 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_PositiveTimestampCreationErrorZPtr { + 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` +/// 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) } +#[repr(C)] +/// 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_invoice::Bolt11SemanticError, +} +#[repr(C)] +/// 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_NoneBolt11SemanticErrorZ { + /// The contents of this CResult_NoneBolt11SemanticErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_NoneBolt11SemanticErrorZPtr, + /// Whether this CResult_NoneBolt11SemanticErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// 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_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, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_NoneBolt11SemanticErrorZ_is_ok(o: &CResult_NoneBolt11SemanticErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// 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 { + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +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 _ = 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_NoneBolt11SemanticErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_NoneBolt11SemanticErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_NoneBolt11SemanticErrorZPtr { + result: core::ptr::null_mut() + } } + } else { + Self { result_ok: false, contents: CResult_NoneBolt11SemanticErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// 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_NoneBolt11SemanticErrorZ_clone(orig: &CResult_NoneBolt11SemanticErrorZ) -> CResult_NoneBolt11SemanticErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// 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_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_invoice::Bolt11SemanticError, +} +#[repr(C)] +/// 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_Bolt11InvoiceBolt11SemanticErrorZ { + /// The contents of this CResult_Bolt11InvoiceBolt11SemanticErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_SiPrefixBolt11ParseErrorZPtr, - /// Whether this CResult_SiPrefixBolt11ParseErrorZ 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_SiPrefixBolt11ParseErrorZ in the success state. -pub extern "C" fn CResult_SiPrefixBolt11ParseErrorZ_ok(o: crate::lightning_invoice::SiPrefix) -> CResult_SiPrefixBolt11ParseErrorZ { - CResult_SiPrefixBolt11ParseErrorZ { - contents: CResult_SiPrefixBolt11ParseErrorZPtr { +/// 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_SiPrefixBolt11ParseErrorZ in the error state. -pub extern "C" fn CResult_SiPrefixBolt11ParseErrorZ_err(e: crate::lightning_invoice::Bolt11ParseError) -> CResult_SiPrefixBolt11ParseErrorZ { - CResult_SiPrefixBolt11ParseErrorZ { - contents: CResult_SiPrefixBolt11ParseErrorZPtr { +/// 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, @@ -24072,13 +25871,13 @@ pub extern "C" fn CResult_SiPrefixBolt11ParseErrorZ_err(e: crate::lightning_invo } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_SiPrefixBolt11ParseErrorZ_is_ok(o: &CResult_SiPrefixBolt11ParseErrorZ) -> 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_SiPrefixBolt11ParseErrorZ. -pub extern "C" fn CResult_SiPrefixBolt11ParseErrorZ_free(_res: CResult_SiPrefixBolt11ParseErrorZ) { } -impl Drop for CResult_SiPrefixBolt11ParseErrorZ { +/// 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() } { @@ -24091,16 +25890,16 @@ impl Drop for CResult_SiPrefixBolt11ParseErrorZ { } } } -impl From> for CResult_SiPrefixBolt11ParseErrorZ { - 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_SiPrefixBolt11ParseErrorZPtr { result } + CResult_Bolt11InvoiceBolt11SemanticErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_SiPrefixBolt11ParseErrorZPtr { err } + CResult_Bolt11InvoiceBolt11SemanticErrorZPtr { err } }; Self { contents, @@ -24108,59 +25907,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_SiPrefixBolt11ParseErrorZPtr { - 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_SiPrefixBolt11ParseErrorZPtr { - 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_SiPrefixBolt11ParseErrorZ 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_SiPrefixBolt11ParseErrorZ_clone(orig: &CResult_SiPrefixBolt11ParseErrorZ) -> CResult_SiPrefixBolt11ParseErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_Bolt11InvoiceBolt11SemanticErrorZ_clone(orig: &CResult_Bolt11InvoiceBolt11SemanticErrorZ) -> CResult_Bolt11InvoiceBolt11SemanticErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_Bolt11InvoiceParseOrSemanticErrorZ -pub union CResult_Bolt11InvoiceParseOrSemanticErrorZPtr { +/// 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_invoice::Bolt11Invoice, + 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_invoice::ParseOrSemanticError, + pub err: *mut crate::lightning_invoice::CreationError, } #[repr(C)] -/// 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. +/// 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_Bolt11InvoiceParseOrSemanticErrorZ { - /// The contents of this CResult_Bolt11InvoiceParseOrSemanticErrorZ, 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_Bolt11InvoiceParseOrSemanticErrorZPtr, - /// Whether this CResult_Bolt11InvoiceParseOrSemanticErrorZ 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_Bolt11InvoiceParseOrSemanticErrorZ in the success state. -pub extern "C" fn CResult_Bolt11InvoiceParseOrSemanticErrorZ_ok(o: crate::lightning_invoice::Bolt11Invoice) -> CResult_Bolt11InvoiceParseOrSemanticErrorZ { - CResult_Bolt11InvoiceParseOrSemanticErrorZ { - contents: CResult_Bolt11InvoiceParseOrSemanticErrorZPtr { +/// 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_Bolt11InvoiceParseOrSemanticErrorZ in the error state. -pub extern "C" fn CResult_Bolt11InvoiceParseOrSemanticErrorZ_err(e: crate::lightning_invoice::ParseOrSemanticError) -> CResult_Bolt11InvoiceParseOrSemanticErrorZ { - CResult_Bolt11InvoiceParseOrSemanticErrorZ { - contents: CResult_Bolt11InvoiceParseOrSemanticErrorZPtr { +/// 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, @@ -24168,13 +25967,13 @@ pub extern "C" fn CResult_Bolt11InvoiceParseOrSemanticErrorZ_err(e: crate::light } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_Bolt11InvoiceParseOrSemanticErrorZ_is_ok(o: &CResult_Bolt11InvoiceParseOrSemanticErrorZ) -> 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_Bolt11InvoiceParseOrSemanticErrorZ. -pub extern "C" fn CResult_Bolt11InvoiceParseOrSemanticErrorZ_free(_res: CResult_Bolt11InvoiceParseOrSemanticErrorZ) { } -impl Drop for CResult_Bolt11InvoiceParseOrSemanticErrorZ { +/// 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() } { @@ -24187,16 +25986,16 @@ impl Drop for CResult_Bolt11InvoiceParseOrSemanticErrorZ { } } } -impl From> for CResult_Bolt11InvoiceParseOrSemanticErrorZ { - 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_Bolt11InvoiceParseOrSemanticErrorZPtr { result } + CResult_DescriptionCreationErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_Bolt11InvoiceParseOrSemanticErrorZPtr { err } + CResult_DescriptionCreationErrorZPtr { err } }; Self { contents, @@ -24204,59 +26003,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_Bolt11InvoiceParseOrSemanticErrorZPtr { - 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_Bolt11InvoiceParseOrSemanticErrorZPtr { - 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_Bolt11InvoiceParseOrSemanticErrorZ 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_Bolt11InvoiceParseOrSemanticErrorZ_clone(orig: &CResult_Bolt11InvoiceParseOrSemanticErrorZ) -> CResult_Bolt11InvoiceParseOrSemanticErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_DescriptionCreationErrorZ_clone(orig: &CResult_DescriptionCreationErrorZ) -> CResult_DescriptionCreationErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ -pub union CResult_SignedRawBolt11InvoiceBolt11ParseErrorZPtr { +/// 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_invoice::SignedRawBolt11Invoice, + 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::Bolt11ParseError, + pub err: *mut crate::lightning_invoice::CreationError, } #[repr(C)] -/// 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. +/// 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_SignedRawBolt11InvoiceBolt11ParseErrorZ { - /// The contents of this CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ, 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_SignedRawBolt11InvoiceBolt11ParseErrorZPtr, - /// Whether this CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ 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_SignedRawBolt11InvoiceBolt11ParseErrorZ in the success state. -pub extern "C" fn CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_ok(o: crate::lightning_invoice::SignedRawBolt11Invoice) -> CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ { - CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ { - contents: CResult_SignedRawBolt11InvoiceBolt11ParseErrorZPtr { +/// 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_SignedRawBolt11InvoiceBolt11ParseErrorZ in the error state. -pub extern "C" fn CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_err(e: crate::lightning_invoice::Bolt11ParseError) -> CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ { - CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ { - contents: CResult_SignedRawBolt11InvoiceBolt11ParseErrorZPtr { +/// 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, @@ -24264,13 +26063,13 @@ pub extern "C" fn CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_err(e: crate:: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_is_ok(o: &CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ) -> 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_SignedRawBolt11InvoiceBolt11ParseErrorZ. -pub extern "C" fn CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_free(_res: CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ) { } -impl Drop for CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ { +/// 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() } { @@ -24283,16 +26082,16 @@ impl Drop for CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ { } } } -impl From> for CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ { - 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_SignedRawBolt11InvoiceBolt11ParseErrorZPtr { result } + CResult_PrivateRouteCreationErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_SignedRawBolt11InvoiceBolt11ParseErrorZPtr { err } + CResult_PrivateRouteCreationErrorZPtr { err } }; Self { contents, @@ -24300,105 +26099,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_SignedRawBolt11InvoiceBolt11ParseErrorZPtr { - 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_SignedRawBolt11InvoiceBolt11ParseErrorZPtr { - 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_SignedRawBolt11InvoiceBolt11ParseErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_clone(orig: &CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ) -> CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// 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` +/// 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 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) { } +pub extern "C" fn CResult_PrivateRouteCreationErrorZ_clone(orig: &CResult_PrivateRouteCreationErrorZ) -> CResult_PrivateRouteCreationErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_PayeePubKeySecp256k1ErrorZ -pub union CResult_PayeePubKeySecp256k1ErrorZPtr { +/// 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_invoice::PayeePubKey, + 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::c_types::Secp256k1Error, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_PayeePubKeySecp256k1ErrorZ 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_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_PayeePubKeySecp256k1ErrorZ { - /// The contents of this CResult_PayeePubKeySecp256k1ErrorZ, 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_PayeePubKeySecp256k1ErrorZPtr, - /// Whether this CResult_PayeePubKeySecp256k1ErrorZ 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_PayeePubKeySecp256k1ErrorZ in the success state. -pub extern "C" fn CResult_PayeePubKeySecp256k1ErrorZ_ok(o: crate::lightning_invoice::PayeePubKey) -> CResult_PayeePubKeySecp256k1ErrorZ { - CResult_PayeePubKeySecp256k1ErrorZ { - contents: CResult_PayeePubKeySecp256k1ErrorZPtr { +/// 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_PayeePubKeySecp256k1ErrorZ in the error state. -pub extern "C" fn CResult_PayeePubKeySecp256k1ErrorZ_err(e: crate::c_types::Secp256k1Error) -> CResult_PayeePubKeySecp256k1ErrorZ { - CResult_PayeePubKeySecp256k1ErrorZ { - contents: CResult_PayeePubKeySecp256k1ErrorZPtr { +/// 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, @@ -24406,13 +26159,13 @@ pub extern "C" fn CResult_PayeePubKeySecp256k1ErrorZ_err(e: crate::c_types::Secp } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_PayeePubKeySecp256k1ErrorZ_is_ok(o: &CResult_PayeePubKeySecp256k1ErrorZ) -> 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_PayeePubKeySecp256k1ErrorZ. -pub extern "C" fn CResult_PayeePubKeySecp256k1ErrorZ_free(_res: CResult_PayeePubKeySecp256k1ErrorZ) { } -impl Drop for CResult_PayeePubKeySecp256k1ErrorZ { +/// 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() } { @@ -24425,16 +26178,16 @@ impl Drop for CResult_PayeePubKeySecp256k1ErrorZ { } } } -impl From> for CResult_PayeePubKeySecp256k1ErrorZ { - 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_PayeePubKeySecp256k1ErrorZPtr { result } + CResult_OutPointDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_PayeePubKeySecp256k1ErrorZPtr { err } + CResult_OutPointDecodeErrorZPtr { err } }; Self { contents, @@ -24442,105 +26195,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_PayeePubKeySecp256k1ErrorZPtr { - 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_PayeePubKeySecp256k1ErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_OutPointDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_PayeePubKeySecp256k1ErrorZ 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_PayeePubKeySecp256k1ErrorZ_clone(orig: &CResult_PayeePubKeySecp256k1ErrorZ) -> CResult_PayeePubKeySecp256k1ErrorZ { 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_OutPointDecodeErrorZ_clone(orig: &CResult_OutPointDecodeErrorZ) -> CResult_OutPointDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_PositiveTimestampCreationErrorZ -pub union CResult_PositiveTimestampCreationErrorZPtr { +/// 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_invoice::PositiveTimestamp, + 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_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_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_PositiveTimestampCreationErrorZ { - /// The contents of this CResult_PositiveTimestampCreationErrorZ, 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_PositiveTimestampCreationErrorZPtr, - /// Whether this CResult_PositiveTimestampCreationErrorZ 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_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_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_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_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, @@ -24548,13 +26255,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_BigSizeDecodeErrorZ_is_ok(o: &CResult_BigSizeDecodeErrorZ) -> 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_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() } { @@ -24567,16 +26274,16 @@ impl Drop for CResult_PositiveTimestampCreationErrorZ { } } } -impl From> for CResult_PositiveTimestampCreationErrorZ { - 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_PositiveTimestampCreationErrorZPtr { result } + CResult_BigSizeDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_PositiveTimestampCreationErrorZPtr { err } + CResult_BigSizeDecodeErrorZPtr { err } }; Self { contents, @@ -24584,58 +26291,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_BigSizeDecodeErrorZPtr { + 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_BigSizeDecodeErrorZPtr { + 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_BigSizeDecodeErrorZ 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_BigSizeDecodeErrorZ_clone(orig: &CResult_BigSizeDecodeErrorZ) -> CResult_BigSizeDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// 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, +/// 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_types::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_invoice::Bolt11SemanticError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_NoneBolt11SemanticErrorZ represents the result of a fallible operation, -/// containing a () on success and a crate::lightning_invoice::Bolt11SemanticError on failure. +/// A CResult_UntrustedStringDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning_types::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_NoneBolt11SemanticErrorZ { - /// The contents of this CResult_NoneBolt11SemanticErrorZ, 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_NoneBolt11SemanticErrorZPtr, - /// Whether this CResult_NoneBolt11SemanticErrorZ 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_NoneBolt11SemanticErrorZ in the success state. -pub extern "C" fn CResult_NoneBolt11SemanticErrorZ_ok() -> CResult_NoneBolt11SemanticErrorZ { - CResult_NoneBolt11SemanticErrorZ { - contents: CResult_NoneBolt11SemanticErrorZPtr { - result: core::ptr::null_mut(), +/// Creates a new CResult_UntrustedStringDecodeErrorZ in the success state. +pub extern "C" fn CResult_UntrustedStringDecodeErrorZ_ok(o: crate::lightning_types::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_NoneBolt11SemanticErrorZ in the error state. -pub extern "C" fn CResult_NoneBolt11SemanticErrorZ_err(e: crate::lightning_invoice::Bolt11SemanticError) -> CResult_NoneBolt11SemanticErrorZ { - CResult_NoneBolt11SemanticErrorZ { - contents: CResult_NoneBolt11SemanticErrorZPtr { +/// 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, @@ -24643,15 +26351,18 @@ pub extern "C" fn CResult_NoneBolt11SemanticErrorZ_err(e: crate::lightning_invoi } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_NoneBolt11SemanticErrorZ_is_ok(o: &CResult_NoneBolt11SemanticErrorZ) -> 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_NoneBolt11SemanticErrorZ. -pub extern "C" fn CResult_NoneBolt11SemanticErrorZ_free(_res: CResult_NoneBolt11SemanticErrorZ) { } -impl Drop for CResult_NoneBolt11SemanticErrorZ { +/// 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) }; @@ -24659,16 +26370,16 @@ impl Drop for CResult_NoneBolt11SemanticErrorZ { } } } -impl From> for CResult_NoneBolt11SemanticErrorZ { - fn from(mut o: crate::c_types::CResultTempl<(), crate::lightning_invoice::Bolt11SemanticError>) -> Self { +impl From> for CResult_UntrustedStringDecodeErrorZ { + 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_NoneBolt11SemanticErrorZPtr { result: core::ptr::null_mut() } + 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_NoneBolt11SemanticErrorZPtr { err } + CResult_UntrustedStringDecodeErrorZPtr { err } }; Self { contents, @@ -24676,59 +26387,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_NoneBolt11SemanticErrorZPtr { - result: core::ptr::null_mut() + 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_NoneBolt11SemanticErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_UntrustedStringDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_NoneBolt11SemanticErrorZ 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_NoneBolt11SemanticErrorZ_clone(orig: &CResult_NoneBolt11SemanticErrorZ) -> CResult_NoneBolt11SemanticErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_UntrustedStringDecodeErrorZ_clone(orig: &CResult_UntrustedStringDecodeErrorZ) -> CResult_UntrustedStringDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_Bolt11InvoiceBolt11SemanticErrorZ -pub union CResult_Bolt11InvoiceBolt11SemanticErrorZPtr { +/// 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_invoice::Bolt11Invoice, + 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_invoice::Bolt11SemanticError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// 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. +/// 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_Bolt11InvoiceBolt11SemanticErrorZ { - /// The contents of this CResult_Bolt11InvoiceBolt11SemanticErrorZ, 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_Bolt11InvoiceBolt11SemanticErrorZPtr, - /// Whether this CResult_Bolt11InvoiceBolt11SemanticErrorZ 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_Bolt11InvoiceBolt11SemanticErrorZ in the success state. -pub extern "C" fn CResult_Bolt11InvoiceBolt11SemanticErrorZ_ok(o: crate::lightning_invoice::Bolt11Invoice) -> CResult_Bolt11InvoiceBolt11SemanticErrorZ { - CResult_Bolt11InvoiceBolt11SemanticErrorZ { - contents: CResult_Bolt11InvoiceBolt11SemanticErrorZPtr { +/// 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_Bolt11InvoiceBolt11SemanticErrorZ in the error state. -pub extern "C" fn CResult_Bolt11InvoiceBolt11SemanticErrorZ_err(e: crate::lightning_invoice::Bolt11SemanticError) -> CResult_Bolt11InvoiceBolt11SemanticErrorZ { - CResult_Bolt11InvoiceBolt11SemanticErrorZ { - contents: CResult_Bolt11InvoiceBolt11SemanticErrorZPtr { +} +#[no_mangle] +/// 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, @@ -24736,13 +26447,13 @@ pub extern "C" fn CResult_Bolt11InvoiceBolt11SemanticErrorZ_err(e: crate::lightn } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_Bolt11InvoiceBolt11SemanticErrorZ_is_ok(o: &CResult_Bolt11InvoiceBolt11SemanticErrorZ) -> 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_Bolt11InvoiceBolt11SemanticErrorZ. -pub extern "C" fn CResult_Bolt11InvoiceBolt11SemanticErrorZ_free(_res: CResult_Bolt11InvoiceBolt11SemanticErrorZ) { } -impl Drop for CResult_Bolt11InvoiceBolt11SemanticErrorZ { +/// 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() } { @@ -24755,16 +26466,16 @@ impl Drop for CResult_Bolt11InvoiceBolt11SemanticErrorZ { } } } -impl From> for CResult_Bolt11InvoiceBolt11SemanticErrorZ { - 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_Bolt11InvoiceBolt11SemanticErrorZPtr { result } + CResult_HostnameDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_Bolt11InvoiceBolt11SemanticErrorZPtr { err } + CResult_HostnameDecodeErrorZPtr { err } }; Self { contents, @@ -24772,95 +26483,91 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_Bolt11InvoiceBolt11SemanticErrorZPtr { - 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_Bolt11InvoiceBolt11SemanticErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_HostnameDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_Bolt11InvoiceBolt11SemanticErrorZ 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_Bolt11InvoiceBolt11SemanticErrorZ_clone(orig: &CResult_Bolt11InvoiceBolt11SemanticErrorZ) -> CResult_Bolt11InvoiceBolt11SemanticErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_HostnameDecodeErrorZ_clone(orig: &CResult_HostnameDecodeErrorZ) -> CResult_HostnameDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_DescriptionCreationErrorZ -pub union CResult_DescriptionCreationErrorZPtr { +/// 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_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_invoice::CreationError, + 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_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_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_DescriptionCreationErrorZ { - /// The contents of this CResult_DescriptionCreationErrorZ, 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_DescriptionCreationErrorZPtr, - /// Whether this CResult_DescriptionCreationErrorZ 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_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_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_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)), +/// 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_DescriptionCreationErrorZ_is_ok(o: &CResult_DescriptionCreationErrorZ) -> 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_DescriptionCreationErrorZ. -pub extern "C" fn CResult_DescriptionCreationErrorZ_free(_res: CResult_DescriptionCreationErrorZ) { } -impl Drop for CResult_DescriptionCreationErrorZ { +/// 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_DescriptionCreationErrorZ { - 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_DescriptionCreationErrorZPtr { result } + CResult_TransactionU16LenLimitedNoneZPtr { result } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_DescriptionCreationErrorZPtr { 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, @@ -24868,59 +26575,59 @@ 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_TransactionU16LenLimitedNoneZPtr { + 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_TransactionU16LenLimitedNoneZPtr { + err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_DescriptionCreationErrorZ 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_DescriptionCreationErrorZ_clone(orig: &CResult_DescriptionCreationErrorZ) -> CResult_DescriptionCreationErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_TransactionU16LenLimitedNoneZ_clone(orig: &CResult_TransactionU16LenLimitedNoneZ) -> CResult_TransactionU16LenLimitedNoneZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_PrivateRouteCreationErrorZ -pub union CResult_PrivateRouteCreationErrorZPtr { +/// 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_invoice::PrivateRoute, + 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_invoice::CreationError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[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_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_PrivateRouteCreationErrorZ { - /// The contents of this CResult_PrivateRouteCreationErrorZ, 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_PrivateRouteCreationErrorZPtr, - /// Whether this CResult_PrivateRouteCreationErrorZ 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_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_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_PrivateRouteCreationErrorZ in the error state. -pub extern "C" fn CResult_PrivateRouteCreationErrorZ_err(e: crate::lightning_invoice::CreationError) -> CResult_PrivateRouteCreationErrorZ { - CResult_PrivateRouteCreationErrorZ { - contents: CResult_PrivateRouteCreationErrorZPtr { +/// 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, @@ -24928,13 +26635,13 @@ pub extern "C" fn CResult_PrivateRouteCreationErrorZ_err(e: crate::lightning_inv } /// 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_TransactionU16LenLimitedDecodeErrorZ_is_ok(o: &CResult_TransactionU16LenLimitedDecodeErrorZ) -> 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_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() } { @@ -24947,16 +26654,16 @@ impl Drop for CResult_PrivateRouteCreationErrorZ { } } } -impl From> for CResult_PrivateRouteCreationErrorZ { - 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_PrivateRouteCreationErrorZPtr { result } + CResult_TransactionU16LenLimitedDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_PrivateRouteCreationErrorZPtr { err } + CResult_TransactionU16LenLimitedDecodeErrorZPtr { err } }; Self { contents, @@ -24964,59 +26671,59 @@ 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 }))) + 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_PrivateRouteCreationErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_TransactionU16LenLimitedDecodeErrorZPtr { + 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` +/// 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_PrivateRouteCreationErrorZ_clone(orig: &CResult_PrivateRouteCreationErrorZ) -> CResult_PrivateRouteCreationErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_TransactionU16LenLimitedDecodeErrorZ_clone(orig: &CResult_TransactionU16LenLimitedDecodeErrorZ) -> CResult_TransactionU16LenLimitedDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_OutPointDecodeErrorZ -pub union CResult_OutPointDecodeErrorZPtr { +/// The contents of CResult_ChannelIdDecodeErrorZ +pub union CResult_ChannelIdDecodeErrorZPtr { /// 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, + pub result: *mut crate::lightning::ln::types::ChannelId, /// 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_ChannelIdDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::types::ChannelId 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_ChannelIdDecodeErrorZ { + /// The contents of this CResult_ChannelIdDecodeErrorZ, 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_ChannelIdDecodeErrorZPtr, + /// Whether this CResult_ChannelIdDecodeErrorZ 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_ChannelIdDecodeErrorZ in the success state. +pub extern "C" fn CResult_ChannelIdDecodeErrorZ_ok(o: crate::lightning::ln::types::ChannelId) -> CResult_ChannelIdDecodeErrorZ { + CResult_ChannelIdDecodeErrorZ { + contents: CResult_ChannelIdDecodeErrorZPtr { 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_ChannelIdDecodeErrorZ in the error state. +pub extern "C" fn CResult_ChannelIdDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelIdDecodeErrorZ { + CResult_ChannelIdDecodeErrorZ { + contents: CResult_ChannelIdDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -25024,13 +26731,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_ChannelIdDecodeErrorZ_is_ok(o: &CResult_ChannelIdDecodeErrorZ) -> 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_ChannelIdDecodeErrorZ. +pub extern "C" fn CResult_ChannelIdDecodeErrorZ_free(_res: CResult_ChannelIdDecodeErrorZ) { } +impl Drop for CResult_ChannelIdDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -25043,76 +26750,118 @@ impl Drop for CResult_OutPointDecodeErrorZ { } } } -impl From> for CResult_OutPointDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ChannelIdDecodeErrorZ { + 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_ChannelIdDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_OutPointDecodeErrorZPtr { err } + CResult_ChannelIdDecodeErrorZPtr { err } }; Self { - contents, - result_ok: o.result_ok, + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_ChannelIdDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_ChannelIdDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_ChannelIdDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_ChannelIdDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_ChannelIdDecodeErrorZ_clone(orig: &CResult_ChannelIdDecodeErrorZ) -> CResult_ChannelIdDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple__u832u16Z { + /// The element at position 0 + pub a: crate::c_types::ThirtyTwoBytes, + /// The element at position 1 + pub b: u16, +} +impl From<(crate::c_types::ThirtyTwoBytes, u16)> for C2Tuple__u832u16Z { + fn from (tup: (crate::c_types::ThirtyTwoBytes, u16)) -> Self { + Self { + a: tup.0, + b: tup.1, } } } -impl Clone for CResult_OutPointDecodeErrorZ { +impl C2Tuple__u832u16Z { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoBytes, u16) { + (self.a, self.b) + } +} +impl Clone for C2Tuple__u832u16Z { fn clone(&self) -> 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 }))) - } } + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), } } } #[no_mangle] -/// Creates a new CResult_OutPointDecodeErrorZ 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_OutPointDecodeErrorZ_clone(orig: &CResult_OutPointDecodeErrorZ) -> CResult_OutPointDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn C2Tuple__u832u16Z_clone(orig: &C2Tuple__u832u16Z) -> C2Tuple__u832u16Z { Clone::clone(&orig) } +/// Creates a new C2Tuple__u832u16Z from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple__u832u16Z_new(a: crate::c_types::ThirtyTwoBytes, b: u16) -> C2Tuple__u832u16Z { + C2Tuple__u832u16Z { a, b, } +} + +#[no_mangle] +/// Frees any resources used by the C2Tuple__u832u16Z. +pub extern "C" fn C2Tuple__u832u16Z_free(_res: C2Tuple__u832u16Z) { } #[repr(C)] -/// The contents of CResult_BigSizeDecodeErrorZ -pub union CResult_BigSizeDecodeErrorZPtr { +/// 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::util::ser::BigSize, + pub result: *mut crate::lightning::blinded_path::payment::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_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. +/// A CResult_BlindedPayInfoDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::blinded_path::payment::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_BigSizeDecodeErrorZ { - /// The contents of this CResult_BigSizeDecodeErrorZ, 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_BigSizeDecodeErrorZPtr, - /// Whether this CResult_BigSizeDecodeErrorZ 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_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 { +/// Creates a new CResult_BlindedPayInfoDecodeErrorZ in the success state. +pub extern "C" fn CResult_BlindedPayInfoDecodeErrorZ_ok(o: crate::lightning::blinded_path::payment::BlindedPayInfo) -> CResult_BlindedPayInfoDecodeErrorZ { + CResult_BlindedPayInfoDecodeErrorZ { + contents: CResult_BlindedPayInfoDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// 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 { +/// 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, @@ -25120,13 +26869,13 @@ pub extern "C" fn CResult_BigSizeDecodeErrorZ_err(e: crate::lightning::ln::msgs: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_BigSizeDecodeErrorZ_is_ok(o: &CResult_BigSizeDecodeErrorZ) -> 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_BigSizeDecodeErrorZ. -pub extern "C" fn CResult_BigSizeDecodeErrorZ_free(_res: CResult_BigSizeDecodeErrorZ) { } -impl Drop for CResult_BigSizeDecodeErrorZ { +/// 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() } { @@ -25139,16 +26888,16 @@ impl Drop for CResult_BigSizeDecodeErrorZ { } } } -impl From> for CResult_BigSizeDecodeErrorZ { - 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 result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_BigSizeDecodeErrorZPtr { result } + CResult_BlindedPayInfoDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_BigSizeDecodeErrorZPtr { err } + CResult_BlindedPayInfoDecodeErrorZPtr { err } }; Self { contents, @@ -25156,95 +26905,91 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_BigSizeDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + 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_BigSizeDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_BlindedPayInfoDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_BigSizeDecodeErrorZ 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_BigSizeDecodeErrorZ_clone(orig: &CResult_BigSizeDecodeErrorZ) -> CResult_BigSizeDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_BlindedPayInfoDecodeErrorZ_clone(orig: &CResult_BlindedPayInfoDecodeErrorZ) -> CResult_BlindedPayInfoDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_HostnameDecodeErrorZ -pub union CResult_HostnameDecodeErrorZPtr { +/// The contents of CResult_BlindedPaymentPathNoneZ +pub union CResult_BlindedPaymentPathNoneZPtr { /// 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::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, + pub result: *mut crate::lightning::blinded_path::payment::BlindedPaymentPath, + /// 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_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. +/// A CResult_BlindedPaymentPathNoneZ represents the result of a fallible operation, +/// containing a crate::lightning::blinded_path::payment::BlindedPaymentPath on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_HostnameDecodeErrorZ { - /// The contents of this CResult_HostnameDecodeErrorZ, accessible via either +pub struct CResult_BlindedPaymentPathNoneZ { + /// The contents of this CResult_BlindedPaymentPathNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_HostnameDecodeErrorZPtr, - /// Whether this CResult_HostnameDecodeErrorZ represents a success state. + pub contents: CResult_BlindedPaymentPathNoneZPtr, + /// Whether this CResult_BlindedPaymentPathNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// 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 { +/// Creates a new CResult_BlindedPaymentPathNoneZ in the success state. +pub extern "C" fn CResult_BlindedPaymentPathNoneZ_ok(o: crate::lightning::blinded_path::payment::BlindedPaymentPath) -> CResult_BlindedPaymentPathNoneZ { + CResult_BlindedPaymentPathNoneZ { + contents: CResult_BlindedPaymentPathNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// 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)), +/// Creates a new CResult_BlindedPaymentPathNoneZ in the error state. +pub extern "C" fn CResult_BlindedPaymentPathNoneZ_err() -> CResult_BlindedPaymentPathNoneZ { + CResult_BlindedPaymentPathNoneZ { + contents: CResult_BlindedPaymentPathNoneZPtr { + 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_HostnameDecodeErrorZ_is_ok(o: &CResult_HostnameDecodeErrorZ) -> bool { +pub extern "C" fn CResult_BlindedPaymentPathNoneZ_is_ok(o: &CResult_BlindedPaymentPathNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_HostnameDecodeErrorZ. -pub extern "C" fn CResult_HostnameDecodeErrorZ_free(_res: CResult_HostnameDecodeErrorZ) { } -impl Drop for CResult_HostnameDecodeErrorZ { +/// Frees any resources used by the CResult_BlindedPaymentPathNoneZ. +pub extern "C" fn CResult_BlindedPaymentPathNoneZ_free(_res: CResult_BlindedPaymentPathNoneZ) { } +impl Drop for CResult_BlindedPaymentPathNoneZ { 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_HostnameDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_BlindedPaymentPathNoneZ { + 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_HostnameDecodeErrorZPtr { result } + CResult_BlindedPaymentPathNoneZPtr { result } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_HostnameDecodeErrorZPtr { err } + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_BlindedPaymentPathNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -25252,91 +26997,141 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_HostnameDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_BlindedPaymentPathNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_HostnameDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_BlindedPaymentPathNoneZPtr { + err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_HostnameDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_BlindedPaymentPathNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_HostnameDecodeErrorZ_clone(orig: &CResult_HostnameDecodeErrorZ) -> CResult_HostnameDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_BlindedPaymentPathNoneZ_clone(orig: &CResult_BlindedPaymentPathNoneZ) -> CResult_BlindedPaymentPathNoneZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_TransactionU16LenLimitedNoneZ -pub union CResult_TransactionU16LenLimitedNoneZPtr { +/// A dynamically-allocated array of crate::lightning::blinded_path::payment::PaymentForwardNodes of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_PaymentForwardNodeZ { + /// 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::payment::PaymentForwardNode, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_PaymentForwardNodeZ { + #[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::payment::PaymentForwardNode] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_PaymentForwardNodeZ { + 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_PaymentForwardNodeZ_free(_res: CVec_PaymentForwardNodeZ) { } +impl Drop for CVec_PaymentForwardNodeZ { + 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_PaymentForwardNodeZ { + 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_PaymentRelayDecodeErrorZ +pub union CResult_PaymentRelayDecodeErrorZPtr { /// 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::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, + pub result: *mut crate::lightning::blinded_path::payment::PaymentRelay, + /// 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_TransactionU16LenLimitedNoneZ represents the result of a fallible operation, -/// containing a crate::lightning::util::ser::TransactionU16LenLimited on success and a () on failure. +/// A CResult_PaymentRelayDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::blinded_path::payment::PaymentRelay 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_TransactionU16LenLimitedNoneZ { - /// The contents of this CResult_TransactionU16LenLimitedNoneZ, accessible via either +pub struct CResult_PaymentRelayDecodeErrorZ { + /// The contents of this CResult_PaymentRelayDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_TransactionU16LenLimitedNoneZPtr, - /// Whether this CResult_TransactionU16LenLimitedNoneZ represents a success state. + pub contents: CResult_PaymentRelayDecodeErrorZPtr, + /// Whether this CResult_PaymentRelayDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// 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 { +/// Creates a new CResult_PaymentRelayDecodeErrorZ in the success state. +pub extern "C" fn CResult_PaymentRelayDecodeErrorZ_ok(o: crate::lightning::blinded_path::payment::PaymentRelay) -> CResult_PaymentRelayDecodeErrorZ { + CResult_PaymentRelayDecodeErrorZ { + contents: CResult_PaymentRelayDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// 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(), +/// Creates a new CResult_PaymentRelayDecodeErrorZ in the error state. +pub extern "C" fn CResult_PaymentRelayDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_PaymentRelayDecodeErrorZ { + CResult_PaymentRelayDecodeErrorZ { + contents: CResult_PaymentRelayDecodeErrorZPtr { + 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_TransactionU16LenLimitedNoneZ_is_ok(o: &CResult_TransactionU16LenLimitedNoneZ) -> bool { +pub extern "C" fn CResult_PaymentRelayDecodeErrorZ_is_ok(o: &CResult_PaymentRelayDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_TransactionU16LenLimitedNoneZ. -pub extern "C" fn CResult_TransactionU16LenLimitedNoneZ_free(_res: CResult_TransactionU16LenLimitedNoneZ) { } -impl Drop for CResult_TransactionU16LenLimitedNoneZ { +/// Frees any resources used by the CResult_PaymentRelayDecodeErrorZ. +pub extern "C" fn CResult_PaymentRelayDecodeErrorZ_free(_res: CResult_PaymentRelayDecodeErrorZ) { } +impl Drop for CResult_PaymentRelayDecodeErrorZ { 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_TransactionU16LenLimitedNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_PaymentRelayDecodeErrorZ { + 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_TransactionU16LenLimitedNoneZPtr { result } + CResult_PaymentRelayDecodeErrorZPtr { result } } else { - let _ = unsafe { Box::from_raw(o.contents.err) }; - o.contents.err = core::ptr::null_mut(); - CResult_TransactionU16LenLimitedNoneZPtr { err: core::ptr::null_mut() } + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_PaymentRelayDecodeErrorZPtr { err } }; Self { contents, @@ -25344,59 +27139,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_TransactionU16LenLimitedNoneZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_PaymentRelayDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_TransactionU16LenLimitedNoneZPtr { - err: core::ptr::null_mut() + Self { result_ok: false, contents: CResult_PaymentRelayDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_TransactionU16LenLimitedNoneZ which has the same data as `orig` +/// Creates a new CResult_PaymentRelayDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_TransactionU16LenLimitedNoneZ_clone(orig: &CResult_TransactionU16LenLimitedNoneZ) -> CResult_TransactionU16LenLimitedNoneZ { Clone::clone(&orig) } +pub extern "C" fn CResult_PaymentRelayDecodeErrorZ_clone(orig: &CResult_PaymentRelayDecodeErrorZ) -> CResult_PaymentRelayDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_TransactionU16LenLimitedDecodeErrorZ -pub union CResult_TransactionU16LenLimitedDecodeErrorZPtr { +/// The contents of CResult_PaymentConstraintsDecodeErrorZ +pub union CResult_PaymentConstraintsDecodeErrorZPtr { /// 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::ser::TransactionU16LenLimited, + pub result: *mut crate::lightning::blinded_path::payment::PaymentConstraints, /// 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_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. +/// A CResult_PaymentConstraintsDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::blinded_path::payment::PaymentConstraints 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_TransactionU16LenLimitedDecodeErrorZ { - /// The contents of this CResult_TransactionU16LenLimitedDecodeErrorZ, accessible via either +pub struct CResult_PaymentConstraintsDecodeErrorZ { + /// The contents of this CResult_PaymentConstraintsDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_TransactionU16LenLimitedDecodeErrorZPtr, - /// Whether this CResult_TransactionU16LenLimitedDecodeErrorZ represents a success state. + pub contents: CResult_PaymentConstraintsDecodeErrorZPtr, + /// Whether this CResult_PaymentConstraintsDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// 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 { +/// Creates a new CResult_PaymentConstraintsDecodeErrorZ in the success state. +pub extern "C" fn CResult_PaymentConstraintsDecodeErrorZ_ok(o: crate::lightning::blinded_path::payment::PaymentConstraints) -> CResult_PaymentConstraintsDecodeErrorZ { + CResult_PaymentConstraintsDecodeErrorZ { + contents: CResult_PaymentConstraintsDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// 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 { +/// Creates a new CResult_PaymentConstraintsDecodeErrorZ in the error state. +pub extern "C" fn CResult_PaymentConstraintsDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_PaymentConstraintsDecodeErrorZ { + CResult_PaymentConstraintsDecodeErrorZ { + contents: CResult_PaymentConstraintsDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -25404,13 +27199,13 @@ pub extern "C" fn CResult_TransactionU16LenLimitedDecodeErrorZ_err(e: crate::lig } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_TransactionU16LenLimitedDecodeErrorZ_is_ok(o: &CResult_TransactionU16LenLimitedDecodeErrorZ) -> bool { +pub extern "C" fn CResult_PaymentConstraintsDecodeErrorZ_is_ok(o: &CResult_PaymentConstraintsDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_TransactionU16LenLimitedDecodeErrorZ. -pub extern "C" fn CResult_TransactionU16LenLimitedDecodeErrorZ_free(_res: CResult_TransactionU16LenLimitedDecodeErrorZ) { } -impl Drop for CResult_TransactionU16LenLimitedDecodeErrorZ { +/// Frees any resources used by the CResult_PaymentConstraintsDecodeErrorZ. +pub extern "C" fn CResult_PaymentConstraintsDecodeErrorZ_free(_res: CResult_PaymentConstraintsDecodeErrorZ) { } +impl Drop for CResult_PaymentConstraintsDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -25423,16 +27218,16 @@ impl Drop for CResult_TransactionU16LenLimitedDecodeErrorZ { } } } -impl From> for CResult_TransactionU16LenLimitedDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_PaymentConstraintsDecodeErrorZ { + 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_TransactionU16LenLimitedDecodeErrorZPtr { result } + CResult_PaymentConstraintsDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_TransactionU16LenLimitedDecodeErrorZPtr { err } + CResult_PaymentConstraintsDecodeErrorZPtr { err } }; Self { contents, @@ -25440,59 +27235,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_TransactionU16LenLimitedDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_PaymentConstraintsDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_TransactionU16LenLimitedDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_PaymentConstraintsDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_TransactionU16LenLimitedDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_PaymentConstraintsDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_TransactionU16LenLimitedDecodeErrorZ_clone(orig: &CResult_TransactionU16LenLimitedDecodeErrorZ) -> CResult_TransactionU16LenLimitedDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_PaymentConstraintsDecodeErrorZ_clone(orig: &CResult_PaymentConstraintsDecodeErrorZ) -> CResult_PaymentConstraintsDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_UntrustedStringDecodeErrorZ -pub union CResult_UntrustedStringDecodeErrorZPtr { +/// The contents of CResult_PaymentContextDecodeErrorZ +pub union CResult_PaymentContextDecodeErrorZPtr { /// 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, + pub result: *mut crate::lightning::blinded_path::payment::PaymentContext, /// 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. +/// A CResult_PaymentContextDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::blinded_path::payment::PaymentContext 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 +pub struct CResult_PaymentContextDecodeErrorZ { + /// The contents of this CResult_PaymentContextDecodeErrorZ, 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 contents: CResult_PaymentContextDecodeErrorZPtr, + /// Whether this CResult_PaymentContextDecodeErrorZ 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 { +/// Creates a new CResult_PaymentContextDecodeErrorZ in the success state. +pub extern "C" fn CResult_PaymentContextDecodeErrorZ_ok(o: crate::lightning::blinded_path::payment::PaymentContext) -> CResult_PaymentContextDecodeErrorZ { + CResult_PaymentContextDecodeErrorZ { + contents: CResult_PaymentContextDecodeErrorZPtr { 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 { +/// Creates a new CResult_PaymentContextDecodeErrorZ in the error state. +pub extern "C" fn CResult_PaymentContextDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_PaymentContextDecodeErrorZ { + CResult_PaymentContextDecodeErrorZ { + contents: CResult_PaymentContextDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -25500,13 +27295,13 @@ pub extern "C" fn CResult_UntrustedStringDecodeErrorZ_err(e: crate::lightning::l } /// 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 { +pub extern "C" fn CResult_PaymentContextDecodeErrorZ_is_ok(o: &CResult_PaymentContextDecodeErrorZ) -> 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 { +/// Frees any resources used by the CResult_PaymentContextDecodeErrorZ. +pub extern "C" fn CResult_PaymentContextDecodeErrorZ_free(_res: CResult_PaymentContextDecodeErrorZ) { } +impl Drop for CResult_PaymentContextDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -25519,16 +27314,16 @@ impl Drop for CResult_UntrustedStringDecodeErrorZ { } } } -impl From> for CResult_UntrustedStringDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_PaymentContextDecodeErrorZ { + 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 } + CResult_PaymentContextDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_UntrustedStringDecodeErrorZPtr { err } + CResult_PaymentContextDecodeErrorZPtr { err } }; Self { contents, @@ -25536,59 +27331,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_UntrustedStringDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_PaymentContextDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_UntrustedStringDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_PaymentContextDecodeErrorZPtr { 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` +/// Creates a new CResult_PaymentContextDecodeErrorZ 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) } +pub extern "C" fn CResult_PaymentContextDecodeErrorZ_clone(orig: &CResult_PaymentContextDecodeErrorZ) -> CResult_PaymentContextDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_ChannelIdDecodeErrorZ -pub union CResult_ChannelIdDecodeErrorZPtr { +/// The contents of CResult_UnknownPaymentContextDecodeErrorZ +pub union CResult_UnknownPaymentContextDecodeErrorZPtr { /// 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::types::ChannelId, + pub result: *mut crate::lightning::blinded_path::payment::UnknownPaymentContext, /// 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_ChannelIdDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::types::ChannelId on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_UnknownPaymentContextDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::blinded_path::payment::UnknownPaymentContext 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_ChannelIdDecodeErrorZ { - /// The contents of this CResult_ChannelIdDecodeErrorZ, accessible via either +pub struct CResult_UnknownPaymentContextDecodeErrorZ { + /// The contents of this CResult_UnknownPaymentContextDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ChannelIdDecodeErrorZPtr, - /// Whether this CResult_ChannelIdDecodeErrorZ represents a success state. + pub contents: CResult_UnknownPaymentContextDecodeErrorZPtr, + /// Whether this CResult_UnknownPaymentContextDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ChannelIdDecodeErrorZ in the success state. -pub extern "C" fn CResult_ChannelIdDecodeErrorZ_ok(o: crate::lightning::ln::types::ChannelId) -> CResult_ChannelIdDecodeErrorZ { - CResult_ChannelIdDecodeErrorZ { - contents: CResult_ChannelIdDecodeErrorZPtr { +/// Creates a new CResult_UnknownPaymentContextDecodeErrorZ in the success state. +pub extern "C" fn CResult_UnknownPaymentContextDecodeErrorZ_ok(o: crate::lightning::blinded_path::payment::UnknownPaymentContext) -> CResult_UnknownPaymentContextDecodeErrorZ { + CResult_UnknownPaymentContextDecodeErrorZ { + contents: CResult_UnknownPaymentContextDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ChannelIdDecodeErrorZ in the error state. -pub extern "C" fn CResult_ChannelIdDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelIdDecodeErrorZ { - CResult_ChannelIdDecodeErrorZ { - contents: CResult_ChannelIdDecodeErrorZPtr { +/// Creates a new CResult_UnknownPaymentContextDecodeErrorZ in the error state. +pub extern "C" fn CResult_UnknownPaymentContextDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_UnknownPaymentContextDecodeErrorZ { + CResult_UnknownPaymentContextDecodeErrorZ { + contents: CResult_UnknownPaymentContextDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -25596,13 +27391,13 @@ pub extern "C" fn CResult_ChannelIdDecodeErrorZ_err(e: crate::lightning::ln::msg } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ChannelIdDecodeErrorZ_is_ok(o: &CResult_ChannelIdDecodeErrorZ) -> bool { +pub extern "C" fn CResult_UnknownPaymentContextDecodeErrorZ_is_ok(o: &CResult_UnknownPaymentContextDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_ChannelIdDecodeErrorZ. -pub extern "C" fn CResult_ChannelIdDecodeErrorZ_free(_res: CResult_ChannelIdDecodeErrorZ) { } -impl Drop for CResult_ChannelIdDecodeErrorZ { +/// Frees any resources used by the CResult_UnknownPaymentContextDecodeErrorZ. +pub extern "C" fn CResult_UnknownPaymentContextDecodeErrorZ_free(_res: CResult_UnknownPaymentContextDecodeErrorZ) { } +impl Drop for CResult_UnknownPaymentContextDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -25615,16 +27410,16 @@ impl Drop for CResult_ChannelIdDecodeErrorZ { } } } -impl From> for CResult_ChannelIdDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_UnknownPaymentContextDecodeErrorZ { + 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_ChannelIdDecodeErrorZPtr { result } + CResult_UnknownPaymentContextDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ChannelIdDecodeErrorZPtr { err } + CResult_UnknownPaymentContextDecodeErrorZPtr { err } }; Self { contents, @@ -25632,101 +27427,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ChannelIdDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_UnknownPaymentContextDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_ChannelIdDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_UnknownPaymentContextDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_ChannelIdDecodeErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ChannelIdDecodeErrorZ_clone(orig: &CResult_ChannelIdDecodeErrorZ) -> CResult_ChannelIdDecodeErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple__u832u16Z { - /// The element at position 0 - pub a: crate::c_types::ThirtyTwoBytes, - /// The element at position 1 - pub b: u16, -} -impl From<(crate::c_types::ThirtyTwoBytes, u16)> for C2Tuple__u832u16Z { - fn from (tup: (crate::c_types::ThirtyTwoBytes, u16)) -> Self { - Self { - a: tup.0, - b: tup.1, - } - } -} -impl C2Tuple__u832u16Z { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoBytes, u16) { - (self.a, self.b) - } -} -impl Clone for C2Tuple__u832u16Z { - 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_UnknownPaymentContextDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C2Tuple__u832u16Z_clone(orig: &C2Tuple__u832u16Z) -> C2Tuple__u832u16Z { Clone::clone(&orig) } -/// Creates a new C2Tuple__u832u16Z from the contained elements. -#[no_mangle] -pub extern "C" fn C2Tuple__u832u16Z_new(a: crate::c_types::ThirtyTwoBytes, b: u16) -> C2Tuple__u832u16Z { - C2Tuple__u832u16Z { a, b, } -} - -#[no_mangle] -/// Frees any resources used by the C2Tuple__u832u16Z. -pub extern "C" fn C2Tuple__u832u16Z_free(_res: C2Tuple__u832u16Z) { } +pub extern "C" fn CResult_UnknownPaymentContextDecodeErrorZ_clone(orig: &CResult_UnknownPaymentContextDecodeErrorZ) -> CResult_UnknownPaymentContextDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_PaymentRelayDecodeErrorZ -pub union CResult_PaymentRelayDecodeErrorZPtr { +/// The contents of CResult_Bolt12OfferContextDecodeErrorZ +pub union CResult_Bolt12OfferContextDecodeErrorZPtr { /// 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::payment::PaymentRelay, + pub result: *mut crate::lightning::blinded_path::payment::Bolt12OfferContext, /// 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_PaymentRelayDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::blinded_path::payment::PaymentRelay on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_Bolt12OfferContextDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::blinded_path::payment::Bolt12OfferContext 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_PaymentRelayDecodeErrorZ { - /// The contents of this CResult_PaymentRelayDecodeErrorZ, accessible via either +pub struct CResult_Bolt12OfferContextDecodeErrorZ { + /// The contents of this CResult_Bolt12OfferContextDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_PaymentRelayDecodeErrorZPtr, - /// Whether this CResult_PaymentRelayDecodeErrorZ represents a success state. + pub contents: CResult_Bolt12OfferContextDecodeErrorZPtr, + /// Whether this CResult_Bolt12OfferContextDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_PaymentRelayDecodeErrorZ in the success state. -pub extern "C" fn CResult_PaymentRelayDecodeErrorZ_ok(o: crate::lightning::blinded_path::payment::PaymentRelay) -> CResult_PaymentRelayDecodeErrorZ { - CResult_PaymentRelayDecodeErrorZ { - contents: CResult_PaymentRelayDecodeErrorZPtr { +/// Creates a new CResult_Bolt12OfferContextDecodeErrorZ in the success state. +pub extern "C" fn CResult_Bolt12OfferContextDecodeErrorZ_ok(o: crate::lightning::blinded_path::payment::Bolt12OfferContext) -> CResult_Bolt12OfferContextDecodeErrorZ { + CResult_Bolt12OfferContextDecodeErrorZ { + contents: CResult_Bolt12OfferContextDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_PaymentRelayDecodeErrorZ in the error state. -pub extern "C" fn CResult_PaymentRelayDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_PaymentRelayDecodeErrorZ { - CResult_PaymentRelayDecodeErrorZ { - contents: CResult_PaymentRelayDecodeErrorZPtr { +/// Creates a new CResult_Bolt12OfferContextDecodeErrorZ in the error state. +pub extern "C" fn CResult_Bolt12OfferContextDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_Bolt12OfferContextDecodeErrorZ { + CResult_Bolt12OfferContextDecodeErrorZ { + contents: CResult_Bolt12OfferContextDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -25734,13 +27487,13 @@ pub extern "C" fn CResult_PaymentRelayDecodeErrorZ_err(e: crate::lightning::ln:: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_PaymentRelayDecodeErrorZ_is_ok(o: &CResult_PaymentRelayDecodeErrorZ) -> bool { +pub extern "C" fn CResult_Bolt12OfferContextDecodeErrorZ_is_ok(o: &CResult_Bolt12OfferContextDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_PaymentRelayDecodeErrorZ. -pub extern "C" fn CResult_PaymentRelayDecodeErrorZ_free(_res: CResult_PaymentRelayDecodeErrorZ) { } -impl Drop for CResult_PaymentRelayDecodeErrorZ { +/// Frees any resources used by the CResult_Bolt12OfferContextDecodeErrorZ. +pub extern "C" fn CResult_Bolt12OfferContextDecodeErrorZ_free(_res: CResult_Bolt12OfferContextDecodeErrorZ) { } +impl Drop for CResult_Bolt12OfferContextDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -25753,16 +27506,16 @@ impl Drop for CResult_PaymentRelayDecodeErrorZ { } } } -impl From> for CResult_PaymentRelayDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_Bolt12OfferContextDecodeErrorZ { + 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_PaymentRelayDecodeErrorZPtr { result } + CResult_Bolt12OfferContextDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_PaymentRelayDecodeErrorZPtr { err } + CResult_Bolt12OfferContextDecodeErrorZPtr { err } }; Self { contents, @@ -25770,59 +27523,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_PaymentRelayDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_Bolt12OfferContextDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_PaymentRelayDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_Bolt12OfferContextDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_PaymentRelayDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_Bolt12OfferContextDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_PaymentRelayDecodeErrorZ_clone(orig: &CResult_PaymentRelayDecodeErrorZ) -> CResult_PaymentRelayDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_Bolt12OfferContextDecodeErrorZ_clone(orig: &CResult_Bolt12OfferContextDecodeErrorZ) -> CResult_Bolt12OfferContextDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_PaymentConstraintsDecodeErrorZ -pub union CResult_PaymentConstraintsDecodeErrorZPtr { +/// The contents of CResult_Bolt12RefundContextDecodeErrorZ +pub union CResult_Bolt12RefundContextDecodeErrorZPtr { /// 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::payment::PaymentConstraints, + pub result: *mut crate::lightning::blinded_path::payment::Bolt12RefundContext, /// 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_PaymentConstraintsDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::blinded_path::payment::PaymentConstraints on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_Bolt12RefundContextDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::blinded_path::payment::Bolt12RefundContext 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_PaymentConstraintsDecodeErrorZ { - /// The contents of this CResult_PaymentConstraintsDecodeErrorZ, accessible via either +pub struct CResult_Bolt12RefundContextDecodeErrorZ { + /// The contents of this CResult_Bolt12RefundContextDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_PaymentConstraintsDecodeErrorZPtr, - /// Whether this CResult_PaymentConstraintsDecodeErrorZ represents a success state. + pub contents: CResult_Bolt12RefundContextDecodeErrorZPtr, + /// Whether this CResult_Bolt12RefundContextDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_PaymentConstraintsDecodeErrorZ in the success state. -pub extern "C" fn CResult_PaymentConstraintsDecodeErrorZ_ok(o: crate::lightning::blinded_path::payment::PaymentConstraints) -> CResult_PaymentConstraintsDecodeErrorZ { - CResult_PaymentConstraintsDecodeErrorZ { - contents: CResult_PaymentConstraintsDecodeErrorZPtr { +/// Creates a new CResult_Bolt12RefundContextDecodeErrorZ in the success state. +pub extern "C" fn CResult_Bolt12RefundContextDecodeErrorZ_ok(o: crate::lightning::blinded_path::payment::Bolt12RefundContext) -> CResult_Bolt12RefundContextDecodeErrorZ { + CResult_Bolt12RefundContextDecodeErrorZ { + contents: CResult_Bolt12RefundContextDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_PaymentConstraintsDecodeErrorZ in the error state. -pub extern "C" fn CResult_PaymentConstraintsDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_PaymentConstraintsDecodeErrorZ { - CResult_PaymentConstraintsDecodeErrorZ { - contents: CResult_PaymentConstraintsDecodeErrorZPtr { +/// Creates a new CResult_Bolt12RefundContextDecodeErrorZ in the error state. +pub extern "C" fn CResult_Bolt12RefundContextDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_Bolt12RefundContextDecodeErrorZ { + CResult_Bolt12RefundContextDecodeErrorZ { + contents: CResult_Bolt12RefundContextDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -25830,13 +27583,13 @@ pub extern "C" fn CResult_PaymentConstraintsDecodeErrorZ_err(e: crate::lightning } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_PaymentConstraintsDecodeErrorZ_is_ok(o: &CResult_PaymentConstraintsDecodeErrorZ) -> bool { +pub extern "C" fn CResult_Bolt12RefundContextDecodeErrorZ_is_ok(o: &CResult_Bolt12RefundContextDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_PaymentConstraintsDecodeErrorZ. -pub extern "C" fn CResult_PaymentConstraintsDecodeErrorZ_free(_res: CResult_PaymentConstraintsDecodeErrorZ) { } -impl Drop for CResult_PaymentConstraintsDecodeErrorZ { +/// Frees any resources used by the CResult_Bolt12RefundContextDecodeErrorZ. +pub extern "C" fn CResult_Bolt12RefundContextDecodeErrorZ_free(_res: CResult_Bolt12RefundContextDecodeErrorZ) { } +impl Drop for CResult_Bolt12RefundContextDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -25849,16 +27602,16 @@ impl Drop for CResult_PaymentConstraintsDecodeErrorZ { } } } -impl From> for CResult_PaymentConstraintsDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_Bolt12RefundContextDecodeErrorZ { + 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_PaymentConstraintsDecodeErrorZPtr { result } + CResult_Bolt12RefundContextDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_PaymentConstraintsDecodeErrorZPtr { err } + CResult_Bolt12RefundContextDecodeErrorZPtr { err } }; Self { contents, @@ -25866,59 +27619,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_PaymentConstraintsDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_Bolt12RefundContextDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_PaymentConstraintsDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_Bolt12RefundContextDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_PaymentConstraintsDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_Bolt12RefundContextDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_PaymentConstraintsDecodeErrorZ_clone(orig: &CResult_PaymentConstraintsDecodeErrorZ) -> CResult_PaymentConstraintsDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_Bolt12RefundContextDecodeErrorZ_clone(orig: &CResult_Bolt12RefundContextDecodeErrorZ) -> CResult_Bolt12RefundContextDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_PaymentContextDecodeErrorZ -pub union CResult_PaymentContextDecodeErrorZPtr { +/// 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::blinded_path::payment::PaymentContext, + 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_PaymentContextDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::blinded_path::payment::PaymentContext 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_PaymentContextDecodeErrorZ { - /// The contents of this CResult_PaymentContextDecodeErrorZ, 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_PaymentContextDecodeErrorZPtr, - /// Whether this CResult_PaymentContextDecodeErrorZ 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_PaymentContextDecodeErrorZ in the success state. -pub extern "C" fn CResult_PaymentContextDecodeErrorZ_ok(o: crate::lightning::blinded_path::payment::PaymentContext) -> CResult_PaymentContextDecodeErrorZ { - CResult_PaymentContextDecodeErrorZ { - contents: CResult_PaymentContextDecodeErrorZPtr { +/// 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_PaymentContextDecodeErrorZ in the error state. -pub extern "C" fn CResult_PaymentContextDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_PaymentContextDecodeErrorZ { - CResult_PaymentContextDecodeErrorZ { - contents: CResult_PaymentContextDecodeErrorZPtr { +/// 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, @@ -25926,13 +27679,13 @@ pub extern "C" fn CResult_PaymentContextDecodeErrorZ_err(e: crate::lightning::ln } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_PaymentContextDecodeErrorZ_is_ok(o: &CResult_PaymentContextDecodeErrorZ) -> 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_PaymentContextDecodeErrorZ. -pub extern "C" fn CResult_PaymentContextDecodeErrorZ_free(_res: CResult_PaymentContextDecodeErrorZ) { } -impl Drop for CResult_PaymentContextDecodeErrorZ { +/// 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() } { @@ -25945,16 +27698,16 @@ impl Drop for CResult_PaymentContextDecodeErrorZ { } } } -impl From> for CResult_PaymentContextDecodeErrorZ { - 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_PaymentContextDecodeErrorZPtr { result } + CResult_TxOutUtxoLookupErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_PaymentContextDecodeErrorZPtr { err } + CResult_TxOutUtxoLookupErrorZPtr { err } }; Self { contents, @@ -25962,59 +27715,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_PaymentContextDecodeErrorZPtr { - 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_PaymentContextDecodeErrorZPtr { - 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_PaymentContextDecodeErrorZ 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_PaymentContextDecodeErrorZ_clone(orig: &CResult_PaymentContextDecodeErrorZ) -> CResult_PaymentContextDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_TxOutUtxoLookupErrorZ_clone(orig: &CResult_TxOutUtxoLookupErrorZ) -> CResult_TxOutUtxoLookupErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_UnknownPaymentContextDecodeErrorZ -pub union CResult_UnknownPaymentContextDecodeErrorZPtr { +/// The contents of CResult_ResponderDecodeErrorZ +pub union CResult_ResponderDecodeErrorZPtr { /// 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::payment::UnknownPaymentContext, + pub result: *mut crate::lightning::onion_message::messenger::Responder, /// 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_UnknownPaymentContextDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::blinded_path::payment::UnknownPaymentContext on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_ResponderDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::onion_message::messenger::Responder 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_UnknownPaymentContextDecodeErrorZ { - /// The contents of this CResult_UnknownPaymentContextDecodeErrorZ, accessible via either +pub struct CResult_ResponderDecodeErrorZ { + /// The contents of this CResult_ResponderDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_UnknownPaymentContextDecodeErrorZPtr, - /// Whether this CResult_UnknownPaymentContextDecodeErrorZ represents a success state. + pub contents: CResult_ResponderDecodeErrorZPtr, + /// Whether this CResult_ResponderDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_UnknownPaymentContextDecodeErrorZ in the success state. -pub extern "C" fn CResult_UnknownPaymentContextDecodeErrorZ_ok(o: crate::lightning::blinded_path::payment::UnknownPaymentContext) -> CResult_UnknownPaymentContextDecodeErrorZ { - CResult_UnknownPaymentContextDecodeErrorZ { - contents: CResult_UnknownPaymentContextDecodeErrorZPtr { +/// Creates a new CResult_ResponderDecodeErrorZ in the success state. +pub extern "C" fn CResult_ResponderDecodeErrorZ_ok(o: crate::lightning::onion_message::messenger::Responder) -> CResult_ResponderDecodeErrorZ { + CResult_ResponderDecodeErrorZ { + contents: CResult_ResponderDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_UnknownPaymentContextDecodeErrorZ in the error state. -pub extern "C" fn CResult_UnknownPaymentContextDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_UnknownPaymentContextDecodeErrorZ { - CResult_UnknownPaymentContextDecodeErrorZ { - contents: CResult_UnknownPaymentContextDecodeErrorZPtr { +/// Creates a new CResult_ResponderDecodeErrorZ in the error state. +pub extern "C" fn CResult_ResponderDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ResponderDecodeErrorZ { + CResult_ResponderDecodeErrorZ { + contents: CResult_ResponderDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -26022,13 +27775,13 @@ pub extern "C" fn CResult_UnknownPaymentContextDecodeErrorZ_err(e: crate::lightn } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_UnknownPaymentContextDecodeErrorZ_is_ok(o: &CResult_UnknownPaymentContextDecodeErrorZ) -> bool { +pub extern "C" fn CResult_ResponderDecodeErrorZ_is_ok(o: &CResult_ResponderDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_UnknownPaymentContextDecodeErrorZ. -pub extern "C" fn CResult_UnknownPaymentContextDecodeErrorZ_free(_res: CResult_UnknownPaymentContextDecodeErrorZ) { } -impl Drop for CResult_UnknownPaymentContextDecodeErrorZ { +/// Frees any resources used by the CResult_ResponderDecodeErrorZ. +pub extern "C" fn CResult_ResponderDecodeErrorZ_free(_res: CResult_ResponderDecodeErrorZ) { } +impl Drop for CResult_ResponderDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -26041,16 +27794,16 @@ impl Drop for CResult_UnknownPaymentContextDecodeErrorZ { } } } -impl From> for CResult_UnknownPaymentContextDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ResponderDecodeErrorZ { + 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_UnknownPaymentContextDecodeErrorZPtr { result } + CResult_ResponderDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_UnknownPaymentContextDecodeErrorZPtr { err } + CResult_ResponderDecodeErrorZPtr { err } }; Self { contents, @@ -26058,155 +27811,142 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_UnknownPaymentContextDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_ResponderDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_UnknownPaymentContextDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_ResponderDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_UnknownPaymentContextDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_ResponderDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_UnknownPaymentContextDecodeErrorZ_clone(orig: &CResult_UnknownPaymentContextDecodeErrorZ) -> CResult_UnknownPaymentContextDecodeErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// The contents of CResult_Bolt12OfferContextDecodeErrorZ -pub union CResult_Bolt12OfferContextDecodeErrorZPtr { - /// 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::payment::Bolt12OfferContext, - /// 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_ResponderDecodeErrorZ_clone(orig: &CResult_ResponderDecodeErrorZ) -> CResult_ResponderDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// A CResult_Bolt12OfferContextDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::blinded_path::payment::Bolt12OfferContext 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_Bolt12OfferContextDecodeErrorZ { - /// The contents of this CResult_Bolt12OfferContextDecodeErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_Bolt12OfferContextDecodeErrorZPtr, - /// Whether this CResult_Bolt12OfferContextDecodeErrorZ represents a success state. - pub result_ok: bool, +#[derive(Clone)] +/// An enum which can either contain a crate::lightning::blinded_path::message::MessageContext or not +pub enum COption_MessageContextZ { + /// When we're in this state, this COption_MessageContextZ contains a crate::lightning::blinded_path::message::MessageContext + Some(crate::lightning::blinded_path::message::MessageContext), + /// When we're in this state, this COption_MessageContextZ contains nothing + None } -#[no_mangle] -/// Creates a new CResult_Bolt12OfferContextDecodeErrorZ in the success state. -pub extern "C" fn CResult_Bolt12OfferContextDecodeErrorZ_ok(o: crate::lightning::blinded_path::payment::Bolt12OfferContext) -> CResult_Bolt12OfferContextDecodeErrorZ { - CResult_Bolt12OfferContextDecodeErrorZ { - contents: CResult_Bolt12OfferContextDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, +impl COption_MessageContextZ { + #[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::blinded_path::message::MessageContext { + if let Self::Some(v) = self { v } else { unreachable!() } } } #[no_mangle] -/// Creates a new CResult_Bolt12OfferContextDecodeErrorZ in the error state. -pub extern "C" fn CResult_Bolt12OfferContextDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_Bolt12OfferContextDecodeErrorZ { - CResult_Bolt12OfferContextDecodeErrorZ { - contents: CResult_Bolt12OfferContextDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), - }, - result_ok: false, - } +/// Constructs a new COption_MessageContextZ containing a crate::lightning::blinded_path::message::MessageContext +pub extern "C" fn COption_MessageContextZ_some(o: crate::lightning::blinded_path::message::MessageContext) -> COption_MessageContextZ { + COption_MessageContextZ::Some(o) } -/// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_Bolt12OfferContextDecodeErrorZ_is_ok(o: &CResult_Bolt12OfferContextDecodeErrorZ) -> bool { - o.result_ok +/// Constructs a new COption_MessageContextZ containing nothing +pub extern "C" fn COption_MessageContextZ_none() -> COption_MessageContextZ { + COption_MessageContextZ::None } #[no_mangle] -/// Frees any resources used by the CResult_Bolt12OfferContextDecodeErrorZ. -pub extern "C" fn CResult_Bolt12OfferContextDecodeErrorZ_free(_res: CResult_Bolt12OfferContextDecodeErrorZ) { } -impl Drop for CResult_Bolt12OfferContextDecodeErrorZ { - 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::lightning::blinded_path::message::MessageContext, if we are in the Some state +pub extern "C" fn COption_MessageContextZ_free(_res: COption_MessageContextZ) { } +#[no_mangle] +/// Creates a new COption_MessageContextZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_MessageContextZ_clone(orig: &COption_MessageContextZ) -> COption_MessageContextZ { Clone::clone(&orig) } +#[repr(C)] +/// A tuple of 3 elements. See the individual fields for the types contained. +pub struct C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ { + /// The element at position 0 + pub a: crate::c_types::PublicKey, + /// The element at position 1 + pub b: crate::lightning::ln::msgs::OnionMessage, + /// The element at position 2 + pub c: crate::c_types::derived::COption_CVec_SocketAddressZZ, } -impl From> for CResult_Bolt12OfferContextDecodeErrorZ { - 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_Bolt12OfferContextDecodeErrorZPtr { result } - } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_Bolt12OfferContextDecodeErrorZPtr { err } - }; +impl From<(crate::c_types::PublicKey, crate::lightning::ln::msgs::OnionMessage, crate::c_types::derived::COption_CVec_SocketAddressZZ)> for C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ { + fn from (tup: (crate::c_types::PublicKey, crate::lightning::ln::msgs::OnionMessage, crate::c_types::derived::COption_CVec_SocketAddressZZ)) -> Self { Self { - contents, - result_ok: o.result_ok, + a: tup.0, + b: tup.1, + c: tup.2, } } } -impl Clone for CResult_Bolt12OfferContextDecodeErrorZ { +impl C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::PublicKey, crate::lightning::ln::msgs::OnionMessage, crate::c_types::derived::COption_CVec_SocketAddressZZ) { + (self.a, self.b, self.c) + } +} +impl Clone for C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ { fn clone(&self) -> Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_Bolt12OfferContextDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_Bolt12OfferContextDecodeErrorZPtr { - 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_Bolt12OfferContextDecodeErrorZ 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_Bolt12OfferContextDecodeErrorZ_clone(orig: &CResult_Bolt12OfferContextDecodeErrorZ) -> CResult_Bolt12OfferContextDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ_clone(orig: &C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ) -> C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ { Clone::clone(&orig) } +/// Creates a new C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ from the contained elements. +#[no_mangle] +pub extern "C" fn C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ_new(a: crate::c_types::PublicKey, b: crate::lightning::ln::msgs::OnionMessage, c: crate::c_types::derived::COption_CVec_SocketAddressZZ) -> C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ { + C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ { a, b, c, } +} + +#[no_mangle] +/// Frees any resources used by the C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ. +pub extern "C" fn C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ_free(_res: C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ) { } #[repr(C)] -/// The contents of CResult_Bolt12RefundContextDecodeErrorZ -pub union CResult_Bolt12RefundContextDecodeErrorZPtr { +/// The contents of CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ +pub union CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZPtr { /// 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::payment::Bolt12RefundContext, + pub result: *mut crate::c_types::derived::C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ, /// 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_Bolt12RefundContextDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::blinded_path::payment::Bolt12RefundContext on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ 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_Bolt12RefundContextDecodeErrorZ { - /// The contents of this CResult_Bolt12RefundContextDecodeErrorZ, accessible via either +pub struct CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ { + /// The contents of this CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_Bolt12RefundContextDecodeErrorZPtr, - /// Whether this CResult_Bolt12RefundContextDecodeErrorZ represents a success state. + pub contents: CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZPtr, + /// Whether this CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_Bolt12RefundContextDecodeErrorZ in the success state. -pub extern "C" fn CResult_Bolt12RefundContextDecodeErrorZ_ok(o: crate::lightning::blinded_path::payment::Bolt12RefundContext) -> CResult_Bolt12RefundContextDecodeErrorZ { - CResult_Bolt12RefundContextDecodeErrorZ { - contents: CResult_Bolt12RefundContextDecodeErrorZPtr { +/// Creates a new CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ in the success state. +pub extern "C" fn CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ_ok(o: crate::c_types::derived::C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ) -> CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ { + CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ { + contents: CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_Bolt12RefundContextDecodeErrorZ in the error state. -pub extern "C" fn CResult_Bolt12RefundContextDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_Bolt12RefundContextDecodeErrorZ { - CResult_Bolt12RefundContextDecodeErrorZ { - contents: CResult_Bolt12RefundContextDecodeErrorZPtr { +/// Creates a new CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ in the error state. +pub extern "C" fn CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ_err(e: crate::lightning::onion_message::messenger::SendError) -> CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ { + CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ { + contents: CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -26214,13 +27954,13 @@ pub extern "C" fn CResult_Bolt12RefundContextDecodeErrorZ_err(e: crate::lightnin } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_Bolt12RefundContextDecodeErrorZ_is_ok(o: &CResult_Bolt12RefundContextDecodeErrorZ) -> bool { +pub extern "C" fn CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ_is_ok(o: &CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_Bolt12RefundContextDecodeErrorZ. -pub extern "C" fn CResult_Bolt12RefundContextDecodeErrorZ_free(_res: CResult_Bolt12RefundContextDecodeErrorZ) { } -impl Drop for CResult_Bolt12RefundContextDecodeErrorZ { +/// Frees any resources used by the CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ. +pub extern "C" fn CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ_free(_res: CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ) { } +impl Drop for CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -26233,16 +27973,16 @@ impl Drop for CResult_Bolt12RefundContextDecodeErrorZ { } } } -impl From> for CResult_Bolt12RefundContextDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ { + 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_Bolt12RefundContextDecodeErrorZPtr { result } + CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_Bolt12RefundContextDecodeErrorZPtr { err } + CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZPtr { err } }; Self { contents, @@ -26250,95 +27990,91 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_Bolt12RefundContextDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_Bolt12RefundContextDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_Bolt12RefundContextDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_Bolt12RefundContextDecodeErrorZ_clone(orig: &CResult_Bolt12RefundContextDecodeErrorZ) -> CResult_Bolt12RefundContextDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ_clone(orig: &CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ) -> CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_StrSecp256k1ErrorZ -pub union CResult_StrSecp256k1ErrorZPtr { +/// The contents of CResult_PeeledOnionNoneZ +pub union CResult_PeeledOnionNoneZPtr { /// 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, - /// 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 result: *mut crate::lightning::onion_message::messenger::PeeledOnion, + /// 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_StrSecp256k1ErrorZ 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_PeeledOnionNoneZ represents the result of a fallible operation, +/// containing a crate::lightning::onion_message::messenger::PeeledOnion on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_StrSecp256k1ErrorZ { - /// The contents of this CResult_StrSecp256k1ErrorZ, accessible via either +pub struct CResult_PeeledOnionNoneZ { + /// The contents of this CResult_PeeledOnionNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_StrSecp256k1ErrorZPtr, - /// Whether this CResult_StrSecp256k1ErrorZ represents a success state. + pub contents: CResult_PeeledOnionNoneZPtr, + /// Whether this CResult_PeeledOnionNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_StrSecp256k1ErrorZ in the success state. -pub extern "C" fn CResult_StrSecp256k1ErrorZ_ok(o: crate::c_types::Str) -> CResult_StrSecp256k1ErrorZ { - CResult_StrSecp256k1ErrorZ { - contents: CResult_StrSecp256k1ErrorZPtr { +/// Creates a new CResult_PeeledOnionNoneZ in the success state. +pub extern "C" fn CResult_PeeledOnionNoneZ_ok(o: crate::lightning::onion_message::messenger::PeeledOnion) -> CResult_PeeledOnionNoneZ { + CResult_PeeledOnionNoneZ { + contents: CResult_PeeledOnionNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_StrSecp256k1ErrorZ in the error state. -pub extern "C" fn CResult_StrSecp256k1ErrorZ_err(e: crate::c_types::Secp256k1Error) -> CResult_StrSecp256k1ErrorZ { - CResult_StrSecp256k1ErrorZ { - contents: CResult_StrSecp256k1ErrorZPtr { - err: Box::into_raw(Box::new(e)), +/// Creates a new CResult_PeeledOnionNoneZ in the error state. +pub extern "C" fn CResult_PeeledOnionNoneZ_err() -> CResult_PeeledOnionNoneZ { + CResult_PeeledOnionNoneZ { + contents: CResult_PeeledOnionNoneZPtr { + 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_StrSecp256k1ErrorZ_is_ok(o: &CResult_StrSecp256k1ErrorZ) -> bool { +pub extern "C" fn CResult_PeeledOnionNoneZ_is_ok(o: &CResult_PeeledOnionNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_StrSecp256k1ErrorZ. -pub extern "C" fn CResult_StrSecp256k1ErrorZ_free(_res: CResult_StrSecp256k1ErrorZ) { } -impl Drop for CResult_StrSecp256k1ErrorZ { +/// Frees any resources used by the CResult_PeeledOnionNoneZ. +pub extern "C" fn CResult_PeeledOnionNoneZ_free(_res: CResult_PeeledOnionNoneZ) { } +impl Drop for CResult_PeeledOnionNoneZ { 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_StrSecp256k1ErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_PeeledOnionNoneZ { + 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_StrSecp256k1ErrorZPtr { result } + CResult_PeeledOnionNoneZPtr { result } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_StrSecp256k1ErrorZPtr { err } + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_PeeledOnionNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -26346,137 +28082,95 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_StrSecp256k1ErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_PeeledOnionNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_StrSecp256k1ErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_PeeledOnionNoneZPtr { + err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_StrSecp256k1ErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_StrSecp256k1ErrorZ_clone(orig: &CResult_StrSecp256k1ErrorZ) -> CResult_StrSecp256k1ErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// A tuple of 3 elements. See the individual fields for the types contained. -pub struct C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ { - /// The element at position 0 - pub a: crate::c_types::ThirtyTwoBytes, - /// The element at position 1 - pub b: crate::lightning::ln::outbound_payment::RecipientOnionFields, - /// The element at position 2 - pub c: crate::lightning::routing::router::RouteParameters, -} -impl From<(crate::c_types::ThirtyTwoBytes, crate::lightning::ln::outbound_payment::RecipientOnionFields, crate::lightning::routing::router::RouteParameters)> for C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ { - fn from (tup: (crate::c_types::ThirtyTwoBytes, crate::lightning::ln::outbound_payment::RecipientOnionFields, crate::lightning::routing::router::RouteParameters)) -> Self { - Self { - a: tup.0, - b: tup.1, - c: tup.2, - } - } -} -impl C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoBytes, crate::lightning::ln::outbound_payment::RecipientOnionFields, crate::lightning::routing::router::RouteParameters) { - (self.a, self.b, self.c) - } -} -impl Clone for C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ { - 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` +/// Creates a new CResult_PeeledOnionNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ_clone(orig: &C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ) -> C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ { Clone::clone(&orig) } -/// Creates a new C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ from the contained elements. -#[no_mangle] -pub extern "C" fn C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ_new(a: crate::c_types::ThirtyTwoBytes, b: crate::lightning::ln::outbound_payment::RecipientOnionFields, c: crate::lightning::routing::router::RouteParameters) -> C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ { - C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ { a, b, c, } -} - -#[no_mangle] -/// Frees any resources used by the C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ. -pub extern "C" fn C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ_free(_res: C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ) { } +pub extern "C" fn CResult_PeeledOnionNoneZ_clone(orig: &CResult_PeeledOnionNoneZ) -> CResult_PeeledOnionNoneZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ -pub union CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZPtr { +/// The contents of CResult_SendSuccessSendErrorZ +pub union CResult_SendSuccessSendErrorZPtr { /// 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::C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ, - /// 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::onion_message::messenger::SendSuccess, + /// 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, } #[repr(C)] -/// A CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ on success and a () on failure. +/// A CResult_SendSuccessSendErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::onion_message::messenger::SendSuccess 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_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ { - /// The contents of this CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ, accessible via either +pub struct CResult_SendSuccessSendErrorZ { + /// The contents of this CResult_SendSuccessSendErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZPtr, - /// Whether this CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ represents a success state. + pub contents: CResult_SendSuccessSendErrorZPtr, + /// Whether this CResult_SendSuccessSendErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ in the success state. -pub extern "C" fn CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ_ok(o: crate::c_types::derived::C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ) -> CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ { - CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ { - contents: CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZPtr { +/// Creates a new CResult_SendSuccessSendErrorZ in the success state. +pub extern "C" fn CResult_SendSuccessSendErrorZ_ok(o: crate::lightning::onion_message::messenger::SendSuccess) -> CResult_SendSuccessSendErrorZ { + CResult_SendSuccessSendErrorZ { + contents: CResult_SendSuccessSendErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ in the error state. -pub extern "C" fn CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ_err() -> CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ { - CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ { - contents: CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZPtr { - err: core::ptr::null_mut(), +/// Creates a new CResult_SendSuccessSendErrorZ in the error state. +pub extern "C" fn CResult_SendSuccessSendErrorZ_err(e: crate::lightning::onion_message::messenger::SendError) -> CResult_SendSuccessSendErrorZ { + CResult_SendSuccessSendErrorZ { + contents: CResult_SendSuccessSendErrorZPtr { + 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_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ_is_ok(o: &CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ) -> bool { +pub extern "C" fn CResult_SendSuccessSendErrorZ_is_ok(o: &CResult_SendSuccessSendErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ. -pub extern "C" fn CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ_free(_res: CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ) { } -impl Drop for CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ { +/// Frees any resources used by the CResult_SendSuccessSendErrorZ. +pub extern "C" fn CResult_SendSuccessSendErrorZ_free(_res: CResult_SendSuccessSendErrorZ) { } +impl Drop for CResult_SendSuccessSendErrorZ { 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_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_SendSuccessSendErrorZ { + 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_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZPtr { result } + CResult_SendSuccessSendErrorZPtr { result } } else { - let _ = unsafe { Box::from_raw(o.contents.err) }; - o.contents.err = core::ptr::null_mut(); - CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZPtr { err: core::ptr::null_mut() } + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_SendSuccessSendErrorZPtr { err } }; Self { contents, @@ -26484,59 +28178,58 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_SendSuccessSendErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZPtr { - err: core::ptr::null_mut() + Self { result_ok: false, contents: CResult_SendSuccessSendErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ which has the same data as `orig` +/// Creates a new CResult_SendSuccessSendErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ_clone(orig: &CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ) -> CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ { Clone::clone(&orig) } +pub extern "C" fn CResult_SendSuccessSendErrorZ_clone(orig: &CResult_SendSuccessSendErrorZ) -> CResult_SendSuccessSendErrorZ { Clone::clone(&orig) } #[repr(C)] -/// 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::c_types::TxOut, +/// 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::routing::utxo::UtxoLookupError, + pub err: *mut crate::lightning::onion_message::messenger::SendError, } #[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_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_TxOutUtxoLookupErrorZ { - /// The contents of this CResult_TxOutUtxoLookupErrorZ, 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_TxOutUtxoLookupErrorZPtr, - /// Whether this CResult_TxOutUtxoLookupErrorZ 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_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)), +/// 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_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_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, @@ -26544,18 +28237,15 @@ 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_NoneSendErrorZ_is_ok(o: &CResult_NoneSendErrorZ) -> 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_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) }; @@ -26563,16 +28253,16 @@ impl Drop for CResult_TxOutUtxoLookupErrorZ { } } } -impl From> for CResult_TxOutUtxoLookupErrorZ { - 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_TxOutUtxoLookupErrorZPtr { 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_TxOutUtxoLookupErrorZPtr { err } + CResult_NoneSendErrorZPtr { err } }; Self { contents, @@ -26580,105 +28270,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_NoneSendErrorZPtr { + result: core::ptr::null_mut() } } } 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_NoneSendErrorZPtr { + 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` -/// 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) } -#[repr(C)] -/// A tuple of 3 elements. See the individual fields for the types contained. -pub struct C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ { - /// The element at position 0 - pub a: crate::c_types::PublicKey, - /// The element at position 1 - pub b: crate::lightning::ln::msgs::OnionMessage, - /// The element at position 2 - pub c: crate::c_types::derived::COption_CVec_SocketAddressZZ, -} -impl From<(crate::c_types::PublicKey, crate::lightning::ln::msgs::OnionMessage, crate::c_types::derived::COption_CVec_SocketAddressZZ)> for C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ { - fn from (tup: (crate::c_types::PublicKey, crate::lightning::ln::msgs::OnionMessage, crate::c_types::derived::COption_CVec_SocketAddressZZ)) -> Self { - Self { - a: tup.0, - b: tup.1, - c: tup.2, - } - } -} -impl C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::PublicKey, crate::lightning::ln::msgs::OnionMessage, crate::c_types::derived::COption_CVec_SocketAddressZZ) { - (self.a, self.b, self.c) - } -} -impl Clone for C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ { - 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` +/// Creates a new CResult_NoneSendErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ_clone(orig: &C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ) -> C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ { Clone::clone(&orig) } -/// Creates a new C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ from the contained elements. -#[no_mangle] -pub extern "C" fn C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ_new(a: crate::c_types::PublicKey, b: crate::lightning::ln::msgs::OnionMessage, c: crate::c_types::derived::COption_CVec_SocketAddressZZ) -> C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ { - C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ { a, b, c, } -} - -#[no_mangle] -/// Frees any resources used by the C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ. -pub extern "C" fn C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ_free(_res: C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ) { } +pub extern "C" fn CResult_NoneSendErrorZ_clone(orig: &CResult_NoneSendErrorZ) -> CResult_NoneSendErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ -pub union CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZPtr { +/// 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::c_types::derived::C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ, + 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::onion_message::messenger::SendError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ on success and a crate::lightning::onion_message::messenger::SendError 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_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ { - /// The contents of this CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ, 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_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZPtr, - /// Whether this CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ 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_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ in the success state. -pub extern "C" fn CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ_ok(o: crate::c_types::derived::C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ) -> CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ { - CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ { - contents: CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZPtr { +/// 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_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ in the error state. -pub extern "C" fn CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ_err(e: crate::lightning::onion_message::messenger::SendError) -> CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ { - CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ { - contents: CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZPtr { +/// 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, @@ -26686,13 +28330,13 @@ pub extern "C" fn CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddres } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ_is_ok(o: &CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ) -> 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_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ. -pub extern "C" fn CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ_free(_res: CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ) { } -impl Drop for CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ { +/// 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() } { @@ -26705,16 +28349,16 @@ impl Drop for CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ } } } -impl From> for CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ { - 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_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZPtr { result } + CResult_BlindedHopDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZPtr { err } + CResult_BlindedHopDecodeErrorZPtr { err } }; Self { contents, @@ -26722,91 +28366,141 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZPtr { - 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_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_BlindedHopDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ 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_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ_clone(orig: &CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ) -> CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_BlindedHopDecodeErrorZ_clone(orig: &CResult_BlindedHopDecodeErrorZ) -> CResult_BlindedHopDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_PeeledOnionNoneZ -pub union CResult_PeeledOnionNoneZPtr { +/// 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::onion_message::messenger::PeeledOnion, - /// 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_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_invoice::SignOrCreationError, } #[repr(C)] -/// A CResult_PeeledOnionNoneZ represents the result of a fallible operation, -/// containing a crate::lightning::onion_message::messenger::PeeledOnion on success and a () 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_PeeledOnionNoneZ { - /// The contents of this CResult_PeeledOnionNoneZ, 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_PeeledOnionNoneZPtr, - /// Whether this CResult_PeeledOnionNoneZ 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_PeeledOnionNoneZ in the success state. -pub extern "C" fn CResult_PeeledOnionNoneZ_ok(o: crate::lightning::onion_message::messenger::PeeledOnion) -> CResult_PeeledOnionNoneZ { - CResult_PeeledOnionNoneZ { - contents: CResult_PeeledOnionNoneZPtr { +/// 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_PeeledOnionNoneZ in the error state. -pub extern "C" fn CResult_PeeledOnionNoneZ_err() -> CResult_PeeledOnionNoneZ { - CResult_PeeledOnionNoneZ { - contents: CResult_PeeledOnionNoneZPtr { - err: core::ptr::null_mut(), +/// 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, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_PeeledOnionNoneZ_is_ok(o: &CResult_PeeledOnionNoneZ) -> 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_PeeledOnionNoneZ. -pub extern "C" fn CResult_PeeledOnionNoneZ_free(_res: CResult_PeeledOnionNoneZ) { } -impl Drop for CResult_PeeledOnionNoneZ { +/// 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() } { 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_PeeledOnionNoneZ { - 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_PeeledOnionNoneZPtr { result } + CResult_Bolt11InvoiceSignOrCreationErrorZPtr { result } } else { - let _ = unsafe { Box::from_raw(o.contents.err) }; - o.contents.err = core::ptr::null_mut(); - CResult_PeeledOnionNoneZPtr { err: core::ptr::null_mut() } + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_Bolt11InvoiceSignOrCreationErrorZPtr { err } }; Self { contents, @@ -26814,59 +28508,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_PeeledOnionNoneZPtr { - 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_PeeledOnionNoneZPtr { - err: core::ptr::null_mut() + Self { result_ok: false, contents: CResult_Bolt11InvoiceSignOrCreationErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_PeeledOnionNoneZ 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_PeeledOnionNoneZ_clone(orig: &CResult_PeeledOnionNoneZ) -> CResult_PeeledOnionNoneZ { Clone::clone(&orig) } +pub extern "C" fn CResult_Bolt11InvoiceSignOrCreationErrorZ_clone(orig: &CResult_Bolt11InvoiceSignOrCreationErrorZ) -> CResult_Bolt11InvoiceSignOrCreationErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_SendSuccessSendErrorZ -pub union CResult_SendSuccessSendErrorZPtr { +/// 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::onion_message::messenger::SendSuccess, + 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::onion_message::messenger::SendError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_SendSuccessSendErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::onion_message::messenger::SendSuccess on success and a crate::lightning::onion_message::messenger::SendError 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_SendSuccessSendErrorZ { - /// The contents of this CResult_SendSuccessSendErrorZ, 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_SendSuccessSendErrorZPtr, - /// Whether this CResult_SendSuccessSendErrorZ 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_SendSuccessSendErrorZ in the success state. -pub extern "C" fn CResult_SendSuccessSendErrorZ_ok(o: crate::lightning::onion_message::messenger::SendSuccess) -> CResult_SendSuccessSendErrorZ { - CResult_SendSuccessSendErrorZ { - contents: CResult_SendSuccessSendErrorZPtr { +/// 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_SendSuccessSendErrorZ in the error state. -pub extern "C" fn CResult_SendSuccessSendErrorZ_err(e: crate::lightning::onion_message::messenger::SendError) -> CResult_SendSuccessSendErrorZ { - CResult_SendSuccessSendErrorZ { - contents: CResult_SendSuccessSendErrorZPtr { +/// 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, @@ -26874,13 +28568,13 @@ pub extern "C" fn CResult_SendSuccessSendErrorZ_err(e: crate::lightning::onion_m } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_SendSuccessSendErrorZ_is_ok(o: &CResult_SendSuccessSendErrorZ) -> 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_SendSuccessSendErrorZ. -pub extern "C" fn CResult_SendSuccessSendErrorZ_free(_res: CResult_SendSuccessSendErrorZ) { } -impl Drop for CResult_SendSuccessSendErrorZ { +/// 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() } { @@ -26893,16 +28587,16 @@ impl Drop for CResult_SendSuccessSendErrorZ { } } } -impl From> for CResult_SendSuccessSendErrorZ { - 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_SendSuccessSendErrorZPtr { result } + CResult_InvoiceErrorDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_SendSuccessSendErrorZPtr { err } + CResult_InvoiceErrorDecodeErrorZPtr { err } }; Self { contents, @@ -26910,91 +28604,95 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_SendSuccessSendErrorZPtr { - 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_SendSuccessSendErrorZPtr { - 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_SendSuccessSendErrorZ 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_SendSuccessSendErrorZ_clone(orig: &CResult_SendSuccessSendErrorZ) -> CResult_SendSuccessSendErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_InvoiceErrorDecodeErrorZ_clone(orig: &CResult_InvoiceErrorDecodeErrorZ) -> CResult_InvoiceErrorDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_BlindedPathNoneZ -pub union CResult_BlindedPathNoneZPtr { +/// The contents of CResult_TrackedSpendableOutputDecodeErrorZ +pub union CResult_TrackedSpendableOutputDecodeErrorZPtr { /// 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::util::sweep::TrackedSpendableOutput, + /// 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_TrackedSpendableOutputDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::util::sweep::TrackedSpendableOutput 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_TrackedSpendableOutputDecodeErrorZ { + /// The contents of this CResult_TrackedSpendableOutputDecodeErrorZ, 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_TrackedSpendableOutputDecodeErrorZPtr, + /// Whether this CResult_TrackedSpendableOutputDecodeErrorZ 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_TrackedSpendableOutputDecodeErrorZ in the success state. +pub extern "C" fn CResult_TrackedSpendableOutputDecodeErrorZ_ok(o: crate::lightning::util::sweep::TrackedSpendableOutput) -> CResult_TrackedSpendableOutputDecodeErrorZ { + CResult_TrackedSpendableOutputDecodeErrorZ { + contents: CResult_TrackedSpendableOutputDecodeErrorZPtr { 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_TrackedSpendableOutputDecodeErrorZ in the error state. +pub extern "C" fn CResult_TrackedSpendableOutputDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_TrackedSpendableOutputDecodeErrorZ { + CResult_TrackedSpendableOutputDecodeErrorZ { + contents: CResult_TrackedSpendableOutputDecodeErrorZPtr { + 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_TrackedSpendableOutputDecodeErrorZ_is_ok(o: &CResult_TrackedSpendableOutputDecodeErrorZ) -> 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_TrackedSpendableOutputDecodeErrorZ. +pub extern "C" fn CResult_TrackedSpendableOutputDecodeErrorZ_free(_res: CResult_TrackedSpendableOutputDecodeErrorZ) { } +impl Drop for CResult_TrackedSpendableOutputDecodeErrorZ { 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_TrackedSpendableOutputDecodeErrorZ { + 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_TrackedSpendableOutputDecodeErrorZPtr { 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_TrackedSpendableOutputDecodeErrorZPtr { err } }; Self { contents, @@ -27002,91 +28700,95 @@ 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_TrackedSpendableOutputDecodeErrorZPtr { + 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_TrackedSpendableOutputDecodeErrorZPtr { + 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_TrackedSpendableOutputDecodeErrorZ 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_TrackedSpendableOutputDecodeErrorZ_clone(orig: &CResult_TrackedSpendableOutputDecodeErrorZ) -> CResult_TrackedSpendableOutputDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ -pub union CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZPtr { +/// The contents of CResult_OutputSpendStatusDecodeErrorZ +pub union CResult_OutputSpendStatusDecodeErrorZPtr { /// 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_BlindedPayInfoBlindedPathZ, - /// 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::sweep::OutputSpendStatus, + /// 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_BlindedPayInfoBlindedPathZNoneZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::C2Tuple_BlindedPayInfoBlindedPathZ on success and a () on failure. +/// A CResult_OutputSpendStatusDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::util::sweep::OutputSpendStatus 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_BlindedPayInfoBlindedPathZNoneZ { - /// The contents of this CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ, accessible via either +pub struct CResult_OutputSpendStatusDecodeErrorZ { + /// The contents of this CResult_OutputSpendStatusDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZPtr, - /// Whether this CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ represents a success state. + pub contents: CResult_OutputSpendStatusDecodeErrorZPtr, + /// Whether this CResult_OutputSpendStatusDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ in the success state. -pub extern "C" fn CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ_ok(o: crate::c_types::derived::C2Tuple_BlindedPayInfoBlindedPathZ) -> CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ { - CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ { - contents: CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZPtr { +/// Creates a new CResult_OutputSpendStatusDecodeErrorZ in the success state. +pub extern "C" fn CResult_OutputSpendStatusDecodeErrorZ_ok(o: crate::lightning::util::sweep::OutputSpendStatus) -> CResult_OutputSpendStatusDecodeErrorZ { + CResult_OutputSpendStatusDecodeErrorZ { + contents: CResult_OutputSpendStatusDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ in the error state. -pub extern "C" fn CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ_err() -> CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ { - CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ { - contents: CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZPtr { - err: core::ptr::null_mut(), +/// Creates a new CResult_OutputSpendStatusDecodeErrorZ in the error state. +pub extern "C" fn CResult_OutputSpendStatusDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_OutputSpendStatusDecodeErrorZ { + CResult_OutputSpendStatusDecodeErrorZ { + contents: CResult_OutputSpendStatusDecodeErrorZPtr { + 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_BlindedPayInfoBlindedPathZNoneZ_is_ok(o: &CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ) -> bool { +pub extern "C" fn CResult_OutputSpendStatusDecodeErrorZ_is_ok(o: &CResult_OutputSpendStatusDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ. -pub extern "C" fn CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ_free(_res: CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ) { } -impl Drop for CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ { +/// Frees any resources used by the CResult_OutputSpendStatusDecodeErrorZ. +pub extern "C" fn CResult_OutputSpendStatusDecodeErrorZ_free(_res: CResult_OutputSpendStatusDecodeErrorZ) { } +impl Drop for CResult_OutputSpendStatusDecodeErrorZ { 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_BlindedPayInfoBlindedPathZNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_OutputSpendStatusDecodeErrorZ { + 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_BlindedPayInfoBlindedPathZNoneZPtr { result } + CResult_OutputSpendStatusDecodeErrorZPtr { result } } else { - let _ = unsafe { Box::from_raw(o.contents.err) }; - o.contents.err = core::ptr::null_mut(); - CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZPtr { err: core::ptr::null_mut() } + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_OutputSpendStatusDecodeErrorZPtr { err } }; Self { contents, @@ -27094,47 +28796,79 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_OutputSpendStatusDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZPtr { - err: core::ptr::null_mut() + Self { result_ok: false, contents: CResult_OutputSpendStatusDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ_clone(orig: &CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ) -> CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ { Clone::clone(&orig) } +/// Creates a new CResult_OutputSpendStatusDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_OutputSpendStatusDecodeErrorZ_clone(orig: &CResult_OutputSpendStatusDecodeErrorZ) -> CResult_OutputSpendStatusDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// An enum which can either contain a crate::lightning::chain::Filter or not +pub enum COption_FilterZ { + /// When we're in this state, this COption_FilterZ contains a crate::lightning::chain::Filter + Some(crate::lightning::chain::Filter), + /// When we're in this state, this COption_FilterZ contains nothing + None +} +impl COption_FilterZ { + #[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::Filter { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_FilterZ containing a crate::lightning::chain::Filter +pub extern "C" fn COption_FilterZ_some(o: crate::lightning::chain::Filter) -> COption_FilterZ { + COption_FilterZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_FilterZ containing nothing +pub extern "C" fn COption_FilterZ_none() -> COption_FilterZ { + COption_FilterZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::lightning::chain::Filter, if we are in the Some state +pub extern "C" fn COption_FilterZ_free(_res: COption_FilterZ) { } #[repr(C)] -/// A dynamically-allocated array of crate::lightning::blinded_path::payment::ForwardNodes of arbitrary size. +/// A dynamically-allocated array of crate::lightning::util::sweep::TrackedSpendableOutputs of arbitrary size. /// This corresponds to std::vector in C++ -pub struct CVec_ForwardNodeZ { +pub struct CVec_TrackedSpendableOutputZ { /// 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::payment::ForwardNode, + pub data: *mut crate::lightning::util::sweep::TrackedSpendableOutput, /// The number of elements pointed to by `data`. pub datalen: usize } -impl CVec_ForwardNodeZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { +impl CVec_TrackedSpendableOutputZ { + #[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::payment::ForwardNode] { + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::util::sweep::TrackedSpendableOutput] { unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl From> for CVec_ForwardNodeZ { - fn from(v: Vec) -> Self { +impl From> for CVec_TrackedSpendableOutputZ { + 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() } } @@ -27142,14 +28876,14 @@ impl From> for CVec_Fo } #[no_mangle] /// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_ForwardNodeZ_free(_res: CVec_ForwardNodeZ) { } -impl Drop for CVec_ForwardNodeZ { +pub extern "C" fn CVec_TrackedSpendableOutputZ_free(_res: CVec_TrackedSpendableOutputZ) { } +impl Drop for CVec_TrackedSpendableOutputZ { 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_ForwardNodeZ { +impl Clone for CVec_TrackedSpendableOutputZ { fn clone(&self) -> Self { let mut res = Vec::new(); if self.datalen == 0 { return Self::from(res); } @@ -27158,41 +28892,41 @@ impl Clone for CVec_ForwardNodeZ { } } #[repr(C)] -/// The contents of CResult_BlindedPathDecodeErrorZ -pub union CResult_BlindedPathDecodeErrorZPtr { +/// The contents of CResult_OutputSweeperDecodeErrorZ +pub union CResult_OutputSweeperDecodeErrorZPtr { /// 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::util::sweep::OutputSweeper, /// 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_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_OutputSweeperDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::util::sweep::OutputSweeper 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_BlindedPathDecodeErrorZ { - /// The contents of this CResult_BlindedPathDecodeErrorZ, accessible via either +pub struct CResult_OutputSweeperDecodeErrorZ { + /// The contents of this CResult_OutputSweeperDecodeErrorZ, 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_OutputSweeperDecodeErrorZPtr, + /// Whether this CResult_OutputSweeperDecodeErrorZ 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_OutputSweeperDecodeErrorZ in the success state. +pub extern "C" fn CResult_OutputSweeperDecodeErrorZ_ok(o: crate::lightning::util::sweep::OutputSweeper) -> CResult_OutputSweeperDecodeErrorZ { + CResult_OutputSweeperDecodeErrorZ { + contents: CResult_OutputSweeperDecodeErrorZPtr { 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 { +/// Creates a new CResult_OutputSweeperDecodeErrorZ in the error state. +pub extern "C" fn CResult_OutputSweeperDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_OutputSweeperDecodeErrorZ { + CResult_OutputSweeperDecodeErrorZ { + contents: CResult_OutputSweeperDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -27200,13 +28934,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_OutputSweeperDecodeErrorZ_is_ok(o: &CResult_OutputSweeperDecodeErrorZ) -> 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_OutputSweeperDecodeErrorZ. +pub extern "C" fn CResult_OutputSweeperDecodeErrorZ_free(_res: CResult_OutputSweeperDecodeErrorZ) { } +impl Drop for CResult_OutputSweeperDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -27219,16 +28953,16 @@ impl Drop for CResult_BlindedPathDecodeErrorZ { } } } -impl From> for CResult_BlindedPathDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_OutputSweeperDecodeErrorZ { + 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_OutputSweeperDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_BlindedPathDecodeErrorZPtr { err } + CResult_OutputSweeperDecodeErrorZPtr { err } }; Self { contents, @@ -27236,59 +28970,72 @@ 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 }))) - } } - } else { - Self { result_ok: false, contents: CResult_BlindedPathDecodeErrorZPtr { - 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_BestBlockOutputSweeperZ { + /// The element at position 0 + pub a: crate::lightning::chain::BestBlock, + /// The element at position 1 + pub b: crate::lightning::util::sweep::OutputSweeper, +} +impl From<(crate::lightning::chain::BestBlock, crate::lightning::util::sweep::OutputSweeper)> for C2Tuple_BestBlockOutputSweeperZ { + fn from (tup: (crate::lightning::chain::BestBlock, crate::lightning::util::sweep::OutputSweeper)) -> Self { + Self { + a: tup.0, + b: tup.1, } } } +impl C2Tuple_BestBlockOutputSweeperZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::lightning::chain::BestBlock, crate::lightning::util::sweep::OutputSweeper) { + (self.a, self.b) + } +} +/// Creates a new C2Tuple_BestBlockOutputSweeperZ from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_BestBlockOutputSweeperZ_new(a: crate::lightning::chain::BestBlock, b: crate::lightning::util::sweep::OutputSweeper) -> C2Tuple_BestBlockOutputSweeperZ { + C2Tuple_BestBlockOutputSweeperZ { a, b, } +} + #[no_mangle] -/// 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_BlindedPathDecodeErrorZ_clone(orig: &CResult_BlindedPathDecodeErrorZ) -> CResult_BlindedPathDecodeErrorZ { Clone::clone(&orig) } +/// Frees any resources used by the C2Tuple_BestBlockOutputSweeperZ. +pub extern "C" fn C2Tuple_BestBlockOutputSweeperZ_free(_res: C2Tuple_BestBlockOutputSweeperZ) { } #[repr(C)] -/// The contents of CResult_BlindedHopDecodeErrorZ -pub union CResult_BlindedHopDecodeErrorZPtr { +/// The contents of CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ +pub union CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZPtr { /// 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::c_types::derived::C2Tuple_BestBlockOutputSweeperZ, /// 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_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::C2Tuple_BestBlockOutputSweeperZ 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_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ { + /// The contents of this CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ, 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_C2Tuple_BestBlockOutputSweeperZDecodeErrorZPtr, + /// Whether this CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ 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_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ in the success state. +pub extern "C" fn CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ_ok(o: crate::c_types::derived::C2Tuple_BestBlockOutputSweeperZ) -> CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ { + CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ { + contents: CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZPtr { 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_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ in the error state. +pub extern "C" fn CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ { + CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ { + contents: CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -27296,13 +29043,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_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ_is_ok(o: &CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ) -> 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_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ. +pub extern "C" fn CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ_free(_res: CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ) { } +impl Drop for CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -27315,16 +29062,16 @@ impl Drop for CResult_BlindedHopDecodeErrorZ { } } } -impl From> for CResult_BlindedHopDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ { + 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_C2Tuple_BestBlockOutputSweeperZDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_BlindedHopDecodeErrorZPtr { err } + CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZPtr { err } }; Self { contents, @@ -27332,59 +29079,42 @@ 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 }))) - } } - } else { - Self { result_ok: false, contents: CResult_BlindedHopDecodeErrorZPtr { - 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` -/// 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) } #[repr(C)] -/// The contents of CResult_InvoiceErrorDecodeErrorZ -pub union CResult_InvoiceErrorDecodeErrorZPtr { +/// The contents of CResult_DelayedPaymentBasepointDecodeErrorZ +pub union CResult_DelayedPaymentBasepointDecodeErrorZPtr { /// 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_error::InvoiceError, + pub result: *mut crate::lightning::ln::channel_keys::DelayedPaymentBasepoint, /// 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_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. +/// A CResult_DelayedPaymentBasepointDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::channel_keys::DelayedPaymentBasepoint 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_InvoiceErrorDecodeErrorZ { - /// The contents of this CResult_InvoiceErrorDecodeErrorZ, accessible via either +pub struct CResult_DelayedPaymentBasepointDecodeErrorZ { + /// The contents of this CResult_DelayedPaymentBasepointDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_InvoiceErrorDecodeErrorZPtr, - /// Whether this CResult_InvoiceErrorDecodeErrorZ represents a success state. + pub contents: CResult_DelayedPaymentBasepointDecodeErrorZPtr, + /// Whether this CResult_DelayedPaymentBasepointDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// 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 { +/// Creates a new CResult_DelayedPaymentBasepointDecodeErrorZ in the success state. +pub extern "C" fn CResult_DelayedPaymentBasepointDecodeErrorZ_ok(o: crate::lightning::ln::channel_keys::DelayedPaymentBasepoint) -> CResult_DelayedPaymentBasepointDecodeErrorZ { + CResult_DelayedPaymentBasepointDecodeErrorZ { + contents: CResult_DelayedPaymentBasepointDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// 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 { +/// Creates a new CResult_DelayedPaymentBasepointDecodeErrorZ in the error state. +pub extern "C" fn CResult_DelayedPaymentBasepointDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_DelayedPaymentBasepointDecodeErrorZ { + CResult_DelayedPaymentBasepointDecodeErrorZ { + contents: CResult_DelayedPaymentBasepointDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -27392,13 +29122,13 @@ pub extern "C" fn CResult_InvoiceErrorDecodeErrorZ_err(e: crate::lightning::ln:: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_InvoiceErrorDecodeErrorZ_is_ok(o: &CResult_InvoiceErrorDecodeErrorZ) -> bool { +pub extern "C" fn CResult_DelayedPaymentBasepointDecodeErrorZ_is_ok(o: &CResult_DelayedPaymentBasepointDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_InvoiceErrorDecodeErrorZ. -pub extern "C" fn CResult_InvoiceErrorDecodeErrorZ_free(_res: CResult_InvoiceErrorDecodeErrorZ) { } -impl Drop for CResult_InvoiceErrorDecodeErrorZ { +/// Frees any resources used by the CResult_DelayedPaymentBasepointDecodeErrorZ. +pub extern "C" fn CResult_DelayedPaymentBasepointDecodeErrorZ_free(_res: CResult_DelayedPaymentBasepointDecodeErrorZ) { } +impl Drop for CResult_DelayedPaymentBasepointDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -27411,16 +29141,16 @@ impl Drop for CResult_InvoiceErrorDecodeErrorZ { } } } -impl From> for CResult_InvoiceErrorDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_DelayedPaymentBasepointDecodeErrorZ { + 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_InvoiceErrorDecodeErrorZPtr { result } + CResult_DelayedPaymentBasepointDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_InvoiceErrorDecodeErrorZPtr { err } + CResult_DelayedPaymentBasepointDecodeErrorZPtr { err } }; Self { contents, @@ -27428,59 +29158,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_InvoiceErrorDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_DelayedPaymentBasepointDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_InvoiceErrorDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_DelayedPaymentBasepointDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_InvoiceErrorDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_DelayedPaymentBasepointDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_InvoiceErrorDecodeErrorZ_clone(orig: &CResult_InvoiceErrorDecodeErrorZ) -> CResult_InvoiceErrorDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_DelayedPaymentBasepointDecodeErrorZ_clone(orig: &CResult_DelayedPaymentBasepointDecodeErrorZ) -> CResult_DelayedPaymentBasepointDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_TrackedSpendableOutputDecodeErrorZ -pub union CResult_TrackedSpendableOutputDecodeErrorZPtr { +/// The contents of CResult_DelayedPaymentKeyDecodeErrorZ +pub union CResult_DelayedPaymentKeyDecodeErrorZPtr { /// 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::sweep::TrackedSpendableOutput, + pub result: *mut crate::lightning::ln::channel_keys::DelayedPaymentKey, /// 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_TrackedSpendableOutputDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::util::sweep::TrackedSpendableOutput on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_DelayedPaymentKeyDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::channel_keys::DelayedPaymentKey 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_TrackedSpendableOutputDecodeErrorZ { - /// The contents of this CResult_TrackedSpendableOutputDecodeErrorZ, accessible via either +pub struct CResult_DelayedPaymentKeyDecodeErrorZ { + /// The contents of this CResult_DelayedPaymentKeyDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_TrackedSpendableOutputDecodeErrorZPtr, - /// Whether this CResult_TrackedSpendableOutputDecodeErrorZ represents a success state. + pub contents: CResult_DelayedPaymentKeyDecodeErrorZPtr, + /// Whether this CResult_DelayedPaymentKeyDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_TrackedSpendableOutputDecodeErrorZ in the success state. -pub extern "C" fn CResult_TrackedSpendableOutputDecodeErrorZ_ok(o: crate::lightning::util::sweep::TrackedSpendableOutput) -> CResult_TrackedSpendableOutputDecodeErrorZ { - CResult_TrackedSpendableOutputDecodeErrorZ { - contents: CResult_TrackedSpendableOutputDecodeErrorZPtr { +/// Creates a new CResult_DelayedPaymentKeyDecodeErrorZ in the success state. +pub extern "C" fn CResult_DelayedPaymentKeyDecodeErrorZ_ok(o: crate::lightning::ln::channel_keys::DelayedPaymentKey) -> CResult_DelayedPaymentKeyDecodeErrorZ { + CResult_DelayedPaymentKeyDecodeErrorZ { + contents: CResult_DelayedPaymentKeyDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_TrackedSpendableOutputDecodeErrorZ in the error state. -pub extern "C" fn CResult_TrackedSpendableOutputDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_TrackedSpendableOutputDecodeErrorZ { - CResult_TrackedSpendableOutputDecodeErrorZ { - contents: CResult_TrackedSpendableOutputDecodeErrorZPtr { +/// Creates a new CResult_DelayedPaymentKeyDecodeErrorZ in the error state. +pub extern "C" fn CResult_DelayedPaymentKeyDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_DelayedPaymentKeyDecodeErrorZ { + CResult_DelayedPaymentKeyDecodeErrorZ { + contents: CResult_DelayedPaymentKeyDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -27488,13 +29218,13 @@ pub extern "C" fn CResult_TrackedSpendableOutputDecodeErrorZ_err(e: crate::light } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_TrackedSpendableOutputDecodeErrorZ_is_ok(o: &CResult_TrackedSpendableOutputDecodeErrorZ) -> bool { +pub extern "C" fn CResult_DelayedPaymentKeyDecodeErrorZ_is_ok(o: &CResult_DelayedPaymentKeyDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_TrackedSpendableOutputDecodeErrorZ. -pub extern "C" fn CResult_TrackedSpendableOutputDecodeErrorZ_free(_res: CResult_TrackedSpendableOutputDecodeErrorZ) { } -impl Drop for CResult_TrackedSpendableOutputDecodeErrorZ { +/// Frees any resources used by the CResult_DelayedPaymentKeyDecodeErrorZ. +pub extern "C" fn CResult_DelayedPaymentKeyDecodeErrorZ_free(_res: CResult_DelayedPaymentKeyDecodeErrorZ) { } +impl Drop for CResult_DelayedPaymentKeyDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -27507,16 +29237,16 @@ impl Drop for CResult_TrackedSpendableOutputDecodeErrorZ { } } } -impl From> for CResult_TrackedSpendableOutputDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_DelayedPaymentKeyDecodeErrorZ { + 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_TrackedSpendableOutputDecodeErrorZPtr { result } + CResult_DelayedPaymentKeyDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_TrackedSpendableOutputDecodeErrorZPtr { err } + CResult_DelayedPaymentKeyDecodeErrorZPtr { err } }; Self { contents, @@ -27524,59 +29254,59 @@ impl From Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_TrackedSpendableOutputDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + if self.result_ok { + Self { result_ok: true, contents: CResult_DelayedPaymentKeyDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_TrackedSpendableOutputDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_DelayedPaymentKeyDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_TrackedSpendableOutputDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_DelayedPaymentKeyDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_TrackedSpendableOutputDecodeErrorZ_clone(orig: &CResult_TrackedSpendableOutputDecodeErrorZ) -> CResult_TrackedSpendableOutputDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_DelayedPaymentKeyDecodeErrorZ_clone(orig: &CResult_DelayedPaymentKeyDecodeErrorZ) -> CResult_DelayedPaymentKeyDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_OutputSpendStatusDecodeErrorZ -pub union CResult_OutputSpendStatusDecodeErrorZPtr { +/// The contents of CResult_HtlcBasepointDecodeErrorZ +pub union CResult_HtlcBasepointDecodeErrorZPtr { /// 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::sweep::OutputSpendStatus, + pub result: *mut crate::lightning::ln::channel_keys::HtlcBasepoint, /// 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_OutputSpendStatusDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::util::sweep::OutputSpendStatus on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_HtlcBasepointDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::channel_keys::HtlcBasepoint 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_OutputSpendStatusDecodeErrorZ { - /// The contents of this CResult_OutputSpendStatusDecodeErrorZ, accessible via either +pub struct CResult_HtlcBasepointDecodeErrorZ { + /// The contents of this CResult_HtlcBasepointDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_OutputSpendStatusDecodeErrorZPtr, - /// Whether this CResult_OutputSpendStatusDecodeErrorZ represents a success state. + pub contents: CResult_HtlcBasepointDecodeErrorZPtr, + /// Whether this CResult_HtlcBasepointDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_OutputSpendStatusDecodeErrorZ in the success state. -pub extern "C" fn CResult_OutputSpendStatusDecodeErrorZ_ok(o: crate::lightning::util::sweep::OutputSpendStatus) -> CResult_OutputSpendStatusDecodeErrorZ { - CResult_OutputSpendStatusDecodeErrorZ { - contents: CResult_OutputSpendStatusDecodeErrorZPtr { +/// Creates a new CResult_HtlcBasepointDecodeErrorZ in the success state. +pub extern "C" fn CResult_HtlcBasepointDecodeErrorZ_ok(o: crate::lightning::ln::channel_keys::HtlcBasepoint) -> CResult_HtlcBasepointDecodeErrorZ { + CResult_HtlcBasepointDecodeErrorZ { + contents: CResult_HtlcBasepointDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_OutputSpendStatusDecodeErrorZ in the error state. -pub extern "C" fn CResult_OutputSpendStatusDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_OutputSpendStatusDecodeErrorZ { - CResult_OutputSpendStatusDecodeErrorZ { - contents: CResult_OutputSpendStatusDecodeErrorZPtr { +/// Creates a new CResult_HtlcBasepointDecodeErrorZ in the error state. +pub extern "C" fn CResult_HtlcBasepointDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_HtlcBasepointDecodeErrorZ { + CResult_HtlcBasepointDecodeErrorZ { + contents: CResult_HtlcBasepointDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -27584,13 +29314,13 @@ pub extern "C" fn CResult_OutputSpendStatusDecodeErrorZ_err(e: crate::lightning: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_OutputSpendStatusDecodeErrorZ_is_ok(o: &CResult_OutputSpendStatusDecodeErrorZ) -> bool { +pub extern "C" fn CResult_HtlcBasepointDecodeErrorZ_is_ok(o: &CResult_HtlcBasepointDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_OutputSpendStatusDecodeErrorZ. -pub extern "C" fn CResult_OutputSpendStatusDecodeErrorZ_free(_res: CResult_OutputSpendStatusDecodeErrorZ) { } -impl Drop for CResult_OutputSpendStatusDecodeErrorZ { +/// Frees any resources used by the CResult_HtlcBasepointDecodeErrorZ. +pub extern "C" fn CResult_HtlcBasepointDecodeErrorZ_free(_res: CResult_HtlcBasepointDecodeErrorZ) { } +impl Drop for CResult_HtlcBasepointDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -27603,16 +29333,16 @@ impl Drop for CResult_OutputSpendStatusDecodeErrorZ { } } } -impl From> for CResult_OutputSpendStatusDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_HtlcBasepointDecodeErrorZ { + 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_OutputSpendStatusDecodeErrorZPtr { result } + CResult_HtlcBasepointDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_OutputSpendStatusDecodeErrorZPtr { err } + CResult_HtlcBasepointDecodeErrorZPtr { err } }; Self { contents, @@ -27620,137 +29350,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_OutputSpendStatusDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_HtlcBasepointDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_OutputSpendStatusDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_HtlcBasepointDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_OutputSpendStatusDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_HtlcBasepointDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_OutputSpendStatusDecodeErrorZ_clone(orig: &CResult_OutputSpendStatusDecodeErrorZ) -> CResult_OutputSpendStatusDecodeErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// An enum which can either contain a crate::lightning::chain::Filter or not -pub enum COption_FilterZ { - /// When we're in this state, this COption_FilterZ contains a crate::lightning::chain::Filter - Some(crate::lightning::chain::Filter), - /// When we're in this state, this COption_FilterZ contains nothing - None -} -impl COption_FilterZ { - #[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::Filter { - if let Self::Some(v) = self { v } else { unreachable!() } - } -} -#[no_mangle] -/// Constructs a new COption_FilterZ containing a crate::lightning::chain::Filter -pub extern "C" fn COption_FilterZ_some(o: crate::lightning::chain::Filter) -> COption_FilterZ { - COption_FilterZ::Some(o) -} -#[no_mangle] -/// Constructs a new COption_FilterZ containing nothing -pub extern "C" fn COption_FilterZ_none() -> COption_FilterZ { - COption_FilterZ::None -} -#[no_mangle] -/// Frees any resources associated with the crate::lightning::chain::Filter, if we are in the Some state -pub extern "C" fn COption_FilterZ_free(_res: COption_FilterZ) { } -#[repr(C)] -/// A dynamically-allocated array of crate::lightning::util::sweep::TrackedSpendableOutputs of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_TrackedSpendableOutputZ { - /// 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::sweep::TrackedSpendableOutput, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_TrackedSpendableOutputZ { - #[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::sweep::TrackedSpendableOutput] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_TrackedSpendableOutputZ { - 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_TrackedSpendableOutputZ_free(_res: CVec_TrackedSpendableOutputZ) { } -impl Drop for CVec_TrackedSpendableOutputZ { - 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_TrackedSpendableOutputZ { - 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_HtlcBasepointDecodeErrorZ_clone(orig: &CResult_HtlcBasepointDecodeErrorZ) -> CResult_HtlcBasepointDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_OutputSweeperDecodeErrorZ -pub union CResult_OutputSweeperDecodeErrorZPtr { +/// The contents of CResult_HtlcKeyDecodeErrorZ +pub union CResult_HtlcKeyDecodeErrorZPtr { /// 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::sweep::OutputSweeper, + pub result: *mut crate::lightning::ln::channel_keys::HtlcKey, /// 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_OutputSweeperDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::util::sweep::OutputSweeper on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_HtlcKeyDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::channel_keys::HtlcKey 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_OutputSweeperDecodeErrorZ { - /// The contents of this CResult_OutputSweeperDecodeErrorZ, accessible via either +pub struct CResult_HtlcKeyDecodeErrorZ { + /// The contents of this CResult_HtlcKeyDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_OutputSweeperDecodeErrorZPtr, - /// Whether this CResult_OutputSweeperDecodeErrorZ represents a success state. + pub contents: CResult_HtlcKeyDecodeErrorZPtr, + /// Whether this CResult_HtlcKeyDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_OutputSweeperDecodeErrorZ in the success state. -pub extern "C" fn CResult_OutputSweeperDecodeErrorZ_ok(o: crate::lightning::util::sweep::OutputSweeper) -> CResult_OutputSweeperDecodeErrorZ { - CResult_OutputSweeperDecodeErrorZ { - contents: CResult_OutputSweeperDecodeErrorZPtr { +/// Creates a new CResult_HtlcKeyDecodeErrorZ in the success state. +pub extern "C" fn CResult_HtlcKeyDecodeErrorZ_ok(o: crate::lightning::ln::channel_keys::HtlcKey) -> CResult_HtlcKeyDecodeErrorZ { + CResult_HtlcKeyDecodeErrorZ { + contents: CResult_HtlcKeyDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_OutputSweeperDecodeErrorZ in the error state. -pub extern "C" fn CResult_OutputSweeperDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_OutputSweeperDecodeErrorZ { - CResult_OutputSweeperDecodeErrorZ { - contents: CResult_OutputSweeperDecodeErrorZPtr { +/// Creates a new CResult_HtlcKeyDecodeErrorZ in the error state. +pub extern "C" fn CResult_HtlcKeyDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_HtlcKeyDecodeErrorZ { + CResult_HtlcKeyDecodeErrorZ { + contents: CResult_HtlcKeyDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -27758,13 +29410,13 @@ pub extern "C" fn CResult_OutputSweeperDecodeErrorZ_err(e: crate::lightning::ln: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_OutputSweeperDecodeErrorZ_is_ok(o: &CResult_OutputSweeperDecodeErrorZ) -> bool { +pub extern "C" fn CResult_HtlcKeyDecodeErrorZ_is_ok(o: &CResult_HtlcKeyDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_OutputSweeperDecodeErrorZ. -pub extern "C" fn CResult_OutputSweeperDecodeErrorZ_free(_res: CResult_OutputSweeperDecodeErrorZ) { } -impl Drop for CResult_OutputSweeperDecodeErrorZ { +/// Frees any resources used by the CResult_HtlcKeyDecodeErrorZ. +pub extern "C" fn CResult_HtlcKeyDecodeErrorZ_free(_res: CResult_HtlcKeyDecodeErrorZ) { } +impl Drop for CResult_HtlcKeyDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -27777,16 +29429,16 @@ impl Drop for CResult_OutputSweeperDecodeErrorZ { } } } -impl From> for CResult_OutputSweeperDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_HtlcKeyDecodeErrorZ { + 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_OutputSweeperDecodeErrorZPtr { result } + CResult_HtlcKeyDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_OutputSweeperDecodeErrorZPtr { err } + CResult_HtlcKeyDecodeErrorZPtr { err } }; Self { contents, @@ -27794,72 +29446,59 @@ impl From for C2Tuple_BestBlockOutputSweeperZ { - fn from (tup: (crate::lightning::chain::BestBlock, crate::lightning::util::sweep::OutputSweeper)) -> Self { - Self { - a: tup.0, - b: tup.1, +impl Clone for CResult_HtlcKeyDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_HtlcKeyDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_HtlcKeyDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } } } } -impl C2Tuple_BestBlockOutputSweeperZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::lightning::chain::BestBlock, crate::lightning::util::sweep::OutputSweeper) { - (self.a, self.b) - } -} -/// Creates a new C2Tuple_BestBlockOutputSweeperZ from the contained elements. -#[no_mangle] -pub extern "C" fn C2Tuple_BestBlockOutputSweeperZ_new(a: crate::lightning::chain::BestBlock, b: crate::lightning::util::sweep::OutputSweeper) -> C2Tuple_BestBlockOutputSweeperZ { - C2Tuple_BestBlockOutputSweeperZ { a, b, } -} - #[no_mangle] -/// Frees any resources used by the C2Tuple_BestBlockOutputSweeperZ. -pub extern "C" fn C2Tuple_BestBlockOutputSweeperZ_free(_res: C2Tuple_BestBlockOutputSweeperZ) { } +/// Creates a new CResult_HtlcKeyDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_HtlcKeyDecodeErrorZ_clone(orig: &CResult_HtlcKeyDecodeErrorZ) -> CResult_HtlcKeyDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ -pub union CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZPtr { +/// The contents of CResult_RevocationBasepointDecodeErrorZ +pub union CResult_RevocationBasepointDecodeErrorZPtr { /// 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_BestBlockOutputSweeperZ, + pub result: *mut crate::lightning::ln::channel_keys::RevocationBasepoint, /// 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_BestBlockOutputSweeperZDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::C2Tuple_BestBlockOutputSweeperZ on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_RevocationBasepointDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::channel_keys::RevocationBasepoint 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_BestBlockOutputSweeperZDecodeErrorZ { - /// The contents of this CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ, accessible via either +pub struct CResult_RevocationBasepointDecodeErrorZ { + /// The contents of this CResult_RevocationBasepointDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZPtr, - /// Whether this CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ represents a success state. + pub contents: CResult_RevocationBasepointDecodeErrorZPtr, + /// Whether this CResult_RevocationBasepointDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ in the success state. -pub extern "C" fn CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ_ok(o: crate::c_types::derived::C2Tuple_BestBlockOutputSweeperZ) -> CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ { - CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ { - contents: CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZPtr { +/// Creates a new CResult_RevocationBasepointDecodeErrorZ in the success state. +pub extern "C" fn CResult_RevocationBasepointDecodeErrorZ_ok(o: crate::lightning::ln::channel_keys::RevocationBasepoint) -> CResult_RevocationBasepointDecodeErrorZ { + CResult_RevocationBasepointDecodeErrorZ { + contents: CResult_RevocationBasepointDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ in the error state. -pub extern "C" fn CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ { - CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ { - contents: CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZPtr { +/// Creates a new CResult_RevocationBasepointDecodeErrorZ in the error state. +pub extern "C" fn CResult_RevocationBasepointDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_RevocationBasepointDecodeErrorZ { + CResult_RevocationBasepointDecodeErrorZ { + contents: CResult_RevocationBasepointDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -27867,13 +29506,13 @@ pub extern "C" fn CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ_err(e: cra } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ_is_ok(o: &CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ) -> bool { +pub extern "C" fn CResult_RevocationBasepointDecodeErrorZ_is_ok(o: &CResult_RevocationBasepointDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ. -pub extern "C" fn CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ_free(_res: CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ) { } -impl Drop for CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ { +/// Frees any resources used by the CResult_RevocationBasepointDecodeErrorZ. +pub extern "C" fn CResult_RevocationBasepointDecodeErrorZ_free(_res: CResult_RevocationBasepointDecodeErrorZ) { } +impl Drop for CResult_RevocationBasepointDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -27886,16 +29525,16 @@ impl Drop for CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ { } } } -impl From> for CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_RevocationBasepointDecodeErrorZ { + 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_BestBlockOutputSweeperZDecodeErrorZPtr { result } + CResult_RevocationBasepointDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZPtr { err } + CResult_RevocationBasepointDecodeErrorZPtr { err } }; Self { contents, @@ -27903,42 +29542,59 @@ impl From Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_RevocationBasepointDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_RevocationBasepointDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_RevocationBasepointDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_RevocationBasepointDecodeErrorZ_clone(orig: &CResult_RevocationBasepointDecodeErrorZ) -> CResult_RevocationBasepointDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_DelayedPaymentBasepointDecodeErrorZ -pub union CResult_DelayedPaymentBasepointDecodeErrorZPtr { +/// The contents of CResult_RevocationKeyDecodeErrorZ +pub union CResult_RevocationKeyDecodeErrorZPtr { /// 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::channel_keys::DelayedPaymentBasepoint, + pub result: *mut crate::lightning::ln::channel_keys::RevocationKey, /// 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_DelayedPaymentBasepointDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::channel_keys::DelayedPaymentBasepoint on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_RevocationKeyDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::channel_keys::RevocationKey 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_DelayedPaymentBasepointDecodeErrorZ { - /// The contents of this CResult_DelayedPaymentBasepointDecodeErrorZ, accessible via either +pub struct CResult_RevocationKeyDecodeErrorZ { + /// The contents of this CResult_RevocationKeyDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_DelayedPaymentBasepointDecodeErrorZPtr, - /// Whether this CResult_DelayedPaymentBasepointDecodeErrorZ represents a success state. + pub contents: CResult_RevocationKeyDecodeErrorZPtr, + /// Whether this CResult_RevocationKeyDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_DelayedPaymentBasepointDecodeErrorZ in the success state. -pub extern "C" fn CResult_DelayedPaymentBasepointDecodeErrorZ_ok(o: crate::lightning::ln::channel_keys::DelayedPaymentBasepoint) -> CResult_DelayedPaymentBasepointDecodeErrorZ { - CResult_DelayedPaymentBasepointDecodeErrorZ { - contents: CResult_DelayedPaymentBasepointDecodeErrorZPtr { +/// Creates a new CResult_RevocationKeyDecodeErrorZ in the success state. +pub extern "C" fn CResult_RevocationKeyDecodeErrorZ_ok(o: crate::lightning::ln::channel_keys::RevocationKey) -> CResult_RevocationKeyDecodeErrorZ { + CResult_RevocationKeyDecodeErrorZ { + contents: CResult_RevocationKeyDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_DelayedPaymentBasepointDecodeErrorZ in the error state. -pub extern "C" fn CResult_DelayedPaymentBasepointDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_DelayedPaymentBasepointDecodeErrorZ { - CResult_DelayedPaymentBasepointDecodeErrorZ { - contents: CResult_DelayedPaymentBasepointDecodeErrorZPtr { +/// Creates a new CResult_RevocationKeyDecodeErrorZ in the error state. +pub extern "C" fn CResult_RevocationKeyDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_RevocationKeyDecodeErrorZ { + CResult_RevocationKeyDecodeErrorZ { + contents: CResult_RevocationKeyDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -27946,13 +29602,13 @@ pub extern "C" fn CResult_DelayedPaymentBasepointDecodeErrorZ_err(e: crate::ligh } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_DelayedPaymentBasepointDecodeErrorZ_is_ok(o: &CResult_DelayedPaymentBasepointDecodeErrorZ) -> bool { +pub extern "C" fn CResult_RevocationKeyDecodeErrorZ_is_ok(o: &CResult_RevocationKeyDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_DelayedPaymentBasepointDecodeErrorZ. -pub extern "C" fn CResult_DelayedPaymentBasepointDecodeErrorZ_free(_res: CResult_DelayedPaymentBasepointDecodeErrorZ) { } -impl Drop for CResult_DelayedPaymentBasepointDecodeErrorZ { +/// Frees any resources used by the CResult_RevocationKeyDecodeErrorZ. +pub extern "C" fn CResult_RevocationKeyDecodeErrorZ_free(_res: CResult_RevocationKeyDecodeErrorZ) { } +impl Drop for CResult_RevocationKeyDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -27965,16 +29621,16 @@ impl Drop for CResult_DelayedPaymentBasepointDecodeErrorZ { } } } -impl From> for CResult_DelayedPaymentBasepointDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_RevocationKeyDecodeErrorZ { + 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_DelayedPaymentBasepointDecodeErrorZPtr { result } + CResult_RevocationKeyDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_DelayedPaymentBasepointDecodeErrorZPtr { err } + CResult_RevocationKeyDecodeErrorZPtr { err } }; Self { contents, @@ -27982,251 +29638,310 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_DelayedPaymentBasepointDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_RevocationKeyDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_DelayedPaymentBasepointDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_RevocationKeyDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_DelayedPaymentBasepointDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_RevocationKeyDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_DelayedPaymentBasepointDecodeErrorZ_clone(orig: &CResult_DelayedPaymentBasepointDecodeErrorZ) -> CResult_DelayedPaymentBasepointDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_RevocationKeyDecodeErrorZ_clone(orig: &CResult_RevocationKeyDecodeErrorZ) -> CResult_RevocationKeyDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_DelayedPaymentKeyDecodeErrorZ -pub union CResult_DelayedPaymentKeyDecodeErrorZPtr { +/// The contents of CResult_LockedChannelMonitorNoneZ +pub union CResult_LockedChannelMonitorNoneZPtr { /// 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::channel_keys::DelayedPaymentKey, - /// 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::chain::chainmonitor::LockedChannelMonitor, + /// 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_DelayedPaymentKeyDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::channel_keys::DelayedPaymentKey on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// 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`. -pub struct CResult_DelayedPaymentKeyDecodeErrorZ { - /// The contents of this CResult_DelayedPaymentKeyDecodeErrorZ, accessible via either +pub struct CResult_LockedChannelMonitorNoneZ { + /// The contents of this CResult_LockedChannelMonitorNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_DelayedPaymentKeyDecodeErrorZPtr, - /// Whether this CResult_DelayedPaymentKeyDecodeErrorZ represents a success state. + pub contents: CResult_LockedChannelMonitorNoneZPtr, + /// Whether this CResult_LockedChannelMonitorNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_DelayedPaymentKeyDecodeErrorZ in the success state. -pub extern "C" fn CResult_DelayedPaymentKeyDecodeErrorZ_ok(o: crate::lightning::ln::channel_keys::DelayedPaymentKey) -> CResult_DelayedPaymentKeyDecodeErrorZ { - CResult_DelayedPaymentKeyDecodeErrorZ { - contents: CResult_DelayedPaymentKeyDecodeErrorZPtr { +/// Creates a new CResult_LockedChannelMonitorNoneZ in the success state. +pub extern "C" fn CResult_LockedChannelMonitorNoneZ_ok(o: crate::lightning::chain::chainmonitor::LockedChannelMonitor) -> CResult_LockedChannelMonitorNoneZ { + CResult_LockedChannelMonitorNoneZ { + contents: CResult_LockedChannelMonitorNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_DelayedPaymentKeyDecodeErrorZ in the error state. -pub extern "C" fn CResult_DelayedPaymentKeyDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_DelayedPaymentKeyDecodeErrorZ { - CResult_DelayedPaymentKeyDecodeErrorZ { - contents: CResult_DelayedPaymentKeyDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), +/// Creates a new CResult_LockedChannelMonitorNoneZ in the error state. +pub extern "C" fn CResult_LockedChannelMonitorNoneZ_err() -> CResult_LockedChannelMonitorNoneZ { + CResult_LockedChannelMonitorNoneZ { + contents: CResult_LockedChannelMonitorNoneZPtr { + 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_DelayedPaymentKeyDecodeErrorZ_is_ok(o: &CResult_DelayedPaymentKeyDecodeErrorZ) -> bool { - o.result_ok -} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_LockedChannelMonitorNoneZ_is_ok(o: &CResult_LockedChannelMonitorNoneZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_LockedChannelMonitorNoneZ. +pub extern "C" fn CResult_LockedChannelMonitorNoneZ_free(_res: CResult_LockedChannelMonitorNoneZ) { } +impl Drop for CResult_LockedChannelMonitorNoneZ { + 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 { + } + } +} +impl From> for CResult_LockedChannelMonitorNoneZ { + 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_LockedChannelMonitorNoneZPtr { result } + } else { + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_LockedChannelMonitorNoneZPtr { err: core::ptr::null_mut() } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +#[repr(C)] +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_OutPointChannelIdZ { + /// The element at position 0 + pub a: crate::lightning::chain::transaction::OutPoint, + /// The element at position 1 + pub b: crate::lightning::ln::types::ChannelId, +} +impl From<(crate::lightning::chain::transaction::OutPoint, crate::lightning::ln::types::ChannelId)> for C2Tuple_OutPointChannelIdZ { + fn from (tup: (crate::lightning::chain::transaction::OutPoint, crate::lightning::ln::types::ChannelId)) -> Self { + Self { + a: tup.0, + b: tup.1, + } + } +} +impl C2Tuple_OutPointChannelIdZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::lightning::chain::transaction::OutPoint, crate::lightning::ln::types::ChannelId) { + (self.a, self.b) + } +} +impl Clone for C2Tuple_OutPointChannelIdZ { + 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_OutPointChannelIdZ_clone(orig: &C2Tuple_OutPointChannelIdZ) -> C2Tuple_OutPointChannelIdZ { Clone::clone(&orig) } +/// Creates a new C2Tuple_OutPointChannelIdZ from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_OutPointChannelIdZ_new(a: crate::lightning::chain::transaction::OutPoint, b: crate::lightning::ln::types::ChannelId) -> C2Tuple_OutPointChannelIdZ { + C2Tuple_OutPointChannelIdZ { a, b, } +} + +#[no_mangle] +/// Frees any resources used by the C2Tuple_OutPointChannelIdZ. +pub extern "C" fn C2Tuple_OutPointChannelIdZ_free(_res: C2Tuple_OutPointChannelIdZ) { } +#[repr(C)] +/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_OutPointChannelIdZs of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_C2Tuple_OutPointChannelIdZZ { + /// 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_OutPointChannelIdZ, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_C2Tuple_OutPointChannelIdZZ { + #[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_OutPointChannelIdZ] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_C2Tuple_OutPointChannelIdZZ { + 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_DelayedPaymentKeyDecodeErrorZ. -pub extern "C" fn CResult_DelayedPaymentKeyDecodeErrorZ_free(_res: CResult_DelayedPaymentKeyDecodeErrorZ) { } -impl Drop for CResult_DelayedPaymentKeyDecodeErrorZ { +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_C2Tuple_OutPointChannelIdZZ_free(_res: CVec_C2Tuple_OutPointChannelIdZZ) { } +impl Drop for CVec_C2Tuple_OutPointChannelIdZZ { 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_DelayedPaymentKeyDecodeErrorZ { - 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_DelayedPaymentKeyDecodeErrorZPtr { result } - } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_DelayedPaymentKeyDecodeErrorZPtr { err } - }; +impl Clone for CVec_C2Tuple_OutPointChannelIdZZ { + 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_OutPointCVec_u64ZZ { + /// The element at position 0 + pub a: crate::lightning::chain::transaction::OutPoint, + /// The element at position 1 + pub b: crate::c_types::derived::CVec_u64Z, +} +impl From<(crate::lightning::chain::transaction::OutPoint, crate::c_types::derived::CVec_u64Z)> for C2Tuple_OutPointCVec_u64ZZ { + fn from (tup: (crate::lightning::chain::transaction::OutPoint, crate::c_types::derived::CVec_u64Z)) -> Self { Self { - contents, - result_ok: o.result_ok, + a: tup.0, + b: tup.1, } } } -impl Clone for CResult_DelayedPaymentKeyDecodeErrorZ { +impl C2Tuple_OutPointCVec_u64ZZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::lightning::chain::transaction::OutPoint, crate::c_types::derived::CVec_u64Z) { + (self.a, self.b) + } +} +impl Clone for C2Tuple_OutPointCVec_u64ZZ { fn clone(&self) -> Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_DelayedPaymentKeyDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_DelayedPaymentKeyDecodeErrorZPtr { - 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_DelayedPaymentKeyDecodeErrorZ 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_DelayedPaymentKeyDecodeErrorZ_clone(orig: &CResult_DelayedPaymentKeyDecodeErrorZ) -> CResult_DelayedPaymentKeyDecodeErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// The contents of CResult_HtlcBasepointDecodeErrorZ -pub union CResult_HtlcBasepointDecodeErrorZPtr { - /// 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::channel_keys::HtlcBasepoint, - /// 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_OutPointCVec_u64ZZ_clone(orig: &C2Tuple_OutPointCVec_u64ZZ) -> C2Tuple_OutPointCVec_u64ZZ { Clone::clone(&orig) } +/// Creates a new C2Tuple_OutPointCVec_u64ZZ from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_OutPointCVec_u64ZZ_new(a: crate::lightning::chain::transaction::OutPoint, b: crate::c_types::derived::CVec_u64Z) -> C2Tuple_OutPointCVec_u64ZZ { + C2Tuple_OutPointCVec_u64ZZ { a, b, } } + +#[no_mangle] +/// Frees any resources used by the C2Tuple_OutPointCVec_u64ZZ. +pub extern "C" fn C2Tuple_OutPointCVec_u64ZZ_free(_res: C2Tuple_OutPointCVec_u64ZZ) { } #[repr(C)] -/// A CResult_HtlcBasepointDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::channel_keys::HtlcBasepoint 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_HtlcBasepointDecodeErrorZ { - /// The contents of this CResult_HtlcBasepointDecodeErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_HtlcBasepointDecodeErrorZPtr, - /// Whether this CResult_HtlcBasepointDecodeErrorZ represents a success state. - pub result_ok: bool, +/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_OutPointCVec_u64ZZs of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_C2Tuple_OutPointCVec_u64ZZZ { + /// 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_OutPointCVec_u64ZZ, + /// The number of elements pointed to by `data`. + pub datalen: usize } -#[no_mangle] -/// Creates a new CResult_HtlcBasepointDecodeErrorZ in the success state. -pub extern "C" fn CResult_HtlcBasepointDecodeErrorZ_ok(o: crate::lightning::ln::channel_keys::HtlcBasepoint) -> CResult_HtlcBasepointDecodeErrorZ { - CResult_HtlcBasepointDecodeErrorZ { - contents: CResult_HtlcBasepointDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, +impl CVec_C2Tuple_OutPointCVec_u64ZZZ { + #[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_HtlcBasepointDecodeErrorZ in the error state. -pub extern "C" fn CResult_HtlcBasepointDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_HtlcBasepointDecodeErrorZ { - CResult_HtlcBasepointDecodeErrorZ { - contents: CResult_HtlcBasepointDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), - }, - result_ok: false, + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_OutPointCVec_u64ZZ] { + 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_HtlcBasepointDecodeErrorZ_is_ok(o: &CResult_HtlcBasepointDecodeErrorZ) -> bool { - o.result_ok +impl From> for CVec_C2Tuple_OutPointCVec_u64ZZZ { + 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_HtlcBasepointDecodeErrorZ. -pub extern "C" fn CResult_HtlcBasepointDecodeErrorZ_free(_res: CResult_HtlcBasepointDecodeErrorZ) { } -impl Drop for CResult_HtlcBasepointDecodeErrorZ { +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_C2Tuple_OutPointCVec_u64ZZZ_free(_res: CVec_C2Tuple_OutPointCVec_u64ZZZ) { } +impl Drop for CVec_C2Tuple_OutPointCVec_u64ZZZ { 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_HtlcBasepointDecodeErrorZ { - 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_HtlcBasepointDecodeErrorZPtr { result } - } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_HtlcBasepointDecodeErrorZPtr { 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_HtlcBasepointDecodeErrorZ { +impl Clone for CVec_C2Tuple_OutPointCVec_u64ZZZ { fn clone(&self) -> Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_HtlcBasepointDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_HtlcBasepointDecodeErrorZPtr { - 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_HtlcBasepointDecodeErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_HtlcBasepointDecodeErrorZ_clone(orig: &CResult_HtlcBasepointDecodeErrorZ) -> CResult_HtlcBasepointDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_HtlcKeyDecodeErrorZ -pub union CResult_HtlcKeyDecodeErrorZPtr { +/// The contents of CResult_BlindedMessagePathDecodeErrorZ +pub union CResult_BlindedMessagePathDecodeErrorZPtr { /// 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::channel_keys::HtlcKey, + pub result: *mut crate::lightning::blinded_path::message::BlindedMessagePath, /// 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_HtlcKeyDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::channel_keys::HtlcKey on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_BlindedMessagePathDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::blinded_path::message::BlindedMessagePath 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_HtlcKeyDecodeErrorZ { - /// The contents of this CResult_HtlcKeyDecodeErrorZ, accessible via either +pub struct CResult_BlindedMessagePathDecodeErrorZ { + /// The contents of this CResult_BlindedMessagePathDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_HtlcKeyDecodeErrorZPtr, - /// Whether this CResult_HtlcKeyDecodeErrorZ represents a success state. + pub contents: CResult_BlindedMessagePathDecodeErrorZPtr, + /// Whether this CResult_BlindedMessagePathDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_HtlcKeyDecodeErrorZ in the success state. -pub extern "C" fn CResult_HtlcKeyDecodeErrorZ_ok(o: crate::lightning::ln::channel_keys::HtlcKey) -> CResult_HtlcKeyDecodeErrorZ { - CResult_HtlcKeyDecodeErrorZ { - contents: CResult_HtlcKeyDecodeErrorZPtr { +/// Creates a new CResult_BlindedMessagePathDecodeErrorZ in the success state. +pub extern "C" fn CResult_BlindedMessagePathDecodeErrorZ_ok(o: crate::lightning::blinded_path::message::BlindedMessagePath) -> CResult_BlindedMessagePathDecodeErrorZ { + CResult_BlindedMessagePathDecodeErrorZ { + contents: CResult_BlindedMessagePathDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_HtlcKeyDecodeErrorZ in the error state. -pub extern "C" fn CResult_HtlcKeyDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_HtlcKeyDecodeErrorZ { - CResult_HtlcKeyDecodeErrorZ { - contents: CResult_HtlcKeyDecodeErrorZPtr { +/// Creates a new CResult_BlindedMessagePathDecodeErrorZ in the error state. +pub extern "C" fn CResult_BlindedMessagePathDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_BlindedMessagePathDecodeErrorZ { + CResult_BlindedMessagePathDecodeErrorZ { + contents: CResult_BlindedMessagePathDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -28234,13 +29949,13 @@ pub extern "C" fn CResult_HtlcKeyDecodeErrorZ_err(e: crate::lightning::ln::msgs: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_HtlcKeyDecodeErrorZ_is_ok(o: &CResult_HtlcKeyDecodeErrorZ) -> bool { +pub extern "C" fn CResult_BlindedMessagePathDecodeErrorZ_is_ok(o: &CResult_BlindedMessagePathDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_HtlcKeyDecodeErrorZ. -pub extern "C" fn CResult_HtlcKeyDecodeErrorZ_free(_res: CResult_HtlcKeyDecodeErrorZ) { } -impl Drop for CResult_HtlcKeyDecodeErrorZ { +/// Frees any resources used by the CResult_BlindedMessagePathDecodeErrorZ. +pub extern "C" fn CResult_BlindedMessagePathDecodeErrorZ_free(_res: CResult_BlindedMessagePathDecodeErrorZ) { } +impl Drop for CResult_BlindedMessagePathDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -28253,16 +29968,16 @@ impl Drop for CResult_HtlcKeyDecodeErrorZ { } } } -impl From> for CResult_HtlcKeyDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_BlindedMessagePathDecodeErrorZ { + 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_HtlcKeyDecodeErrorZPtr { result } + CResult_BlindedMessagePathDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_HtlcKeyDecodeErrorZPtr { err } + CResult_BlindedMessagePathDecodeErrorZPtr { err } }; Self { contents, @@ -28270,95 +29985,91 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_HtlcKeyDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_BlindedMessagePathDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_HtlcKeyDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_BlindedMessagePathDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_HtlcKeyDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_BlindedMessagePathDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_HtlcKeyDecodeErrorZ_clone(orig: &CResult_HtlcKeyDecodeErrorZ) -> CResult_HtlcKeyDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_BlindedMessagePathDecodeErrorZ_clone(orig: &CResult_BlindedMessagePathDecodeErrorZ) -> CResult_BlindedMessagePathDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_RevocationBasepointDecodeErrorZ -pub union CResult_RevocationBasepointDecodeErrorZPtr { +/// The contents of CResult_BlindedMessagePathNoneZ +pub union CResult_BlindedMessagePathNoneZPtr { /// 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::channel_keys::RevocationBasepoint, - /// 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::message::BlindedMessagePath, + /// 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_RevocationBasepointDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::channel_keys::RevocationBasepoint on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_BlindedMessagePathNoneZ represents the result of a fallible operation, +/// containing a crate::lightning::blinded_path::message::BlindedMessagePath on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_RevocationBasepointDecodeErrorZ { - /// The contents of this CResult_RevocationBasepointDecodeErrorZ, accessible via either +pub struct CResult_BlindedMessagePathNoneZ { + /// The contents of this CResult_BlindedMessagePathNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_RevocationBasepointDecodeErrorZPtr, - /// Whether this CResult_RevocationBasepointDecodeErrorZ represents a success state. + pub contents: CResult_BlindedMessagePathNoneZPtr, + /// Whether this CResult_BlindedMessagePathNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_RevocationBasepointDecodeErrorZ in the success state. -pub extern "C" fn CResult_RevocationBasepointDecodeErrorZ_ok(o: crate::lightning::ln::channel_keys::RevocationBasepoint) -> CResult_RevocationBasepointDecodeErrorZ { - CResult_RevocationBasepointDecodeErrorZ { - contents: CResult_RevocationBasepointDecodeErrorZPtr { +/// Creates a new CResult_BlindedMessagePathNoneZ in the success state. +pub extern "C" fn CResult_BlindedMessagePathNoneZ_ok(o: crate::lightning::blinded_path::message::BlindedMessagePath) -> CResult_BlindedMessagePathNoneZ { + CResult_BlindedMessagePathNoneZ { + contents: CResult_BlindedMessagePathNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_RevocationBasepointDecodeErrorZ in the error state. -pub extern "C" fn CResult_RevocationBasepointDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_RevocationBasepointDecodeErrorZ { - CResult_RevocationBasepointDecodeErrorZ { - contents: CResult_RevocationBasepointDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), +/// Creates a new CResult_BlindedMessagePathNoneZ in the error state. +pub extern "C" fn CResult_BlindedMessagePathNoneZ_err() -> CResult_BlindedMessagePathNoneZ { + CResult_BlindedMessagePathNoneZ { + contents: CResult_BlindedMessagePathNoneZPtr { + 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_RevocationBasepointDecodeErrorZ_is_ok(o: &CResult_RevocationBasepointDecodeErrorZ) -> bool { +pub extern "C" fn CResult_BlindedMessagePathNoneZ_is_ok(o: &CResult_BlindedMessagePathNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_RevocationBasepointDecodeErrorZ. -pub extern "C" fn CResult_RevocationBasepointDecodeErrorZ_free(_res: CResult_RevocationBasepointDecodeErrorZ) { } -impl Drop for CResult_RevocationBasepointDecodeErrorZ { +/// Frees any resources used by the CResult_BlindedMessagePathNoneZ. +pub extern "C" fn CResult_BlindedMessagePathNoneZ_free(_res: CResult_BlindedMessagePathNoneZ) { } +impl Drop for CResult_BlindedMessagePathNoneZ { 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_RevocationBasepointDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_BlindedMessagePathNoneZ { + 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_RevocationBasepointDecodeErrorZPtr { result } + CResult_BlindedMessagePathNoneZPtr { result } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_RevocationBasepointDecodeErrorZPtr { err } + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_BlindedMessagePathNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -28366,59 +30077,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_RevocationBasepointDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_BlindedMessagePathNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_RevocationBasepointDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_BlindedMessagePathNoneZPtr { + err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_RevocationBasepointDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_BlindedMessagePathNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_RevocationBasepointDecodeErrorZ_clone(orig: &CResult_RevocationBasepointDecodeErrorZ) -> CResult_RevocationBasepointDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_BlindedMessagePathNoneZ_clone(orig: &CResult_BlindedMessagePathNoneZ) -> CResult_BlindedMessagePathNoneZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_RevocationKeyDecodeErrorZ -pub union CResult_RevocationKeyDecodeErrorZPtr { +/// The contents of CResult_MessageContextDecodeErrorZ +pub union CResult_MessageContextDecodeErrorZPtr { /// 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::channel_keys::RevocationKey, + pub result: *mut crate::lightning::blinded_path::message::MessageContext, /// 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_RevocationKeyDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::channel_keys::RevocationKey on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_MessageContextDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::blinded_path::message::MessageContext 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_RevocationKeyDecodeErrorZ { - /// The contents of this CResult_RevocationKeyDecodeErrorZ, accessible via either +pub struct CResult_MessageContextDecodeErrorZ { + /// The contents of this CResult_MessageContextDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_RevocationKeyDecodeErrorZPtr, - /// Whether this CResult_RevocationKeyDecodeErrorZ represents a success state. + pub contents: CResult_MessageContextDecodeErrorZPtr, + /// Whether this CResult_MessageContextDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_RevocationKeyDecodeErrorZ in the success state. -pub extern "C" fn CResult_RevocationKeyDecodeErrorZ_ok(o: crate::lightning::ln::channel_keys::RevocationKey) -> CResult_RevocationKeyDecodeErrorZ { - CResult_RevocationKeyDecodeErrorZ { - contents: CResult_RevocationKeyDecodeErrorZPtr { +/// Creates a new CResult_MessageContextDecodeErrorZ in the success state. +pub extern "C" fn CResult_MessageContextDecodeErrorZ_ok(o: crate::lightning::blinded_path::message::MessageContext) -> CResult_MessageContextDecodeErrorZ { + CResult_MessageContextDecodeErrorZ { + contents: CResult_MessageContextDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_RevocationKeyDecodeErrorZ in the error state. -pub extern "C" fn CResult_RevocationKeyDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_RevocationKeyDecodeErrorZ { - CResult_RevocationKeyDecodeErrorZ { - contents: CResult_RevocationKeyDecodeErrorZPtr { +/// Creates a new CResult_MessageContextDecodeErrorZ in the error state. +pub extern "C" fn CResult_MessageContextDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_MessageContextDecodeErrorZ { + CResult_MessageContextDecodeErrorZ { + contents: CResult_MessageContextDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -28426,13 +30137,13 @@ pub extern "C" fn CResult_RevocationKeyDecodeErrorZ_err(e: crate::lightning::ln: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_RevocationKeyDecodeErrorZ_is_ok(o: &CResult_RevocationKeyDecodeErrorZ) -> bool { +pub extern "C" fn CResult_MessageContextDecodeErrorZ_is_ok(o: &CResult_MessageContextDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_RevocationKeyDecodeErrorZ. -pub extern "C" fn CResult_RevocationKeyDecodeErrorZ_free(_res: CResult_RevocationKeyDecodeErrorZ) { } -impl Drop for CResult_RevocationKeyDecodeErrorZ { +/// Frees any resources used by the CResult_MessageContextDecodeErrorZ. +pub extern "C" fn CResult_MessageContextDecodeErrorZ_free(_res: CResult_MessageContextDecodeErrorZ) { } +impl Drop for CResult_MessageContextDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -28445,16 +30156,16 @@ impl Drop for CResult_RevocationKeyDecodeErrorZ { } } } -impl From> for CResult_RevocationKeyDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_MessageContextDecodeErrorZ { + 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_RevocationKeyDecodeErrorZPtr { result } + CResult_MessageContextDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_RevocationKeyDecodeErrorZPtr { err } + CResult_MessageContextDecodeErrorZPtr { err } }; Self { contents, @@ -28462,91 +30173,95 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_RevocationKeyDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_MessageContextDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_RevocationKeyDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_MessageContextDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_RevocationKeyDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_MessageContextDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_RevocationKeyDecodeErrorZ_clone(orig: &CResult_RevocationKeyDecodeErrorZ) -> CResult_RevocationKeyDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_MessageContextDecodeErrorZ_clone(orig: &CResult_MessageContextDecodeErrorZ) -> CResult_MessageContextDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_LockedChannelMonitorNoneZ -pub union CResult_LockedChannelMonitorNoneZPtr { +/// The contents of CResult_OffersContextDecodeErrorZ +pub union CResult_OffersContextDecodeErrorZPtr { /// 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::chainmonitor::LockedChannelMonitor, - /// 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::blinded_path::message::OffersContext, + /// 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_LockedChannelMonitorNoneZ represents the result of a fallible operation, -/// containing a crate::lightning::chain::chainmonitor::LockedChannelMonitor on success and a () on failure. +/// A CResult_OffersContextDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::blinded_path::message::OffersContext 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_LockedChannelMonitorNoneZ { - /// The contents of this CResult_LockedChannelMonitorNoneZ, accessible via either +pub struct CResult_OffersContextDecodeErrorZ { + /// The contents of this CResult_OffersContextDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_LockedChannelMonitorNoneZPtr, - /// Whether this CResult_LockedChannelMonitorNoneZ represents a success state. + pub contents: CResult_OffersContextDecodeErrorZPtr, + /// Whether this CResult_OffersContextDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_LockedChannelMonitorNoneZ in the success state. -pub extern "C" fn CResult_LockedChannelMonitorNoneZ_ok(o: crate::lightning::chain::chainmonitor::LockedChannelMonitor) -> CResult_LockedChannelMonitorNoneZ { - CResult_LockedChannelMonitorNoneZ { - contents: CResult_LockedChannelMonitorNoneZPtr { +/// Creates a new CResult_OffersContextDecodeErrorZ in the success state. +pub extern "C" fn CResult_OffersContextDecodeErrorZ_ok(o: crate::lightning::blinded_path::message::OffersContext) -> CResult_OffersContextDecodeErrorZ { + CResult_OffersContextDecodeErrorZ { + contents: CResult_OffersContextDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_LockedChannelMonitorNoneZ in the error state. -pub extern "C" fn CResult_LockedChannelMonitorNoneZ_err() -> CResult_LockedChannelMonitorNoneZ { - CResult_LockedChannelMonitorNoneZ { - contents: CResult_LockedChannelMonitorNoneZPtr { - err: core::ptr::null_mut(), +/// Creates a new CResult_OffersContextDecodeErrorZ in the error state. +pub extern "C" fn CResult_OffersContextDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_OffersContextDecodeErrorZ { + CResult_OffersContextDecodeErrorZ { + contents: CResult_OffersContextDecodeErrorZPtr { + 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_LockedChannelMonitorNoneZ_is_ok(o: &CResult_LockedChannelMonitorNoneZ) -> bool { +pub extern "C" fn CResult_OffersContextDecodeErrorZ_is_ok(o: &CResult_OffersContextDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_LockedChannelMonitorNoneZ. -pub extern "C" fn CResult_LockedChannelMonitorNoneZ_free(_res: CResult_LockedChannelMonitorNoneZ) { } -impl Drop for CResult_LockedChannelMonitorNoneZ { +/// Frees any resources used by the CResult_OffersContextDecodeErrorZ. +pub extern "C" fn CResult_OffersContextDecodeErrorZ_free(_res: CResult_OffersContextDecodeErrorZ) { } +impl Drop for CResult_OffersContextDecodeErrorZ { 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_LockedChannelMonitorNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_OffersContextDecodeErrorZ { + 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_LockedChannelMonitorNoneZPtr { result } + CResult_OffersContextDecodeErrorZPtr { result } } else { - let _ = unsafe { Box::from_raw(o.contents.err) }; - o.contents.err = core::ptr::null_mut(); - CResult_LockedChannelMonitorNoneZPtr { err: core::ptr::null_mut() } + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_OffersContextDecodeErrorZPtr { err } }; Self { contents, @@ -28554,225 +30269,20 @@ impl From for C2Tuple_OutPointChannelIdZ { - fn from (tup: (crate::lightning::chain::transaction::OutPoint, crate::lightning::ln::types::ChannelId)) -> Self { - Self { - a: tup.0, - b: tup.1, - } - } -} -impl C2Tuple_OutPointChannelIdZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::lightning::chain::transaction::OutPoint, crate::lightning::ln::types::ChannelId) { - (self.a, self.b) - } -} -impl Clone for C2Tuple_OutPointChannelIdZ { - 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_OutPointChannelIdZ_clone(orig: &C2Tuple_OutPointChannelIdZ) -> C2Tuple_OutPointChannelIdZ { Clone::clone(&orig) } -/// Creates a new C2Tuple_OutPointChannelIdZ from the contained elements. -#[no_mangle] -pub extern "C" fn C2Tuple_OutPointChannelIdZ_new(a: crate::lightning::chain::transaction::OutPoint, b: crate::lightning::ln::types::ChannelId) -> C2Tuple_OutPointChannelIdZ { - C2Tuple_OutPointChannelIdZ { a, b, } -} - -#[no_mangle] -/// Frees any resources used by the C2Tuple_OutPointChannelIdZ. -pub extern "C" fn C2Tuple_OutPointChannelIdZ_free(_res: C2Tuple_OutPointChannelIdZ) { } -#[repr(C)] -/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_OutPointChannelIdZs of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_C2Tuple_OutPointChannelIdZZ { - /// 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_OutPointChannelIdZ, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_C2Tuple_OutPointChannelIdZZ { - #[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_OutPointChannelIdZ] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_C2Tuple_OutPointChannelIdZZ { - 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_OutPointChannelIdZZ_free(_res: CVec_C2Tuple_OutPointChannelIdZZ) { } -impl Drop for CVec_C2Tuple_OutPointChannelIdZZ { - 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_OutPointChannelIdZZ { - 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::chainmonitor::MonitorUpdateIds of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_MonitorUpdateIdZ { - /// 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::chainmonitor::MonitorUpdateId, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_MonitorUpdateIdZ { - #[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::chainmonitor::MonitorUpdateId] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_MonitorUpdateIdZ { - 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_MonitorUpdateIdZ_free(_res: CVec_MonitorUpdateIdZ) { } -impl Drop for CVec_MonitorUpdateIdZ { - 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_MonitorUpdateIdZ { - 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_OutPointCVec_MonitorUpdateIdZZ { - /// The element at position 0 - pub a: crate::lightning::chain::transaction::OutPoint, - /// The element at position 1 - pub b: crate::c_types::derived::CVec_MonitorUpdateIdZ, -} -impl From<(crate::lightning::chain::transaction::OutPoint, crate::c_types::derived::CVec_MonitorUpdateIdZ)> for C2Tuple_OutPointCVec_MonitorUpdateIdZZ { - fn from (tup: (crate::lightning::chain::transaction::OutPoint, crate::c_types::derived::CVec_MonitorUpdateIdZ)) -> Self { - Self { - a: tup.0, - b: tup.1, - } - } -} -impl C2Tuple_OutPointCVec_MonitorUpdateIdZZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::lightning::chain::transaction::OutPoint, crate::c_types::derived::CVec_MonitorUpdateIdZ) { - (self.a, self.b) - } -} -impl Clone for C2Tuple_OutPointCVec_MonitorUpdateIdZZ { +impl Clone for CResult_OffersContextDecodeErrorZ { 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_OffersContextDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_OffersContextDecodeErrorZPtr { + 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_OffersContextDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C2Tuple_OutPointCVec_MonitorUpdateIdZZ_clone(orig: &C2Tuple_OutPointCVec_MonitorUpdateIdZZ) -> C2Tuple_OutPointCVec_MonitorUpdateIdZZ { Clone::clone(&orig) } -/// Creates a new C2Tuple_OutPointCVec_MonitorUpdateIdZZ from the contained elements. -#[no_mangle] -pub extern "C" fn C2Tuple_OutPointCVec_MonitorUpdateIdZZ_new(a: crate::lightning::chain::transaction::OutPoint, b: crate::c_types::derived::CVec_MonitorUpdateIdZ) -> C2Tuple_OutPointCVec_MonitorUpdateIdZZ { - C2Tuple_OutPointCVec_MonitorUpdateIdZZ { a, b, } -} - -#[no_mangle] -/// Frees any resources used by the C2Tuple_OutPointCVec_MonitorUpdateIdZZ. -pub extern "C" fn C2Tuple_OutPointCVec_MonitorUpdateIdZZ_free(_res: C2Tuple_OutPointCVec_MonitorUpdateIdZZ) { } -#[repr(C)] -/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_OutPointCVec_MonitorUpdateIdZZs of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ { - /// 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_OutPointCVec_MonitorUpdateIdZZ, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ { - #[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_OutPointCVec_MonitorUpdateIdZZ] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ { - 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_OutPointCVec_MonitorUpdateIdZZZ_free(_res: CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ) { } -impl Drop for CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ { - 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_OutPointCVec_MonitorUpdateIdZZZ { - 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_OffersContextDecodeErrorZ_clone(orig: &CResult_OffersContextDecodeErrorZ) -> CResult_OffersContextDecodeErrorZ { Clone::clone(&orig) } diff --git a/lightning-c-bindings/src/lib.rs b/lightning-c-bindings/src/lib.rs index 53abe8a..a076598 100644 --- a/lightning-c-bindings/src/lib.rs +++ b/lightning-c-bindings/src/lib.rs @@ -24,6 +24,7 @@ pub mod version; pub mod c_types; pub mod bitcoin; pub mod lightning; +pub mod lightning_types; pub mod lightning_persister; pub mod lightning_background_processor; pub mod lightning_invoice; diff --git a/lightning-c-bindings/src/lightning/blinded_path/message.rs b/lightning-c-bindings/src/lightning/blinded_path/message.rs new file mode 100644 index 0000000..382a728 --- /dev/null +++ b/lightning-c-bindings/src/lightning/blinded_path/message.rs @@ -0,0 +1,870 @@ +// 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 methods for constructing [`BlindedMessagePath`]s to send a message over. + +use alloc::str::FromStr; +use alloc::string::String; +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::blinded_path::message::BlindedMessagePath as nativeBlindedMessagePathImport; +pub(crate) type nativeBlindedMessagePath = nativeBlindedMessagePathImport; + +/// A blinded path to be used for sending or receiving a message, hiding the identity of the +/// recipient. +#[must_use] +#[repr(C)] +pub struct BlindedMessagePath { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, 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 nativeBlindedMessagePath, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust 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 core::ops::Deref for BlindedMessagePath { + type Target = nativeBlindedMessagePath; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for BlindedMessagePath { } +unsafe impl core::marker::Sync for BlindedMessagePath { } +impl Drop for BlindedMessagePath { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeBlindedMessagePath>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the BlindedMessagePath, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn BlindedMessagePath_free(this_obj: BlindedMessagePath) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn BlindedMessagePath_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeBlindedMessagePath) }; +} +#[allow(unused)] +impl BlindedMessagePath { + pub(crate) fn get_native_ref(&self) -> &'static nativeBlindedMessagePath { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeBlindedMessagePath { + 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 nativeBlindedMessagePath { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +impl Clone for BlindedMessagePath { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeBlindedMessagePath>::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 BlindedMessagePath_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeBlindedMessagePath)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the BlindedMessagePath +pub extern "C" fn BlindedMessagePath_clone(orig: &BlindedMessagePath) -> BlindedMessagePath { + orig.clone() +} +/// Get a string which allows debug introspection of a BlindedMessagePath object +pub extern "C" fn BlindedMessagePath_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::blinded_path::message::BlindedMessagePath }).into()} +/// Generates a non-cryptographic 64-bit hash of the BlindedMessagePath. +#[no_mangle] +pub extern "C" fn BlindedMessagePath_hash(o: &BlindedMessagePath) -> 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 BlindedMessagePaths 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 BlindedMessagePath_eq(a: &BlindedMessagePath, b: &BlindedMessagePath) -> 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 BlindedMessagePath object into a byte array which can be read by BlindedMessagePath_read +pub extern "C" fn BlindedMessagePath_write(obj: &crate::lightning::blinded_path::message::BlindedMessagePath) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[allow(unused)] +pub(crate) extern "C" fn BlindedMessagePath_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::blinded_path::message::nativeBlindedMessagePath) }) +} +#[no_mangle] +/// Read a BlindedMessagePath from a byte array, created by BlindedMessagePath_write +pub extern "C" fn BlindedMessagePath_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_BlindedMessagePathDecodeErrorZ { + 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::blinded_path::message::BlindedMessagePath { 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 +} +/// Create a one-hop blinded path for a message. +#[must_use] +#[no_mangle] +pub extern "C" fn BlindedMessagePath_one_hop(mut recipient_node_id: crate::c_types::PublicKey, mut context: crate::lightning::blinded_path::message::MessageContext, mut entropy_source: crate::lightning::sign::EntropySource) -> crate::c_types::derived::CResult_BlindedMessagePathNoneZ { + let mut ret = lightning::blinded_path::message::BlindedMessagePath::one_hop(recipient_node_id.into_rust(), context.into_native(), entropy_source, secp256k1::global::SECP256K1); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::blinded_path::message::BlindedMessagePath { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Create a path for an onion message, to be forwarded along `node_pks`. The last node +/// pubkey in `node_pks` will be the destination node. +/// +/// Errors if no hops are provided or if `node_pk`(s) are invalid. +#[must_use] +#[no_mangle] +pub extern "C" fn BlindedMessagePath_new(mut intermediate_nodes: crate::c_types::derived::CVec_MessageForwardNodeZ, mut recipient_node_id: crate::c_types::PublicKey, mut context: crate::lightning::blinded_path::message::MessageContext, mut entropy_source: crate::lightning::sign::EntropySource) -> crate::c_types::derived::CResult_BlindedMessagePathNoneZ { + let mut local_intermediate_nodes = Vec::new(); for mut item in intermediate_nodes.into_rust().drain(..) { local_intermediate_nodes.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; + let mut ret = lightning::blinded_path::message::BlindedMessagePath::new(&local_intermediate_nodes[..], recipient_node_id.into_rust(), context.into_native(), entropy_source, secp256k1::global::SECP256K1); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::blinded_path::message::BlindedMessagePath { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Attempts to a use a compact representation for the [`IntroductionNode`] by using a directed +/// short channel id from a channel in `network_graph` leading to the introduction node. +/// +/// While this may result in a smaller encoding, there is a trade off in that the path may +/// become invalid if the channel is closed or hasn't been propagated via gossip. Therefore, +/// calling this may not be suitable for long-lived blinded paths. +#[no_mangle] +pub extern "C" fn BlindedMessagePath_use_compact_introduction_node(this_arg: &mut crate::lightning::blinded_path::message::BlindedMessagePath, network_graph: &crate::lightning::routing::gossip::ReadOnlyNetworkGraph) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::blinded_path::message::nativeBlindedMessagePath)) }.use_compact_introduction_node(network_graph.get_native_ref()) +} + +/// Returns the introduction [`NodeId`] of the blinded path, if it is publicly reachable (i.e., +/// it is found in the network graph). +/// +/// 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 BlindedMessagePath_public_introduction_node_id(this_arg: &crate::lightning::blinded_path::message::BlindedMessagePath, network_graph: &crate::lightning::routing::gossip::ReadOnlyNetworkGraph) -> crate::lightning::routing::gossip::NodeId { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.public_introduction_node_id(network_graph.get_native_ref()); + let mut local_ret = crate::lightning::routing::gossip::NodeId { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning::routing::gossip::NodeId<>) as *mut _ }, is_owned: false }; + local_ret +} + +/// The [`IntroductionNode`] of the blinded path. +#[must_use] +#[no_mangle] +pub extern "C" fn BlindedMessagePath_introduction_node(this_arg: &crate::lightning::blinded_path::message::BlindedMessagePath) -> crate::lightning::blinded_path::IntroductionNode { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.introduction_node(); + crate::lightning::blinded_path::IntroductionNode::from_native(ret) +} + +/// Used by the [`IntroductionNode`] to decrypt its [`encrypted_payload`] to forward the message. +/// +/// [`encrypted_payload`]: BlindedHop::encrypted_payload +#[must_use] +#[no_mangle] +pub extern "C" fn BlindedMessagePath_blinding_point(this_arg: &crate::lightning::blinded_path::message::BlindedMessagePath) -> crate::c_types::PublicKey { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.blinding_point(); + crate::c_types::PublicKey::from_rust(&ret) +} + +/// The [`BlindedHop`]s within the blinded path. +#[must_use] +#[no_mangle] +pub extern "C" fn BlindedMessagePath_blinded_hops(this_arg: &crate::lightning::blinded_path::message::BlindedMessagePath) -> crate::c_types::derived::CVec_BlindedHopZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.blinded_hops(); + let mut local_ret_clone = Vec::new(); local_ret_clone.extend_from_slice(ret); let mut ret = local_ret_clone; let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::blinded_path::BlindedHop { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; + local_ret.into() +} + +/// Advance the blinded onion message path by one hop, making the second hop into the new +/// introduction node. +/// +/// Will only modify `self` when returning `Ok`. +#[must_use] +#[no_mangle] +pub extern "C" fn BlindedMessagePath_advance_path_by_one(this_arg: &mut crate::lightning::blinded_path::message::BlindedMessagePath, node_signer: &crate::lightning::sign::NodeSigner, node_id_lookup: &crate::lightning::blinded_path::NodeIdLookUp) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::blinded_path::message::nativeBlindedMessagePath)) }.advance_path_by_one(node_signer, node_id_lookup, 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( { () /*e*/ }).into() }; + local_ret +} + +/// The next hop to forward an onion message along its path. +/// +/// Note that payment blinded paths always specify their next hop using an explicit node id. +#[derive(Clone)] +#[must_use] +#[repr(C)] +pub enum NextMessageHop { + /// The node id of the next hop. + NodeId( + crate::c_types::PublicKey), + /// The short channel id leading to the next hop. + ShortChannelId( + u64), +} +use lightning::blinded_path::message::NextMessageHop as NextMessageHopImport; +pub(crate) type nativeNextMessageHop = NextMessageHopImport; + +impl NextMessageHop { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeNextMessageHop { + match self { + NextMessageHop::NodeId (ref a, ) => { + let mut a_nonref = Clone::clone(a); + nativeNextMessageHop::NodeId ( + a_nonref.into_rust(), + ) + }, + NextMessageHop::ShortChannelId (ref a, ) => { + let mut a_nonref = Clone::clone(a); + nativeNextMessageHop::ShortChannelId ( + a_nonref, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeNextMessageHop { + match self { + NextMessageHop::NodeId (mut a, ) => { + nativeNextMessageHop::NodeId ( + a.into_rust(), + ) + }, + NextMessageHop::ShortChannelId (mut a, ) => { + nativeNextMessageHop::ShortChannelId ( + a, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &NextMessageHopImport) -> Self { + let native = unsafe { &*(native as *const _ as *const c_void as *const nativeNextMessageHop) }; + match native { + nativeNextMessageHop::NodeId (ref a, ) => { + let mut a_nonref = Clone::clone(a); + NextMessageHop::NodeId ( + crate::c_types::PublicKey::from_rust(&a_nonref), + ) + }, + nativeNextMessageHop::ShortChannelId (ref a, ) => { + let mut a_nonref = Clone::clone(a); + NextMessageHop::ShortChannelId ( + a_nonref, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeNextMessageHop) -> Self { + match native { + nativeNextMessageHop::NodeId (mut a, ) => { + NextMessageHop::NodeId ( + crate::c_types::PublicKey::from_rust(&a), + ) + }, + nativeNextMessageHop::ShortChannelId (mut a, ) => { + NextMessageHop::ShortChannelId ( + a, + ) + }, + } + } +} +/// Frees any resources used by the NextMessageHop +#[no_mangle] +pub extern "C" fn NextMessageHop_free(this_ptr: NextMessageHop) { } +/// Creates a copy of the NextMessageHop +#[no_mangle] +pub extern "C" fn NextMessageHop_clone(orig: &NextMessageHop) -> NextMessageHop { + orig.clone() +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn NextMessageHop_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const NextMessageHop)).clone() })) as *mut c_void +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn NextMessageHop_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut NextMessageHop) }; +} +#[no_mangle] +/// Utility method to constructs a new NodeId-variant NextMessageHop +pub extern "C" fn NextMessageHop_node_id(a: crate::c_types::PublicKey) -> NextMessageHop { + NextMessageHop::NodeId(a, ) +} +#[no_mangle] +/// Utility method to constructs a new ShortChannelId-variant NextMessageHop +pub extern "C" fn NextMessageHop_short_channel_id(a: u64) -> NextMessageHop { + NextMessageHop::ShortChannelId(a, ) +} +/// Get a string which allows debug introspection of a NextMessageHop object +pub extern "C" fn NextMessageHop_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::blinded_path::message::NextMessageHop }).into()} +/// Generates a non-cryptographic 64-bit hash of the NextMessageHop. +#[no_mangle] +pub extern "C" fn NextMessageHop_hash(o: &NextMessageHop) -> 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 NextMessageHops contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +#[no_mangle] +pub extern "C" fn NextMessageHop_eq(a: &NextMessageHop, b: &NextMessageHop) -> bool { + if &a.to_native() == &b.to_native() { true } else { false } +} + +use lightning::blinded_path::message::MessageForwardNode as nativeMessageForwardNodeImport; +pub(crate) type nativeMessageForwardNode = nativeMessageForwardNodeImport; + +/// An intermediate node, and possibly a short channel id leading to the next node. +#[must_use] +#[repr(C)] +pub struct MessageForwardNode { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, 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 nativeMessageForwardNode, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust 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 core::ops::Deref for MessageForwardNode { + type Target = nativeMessageForwardNode; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for MessageForwardNode { } +unsafe impl core::marker::Sync for MessageForwardNode { } +impl Drop for MessageForwardNode { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeMessageForwardNode>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the MessageForwardNode, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn MessageForwardNode_free(this_obj: MessageForwardNode) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn MessageForwardNode_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeMessageForwardNode) }; +} +#[allow(unused)] +impl MessageForwardNode { + pub(crate) fn get_native_ref(&self) -> &'static nativeMessageForwardNode { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeMessageForwardNode { + 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 nativeMessageForwardNode { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// This node's pubkey. +#[no_mangle] +pub extern "C" fn MessageForwardNode_get_node_id(this_ptr: &MessageForwardNode) -> crate::c_types::PublicKey { + let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id; + crate::c_types::PublicKey::from_rust(&inner_val) +} +/// This node's pubkey. +#[no_mangle] +pub extern "C" fn MessageForwardNode_set_node_id(this_ptr: &mut MessageForwardNode, mut val: crate::c_types::PublicKey) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id = val.into_rust(); +} +/// The channel between `node_id` and the next hop. If set, the constructed [`BlindedHop`]'s +/// `encrypted_payload` will use this instead of the next [`MessageForwardNode::node_id`] for a +/// more compact representation. +#[no_mangle] +pub extern "C" fn MessageForwardNode_get_short_channel_id(this_ptr: &MessageForwardNode) -> crate::c_types::derived::COption_u64Z { + let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id; + 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 channel between `node_id` and the next hop. If set, the constructed [`BlindedHop`]'s +/// `encrypted_payload` will use this instead of the next [`MessageForwardNode::node_id`] for a +/// more compact representation. +#[no_mangle] +pub extern "C" fn MessageForwardNode_set_short_channel_id(this_ptr: &mut MessageForwardNode, 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) }.short_channel_id = local_val; +} +/// Constructs a new MessageForwardNode given each field +#[must_use] +#[no_mangle] +pub extern "C" fn MessageForwardNode_new(mut node_id_arg: crate::c_types::PublicKey, mut short_channel_id_arg: crate::c_types::derived::COption_u64Z) -> MessageForwardNode { + let mut local_short_channel_id_arg = if short_channel_id_arg.is_some() { Some( { short_channel_id_arg.take() }) } else { None }; + MessageForwardNode { inner: ObjOps::heap_alloc(nativeMessageForwardNode { + node_id: node_id_arg.into_rust(), + short_channel_id: local_short_channel_id_arg, + }), is_owned: true } +} +impl Clone for MessageForwardNode { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeMessageForwardNode>::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 MessageForwardNode_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeMessageForwardNode)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the MessageForwardNode +pub extern "C" fn MessageForwardNode_clone(orig: &MessageForwardNode) -> MessageForwardNode { + orig.clone() +} +/// Get a string which allows debug introspection of a MessageForwardNode object +pub extern "C" fn MessageForwardNode_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::blinded_path::message::MessageForwardNode }).into()} +/// Generates a non-cryptographic 64-bit hash of the MessageForwardNode. +#[no_mangle] +pub extern "C" fn MessageForwardNode_hash(o: &MessageForwardNode) -> 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 MessageForwardNodes 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 MessageForwardNode_eq(a: &MessageForwardNode, b: &MessageForwardNode) -> 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 } +} +/// Additional data included by the recipient in a [`BlindedMessagePath`]. +/// +/// This data is encrypted by the recipient and will be given to the corresponding message handler +/// when handling a message sent over the [`BlindedMessagePath`]. The recipient can use this data to +/// authenticate the message or for further processing if needed. +#[derive(Clone)] +#[must_use] +#[repr(C)] +pub enum MessageContext { + /// Context specific to an [`OffersMessage`]. + /// + /// [`OffersMessage`]: crate::onion_message::offers::OffersMessage + Offers( + crate::lightning::blinded_path::message::OffersContext), + /// Context specific to a [`CustomOnionMessageHandler::CustomMessage`]. + /// + /// [`CustomOnionMessageHandler::CustomMessage`]: crate::onion_message::messenger::CustomOnionMessageHandler::CustomMessage + Custom( + crate::c_types::derived::CVec_u8Z), +} +use lightning::blinded_path::message::MessageContext as MessageContextImport; +pub(crate) type nativeMessageContext = MessageContextImport; + +impl MessageContext { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeMessageContext { + match self { + MessageContext::Offers (ref a, ) => { + let mut a_nonref = Clone::clone(a); + nativeMessageContext::Offers ( + a_nonref.into_native(), + ) + }, + MessageContext::Custom (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( { item }); }; + nativeMessageContext::Custom ( + local_a_nonref, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeMessageContext { + match self { + MessageContext::Offers (mut a, ) => { + nativeMessageContext::Offers ( + a.into_native(), + ) + }, + MessageContext::Custom (mut a, ) => { + let mut local_a = Vec::new(); for mut item in a.into_rust().drain(..) { local_a.push( { item }); }; + nativeMessageContext::Custom ( + local_a, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &MessageContextImport) -> Self { + let native = unsafe { &*(native as *const _ as *const c_void as *const nativeMessageContext) }; + match native { + nativeMessageContext::Offers (ref a, ) => { + let mut a_nonref = Clone::clone(a); + MessageContext::Offers ( + crate::lightning::blinded_path::message::OffersContext::native_into(a_nonref), + ) + }, + nativeMessageContext::Custom (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( { item }); }; + MessageContext::Custom ( + local_a_nonref.into(), + ) + }, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeMessageContext) -> Self { + match native { + nativeMessageContext::Offers (mut a, ) => { + MessageContext::Offers ( + crate::lightning::blinded_path::message::OffersContext::native_into(a), + ) + }, + nativeMessageContext::Custom (mut a, ) => { + let mut local_a = Vec::new(); for mut item in a.drain(..) { local_a.push( { item }); }; + MessageContext::Custom ( + local_a.into(), + ) + }, + } + } +} +/// Frees any resources used by the MessageContext +#[no_mangle] +pub extern "C" fn MessageContext_free(this_ptr: MessageContext) { } +/// Creates a copy of the MessageContext +#[no_mangle] +pub extern "C" fn MessageContext_clone(orig: &MessageContext) -> MessageContext { + orig.clone() +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn MessageContext_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const MessageContext)).clone() })) as *mut c_void +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn MessageContext_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut MessageContext) }; +} +#[no_mangle] +/// Utility method to constructs a new Offers-variant MessageContext +pub extern "C" fn MessageContext_offers(a: crate::lightning::blinded_path::message::OffersContext) -> MessageContext { + MessageContext::Offers(a, ) +} +#[no_mangle] +/// Utility method to constructs a new Custom-variant MessageContext +pub extern "C" fn MessageContext_custom(a: crate::c_types::derived::CVec_u8Z) -> MessageContext { + MessageContext::Custom(a, ) +} +/// Get a string which allows debug introspection of a MessageContext object +pub extern "C" fn MessageContext_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::blinded_path::message::MessageContext }).into()} +/// Contains data specific to an [`OffersMessage`]. +/// +/// [`OffersMessage`]: crate::onion_message::offers::OffersMessage +#[derive(Clone)] +#[must_use] +#[repr(C)] +pub enum OffersContext { + /// Context used by a [`BlindedMessagePath`] within an [`Offer`]. + /// + /// This variant is intended to be received when handling an [`InvoiceRequest`]. + /// + /// [`Offer`]: crate::offers::offer::Offer + /// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest + InvoiceRequest { + /// A nonce used for authenticating that an [`InvoiceRequest`] is for a valid [`Offer`] and + /// for deriving the offer's signing keys. + /// + /// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest + /// [`Offer`]: crate::offers::offer::Offer + nonce: crate::lightning::offers::nonce::Nonce, + }, + /// Context used by a [`BlindedMessagePath`] within a [`Refund`] or as a reply path for an + /// [`InvoiceRequest`]. + /// + /// This variant is intended to be received when handling a [`Bolt12Invoice`] or an + /// [`InvoiceError`]. + /// + /// [`Refund`]: crate::offers::refund::Refund + /// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest + /// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice + /// [`InvoiceError`]: crate::offers::invoice_error::InvoiceError + OutboundPayment { + /// Payment ID used when creating a [`Refund`] or [`InvoiceRequest`]. + /// + /// [`Refund`]: crate::offers::refund::Refund + /// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest + payment_id: crate::c_types::ThirtyTwoBytes, + /// A nonce used for authenticating that a [`Bolt12Invoice`] is for a valid [`Refund`] or + /// [`InvoiceRequest`] and for deriving their signing keys. + /// + /// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice + /// [`Refund`]: crate::offers::refund::Refund + /// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest + nonce: crate::lightning::offers::nonce::Nonce, + /// Authentication code for the [`PaymentId`], which should be checked when the context is + /// used with an [`InvoiceError`]. + /// + /// [`InvoiceError`]: crate::offers::invoice_error::InvoiceError + /// + /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + hmac: crate::c_types::ThirtyTwoBytes, + }, + /// Context used by a [`BlindedMessagePath`] as a reply path for a [`Bolt12Invoice`]. + /// + /// This variant is intended to be received when handling an [`InvoiceError`]. + /// + /// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice + /// [`InvoiceError`]: crate::offers::invoice_error::InvoiceError + InboundPayment { + /// The same payment hash as [`Bolt12Invoice::payment_hash`]. + /// + /// [`Bolt12Invoice::payment_hash`]: crate::offers::invoice::Bolt12Invoice::payment_hash + payment_hash: crate::c_types::ThirtyTwoBytes, + }, +} +use lightning::blinded_path::message::OffersContext as OffersContextImport; +pub(crate) type nativeOffersContext = OffersContextImport; + +impl OffersContext { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeOffersContext { + match self { + OffersContext::InvoiceRequest {ref nonce, } => { + let mut nonce_nonref = Clone::clone(nonce); + nativeOffersContext::InvoiceRequest { + nonce: *unsafe { Box::from_raw(nonce_nonref.take_inner()) }, + } + }, + OffersContext::OutboundPayment {ref payment_id, ref nonce, ref hmac, } => { + let mut payment_id_nonref = Clone::clone(payment_id); + let mut nonce_nonref = Clone::clone(nonce); + let mut hmac_nonref = Clone::clone(hmac); + let mut local_hmac_nonref = if hmac_nonref.data == [0; 32] { None } else { Some( { hmac_nonref.data }) }; + nativeOffersContext::OutboundPayment { + payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data), + nonce: *unsafe { Box::from_raw(nonce_nonref.take_inner()) }, + hmac: local_hmac_nonref, + } + }, + OffersContext::InboundPayment {ref payment_hash, } => { + let mut payment_hash_nonref = Clone::clone(payment_hash); + nativeOffersContext::InboundPayment { + payment_hash: ::lightning::ln::types::PaymentHash(payment_hash_nonref.data), + } + }, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeOffersContext { + match self { + OffersContext::InvoiceRequest {mut nonce, } => { + nativeOffersContext::InvoiceRequest { + nonce: *unsafe { Box::from_raw(nonce.take_inner()) }, + } + }, + OffersContext::OutboundPayment {mut payment_id, mut nonce, mut hmac, } => { + let mut local_hmac = if hmac.data == [0; 32] { None } else { Some( { hmac.data }) }; + nativeOffersContext::OutboundPayment { + payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id.data), + nonce: *unsafe { Box::from_raw(nonce.take_inner()) }, + hmac: local_hmac, + } + }, + OffersContext::InboundPayment {mut payment_hash, } => { + nativeOffersContext::InboundPayment { + payment_hash: ::lightning::ln::types::PaymentHash(payment_hash.data), + } + }, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &OffersContextImport) -> Self { + let native = unsafe { &*(native as *const _ as *const c_void as *const nativeOffersContext) }; + match native { + nativeOffersContext::InvoiceRequest {ref nonce, } => { + let mut nonce_nonref = Clone::clone(nonce); + OffersContext::InvoiceRequest { + nonce: crate::lightning::offers::nonce::Nonce { inner: ObjOps::heap_alloc(nonce_nonref), is_owned: true }, + } + }, + nativeOffersContext::OutboundPayment {ref payment_id, ref nonce, ref hmac, } => { + let mut payment_id_nonref = Clone::clone(payment_id); + let mut nonce_nonref = Clone::clone(nonce); + let mut hmac_nonref = Clone::clone(hmac); + let mut local_hmac_nonref = if hmac_nonref.is_none() { crate::c_types::ThirtyTwoBytes { data: [0; 32] } } else { { crate::c_types::ThirtyTwoBytes { data: (hmac_nonref.unwrap()) } } }; + OffersContext::OutboundPayment { + payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id_nonref.0 }, + nonce: crate::lightning::offers::nonce::Nonce { inner: ObjOps::heap_alloc(nonce_nonref), is_owned: true }, + hmac: local_hmac_nonref, + } + }, + nativeOffersContext::InboundPayment {ref payment_hash, } => { + let mut payment_hash_nonref = Clone::clone(payment_hash); + OffersContext::InboundPayment { + payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 }, + } + }, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeOffersContext) -> Self { + match native { + nativeOffersContext::InvoiceRequest {mut nonce, } => { + OffersContext::InvoiceRequest { + nonce: crate::lightning::offers::nonce::Nonce { inner: ObjOps::heap_alloc(nonce), is_owned: true }, + } + }, + nativeOffersContext::OutboundPayment {mut payment_id, mut nonce, mut hmac, } => { + let mut local_hmac = if hmac.is_none() { crate::c_types::ThirtyTwoBytes { data: [0; 32] } } else { { crate::c_types::ThirtyTwoBytes { data: (hmac.unwrap()) } } }; + OffersContext::OutboundPayment { + payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id.0 }, + nonce: crate::lightning::offers::nonce::Nonce { inner: ObjOps::heap_alloc(nonce), is_owned: true }, + hmac: local_hmac, + } + }, + nativeOffersContext::InboundPayment {mut payment_hash, } => { + OffersContext::InboundPayment { + payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 }, + } + }, + } + } +} +/// Frees any resources used by the OffersContext +#[no_mangle] +pub extern "C" fn OffersContext_free(this_ptr: OffersContext) { } +/// Creates a copy of the OffersContext +#[no_mangle] +pub extern "C" fn OffersContext_clone(orig: &OffersContext) -> OffersContext { + orig.clone() +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn OffersContext_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const OffersContext)).clone() })) as *mut c_void +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn OffersContext_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut OffersContext) }; +} +#[no_mangle] +/// Utility method to constructs a new InvoiceRequest-variant OffersContext +pub extern "C" fn OffersContext_invoice_request(nonce: crate::lightning::offers::nonce::Nonce) -> OffersContext { + OffersContext::InvoiceRequest { + nonce, + } +} +#[no_mangle] +/// Utility method to constructs a new OutboundPayment-variant OffersContext +pub extern "C" fn OffersContext_outbound_payment(payment_id: crate::c_types::ThirtyTwoBytes, nonce: crate::lightning::offers::nonce::Nonce, hmac: crate::c_types::ThirtyTwoBytes) -> OffersContext { + OffersContext::OutboundPayment { + payment_id, + nonce, + hmac, + } +} +#[no_mangle] +/// Utility method to constructs a new InboundPayment-variant OffersContext +pub extern "C" fn OffersContext_inbound_payment(payment_hash: crate::c_types::ThirtyTwoBytes) -> OffersContext { + OffersContext::InboundPayment { + payment_hash, + } +} +/// Get a string which allows debug introspection of a OffersContext object +pub extern "C" fn OffersContext_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::blinded_path::message::OffersContext }).into()} +/// Checks if two OffersContexts contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +#[no_mangle] +pub extern "C" fn OffersContext_eq(a: &OffersContext, b: &OffersContext) -> bool { + if &a.to_native() == &b.to_native() { true } else { false } +} +#[no_mangle] +/// Serialize the MessageContext object into a byte array which can be read by MessageContext_read +pub extern "C" fn MessageContext_write(obj: &crate::lightning::blinded_path::message::MessageContext) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(&unsafe { &*obj }.to_native()) +} +#[allow(unused)] +pub(crate) extern "C" fn MessageContext_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + MessageContext_write(unsafe { &*(obj as *const MessageContext) }) +} +#[no_mangle] +/// Read a MessageContext from a byte array, created by MessageContext_write +pub extern "C" fn MessageContext_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_MessageContextDecodeErrorZ { + 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::blinded_path::message::MessageContext::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} +#[no_mangle] +/// Serialize the OffersContext object into a byte array which can be read by OffersContext_read +pub extern "C" fn OffersContext_write(obj: &crate::lightning::blinded_path::message::OffersContext) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(&unsafe { &*obj }.to_native()) +} +#[allow(unused)] +pub(crate) extern "C" fn OffersContext_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + OffersContext_write(unsafe { &*(obj as *const OffersContext) }) +} +#[no_mangle] +/// Read a OffersContext from a byte array, created by OffersContext_write +pub extern "C" fn OffersContext_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OffersContextDecodeErrorZ { + 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::blinded_path::message::OffersContext::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/blinded_path/mod.rs b/lightning-c-bindings/src/lightning/blinded_path/mod.rs index 37a077c..4c2f1f6 100644 --- a/lightning-c-bindings/src/lightning/blinded_path/mod.rs +++ b/lightning-c-bindings/src/lightning/blinded_path/mod.rs @@ -18,18 +18,7 @@ use crate::c_types::*; use alloc::{vec::Vec, boxed::Box}; pub mod payment; -mod message { - -use alloc::str::FromStr; -use alloc::string::String; -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 message; mod utils { use alloc::str::FromStr; @@ -42,290 +31,7 @@ use crate::c_types::*; use alloc::{vec::Vec, boxed::Box}; } -/// The next hop to forward an onion message along its path. -/// -/// Note that payment blinded paths always specify their next hop using an explicit node id. -#[derive(Clone)] -#[must_use] -#[repr(C)] -pub enum NextMessageHop { - /// The node id of the next hop. - NodeId( - crate::c_types::PublicKey), - /// The short channel id leading to the next hop. - ShortChannelId( - u64), -} -use lightning::blinded_path::NextMessageHop as NextMessageHopImport; -pub(crate) type nativeNextMessageHop = NextMessageHopImport; - -impl NextMessageHop { - #[allow(unused)] - pub(crate) fn to_native(&self) -> nativeNextMessageHop { - match self { - NextMessageHop::NodeId (ref a, ) => { - let mut a_nonref = Clone::clone(a); - nativeNextMessageHop::NodeId ( - a_nonref.into_rust(), - ) - }, - NextMessageHop::ShortChannelId (ref a, ) => { - let mut a_nonref = Clone::clone(a); - nativeNextMessageHop::ShortChannelId ( - a_nonref, - ) - }, - } - } - #[allow(unused)] - pub(crate) fn into_native(self) -> nativeNextMessageHop { - match self { - NextMessageHop::NodeId (mut a, ) => { - nativeNextMessageHop::NodeId ( - a.into_rust(), - ) - }, - NextMessageHop::ShortChannelId (mut a, ) => { - nativeNextMessageHop::ShortChannelId ( - a, - ) - }, - } - } - #[allow(unused)] - pub(crate) fn from_native(native: &NextMessageHopImport) -> Self { - let native = unsafe { &*(native as *const _ as *const c_void as *const nativeNextMessageHop) }; - match native { - nativeNextMessageHop::NodeId (ref a, ) => { - let mut a_nonref = Clone::clone(a); - NextMessageHop::NodeId ( - crate::c_types::PublicKey::from_rust(&a_nonref), - ) - }, - nativeNextMessageHop::ShortChannelId (ref a, ) => { - let mut a_nonref = Clone::clone(a); - NextMessageHop::ShortChannelId ( - a_nonref, - ) - }, - } - } - #[allow(unused)] - pub(crate) fn native_into(native: nativeNextMessageHop) -> Self { - match native { - nativeNextMessageHop::NodeId (mut a, ) => { - NextMessageHop::NodeId ( - crate::c_types::PublicKey::from_rust(&a), - ) - }, - nativeNextMessageHop::ShortChannelId (mut a, ) => { - NextMessageHop::ShortChannelId ( - a, - ) - }, - } - } -} -/// Frees any resources used by the NextMessageHop -#[no_mangle] -pub extern "C" fn NextMessageHop_free(this_ptr: NextMessageHop) { } -/// Creates a copy of the NextMessageHop -#[no_mangle] -pub extern "C" fn NextMessageHop_clone(orig: &NextMessageHop) -> NextMessageHop { - orig.clone() -} -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn NextMessageHop_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *const NextMessageHop)).clone() })) as *mut c_void -} -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn NextMessageHop_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut NextMessageHop) }; -} -#[no_mangle] -/// Utility method to constructs a new NodeId-variant NextMessageHop -pub extern "C" fn NextMessageHop_node_id(a: crate::c_types::PublicKey) -> NextMessageHop { - NextMessageHop::NodeId(a, ) -} -#[no_mangle] -/// Utility method to constructs a new ShortChannelId-variant NextMessageHop -pub extern "C" fn NextMessageHop_short_channel_id(a: u64) -> NextMessageHop { - NextMessageHop::ShortChannelId(a, ) -} -/// Get a string which allows debug introspection of a NextMessageHop object -pub extern "C" fn NextMessageHop_debug_str_void(o: *const c_void) -> Str { - alloc::format!("{:?}", unsafe { o as *const crate::lightning::blinded_path::NextMessageHop }).into()} -/// Generates a non-cryptographic 64-bit hash of the NextMessageHop. -#[no_mangle] -pub extern "C" fn NextMessageHop_hash(o: &NextMessageHop) -> 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 NextMessageHops contain equal inner contents. -/// This ignores pointers and is_owned flags and looks at the values in fields. -#[no_mangle] -pub extern "C" fn NextMessageHop_eq(a: &NextMessageHop, b: &NextMessageHop) -> bool { - if &a.to_native() == &b.to_native() { true } else { false } -} - -use lightning::blinded_path::BlindedPath as nativeBlindedPathImport; -pub(crate) type nativeBlindedPath = nativeBlindedPathImport; - -/// Onion messages and payments can be sent and received to blinded paths, which serve to hide the -/// identity of the recipient. -#[must_use] -#[repr(C)] -pub struct BlindedPath { - /// A pointer to the opaque Rust object. - - /// Nearly everywhere, 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 nativeBlindedPath, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust 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 BlindedPath { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeBlindedPath>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; - } - } -} -/// Frees any resources used by the BlindedPath, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn BlindedPath_free(this_obj: BlindedPath) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn BlindedPath_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeBlindedPath) }; -} -#[allow(unused)] -impl BlindedPath { - pub(crate) fn get_native_ref(&self) -> &'static nativeBlindedPath { - unsafe { &*ObjOps::untweak_ptr(self.inner) } - } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeBlindedPath { - 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 nativeBlindedPath { - assert!(self.is_owned); - let ret = ObjOps::untweak_ptr(self.inner); - self.inner = core::ptr::null_mut(); - ret - } -} -/// To send to a blinded path, the sender first finds a route to the unblinded -/// `introduction_node`, which can unblind its [`encrypted_payload`] to find out the onion -/// message or payment's next hop and forward it along. -/// -/// [`encrypted_payload`]: BlindedHop::encrypted_payload -#[no_mangle] -pub extern "C" fn BlindedPath_get_introduction_node(this_ptr: &BlindedPath) -> crate::lightning::blinded_path::IntroductionNode { - let mut inner_val = &mut this_ptr.get_native_mut_ref().introduction_node; - crate::lightning::blinded_path::IntroductionNode::from_native(inner_val) -} -/// To send to a blinded path, the sender first finds a route to the unblinded -/// `introduction_node`, which can unblind its [`encrypted_payload`] to find out the onion -/// message or payment's next hop and forward it along. -/// -/// [`encrypted_payload`]: BlindedHop::encrypted_payload -#[no_mangle] -pub extern "C" fn BlindedPath_set_introduction_node(this_ptr: &mut BlindedPath, mut val: crate::lightning::blinded_path::IntroductionNode) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.introduction_node = val.into_native(); -} -/// Used by the introduction node to decrypt its [`encrypted_payload`] to forward the onion -/// message or payment. -/// -/// [`encrypted_payload`]: BlindedHop::encrypted_payload -#[no_mangle] -pub extern "C" fn BlindedPath_get_blinding_point(this_ptr: &BlindedPath) -> crate::c_types::PublicKey { - let mut inner_val = &mut this_ptr.get_native_mut_ref().blinding_point; - crate::c_types::PublicKey::from_rust(&inner_val) -} -/// Used by the introduction node to decrypt its [`encrypted_payload`] to forward the onion -/// message or payment. -/// -/// [`encrypted_payload`]: BlindedHop::encrypted_payload -#[no_mangle] -pub extern "C" fn BlindedPath_set_blinding_point(this_ptr: &mut BlindedPath, mut val: crate::c_types::PublicKey) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.blinding_point = val.into_rust(); -} -/// The hops composing the blinded path. -#[no_mangle] -pub extern "C" fn BlindedPath_get_blinded_hops(this_ptr: &BlindedPath) -> crate::c_types::derived::CVec_BlindedHopZ { - let mut inner_val = &mut this_ptr.get_native_mut_ref().blinded_hops; - let mut local_inner_val = Vec::new(); for item in inner_val.iter() { local_inner_val.push( { crate::lightning::blinded_path::BlindedHop { inner: unsafe { ObjOps::nonnull_ptr_to_inner((item as *const lightning::blinded_path::BlindedHop<>) as *mut _) }, is_owned: false } }); }; - local_inner_val.into() -} -/// The hops composing the blinded path. -#[no_mangle] -pub extern "C" fn BlindedPath_set_blinded_hops(this_ptr: &mut BlindedPath, mut val: crate::c_types::derived::CVec_BlindedHopZ) { - 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) }.blinded_hops = local_val; -} -/// Constructs a new BlindedPath given each field -#[must_use] -#[no_mangle] -pub extern "C" fn BlindedPath_new(mut introduction_node_arg: crate::lightning::blinded_path::IntroductionNode, mut blinding_point_arg: crate::c_types::PublicKey, mut blinded_hops_arg: crate::c_types::derived::CVec_BlindedHopZ) -> BlindedPath { - let mut local_blinded_hops_arg = Vec::new(); for mut item in blinded_hops_arg.into_rust().drain(..) { local_blinded_hops_arg.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; - BlindedPath { inner: ObjOps::heap_alloc(nativeBlindedPath { - introduction_node: introduction_node_arg.into_native(), - blinding_point: blinding_point_arg.into_rust(), - blinded_hops: local_blinded_hops_arg, - }), is_owned: true } -} -impl Clone for BlindedPath { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeBlindedPath>::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 BlindedPath_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeBlindedPath)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the BlindedPath -pub extern "C" fn BlindedPath_clone(orig: &BlindedPath) -> BlindedPath { - orig.clone() -} -/// Get a string which allows debug introspection of a BlindedPath object -pub extern "C" fn BlindedPath_debug_str_void(o: *const c_void) -> Str { - alloc::format!("{:?}", unsafe { o as *const crate::lightning::blinded_path::BlindedPath }).into()} -/// Generates a non-cryptographic 64-bit hash of the BlindedPath. -#[no_mangle] -pub extern "C" fn BlindedPath_hash(o: &BlindedPath) -> 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 BlindedPaths 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 BlindedPath_eq(a: &BlindedPath, b: &BlindedPath) -> 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 } -} -/// The unblinded node in a [`BlindedPath`]. +/// The unblinded node in a blinded path. #[derive(Clone)] #[must_use] #[repr(C)] @@ -461,8 +167,8 @@ pub extern "C" fn IntroductionNode_hash(o: &IntroductionNode) -> u64 { pub extern "C" fn IntroductionNode_eq(a: &IntroductionNode, b: &IntroductionNode) -> bool { if &a.to_native() == &b.to_native() { true } else { false } } -/// The side of a channel that is the [`IntroductionNode`] in a [`BlindedPath`]. [BOLT 7] defines -/// which nodes is which in the [`ChannelAnnouncement`] message. +/// The side of a channel that is the [`IntroductionNode`] in a blinded path. [BOLT 7] defines which +/// nodes is which in the [`ChannelAnnouncement`] message. /// /// [BOLT 7]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_announcement-message /// [`ChannelAnnouncement`]: crate::ln::msgs::ChannelAnnouncement @@ -592,17 +298,26 @@ impl rustNodeIdLookUp for NodeIdLookUp { } } +pub struct NodeIdLookUpRef(NodeIdLookUp); +impl rustNodeIdLookUp for NodeIdLookUpRef { + fn next_node_id(&self, mut short_channel_id: u64) -> Option { + let mut ret = (self.0.next_node_id)(self.0.this_arg, short_channel_id); + let mut local_ret = if ret.is_null() { None } else { Some( { ret.into_rust() }) }; + 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 NodeIdLookUp { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = NodeIdLookUpRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const NodeIdLookUpRef) } } } impl core::ops::DerefMut for NodeIdLookUp { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut NodeIdLookUpRef { + unsafe { &mut *(self as *mut _ as *mut NodeIdLookUpRef) } } } /// Calls the free function if one is set @@ -635,6 +350,12 @@ pub struct EmptyNodeIdLookUp { pub is_owned: bool, } +impl core::ops::Deref for EmptyNodeIdLookUp { + type Target = nativeEmptyNodeIdLookUp; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for EmptyNodeIdLookUp { } +unsafe impl core::marker::Sync for EmptyNodeIdLookUp { } impl Drop for EmptyNodeIdLookUp { fn drop(&mut self) { if self.is_owned && !<*mut nativeEmptyNodeIdLookUp>::is_null(self.inner) { @@ -665,6 +386,9 @@ impl EmptyNodeIdLookUp { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Constructs a new EmptyNodeIdLookUp given each field #[must_use] @@ -723,6 +447,12 @@ pub struct BlindedHop { pub is_owned: bool, } +impl core::ops::Deref for BlindedHop { + type Target = nativeBlindedHop; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for BlindedHop { } +unsafe impl core::marker::Sync for BlindedHop { } impl Drop for BlindedHop { fn drop(&mut self) { if self.is_owned && !<*mut nativeBlindedHop>::is_null(self.inner) { @@ -753,19 +483,22 @@ impl BlindedHop { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } -/// The blinded node id of this hop in a [`BlindedPath`]. +/// The blinded node id of this hop in a blinded path. #[no_mangle] pub extern "C" fn BlindedHop_get_blinded_node_id(this_ptr: &BlindedHop) -> crate::c_types::PublicKey { let mut inner_val = &mut this_ptr.get_native_mut_ref().blinded_node_id; crate::c_types::PublicKey::from_rust(&inner_val) } -/// The blinded node id of this hop in a [`BlindedPath`]. +/// The blinded node id of this hop in a blinded path. #[no_mangle] pub extern "C" fn BlindedHop_set_blinded_node_id(this_ptr: &mut BlindedHop, mut val: crate::c_types::PublicKey) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.blinded_node_id = val.into_rust(); } -/// The encrypted payload intended for this hop in a [`BlindedPath`]. +/// The encrypted payload intended for this hop in a blinded path. /// /// Returns a copy of the field. #[no_mangle] @@ -774,7 +507,7 @@ pub extern "C" fn BlindedHop_get_encrypted_payload(this_ptr: &BlindedHop) -> cra let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); }; local_inner_val.into() } -/// The encrypted payload intended for this hop in a [`BlindedPath`]. +/// The encrypted payload intended for this hop in a blinded path. #[no_mangle] pub extern "C" fn BlindedHop_set_encrypted_payload(this_ptr: &mut BlindedHop, 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 }); }; @@ -831,82 +564,6 @@ pub extern "C" fn BlindedHop_eq(a: &BlindedHop, b: &BlindedHop) -> bool { if a.inner.is_null() || b.inner.is_null() { return false; } if a.get_native_ref() == b.get_native_ref() { true } else { false } } -/// Create a one-hop blinded path for a message. -#[must_use] -#[no_mangle] -pub extern "C" fn BlindedPath_one_hop_for_message(mut recipient_node_id: crate::c_types::PublicKey, mut entropy_source: crate::lightning::sign::EntropySource) -> crate::c_types::derived::CResult_BlindedPathNoneZ { - let mut ret = lightning::blinded_path::BlindedPath::one_hop_for_message(recipient_node_id.into_rust(), 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() }; - local_ret -} - -/// Create a blinded path for an onion message, to be forwarded along `node_pks`. The last node -/// pubkey in `node_pks` will be the destination node. -/// -/// Errors if no 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, mut 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() }; - local_ret -} - -/// Create a one-hop blinded path for a payment. -#[must_use] -#[no_mangle] -pub extern "C" fn BlindedPath_one_hop_for_payment(mut payee_node_id: crate::c_types::PublicKey, mut payee_tlvs: crate::lightning::blinded_path::payment::ReceiveTlvs, mut min_final_cltv_expiry_delta: u16, mut entropy_source: crate::lightning::sign::EntropySource) -> crate::c_types::derived::CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ { - let mut ret = lightning::blinded_path::BlindedPath::one_hop_for_payment(payee_node_id.into_rust(), *unsafe { Box::from_raw(payee_tlvs.take_inner()) }, min_final_cltv_expiry_delta, entropy_source, 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_ret_0 = (crate::lightning::offers::invoice::BlindedPayInfo { inner: ObjOps::heap_alloc(orig_ret_0_0), is_owned: true }, crate::lightning::blinded_path::BlindedPath { inner: ObjOps::heap_alloc(orig_ret_0_1), is_owned: true }).into(); local_ret_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} - -/// Create a blinded path for a payment, to be forwarded along `intermediate_nodes`. -/// -/// Errors if: -/// * a provided node id is invalid -/// * [`BlindedPayInfo`] calculation results in an integer overflow -/// * any unknown features are required in the provided [`ForwardTlvs`] -/// -/// [`ForwardTlvs`]: crate::blinded_path::payment::ForwardTlvs -#[must_use] -#[no_mangle] -pub extern "C" fn BlindedPath_new_for_payment(mut intermediate_nodes: crate::c_types::derived::CVec_ForwardNodeZ, mut payee_node_id: crate::c_types::PublicKey, mut payee_tlvs: crate::lightning::blinded_path::payment::ReceiveTlvs, mut htlc_maximum_msat: u64, mut min_final_cltv_expiry_delta: u16, mut entropy_source: crate::lightning::sign::EntropySource) -> crate::c_types::derived::CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ { - let mut local_intermediate_nodes = Vec::new(); for mut item in intermediate_nodes.into_rust().drain(..) { local_intermediate_nodes.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; - let mut ret = lightning::blinded_path::BlindedPath::new_for_payment(local_intermediate_nodes, payee_node_id.into_rust(), *unsafe { Box::from_raw(payee_tlvs.take_inner()) }, htlc_maximum_msat, min_final_cltv_expiry_delta, entropy_source, 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_ret_0 = (crate::lightning::offers::invoice::BlindedPayInfo { inner: ObjOps::heap_alloc(orig_ret_0_0), is_owned: true }, crate::lightning::blinded_path::BlindedPath { inner: ObjOps::heap_alloc(orig_ret_0_1), is_owned: true }).into(); local_ret_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} - -/// Returns the introduction [`NodeId`] of the blinded path, if it is publicly reachable (i.e., -/// it is found in the network graph). -/// -/// 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 BlindedPath_public_introduction_node_id(this_arg: &crate::lightning::blinded_path::BlindedPath, network_graph: &crate::lightning::routing::gossip::ReadOnlyNetworkGraph) -> crate::lightning::routing::gossip::NodeId { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.public_introduction_node_id(network_graph.get_native_ref()); - let mut local_ret = crate::lightning::routing::gossip::NodeId { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning::routing::gossip::NodeId<>) as *mut _ }, is_owned: false }; - local_ret -} - -#[no_mangle] -/// Serialize the BlindedPath object into a byte array which can be read by BlindedPath_read -pub extern "C" fn BlindedPath_write(obj: &crate::lightning::blinded_path::BlindedPath) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) -} -#[allow(unused)] -pub(crate) extern "C" fn BlindedPath_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeBlindedPath) }) -} -#[no_mangle] -/// Read a BlindedPath from a byte array, created by BlindedPath_write -pub extern "C" fn BlindedPath_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_BlindedPathDecodeErrorZ { - 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::blinded_path::BlindedPath { 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 BlindedHop object into a byte array which can be read by BlindedHop_read pub extern "C" fn BlindedHop_write(obj: &crate::lightning::blinded_path::BlindedHop) -> crate::c_types::derived::CVec_u8Z { @@ -914,7 +571,7 @@ pub extern "C" fn BlindedHop_write(obj: &crate::lightning::blinded_path::Blinded } #[allow(unused)] pub(crate) extern "C" fn BlindedHop_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeBlindedHop) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::blinded_path::nativeBlindedHop) }) } #[no_mangle] /// Read a BlindedHop from a byte array, created by BlindedHop_write diff --git a/lightning-c-bindings/src/lightning/blinded_path/payment.rs b/lightning-c-bindings/src/lightning/blinded_path/payment.rs index 63ec9d2..58be01e 100644 --- a/lightning-c-bindings/src/lightning/blinded_path/payment.rs +++ b/lightning-c-bindings/src/lightning/blinded_path/payment.rs @@ -6,9 +6,7 @@ // license as that which applies to the original source files from which this // source was automatically generated. -//! Data structures and methods for constructing [`BlindedPath`]s to send a payment over. -//! -//! [`BlindedPath`]: crate::blinded_path::BlindedPath +//! Data structures and methods for constructing [`BlindedPaymentPath`]s to send a payment over. use alloc::str::FromStr; use alloc::string::String; @@ -20,18 +18,416 @@ use crate::c_types::*; use alloc::{vec::Vec, boxed::Box}; -use lightning::blinded_path::payment::ForwardNode as nativeForwardNodeImport; -pub(crate) type nativeForwardNode = nativeForwardNodeImport; +use lightning::blinded_path::payment::BlindedPayInfo as nativeBlindedPayInfoImport; +pub(crate) type nativeBlindedPayInfo = nativeBlindedPayInfoImport; + +/// Information needed to route a payment across a [`BlindedPaymentPath`]. +#[must_use] +#[repr(C)] +pub struct BlindedPayInfo { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, 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 nativeBlindedPayInfo, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust 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 core::ops::Deref for BlindedPayInfo { + type Target = nativeBlindedPayInfo; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for BlindedPayInfo { } +unsafe impl core::marker::Sync for BlindedPayInfo { } +impl Drop for BlindedPayInfo { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeBlindedPayInfo>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the BlindedPayInfo, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn BlindedPayInfo_free(this_obj: BlindedPayInfo) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn BlindedPayInfo_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeBlindedPayInfo) }; +} +#[allow(unused)] +impl BlindedPayInfo { + pub(crate) fn get_native_ref(&self) -> &'static nativeBlindedPayInfo { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeBlindedPayInfo { + 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 nativeBlindedPayInfo { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// Base fee charged (in millisatoshi) for the entire blinded path. +#[no_mangle] +pub extern "C" fn BlindedPayInfo_get_fee_base_msat(this_ptr: &BlindedPayInfo) -> u32 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_base_msat; + *inner_val +} +/// Base fee charged (in millisatoshi) for the entire blinded path. +#[no_mangle] +pub extern "C" fn BlindedPayInfo_set_fee_base_msat(this_ptr: &mut BlindedPayInfo, mut val: u32) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_base_msat = val; +} +/// Liquidity fee charged (in millionths of the amount transferred) for the entire blinded path +/// (i.e., 10,000 is 1%). +#[no_mangle] +pub extern "C" fn BlindedPayInfo_get_fee_proportional_millionths(this_ptr: &BlindedPayInfo) -> u32 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_proportional_millionths; + *inner_val +} +/// Liquidity fee charged (in millionths of the amount transferred) for the entire blinded path +/// (i.e., 10,000 is 1%). +#[no_mangle] +pub extern "C" fn BlindedPayInfo_set_fee_proportional_millionths(this_ptr: &mut BlindedPayInfo, mut val: u32) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_proportional_millionths = val; +} +/// Number of blocks subtracted from an incoming HTLC's `cltv_expiry` for the entire blinded +/// path. +#[no_mangle] +pub extern "C" fn BlindedPayInfo_get_cltv_expiry_delta(this_ptr: &BlindedPayInfo) -> u16 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta; + *inner_val +} +/// Number of blocks subtracted from an incoming HTLC's `cltv_expiry` for the entire blinded +/// path. +#[no_mangle] +pub extern "C" fn BlindedPayInfo_set_cltv_expiry_delta(this_ptr: &mut BlindedPayInfo, mut val: u16) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = 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. +#[no_mangle] +pub extern "C" fn BlindedPayInfo_get_htlc_minimum_msat(this_ptr: &BlindedPayInfo) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat; + *inner_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. +#[no_mangle] +pub extern "C" fn BlindedPayInfo_set_htlc_minimum_msat(this_ptr: &mut BlindedPayInfo, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val; +} +/// 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. +#[no_mangle] +pub extern "C" fn BlindedPayInfo_get_htlc_maximum_msat(this_ptr: &BlindedPayInfo) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_maximum_msat; + *inner_val +} +/// 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. +#[no_mangle] +pub extern "C" fn BlindedPayInfo_set_htlc_maximum_msat(this_ptr: &mut BlindedPayInfo, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_maximum_msat = val; +} +/// Features set in `encrypted_data_tlv` for the `encrypted_recipient_data` TLV record in an +/// onion payload. +#[no_mangle] +pub extern "C" fn BlindedPayInfo_get_features(this_ptr: &BlindedPayInfo) -> crate::lightning_types::features::BlindedHopFeatures { + let mut inner_val = &mut this_ptr.get_native_mut_ref().features; + crate::lightning_types::features::BlindedHopFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning_types::features::BlindedHopFeatures<>) as *mut _) }, is_owned: false } +} +/// Features set in `encrypted_data_tlv` for the `encrypted_recipient_data` TLV record in an +/// onion payload. +#[no_mangle] +pub extern "C" fn BlindedPayInfo_set_features(this_ptr: &mut BlindedPayInfo, mut val: crate::lightning_types::features::BlindedHopFeatures) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// Constructs a new BlindedPayInfo given each field +#[must_use] +#[no_mangle] +pub extern "C" fn BlindedPayInfo_new(mut fee_base_msat_arg: u32, mut fee_proportional_millionths_arg: u32, mut cltv_expiry_delta_arg: u16, mut htlc_minimum_msat_arg: u64, mut htlc_maximum_msat_arg: u64, mut features_arg: crate::lightning_types::features::BlindedHopFeatures) -> BlindedPayInfo { + BlindedPayInfo { inner: ObjOps::heap_alloc(nativeBlindedPayInfo { + fee_base_msat: fee_base_msat_arg, + fee_proportional_millionths: fee_proportional_millionths_arg, + cltv_expiry_delta: cltv_expiry_delta_arg, + htlc_minimum_msat: htlc_minimum_msat_arg, + htlc_maximum_msat: htlc_maximum_msat_arg, + features: *unsafe { Box::from_raw(features_arg.take_inner()) }, + }), is_owned: true } +} +impl Clone for BlindedPayInfo { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeBlindedPayInfo>::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 BlindedPayInfo_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeBlindedPayInfo)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the BlindedPayInfo +pub extern "C" fn BlindedPayInfo_clone(orig: &BlindedPayInfo) -> BlindedPayInfo { + orig.clone() +} +/// Get a string which allows debug introspection of a BlindedPayInfo object +pub extern "C" fn BlindedPayInfo_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::blinded_path::payment::BlindedPayInfo }).into()} +/// Generates a non-cryptographic 64-bit hash of the BlindedPayInfo. +#[no_mangle] +pub extern "C" fn BlindedPayInfo_hash(o: &BlindedPayInfo) -> 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 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. +#[no_mangle] +pub extern "C" fn BlindedPayInfo_eq(a: &BlindedPayInfo, b: &BlindedPayInfo) -> 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 BlindedPayInfo object into a byte array which can be read by BlindedPayInfo_read +pub extern "C" fn BlindedPayInfo_write(obj: &crate::lightning::blinded_path::payment::BlindedPayInfo) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[allow(unused)] +pub(crate) extern "C" fn BlindedPayInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::blinded_path::payment::nativeBlindedPayInfo) }) +} +#[no_mangle] +/// Read a BlindedPayInfo from a byte array, created by BlindedPayInfo_write +pub extern "C" fn BlindedPayInfo_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_BlindedPayInfoDecodeErrorZ { + 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::blinded_path::payment::BlindedPayInfo { 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::blinded_path::payment::BlindedPaymentPath as nativeBlindedPaymentPathImport; +pub(crate) type nativeBlindedPaymentPath = nativeBlindedPaymentPathImport; + +/// A blinded path to be used for sending or receiving a payment, hiding the identity of the +/// recipient. +#[must_use] +#[repr(C)] +pub struct BlindedPaymentPath { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, 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 nativeBlindedPaymentPath, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust 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 core::ops::Deref for BlindedPaymentPath { + type Target = nativeBlindedPaymentPath; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for BlindedPaymentPath { } +unsafe impl core::marker::Sync for BlindedPaymentPath { } +impl Drop for BlindedPaymentPath { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeBlindedPaymentPath>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the BlindedPaymentPath, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn BlindedPaymentPath_free(this_obj: BlindedPaymentPath) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn BlindedPaymentPath_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeBlindedPaymentPath) }; +} +#[allow(unused)] +impl BlindedPaymentPath { + pub(crate) fn get_native_ref(&self) -> &'static nativeBlindedPaymentPath { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeBlindedPaymentPath { + 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 nativeBlindedPaymentPath { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// The [`BlindedPayInfo`] used to pay this blinded path. +#[no_mangle] +pub extern "C" fn BlindedPaymentPath_get_payinfo(this_ptr: &BlindedPaymentPath) -> crate::lightning::blinded_path::payment::BlindedPayInfo { + let mut inner_val = &mut this_ptr.get_native_mut_ref().payinfo; + crate::lightning::blinded_path::payment::BlindedPayInfo { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::blinded_path::payment::BlindedPayInfo<>) as *mut _) }, is_owned: false } +} +/// The [`BlindedPayInfo`] used to pay this blinded path. +#[no_mangle] +pub extern "C" fn BlindedPaymentPath_set_payinfo(this_ptr: &mut BlindedPaymentPath, mut val: crate::lightning::blinded_path::payment::BlindedPayInfo) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payinfo = *unsafe { Box::from_raw(val.take_inner()) }; +} +impl Clone for BlindedPaymentPath { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeBlindedPaymentPath>::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 BlindedPaymentPath_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeBlindedPaymentPath)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the BlindedPaymentPath +pub extern "C" fn BlindedPaymentPath_clone(orig: &BlindedPaymentPath) -> BlindedPaymentPath { + orig.clone() +} +/// Get a string which allows debug introspection of a BlindedPaymentPath object +pub extern "C" fn BlindedPaymentPath_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::blinded_path::payment::BlindedPaymentPath }).into()} +/// Generates a non-cryptographic 64-bit hash of the BlindedPaymentPath. +#[no_mangle] +pub extern "C" fn BlindedPaymentPath_hash(o: &BlindedPaymentPath) -> 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 BlindedPaymentPaths 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 BlindedPaymentPath_eq(a: &BlindedPaymentPath, b: &BlindedPaymentPath) -> 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 } +} +/// Create a one-hop blinded path for a payment. +#[must_use] +#[no_mangle] +pub extern "C" fn BlindedPaymentPath_one_hop(mut payee_node_id: crate::c_types::PublicKey, mut payee_tlvs: crate::lightning::blinded_path::payment::ReceiveTlvs, mut min_final_cltv_expiry_delta: u16, mut entropy_source: crate::lightning::sign::EntropySource) -> crate::c_types::derived::CResult_BlindedPaymentPathNoneZ { + let mut ret = lightning::blinded_path::payment::BlindedPaymentPath::one_hop(payee_node_id.into_rust(), *unsafe { Box::from_raw(payee_tlvs.take_inner()) }, min_final_cltv_expiry_delta, entropy_source, secp256k1::global::SECP256K1); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::blinded_path::payment::BlindedPaymentPath { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Create a blinded path for a payment, to be forwarded along `intermediate_nodes`. +/// +/// Errors if: +/// * a provided node id is invalid +/// * [`BlindedPayInfo`] calculation results in an integer overflow +/// * any unknown features are required in the provided [`ForwardTlvs`] +#[must_use] +#[no_mangle] +pub extern "C" fn BlindedPaymentPath_new(mut intermediate_nodes: crate::c_types::derived::CVec_PaymentForwardNodeZ, mut payee_node_id: crate::c_types::PublicKey, mut payee_tlvs: crate::lightning::blinded_path::payment::ReceiveTlvs, mut htlc_maximum_msat: u64, mut min_final_cltv_expiry_delta: u16, mut entropy_source: crate::lightning::sign::EntropySource) -> crate::c_types::derived::CResult_BlindedPaymentPathNoneZ { + let mut local_intermediate_nodes = Vec::new(); for mut item in intermediate_nodes.into_rust().drain(..) { local_intermediate_nodes.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; + let mut ret = lightning::blinded_path::payment::BlindedPaymentPath::new(local_intermediate_nodes, payee_node_id.into_rust(), *unsafe { Box::from_raw(payee_tlvs.take_inner()) }, htlc_maximum_msat, min_final_cltv_expiry_delta, entropy_source, secp256k1::global::SECP256K1); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::blinded_path::payment::BlindedPaymentPath { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Returns the introduction [`NodeId`] of the blinded path, if it is publicly reachable (i.e., +/// it is found in the network graph). +/// +/// 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 BlindedPaymentPath_public_introduction_node_id(this_arg: &crate::lightning::blinded_path::payment::BlindedPaymentPath, network_graph: &crate::lightning::routing::gossip::ReadOnlyNetworkGraph) -> crate::lightning::routing::gossip::NodeId { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.public_introduction_node_id(network_graph.get_native_ref()); + let mut local_ret = crate::lightning::routing::gossip::NodeId { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning::routing::gossip::NodeId<>) as *mut _ }, is_owned: false }; + local_ret +} + +/// The [`IntroductionNode`] of the blinded path. +#[must_use] +#[no_mangle] +pub extern "C" fn BlindedPaymentPath_introduction_node(this_arg: &crate::lightning::blinded_path::payment::BlindedPaymentPath) -> crate::lightning::blinded_path::IntroductionNode { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.introduction_node(); + crate::lightning::blinded_path::IntroductionNode::from_native(ret) +} + +/// Used by the [`IntroductionNode`] to decrypt its [`encrypted_payload`] to forward the payment. +/// +/// [`encrypted_payload`]: BlindedHop::encrypted_payload +#[must_use] +#[no_mangle] +pub extern "C" fn BlindedPaymentPath_blinding_point(this_arg: &crate::lightning::blinded_path::payment::BlindedPaymentPath) -> crate::c_types::PublicKey { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.blinding_point(); + crate::c_types::PublicKey::from_rust(&ret) +} + +/// The [`BlindedHop`]s within the blinded path. +#[must_use] +#[no_mangle] +pub extern "C" fn BlindedPaymentPath_blinded_hops(this_arg: &crate::lightning::blinded_path::payment::BlindedPaymentPath) -> crate::c_types::derived::CVec_BlindedHopZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.blinded_hops(); + let mut local_ret_clone = Vec::new(); local_ret_clone.extend_from_slice(ret); let mut ret = local_ret_clone; let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::blinded_path::BlindedHop { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; + local_ret.into() +} + +/// Advance the blinded onion payment path by one hop, making the second hop into the new +/// introduction node. +/// +/// Will only modify `self` when returning `Ok`. +#[must_use] +#[no_mangle] +pub extern "C" fn BlindedPaymentPath_advance_path_by_one(this_arg: &mut crate::lightning::blinded_path::payment::BlindedPaymentPath, node_signer: &crate::lightning::sign::NodeSigner, node_id_lookup: &crate::lightning::blinded_path::NodeIdLookUp) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::blinded_path::payment::nativeBlindedPaymentPath)) }.advance_path_by_one(node_signer, node_id_lookup, 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( { () /*e*/ }).into() }; + local_ret +} + + +use lightning::blinded_path::payment::PaymentForwardNode as nativePaymentForwardNodeImport; +pub(crate) type nativePaymentForwardNode = nativePaymentForwardNodeImport; /// An intermediate node, its outbound channel, and relay parameters. #[must_use] #[repr(C)] -pub struct ForwardNode { +pub struct PaymentForwardNode { /// A pointer to the opaque Rust object. /// Nearly everywhere, 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 nativeForwardNode, + pub inner: *mut nativePaymentForwardNode, /// Indicates that this is the only struct which contains the same pointer. /// Rust functions which take ownership of an object provided via an argument require @@ -39,86 +435,95 @@ pub struct ForwardNode { pub is_owned: bool, } -impl Drop for ForwardNode { +impl core::ops::Deref for PaymentForwardNode { + type Target = nativePaymentForwardNode; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for PaymentForwardNode { } +unsafe impl core::marker::Sync for PaymentForwardNode { } +impl Drop for PaymentForwardNode { fn drop(&mut self) { - if self.is_owned && !<*mut nativeForwardNode>::is_null(self.inner) { + if self.is_owned && !<*mut nativePaymentForwardNode>::is_null(self.inner) { let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; } } } -/// Frees any resources used by the ForwardNode, if is_owned is set and inner is non-NULL. +/// Frees any resources used by the PaymentForwardNode, if is_owned is set and inner is non-NULL. #[no_mangle] -pub extern "C" fn ForwardNode_free(this_obj: ForwardNode) { } +pub extern "C" fn PaymentForwardNode_free(this_obj: PaymentForwardNode) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn ForwardNode_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeForwardNode) }; +pub(crate) extern "C" fn PaymentForwardNode_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativePaymentForwardNode) }; } #[allow(unused)] -impl ForwardNode { - pub(crate) fn get_native_ref(&self) -> &'static nativeForwardNode { +impl PaymentForwardNode { + pub(crate) fn get_native_ref(&self) -> &'static nativePaymentForwardNode { unsafe { &*ObjOps::untweak_ptr(self.inner) } } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeForwardNode { + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePaymentForwardNode { 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 nativeForwardNode { + pub(crate) fn take_inner(mut self) -> *mut nativePaymentForwardNode { assert!(self.is_owned); let ret = ObjOps::untweak_ptr(self.inner); self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The TLVs for this node's [`BlindedHop`], where the fee parameters contained within are also /// used for [`BlindedPayInfo`] construction. #[no_mangle] -pub extern "C" fn ForwardNode_get_tlvs(this_ptr: &ForwardNode) -> crate::lightning::blinded_path::payment::ForwardTlvs { +pub extern "C" fn PaymentForwardNode_get_tlvs(this_ptr: &PaymentForwardNode) -> crate::lightning::blinded_path::payment::ForwardTlvs { let mut inner_val = &mut this_ptr.get_native_mut_ref().tlvs; crate::lightning::blinded_path::payment::ForwardTlvs { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::blinded_path::payment::ForwardTlvs<>) as *mut _) }, is_owned: false } } /// The TLVs for this node's [`BlindedHop`], where the fee parameters contained within are also /// used for [`BlindedPayInfo`] construction. #[no_mangle] -pub extern "C" fn ForwardNode_set_tlvs(this_ptr: &mut ForwardNode, mut val: crate::lightning::blinded_path::payment::ForwardTlvs) { +pub extern "C" fn PaymentForwardNode_set_tlvs(this_ptr: &mut PaymentForwardNode, mut val: crate::lightning::blinded_path::payment::ForwardTlvs) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.tlvs = *unsafe { Box::from_raw(val.take_inner()) }; } /// This node's pubkey. #[no_mangle] -pub extern "C" fn ForwardNode_get_node_id(this_ptr: &ForwardNode) -> crate::c_types::PublicKey { +pub extern "C" fn PaymentForwardNode_get_node_id(this_ptr: &PaymentForwardNode) -> crate::c_types::PublicKey { let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id; crate::c_types::PublicKey::from_rust(&inner_val) } /// This node's pubkey. #[no_mangle] -pub extern "C" fn ForwardNode_set_node_id(this_ptr: &mut ForwardNode, mut val: crate::c_types::PublicKey) { +pub extern "C" fn PaymentForwardNode_set_node_id(this_ptr: &mut PaymentForwardNode, mut val: crate::c_types::PublicKey) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id = val.into_rust(); } /// The maximum value, in msat, that may be accepted by this node. #[no_mangle] -pub extern "C" fn ForwardNode_get_htlc_maximum_msat(this_ptr: &ForwardNode) -> u64 { +pub extern "C" fn PaymentForwardNode_get_htlc_maximum_msat(this_ptr: &PaymentForwardNode) -> u64 { let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_maximum_msat; *inner_val } /// The maximum value, in msat, that may be accepted by this node. #[no_mangle] -pub extern "C" fn ForwardNode_set_htlc_maximum_msat(this_ptr: &mut ForwardNode, mut val: u64) { +pub extern "C" fn PaymentForwardNode_set_htlc_maximum_msat(this_ptr: &mut PaymentForwardNode, mut val: u64) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_maximum_msat = val; } -/// Constructs a new ForwardNode given each field +/// Constructs a new PaymentForwardNode given each field #[must_use] #[no_mangle] -pub extern "C" fn ForwardNode_new(mut tlvs_arg: crate::lightning::blinded_path::payment::ForwardTlvs, mut node_id_arg: crate::c_types::PublicKey, mut htlc_maximum_msat_arg: u64) -> ForwardNode { - ForwardNode { inner: ObjOps::heap_alloc(nativeForwardNode { +pub extern "C" fn PaymentForwardNode_new(mut tlvs_arg: crate::lightning::blinded_path::payment::ForwardTlvs, mut node_id_arg: crate::c_types::PublicKey, mut htlc_maximum_msat_arg: u64) -> PaymentForwardNode { + PaymentForwardNode { inner: ObjOps::heap_alloc(nativePaymentForwardNode { tlvs: *unsafe { Box::from_raw(tlvs_arg.take_inner()) }, node_id: node_id_arg.into_rust(), htlc_maximum_msat: htlc_maximum_msat_arg, }), is_owned: true } } -impl Clone for ForwardNode { +impl Clone for PaymentForwardNode { fn clone(&self) -> Self { Self { - inner: if <*mut nativeForwardNode>::is_null(self.inner) { core::ptr::null_mut() } else { + inner: if <*mut nativePaymentForwardNode>::is_null(self.inner) { core::ptr::null_mut() } else { ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, is_owned: true, } @@ -126,17 +531,17 @@ impl Clone for ForwardNode { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn ForwardNode_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeForwardNode)).clone() })) as *mut c_void +pub(crate) extern "C" fn PaymentForwardNode_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativePaymentForwardNode)).clone() })) as *mut c_void } #[no_mangle] -/// Creates a copy of the ForwardNode -pub extern "C" fn ForwardNode_clone(orig: &ForwardNode) -> ForwardNode { +/// Creates a copy of the PaymentForwardNode +pub extern "C" fn PaymentForwardNode_clone(orig: &PaymentForwardNode) -> PaymentForwardNode { orig.clone() } -/// Get a string which allows debug introspection of a ForwardNode object -pub extern "C" fn ForwardNode_debug_str_void(o: *const c_void) -> Str { - alloc::format!("{:?}", unsafe { o as *const crate::lightning::blinded_path::payment::ForwardNode }).into()} +/// Get a string which allows debug introspection of a PaymentForwardNode object +pub extern "C" fn PaymentForwardNode_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::blinded_path::payment::PaymentForwardNode }).into()} use lightning::blinded_path::payment::ForwardTlvs as nativeForwardTlvsImport; pub(crate) type nativeForwardTlvs = nativeForwardTlvsImport; @@ -157,6 +562,12 @@ pub struct ForwardTlvs { pub is_owned: bool, } +impl core::ops::Deref for ForwardTlvs { + type Target = nativeForwardTlvs; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ForwardTlvs { } +unsafe impl core::marker::Sync for ForwardTlvs { } impl Drop for ForwardTlvs { fn drop(&mut self) { if self.is_owned && !<*mut nativeForwardTlvs>::is_null(self.inner) { @@ -187,6 +598,9 @@ impl ForwardTlvs { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The short channel id this payment should be forwarded out over. #[no_mangle] @@ -226,27 +640,50 @@ pub extern "C" fn ForwardTlvs_set_payment_constraints(this_ptr: &mut ForwardTlvs /// /// [`BlindedHop::encrypted_payload`]: crate::blinded_path::BlindedHop::encrypted_payload #[no_mangle] -pub extern "C" fn ForwardTlvs_get_features(this_ptr: &ForwardTlvs) -> crate::lightning::ln::features::BlindedHopFeatures { +pub extern "C" fn ForwardTlvs_get_features(this_ptr: &ForwardTlvs) -> crate::lightning_types::features::BlindedHopFeatures { let mut inner_val = &mut this_ptr.get_native_mut_ref().features; - crate::lightning::ln::features::BlindedHopFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::features::BlindedHopFeatures<>) as *mut _) }, is_owned: false } + crate::lightning_types::features::BlindedHopFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning_types::features::BlindedHopFeatures<>) as *mut _) }, is_owned: false } } /// Supported and required features when relaying a payment onion containing this object's /// corresponding [`BlindedHop::encrypted_payload`]. /// /// [`BlindedHop::encrypted_payload`]: crate::blinded_path::BlindedHop::encrypted_payload #[no_mangle] -pub extern "C" fn ForwardTlvs_set_features(this_ptr: &mut ForwardTlvs, mut val: crate::lightning::ln::features::BlindedHopFeatures) { +pub extern "C" fn ForwardTlvs_set_features(this_ptr: &mut ForwardTlvs, mut val: crate::lightning_types::features::BlindedHopFeatures) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) }; } +/// Set if this [`BlindedPaymentPath`] is concatenated to another, to indicate the +/// [`BlindedPaymentPath::blinding_point`] of the appended blinded path. +/// +/// 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 ForwardTlvs_get_next_blinding_override(this_ptr: &ForwardTlvs) -> crate::c_types::PublicKey { + let mut inner_val = &mut this_ptr.get_native_mut_ref().next_blinding_override; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::PublicKey::null() } else { { crate::c_types::PublicKey::from_rust(&(inner_val.unwrap())) } }; + local_inner_val +} +/// Set if this [`BlindedPaymentPath`] is concatenated to another, to indicate the +/// [`BlindedPaymentPath::blinding_point`] of the appended blinded path. +/// +/// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None +#[no_mangle] +pub extern "C" fn ForwardTlvs_set_next_blinding_override(this_ptr: &mut ForwardTlvs, mut val: crate::c_types::PublicKey) { + let mut local_val = if val.is_null() { None } else { Some( { val.into_rust() }) }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_blinding_override = local_val; +} /// Constructs a new ForwardTlvs given each field +/// +/// Note that next_blinding_override_arg (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn ForwardTlvs_new(mut short_channel_id_arg: u64, mut payment_relay_arg: crate::lightning::blinded_path::payment::PaymentRelay, mut payment_constraints_arg: crate::lightning::blinded_path::payment::PaymentConstraints, mut features_arg: crate::lightning::ln::features::BlindedHopFeatures) -> ForwardTlvs { +pub extern "C" fn ForwardTlvs_new(mut short_channel_id_arg: u64, mut payment_relay_arg: crate::lightning::blinded_path::payment::PaymentRelay, mut payment_constraints_arg: crate::lightning::blinded_path::payment::PaymentConstraints, mut features_arg: crate::lightning_types::features::BlindedHopFeatures, mut next_blinding_override_arg: crate::c_types::PublicKey) -> ForwardTlvs { + let mut local_next_blinding_override_arg = if next_blinding_override_arg.is_null() { None } else { Some( { next_blinding_override_arg.into_rust() }) }; ForwardTlvs { inner: ObjOps::heap_alloc(nativeForwardTlvs { short_channel_id: short_channel_id_arg, payment_relay: *unsafe { Box::from_raw(payment_relay_arg.take_inner()) }, payment_constraints: *unsafe { Box::from_raw(payment_constraints_arg.take_inner()) }, features: *unsafe { Box::from_raw(features_arg.take_inner()) }, + next_blinding_override: local_next_blinding_override_arg, }), is_owned: true } } impl Clone for ForwardTlvs { @@ -292,6 +729,12 @@ pub struct ReceiveTlvs { pub is_owned: bool, } +impl core::ops::Deref for ReceiveTlvs { + type Target = nativeReceiveTlvs; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ReceiveTlvs { } +unsafe impl core::marker::Sync for ReceiveTlvs { } impl Drop for ReceiveTlvs { fn drop(&mut self) { if self.is_owned && !<*mut nativeReceiveTlvs>::is_null(self.inner) { @@ -322,6 +765,9 @@ impl ReceiveTlvs { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Used to authenticate the sender of a payment to the receiver and tie MPP HTLCs together. #[no_mangle] @@ -410,6 +856,12 @@ pub struct PaymentRelay { pub is_owned: bool, } +impl core::ops::Deref for PaymentRelay { + type Target = nativePaymentRelay; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for PaymentRelay { } +unsafe impl core::marker::Sync for PaymentRelay { } impl Drop for PaymentRelay { fn drop(&mut self) { if self.is_owned && !<*mut nativePaymentRelay>::is_null(self.inner) { @@ -440,6 +892,9 @@ impl PaymentRelay { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Number of blocks subtracted from an incoming HTLC's `cltv_expiry` for this [`BlindedHop`]. #[no_mangle] @@ -530,6 +985,12 @@ pub struct PaymentConstraints { pub is_owned: bool, } +impl core::ops::Deref for PaymentConstraints { + type Target = nativePaymentConstraints; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for PaymentConstraints { } +unsafe impl core::marker::Sync for PaymentConstraints { } impl Drop for PaymentConstraints { fn drop(&mut self) { if self.is_owned && !<*mut nativePaymentConstraints>::is_null(self.inner) { @@ -560,6 +1021,9 @@ impl PaymentConstraints { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The maximum total CLTV that is acceptable when relaying a payment over this [`BlindedHop`]. #[no_mangle] @@ -616,10 +1080,9 @@ pub extern "C" fn PaymentConstraints_clone(orig: &PaymentConstraints) -> Payment /// Get a string which allows debug introspection of a PaymentConstraints object pub extern "C" fn PaymentConstraints_debug_str_void(o: *const c_void) -> Str { alloc::format!("{:?}", unsafe { o as *const crate::lightning::blinded_path::payment::PaymentConstraints }).into()} -/// The context of an inbound payment, which is included in a [`BlindedPath`] via [`ReceiveTlvs`] -/// and surfaced in [`PaymentPurpose`]. +/// The context of an inbound payment, which is included in a [`BlindedPaymentPath`] via +/// [`ReceiveTlvs`] and surfaced in [`PaymentPurpose`]. /// -/// [`BlindedPath`]: crate::blinded_path::BlindedPath /// [`PaymentPurpose`]: crate::events::PaymentPurpose #[derive(Clone)] #[must_use] @@ -793,6 +1256,12 @@ pub struct UnknownPaymentContext { pub is_owned: bool, } +impl core::ops::Deref for UnknownPaymentContext { + type Target = nativeUnknownPaymentContext; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for UnknownPaymentContext { } +unsafe impl core::marker::Sync for UnknownPaymentContext { } impl Drop for UnknownPaymentContext { fn drop(&mut self) { if self.is_owned && !<*mut nativeUnknownPaymentContext>::is_null(self.inner) { @@ -823,6 +1292,9 @@ impl UnknownPaymentContext { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } impl Clone for UnknownPaymentContext { fn clone(&self) -> Self { @@ -877,6 +1349,12 @@ pub struct Bolt12OfferContext { pub is_owned: bool, } +impl core::ops::Deref for Bolt12OfferContext { + type Target = nativeBolt12OfferContext; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for Bolt12OfferContext { } +unsafe impl core::marker::Sync for Bolt12OfferContext { } impl Drop for Bolt12OfferContext { fn drop(&mut self) { if self.is_owned && !<*mut nativeBolt12OfferContext>::is_null(self.inner) { @@ -907,6 +1385,9 @@ impl Bolt12OfferContext { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The identifier of the [`Offer`]. /// @@ -1002,6 +1483,12 @@ pub struct Bolt12RefundContext { pub is_owned: bool, } +impl core::ops::Deref for Bolt12RefundContext { + type Target = nativeBolt12RefundContext; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for Bolt12RefundContext { } +unsafe impl core::marker::Sync for Bolt12RefundContext { } impl Drop for Bolt12RefundContext { fn drop(&mut self) { if self.is_owned && !<*mut nativeBolt12RefundContext>::is_null(self.inner) { @@ -1032,6 +1519,9 @@ impl Bolt12RefundContext { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Constructs a new Bolt12RefundContext given each field #[must_use] @@ -1078,7 +1568,7 @@ pub extern "C" fn ForwardTlvs_write(obj: &crate::lightning::blinded_path::paymen } #[allow(unused)] pub(crate) extern "C" fn ForwardTlvs_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeForwardTlvs) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::blinded_path::payment::nativeForwardTlvs) }) } #[no_mangle] /// Serialize the ReceiveTlvs object into a byte array which can be read by ReceiveTlvs_read @@ -1087,7 +1577,7 @@ pub extern "C" fn ReceiveTlvs_write(obj: &crate::lightning::blinded_path::paymen } #[allow(unused)] pub(crate) extern "C" fn ReceiveTlvs_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReceiveTlvs) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::blinded_path::payment::nativeReceiveTlvs) }) } #[no_mangle] /// Serialize the PaymentRelay object into a byte array which can be read by PaymentRelay_read @@ -1096,7 +1586,7 @@ pub extern "C" fn PaymentRelay_write(obj: &crate::lightning::blinded_path::payme } #[allow(unused)] pub(crate) extern "C" fn PaymentRelay_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePaymentRelay) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::blinded_path::payment::nativePaymentRelay) }) } #[no_mangle] /// Read a PaymentRelay from a byte array, created by PaymentRelay_write @@ -1112,7 +1602,7 @@ pub extern "C" fn PaymentConstraints_write(obj: &crate::lightning::blinded_path: } #[allow(unused)] pub(crate) extern "C" fn PaymentConstraints_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePaymentConstraints) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::blinded_path::payment::nativePaymentConstraints) }) } #[no_mangle] /// Read a PaymentConstraints from a byte array, created by PaymentConstraints_write @@ -1144,7 +1634,7 @@ pub extern "C" fn UnknownPaymentContext_write(obj: &crate::lightning::blinded_pa } #[allow(unused)] pub(crate) extern "C" fn UnknownPaymentContext_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnknownPaymentContext) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::blinded_path::payment::nativeUnknownPaymentContext) }) } #[no_mangle] /// Read a UnknownPaymentContext from a byte array, created by UnknownPaymentContext_write @@ -1160,7 +1650,7 @@ pub extern "C" fn Bolt12OfferContext_write(obj: &crate::lightning::blinded_path: } #[allow(unused)] pub(crate) extern "C" fn Bolt12OfferContext_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeBolt12OfferContext) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::blinded_path::payment::nativeBolt12OfferContext) }) } #[no_mangle] /// Read a Bolt12OfferContext from a byte array, created by Bolt12OfferContext_write @@ -1176,7 +1666,7 @@ pub extern "C" fn Bolt12RefundContext_write(obj: &crate::lightning::blinded_path } #[allow(unused)] pub(crate) extern "C" fn Bolt12RefundContext_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeBolt12RefundContext) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::blinded_path::payment::nativeBolt12RefundContext) }) } #[no_mangle] /// Read a Bolt12RefundContext from a byte array, created by Bolt12RefundContext_write diff --git a/lightning-c-bindings/src/lightning/chain/chaininterface.rs b/lightning-c-bindings/src/lightning/chain/chaininterface.rs index e85a87e..2f86326 100644 --- a/lightning-c-bindings/src/lightning/chain/chaininterface.rs +++ b/lightning-c-bindings/src/lightning/chain/chaininterface.rs @@ -58,23 +58,31 @@ pub(crate) fn BroadcasterInterface_clone_fields(orig: &BroadcasterInterface) -> use lightning::chain::chaininterface::BroadcasterInterface as rustBroadcasterInterface; impl rustBroadcasterInterface for BroadcasterInterface { - fn broadcast_transactions(&self, mut txs: &[&bitcoin::blockdata::transaction::Transaction]) { + fn broadcast_transactions(&self, mut txs: &[&bitcoin::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()) } } +pub struct BroadcasterInterfaceRef(BroadcasterInterface); +impl rustBroadcasterInterface for BroadcasterInterfaceRef { + fn broadcast_transactions(&self, mut txs: &[&bitcoin::transaction::Transaction]) { + let mut local_txs = Vec::new(); for item in txs.iter() { local_txs.push( { crate::c_types::Transaction::from_bitcoin((*item)) }); }; + (self.0.broadcast_transactions)(self.0.this_arg, local_txs.into()) + } +} + // 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 BroadcasterInterface { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = BroadcasterInterfaceRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const BroadcasterInterfaceRef) } } } impl core::ops::DerefMut for BroadcasterInterface { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut BroadcasterInterfaceRef { + unsafe { &mut *(self as *mut _ as *mut BroadcasterInterfaceRef) } } } /// Calls the free function if one is set @@ -93,11 +101,19 @@ impl Drop for BroadcasterInterface { #[must_use] #[repr(C)] pub enum ConfirmationTarget { + /// The most aggressive (i.e. highest) feerate estimate available. + /// + /// This is used to sanity-check our counterparty's feerates and should be as conservative as + /// possible to ensure that we don't confuse a peer using a very conservative estimator for one + /// trying to burn channel balance to dust. + MaximumFeeEstimate, /// We have some funds available on chain which we need to spend prior to some expiry time at - /// which point our counterparty may be able to steal them. Generally we have in the high tens - /// to low hundreds of blocks to get our transaction on-chain, but we shouldn't risk too low a - /// fee - this should be a relatively high priority feerate. - OnChainSweep, + /// which point our counterparty may be able to steal them. + /// + /// Generally we have in the high tens to low hundreds of blocks to get our transaction + /// on-chain (it doesn't have to happen in the next few blocks!), but we shouldn't risk too low + /// a fee - this should be a relatively high priority feerate. + UrgentOnChainSweep, /// This is the lowest feerate we will allow our channel counterparty to have in an anchor /// channel in order to close the channel if a channel party goes away. /// @@ -168,14 +184,18 @@ pub enum ConfirmationTarget { /// /// [`ChannelManager::close_channel_with_feerate_and_script`]: crate::ln::channelmanager::ChannelManager::close_channel_with_feerate_and_script ChannelCloseMinimum, - /// The feerate [`OutputSweeper`] will use on transactions spending - /// [`SpendableOutputDescriptor`]s after a channel closure. + /// The feerate used to claim on-chain funds when there is no particular urgency to do so. + /// + /// It is used to get commitment transactions without any HTLCs confirmed in [`ChannelMonitor`] + /// and by [`OutputSweeper`] on transactions spending [`SpendableOutputDescriptor`]s after a + /// channel closure. /// /// Generally spending these outputs is safe as long as they eventually confirm, so a value /// (slightly above) the mempool minimum should suffice. However, as this value will influence /// how long funds will be unavailable after channel closure, [`FeeEstimator`] implementors /// might want to choose a higher feerate to regain control over funds faster. /// + /// [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor /// [`OutputSweeper`]: crate::util::sweep::OutputSweeper /// [`SpendableOutputDescriptor`]: crate::sign::SpendableOutputDescriptor OutputSpendingFee, @@ -187,7 +207,8 @@ impl ConfirmationTarget { #[allow(unused)] pub(crate) fn to_native(&self) -> nativeConfirmationTarget { match self { - ConfirmationTarget::OnChainSweep => nativeConfirmationTarget::OnChainSweep, + ConfirmationTarget::MaximumFeeEstimate => nativeConfirmationTarget::MaximumFeeEstimate, + ConfirmationTarget::UrgentOnChainSweep => nativeConfirmationTarget::UrgentOnChainSweep, ConfirmationTarget::MinAllowedAnchorChannelRemoteFee => nativeConfirmationTarget::MinAllowedAnchorChannelRemoteFee, ConfirmationTarget::MinAllowedNonAnchorChannelRemoteFee => nativeConfirmationTarget::MinAllowedNonAnchorChannelRemoteFee, ConfirmationTarget::AnchorChannelFee => nativeConfirmationTarget::AnchorChannelFee, @@ -199,7 +220,8 @@ impl ConfirmationTarget { #[allow(unused)] pub(crate) fn into_native(self) -> nativeConfirmationTarget { match self { - ConfirmationTarget::OnChainSweep => nativeConfirmationTarget::OnChainSweep, + ConfirmationTarget::MaximumFeeEstimate => nativeConfirmationTarget::MaximumFeeEstimate, + ConfirmationTarget::UrgentOnChainSweep => nativeConfirmationTarget::UrgentOnChainSweep, ConfirmationTarget::MinAllowedAnchorChannelRemoteFee => nativeConfirmationTarget::MinAllowedAnchorChannelRemoteFee, ConfirmationTarget::MinAllowedNonAnchorChannelRemoteFee => nativeConfirmationTarget::MinAllowedNonAnchorChannelRemoteFee, ConfirmationTarget::AnchorChannelFee => nativeConfirmationTarget::AnchorChannelFee, @@ -212,7 +234,8 @@ impl ConfirmationTarget { pub(crate) fn from_native(native: &ConfirmationTargetImport) -> Self { let native = unsafe { &*(native as *const _ as *const c_void as *const nativeConfirmationTarget) }; match native { - nativeConfirmationTarget::OnChainSweep => ConfirmationTarget::OnChainSweep, + nativeConfirmationTarget::MaximumFeeEstimate => ConfirmationTarget::MaximumFeeEstimate, + nativeConfirmationTarget::UrgentOnChainSweep => ConfirmationTarget::UrgentOnChainSweep, nativeConfirmationTarget::MinAllowedAnchorChannelRemoteFee => ConfirmationTarget::MinAllowedAnchorChannelRemoteFee, nativeConfirmationTarget::MinAllowedNonAnchorChannelRemoteFee => ConfirmationTarget::MinAllowedNonAnchorChannelRemoteFee, nativeConfirmationTarget::AnchorChannelFee => ConfirmationTarget::AnchorChannelFee, @@ -224,7 +247,8 @@ impl ConfirmationTarget { #[allow(unused)] pub(crate) fn native_into(native: nativeConfirmationTarget) -> Self { match native { - nativeConfirmationTarget::OnChainSweep => ConfirmationTarget::OnChainSweep, + nativeConfirmationTarget::MaximumFeeEstimate => ConfirmationTarget::MaximumFeeEstimate, + nativeConfirmationTarget::UrgentOnChainSweep => ConfirmationTarget::UrgentOnChainSweep, nativeConfirmationTarget::MinAllowedAnchorChannelRemoteFee => ConfirmationTarget::MinAllowedAnchorChannelRemoteFee, nativeConfirmationTarget::MinAllowedNonAnchorChannelRemoteFee => ConfirmationTarget::MinAllowedNonAnchorChannelRemoteFee, nativeConfirmationTarget::AnchorChannelFee => ConfirmationTarget::AnchorChannelFee, @@ -250,9 +274,13 @@ pub(crate) extern "C" fn ConfirmationTarget_free_void(this_ptr: *mut c_void) { let _ = unsafe { Box::from_raw(this_ptr as *mut ConfirmationTarget) }; } #[no_mangle] -/// Utility method to constructs a new OnChainSweep-variant ConfirmationTarget -pub extern "C" fn ConfirmationTarget_on_chain_sweep() -> ConfirmationTarget { - ConfirmationTarget::OnChainSweep} +/// Utility method to constructs a new MaximumFeeEstimate-variant ConfirmationTarget +pub extern "C" fn ConfirmationTarget_maximum_fee_estimate() -> ConfirmationTarget { + ConfirmationTarget::MaximumFeeEstimate} +#[no_mangle] +/// Utility method to constructs a new UrgentOnChainSweep-variant ConfirmationTarget +pub extern "C" fn ConfirmationTarget_urgent_on_chain_sweep() -> ConfirmationTarget { + ConfirmationTarget::UrgentOnChainSweep} #[no_mangle] /// Utility method to constructs a new MinAllowedAnchorChannelRemoteFee-variant ConfirmationTarget pub extern "C" fn ConfirmationTarget_min_allowed_anchor_channel_remote_fee() -> ConfirmationTarget { @@ -346,17 +374,25 @@ impl rustFeeEstimator for FeeEstimator { } } +pub struct FeeEstimatorRef(FeeEstimator); +impl rustFeeEstimator for FeeEstimatorRef { + fn get_est_sat_per_1000_weight(&self, mut confirmation_target: lightning::chain::chaininterface::ConfirmationTarget) -> u32 { + let mut ret = (self.0.get_est_sat_per_1000_weight)(self.0.this_arg, crate::lightning::chain::chaininterface::ConfirmationTarget::native_into(confirmation_target)); + 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 FeeEstimator { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = FeeEstimatorRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const FeeEstimatorRef) } } } impl core::ops::DerefMut for FeeEstimator { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut FeeEstimatorRef { + unsafe { &mut *(self as *mut _ as *mut FeeEstimatorRef) } } } /// Calls the free function if one is set diff --git a/lightning-c-bindings/src/lightning/chain/chainmonitor.rs b/lightning-c-bindings/src/lightning/chain/chainmonitor.rs index a8633ae..851c182 100644 --- a/lightning-c-bindings/src/lightning/chain/chainmonitor.rs +++ b/lightning-c-bindings/src/lightning/chain/chainmonitor.rs @@ -31,110 +31,6 @@ use crate::c_types::*; #[cfg(feature="no-std")] use alloc::{vec::Vec, boxed::Box}; -mod update_origin { - -use alloc::str::FromStr; -use alloc::string::String; -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::chainmonitor::MonitorUpdateId as nativeMonitorUpdateIdImport; -pub(crate) type nativeMonitorUpdateId = nativeMonitorUpdateIdImport; - -/// An opaque identifier describing a specific [`Persist`] method call. -#[must_use] -#[repr(C)] -pub struct MonitorUpdateId { - /// A pointer to the opaque Rust object. - - /// Nearly everywhere, 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 nativeMonitorUpdateId, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust 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 MonitorUpdateId { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeMonitorUpdateId>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; - } - } -} -/// Frees any resources used by the MonitorUpdateId, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn MonitorUpdateId_free(this_obj: MonitorUpdateId) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn MonitorUpdateId_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeMonitorUpdateId) }; -} -#[allow(unused)] -impl MonitorUpdateId { - pub(crate) fn get_native_ref(&self) -> &'static nativeMonitorUpdateId { - unsafe { &*ObjOps::untweak_ptr(self.inner) } - } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeMonitorUpdateId { - 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 nativeMonitorUpdateId { - assert!(self.is_owned); - let ret = ObjOps::untweak_ptr(self.inner); - self.inner = core::ptr::null_mut(); - ret - } -} -/// Get a string which allows debug introspection of a MonitorUpdateId object -pub extern "C" fn MonitorUpdateId_debug_str_void(o: *const c_void) -> Str { - alloc::format!("{:?}", unsafe { o as *const crate::lightning::chain::chainmonitor::MonitorUpdateId }).into()} -impl Clone for MonitorUpdateId { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeMonitorUpdateId>::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 MonitorUpdateId_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeMonitorUpdateId)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the MonitorUpdateId -pub extern "C" fn MonitorUpdateId_clone(orig: &MonitorUpdateId) -> MonitorUpdateId { - orig.clone() -} -/// Generates a non-cryptographic 64-bit hash of the MonitorUpdateId. -#[no_mangle] -pub extern "C" fn MonitorUpdateId_hash(o: &MonitorUpdateId) -> 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 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. -#[no_mangle] -pub extern "C" fn MonitorUpdateId_eq(a: &MonitorUpdateId, b: &MonitorUpdateId) -> 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 } -} /// `Persist` defines behavior for persisting channel monitors: this could mean /// writing once to disk, and/or uploading to one or more backup services. /// @@ -167,7 +63,7 @@ pub extern "C" fn MonitorUpdateId_eq(a: &MonitorUpdateId, b: &MonitorUpdateId) - /// All calls should generally spawn a background task and immediately return /// [`ChannelMonitorUpdateStatus::InProgress`]. Once the update completes, /// [`ChainMonitor::channel_monitor_updated`] should be called with the corresponding -/// [`MonitorUpdateId`]. +/// [`ChannelMonitor::get_latest_update_id`] or [`ChannelMonitorUpdate::update_id`]. /// /// Note that unlike the direct [`chain::Watch`] interface, /// [`ChainMonitor::channel_monitor_updated`] must be called once for *each* update which occurs. @@ -202,15 +98,16 @@ pub struct Persist { /// 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`]. + /// The [`ChannelMonitor::get_latest_update_id`] uniquely links this call to [`ChainMonitor::channel_monitor_updated`]. + /// For [`Persist::persist_new_channel`], it is only necessary to call [`ChainMonitor::channel_monitor_updated`] + /// when 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 - pub persist_new_channel: extern "C" fn (this_arg: *const c_void, channel_funding_outpoint: crate::lightning::chain::transaction::OutPoint, data: &crate::lightning::chain::channelmonitor::ChannelMonitor, update_id: crate::lightning::chain::chainmonitor::MonitorUpdateId) -> crate::lightning::chain::ChannelMonitorUpdateStatus, + pub persist_new_channel: extern "C" fn (this_arg: *const c_void, channel_funding_outpoint: crate::lightning::chain::transaction::OutPoint, monitor: &crate::lightning::chain::channelmonitor::ChannelMonitor) -> crate::lightning::chain::ChannelMonitorUpdateStatus, /// Update one channel's data. The provided [`ChannelMonitor`] has already applied the given /// update. /// @@ -227,7 +124,9 @@ pub struct Persist { /// 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 + /// deserialization routine. If there are any gaps in the persisted [`ChannelMonitorUpdate`]s, + /// implementer can safely ignore [`ChannelMonitorUpdate`]s after the gap and load without them. + /// 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. /// @@ -236,8 +135,10 @@ pub struct Persist { /// 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`]. + /// The [`ChannelMonitorUpdate::update_id`] or [`ChannelMonitor::get_latest_update_id`] uniquely + /// links this call to [`ChainMonitor::channel_monitor_updated`]. + /// For [`Persist::update_persisted_channel`], it is only necessary to call [`ChainMonitor::channel_monitor_updated`] + /// when a [`ChannelMonitorUpdate`] is provided and when you return [`ChannelMonitorUpdateStatus::InProgress`]. /// /// See [`Writeable::write`] on [`ChannelMonitor`] for writing out a `ChannelMonitor`, /// [`Writeable::write`] on [`ChannelMonitorUpdate`] for writing out an update, and @@ -245,8 +146,8 @@ 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 - pub update_persisted_channel: extern "C" fn (this_arg: *const c_void, channel_funding_outpoint: 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, + /// Note that monitor_update (or a relevant inner pointer) may be NULL or all-0s to represent None + pub update_persisted_channel: extern "C" fn (this_arg: *const c_void, channel_funding_outpoint: crate::lightning::chain::transaction::OutPoint, monitor_update: crate::lightning::chain::channelmonitor::ChannelMonitorUpdate, monitor: &crate::lightning::chain::channelmonitor::ChannelMonitor) -> crate::lightning::chain::ChannelMonitorUpdateStatus, /// Prevents the channel monitor from being loaded on startup. /// /// Archiving the data in a backup location (rather than deleting it fully) is useful for @@ -270,14 +171,14 @@ pub(crate) 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_funding_outpoint: 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_funding_outpoint), 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 }); +impl rustPersist for Persist { + fn persist_new_channel(&self, mut channel_funding_outpoint: lightning::chain::transaction::OutPoint, mut monitor: &lightning::chain::channelmonitor::ChannelMonitor) -> lightning::chain::ChannelMonitorUpdateStatus { + let mut ret = (self.persist_new_channel)(self.this_arg, crate::lightning::chain::transaction::OutPoint { inner: ObjOps::heap_alloc(channel_funding_outpoint), is_owned: true }, &crate::lightning::chain::channelmonitor::ChannelMonitor { inner: unsafe { ObjOps::nonnull_ptr_to_inner((monitor as *const lightning::chain::channelmonitor::ChannelMonitor<_, >) as *mut _) }, is_owned: false }); ret.into_native() } - fn update_persisted_channel(&self, mut channel_funding_outpoint: 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_funding_outpoint), 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 }); + fn update_persisted_channel(&self, mut channel_funding_outpoint: lightning::chain::transaction::OutPoint, mut monitor_update: Option<&lightning::chain::channelmonitor::ChannelMonitorUpdate>, mut monitor: &lightning::chain::channelmonitor::ChannelMonitor) -> lightning::chain::ChannelMonitorUpdateStatus { + let mut local_monitor_update = crate::lightning::chain::channelmonitor::ChannelMonitorUpdate { inner: unsafe { (if monitor_update.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (monitor_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_funding_outpoint), is_owned: true }, local_monitor_update, &crate::lightning::chain::channelmonitor::ChannelMonitor { inner: unsafe { ObjOps::nonnull_ptr_to_inner((monitor as *const lightning::chain::channelmonitor::ChannelMonitor<_, >) as *mut _) }, is_owned: false }); ret.into_native() } fn archive_persisted_channel(&self, mut channel_funding_outpoint: lightning::chain::transaction::OutPoint) { @@ -285,17 +186,33 @@ impl rustPersist f } } +pub struct PersistRef(Persist); +impl rustPersist for PersistRef { + fn persist_new_channel(&self, mut channel_funding_outpoint: lightning::chain::transaction::OutPoint, mut monitor: &lightning::chain::channelmonitor::ChannelMonitor) -> lightning::chain::ChannelMonitorUpdateStatus { + let mut ret = (self.0.persist_new_channel)(self.0.this_arg, crate::lightning::chain::transaction::OutPoint { inner: ObjOps::heap_alloc(channel_funding_outpoint), is_owned: true }, &crate::lightning::chain::channelmonitor::ChannelMonitor { inner: unsafe { ObjOps::nonnull_ptr_to_inner((monitor as *const lightning::chain::channelmonitor::ChannelMonitor<_, >) as *mut _) }, is_owned: false }); + ret.into_native() + } + fn update_persisted_channel(&self, mut channel_funding_outpoint: lightning::chain::transaction::OutPoint, mut monitor_update: Option<&lightning::chain::channelmonitor::ChannelMonitorUpdate>, mut monitor: &lightning::chain::channelmonitor::ChannelMonitor) -> lightning::chain::ChannelMonitorUpdateStatus { + let mut local_monitor_update = crate::lightning::chain::channelmonitor::ChannelMonitorUpdate { inner: unsafe { (if monitor_update.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (monitor_update.unwrap()) }) } as *const lightning::chain::channelmonitor::ChannelMonitorUpdate<>) as *mut _ }, is_owned: false }; + let mut ret = (self.0.update_persisted_channel)(self.0.this_arg, crate::lightning::chain::transaction::OutPoint { inner: ObjOps::heap_alloc(channel_funding_outpoint), is_owned: true }, local_monitor_update, &crate::lightning::chain::channelmonitor::ChannelMonitor { inner: unsafe { ObjOps::nonnull_ptr_to_inner((monitor as *const lightning::chain::channelmonitor::ChannelMonitor<_, >) as *mut _) }, is_owned: false }); + ret.into_native() + } + fn archive_persisted_channel(&self, mut channel_funding_outpoint: lightning::chain::transaction::OutPoint) { + (self.0.archive_persisted_channel)(self.0.this_arg, crate::lightning::chain::transaction::OutPoint { inner: ObjOps::heap_alloc(channel_funding_outpoint), is_owned: true }) + } +} + // 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 Persist { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = PersistRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const PersistRef) } } } impl core::ops::DerefMut for Persist { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut PersistRef { + unsafe { &mut *(self as *mut _ as *mut PersistRef) } } } /// Calls the free function if one is set @@ -310,7 +227,7 @@ impl Drop for Persist { } use lightning::chain::chainmonitor::LockedChannelMonitor as nativeLockedChannelMonitorImport; -pub(crate) type nativeLockedChannelMonitor = nativeLockedChannelMonitorImport<'static, crate::lightning::sign::ecdsa::WriteableEcdsaChannelSigner, >; +pub(crate) type nativeLockedChannelMonitor = nativeLockedChannelMonitorImport<'static, crate::lightning::sign::ecdsa::EcdsaChannelSigner, >; /// A read-only reference to a current ChannelMonitor. /// @@ -331,6 +248,12 @@ pub struct LockedChannelMonitor { pub is_owned: bool, } +impl core::ops::Deref for LockedChannelMonitor { + type Target = nativeLockedChannelMonitor; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for LockedChannelMonitor { } +unsafe impl core::marker::Sync for LockedChannelMonitor { } impl Drop for LockedChannelMonitor { fn drop(&mut self) { if self.is_owned && !<*mut nativeLockedChannelMonitor>::is_null(self.inner) { @@ -361,10 +284,13 @@ impl LockedChannelMonitor { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } 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. /// @@ -397,6 +323,12 @@ pub struct ChainMonitor { pub is_owned: bool, } +impl core::ops::Deref for ChainMonitor { + type Target = nativeChainMonitor; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ChainMonitor { } +unsafe impl core::marker::Sync for ChainMonitor { } impl Drop for ChainMonitor { fn drop(&mut self) { if self.is_owned && !<*mut nativeChainMonitor>::is_null(self.inner) { @@ -427,6 +359,9 @@ impl ChainMonitor { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Creates a new `ChainMonitor` used to watch on-chain activity pertaining to channels. /// @@ -447,8 +382,7 @@ pub extern "C" fn ChainMonitor_new(mut chain_source: crate::c_types::derived::CO /// 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`]). +/// `ignored_channels`. /// /// See [`ChannelMonitor::get_claimable_balances`] for more details on the exact criteria for /// inclusion in the return value. @@ -487,11 +421,14 @@ pub extern "C" fn ChainMonitor_list_monitors(this_arg: &crate::lightning::chain: } /// Lists the pending updates for each [`ChannelMonitor`] (by `OutPoint` being monitored). +/// Each `Vec` contains `update_id`s from [`ChannelMonitor::get_latest_update_id`] for updates +/// that have not yet been fully persisted. Note that if a full monitor is persisted all the pending +/// monitor updates must be individually marked completed by calling [`ChainMonitor::channel_monitor_updated`]. #[must_use] #[no_mangle] -pub extern "C" fn ChainMonitor_list_pending_monitor_updates(this_arg: &crate::lightning::chain::chainmonitor::ChainMonitor) -> crate::c_types::derived::CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ { +pub extern "C" fn ChainMonitor_list_pending_monitor_updates(this_arg: &crate::lightning::chain::chainmonitor::ChainMonitor) -> crate::c_types::derived::CVec_C2Tuple_OutPointCVec_u64ZZZ { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.list_pending_monitor_updates(); - 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( { crate::lightning::chain::chainmonitor::MonitorUpdateId { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; let mut local_ret_0 = (crate::lightning::chain::transaction::OutPoint { inner: ObjOps::heap_alloc(orig_ret_0_0), is_owned: true }, 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( { item }); }; let mut local_ret_0 = (crate::lightning::chain::transaction::OutPoint { inner: ObjOps::heap_alloc(orig_ret_0_0), is_owned: true }, local_orig_ret_0_1.into()).into(); local_ret_0 }); }; local_ret.into() } @@ -502,16 +439,23 @@ pub extern "C" fn ChainMonitor_list_pending_monitor_updates(this_arg: &crate::li /// 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. +/// 2) once all remote copies are updated, you call this function with [`ChannelMonitor::get_latest_update_id`] +/// or [`ChannelMonitorUpdate::update_id`] as the `completed_update_id`, and once all pending +/// updates have completed the channel will be re-enabled. +/// +/// It is only necessary to call [`ChainMonitor::channel_monitor_updated`] when you return [`ChannelMonitorUpdateStatus::InProgress`] +/// from [`Persist`] and either: +/// 1. A new [`ChannelMonitor`] was added in [`Persist::persist_new_channel`], or +/// 2. A [`ChannelMonitorUpdate`] was provided as part of [`Persist::update_persisted_channel`]. +/// Note that we don't care about calls to [`Persist::update_persisted_channel`] where no +/// [`ChannelMonitorUpdate`] was provided. /// /// Returns an [`APIError::APIMisuseError`] if `funding_txo` does not match any currently /// registered [`ChannelMonitor`]s. #[must_use] #[no_mangle] -pub extern "C" fn ChainMonitor_channel_monitor_updated(this_arg: &crate::lightning::chain::chainmonitor::ChainMonitor, mut funding_txo: crate::lightning::chain::transaction::OutPoint, mut completed_update_id: crate::lightning::chain::chainmonitor::MonitorUpdateId) -> crate::c_types::derived::CResult_NoneAPIErrorZ { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.channel_monitor_updated(*unsafe { Box::from_raw(funding_txo.take_inner()) }, *unsafe { Box::from_raw(completed_update_id.take_inner()) }); +pub extern "C" fn ChainMonitor_channel_monitor_updated(this_arg: &crate::lightning::chain::chainmonitor::ChainMonitor, mut funding_txo: crate::lightning::chain::transaction::OutPoint, mut completed_update_id: u64) -> crate::c_types::derived::CResult_NoneAPIErrorZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.channel_monitor_updated(*unsafe { Box::from_raw(funding_txo.take_inner()) }, completed_update_id); 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 } @@ -667,18 +611,18 @@ pub extern "C" fn ChainMonitor_as_Watch(this_arg: &ChainMonitor) -> crate::light #[must_use] extern "C" fn ChainMonitor_Watch_watch_channel(this_arg: *const c_void, mut funding_txo: crate::lightning::chain::transaction::OutPoint, mut monitor: crate::lightning::chain::channelmonitor::ChannelMonitor) -> crate::c_types::derived::CResult_ChannelMonitorUpdateStatusNoneZ { - let mut ret = >::watch_channel(unsafe { &mut *(this_arg as *mut nativeChainMonitor) }, *unsafe { Box::from_raw(funding_txo.take_inner()) }, *unsafe { Box::from_raw(monitor.take_inner()) }); + let mut ret = >::watch_channel(unsafe { &mut *(this_arg as *mut nativeChainMonitor) }, *unsafe { Box::from_raw(funding_txo.take_inner()) }, *unsafe { Box::from_raw(monitor.take_inner()) }); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::chain::ChannelMonitorUpdateStatus::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; local_ret } #[must_use] extern "C" fn ChainMonitor_Watch_update_channel(this_arg: *const c_void, mut funding_txo: crate::lightning::chain::transaction::OutPoint, update: &crate::lightning::chain::channelmonitor::ChannelMonitorUpdate) -> crate::lightning::chain::ChannelMonitorUpdateStatus { - let mut ret = >::update_channel(unsafe { &mut *(this_arg as *mut nativeChainMonitor) }, *unsafe { Box::from_raw(funding_txo.take_inner()) }, update.get_native_ref()); + let mut ret = >::update_channel(unsafe { &mut *(this_arg as *mut nativeChainMonitor) }, *unsafe { Box::from_raw(funding_txo.take_inner()) }, update.get_native_ref()); crate::lightning::chain::ChannelMonitorUpdateStatus::native_into(ret) } #[must_use] extern "C" fn ChainMonitor_Watch_release_pending_monitor_events(this_arg: *const c_void) -> crate::c_types::derived::CVec_C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZZ { - let mut ret = >::release_pending_monitor_events(unsafe { &mut *(this_arg as *mut nativeChainMonitor) }, ); + let mut ret = >::release_pending_monitor_events(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, mut orig_ret_0_2, mut orig_ret_0_3) = item; let mut local_orig_ret_0_2 = Vec::new(); for mut item in orig_ret_0_2.drain(..) { local_orig_ret_0_2.push( { crate::lightning::chain::channelmonitor::MonitorEvent::native_into(item) }); }; let mut local_orig_ret_0_3 = if orig_ret_0_3.is_none() { crate::c_types::PublicKey::null() } else { { crate::c_types::PublicKey::from_rust(&(orig_ret_0_3.unwrap())) } }; let mut local_ret_0 = (crate::lightning::chain::transaction::OutPoint { inner: ObjOps::heap_alloc(orig_ret_0_0), is_owned: true }, crate::lightning::ln::types::ChannelId { inner: ObjOps::heap_alloc(orig_ret_0_1), is_owned: true }, local_orig_ret_0_2.into(), local_orig_ret_0_3).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 9835584..4a51287 100644 --- a/lightning-c-bindings/src/lightning/chain/channelmonitor.rs +++ b/lightning-c-bindings/src/lightning/chain/channelmonitor.rs @@ -54,6 +54,12 @@ pub struct ChannelMonitorUpdate { pub is_owned: bool, } +impl core::ops::Deref for ChannelMonitorUpdate { + type Target = nativeChannelMonitorUpdate; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ChannelMonitorUpdate { } +unsafe impl core::marker::Sync for ChannelMonitorUpdate { } impl Drop for ChannelMonitorUpdate { fn drop(&mut self) { if self.is_owned && !<*mut nativeChannelMonitorUpdate>::is_null(self.inner) { @@ -84,6 +90,9 @@ impl ChannelMonitorUpdate { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// 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 @@ -196,7 +205,7 @@ pub extern "C" fn ChannelMonitorUpdate_write(obj: &crate::lightning::chain::chan } #[allow(unused)] pub(crate) extern "C" fn ChannelMonitorUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelMonitorUpdate) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::chain::channelmonitor::nativeChannelMonitorUpdate) }) } #[no_mangle] /// Read a ChannelMonitorUpdate from a byte array, created by ChannelMonitorUpdate_write @@ -472,6 +481,12 @@ pub struct HTLCUpdate { pub is_owned: bool, } +impl core::ops::Deref for HTLCUpdate { + type Target = nativeHTLCUpdate; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for HTLCUpdate { } +unsafe impl core::marker::Sync for HTLCUpdate { } impl Drop for HTLCUpdate { fn drop(&mut self) { if self.is_owned && !<*mut nativeHTLCUpdate>::is_null(self.inner) { @@ -502,6 +517,9 @@ impl HTLCUpdate { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } impl Clone for HTLCUpdate { fn clone(&self) -> Self { @@ -538,7 +556,7 @@ pub extern "C" fn HTLCUpdate_write(obj: &crate::lightning::chain::channelmonitor } #[allow(unused)] pub(crate) extern "C" fn HTLCUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeHTLCUpdate) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::chain::channelmonitor::nativeHTLCUpdate) }) } #[no_mangle] /// Read a HTLCUpdate from a byte array, created by HTLCUpdate_write @@ -557,6 +575,103 @@ pub extern "C" fn HTLCUpdate_read(ser: crate::c_types::u8slice) -> crate::c_type #[no_mangle] pub static ANTI_REORG_DELAY: u32 = lightning::chain::channelmonitor::ANTI_REORG_DELAY; +/// Indicates whether the balance is derived from a cooperative close, a force-close +/// (for holder or counterparty), or whether it is for an HTLC. +#[derive(Clone)] +#[must_use] +#[repr(C)] +pub enum BalanceSource { + /// The channel was force closed by the holder. + HolderForceClosed, + /// The channel was force closed by the counterparty. + CounterpartyForceClosed, + /// The channel was cooperatively closed. + CoopClose, + /// This balance is the result of an HTLC. + Htlc, +} +use lightning::chain::channelmonitor::BalanceSource as BalanceSourceImport; +pub(crate) type nativeBalanceSource = BalanceSourceImport; + +impl BalanceSource { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeBalanceSource { + match self { + BalanceSource::HolderForceClosed => nativeBalanceSource::HolderForceClosed, + BalanceSource::CounterpartyForceClosed => nativeBalanceSource::CounterpartyForceClosed, + BalanceSource::CoopClose => nativeBalanceSource::CoopClose, + BalanceSource::Htlc => nativeBalanceSource::Htlc, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeBalanceSource { + match self { + BalanceSource::HolderForceClosed => nativeBalanceSource::HolderForceClosed, + BalanceSource::CounterpartyForceClosed => nativeBalanceSource::CounterpartyForceClosed, + BalanceSource::CoopClose => nativeBalanceSource::CoopClose, + BalanceSource::Htlc => nativeBalanceSource::Htlc, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &BalanceSourceImport) -> Self { + let native = unsafe { &*(native as *const _ as *const c_void as *const nativeBalanceSource) }; + match native { + nativeBalanceSource::HolderForceClosed => BalanceSource::HolderForceClosed, + nativeBalanceSource::CounterpartyForceClosed => BalanceSource::CounterpartyForceClosed, + nativeBalanceSource::CoopClose => BalanceSource::CoopClose, + nativeBalanceSource::Htlc => BalanceSource::Htlc, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeBalanceSource) -> Self { + match native { + nativeBalanceSource::HolderForceClosed => BalanceSource::HolderForceClosed, + nativeBalanceSource::CounterpartyForceClosed => BalanceSource::CounterpartyForceClosed, + nativeBalanceSource::CoopClose => BalanceSource::CoopClose, + nativeBalanceSource::Htlc => BalanceSource::Htlc, + } + } +} +/// Creates a copy of the BalanceSource +#[no_mangle] +pub extern "C" fn BalanceSource_clone(orig: &BalanceSource) -> BalanceSource { + orig.clone() +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn BalanceSource_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const BalanceSource)).clone() })) as *mut c_void +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn BalanceSource_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut BalanceSource) }; +} +#[no_mangle] +/// Utility method to constructs a new HolderForceClosed-variant BalanceSource +pub extern "C" fn BalanceSource_holder_force_closed() -> BalanceSource { + BalanceSource::HolderForceClosed} +#[no_mangle] +/// Utility method to constructs a new CounterpartyForceClosed-variant BalanceSource +pub extern "C" fn BalanceSource_counterparty_force_closed() -> BalanceSource { + BalanceSource::CounterpartyForceClosed} +#[no_mangle] +/// Utility method to constructs a new CoopClose-variant BalanceSource +pub extern "C" fn BalanceSource_coop_close() -> BalanceSource { + BalanceSource::CoopClose} +#[no_mangle] +/// Utility method to constructs a new Htlc-variant BalanceSource +pub extern "C" fn BalanceSource_htlc() -> BalanceSource { + BalanceSource::Htlc} +/// Get a string which allows debug introspection of a BalanceSource object +pub extern "C" fn BalanceSource_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::chain::channelmonitor::BalanceSource }).into()} +/// Checks if two BalanceSources contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +#[no_mangle] +pub extern "C" fn BalanceSource_eq(a: &BalanceSource, b: &BalanceSource) -> bool { + if &a.to_native() == &b.to_native() { true } else { false } +} /// 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 @@ -572,6 +687,49 @@ pub enum Balance { /// The amount available to claim, in satoshis, excluding the on-chain fees which will be /// required to do so. amount_satoshis: u64, + /// The transaction fee we pay for the closing commitment transaction. This amount is not + /// included in the [`Balance::ClaimableOnChannelClose::amount_satoshis`] value. + /// + /// Note that if this channel is inbound (and thus our counterparty pays the commitment + /// transaction fee) this value will be zero. For [`ChannelMonitor`]s created prior to LDK + /// 0.0.124, the channel is always treated as outbound (and thus this value is never zero). + transaction_fee_satoshis: u64, + /// The amount of millisatoshis which has been burned to fees from HTLCs which are outbound + /// from us and are related to a payment which was sent by us. This is the sum of the + /// millisatoshis part of all HTLCs which are otherwise represented by + /// [`Balance::MaybeTimeoutClaimableHTLC`] with their + /// [`Balance::MaybeTimeoutClaimableHTLC::outbound_payment`] flag set, as well as any dust + /// HTLCs which would otherwise be represented the same. + /// + /// This amount (rounded up to a whole satoshi value) will not be included in `amount_satoshis`. + outbound_payment_htlc_rounded_msat: u64, + /// The amount of millisatoshis which has been burned to fees from HTLCs which are outbound + /// from us and are related to a forwarded HTLC. This is the sum of the millisatoshis part + /// of all HTLCs which are otherwise represented by [`Balance::MaybeTimeoutClaimableHTLC`] + /// with their [`Balance::MaybeTimeoutClaimableHTLC::outbound_payment`] flag *not* set, as + /// well as any dust HTLCs which would otherwise be represented the same. + /// + /// This amount (rounded up to a whole satoshi value) will not be included in `amount_satoshis`. + outbound_forwarded_htlc_rounded_msat: u64, + /// The amount of millisatoshis which has been burned to fees from HTLCs which are inbound + /// to us and for which we know the preimage. This is the sum of the millisatoshis part of + /// all HTLCs which would be represented by [`Balance::ContentiousClaimable`] on channel + /// close, but whose current value is included in + /// [`Balance::ClaimableOnChannelClose::amount_satoshis`], as well as any dust HTLCs which + /// would otherwise be represented the same. + /// + /// This amount (rounded up to a whole satoshi value) will not be included in the counterparty's + /// `amount_satoshis`. + inbound_claiming_htlc_rounded_msat: u64, + /// The amount of millisatoshis which has been burned to fees from HTLCs which are inbound + /// to us and for which we do not know the preimage. This is the sum of the millisatoshis + /// part of all HTLCs which would be represented by [`Balance::MaybePreimageClaimableHTLC`] + /// on channel close, as well as any dust HTLCs which would otherwise be represented the + /// same. + /// + /// This amount (rounded up to a whole satoshi value) will not be included in the counterparty's + /// `amount_satoshis`. + inbound_htlc_rounded_msat: u64, }, /// The channel has been closed, and the given balance is ours but awaiting confirmations until /// we consider it spendable. @@ -582,6 +740,8 @@ pub enum Balance { /// The height at which an [`Event::SpendableOutputs`] event will be generated for this /// amount. confirmation_height: u32, + /// Whether this balance is a result of cooperative close, a force-close, or an HTLC. + source: crate::lightning::chain::channelmonitor::BalanceSource, }, /// 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 @@ -614,6 +774,10 @@ pub enum Balance { claimable_height: u32, /// The payment hash whose preimage our counterparty needs to claim this HTLC. payment_hash: crate::c_types::ThirtyTwoBytes, + /// Whether this HTLC represents a payment which was sent outbound from us. Otherwise it + /// represents an HTLC which was forwarded (and should, thus, have a corresponding inbound + /// edge on another channel). + outbound_payment: bool, }, /// 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 @@ -648,18 +812,30 @@ impl Balance { #[allow(unused)] pub(crate) fn to_native(&self) -> nativeBalance { match self { - Balance::ClaimableOnChannelClose {ref amount_satoshis, } => { + Balance::ClaimableOnChannelClose {ref amount_satoshis, ref transaction_fee_satoshis, ref outbound_payment_htlc_rounded_msat, ref outbound_forwarded_htlc_rounded_msat, ref inbound_claiming_htlc_rounded_msat, ref inbound_htlc_rounded_msat, } => { let mut amount_satoshis_nonref = Clone::clone(amount_satoshis); + let mut transaction_fee_satoshis_nonref = Clone::clone(transaction_fee_satoshis); + let mut outbound_payment_htlc_rounded_msat_nonref = Clone::clone(outbound_payment_htlc_rounded_msat); + let mut outbound_forwarded_htlc_rounded_msat_nonref = Clone::clone(outbound_forwarded_htlc_rounded_msat); + let mut inbound_claiming_htlc_rounded_msat_nonref = Clone::clone(inbound_claiming_htlc_rounded_msat); + let mut inbound_htlc_rounded_msat_nonref = Clone::clone(inbound_htlc_rounded_msat); nativeBalance::ClaimableOnChannelClose { amount_satoshis: amount_satoshis_nonref, + transaction_fee_satoshis: transaction_fee_satoshis_nonref, + outbound_payment_htlc_rounded_msat: outbound_payment_htlc_rounded_msat_nonref, + outbound_forwarded_htlc_rounded_msat: outbound_forwarded_htlc_rounded_msat_nonref, + inbound_claiming_htlc_rounded_msat: inbound_claiming_htlc_rounded_msat_nonref, + inbound_htlc_rounded_msat: inbound_htlc_rounded_msat_nonref, } }, - Balance::ClaimableAwaitingConfirmations {ref amount_satoshis, ref confirmation_height, } => { + Balance::ClaimableAwaitingConfirmations {ref amount_satoshis, ref confirmation_height, ref source, } => { let mut amount_satoshis_nonref = Clone::clone(amount_satoshis); let mut confirmation_height_nonref = Clone::clone(confirmation_height); + let mut source_nonref = Clone::clone(source); nativeBalance::ClaimableAwaitingConfirmations { amount_satoshis: amount_satoshis_nonref, confirmation_height: confirmation_height_nonref, + source: source_nonref.into_native(), } }, Balance::ContentiousClaimable {ref amount_satoshis, ref timeout_height, ref payment_hash, ref payment_preimage, } => { @@ -674,14 +850,16 @@ impl Balance { payment_preimage: ::lightning::ln::types::PaymentPreimage(payment_preimage_nonref.data), } }, - Balance::MaybeTimeoutClaimableHTLC {ref amount_satoshis, ref claimable_height, ref payment_hash, } => { + Balance::MaybeTimeoutClaimableHTLC {ref amount_satoshis, ref claimable_height, ref payment_hash, ref outbound_payment, } => { let mut amount_satoshis_nonref = Clone::clone(amount_satoshis); let mut claimable_height_nonref = Clone::clone(claimable_height); let mut payment_hash_nonref = Clone::clone(payment_hash); + let mut outbound_payment_nonref = Clone::clone(outbound_payment); nativeBalance::MaybeTimeoutClaimableHTLC { amount_satoshis: amount_satoshis_nonref, claimable_height: claimable_height_nonref, payment_hash: ::lightning::ln::types::PaymentHash(payment_hash_nonref.data), + outbound_payment: outbound_payment_nonref, } }, Balance::MaybePreimageClaimableHTLC {ref amount_satoshis, ref expiry_height, ref payment_hash, } => { @@ -705,15 +883,21 @@ impl Balance { #[allow(unused)] pub(crate) fn into_native(self) -> nativeBalance { match self { - Balance::ClaimableOnChannelClose {mut amount_satoshis, } => { + Balance::ClaimableOnChannelClose {mut amount_satoshis, mut transaction_fee_satoshis, mut outbound_payment_htlc_rounded_msat, mut outbound_forwarded_htlc_rounded_msat, mut inbound_claiming_htlc_rounded_msat, mut inbound_htlc_rounded_msat, } => { nativeBalance::ClaimableOnChannelClose { amount_satoshis: amount_satoshis, + transaction_fee_satoshis: transaction_fee_satoshis, + outbound_payment_htlc_rounded_msat: outbound_payment_htlc_rounded_msat, + outbound_forwarded_htlc_rounded_msat: outbound_forwarded_htlc_rounded_msat, + inbound_claiming_htlc_rounded_msat: inbound_claiming_htlc_rounded_msat, + inbound_htlc_rounded_msat: inbound_htlc_rounded_msat, } }, - Balance::ClaimableAwaitingConfirmations {mut amount_satoshis, mut confirmation_height, } => { + Balance::ClaimableAwaitingConfirmations {mut amount_satoshis, mut confirmation_height, mut source, } => { nativeBalance::ClaimableAwaitingConfirmations { amount_satoshis: amount_satoshis, confirmation_height: confirmation_height, + source: source.into_native(), } }, Balance::ContentiousClaimable {mut amount_satoshis, mut timeout_height, mut payment_hash, mut payment_preimage, } => { @@ -724,11 +908,12 @@ impl Balance { payment_preimage: ::lightning::ln::types::PaymentPreimage(payment_preimage.data), } }, - Balance::MaybeTimeoutClaimableHTLC {mut amount_satoshis, mut claimable_height, mut payment_hash, } => { + Balance::MaybeTimeoutClaimableHTLC {mut amount_satoshis, mut claimable_height, mut payment_hash, mut outbound_payment, } => { nativeBalance::MaybeTimeoutClaimableHTLC { amount_satoshis: amount_satoshis, claimable_height: claimable_height, payment_hash: ::lightning::ln::types::PaymentHash(payment_hash.data), + outbound_payment: outbound_payment, } }, Balance::MaybePreimageClaimableHTLC {mut amount_satoshis, mut expiry_height, mut payment_hash, } => { @@ -749,18 +934,30 @@ impl Balance { pub(crate) fn from_native(native: &BalanceImport) -> Self { let native = unsafe { &*(native as *const _ as *const c_void as *const nativeBalance) }; match native { - nativeBalance::ClaimableOnChannelClose {ref amount_satoshis, } => { + nativeBalance::ClaimableOnChannelClose {ref amount_satoshis, ref transaction_fee_satoshis, ref outbound_payment_htlc_rounded_msat, ref outbound_forwarded_htlc_rounded_msat, ref inbound_claiming_htlc_rounded_msat, ref inbound_htlc_rounded_msat, } => { let mut amount_satoshis_nonref = Clone::clone(amount_satoshis); + let mut transaction_fee_satoshis_nonref = Clone::clone(transaction_fee_satoshis); + let mut outbound_payment_htlc_rounded_msat_nonref = Clone::clone(outbound_payment_htlc_rounded_msat); + let mut outbound_forwarded_htlc_rounded_msat_nonref = Clone::clone(outbound_forwarded_htlc_rounded_msat); + let mut inbound_claiming_htlc_rounded_msat_nonref = Clone::clone(inbound_claiming_htlc_rounded_msat); + let mut inbound_htlc_rounded_msat_nonref = Clone::clone(inbound_htlc_rounded_msat); Balance::ClaimableOnChannelClose { amount_satoshis: amount_satoshis_nonref, + transaction_fee_satoshis: transaction_fee_satoshis_nonref, + outbound_payment_htlc_rounded_msat: outbound_payment_htlc_rounded_msat_nonref, + outbound_forwarded_htlc_rounded_msat: outbound_forwarded_htlc_rounded_msat_nonref, + inbound_claiming_htlc_rounded_msat: inbound_claiming_htlc_rounded_msat_nonref, + inbound_htlc_rounded_msat: inbound_htlc_rounded_msat_nonref, } }, - nativeBalance::ClaimableAwaitingConfirmations {ref amount_satoshis, ref confirmation_height, } => { + nativeBalance::ClaimableAwaitingConfirmations {ref amount_satoshis, ref confirmation_height, ref source, } => { let mut amount_satoshis_nonref = Clone::clone(amount_satoshis); let mut confirmation_height_nonref = Clone::clone(confirmation_height); + let mut source_nonref = Clone::clone(source); Balance::ClaimableAwaitingConfirmations { amount_satoshis: amount_satoshis_nonref, confirmation_height: confirmation_height_nonref, + source: crate::lightning::chain::channelmonitor::BalanceSource::native_into(source_nonref), } }, nativeBalance::ContentiousClaimable {ref amount_satoshis, ref timeout_height, ref payment_hash, ref payment_preimage, } => { @@ -775,14 +972,16 @@ impl Balance { payment_preimage: crate::c_types::ThirtyTwoBytes { data: payment_preimage_nonref.0 }, } }, - nativeBalance::MaybeTimeoutClaimableHTLC {ref amount_satoshis, ref claimable_height, ref payment_hash, } => { + nativeBalance::MaybeTimeoutClaimableHTLC {ref amount_satoshis, ref claimable_height, ref payment_hash, ref outbound_payment, } => { let mut amount_satoshis_nonref = Clone::clone(amount_satoshis); let mut claimable_height_nonref = Clone::clone(claimable_height); let mut payment_hash_nonref = Clone::clone(payment_hash); + let mut outbound_payment_nonref = Clone::clone(outbound_payment); Balance::MaybeTimeoutClaimableHTLC { amount_satoshis: amount_satoshis_nonref, claimable_height: claimable_height_nonref, payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 }, + outbound_payment: outbound_payment_nonref, } }, nativeBalance::MaybePreimageClaimableHTLC {ref amount_satoshis, ref expiry_height, ref payment_hash, } => { @@ -806,15 +1005,21 @@ impl Balance { #[allow(unused)] pub(crate) fn native_into(native: nativeBalance) -> Self { match native { - nativeBalance::ClaimableOnChannelClose {mut amount_satoshis, } => { + nativeBalance::ClaimableOnChannelClose {mut amount_satoshis, mut transaction_fee_satoshis, mut outbound_payment_htlc_rounded_msat, mut outbound_forwarded_htlc_rounded_msat, mut inbound_claiming_htlc_rounded_msat, mut inbound_htlc_rounded_msat, } => { Balance::ClaimableOnChannelClose { amount_satoshis: amount_satoshis, + transaction_fee_satoshis: transaction_fee_satoshis, + outbound_payment_htlc_rounded_msat: outbound_payment_htlc_rounded_msat, + outbound_forwarded_htlc_rounded_msat: outbound_forwarded_htlc_rounded_msat, + inbound_claiming_htlc_rounded_msat: inbound_claiming_htlc_rounded_msat, + inbound_htlc_rounded_msat: inbound_htlc_rounded_msat, } }, - nativeBalance::ClaimableAwaitingConfirmations {mut amount_satoshis, mut confirmation_height, } => { + nativeBalance::ClaimableAwaitingConfirmations {mut amount_satoshis, mut confirmation_height, mut source, } => { Balance::ClaimableAwaitingConfirmations { amount_satoshis: amount_satoshis, confirmation_height: confirmation_height, + source: crate::lightning::chain::channelmonitor::BalanceSource::native_into(source), } }, nativeBalance::ContentiousClaimable {mut amount_satoshis, mut timeout_height, mut payment_hash, mut payment_preimage, } => { @@ -825,11 +1030,12 @@ impl Balance { payment_preimage: crate::c_types::ThirtyTwoBytes { data: payment_preimage.0 }, } }, - nativeBalance::MaybeTimeoutClaimableHTLC {mut amount_satoshis, mut claimable_height, mut payment_hash, } => { + nativeBalance::MaybeTimeoutClaimableHTLC {mut amount_satoshis, mut claimable_height, mut payment_hash, mut outbound_payment, } => { Balance::MaybeTimeoutClaimableHTLC { amount_satoshis: amount_satoshis, claimable_height: claimable_height, payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 }, + outbound_payment: outbound_payment, } }, nativeBalance::MaybePreimageClaimableHTLC {mut amount_satoshis, mut expiry_height, mut payment_hash, } => { @@ -867,17 +1073,23 @@ pub(crate) extern "C" fn Balance_free_void(this_ptr: *mut c_void) { } #[no_mangle] /// Utility method to constructs a new ClaimableOnChannelClose-variant Balance -pub extern "C" fn Balance_claimable_on_channel_close(amount_satoshis: u64) -> Balance { +pub extern "C" fn Balance_claimable_on_channel_close(amount_satoshis: u64, transaction_fee_satoshis: u64, outbound_payment_htlc_rounded_msat: u64, outbound_forwarded_htlc_rounded_msat: u64, inbound_claiming_htlc_rounded_msat: u64, inbound_htlc_rounded_msat: u64) -> Balance { Balance::ClaimableOnChannelClose { amount_satoshis, + transaction_fee_satoshis, + outbound_payment_htlc_rounded_msat, + outbound_forwarded_htlc_rounded_msat, + inbound_claiming_htlc_rounded_msat, + inbound_htlc_rounded_msat, } } #[no_mangle] /// Utility method to constructs a new ClaimableAwaitingConfirmations-variant Balance -pub extern "C" fn Balance_claimable_awaiting_confirmations(amount_satoshis: u64, confirmation_height: u32) -> Balance { +pub extern "C" fn Balance_claimable_awaiting_confirmations(amount_satoshis: u64, confirmation_height: u32, source: crate::lightning::chain::channelmonitor::BalanceSource) -> Balance { Balance::ClaimableAwaitingConfirmations { amount_satoshis, confirmation_height, + source, } } #[no_mangle] @@ -892,11 +1104,12 @@ pub extern "C" fn Balance_contentious_claimable(amount_satoshis: u64, timeout_he } #[no_mangle] /// Utility method to constructs a new MaybeTimeoutClaimableHTLC-variant Balance -pub extern "C" fn Balance_maybe_timeout_claimable_htlc(amount_satoshis: u64, claimable_height: u32, payment_hash: crate::c_types::ThirtyTwoBytes) -> Balance { +pub extern "C" fn Balance_maybe_timeout_claimable_htlc(amount_satoshis: u64, claimable_height: u32, payment_hash: crate::c_types::ThirtyTwoBytes, outbound_payment: bool) -> Balance { Balance::MaybeTimeoutClaimableHTLC { amount_satoshis, claimable_height, payment_hash, + outbound_payment, } } #[no_mangle] @@ -924,9 +1137,15 @@ pub extern "C" fn Balance_debug_str_void(o: *const c_void) -> Str { 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 +/// The amount claimable, in satoshis. +/// +/// For outbound payments, this excludes the balance from the possible HTLC timeout. +/// +/// For forwarded payments, this includes the balance from the possible HTLC timeout as +/// (to be conservative) that balance does not include routing fees we'd earn if we'd claim +/// the balance from a preimage in a successful forward. +/// +/// 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. @@ -939,7 +1158,7 @@ pub extern "C" fn Balance_claimable_amount_satoshis(this_arg: &crate::lightning: 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. @@ -967,6 +1186,12 @@ pub struct ChannelMonitor { pub is_owned: bool, } +impl core::ops::Deref for ChannelMonitor { + type Target = nativeChannelMonitor; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ChannelMonitor { } +unsafe impl core::marker::Sync for ChannelMonitor { } impl Drop for ChannelMonitor { fn drop(&mut self) { if self.is_owned && !<*mut nativeChannelMonitor>::is_null(self.inner) { @@ -997,6 +1222,9 @@ impl ChannelMonitor { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } impl Clone for ChannelMonitor { fn clone(&self) -> Self { @@ -1024,7 +1252,7 @@ pub extern "C" fn ChannelMonitor_write(obj: &crate::lightning::chain::channelmon } #[allow(unused)] pub(crate) extern "C" fn ChannelMonitor_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelMonitor) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::chain::channelmonitor::nativeChannelMonitor) }) } /// Updates a ChannelMonitor on the basis of some new information provided by the Channel /// itself. @@ -1103,11 +1331,16 @@ pub extern "C" fn ChannelMonitor_get_and_clear_pending_monitor_events(this_arg: /// An [`EventHandler`] may safely call back to the provider, though this shouldn't be needed in /// order to handle these events. /// +/// Will return a [`ReplayEvent`] error if event handling failed and should eventually be retried. +/// /// [`SpendableOutputs`]: crate::events::Event::SpendableOutputs /// [`BumpTransaction`]: crate::events::Event::BumpTransaction +#[must_use] #[no_mangle] -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) +pub extern "C" fn ChannelMonitor_process_pending_events(this_arg: &crate::lightning::chain::channelmonitor::ChannelMonitor, handler: &crate::lightning::events::EventHandler) -> crate::c_types::derived::CResult_NoneReplayEventZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.process_pending_events(handler); + 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::events::ReplayEvent { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; + local_ret } /// Gets the counterparty's initial commitment transaction. The returned commitment @@ -1310,6 +1543,14 @@ pub extern "C" fn ChannelMonitor_rebroadcast_pending_claims(this_arg: &crate::li unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.rebroadcast_pending_claims(broadcaster, fee_estimator, logger) } +/// Returns true if the monitor has pending claim requests that are not fully confirmed yet. +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelMonitor_has_pending_claims(this_arg: &crate::lightning::chain::channelmonitor::ChannelMonitor) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.has_pending_claims(); + ret +} + /// Triggers rebroadcasts of pending claims from a force-closed channel after a transaction /// signature generation failure. #[no_mangle] @@ -1383,7 +1624,7 @@ pub extern "C" fn C2Tuple_ThirtyTwoBytesChannelMonitorZ_read(ser: crate::c_types 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.as_ref() }, 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/mod.rs b/lightning-c-bindings/src/lightning/chain/mod.rs index ff7650c..c981ca3 100644 --- a/lightning-c-bindings/src/lightning/chain/mod.rs +++ b/lightning-c-bindings/src/lightning/chain/mod.rs @@ -65,6 +65,12 @@ pub struct BestBlock { pub is_owned: bool, } +impl core::ops::Deref for BestBlock { + type Target = nativeBestBlock; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for BestBlock { } +unsafe impl core::marker::Sync for BestBlock { } impl Drop for BestBlock { fn drop(&mut self) { if self.is_owned && !<*mut nativeBestBlock>::is_null(self.inner) { @@ -95,6 +101,9 @@ impl BestBlock { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The block's hash #[no_mangle] @@ -184,7 +193,7 @@ pub extern "C" fn BestBlock_write(obj: &crate::lightning::chain::BestBlock) -> c } #[allow(unused)] pub(crate) extern "C" fn BestBlock_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeBestBlock) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::chain::nativeBestBlock) }) } #[no_mangle] /// Read a BestBlock from a byte array, created by BestBlock_write @@ -235,32 +244,49 @@ pub(crate) fn Listen_clone_fields(orig: &Listen) -> Listen { use lightning::chain::Listen as rustListen; impl rustListen for Listen { - fn filtered_block_connected(&self, mut header: &bitcoin::blockdata::block::Header, mut txdata: &lightning::chain::transaction::TransactionData, mut height: u32) { + fn filtered_block_connected(&self, mut header: &bitcoin::block::Header, mut txdata: &lightning::chain::transaction::TransactionData, mut height: u32) { let mut local_header = { let mut s = [0u8; 80]; s[..].copy_from_slice(&::bitcoin::consensus::encode::serialize(header)); s }; let mut local_txdata = Vec::new(); for item in txdata.iter() { local_txdata.push( { let (mut orig_txdata_0_0, mut orig_txdata_0_1) = item; let mut local_txdata_0 = (orig_txdata_0_0, crate::c_types::Transaction::from_bitcoin(&orig_txdata_0_1)).into(); local_txdata_0 }); }; (self.filtered_block_connected)(self.this_arg, &local_header, local_txdata.into(), height) } - fn block_connected(&self, mut block: &bitcoin::blockdata::block::Block, mut height: u32) { + fn block_connected(&self, mut block: &bitcoin::block::Block, mut height: u32) { let mut local_block = ::bitcoin::consensus::encode::serialize(block); (self.block_connected)(self.this_arg, crate::c_types::u8slice::from_slice(&local_block), height) } - fn block_disconnected(&self, mut header: &bitcoin::blockdata::block::Header, mut height: u32) { + fn block_disconnected(&self, mut header: &bitcoin::block::Header, mut height: u32) { let mut local_header = { let mut s = [0u8; 80]; s[..].copy_from_slice(&::bitcoin::consensus::encode::serialize(header)); s }; (self.block_disconnected)(self.this_arg, &local_header, height) } } +pub struct ListenRef(Listen); +impl rustListen for ListenRef { + fn filtered_block_connected(&self, mut header: &bitcoin::block::Header, mut txdata: &lightning::chain::transaction::TransactionData, mut height: u32) { + let mut local_header = { let mut s = [0u8; 80]; s[..].copy_from_slice(&::bitcoin::consensus::encode::serialize(header)); s }; + let mut local_txdata = Vec::new(); for item in txdata.iter() { local_txdata.push( { let (mut orig_txdata_0_0, mut orig_txdata_0_1) = item; let mut local_txdata_0 = (orig_txdata_0_0, crate::c_types::Transaction::from_bitcoin(&orig_txdata_0_1)).into(); local_txdata_0 }); }; + (self.0.filtered_block_connected)(self.0.this_arg, &local_header, local_txdata.into(), height) + } + fn block_connected(&self, mut block: &bitcoin::block::Block, mut height: u32) { + let mut local_block = ::bitcoin::consensus::encode::serialize(block); + (self.0.block_connected)(self.0.this_arg, crate::c_types::u8slice::from_slice(&local_block), height) + } + fn block_disconnected(&self, mut header: &bitcoin::block::Header, mut height: u32) { + let mut local_header = { let mut s = [0u8; 80]; s[..].copy_from_slice(&::bitcoin::consensus::encode::serialize(header)); s }; + (self.0.block_disconnected)(self.0.this_arg, &local_header, height) + } +} + // 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 Listen { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = ListenRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const ListenRef) } } } impl core::ops::DerefMut for Listen { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut ListenRef { + unsafe { &mut *(self as *mut _ as *mut ListenRef) } } } /// Calls the free function if one is set @@ -385,7 +411,7 @@ pub(crate) fn Confirm_clone_fields(orig: &Confirm) -> Confirm { use lightning::chain::Confirm as rustConfirm; impl rustConfirm for Confirm { - fn transactions_confirmed(&self, mut header: &bitcoin::blockdata::block::Header, mut txdata: &lightning::chain::transaction::TransactionData, mut height: u32) { + fn transactions_confirmed(&self, mut header: &bitcoin::block::Header, mut txdata: &lightning::chain::transaction::TransactionData, mut height: u32) { let mut local_header = { let mut s = [0u8; 80]; s[..].copy_from_slice(&::bitcoin::consensus::encode::serialize(header)); s }; let mut local_txdata = Vec::new(); for item in txdata.iter() { local_txdata.push( { let (mut orig_txdata_0_0, mut orig_txdata_0_1) = item; let mut local_txdata_0 = (orig_txdata_0_0, crate::c_types::Transaction::from_bitcoin(&orig_txdata_0_1)).into(); local_txdata_0 }); }; (self.transactions_confirmed)(self.this_arg, &local_header, local_txdata.into(), height) @@ -393,7 +419,7 @@ impl rustConfirm for Confirm { fn transaction_unconfirmed(&self, mut txid: &bitcoin::hash_types::Txid) { (self.transaction_unconfirmed)(self.this_arg, txid.as_ref()) } - fn best_block_updated(&self, mut header: &bitcoin::blockdata::block::Header, mut height: u32) { + fn best_block_updated(&self, mut header: &bitcoin::block::Header, mut height: u32) { let mut local_header = { let mut s = [0u8; 80]; s[..].copy_from_slice(&::bitcoin::consensus::encode::serialize(header)); s }; (self.best_block_updated)(self.this_arg, &local_header, height) } @@ -404,17 +430,38 @@ impl rustConfirm for Confirm { } } +pub struct ConfirmRef(Confirm); +impl rustConfirm for ConfirmRef { + fn transactions_confirmed(&self, mut header: &bitcoin::block::Header, mut txdata: &lightning::chain::transaction::TransactionData, mut height: u32) { + let mut local_header = { let mut s = [0u8; 80]; s[..].copy_from_slice(&::bitcoin::consensus::encode::serialize(header)); s }; + let mut local_txdata = Vec::new(); for item in txdata.iter() { local_txdata.push( { let (mut orig_txdata_0_0, mut orig_txdata_0_1) = item; let mut local_txdata_0 = (orig_txdata_0_0, crate::c_types::Transaction::from_bitcoin(&orig_txdata_0_1)).into(); local_txdata_0 }); }; + (self.0.transactions_confirmed)(self.0.this_arg, &local_header, local_txdata.into(), height) + } + fn transaction_unconfirmed(&self, mut txid: &bitcoin::hash_types::Txid) { + (self.0.transaction_unconfirmed)(self.0.this_arg, txid.as_ref()) + } + fn best_block_updated(&self, mut header: &bitcoin::block::Header, mut height: u32) { + let mut local_header = { let mut s = [0u8; 80]; s[..].copy_from_slice(&::bitcoin::consensus::encode::serialize(header)); s }; + (self.0.best_block_updated)(self.0.this_arg, &local_header, height) + } + fn get_relevant_txids(&self) -> Vec<(bitcoin::hash_types::Txid, u32, Option)> { + let mut ret = (self.0.get_relevant_txids)(self.0.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, mut orig_ret_0_2) = item.to_rust(); let mut local_orig_ret_0_2 = { /*orig_ret_0_2*/ let orig_ret_0_2_opt = orig_ret_0_2; if orig_ret_0_2_opt.is_none() { None } else { Some({ { ::bitcoin::hash_types::BlockHash::from_slice(&{ orig_ret_0_2_opt.take() }.data[..]).unwrap() }})} }; let mut local_ret_0 = (::bitcoin::hash_types::Txid::from_slice(&orig_ret_0_0.data[..]).unwrap(), orig_ret_0_1, local_orig_ret_0_2); local_ret_0 }); }; + 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 Confirm { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = ConfirmRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const ConfirmRef) } } } impl core::ops::DerefMut for Confirm { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut ConfirmRef { + unsafe { &mut *(self as *mut _ as *mut ConfirmRef) } } } /// Calls the free function if one is set @@ -645,8 +692,8 @@ pub(crate) 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) -> Result { +impl rustWatch for Watch { + fn watch_channel(&self, mut funding_txo: lightning::chain::transaction::OutPoint, mut monitor: lightning::chain::channelmonitor::ChannelMonitor) -> Result { 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 }); let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_native() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; local_ret @@ -662,17 +709,35 @@ impl rustWatch for } } +pub struct WatchRef(Watch); +impl rustWatch for WatchRef { + fn watch_channel(&self, mut funding_txo: lightning::chain::transaction::OutPoint, mut monitor: lightning::chain::channelmonitor::ChannelMonitor) -> Result { + let mut ret = (self.0.watch_channel)(self.0.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 }); + let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_native() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn update_channel(&self, mut funding_txo: lightning::chain::transaction::OutPoint, mut update: &lightning::chain::channelmonitor::ChannelMonitorUpdate) -> lightning::chain::ChannelMonitorUpdateStatus { + let mut ret = (self.0.update_channel)(self.0.this_arg, crate::lightning::chain::transaction::OutPoint { inner: ObjOps::heap_alloc(funding_txo), is_owned: true }, &crate::lightning::chain::channelmonitor::ChannelMonitorUpdate { inner: unsafe { ObjOps::nonnull_ptr_to_inner((update as *const lightning::chain::channelmonitor::ChannelMonitorUpdate<>) as *mut _) }, is_owned: false }); + ret.into_native() + } + fn release_pending_monitor_events(&self) -> Vec<(lightning::chain::transaction::OutPoint, lightning::ln::types::ChannelId, Vec, Option)> { + let mut ret = (self.0.release_pending_monitor_events)(self.0.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, mut orig_ret_0_2, mut orig_ret_0_3) = item.to_rust(); let mut local_orig_ret_0_2 = Vec::new(); for mut item in orig_ret_0_2.into_rust().drain(..) { local_orig_ret_0_2.push( { item.into_native() }); }; let mut local_orig_ret_0_3 = if orig_ret_0_3.is_null() { None } else { Some( { orig_ret_0_3.into_rust() }) }; let mut local_ret_0 = (*unsafe { Box::from_raw(orig_ret_0_0.take_inner()) }, *unsafe { Box::from_raw(orig_ret_0_1.take_inner()) }, local_orig_ret_0_2, local_orig_ret_0_3); local_ret_0 }); }; + 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 Watch { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = WatchRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const WatchRef) } } } impl core::ops::DerefMut for Watch { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut WatchRef { + unsafe { &mut *(self as *mut _ as *mut WatchRef) } } } /// Calls the free function if one is set @@ -712,6 +777,11 @@ pub struct Filter { pub this_arg: *mut c_void, /// Registers interest in a transaction with `txid` and having an output with `script_pubkey` as /// a spending condition. + /// + /// This may be used, for example, to monitor for when a funding transaction confirms. + /// + /// The `script_pubkey` is provided for informational purposes and may be useful for block + /// sources which only support filtering on scripts. pub register_tx: extern "C" fn (this_arg: *const c_void, txid: *const [u8; 32], script_pubkey: crate::c_types::u8slice), /// Registers interest in spends of a transaction output. /// @@ -719,6 +789,9 @@ pub struct Filter { /// 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. + /// + /// This may be used, for example, to monitor for when a funding output is spent (by any + /// transaction). pub register_output: extern "C" fn (this_arg: *const c_void, output: crate::lightning::chain::WatchedOutput), /// 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. @@ -738,7 +811,7 @@ pub(crate) fn Filter_clone_fields(orig: &Filter) -> Filter { use lightning::chain::Filter as rustFilter; impl rustFilter for Filter { - fn register_tx(&self, mut txid: &bitcoin::hash_types::Txid, mut script_pubkey: &bitcoin::blockdata::script::Script) { + fn register_tx(&self, mut txid: &bitcoin::hash_types::Txid, mut script_pubkey: &bitcoin::script::Script) { (self.register_tx)(self.this_arg, txid.as_ref(), crate::c_types::u8slice::from_slice(script_pubkey.as_ref())) } fn register_output(&self, mut output: lightning::chain::WatchedOutput) { @@ -746,17 +819,27 @@ impl rustFilter for Filter { } } +pub struct FilterRef(Filter); +impl rustFilter for FilterRef { + fn register_tx(&self, mut txid: &bitcoin::hash_types::Txid, mut script_pubkey: &bitcoin::script::Script) { + (self.0.register_tx)(self.0.this_arg, txid.as_ref(), crate::c_types::u8slice::from_slice(script_pubkey.as_ref())) + } + fn register_output(&self, mut output: lightning::chain::WatchedOutput) { + (self.0.register_output)(self.0.this_arg, crate::lightning::chain::WatchedOutput { inner: ObjOps::heap_alloc(output), is_owned: true }) + } +} + // 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 Filter { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = FilterRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const FilterRef) } } } impl core::ops::DerefMut for Filter { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut FilterRef { + unsafe { &mut *(self as *mut _ as *mut FilterRef) } } } /// Calls the free function if one is set @@ -782,6 +865,9 @@ pub(crate) type nativeWatchedOutput = nativeWatchedOutputImport; /// 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. /// +/// Depending on your block source, you may need one or both of either [`Self::outpoint`] or +/// [`Self::script_pubkey`]. +/// /// [`ChannelMonitor`]: channelmonitor::ChannelMonitor /// [`ChannelMonitor::block_connected`]: channelmonitor::ChannelMonitor::block_connected #[must_use] @@ -799,6 +885,12 @@ pub struct WatchedOutput { pub is_owned: bool, } +impl core::ops::Deref for WatchedOutput { + type Target = nativeWatchedOutput; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for WatchedOutput { } +unsafe impl core::marker::Sync for WatchedOutput { } impl Drop for WatchedOutput { fn drop(&mut self) { if self.is_owned && !<*mut nativeWatchedOutput>::is_null(self.inner) { @@ -829,6 +921,9 @@ impl WatchedOutput { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// First block where the transaction output may have been spent. #[no_mangle] @@ -863,7 +958,7 @@ pub extern "C" fn WatchedOutput_get_script_pubkey(this_ptr: &WatchedOutput) -> c /// Spending condition of the transaction output. #[no_mangle] pub extern "C" fn WatchedOutput_set_script_pubkey(this_ptr: &mut WatchedOutput, mut val: crate::c_types::derived::CVec_u8Z) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.script_pubkey = ::bitcoin::blockdata::script::ScriptBuf::from(val.into_rust()); + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.script_pubkey = ::bitcoin::script::ScriptBuf::from(val.into_rust()); } /// Constructs a new WatchedOutput given each field #[must_use] @@ -873,7 +968,7 @@ pub extern "C" fn WatchedOutput_new(mut block_hash_arg: crate::c_types::derived: WatchedOutput { inner: ObjOps::heap_alloc(nativeWatchedOutput { block_hash: local_block_hash_arg, outpoint: *unsafe { Box::from_raw(outpoint_arg.take_inner()) }, - script_pubkey: ::bitcoin::blockdata::script::ScriptBuf::from(script_pubkey_arg.into_rust()), + script_pubkey: ::bitcoin::script::ScriptBuf::from(script_pubkey_arg.into_rust()), }), is_owned: true } } impl Clone for WatchedOutput { diff --git a/lightning-c-bindings/src/lightning/chain/transaction.rs b/lightning-c-bindings/src/lightning/chain/transaction.rs index 858c964..d807fc3 100644 --- a/lightning-c-bindings/src/lightning/chain/transaction.rs +++ b/lightning-c-bindings/src/lightning/chain/transaction.rs @@ -23,7 +23,7 @@ pub(crate) type nativeOutPoint = nativeOutPointImport; /// A reference to a transaction output. /// -/// Differs from bitcoin::blockdata::transaction::OutPoint as the index is a u16 instead of u32 +/// Differs from bitcoin::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. #[must_use] #[repr(C)] @@ -40,6 +40,12 @@ pub struct OutPoint { pub is_owned: bool, } +impl core::ops::Deref for OutPoint { + type Target = nativeOutPoint; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for OutPoint { } +unsafe impl core::marker::Sync for OutPoint { } impl Drop for OutPoint { fn drop(&mut self) { if self.is_owned && !<*mut nativeOutPoint>::is_null(self.inner) { @@ -70,6 +76,9 @@ impl OutPoint { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The referenced transaction's txid. #[no_mangle] @@ -155,7 +164,7 @@ pub extern "C" fn OutPoint_write(obj: &crate::lightning::chain::transaction::Out } #[allow(unused)] pub(crate) extern "C" fn OutPoint_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOutPoint) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::chain::transaction::nativeOutPoint) }) } #[no_mangle] /// Read a OutPoint from a byte array, created by OutPoint_write diff --git a/lightning-c-bindings/src/lightning/events/bump_transaction.rs b/lightning-c-bindings/src/lightning/events/bump_transaction.rs index df19cfa..1d50071 100644 --- a/lightning-c-bindings/src/lightning/events/bump_transaction.rs +++ b/lightning-c-bindings/src/lightning/events/bump_transaction.rs @@ -39,6 +39,12 @@ pub struct AnchorDescriptor { pub is_owned: bool, } +impl core::ops::Deref for AnchorDescriptor { + type Target = nativeAnchorDescriptor; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for AnchorDescriptor { } +unsafe impl core::marker::Sync for AnchorDescriptor { } impl Drop for AnchorDescriptor { fn drop(&mut self) { if self.is_owned && !<*mut nativeAnchorDescriptor>::is_null(self.inner) { @@ -69,6 +75,9 @@ impl AnchorDescriptor { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The parameters required to derive the signer for the anchor input. #[no_mangle] @@ -172,7 +181,7 @@ pub extern "C" fn AnchorDescriptor_tx_input_witness(this_arg: &crate::lightning: /// 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::ecdsa::WriteableEcdsaChannelSigner { +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::ecdsa::EcdsaChannelSigner { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.derive_channel_signer(signer_provider); Into::into(ret) } @@ -341,7 +350,7 @@ impl BumpTransactionEvent { 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::blockdata::locktime::absolute::LockTime::from_consensus(tx_lock_time_nonref), + tx_lock_time: ::bitcoin::locktime::absolute::LockTime::from_consensus(tx_lock_time_nonref), } }, } @@ -370,7 +379,7 @@ impl BumpTransactionEvent { 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::blockdata::locktime::absolute::LockTime::from_consensus(tx_lock_time), + tx_lock_time: ::bitcoin::locktime::absolute::LockTime::from_consensus(tx_lock_time), } }, } @@ -524,6 +533,12 @@ pub struct Input { pub is_owned: bool, } +impl core::ops::Deref for Input { + type Target = nativeInput; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for Input { } +unsafe impl core::marker::Sync for Input { } impl Drop for Input { fn drop(&mut self) { if self.is_owned && !<*mut nativeInput>::is_null(self.inner) { @@ -554,6 +569,9 @@ impl Input { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The unique identifier of the input. #[no_mangle] @@ -664,6 +682,12 @@ pub struct Utxo { pub is_owned: bool, } +impl core::ops::Deref for Utxo { + type Target = nativeUtxo; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for Utxo { } +unsafe impl core::marker::Sync for Utxo { } impl Drop for Utxo { fn drop(&mut self) { if self.is_owned && !<*mut nativeUtxo>::is_null(self.inner) { @@ -694,6 +718,9 @@ impl Utxo { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The unique identifier of the output. #[no_mangle] @@ -787,7 +814,7 @@ pub extern "C" fn Utxo_eq(a: &Utxo, b: &Utxo) -> bool { #[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_raw_hash(bitcoin::hashes::Hash::from_byte_array(unsafe { *pubkey_hash }.clone()))); + let mut ret = lightning::events::bump_transaction::Utxo::new_p2pkh(crate::c_types::C_to_bitcoin_outpoint(outpoint), ::bitcoin::amount::Amount::from_sat(value), &bitcoin::PubkeyHash::from_raw_hash(bitcoin::hashes::Hash::from_byte_array(unsafe { *pubkey_hash }.clone()))); crate::lightning::events::bump_transaction::Utxo { inner: ObjOps::heap_alloc(ret), is_owned: true } } @@ -812,6 +839,12 @@ pub struct CoinSelection { pub is_owned: bool, } +impl core::ops::Deref for CoinSelection { + type Target = nativeCoinSelection; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for CoinSelection { } +unsafe impl core::marker::Sync for CoinSelection { } impl Drop for CoinSelection { fn drop(&mut self) { if self.is_owned && !<*mut nativeCoinSelection>::is_null(self.inner) { @@ -842,6 +875,9 @@ impl CoinSelection { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The set of UTXOs (with at least 1 confirmation) to spend and use within a transaction /// requiring additional fees. @@ -977,24 +1013,40 @@ impl rustCoinSelectionSource for CoinSelectionSource { 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_psbt(&self, mut psbt: bitcoin::psbt::PartiallySignedTransaction) -> Result { + fn sign_psbt(&self, mut psbt: bitcoin::Psbt) -> Result { let mut ret = (self.sign_psbt)(self.this_arg, psbt.serialize().into()); 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 } } +pub struct CoinSelectionSourceRef(CoinSelectionSource); +impl rustCoinSelectionSource for CoinSelectionSourceRef { + 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.0.select_confirmed_utxos)(self.0.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_psbt(&self, mut psbt: bitcoin::Psbt) -> Result { + let mut ret = (self.0.sign_psbt)(self.0.this_arg, psbt.serialize().into()); + 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 + type Target = CoinSelectionSourceRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const CoinSelectionSourceRef) } } } impl core::ops::DerefMut for CoinSelectionSource { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut CoinSelectionSourceRef { + unsafe { &mut *(self as *mut _ as *mut CoinSelectionSourceRef) } } } /// Calls the free function if one is set @@ -1052,27 +1104,46 @@ impl rustWalletSource for WalletSource { } 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::ScriptBuf::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)) })*/ })}; + let mut local_ret = match ret.result_ok { true => Ok( { ::bitcoin::script::ScriptBuf::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_psbt(&self, mut psbt: bitcoin::psbt::PartiallySignedTransaction) -> Result { + fn sign_psbt(&self, mut psbt: bitcoin::Psbt) -> Result { let mut ret = (self.sign_psbt)(self.this_arg, psbt.serialize().into()); 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 } } +pub struct WalletSourceRef(WalletSource); +impl rustWalletSource for WalletSourceRef { + fn list_confirmed_utxos(&self) -> Result, ()> { + let mut ret = (self.0.list_confirmed_utxos)(self.0.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.0.get_change_script)(self.0.this_arg); + let mut local_ret = match ret.result_ok { true => Ok( { ::bitcoin::script::ScriptBuf::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_psbt(&self, mut psbt: bitcoin::Psbt) -> Result { + let mut ret = (self.0.sign_psbt)(self.0.this_arg, psbt.serialize().into()); + 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 + type Target = WalletSourceRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const WalletSourceRef) } } } impl core::ops::DerefMut for WalletSource { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut WalletSourceRef { + unsafe { &mut *(self as *mut _ as *mut WalletSourceRef) } } } /// Calls the free function if one is set @@ -1107,6 +1178,12 @@ pub struct Wallet { pub is_owned: bool, } +impl core::ops::Deref for Wallet { + type Target = nativeWallet; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for Wallet { } +unsafe impl core::marker::Sync for Wallet { } impl Drop for Wallet { fn drop(&mut self) { if self.is_owned && !<*mut nativeWallet>::is_null(self.inner) { @@ -1137,6 +1214,9 @@ impl Wallet { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Returns a new instance backed by the given [`WalletSource`] that serves as an implementation /// of [`CoinSelectionSource`]. @@ -1179,7 +1259,7 @@ extern "C" fn Wallet_CoinSelectionSource_select_confirmed_utxos(this_arg: *const } #[must_use] extern "C" fn Wallet_CoinSelectionSource_sign_psbt(this_arg: *const c_void, mut psbt: crate::c_types::derived::CVec_u8Z) -> crate::c_types::derived::CResult_TransactionNoneZ { - let mut ret = ::sign_psbt(unsafe { &mut *(this_arg as *mut nativeWallet) }, ::bitcoin::psbt::PartiallySignedTransaction::deserialize(psbt.as_slice()).expect("Invalid PSBT format")); + let mut ret = ::sign_psbt(unsafe { &mut *(this_arg as *mut nativeWallet) }, ::bitcoin::Psbt::deserialize(psbt.as_slice()).expect("Invalid PSBT format")); 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 } @@ -1208,6 +1288,12 @@ pub struct BumpTransactionEventHandler { pub is_owned: bool, } +impl core::ops::Deref for BumpTransactionEventHandler { + type Target = nativeBumpTransactionEventHandler; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for BumpTransactionEventHandler { } +unsafe impl core::marker::Sync for BumpTransactionEventHandler { } impl Drop for BumpTransactionEventHandler { fn drop(&mut self) { if self.is_owned && !<*mut nativeBumpTransactionEventHandler>::is_null(self.inner) { @@ -1238,6 +1324,9 @@ impl BumpTransactionEventHandler { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Returns a new instance capable of handling [`Event::BumpTransaction`] events. /// diff --git a/lightning-c-bindings/src/lightning/events/mod.rs b/lightning-c-bindings/src/lightning/events/mod.rs index 2aa4e51..8b4c756 100644 --- a/lightning-c-bindings/src/lightning/events/mod.rs +++ b/lightning-c-bindings/src/lightning/events/mod.rs @@ -23,6 +23,156 @@ use crate::c_types::*; use alloc::{vec::Vec, boxed::Box}; pub mod bump_transaction; +/// `FundingInfo` holds information about a channel's funding transaction. +/// +/// When LDK is set to manual propagation of the funding transaction +/// (via [`ChannelManager::unsafe_manual_funding_transaction_generated`), +/// LDK does not have the full transaction data. Instead, the `OutPoint` +/// for the funding is provided here. +/// +/// [`ChannelManager::unsafe_manual_funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::unsafe_manual_funding_transaction_generated +#[derive(Clone)] +#[must_use] +#[repr(C)] +pub enum FundingInfo { + /// The full funding `Transaction`. + Tx { + /// The funding transaction + transaction: crate::c_types::Transaction, + }, + /// The `OutPoint` of the funding. + OutPoint { + /// The outpoint of the funding + outpoint: crate::lightning::chain::transaction::OutPoint, + }, +} +use lightning::events::FundingInfo as FundingInfoImport; +pub(crate) type nativeFundingInfo = FundingInfoImport; + +impl FundingInfo { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeFundingInfo { + match self { + FundingInfo::Tx {ref transaction, } => { + let mut transaction_nonref = Clone::clone(transaction); + nativeFundingInfo::Tx { + transaction: transaction_nonref.into_bitcoin(), + } + }, + FundingInfo::OutPoint {ref outpoint, } => { + let mut outpoint_nonref = Clone::clone(outpoint); + nativeFundingInfo::OutPoint { + outpoint: *unsafe { Box::from_raw(outpoint_nonref.take_inner()) }, + } + }, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeFundingInfo { + match self { + FundingInfo::Tx {mut transaction, } => { + nativeFundingInfo::Tx { + transaction: transaction.into_bitcoin(), + } + }, + FundingInfo::OutPoint {mut outpoint, } => { + nativeFundingInfo::OutPoint { + outpoint: *unsafe { Box::from_raw(outpoint.take_inner()) }, + } + }, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &FundingInfoImport) -> Self { + let native = unsafe { &*(native as *const _ as *const c_void as *const nativeFundingInfo) }; + match native { + nativeFundingInfo::Tx {ref transaction, } => { + let mut transaction_nonref = Clone::clone(transaction); + FundingInfo::Tx { + transaction: crate::c_types::Transaction::from_bitcoin(&transaction_nonref), + } + }, + nativeFundingInfo::OutPoint {ref outpoint, } => { + let mut outpoint_nonref = Clone::clone(outpoint); + FundingInfo::OutPoint { + outpoint: crate::lightning::chain::transaction::OutPoint { inner: ObjOps::heap_alloc(outpoint_nonref), is_owned: true }, + } + }, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeFundingInfo) -> Self { + match native { + nativeFundingInfo::Tx {mut transaction, } => { + FundingInfo::Tx { + transaction: crate::c_types::Transaction::from_bitcoin(&transaction), + } + }, + nativeFundingInfo::OutPoint {mut outpoint, } => { + FundingInfo::OutPoint { + outpoint: crate::lightning::chain::transaction::OutPoint { inner: ObjOps::heap_alloc(outpoint), is_owned: true }, + } + }, + } + } +} +/// Frees any resources used by the FundingInfo +#[no_mangle] +pub extern "C" fn FundingInfo_free(this_ptr: FundingInfo) { } +/// Creates a copy of the FundingInfo +#[no_mangle] +pub extern "C" fn FundingInfo_clone(orig: &FundingInfo) -> FundingInfo { + orig.clone() +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn FundingInfo_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const FundingInfo)).clone() })) as *mut c_void +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn FundingInfo_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut FundingInfo) }; +} +#[no_mangle] +/// Utility method to constructs a new Tx-variant FundingInfo +pub extern "C" fn FundingInfo_tx(transaction: crate::c_types::Transaction) -> FundingInfo { + FundingInfo::Tx { + transaction, + } +} +#[no_mangle] +/// Utility method to constructs a new OutPoint-variant FundingInfo +pub extern "C" fn FundingInfo_out_point(outpoint: crate::lightning::chain::transaction::OutPoint) -> FundingInfo { + FundingInfo::OutPoint { + outpoint, + } +} +/// Get a string which allows debug introspection of a FundingInfo object +pub extern "C" fn FundingInfo_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::events::FundingInfo }).into()} +/// Checks if two FundingInfos contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +#[no_mangle] +pub extern "C" fn FundingInfo_eq(a: &FundingInfo, b: &FundingInfo) -> bool { + if &a.to_native() == &b.to_native() { true } else { false } +} +#[no_mangle] +/// Serialize the FundingInfo object into a byte array which can be read by FundingInfo_read +pub extern "C" fn FundingInfo_write(obj: &crate::lightning::events::FundingInfo) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(&unsafe { &*obj }.to_native()) +} +#[allow(unused)] +pub(crate) extern "C" fn FundingInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + FundingInfo_write(unsafe { &*(obj as *const FundingInfo) }) +} +#[no_mangle] +/// Read a FundingInfo from a byte array, created by FundingInfo_write +pub extern "C" fn FundingInfo_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingInfoDecodeErrorZ { + 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::FundingInfo::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} /// 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)] @@ -357,6 +507,12 @@ pub struct ClaimedHTLC { pub is_owned: bool, } +impl core::ops::Deref for ClaimedHTLC { + type Target = nativeClaimedHTLC; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ClaimedHTLC { } +unsafe impl core::marker::Sync for ClaimedHTLC { } impl Drop for ClaimedHTLC { fn drop(&mut self) { if self.is_owned && !<*mut nativeClaimedHTLC>::is_null(self.inner) { @@ -387,6 +543,9 @@ impl ClaimedHTLC { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The `channel_id` of the channel over which the HTLC was received. #[no_mangle] @@ -523,7 +682,7 @@ pub extern "C" fn ClaimedHTLC_write(obj: &crate::lightning::events::ClaimedHTLC) } #[allow(unused)] pub(crate) extern "C" fn ClaimedHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClaimedHTLC) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::events::nativeClaimedHTLC) }) } #[no_mangle] /// Read a ClaimedHTLC from a byte array, created by ClaimedHTLC_write @@ -705,12 +864,26 @@ pub enum ClosureReason { /// To be safe, use `Display` on `UntrustedString` /// /// [`UntrustedString`]: crate::util::string::UntrustedString - peer_msg: crate::lightning::util::string::UntrustedString, + peer_msg: crate::lightning_types::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, + HolderForceClosed { + /// Whether or not the latest transaction was broadcasted when the channel was force + /// closed. + /// + /// Channels closed using [`ChannelManager::force_close_broadcasting_latest_txn`] will have + /// this field set to true, whereas channels closed using [`ChannelManager::force_close_without_broadcasting_txn`] + /// or force-closed prior to being funded will have this field set to false. + /// + /// This will be `None` for objects generated or written by LDK 0.0.123 and + /// earlier. + /// + /// [`ChannelManager::force_close_broadcasting_latest_txn`]: crate::ln::channelmanager::ChannelManager::force_close_broadcasting_latest_txn. + /// [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn. + broadcasted_latest_txn: crate::c_types::derived::COption_boolZ, + }, /// 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. /// @@ -762,6 +935,21 @@ pub enum ClosureReason { FundingBatchClosure, /// One of our HTLCs timed out in a channel, causing us to force close the channel. HTLCsTimedOut, + /// Our peer provided a feerate which violated our required minimum (fetched from our + /// [`FeeEstimator`] either as [`ConfirmationTarget::MinAllowedAnchorChannelRemoteFee`] or + /// [`ConfirmationTarget::MinAllowedNonAnchorChannelRemoteFee`]). + /// + /// [`FeeEstimator`]: crate::chain::chaininterface::FeeEstimator + /// [`ConfirmationTarget::MinAllowedAnchorChannelRemoteFee`]: crate::chain::chaininterface::ConfirmationTarget::MinAllowedAnchorChannelRemoteFee + /// [`ConfirmationTarget::MinAllowedNonAnchorChannelRemoteFee`]: crate::chain::chaininterface::ConfirmationTarget::MinAllowedNonAnchorChannelRemoteFee + PeerFeerateTooLow { + /// The feerate on our channel set by our peer. + peer_feerate_sat_per_kw: u32, + /// The required feerate we enforce, from our [`FeeEstimator`]. + /// + /// [`FeeEstimator`]: crate::chain::chaininterface::FeeEstimator + required_feerate_sat_per_kw: u32, + }, } use lightning::events::ClosureReason as ClosureReasonImport; pub(crate) type nativeClosureReason = ClosureReasonImport; @@ -776,7 +964,13 @@ impl ClosureReason { peer_msg: *unsafe { Box::from_raw(peer_msg_nonref.take_inner()) }, } }, - ClosureReason::HolderForceClosed => nativeClosureReason::HolderForceClosed, + ClosureReason::HolderForceClosed {ref broadcasted_latest_txn, } => { + let mut broadcasted_latest_txn_nonref = Clone::clone(broadcasted_latest_txn); + let mut local_broadcasted_latest_txn_nonref = if broadcasted_latest_txn_nonref.is_some() { Some( { broadcasted_latest_txn_nonref.take() }) } else { None }; + nativeClosureReason::HolderForceClosed { + broadcasted_latest_txn: local_broadcasted_latest_txn_nonref, + } + }, ClosureReason::LegacyCooperativeClosure => nativeClosureReason::LegacyCooperativeClosure, ClosureReason::CounterpartyInitiatedCooperativeClosure => nativeClosureReason::CounterpartyInitiatedCooperativeClosure, ClosureReason::LocallyInitiatedCooperativeClosure => nativeClosureReason::LocallyInitiatedCooperativeClosure, @@ -793,6 +987,14 @@ impl ClosureReason { ClosureReason::CounterpartyCoopClosedUnfundedChannel => nativeClosureReason::CounterpartyCoopClosedUnfundedChannel, ClosureReason::FundingBatchClosure => nativeClosureReason::FundingBatchClosure, ClosureReason::HTLCsTimedOut => nativeClosureReason::HTLCsTimedOut, + ClosureReason::PeerFeerateTooLow {ref peer_feerate_sat_per_kw, ref required_feerate_sat_per_kw, } => { + let mut peer_feerate_sat_per_kw_nonref = Clone::clone(peer_feerate_sat_per_kw); + let mut required_feerate_sat_per_kw_nonref = Clone::clone(required_feerate_sat_per_kw); + nativeClosureReason::PeerFeerateTooLow { + peer_feerate_sat_per_kw: peer_feerate_sat_per_kw_nonref, + required_feerate_sat_per_kw: required_feerate_sat_per_kw_nonref, + } + }, } } #[allow(unused)] @@ -803,7 +1005,12 @@ impl ClosureReason { peer_msg: *unsafe { Box::from_raw(peer_msg.take_inner()) }, } }, - ClosureReason::HolderForceClosed => nativeClosureReason::HolderForceClosed, + ClosureReason::HolderForceClosed {mut broadcasted_latest_txn, } => { + let mut local_broadcasted_latest_txn = if broadcasted_latest_txn.is_some() { Some( { broadcasted_latest_txn.take() }) } else { None }; + nativeClosureReason::HolderForceClosed { + broadcasted_latest_txn: local_broadcasted_latest_txn, + } + }, ClosureReason::LegacyCooperativeClosure => nativeClosureReason::LegacyCooperativeClosure, ClosureReason::CounterpartyInitiatedCooperativeClosure => nativeClosureReason::CounterpartyInitiatedCooperativeClosure, ClosureReason::LocallyInitiatedCooperativeClosure => nativeClosureReason::LocallyInitiatedCooperativeClosure, @@ -819,6 +1026,12 @@ impl ClosureReason { ClosureReason::CounterpartyCoopClosedUnfundedChannel => nativeClosureReason::CounterpartyCoopClosedUnfundedChannel, ClosureReason::FundingBatchClosure => nativeClosureReason::FundingBatchClosure, ClosureReason::HTLCsTimedOut => nativeClosureReason::HTLCsTimedOut, + ClosureReason::PeerFeerateTooLow {mut peer_feerate_sat_per_kw, mut required_feerate_sat_per_kw, } => { + nativeClosureReason::PeerFeerateTooLow { + peer_feerate_sat_per_kw: peer_feerate_sat_per_kw, + required_feerate_sat_per_kw: required_feerate_sat_per_kw, + } + }, } } #[allow(unused)] @@ -828,10 +1041,16 @@ impl ClosureReason { 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 }, + peer_msg: crate::lightning_types::string::UntrustedString { inner: ObjOps::heap_alloc(peer_msg_nonref), is_owned: true }, + } + }, + nativeClosureReason::HolderForceClosed {ref broadcasted_latest_txn, } => { + let mut broadcasted_latest_txn_nonref = Clone::clone(broadcasted_latest_txn); + let mut local_broadcasted_latest_txn_nonref = if broadcasted_latest_txn_nonref.is_none() { crate::c_types::derived::COption_boolZ::None } else { crate::c_types::derived::COption_boolZ::Some( { broadcasted_latest_txn_nonref.unwrap() }) }; + ClosureReason::HolderForceClosed { + broadcasted_latest_txn: local_broadcasted_latest_txn_nonref, } }, - nativeClosureReason::HolderForceClosed => ClosureReason::HolderForceClosed, nativeClosureReason::LegacyCooperativeClosure => ClosureReason::LegacyCooperativeClosure, nativeClosureReason::CounterpartyInitiatedCooperativeClosure => ClosureReason::CounterpartyInitiatedCooperativeClosure, nativeClosureReason::LocallyInitiatedCooperativeClosure => ClosureReason::LocallyInitiatedCooperativeClosure, @@ -848,6 +1067,14 @@ impl ClosureReason { nativeClosureReason::CounterpartyCoopClosedUnfundedChannel => ClosureReason::CounterpartyCoopClosedUnfundedChannel, nativeClosureReason::FundingBatchClosure => ClosureReason::FundingBatchClosure, nativeClosureReason::HTLCsTimedOut => ClosureReason::HTLCsTimedOut, + nativeClosureReason::PeerFeerateTooLow {ref peer_feerate_sat_per_kw, ref required_feerate_sat_per_kw, } => { + let mut peer_feerate_sat_per_kw_nonref = Clone::clone(peer_feerate_sat_per_kw); + let mut required_feerate_sat_per_kw_nonref = Clone::clone(required_feerate_sat_per_kw); + ClosureReason::PeerFeerateTooLow { + peer_feerate_sat_per_kw: peer_feerate_sat_per_kw_nonref, + required_feerate_sat_per_kw: required_feerate_sat_per_kw_nonref, + } + }, } } #[allow(unused)] @@ -855,10 +1082,15 @@ impl ClosureReason { 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 }, + peer_msg: crate::lightning_types::string::UntrustedString { inner: ObjOps::heap_alloc(peer_msg), is_owned: true }, + } + }, + nativeClosureReason::HolderForceClosed {mut broadcasted_latest_txn, } => { + let mut local_broadcasted_latest_txn = if broadcasted_latest_txn.is_none() { crate::c_types::derived::COption_boolZ::None } else { crate::c_types::derived::COption_boolZ::Some( { broadcasted_latest_txn.unwrap() }) }; + ClosureReason::HolderForceClosed { + broadcasted_latest_txn: local_broadcasted_latest_txn, } }, - nativeClosureReason::HolderForceClosed => ClosureReason::HolderForceClosed, nativeClosureReason::LegacyCooperativeClosure => ClosureReason::LegacyCooperativeClosure, nativeClosureReason::CounterpartyInitiatedCooperativeClosure => ClosureReason::CounterpartyInitiatedCooperativeClosure, nativeClosureReason::LocallyInitiatedCooperativeClosure => ClosureReason::LocallyInitiatedCooperativeClosure, @@ -874,6 +1106,12 @@ impl ClosureReason { nativeClosureReason::CounterpartyCoopClosedUnfundedChannel => ClosureReason::CounterpartyCoopClosedUnfundedChannel, nativeClosureReason::FundingBatchClosure => ClosureReason::FundingBatchClosure, nativeClosureReason::HTLCsTimedOut => ClosureReason::HTLCsTimedOut, + nativeClosureReason::PeerFeerateTooLow {mut peer_feerate_sat_per_kw, mut required_feerate_sat_per_kw, } => { + ClosureReason::PeerFeerateTooLow { + peer_feerate_sat_per_kw: peer_feerate_sat_per_kw, + required_feerate_sat_per_kw: required_feerate_sat_per_kw, + } + }, } } } @@ -897,15 +1135,18 @@ pub(crate) extern "C" fn ClosureReason_free_void(this_ptr: *mut c_void) { } #[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 { +pub extern "C" fn ClosureReason_counterparty_force_closed(peer_msg: crate::lightning_types::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} +pub extern "C" fn ClosureReason_holder_force_closed(broadcasted_latest_txn: crate::c_types::derived::COption_boolZ) -> ClosureReason { + ClosureReason::HolderForceClosed { + broadcasted_latest_txn, + } +} #[no_mangle] /// Utility method to constructs a new LegacyCooperativeClosure-variant ClosureReason pub extern "C" fn ClosureReason_legacy_cooperative_closure() -> ClosureReason { @@ -953,6 +1194,14 @@ pub extern "C" fn ClosureReason_funding_batch_closure() -> ClosureReason { /// Utility method to constructs a new HTLCsTimedOut-variant ClosureReason pub extern "C" fn ClosureReason_htlcs_timed_out() -> ClosureReason { ClosureReason::HTLCsTimedOut} +#[no_mangle] +/// Utility method to constructs a new PeerFeerateTooLow-variant ClosureReason +pub extern "C" fn ClosureReason_peer_feerate_too_low(peer_feerate_sat_per_kw: u32, required_feerate_sat_per_kw: u32) -> ClosureReason { + ClosureReason::PeerFeerateTooLow { + peer_feerate_sat_per_kw, + required_feerate_sat_per_kw, + } +} /// Get a string which allows debug introspection of a ClosureReason object pub extern "C" fn ClosureReason_debug_str_void(o: *const c_void) -> Str { alloc::format!("{:?}", unsafe { o as *const crate::lightning::events::ClosureReason }).into()} @@ -1238,6 +1487,12 @@ pub extern "C" fn HTLCDestination_read(ser: crate::c_types::u8slice) -> crate::c #[repr(C)] pub enum PaymentFailureReason { /// The intended recipient rejected our payment. + /// + /// Also used for [`UnknownRequiredFeatures`] and [`InvoiceRequestRejected`] when downgrading to + /// version prior to 0.0.124. + /// + /// [`UnknownRequiredFeatures`]: Self::UnknownRequiredFeatures + /// [`InvoiceRequestRejected`]: Self::InvoiceRequestRejected RecipientRejected, /// The user chose to abandon this payment by calling [`ChannelManager::abandon_payment`]. /// @@ -1253,7 +1508,10 @@ pub enum PaymentFailureReason { /// The payment expired while retrying, based on the provided /// [`PaymentParameters::expiry_time`]. /// + /// Also used for [`InvoiceRequestExpired`] when downgrading to version prior to 0.0.124. + /// /// [`PaymentParameters::expiry_time`]: crate::routing::router::PaymentParameters::expiry_time + /// [`InvoiceRequestExpired`]: Self::InvoiceRequestExpired PaymentExpired, /// We failed to find a route while retrying the payment. /// @@ -1264,6 +1522,14 @@ pub enum PaymentFailureReason { /// This error should generally never happen. This likely means that there is a problem with /// your router. UnexpectedError, + /// An invoice was received that required unknown features. + UnknownRequiredFeatures, + /// A [`Bolt12Invoice`] was not received in a reasonable amount of time. + InvoiceRequestExpired, + /// An [`InvoiceRequest`] for the payment was rejected by the recipient. + /// + /// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest + InvoiceRequestRejected, } use lightning::events::PaymentFailureReason as PaymentFailureReasonImport; pub(crate) type nativePaymentFailureReason = PaymentFailureReasonImport; @@ -1278,6 +1544,9 @@ impl PaymentFailureReason { PaymentFailureReason::PaymentExpired => nativePaymentFailureReason::PaymentExpired, PaymentFailureReason::RouteNotFound => nativePaymentFailureReason::RouteNotFound, PaymentFailureReason::UnexpectedError => nativePaymentFailureReason::UnexpectedError, + PaymentFailureReason::UnknownRequiredFeatures => nativePaymentFailureReason::UnknownRequiredFeatures, + PaymentFailureReason::InvoiceRequestExpired => nativePaymentFailureReason::InvoiceRequestExpired, + PaymentFailureReason::InvoiceRequestRejected => nativePaymentFailureReason::InvoiceRequestRejected, } } #[allow(unused)] @@ -1289,6 +1558,9 @@ impl PaymentFailureReason { PaymentFailureReason::PaymentExpired => nativePaymentFailureReason::PaymentExpired, PaymentFailureReason::RouteNotFound => nativePaymentFailureReason::RouteNotFound, PaymentFailureReason::UnexpectedError => nativePaymentFailureReason::UnexpectedError, + PaymentFailureReason::UnknownRequiredFeatures => nativePaymentFailureReason::UnknownRequiredFeatures, + PaymentFailureReason::InvoiceRequestExpired => nativePaymentFailureReason::InvoiceRequestExpired, + PaymentFailureReason::InvoiceRequestRejected => nativePaymentFailureReason::InvoiceRequestRejected, } } #[allow(unused)] @@ -1301,6 +1573,9 @@ impl PaymentFailureReason { nativePaymentFailureReason::PaymentExpired => PaymentFailureReason::PaymentExpired, nativePaymentFailureReason::RouteNotFound => PaymentFailureReason::RouteNotFound, nativePaymentFailureReason::UnexpectedError => PaymentFailureReason::UnexpectedError, + nativePaymentFailureReason::UnknownRequiredFeatures => PaymentFailureReason::UnknownRequiredFeatures, + nativePaymentFailureReason::InvoiceRequestExpired => PaymentFailureReason::InvoiceRequestExpired, + nativePaymentFailureReason::InvoiceRequestRejected => PaymentFailureReason::InvoiceRequestRejected, } } #[allow(unused)] @@ -1312,6 +1587,9 @@ impl PaymentFailureReason { nativePaymentFailureReason::PaymentExpired => PaymentFailureReason::PaymentExpired, nativePaymentFailureReason::RouteNotFound => PaymentFailureReason::RouteNotFound, nativePaymentFailureReason::UnexpectedError => PaymentFailureReason::UnexpectedError, + nativePaymentFailureReason::UnknownRequiredFeatures => PaymentFailureReason::UnknownRequiredFeatures, + nativePaymentFailureReason::InvoiceRequestExpired => PaymentFailureReason::InvoiceRequestExpired, + nativePaymentFailureReason::InvoiceRequestRejected => PaymentFailureReason::InvoiceRequestRejected, } } } @@ -1354,6 +1632,18 @@ pub extern "C" fn PaymentFailureReason_route_not_found() -> PaymentFailureReason /// Utility method to constructs a new UnexpectedError-variant PaymentFailureReason pub extern "C" fn PaymentFailureReason_unexpected_error() -> PaymentFailureReason { PaymentFailureReason::UnexpectedError} +#[no_mangle] +/// Utility method to constructs a new UnknownRequiredFeatures-variant PaymentFailureReason +pub extern "C" fn PaymentFailureReason_unknown_required_features() -> PaymentFailureReason { + PaymentFailureReason::UnknownRequiredFeatures} +#[no_mangle] +/// Utility method to constructs a new InvoiceRequestExpired-variant PaymentFailureReason +pub extern "C" fn PaymentFailureReason_invoice_request_expired() -> PaymentFailureReason { + PaymentFailureReason::InvoiceRequestExpired} +#[no_mangle] +/// Utility method to constructs a new InvoiceRequestRejected-variant PaymentFailureReason +pub extern "C" fn PaymentFailureReason_invoice_request_rejected() -> PaymentFailureReason { + PaymentFailureReason::InvoiceRequestRejected} /// Get a string which allows debug introspection of a PaymentFailureReason object pub extern "C" fn PaymentFailureReason_debug_str_void(o: *const c_void) -> Str { alloc::format!("{:?}", unsafe { o as *const crate::lightning::events::PaymentFailureReason }).into()} @@ -1374,9 +1664,9 @@ pub(crate) extern "C" fn PaymentFailureReason_write_void(obj: *const c_void) -> } #[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() }; +pub extern "C" fn PaymentFailureReason_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_COption_PaymentFailureReasonZDecodeErrorZ { + 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_PaymentFailureReasonZ::None } else { crate::c_types::derived::COption_PaymentFailureReasonZ::Some( { crate::lightning::events::PaymentFailureReason::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 which you should probably take some action in response to. @@ -1394,6 +1684,10 @@ pub enum Event { /// Note that *all inputs* in the funding transaction must spend SegWit outputs or your /// counterparty can steal your funds! /// + /// # Failure Behavior and Persistence + /// This event will eventually be replayed after failures-to-handle (i.e., the event handler + /// returning `Err(ReplayEvent ())`), but won't be persisted across restarts. + /// /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager /// [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated FundingGenerationReady { @@ -1422,6 +1716,32 @@ pub enum Event { /// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels user_channel_id: crate::c_types::U128, }, + /// Used to indicate that the counterparty node has provided the signature(s) required to + /// recover our funds in case they go offline. + /// + /// It is safe (and your responsibility) to broadcast the funding transaction upon receiving this + /// event. + /// + /// This event is only emitted if you called + /// [`ChannelManager::unsafe_manual_funding_transaction_generated`] instead of + /// [`ChannelManager::funding_transaction_generated`]. + /// + /// [`ChannelManager::unsafe_manual_funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::unsafe_manual_funding_transaction_generated + /// [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated + FundingTxBroadcastSafe { + /// The `channel_id` indicating which channel has reached this stage. + channel_id: crate::lightning::ln::types::ChannelId, + /// The `user_channel_id` value passed in to [`ChannelManager::create_channel`]. + /// + /// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel + user_channel_id: crate::c_types::U128, + /// The outpoint of the channel's funding transaction. + funding_txo: crate::lightning::chain::transaction::OutPoint, + /// The `node_id` of the channel counterparty. + counterparty_node_id: crate::c_types::PublicKey, + /// The `temporary_channel_id` this channel used to be known by during channel establishment. + former_temporary_channel_id: crate::lightning::ln::types::ChannelId, + }, /// 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`]. /// @@ -1451,6 +1771,10 @@ pub enum Event { /// # Note /// This event used to be called `PaymentReceived` in LDK versions 0.0.112 and earlier. /// + /// # Failure Behavior and Persistence + /// This event will eventually be replayed after failures-to-handle (i.e., the event handler + /// returning `Err(ReplayEvent ())`) and will be persisted across restarts. + /// /// [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds /// [`ChannelManager::claim_funds_with_known_custom_tlvs`]: crate::ln::channelmanager::ChannelManager::claim_funds_with_known_custom_tlvs /// [`FailureCode::InvalidOnionPayload`]: crate::ln::channelmanager::FailureCode::InvalidOnionPayload @@ -1526,6 +1850,10 @@ pub enum Event { /// [`ChannelManager::claim_funds`] twice for the same [`Event::PaymentClaimable`] you may get /// multiple `PaymentClaimed` events. /// + /// # Failure Behavior and Persistence + /// This event will eventually be replayed after failures-to-handle (i.e., the event handler + /// returning `Err(ReplayEvent ())`) and will be persisted across restarts. + /// /// [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds PaymentClaimed { /// The node that received the payment. @@ -1552,6 +1880,13 @@ pub enum Event { /// The sender-intended sum total of all the MPP parts. This will be `None` for events /// serialized prior to LDK version 0.0.117. sender_intended_total_msat: crate::c_types::derived::COption_u64Z, + /// 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.124 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, }, /// Indicates that a peer connection with a node is needed in order to send an [`OnionMessage`]. /// @@ -1562,6 +1897,11 @@ pub enum Event { /// This event will not be generated for onion message forwards; only for sends including /// replies. Handlers should connect to the node otherwise any buffered messages may be lost. /// + /// # Failure Behavior and Persistence + /// This event won't be replayed after failures-to-handle + /// (i.e., the event handler returning `Err(ReplayEvent ())`), and also won't be persisted + /// across restarts. + /// /// [`OnionMessage`]: msgs::OnionMessage /// [`MessageRouter`]: crate::onion_message::messenger::MessageRouter /// [`Destination`]: crate::onion_message::messenger::Destination @@ -1572,23 +1912,50 @@ pub enum Event { /// Sockets for connecting to the node. addresses: crate::c_types::derived::CVec_SocketAddressZ, }, - /// Indicates a request for an invoice failed to yield a response in a reasonable amount of time - /// or was explicitly abandoned by [`ChannelManager::abandon_payment`]. This may be for an - /// [`InvoiceRequest`] sent for an [`Offer`] or for a [`Refund`] that hasn't been redeemed. + /// Indicates a [`Bolt12Invoice`] in response to an [`InvoiceRequest`] or a [`Refund`] was + /// received. + /// + /// This event will only be generated if [`UserConfig::manually_handle_bolt12_invoices`] is set. + /// Use [`ChannelManager::send_payment_for_bolt12_invoice`] to pay the invoice or + /// [`ChannelManager::abandon_payment`] to abandon the associated payment. See those docs for + /// further details. + /// + /// # Failure Behavior and Persistence + /// This event will eventually be replayed after failures-to-handle (i.e., the event handler + /// returning `Err(ReplayEvent ())`) and will be persisted across restarts. /// - /// [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment /// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest - /// [`Offer`]: crate::offers::offer::Offer /// [`Refund`]: crate::offers::refund::Refund - InvoiceRequestFailed { - /// The `payment_id` to have been associated with payment for the requested invoice. + /// [`UserConfig::manually_handle_bolt12_invoices`]: crate::util::config::UserConfig::manually_handle_bolt12_invoices + /// [`ChannelManager::send_payment_for_bolt12_invoice`]: crate::ln::channelmanager::ChannelManager::send_payment_for_bolt12_invoice + /// [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment + InvoiceReceived { + /// The `payment_id` associated with payment for the invoice. payment_id: crate::c_types::ThirtyTwoBytes, + /// The invoice to pay. + invoice: crate::lightning::offers::invoice::Bolt12Invoice, + /// The context of the [`BlindedMessagePath`] used to send the invoice. + /// + /// [`BlindedMessagePath`]: crate::blinded_path::message::BlindedMessagePath + context: crate::c_types::derived::COption_OffersContextZ, + /// A responder for replying with an [`InvoiceError`] if needed. + /// + /// `None` if the invoice wasn't sent with a reply path. + /// + /// [`InvoiceError`]: crate::offers::invoice_error::InvoiceError + /// + /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + responder: crate::lightning::onion_message::messenger::Responder, }, /// 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. + /// + /// # Failure Behavior and Persistence + /// This event will eventually be replayed after failures-to-handle (i.e., the event handler + /// returning `Err(ReplayEvent ())`) and will be persisted across restarts. PaymentSent { /// The `payment_id` passed to [`ChannelManager::send_payment`]. /// @@ -1610,6 +1977,8 @@ pub enum Event { /// If the recipient or an intermediate node misbehaves and gives us free money, this may /// overstate the amount paid, though this is unlikely. /// + /// This is only `None` for payments initiated on LDK versions prior to 0.0.103. + /// /// [`Route::get_total_fees`]: crate::routing::router::Route::get_total_fees fee_paid_msat: crate::c_types::derived::COption_u64Z, }, @@ -1625,6 +1994,10 @@ pub enum Event { /// received and processed. In this case, the [`Event::PaymentFailed`] event MUST be ignored, /// and the payment MUST be treated as having succeeded. /// + /// # Failure Behavior and Persistence + /// This event will eventually be replayed after failures-to-handle (i.e., the event handler + /// returning `Err(ReplayEvent ())`) and will be persisted across restarts. + /// /// [`Retry`]: crate::ln::channelmanager::Retry /// [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment PaymentFailed { @@ -1632,18 +2005,25 @@ pub enum Event { /// /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment payment_id: crate::c_types::ThirtyTwoBytes, - /// The hash that was given to [`ChannelManager::send_payment`]. + /// The hash that was given to [`ChannelManager::send_payment`]. `None` if the payment failed + /// before receiving an invoice when paying a BOLT12 [`Offer`]. /// /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment - payment_hash: crate::c_types::ThirtyTwoBytes, + /// [`Offer`]: crate::offers::offer::Offer + payment_hash: crate::c_types::derived::COption_ThirtyTwoBytesZ, /// The reason the payment failed. This is only `None` for events generated or serialized - /// by versions prior to 0.0.115. + /// by versions prior to 0.0.115, or when downgrading to a version with a reason that was + /// added after. 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. + /// + /// # Failure Behavior and Persistence + /// This event will eventually be replayed after failures-to-handle (i.e., the event handler + /// returning `Err(ReplayEvent ())`) and will be persisted across restarts. PaymentPathSuccessful { /// The `payment_id` passed to [`ChannelManager::send_payment`]. /// @@ -1669,6 +2049,10 @@ pub enum Event { /// See [`ChannelManager::abandon_payment`] for giving up on this payment before its retries have /// been exhausted. /// + /// # Failure Behavior and Persistence + /// This event will eventually be replayed after failures-to-handle (i.e., the event handler + /// returning `Err(ReplayEvent ())`) and will be persisted across restarts. + /// /// [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment PaymentPathFailed { /// The `payment_id` passed to [`ChannelManager::send_payment`]. @@ -1704,6 +2088,10 @@ pub enum Event { 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. + /// + /// # Failure Behavior and Persistence + /// This event will eventually be replayed after failures-to-handle (i.e., the event handler + /// returning `Err(ReplayEvent ())`) and will be persisted across restarts. ProbeSuccessful { /// The id returned by [`ChannelManager::send_probe`]. /// @@ -1717,6 +2105,10 @@ pub enum Event { path: crate::lightning::routing::router::Path, }, /// Indicates that a probe payment we sent failed at an intermediary node on the path. + /// + /// # Failure Behavior and Persistence + /// This event will eventually be replayed after failures-to-handle (i.e., the event handler + /// returning `Err(ReplayEvent ())`) and will be persisted across restarts. ProbeFailed { /// The id returned by [`ChannelManager::send_probe`]. /// @@ -1738,6 +2130,10 @@ pub enum Event { /// Used to indicate that [`ChannelManager::process_pending_htlc_forwards`] should be called at /// a time in the future. /// + /// # Failure Behavior and Persistence + /// This event will eventually be replayed after failures-to-handle (i.e., the event handler + /// returning `Err(ReplayEvent ())`) and will be regenerated after restarts. + /// /// [`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 @@ -1754,6 +2150,10 @@ pub enum Event { /// [`ChannelManager::fail_intercepted_htlc`] MUST be called in response to this event. See /// their docs for more information. /// + /// # Failure Behavior and Persistence + /// This event will eventually be replayed after failures-to-handle (i.e., the event handler + /// returning `Err(ReplayEvent ())`) and will be persisted across restarts. + /// /// [`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 @@ -1789,6 +2189,10 @@ pub enum Event { /// You may hand them to the [`OutputSweeper`] utility which will store and (re-)generate spending /// transactions for you. /// + /// # Failure Behavior and Persistence + /// This event will eventually be replayed after failures-to-handle (i.e., the event handler + /// returning `Err(ReplayEvent ())`) and will be persisted across restarts. + /// /// [`OutputSweeper`]: crate::util::sweep::OutputSweeper SpendableOutputs { /// The outputs which you should store as spendable by you. @@ -1802,6 +2206,10 @@ pub enum Event { }, /// This event is generated when a payment has been successfully forwarded through us and a /// forwarding fee earned. + /// + /// # Failure Behavior and Persistence + /// This event will eventually be replayed after failures-to-handle (i.e., the event handler + /// returning `Err(ReplayEvent ())`) and will be persisted across restarts. PaymentForwarded { /// The channel id of the incoming channel between the previous node and us. /// @@ -1867,6 +2275,10 @@ pub enum Event { /// 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. + /// + /// # Failure Behavior and Persistence + /// This event will eventually be replayed after failures-to-handle (i.e., the event handler + /// returning `Err(ReplayEvent ())`) and will be persisted across restarts. ChannelPending { /// The `channel_id` of the channel that is pending confirmation. channel_id: crate::lightning::ln::types::ChannelId, @@ -1894,12 +2306,16 @@ pub enum Event { /// Will be `None` for channels created prior to LDK version 0.0.122. /// /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None - channel_type: crate::lightning::ln::features::ChannelTypeFeatures, + channel_type: crate::lightning_types::features::ChannelTypeFeatures, }, /// 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. + /// + /// # Failure Behavior and Persistence + /// This event will eventually be replayed after failures-to-handle (i.e., the event handler + /// returning `Err(ReplayEvent ())`) and will be persisted across restarts. ChannelReady { /// The `channel_id` of the channel that is ready. channel_id: crate::lightning::ln::types::ChannelId, @@ -1915,7 +2331,7 @@ pub enum Event { /// 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, + channel_type: crate::lightning_types::features::ChannelTypeFeatures, }, /// Used to indicate that a channel that got past the initial handshake with the given `channel_id` is in the /// process of closure. This includes previously opened channels, and channels that time out from not being funded. @@ -1926,6 +2342,10 @@ pub enum Event { /// /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel /// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels + /// + /// # Failure Behavior and Persistence + /// This event will eventually be replayed after failures-to-handle (i.e., the event handler + /// returning `Err(ReplayEvent ())`) and will be persisted across restarts. ChannelClosed { /// The `channel_id` of the channel which has been closed. Note that on-chain transactions /// resolving the channel are likely still awaiting confirmation. @@ -1964,11 +2384,15 @@ pub enum Event { /// inputs for another purpose. /// /// This event is not guaranteed to be generated for channels that are closed due to a restart. + /// + /// # Failure Behavior and Persistence + /// This event will eventually be replayed after failures-to-handle (i.e., the event handler + /// returning `Err(ReplayEvent ())`) and will be persisted across restarts. DiscardFunding { /// The channel_id of the channel which has been closed. channel_id: crate::lightning::ln::types::ChannelId, /// The full transaction received from the user - transaction: crate::c_types::Transaction, + funding_info: crate::lightning::events::FundingInfo, }, /// Indicates a request to open a new channel by a peer. /// @@ -1979,6 +2403,10 @@ pub enum Event { /// 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. /// + /// # Failure Behavior and Persistence + /// This event will eventually be replayed after failures-to-handle (i.e., the event handler + /// returning `Err(ReplayEvent ())`) and will be persisted across restarts. + /// /// [`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 @@ -2021,7 +2449,11 @@ pub enum Event { /// or will be rejected otherwise. /// /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager - channel_type: crate::lightning::ln::features::ChannelTypeFeatures, + channel_type: crate::lightning_types::features::ChannelTypeFeatures, + /// True if this channel is (or will be) publicly-announced. + is_announced: bool, + /// Channel parameters given by the counterparty. + params: crate::lightning::ln::msgs::ChannelParameters, }, /// Indicates that the HTLC was accepted, but could not be processed when or after attempting to /// forward it. @@ -2035,6 +2467,10 @@ pub enum Event { /// /// 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). + /// + /// # Failure Behavior and Persistence + /// This event will eventually be replayed after failures-to-handle (i.e., the event handler + /// returning `Err(ReplayEvent ())`) and will be persisted across restarts. HTLCHandlingFailed { /// The channel over which the HTLC was received. prev_channel_id: crate::lightning::ln::types::ChannelId, @@ -2048,9 +2484,45 @@ pub enum Event { /// [`ChannelHandshakeConfig::negotiate_anchors_zero_fee_htlc_tx`] config flag is set to true. /// It is limited to the scope of channels with anchor outputs. /// + /// # Failure Behavior and Persistence + /// This event will eventually be replayed after failures-to-handle (i.e., the event handler + /// returning `Err(ReplayEvent ())`), but will only be regenerated as needed after restarts. + /// /// [`ChannelHandshakeConfig::negotiate_anchors_zero_fee_htlc_tx`]: crate::util::config::ChannelHandshakeConfig::negotiate_anchors_zero_fee_htlc_tx BumpTransaction( crate::lightning::events::bump_transaction::BumpTransactionEvent), + /// We received an onion message that is intended to be forwarded to a peer + /// that is currently offline. This event will only be generated if the + /// `OnionMessenger` was initialized with + /// [`OnionMessenger::new_with_offline_peer_interception`], see its docs. + /// + /// # Failure Behavior and Persistence + /// This event will eventually be replayed after failures-to-handle (i.e., the event handler + /// returning `Err(ReplayEvent ())`), but won't be persisted across restarts. + /// + /// [`OnionMessenger::new_with_offline_peer_interception`]: crate::onion_message::messenger::OnionMessenger::new_with_offline_peer_interception + OnionMessageIntercepted { + /// The node id of the offline peer. + peer_node_id: crate::c_types::PublicKey, + /// The onion message intended to be forwarded to `peer_node_id`. + message: crate::lightning::ln::msgs::OnionMessage, + }, + /// Indicates that an onion message supporting peer has come online and it may + /// be time to forward any onion messages that were previously intercepted for + /// them. This event will only be generated if the `OnionMessenger` was + /// initialized with + /// [`OnionMessenger::new_with_offline_peer_interception`], see its docs. + /// + /// # Failure Behavior and Persistence + /// This event will eventually be replayed after failures-to-handle (i.e., the event handler + /// returning `Err(ReplayEvent ())`), but won't be persisted across restarts. + /// + /// [`OnionMessenger::new_with_offline_peer_interception`]: crate::onion_message::messenger::OnionMessenger::new_with_offline_peer_interception + OnionMessagePeerConnected { + /// The node id of the peer we just connected to, who advertises support for + /// onion messages. + peer_node_id: crate::c_types::PublicKey, + }, } use lightning::events::Event as EventImport; pub(crate) type nativeEvent = EventImport; @@ -2069,8 +2541,22 @@ impl Event { temporary_channel_id: *unsafe { Box::from_raw(temporary_channel_id_nonref.take_inner()) }, counterparty_node_id: counterparty_node_id_nonref.into_rust(), channel_value_satoshis: channel_value_satoshis_nonref, - output_script: ::bitcoin::blockdata::script::ScriptBuf::from(output_script_nonref.into_rust()), + output_script: ::bitcoin::script::ScriptBuf::from(output_script_nonref.into_rust()), + user_channel_id: user_channel_id_nonref.into(), + } + }, + Event::FundingTxBroadcastSafe {ref channel_id, ref user_channel_id, ref funding_txo, ref counterparty_node_id, ref former_temporary_channel_id, } => { + let mut channel_id_nonref = Clone::clone(channel_id); + let mut user_channel_id_nonref = Clone::clone(user_channel_id); + let mut funding_txo_nonref = Clone::clone(funding_txo); + let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id); + let mut former_temporary_channel_id_nonref = Clone::clone(former_temporary_channel_id); + nativeEvent::FundingTxBroadcastSafe { + channel_id: *unsafe { Box::from_raw(channel_id_nonref.take_inner()) }, user_channel_id: user_channel_id_nonref.into(), + funding_txo: crate::c_types::C_to_bitcoin_outpoint(funding_txo_nonref), + counterparty_node_id: counterparty_node_id_nonref.into_rust(), + former_temporary_channel_id: *unsafe { Box::from_raw(former_temporary_channel_id_nonref.take_inner()) }, } }, 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, } => { @@ -2100,7 +2586,7 @@ impl Event { claim_deadline: local_claim_deadline_nonref, } }, - Event::PaymentClaimed {ref receiver_node_id, ref payment_hash, ref amount_msat, ref purpose, ref htlcs, ref sender_intended_total_msat, } => { + Event::PaymentClaimed {ref receiver_node_id, ref payment_hash, ref amount_msat, ref purpose, ref htlcs, ref sender_intended_total_msat, ref onion_fields, } => { 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); @@ -2110,6 +2596,8 @@ impl Event { let mut local_htlcs_nonref = Vec::new(); for mut item in htlcs_nonref.into_rust().drain(..) { local_htlcs_nonref.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; let mut sender_intended_total_msat_nonref = Clone::clone(sender_intended_total_msat); let mut local_sender_intended_total_msat_nonref = if sender_intended_total_msat_nonref.is_some() { Some( { sender_intended_total_msat_nonref.take() }) } else { None }; + 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()) } }) }; nativeEvent::PaymentClaimed { receiver_node_id: local_receiver_node_id_nonref, payment_hash: ::lightning::ln::types::PaymentHash(payment_hash_nonref.data), @@ -2117,6 +2605,7 @@ impl Event { purpose: purpose_nonref.into_native(), htlcs: local_htlcs_nonref, sender_intended_total_msat: local_sender_intended_total_msat_nonref, + onion_fields: local_onion_fields_nonref, } }, Event::ConnectionNeeded {ref node_id, ref addresses, } => { @@ -2128,10 +2617,18 @@ impl Event { addresses: local_addresses_nonref, } }, - Event::InvoiceRequestFailed {ref payment_id, } => { + Event::InvoiceReceived {ref payment_id, ref invoice, ref context, ref responder, } => { let mut payment_id_nonref = Clone::clone(payment_id); - nativeEvent::InvoiceRequestFailed { + let mut invoice_nonref = Clone::clone(invoice); + let mut context_nonref = Clone::clone(context); + let mut local_context_nonref = { /*context_nonref*/ let context_nonref_opt = context_nonref; if context_nonref_opt.is_none() { None } else { Some({ { { context_nonref_opt.take() }.into_native() }})} }; + let mut responder_nonref = Clone::clone(responder); + let mut local_responder_nonref = if responder_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(responder_nonref.take_inner()) } }) }; + nativeEvent::InvoiceReceived { payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data), + invoice: *unsafe { Box::from_raw(invoice_nonref.take_inner()) }, + context: local_context_nonref, + responder: local_responder_nonref, } }, Event::PaymentSent {ref payment_id, ref payment_preimage, ref payment_hash, ref fee_paid_msat, } => { @@ -2151,11 +2648,12 @@ impl Event { 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 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::types::PaymentHash({ payment_hash_nonref_opt.take() }.data) }})} }; 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::types::PaymentHash(payment_hash_nonref.data), + payment_hash: local_payment_hash_nonref, reason: local_reason_nonref, } }, @@ -2317,26 +2815,30 @@ impl Event { channel_funding_txo: local_channel_funding_txo_nonref, } }, - Event::DiscardFunding {ref channel_id, ref transaction, } => { + Event::DiscardFunding {ref channel_id, ref funding_info, } => { let mut channel_id_nonref = Clone::clone(channel_id); - let mut transaction_nonref = Clone::clone(transaction); + let mut funding_info_nonref = Clone::clone(funding_info); nativeEvent::DiscardFunding { channel_id: *unsafe { Box::from_raw(channel_id_nonref.take_inner()) }, - transaction: transaction_nonref.into_bitcoin(), + funding_info: funding_info_nonref.into_native(), } }, - Event::OpenChannelRequest {ref temporary_channel_id, ref counterparty_node_id, ref funding_satoshis, ref push_msat, ref channel_type, } => { + Event::OpenChannelRequest {ref temporary_channel_id, ref counterparty_node_id, ref funding_satoshis, ref push_msat, ref channel_type, ref is_announced, ref params, } => { 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); + let mut is_announced_nonref = Clone::clone(is_announced); + let mut params_nonref = Clone::clone(params); nativeEvent::OpenChannelRequest { temporary_channel_id: *unsafe { Box::from_raw(temporary_channel_id_nonref.take_inner()) }, 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()) }, + is_announced: is_announced_nonref, + params: *unsafe { Box::from_raw(params_nonref.take_inner()) }, } }, Event::HTLCHandlingFailed {ref prev_channel_id, ref failed_next_destination, } => { @@ -2353,6 +2855,20 @@ impl Event { a_nonref.into_native(), ) }, + Event::OnionMessageIntercepted {ref peer_node_id, ref message, } => { + let mut peer_node_id_nonref = Clone::clone(peer_node_id); + let mut message_nonref = Clone::clone(message); + nativeEvent::OnionMessageIntercepted { + peer_node_id: peer_node_id_nonref.into_rust(), + message: *unsafe { Box::from_raw(message_nonref.take_inner()) }, + } + }, + Event::OnionMessagePeerConnected {ref peer_node_id, } => { + let mut peer_node_id_nonref = Clone::clone(peer_node_id); + nativeEvent::OnionMessagePeerConnected { + peer_node_id: peer_node_id_nonref.into_rust(), + } + }, } } #[allow(unused)] @@ -2363,10 +2879,19 @@ impl Event { temporary_channel_id: *unsafe { Box::from_raw(temporary_channel_id.take_inner()) }, counterparty_node_id: counterparty_node_id.into_rust(), channel_value_satoshis: channel_value_satoshis, - output_script: ::bitcoin::blockdata::script::ScriptBuf::from(output_script.into_rust()), + output_script: ::bitcoin::script::ScriptBuf::from(output_script.into_rust()), user_channel_id: user_channel_id.into(), } }, + Event::FundingTxBroadcastSafe {mut channel_id, mut user_channel_id, mut funding_txo, mut counterparty_node_id, mut former_temporary_channel_id, } => { + nativeEvent::FundingTxBroadcastSafe { + channel_id: *unsafe { Box::from_raw(channel_id.take_inner()) }, + user_channel_id: user_channel_id.into(), + funding_txo: crate::c_types::C_to_bitcoin_outpoint(funding_txo), + counterparty_node_id: counterparty_node_id.into_rust(), + former_temporary_channel_id: *unsafe { Box::from_raw(former_temporary_channel_id.take_inner()) }, + } + }, 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()) } }) }; @@ -2385,10 +2910,11 @@ impl Event { claim_deadline: local_claim_deadline, } }, - Event::PaymentClaimed {mut receiver_node_id, mut payment_hash, mut amount_msat, mut purpose, mut htlcs, mut sender_intended_total_msat, } => { + Event::PaymentClaimed {mut receiver_node_id, mut payment_hash, mut amount_msat, mut purpose, mut htlcs, mut sender_intended_total_msat, mut onion_fields, } => { let mut local_receiver_node_id = if receiver_node_id.is_null() { None } else { Some( { receiver_node_id.into_rust() }) }; let mut local_htlcs = Vec::new(); for mut item in htlcs.into_rust().drain(..) { local_htlcs.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; let mut local_sender_intended_total_msat = if sender_intended_total_msat.is_some() { Some( { sender_intended_total_msat.take() }) } else { None }; + let mut local_onion_fields = if onion_fields.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(onion_fields.take_inner()) } }) }; nativeEvent::PaymentClaimed { receiver_node_id: local_receiver_node_id, payment_hash: ::lightning::ln::types::PaymentHash(payment_hash.data), @@ -2396,6 +2922,7 @@ impl Event { purpose: purpose.into_native(), htlcs: local_htlcs, sender_intended_total_msat: local_sender_intended_total_msat, + onion_fields: local_onion_fields, } }, Event::ConnectionNeeded {mut node_id, mut addresses, } => { @@ -2405,9 +2932,14 @@ impl Event { addresses: local_addresses, } }, - Event::InvoiceRequestFailed {mut payment_id, } => { - nativeEvent::InvoiceRequestFailed { + Event::InvoiceReceived {mut payment_id, mut invoice, mut context, mut responder, } => { + let mut local_context = { /*context*/ let context_opt = context; if context_opt.is_none() { None } else { Some({ { { context_opt.take() }.into_native() }})} }; + let mut local_responder = if responder.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(responder.take_inner()) } }) }; + nativeEvent::InvoiceReceived { payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id.data), + invoice: *unsafe { Box::from_raw(invoice.take_inner()) }, + context: local_context, + responder: local_responder, } }, Event::PaymentSent {mut payment_id, mut payment_preimage, mut payment_hash, mut fee_paid_msat, } => { @@ -2421,10 +2953,11 @@ impl Event { } }, Event::PaymentFailed {mut payment_id, mut payment_hash, mut reason, } => { + let mut local_payment_hash = { /*payment_hash*/ let payment_hash_opt = payment_hash; if payment_hash_opt.is_none() { None } else { Some({ { ::lightning::ln::types::PaymentHash({ payment_hash_opt.take() }.data) }})} }; 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::types::PaymentHash(payment_hash.data), + payment_hash: local_payment_hash, reason: local_reason, } }, @@ -2538,19 +3071,21 @@ impl Event { channel_funding_txo: local_channel_funding_txo, } }, - Event::DiscardFunding {mut channel_id, mut transaction, } => { + Event::DiscardFunding {mut channel_id, mut funding_info, } => { nativeEvent::DiscardFunding { channel_id: *unsafe { Box::from_raw(channel_id.take_inner()) }, - transaction: transaction.into_bitcoin(), + funding_info: funding_info.into_native(), } }, - Event::OpenChannelRequest {mut temporary_channel_id, mut counterparty_node_id, mut funding_satoshis, mut push_msat, mut channel_type, } => { + Event::OpenChannelRequest {mut temporary_channel_id, mut counterparty_node_id, mut funding_satoshis, mut push_msat, mut channel_type, mut is_announced, mut params, } => { nativeEvent::OpenChannelRequest { temporary_channel_id: *unsafe { Box::from_raw(temporary_channel_id.take_inner()) }, 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()) }, + is_announced: is_announced, + params: *unsafe { Box::from_raw(params.take_inner()) }, } }, Event::HTLCHandlingFailed {mut prev_channel_id, mut failed_next_destination, } => { @@ -2564,6 +3099,17 @@ impl Event { a.into_native(), ) }, + Event::OnionMessageIntercepted {mut peer_node_id, mut message, } => { + nativeEvent::OnionMessageIntercepted { + peer_node_id: peer_node_id.into_rust(), + message: *unsafe { Box::from_raw(message.take_inner()) }, + } + }, + Event::OnionMessagePeerConnected {mut peer_node_id, } => { + nativeEvent::OnionMessagePeerConnected { + peer_node_id: peer_node_id.into_rust(), + } + }, } } #[allow(unused)] @@ -2584,6 +3130,20 @@ impl Event { user_channel_id: user_channel_id_nonref.into(), } }, + nativeEvent::FundingTxBroadcastSafe {ref channel_id, ref user_channel_id, ref funding_txo, ref counterparty_node_id, ref former_temporary_channel_id, } => { + let mut channel_id_nonref = Clone::clone(channel_id); + let mut user_channel_id_nonref = Clone::clone(user_channel_id); + let mut funding_txo_nonref = Clone::clone(funding_txo); + let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id); + let mut former_temporary_channel_id_nonref = Clone::clone(former_temporary_channel_id); + Event::FundingTxBroadcastSafe { + channel_id: crate::lightning::ln::types::ChannelId { inner: ObjOps::heap_alloc(channel_id_nonref), is_owned: true }, + user_channel_id: user_channel_id_nonref.into(), + funding_txo: crate::c_types::bitcoin_to_C_outpoint(&funding_txo_nonref), + counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id_nonref), + former_temporary_channel_id: crate::lightning::ln::types::ChannelId { inner: ObjOps::heap_alloc(former_temporary_channel_id_nonref), is_owned: true }, + } + }, 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())) } }; @@ -2611,7 +3171,7 @@ impl Event { claim_deadline: local_claim_deadline_nonref, } }, - nativeEvent::PaymentClaimed {ref receiver_node_id, ref payment_hash, ref amount_msat, ref purpose, ref htlcs, ref sender_intended_total_msat, } => { + nativeEvent::PaymentClaimed {ref receiver_node_id, ref payment_hash, ref amount_msat, ref purpose, ref htlcs, ref sender_intended_total_msat, ref onion_fields, } => { 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); @@ -2621,6 +3181,8 @@ impl Event { let mut local_htlcs_nonref = Vec::new(); for mut item in htlcs_nonref.drain(..) { local_htlcs_nonref.push( { crate::lightning::events::ClaimedHTLC { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; let mut sender_intended_total_msat_nonref = Clone::clone(sender_intended_total_msat); let mut local_sender_intended_total_msat_nonref = if sender_intended_total_msat_nonref.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { sender_intended_total_msat_nonref.unwrap() }) }; + 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 }; Event::PaymentClaimed { receiver_node_id: local_receiver_node_id_nonref, payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 }, @@ -2628,6 +3190,7 @@ impl Event { purpose: crate::lightning::events::PaymentPurpose::native_into(purpose_nonref), htlcs: local_htlcs_nonref.into(), sender_intended_total_msat: local_sender_intended_total_msat_nonref, + onion_fields: local_onion_fields_nonref, } }, nativeEvent::ConnectionNeeded {ref node_id, ref addresses, } => { @@ -2639,10 +3202,18 @@ impl Event { addresses: local_addresses_nonref.into(), } }, - nativeEvent::InvoiceRequestFailed {ref payment_id, } => { + nativeEvent::InvoiceReceived {ref payment_id, ref invoice, ref context, ref responder, } => { let mut payment_id_nonref = Clone::clone(payment_id); - Event::InvoiceRequestFailed { + let mut invoice_nonref = Clone::clone(invoice); + let mut context_nonref = Clone::clone(context); + let mut local_context_nonref = if context_nonref.is_none() { crate::c_types::derived::COption_OffersContextZ::None } else { crate::c_types::derived::COption_OffersContextZ::Some( { crate::lightning::blinded_path::message::OffersContext::native_into(context_nonref.unwrap()) }) }; + let mut responder_nonref = Clone::clone(responder); + let mut local_responder_nonref = crate::lightning::onion_message::messenger::Responder { inner: if responder_nonref.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((responder_nonref.unwrap())) } }, is_owned: true }; + Event::InvoiceReceived { payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id_nonref.0 }, + invoice: crate::lightning::offers::invoice::Bolt12Invoice { inner: ObjOps::heap_alloc(invoice_nonref), is_owned: true }, + context: local_context_nonref, + responder: local_responder_nonref, } }, nativeEvent::PaymentSent {ref payment_id, ref payment_preimage, ref payment_hash, ref fee_paid_msat, } => { @@ -2662,11 +3233,12 @@ impl Event { 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 local_payment_hash_nonref = if payment_hash_nonref.is_none() { crate::c_types::derived::COption_ThirtyTwoBytesZ::None } else { crate::c_types::derived::COption_ThirtyTwoBytesZ::Some( { crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.unwrap().0 } }) }; 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 }, + payment_hash: local_payment_hash_nonref, reason: local_reason_nonref, } }, @@ -2787,7 +3359,7 @@ impl Event { let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id); let mut funding_txo_nonref = Clone::clone(funding_txo); let mut channel_type_nonref = Clone::clone(channel_type); - let mut local_channel_type_nonref = crate::lightning::ln::features::ChannelTypeFeatures { inner: if channel_type_nonref.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((channel_type_nonref.unwrap())) } }, is_owned: true }; + let mut local_channel_type_nonref = crate::lightning_types::features::ChannelTypeFeatures { inner: if channel_type_nonref.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((channel_type_nonref.unwrap())) } }, is_owned: true }; Event::ChannelPending { channel_id: crate::lightning::ln::types::ChannelId { inner: ObjOps::heap_alloc(channel_id_nonref), is_owned: true }, user_channel_id: user_channel_id_nonref.into(), @@ -2806,7 +3378,7 @@ impl Event { channel_id: crate::lightning::ln::types::ChannelId { inner: ObjOps::heap_alloc(channel_id_nonref), is_owned: true }, 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 }, + channel_type: crate::lightning_types::features::ChannelTypeFeatures { inner: ObjOps::heap_alloc(channel_type_nonref), is_owned: true }, } }, nativeEvent::ChannelClosed {ref channel_id, ref user_channel_id, ref reason, ref counterparty_node_id, ref channel_capacity_sats, ref channel_funding_txo, } => { @@ -2828,26 +3400,30 @@ impl Event { channel_funding_txo: local_channel_funding_txo_nonref, } }, - nativeEvent::DiscardFunding {ref channel_id, ref transaction, } => { + nativeEvent::DiscardFunding {ref channel_id, ref funding_info, } => { let mut channel_id_nonref = Clone::clone(channel_id); - let mut transaction_nonref = Clone::clone(transaction); + let mut funding_info_nonref = Clone::clone(funding_info); Event::DiscardFunding { channel_id: crate::lightning::ln::types::ChannelId { inner: ObjOps::heap_alloc(channel_id_nonref), is_owned: true }, - transaction: crate::c_types::Transaction::from_bitcoin(&transaction_nonref), + funding_info: crate::lightning::events::FundingInfo::native_into(funding_info_nonref), } }, - nativeEvent::OpenChannelRequest {ref temporary_channel_id, ref counterparty_node_id, ref funding_satoshis, ref push_msat, ref channel_type, } => { + nativeEvent::OpenChannelRequest {ref temporary_channel_id, ref counterparty_node_id, ref funding_satoshis, ref push_msat, ref channel_type, ref is_announced, ref params, } => { 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); + let mut is_announced_nonref = Clone::clone(is_announced); + let mut params_nonref = Clone::clone(params); Event::OpenChannelRequest { temporary_channel_id: crate::lightning::ln::types::ChannelId { inner: ObjOps::heap_alloc(temporary_channel_id_nonref), is_owned: true }, 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 }, + channel_type: crate::lightning_types::features::ChannelTypeFeatures { inner: ObjOps::heap_alloc(channel_type_nonref), is_owned: true }, + is_announced: is_announced_nonref, + params: crate::lightning::ln::msgs::ChannelParameters { inner: ObjOps::heap_alloc(params_nonref), is_owned: true }, } }, nativeEvent::HTLCHandlingFailed {ref prev_channel_id, ref failed_next_destination, } => { @@ -2864,6 +3440,20 @@ impl Event { crate::lightning::events::bump_transaction::BumpTransactionEvent::native_into(a_nonref), ) }, + nativeEvent::OnionMessageIntercepted {ref peer_node_id, ref message, } => { + let mut peer_node_id_nonref = Clone::clone(peer_node_id); + let mut message_nonref = Clone::clone(message); + Event::OnionMessageIntercepted { + peer_node_id: crate::c_types::PublicKey::from_rust(&peer_node_id_nonref), + message: crate::lightning::ln::msgs::OnionMessage { inner: ObjOps::heap_alloc(message_nonref), is_owned: true }, + } + }, + nativeEvent::OnionMessagePeerConnected {ref peer_node_id, } => { + let mut peer_node_id_nonref = Clone::clone(peer_node_id); + Event::OnionMessagePeerConnected { + peer_node_id: crate::c_types::PublicKey::from_rust(&peer_node_id_nonref), + } + }, } } #[allow(unused)] @@ -2878,6 +3468,15 @@ impl Event { user_channel_id: user_channel_id.into(), } }, + nativeEvent::FundingTxBroadcastSafe {mut channel_id, mut user_channel_id, mut funding_txo, mut counterparty_node_id, mut former_temporary_channel_id, } => { + Event::FundingTxBroadcastSafe { + channel_id: crate::lightning::ln::types::ChannelId { inner: ObjOps::heap_alloc(channel_id), is_owned: true }, + user_channel_id: user_channel_id.into(), + funding_txo: crate::c_types::bitcoin_to_C_outpoint(&funding_txo), + counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id), + former_temporary_channel_id: crate::lightning::ln::types::ChannelId { inner: ObjOps::heap_alloc(former_temporary_channel_id), is_owned: true }, + } + }, 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 }; @@ -2896,10 +3495,11 @@ impl Event { claim_deadline: local_claim_deadline, } }, - nativeEvent::PaymentClaimed {mut receiver_node_id, mut payment_hash, mut amount_msat, mut purpose, mut htlcs, mut sender_intended_total_msat, } => { + nativeEvent::PaymentClaimed {mut receiver_node_id, mut payment_hash, mut amount_msat, mut purpose, mut htlcs, mut sender_intended_total_msat, mut onion_fields, } => { 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_htlcs = Vec::new(); for mut item in htlcs.drain(..) { local_htlcs.push( { crate::lightning::events::ClaimedHTLC { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; let mut local_sender_intended_total_msat = if sender_intended_total_msat.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { sender_intended_total_msat.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 }; Event::PaymentClaimed { receiver_node_id: local_receiver_node_id, payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 }, @@ -2907,6 +3507,7 @@ impl Event { purpose: crate::lightning::events::PaymentPurpose::native_into(purpose), htlcs: local_htlcs.into(), sender_intended_total_msat: local_sender_intended_total_msat, + onion_fields: local_onion_fields, } }, nativeEvent::ConnectionNeeded {mut node_id, mut addresses, } => { @@ -2916,9 +3517,14 @@ impl Event { addresses: local_addresses.into(), } }, - nativeEvent::InvoiceRequestFailed {mut payment_id, } => { - Event::InvoiceRequestFailed { + nativeEvent::InvoiceReceived {mut payment_id, mut invoice, mut context, mut responder, } => { + let mut local_context = if context.is_none() { crate::c_types::derived::COption_OffersContextZ::None } else { crate::c_types::derived::COption_OffersContextZ::Some( { crate::lightning::blinded_path::message::OffersContext::native_into(context.unwrap()) }) }; + let mut local_responder = crate::lightning::onion_message::messenger::Responder { inner: if responder.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((responder.unwrap())) } }, is_owned: true }; + Event::InvoiceReceived { payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id.0 }, + invoice: crate::lightning::offers::invoice::Bolt12Invoice { inner: ObjOps::heap_alloc(invoice), is_owned: true }, + context: local_context, + responder: local_responder, } }, nativeEvent::PaymentSent {mut payment_id, mut payment_preimage, mut payment_hash, mut fee_paid_msat, } => { @@ -2932,10 +3538,11 @@ impl Event { } }, nativeEvent::PaymentFailed {mut payment_id, mut payment_hash, mut reason, } => { + let mut local_payment_hash = if payment_hash.is_none() { crate::c_types::derived::COption_ThirtyTwoBytesZ::None } else { crate::c_types::derived::COption_ThirtyTwoBytesZ::Some( { crate::c_types::ThirtyTwoBytes { data: payment_hash.unwrap().0 } }) }; 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 }, + payment_hash: local_payment_hash, reason: local_reason, } }, @@ -3018,7 +3625,7 @@ impl Event { }, nativeEvent::ChannelPending {mut channel_id, mut user_channel_id, mut former_temporary_channel_id, mut counterparty_node_id, mut funding_txo, mut channel_type, } => { let mut local_former_temporary_channel_id = crate::lightning::ln::types::ChannelId { inner: if former_temporary_channel_id.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((former_temporary_channel_id.unwrap())) } }, is_owned: true }; - let mut local_channel_type = crate::lightning::ln::features::ChannelTypeFeatures { inner: if channel_type.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((channel_type.unwrap())) } }, is_owned: true }; + let mut local_channel_type = crate::lightning_types::features::ChannelTypeFeatures { inner: if channel_type.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((channel_type.unwrap())) } }, is_owned: true }; Event::ChannelPending { channel_id: crate::lightning::ln::types::ChannelId { inner: ObjOps::heap_alloc(channel_id), is_owned: true }, user_channel_id: user_channel_id.into(), @@ -3033,7 +3640,7 @@ impl Event { channel_id: crate::lightning::ln::types::ChannelId { inner: ObjOps::heap_alloc(channel_id), is_owned: true }, 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 }, + channel_type: crate::lightning_types::features::ChannelTypeFeatures { inner: ObjOps::heap_alloc(channel_type), is_owned: true }, } }, nativeEvent::ChannelClosed {mut channel_id, mut user_channel_id, mut reason, mut counterparty_node_id, mut channel_capacity_sats, mut channel_funding_txo, } => { @@ -3049,19 +3656,21 @@ impl Event { channel_funding_txo: local_channel_funding_txo, } }, - nativeEvent::DiscardFunding {mut channel_id, mut transaction, } => { + nativeEvent::DiscardFunding {mut channel_id, mut funding_info, } => { Event::DiscardFunding { channel_id: crate::lightning::ln::types::ChannelId { inner: ObjOps::heap_alloc(channel_id), is_owned: true }, - transaction: crate::c_types::Transaction::from_bitcoin(&transaction), + funding_info: crate::lightning::events::FundingInfo::native_into(funding_info), } }, - nativeEvent::OpenChannelRequest {mut temporary_channel_id, mut counterparty_node_id, mut funding_satoshis, mut push_msat, mut channel_type, } => { + nativeEvent::OpenChannelRequest {mut temporary_channel_id, mut counterparty_node_id, mut funding_satoshis, mut push_msat, mut channel_type, mut is_announced, mut params, } => { Event::OpenChannelRequest { temporary_channel_id: crate::lightning::ln::types::ChannelId { inner: ObjOps::heap_alloc(temporary_channel_id), is_owned: true }, 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 }, + channel_type: crate::lightning_types::features::ChannelTypeFeatures { inner: ObjOps::heap_alloc(channel_type), is_owned: true }, + is_announced: is_announced, + params: crate::lightning::ln::msgs::ChannelParameters { inner: ObjOps::heap_alloc(params), is_owned: true }, } }, nativeEvent::HTLCHandlingFailed {mut prev_channel_id, mut failed_next_destination, } => { @@ -3075,6 +3684,17 @@ impl Event { crate::lightning::events::bump_transaction::BumpTransactionEvent::native_into(a), ) }, + nativeEvent::OnionMessageIntercepted {mut peer_node_id, mut message, } => { + Event::OnionMessageIntercepted { + peer_node_id: crate::c_types::PublicKey::from_rust(&peer_node_id), + message: crate::lightning::ln::msgs::OnionMessage { inner: ObjOps::heap_alloc(message), is_owned: true }, + } + }, + nativeEvent::OnionMessagePeerConnected {mut peer_node_id, } => { + Event::OnionMessagePeerConnected { + peer_node_id: crate::c_types::PublicKey::from_rust(&peer_node_id), + } + }, } } } @@ -3108,6 +3728,17 @@ pub extern "C" fn Event_funding_generation_ready(temporary_channel_id: crate::li } } #[no_mangle] +/// Utility method to constructs a new FundingTxBroadcastSafe-variant Event +pub extern "C" fn Event_funding_tx_broadcast_safe(channel_id: crate::lightning::ln::types::ChannelId, user_channel_id: crate::c_types::U128, funding_txo: crate::lightning::chain::transaction::OutPoint, counterparty_node_id: crate::c_types::PublicKey, former_temporary_channel_id: crate::lightning::ln::types::ChannelId) -> Event { + Event::FundingTxBroadcastSafe { + channel_id, + user_channel_id, + funding_txo, + counterparty_node_id, + former_temporary_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::lightning::ln::types::ChannelId, via_user_channel_id: crate::c_types::derived::COption_U128Z, claim_deadline: crate::c_types::derived::COption_u32Z) -> Event { Event::PaymentClaimable { @@ -3124,7 +3755,7 @@ pub extern "C" fn Event_payment_claimable(receiver_node_id: crate::c_types::Publ } #[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, htlcs: crate::c_types::derived::CVec_ClaimedHTLCZ, sender_intended_total_msat: crate::c_types::derived::COption_u64Z) -> 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, htlcs: crate::c_types::derived::CVec_ClaimedHTLCZ, sender_intended_total_msat: crate::c_types::derived::COption_u64Z, onion_fields: crate::lightning::ln::outbound_payment::RecipientOnionFields) -> Event { Event::PaymentClaimed { receiver_node_id, payment_hash, @@ -3132,6 +3763,7 @@ pub extern "C" fn Event_payment_claimed(receiver_node_id: crate::c_types::Public purpose, htlcs, sender_intended_total_msat, + onion_fields, } } #[no_mangle] @@ -3143,10 +3775,13 @@ pub extern "C" fn Event_connection_needed(node_id: crate::c_types::PublicKey, ad } } #[no_mangle] -/// Utility method to constructs a new InvoiceRequestFailed-variant Event -pub extern "C" fn Event_invoice_request_failed(payment_id: crate::c_types::ThirtyTwoBytes) -> Event { - Event::InvoiceRequestFailed { +/// Utility method to constructs a new InvoiceReceived-variant Event +pub extern "C" fn Event_invoice_received(payment_id: crate::c_types::ThirtyTwoBytes, invoice: crate::lightning::offers::invoice::Bolt12Invoice, context: crate::c_types::derived::COption_OffersContextZ, responder: crate::lightning::onion_message::messenger::Responder) -> Event { + Event::InvoiceReceived { payment_id, + invoice, + context, + responder, } } #[no_mangle] @@ -3161,7 +3796,7 @@ pub extern "C" fn Event_payment_sent(payment_id: crate::c_types::derived::COptio } #[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 { +pub extern "C" fn Event_payment_failed(payment_id: crate::c_types::ThirtyTwoBytes, payment_hash: crate::c_types::derived::COption_ThirtyTwoBytesZ, reason: crate::c_types::derived::COption_PaymentFailureReasonZ) -> Event { Event::PaymentFailed { payment_id, payment_hash, @@ -3250,7 +3885,7 @@ pub extern "C" fn Event_payment_forwarded(prev_channel_id: crate::lightning::ln: } #[no_mangle] /// Utility method to constructs a new ChannelPending-variant Event -pub extern "C" fn Event_channel_pending(channel_id: crate::lightning::ln::types::ChannelId, user_channel_id: crate::c_types::U128, former_temporary_channel_id: crate::lightning::ln::types::ChannelId, counterparty_node_id: crate::c_types::PublicKey, funding_txo: crate::lightning::chain::transaction::OutPoint, channel_type: crate::lightning::ln::features::ChannelTypeFeatures) -> Event { +pub extern "C" fn Event_channel_pending(channel_id: crate::lightning::ln::types::ChannelId, user_channel_id: crate::c_types::U128, former_temporary_channel_id: crate::lightning::ln::types::ChannelId, counterparty_node_id: crate::c_types::PublicKey, funding_txo: crate::lightning::chain::transaction::OutPoint, channel_type: crate::lightning_types::features::ChannelTypeFeatures) -> Event { Event::ChannelPending { channel_id, user_channel_id, @@ -3262,7 +3897,7 @@ pub extern "C" fn Event_channel_pending(channel_id: crate::lightning::ln::types: } #[no_mangle] /// Utility method to constructs a new ChannelReady-variant Event -pub extern "C" fn Event_channel_ready(channel_id: crate::lightning::ln::types::ChannelId, user_channel_id: crate::c_types::U128, counterparty_node_id: crate::c_types::PublicKey, channel_type: crate::lightning::ln::features::ChannelTypeFeatures) -> Event { +pub extern "C" fn Event_channel_ready(channel_id: crate::lightning::ln::types::ChannelId, user_channel_id: crate::c_types::U128, counterparty_node_id: crate::c_types::PublicKey, channel_type: crate::lightning_types::features::ChannelTypeFeatures) -> Event { Event::ChannelReady { channel_id, user_channel_id, @@ -3284,21 +3919,23 @@ pub extern "C" fn Event_channel_closed(channel_id: crate::lightning::ln::types:: } #[no_mangle] /// Utility method to constructs a new DiscardFunding-variant Event -pub extern "C" fn Event_discard_funding(channel_id: crate::lightning::ln::types::ChannelId, transaction: crate::c_types::Transaction) -> Event { +pub extern "C" fn Event_discard_funding(channel_id: crate::lightning::ln::types::ChannelId, funding_info: crate::lightning::events::FundingInfo) -> Event { Event::DiscardFunding { channel_id, - transaction, + funding_info, } } #[no_mangle] /// Utility method to constructs a new OpenChannelRequest-variant Event -pub extern "C" fn Event_open_channel_request(temporary_channel_id: crate::lightning::ln::types::ChannelId, counterparty_node_id: crate::c_types::PublicKey, funding_satoshis: u64, push_msat: u64, channel_type: crate::lightning::ln::features::ChannelTypeFeatures) -> Event { +pub extern "C" fn Event_open_channel_request(temporary_channel_id: crate::lightning::ln::types::ChannelId, counterparty_node_id: crate::c_types::PublicKey, funding_satoshis: u64, push_msat: u64, channel_type: crate::lightning_types::features::ChannelTypeFeatures, is_announced: bool, params: crate::lightning::ln::msgs::ChannelParameters) -> Event { Event::OpenChannelRequest { temporary_channel_id, counterparty_node_id, funding_satoshis, push_msat, channel_type, + is_announced, + params, } } #[no_mangle] @@ -3314,6 +3951,21 @@ pub extern "C" fn Event_htlchandling_failed(prev_channel_id: crate::lightning::l pub extern "C" fn Event_bump_transaction(a: crate::lightning::events::bump_transaction::BumpTransactionEvent) -> Event { Event::BumpTransaction(a, ) } +#[no_mangle] +/// Utility method to constructs a new OnionMessageIntercepted-variant Event +pub extern "C" fn Event_onion_message_intercepted(peer_node_id: crate::c_types::PublicKey, message: crate::lightning::ln::msgs::OnionMessage) -> Event { + Event::OnionMessageIntercepted { + peer_node_id, + message, + } +} +#[no_mangle] +/// Utility method to constructs a new OnionMessagePeerConnected-variant Event +pub extern "C" fn Event_onion_message_peer_connected(peer_node_id: crate::c_types::PublicKey) -> Event { + Event::OnionMessagePeerConnected { + peer_node_id, + } +} /// Get a string which allows debug introspection of a Event object pub extern "C" fn Event_debug_str_void(o: *const c_void) -> Str { alloc::format!("{:?}", unsafe { o as *const crate::lightning::events::Event }).into()} @@ -3399,12 +4051,12 @@ pub enum MessageSendEvent { /// The message which should be sent. msg: crate::lightning::ln::msgs::Stfu, }, - /// Used to indicate that a splice message should be sent to the peer with the given node id. - SendSplice { + /// Used to indicate that a splice_init message should be sent to the peer with the given node id. + SendSpliceInit { /// 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::Splice, + msg: crate::lightning::ln::msgs::SpliceInit, }, /// Used to indicate that a splice_ack message should be sent to the peer with the given node id. SendSpliceAck { @@ -3682,10 +4334,10 @@ impl MessageSendEvent { msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, } }, - MessageSendEvent::SendSplice {ref node_id, ref msg, } => { + MessageSendEvent::SendSpliceInit {ref node_id, ref msg, } => { let mut node_id_nonref = Clone::clone(node_id); let mut msg_nonref = Clone::clone(msg); - nativeMessageSendEvent::SendSplice { + nativeMessageSendEvent::SendSpliceInit { node_id: node_id_nonref.into_rust(), msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, } @@ -3960,8 +4612,8 @@ impl MessageSendEvent { msg: *unsafe { Box::from_raw(msg.take_inner()) }, } }, - MessageSendEvent::SendSplice {mut node_id, mut msg, } => { - nativeMessageSendEvent::SendSplice { + MessageSendEvent::SendSpliceInit {mut node_id, mut msg, } => { + nativeMessageSendEvent::SendSpliceInit { node_id: node_id.into_rust(), msg: *unsafe { Box::from_raw(msg.take_inner()) }, } @@ -4196,12 +4848,12 @@ impl MessageSendEvent { msg: crate::lightning::ln::msgs::Stfu { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, } }, - nativeMessageSendEvent::SendSplice {ref node_id, ref msg, } => { + nativeMessageSendEvent::SendSpliceInit {ref node_id, ref msg, } => { let mut node_id_nonref = Clone::clone(node_id); let mut msg_nonref = Clone::clone(msg); - MessageSendEvent::SendSplice { + MessageSendEvent::SendSpliceInit { node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), - msg: crate::lightning::ln::msgs::Splice { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, + msg: crate::lightning::ln::msgs::SpliceInit { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, } }, nativeMessageSendEvent::SendSpliceAck {ref node_id, ref msg, } => { @@ -4474,10 +5126,10 @@ impl MessageSendEvent { msg: crate::lightning::ln::msgs::Stfu { inner: ObjOps::heap_alloc(msg), is_owned: true }, } }, - nativeMessageSendEvent::SendSplice {mut node_id, mut msg, } => { - MessageSendEvent::SendSplice { + nativeMessageSendEvent::SendSpliceInit {mut node_id, mut msg, } => { + MessageSendEvent::SendSpliceInit { node_id: crate::c_types::PublicKey::from_rust(&node_id), - msg: crate::lightning::ln::msgs::Splice { inner: ObjOps::heap_alloc(msg), is_owned: true }, + msg: crate::lightning::ln::msgs::SpliceInit { inner: ObjOps::heap_alloc(msg), is_owned: true }, } }, nativeMessageSendEvent::SendSpliceAck {mut node_id, mut msg, } => { @@ -4726,9 +5378,9 @@ pub extern "C" fn MessageSendEvent_send_stfu(node_id: crate::c_types::PublicKey, } } #[no_mangle] -/// Utility method to constructs a new SendSplice-variant MessageSendEvent -pub extern "C" fn MessageSendEvent_send_splice(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::Splice) -> MessageSendEvent { - MessageSendEvent::SendSplice { +/// Utility method to constructs a new SendSpliceInit-variant MessageSendEvent +pub extern "C" fn MessageSendEvent_send_splice_init(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::SpliceInit) -> MessageSendEvent { + MessageSendEvent::SendSpliceInit { node_id, msg, } @@ -4992,17 +5644,26 @@ impl rustMessageSendEventsProvider for MessageSendEventsProvider { } } +pub struct MessageSendEventsProviderRef(MessageSendEventsProvider); +impl rustMessageSendEventsProvider for MessageSendEventsProviderRef { + fn get_and_clear_pending_msg_events(&self) -> Vec { + let mut ret = (self.0.get_and_clear_pending_msg_events)(self.0.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 + type Target = MessageSendEventsProviderRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const MessageSendEventsProviderRef) } } } impl core::ops::DerefMut for MessageSendEventsProvider { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut MessageSendEventsProviderRef { + unsafe { &mut *(self as *mut _ as *mut MessageSendEventsProviderRef) } } } /// Calls the free function if one is set @@ -5030,8 +5691,12 @@ impl Drop for MessageSendEventsProvider { /// /// 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. +/// [`process_pending_events`] returns `Ok(())`, thus handlers MUST fully handle [`Event`]s and +/// persist any relevant changes to disk *before* returning `Ok(())`. In case of an error (e.g., +/// persistence failure) implementors should return `Err(ReplayEvent())`, signalling to the +/// [`EventsProvider`] to replay unhandled events on the next invocation (generally immediately). +/// Note that some events might not be replayed, please refer to the documentation for +/// the individual [`Event`] variants for more detail. /// /// 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 @@ -5086,11 +5751,104 @@ impl Drop for EventsProvider { } } } + +use lightning::events::ReplayEvent as nativeReplayEventImport; +pub(crate) type nativeReplayEvent = nativeReplayEventImport; + +/// An error type that may be returned to LDK in order to safely abort event handling if it can't +/// currently succeed (e.g., due to a persistence failure). +/// +/// Depending on the type, LDK may ensure the event is persisted and will eventually be replayed. +/// Please refer to the documentation of each [`Event`] variant for more details. +#[must_use] +#[repr(C)] +pub struct ReplayEvent { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, 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 nativeReplayEvent, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust 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 core::ops::Deref for ReplayEvent { + type Target = nativeReplayEvent; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ReplayEvent { } +unsafe impl core::marker::Sync for ReplayEvent { } +impl Drop for ReplayEvent { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeReplayEvent>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the ReplayEvent, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn ReplayEvent_free(this_obj: ReplayEvent) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn ReplayEvent_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeReplayEvent) }; +} +#[allow(unused)] +impl ReplayEvent { + pub(crate) fn get_native_ref(&self) -> &'static nativeReplayEvent { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeReplayEvent { + 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 nativeReplayEvent { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// Constructs a new ReplayEvent given each field +#[must_use] +#[no_mangle] +pub extern "C" fn ReplayEvent_new() -> ReplayEvent { + ReplayEvent { inner: ObjOps::heap_alloc(lightning::events::ReplayEvent ( + )), is_owned: true } +} +impl Clone for ReplayEvent { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeReplayEvent>::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 ReplayEvent_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeReplayEvent)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the ReplayEvent +pub extern "C" fn ReplayEvent_clone(orig: &ReplayEvent) -> ReplayEvent { + orig.clone() +} +/// Get a string which allows debug introspection of a ReplayEvent object +pub extern "C" fn ReplayEvent_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::events::ReplayEvent }).into()} /// 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`. +/// 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. @@ -5099,7 +5857,7 @@ pub struct EventHandler { /// 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), + pub handle_event: extern "C" fn (this_arg: *const c_void, event: crate::lightning::events::Event) -> crate::c_types::derived::CResult_NoneReplayEventZ, /// 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, @@ -5117,22 +5875,33 @@ pub(crate) fn EventHandler_clone_fields(orig: &EventHandler) -> EventHandler { 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)) + fn handle_event(&self, mut event: lightning::events::Event) -> Result<(), lightning::events::ReplayEvent> { + let mut ret = (self.handle_event)(self.this_arg, crate::lightning::events::Event::native_into(event)); + 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((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })}; + local_ret + } +} + +pub struct EventHandlerRef(EventHandler); +impl rustEventHandler for EventHandlerRef { + fn handle_event(&self, mut event: lightning::events::Event) -> Result<(), lightning::events::ReplayEvent> { + let mut ret = (self.0.handle_event)(self.0.this_arg, crate::lightning::events::Event::native_into(event)); + 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((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).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 EventHandler { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = EventHandlerRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const EventHandlerRef) } } } impl core::ops::DerefMut for EventHandler { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut EventHandlerRef { + unsafe { &mut *(self as *mut _ as *mut EventHandlerRef) } } } /// Calls the free function if one is set diff --git a/lightning-c-bindings/src/lightning/io.rs b/lightning-c-bindings/src/lightning/io.rs new file mode 100644 index 0000000..d0f9fec --- /dev/null +++ b/lightning-c-bindings/src/lightning/io.rs @@ -0,0 +1,19 @@ +// 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. + +/// Extension of the bitcoin::io module + +use alloc::str::FromStr; +use alloc::string::String; +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}; + diff --git a/lightning-c-bindings/src/lightning/ln/bolt11_payment.rs b/lightning-c-bindings/src/lightning/ln/bolt11_payment.rs new file mode 100644 index 0000000..1e91910 --- /dev/null +++ b/lightning-c-bindings/src/lightning/ln/bolt11_payment.rs @@ -0,0 +1,56 @@ +// 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. + +//! Convenient utilities for paying Lightning invoices. + +use alloc::str::FromStr; +use alloc::string::String; +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}; + +/// Builds the necessary parameters to pay or pre-flight probe the given zero-amount +/// [`Bolt11Invoice`] using [`ChannelManager::send_payment`] or +/// [`ChannelManager::send_preflight_probes`]. +/// +/// Prior to paying, you must ensure that the [`Bolt11Invoice::payment_hash`] is unique and the +/// same [`PaymentHash`] has never been paid before. +/// +/// Will always succeed unless the invoice has an amount specified, in which case +/// [`payment_parameters_from_invoice`] should be used. +/// +/// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment +/// [`ChannelManager::send_preflight_probes`]: crate::ln::channelmanager::ChannelManager::send_preflight_probes +#[no_mangle] +pub extern "C" fn payment_parameters_from_zero_amount_invoice(invoice: &crate::lightning_invoice::Bolt11Invoice, mut amount_msat: u64) -> crate::c_types::derived::CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ { + let mut ret = lightning::ln::bolt11_payment::payment_parameters_from_zero_amount_invoice(invoice.get_native_ref(), amount_msat); + 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, mut orig_ret_0_2) = o; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0.0 }, crate::lightning::ln::outbound_payment::RecipientOnionFields { inner: ObjOps::heap_alloc(orig_ret_0_1), is_owned: true }, crate::lightning::routing::router::RouteParameters { inner: ObjOps::heap_alloc(orig_ret_0_2), is_owned: true }).into(); local_ret_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Builds the necessary parameters to pay or pre-flight probe the given [`Bolt11Invoice`] using +/// [`ChannelManager::send_payment`] or [`ChannelManager::send_preflight_probes`]. +/// +/// Prior to paying, you must ensure that the [`Bolt11Invoice::payment_hash`] is unique and the +/// same [`PaymentHash`] has never been paid before. +/// +/// Will always succeed unless the invoice has no amount specified, in which case +/// [`payment_parameters_from_zero_amount_invoice`] should be used. +/// +/// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment +/// [`ChannelManager::send_preflight_probes`]: crate::ln::channelmanager::ChannelManager::send_preflight_probes +#[no_mangle] +pub extern "C" fn payment_parameters_from_invoice(invoice: &crate::lightning_invoice::Bolt11Invoice) -> crate::c_types::derived::CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ { + let mut ret = lightning::ln::bolt11_payment::payment_parameters_from_invoice(invoice.get_native_ref()); + 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, mut orig_ret_0_2) = o; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0.0 }, crate::lightning::ln::outbound_payment::RecipientOnionFields { inner: ObjOps::heap_alloc(orig_ret_0_1), is_owned: true }, crate::lightning::routing::router::RouteParameters { inner: ObjOps::heap_alloc(orig_ret_0_2), is_owned: true }).into(); local_ret_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + diff --git a/lightning-c-bindings/src/lightning/ln/chan_utils.rs b/lightning-c-bindings/src/lightning/ln/chan_utils.rs index c1a23fd..a5fa45c 100644 --- a/lightning-c-bindings/src/lightning/ln/chan_utils.rs +++ b/lightning-c-bindings/src/lightning/ln/chan_utils.rs @@ -52,14 +52,14 @@ pub static HTLC_TIMEOUT_INPUT_ANCHOR_WITNESS_WEIGHT: u64 = lightning::ln::chan_u 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(channel_type_features: &crate::lightning::ln::features::ChannelTypeFeatures) -> u64 { +pub extern "C" fn htlc_success_tx_weight(channel_type_features: &crate::lightning_types::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(channel_type_features: &crate::lightning::ln::features::ChannelTypeFeatures) -> u64 { +pub extern "C" fn htlc_timeout_tx_weight(channel_type_features: &crate::lightning_types::features::ChannelTypeFeatures) -> u64 { let mut ret = lightning::ln::chan_utils::htlc_timeout_tx_weight(channel_type_features.get_native_ref()); ret } @@ -186,7 +186,7 @@ pub extern "C" fn build_commitment_secret(commitment_seed: *const [u8; 32], mut /// Build a closing transaction #[no_mangle] pub extern "C" fn build_closing_transaction(mut to_holder_value_sat: u64, mut to_counterparty_value_sat: u64, mut to_holder_script: crate::c_types::derived::CVec_u8Z, mut to_counterparty_script: crate::c_types::derived::CVec_u8Z, mut funding_outpoint: crate::lightning::chain::transaction::OutPoint) -> crate::c_types::Transaction { - let mut ret = lightning::ln::chan_utils::build_closing_transaction(to_holder_value_sat, to_counterparty_value_sat, ::bitcoin::blockdata::script::ScriptBuf::from(to_holder_script.into_rust()), ::bitcoin::blockdata::script::ScriptBuf::from(to_counterparty_script.into_rust()), crate::c_types::C_to_bitcoin_outpoint(funding_outpoint)); + let mut ret = lightning::ln::chan_utils::build_closing_transaction(::bitcoin::amount::Amount::from_sat(to_holder_value_sat), ::bitcoin::amount::Amount::from_sat(to_counterparty_value_sat), ::bitcoin::script::ScriptBuf::from(to_holder_script.into_rust()), ::bitcoin::script::ScriptBuf::from(to_counterparty_script.into_rust()), crate::c_types::C_to_bitcoin_outpoint(funding_outpoint)); crate::c_types::Transaction::from_bitcoin(&ret) } @@ -214,6 +214,12 @@ pub struct CounterpartyCommitmentSecrets { pub is_owned: bool, } +impl core::ops::Deref for CounterpartyCommitmentSecrets { + type Target = nativeCounterpartyCommitmentSecrets; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for CounterpartyCommitmentSecrets { } +unsafe impl core::marker::Sync for CounterpartyCommitmentSecrets { } impl Drop for CounterpartyCommitmentSecrets { fn drop(&mut self) { if self.is_owned && !<*mut nativeCounterpartyCommitmentSecrets>::is_null(self.inner) { @@ -244,6 +250,9 @@ impl CounterpartyCommitmentSecrets { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } impl Clone for CounterpartyCommitmentSecrets { fn clone(&self) -> Self { @@ -310,7 +319,7 @@ pub extern "C" fn CounterpartyCommitmentSecrets_write(obj: &crate::lightning::ln } #[allow(unused)] pub(crate) extern "C" fn CounterpartyCommitmentSecrets_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeCounterpartyCommitmentSecrets) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::chan_utils::nativeCounterpartyCommitmentSecrets) }) } #[no_mangle] /// Read a CounterpartyCommitmentSecrets from a byte array, created by CounterpartyCommitmentSecrets_write @@ -369,6 +378,12 @@ pub struct TxCreationKeys { pub is_owned: bool, } +impl core::ops::Deref for TxCreationKeys { + type Target = nativeTxCreationKeys; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for TxCreationKeys { } +unsafe impl core::marker::Sync for TxCreationKeys { } impl Drop for TxCreationKeys { fn drop(&mut self) { if self.is_owned && !<*mut nativeTxCreationKeys>::is_null(self.inner) { @@ -399,6 +414,9 @@ impl TxCreationKeys { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The broadcaster's per-commitment public key which was used to derive the other keys. #[no_mangle] @@ -509,7 +527,7 @@ pub extern "C" fn TxCreationKeys_write(obj: &crate::lightning::ln::chan_utils::T } #[allow(unused)] pub(crate) extern "C" fn TxCreationKeys_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxCreationKeys) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::chan_utils::nativeTxCreationKeys) }) } #[no_mangle] /// Read a TxCreationKeys from a byte array, created by TxCreationKeys_write @@ -538,6 +556,12 @@ pub struct ChannelPublicKeys { pub is_owned: bool, } +impl core::ops::Deref for ChannelPublicKeys { + type Target = nativeChannelPublicKeys; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ChannelPublicKeys { } +unsafe impl core::marker::Sync for ChannelPublicKeys { } impl Drop for ChannelPublicKeys { fn drop(&mut self) { if self.is_owned && !<*mut nativeChannelPublicKeys>::is_null(self.inner) { @@ -568,6 +592,9 @@ impl ChannelPublicKeys { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// 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. @@ -582,7 +609,7 @@ pub extern "C" fn ChannelPublicKeys_get_funding_pubkey(this_ptr: &ChannelPublicK pub extern "C" fn ChannelPublicKeys_set_funding_pubkey(this_ptr: &mut ChannelPublicKeys, mut val: crate::c_types::PublicKey) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust(); } -/// The base point which is used (with derive_public_revocation_key) to derive per-commitment +/// The base point which is used (with [`RevocationKey::from_basepoint`]) 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. @@ -591,7 +618,7 @@ pub extern "C" fn ChannelPublicKeys_get_revocation_basepoint(this_ptr: &ChannelP let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint; crate::lightning::ln::channel_keys::RevocationBasepoint { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::channel_keys::RevocationBasepoint<>) as *mut _) }, is_owned: false } } -/// The base point which is used (with derive_public_revocation_key) to derive per-commitment +/// The base point which is used (with [`RevocationKey::from_basepoint`]) 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. @@ -702,7 +729,7 @@ pub extern "C" fn ChannelPublicKeys_write(obj: &crate::lightning::ln::chan_utils } #[allow(unused)] pub(crate) extern "C" fn ChannelPublicKeys_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelPublicKeys) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::chan_utils::nativeChannelPublicKeys) }) } #[no_mangle] /// Read a ChannelPublicKeys from a byte array, created by ChannelPublicKeys_write @@ -745,7 +772,7 @@ pub extern "C" fn get_revokeable_redeemscript(revocation_key: &crate::lightning: /// Returns the script for the counterparty's output on a holder's commitment transaction based on /// the channel type. #[no_mangle] -pub extern "C" fn get_counterparty_payment_script(channel_type_features: &crate::lightning::ln::features::ChannelTypeFeatures, mut payment_key: crate::c_types::PublicKey) -> crate::c_types::derived::CVec_u8Z { +pub extern "C" fn get_counterparty_payment_script(channel_type_features: &crate::lightning_types::features::ChannelTypeFeatures, mut payment_key: crate::c_types::PublicKey) -> crate::c_types::derived::CVec_u8Z { let mut ret = lightning::ln::chan_utils::get_counterparty_payment_script(channel_type_features.get_native_ref(), &payment_key.into_rust()); ret.to_bytes().into() } @@ -770,6 +797,12 @@ pub struct HTLCOutputInCommitment { pub is_owned: bool, } +impl core::ops::Deref for HTLCOutputInCommitment { + type Target = nativeHTLCOutputInCommitment; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for HTLCOutputInCommitment { } +unsafe impl core::marker::Sync for HTLCOutputInCommitment { } impl Drop for HTLCOutputInCommitment { fn drop(&mut self) { if self.is_owned && !<*mut nativeHTLCOutputInCommitment>::is_null(self.inner) { @@ -800,6 +833,9 @@ impl HTLCOutputInCommitment { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// 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 @@ -914,6 +950,16 @@ pub extern "C" fn HTLCOutputInCommitment_eq(a: &HTLCOutputInCommitment, b: &HTLC if a.inner.is_null() || b.inner.is_null() { return false; } if a.get_native_ref() == b.get_native_ref() { true } else { false } } +/// Converts HTLC's value with millisatoshi precision into [bitcoin::Amount] with satoshi precision. +/// Typically this conversion is needed when transitioning from LN into base-layer Bitcoin, +/// e. g. in commitment transactions. +#[must_use] +#[no_mangle] +pub extern "C" fn HTLCOutputInCommitment_to_bitcoin_amount(this_arg: &crate::lightning::ln::chan_utils::HTLCOutputInCommitment) -> u64 { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.to_bitcoin_amount(); + ret.to_sat() +} + #[no_mangle] /// Serialize the HTLCOutputInCommitment object into a byte array which can be read by HTLCOutputInCommitment_read pub extern "C" fn HTLCOutputInCommitment_write(obj: &crate::lightning::ln::chan_utils::HTLCOutputInCommitment) -> crate::c_types::derived::CVec_u8Z { @@ -921,7 +967,7 @@ pub extern "C" fn HTLCOutputInCommitment_write(obj: &crate::lightning::ln::chan_ } #[allow(unused)] pub(crate) extern "C" fn HTLCOutputInCommitment_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeHTLCOutputInCommitment) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::chan_utils::nativeHTLCOutputInCommitment) }) } #[no_mangle] /// Read a HTLCOutputInCommitment from a byte array, created by HTLCOutputInCommitment_write @@ -933,7 +979,7 @@ 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, channel_type_features: &crate::lightning::ln::features::ChannelTypeFeatures, keys: &crate::lightning::ln::chan_utils::TxCreationKeys) -> crate::c_types::derived::CVec_u8Z { +pub extern "C" fn get_htlc_redeemscript(htlc: &crate::lightning::ln::chan_utils::HTLCOutputInCommitment, channel_type_features: &crate::lightning_types::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.to_bytes().into() } @@ -954,16 +1000,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, channel_type_features: &crate::lightning::ln::features::ChannelTypeFeatures, broadcaster_delayed_payment_key: &crate::lightning::ln::channel_keys::DelayedPaymentKey, revocation_key: &crate::lightning::ln::channel_keys::RevocationKey) -> crate::c_types::Transaction { +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_types::features::ChannelTypeFeatures, broadcaster_delayed_payment_key: &crate::lightning::ln::channel_keys::DelayedPaymentKey, revocation_key: &crate::lightning::ln::channel_keys::RevocationKey) -> 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.get_native_ref(), revocation_key.get_native_ref()); crate::c_types::Transaction::from_bitcoin(&ret) } /// Returns the witness required to satisfy and spend a HTLC input. #[no_mangle] -pub extern "C" fn build_htlc_input_witness(mut local_sig: crate::c_types::ECDSASignature, mut remote_sig: crate::c_types::ECDSASignature, mut preimage: crate::c_types::derived::COption_ThirtyTwoBytesZ, mut redeem_script: crate::c_types::u8slice, channel_type_features: &crate::lightning::ln::features::ChannelTypeFeatures) -> crate::c_types::Witness { +pub extern "C" fn build_htlc_input_witness(mut local_sig: crate::c_types::ECDSASignature, mut remote_sig: crate::c_types::ECDSASignature, mut preimage: crate::c_types::derived::COption_ThirtyTwoBytesZ, mut redeem_script: crate::c_types::u8slice, channel_type_features: &crate::lightning_types::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::types::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_bytes(redeem_script.to_slice()), channel_type_features.get_native_ref()); + let mut ret = lightning::ln::chan_utils::build_htlc_input_witness(&local_sig.into_rust(), &remote_sig.into_rust(), &local_preimage, ::bitcoin::script::Script::from_bytes(redeem_script.to_slice()), channel_type_features.get_native_ref()); crate::c_types::Witness::from_bitcoin(&ret) } @@ -1017,6 +1063,12 @@ pub struct ChannelTransactionParameters { pub is_owned: bool, } +impl core::ops::Deref for ChannelTransactionParameters { + type Target = nativeChannelTransactionParameters; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ChannelTransactionParameters { } +unsafe impl core::marker::Sync for ChannelTransactionParameters { } impl Drop for ChannelTransactionParameters { fn drop(&mut self) { if self.is_owned && !<*mut nativeChannelTransactionParameters>::is_null(self.inner) { @@ -1047,6 +1099,9 @@ impl ChannelTransactionParameters { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Holder public keys #[no_mangle] @@ -1122,14 +1177,14 @@ pub extern "C" fn ChannelTransactionParameters_set_funding_outpoint(this_ptr: &m /// 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_channel_type_features(this_ptr: &ChannelTransactionParameters) -> crate::lightning::ln::features::ChannelTypeFeatures { +pub extern "C" fn ChannelTransactionParameters_get_channel_type_features(this_ptr: &ChannelTransactionParameters) -> crate::lightning_types::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 } + crate::lightning_types::features::ChannelTypeFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning_types::features::ChannelTypeFeatures<>) as *mut _) }, is_owned: false } } /// 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_channel_type_features(this_ptr: &mut ChannelTransactionParameters, mut val: crate::lightning::ln::features::ChannelTypeFeatures) { +pub extern "C" fn ChannelTransactionParameters_set_channel_type_features(this_ptr: &mut ChannelTransactionParameters, mut val: crate::lightning_types::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 @@ -1138,7 +1193,7 @@ pub extern "C" fn ChannelTransactionParameters_set_channel_type_features(this_pt /// Note that funding_outpoint_arg (or a relevant inner pointer) may be NULL or all-0s to represent None #[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 channel_type_features_arg: crate::lightning::ln::features::ChannelTypeFeatures) -> 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_types::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()) } }) }; ChannelTransactionParameters { inner: ObjOps::heap_alloc(nativeChannelTransactionParameters { @@ -1211,6 +1266,12 @@ pub struct CounterpartyChannelTransactionParameters { pub is_owned: bool, } +impl core::ops::Deref for CounterpartyChannelTransactionParameters { + type Target = nativeCounterpartyChannelTransactionParameters; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for CounterpartyChannelTransactionParameters { } +unsafe impl core::marker::Sync for CounterpartyChannelTransactionParameters { } impl Drop for CounterpartyChannelTransactionParameters { fn drop(&mut self) { if self.is_owned && !<*mut nativeCounterpartyChannelTransactionParameters>::is_null(self.inner) { @@ -1241,6 +1302,9 @@ impl CounterpartyChannelTransactionParameters { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Counter-party public keys #[no_mangle] @@ -1351,7 +1415,7 @@ pub extern "C" fn CounterpartyChannelTransactionParameters_write(obj: &crate::li } #[allow(unused)] pub(crate) extern "C" fn CounterpartyChannelTransactionParameters_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeCounterpartyChannelTransactionParameters) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::chan_utils::nativeCounterpartyChannelTransactionParameters) }) } #[no_mangle] /// Read a CounterpartyChannelTransactionParameters from a byte array, created by CounterpartyChannelTransactionParameters_write @@ -1367,7 +1431,7 @@ pub extern "C" fn ChannelTransactionParameters_write(obj: &crate::lightning::ln: } #[allow(unused)] pub(crate) extern "C" fn ChannelTransactionParameters_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelTransactionParameters) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::chan_utils::nativeChannelTransactionParameters) }) } #[no_mangle] /// Read a ChannelTransactionParameters from a byte array, created by ChannelTransactionParameters_write @@ -1400,6 +1464,12 @@ pub struct DirectedChannelTransactionParameters { pub is_owned: bool, } +impl core::ops::Deref for DirectedChannelTransactionParameters { + type Target = nativeDirectedChannelTransactionParameters; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for DirectedChannelTransactionParameters { } +unsafe impl core::marker::Sync for DirectedChannelTransactionParameters { } impl Drop for DirectedChannelTransactionParameters { fn drop(&mut self) { if self.is_owned && !<*mut nativeDirectedChannelTransactionParameters>::is_null(self.inner) { @@ -1430,6 +1500,9 @@ impl DirectedChannelTransactionParameters { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Get the channel pubkeys for the broadcaster #[must_use] @@ -1478,9 +1551,9 @@ pub extern "C" fn DirectedChannelTransactionParameters_funding_outpoint(this_arg /// Whether to use anchors for this channel #[must_use] #[no_mangle] -pub extern "C" fn DirectedChannelTransactionParameters_channel_type_features(this_arg: &crate::lightning::ln::chan_utils::DirectedChannelTransactionParameters) -> crate::lightning::ln::features::ChannelTypeFeatures { +pub extern "C" fn DirectedChannelTransactionParameters_channel_type_features(this_arg: &crate::lightning::ln::chan_utils::DirectedChannelTransactionParameters) -> crate::lightning_types::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 } + crate::lightning_types::features::ChannelTypeFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning_types::features::ChannelTypeFeatures<>) as *mut _) }, is_owned: false } } @@ -1505,6 +1578,12 @@ pub struct HolderCommitmentTransaction { pub is_owned: bool, } +impl core::ops::Deref for HolderCommitmentTransaction { + type Target = nativeHolderCommitmentTransaction; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for HolderCommitmentTransaction { } +unsafe impl core::marker::Sync for HolderCommitmentTransaction { } impl Drop for HolderCommitmentTransaction { fn drop(&mut self) { if self.is_owned && !<*mut nativeHolderCommitmentTransaction>::is_null(self.inner) { @@ -1535,6 +1614,9 @@ impl HolderCommitmentTransaction { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Our counterparty's signature for the transaction #[no_mangle] @@ -1591,7 +1673,7 @@ pub extern "C" fn HolderCommitmentTransaction_write(obj: &crate::lightning::ln:: } #[allow(unused)] pub(crate) extern "C" fn HolderCommitmentTransaction_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeHolderCommitmentTransaction) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::chan_utils::nativeHolderCommitmentTransaction) }) } #[no_mangle] /// Read a HolderCommitmentTransaction from a byte array, created by HolderCommitmentTransaction_write @@ -1630,6 +1712,12 @@ pub struct BuiltCommitmentTransaction { pub is_owned: bool, } +impl core::ops::Deref for BuiltCommitmentTransaction { + type Target = nativeBuiltCommitmentTransaction; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for BuiltCommitmentTransaction { } +unsafe impl core::marker::Sync for BuiltCommitmentTransaction { } impl Drop for BuiltCommitmentTransaction { fn drop(&mut self) { if self.is_owned && !<*mut nativeBuiltCommitmentTransaction>::is_null(self.inner) { @@ -1660,6 +1748,9 @@ impl BuiltCommitmentTransaction { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The commitment transaction #[no_mangle] @@ -1727,7 +1818,7 @@ pub extern "C" fn BuiltCommitmentTransaction_write(obj: &crate::lightning::ln::c } #[allow(unused)] pub(crate) extern "C" fn BuiltCommitmentTransaction_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeBuiltCommitmentTransaction) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::chan_utils::nativeBuiltCommitmentTransaction) }) } #[no_mangle] /// Read a BuiltCommitmentTransaction from a byte array, created by BuiltCommitmentTransaction_write @@ -1742,7 +1833,7 @@ pub extern "C" fn BuiltCommitmentTransaction_read(ser: crate::c_types::u8slice) #[must_use] #[no_mangle] pub extern "C" fn BuiltCommitmentTransaction_get_sighash_all(this_arg: &crate::lightning::ln::chan_utils::BuiltCommitmentTransaction, mut funding_redeemscript: crate::c_types::u8slice, mut channel_value_satoshis: u64) -> crate::c_types::ThirtyTwoBytes { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_sighash_all(::bitcoin::blockdata::script::Script::from_bytes(funding_redeemscript.to_slice()), channel_value_satoshis); + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_sighash_all(::bitcoin::script::Script::from_bytes(funding_redeemscript.to_slice()), channel_value_satoshis); crate::c_types::ThirtyTwoBytes { data: ret.as_ref().clone() } } @@ -1750,7 +1841,7 @@ pub extern "C" fn BuiltCommitmentTransaction_get_sighash_all(this_arg: &crate::l #[must_use] #[no_mangle] pub extern "C" fn BuiltCommitmentTransaction_sign_counterparty_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) -> crate::c_types::ECDSASignature { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.sign_counterparty_commitment(&::bitcoin::secp256k1::SecretKey::from_slice(&unsafe { *funding_key}[..]).unwrap(), ::bitcoin::blockdata::script::Script::from_bytes(funding_redeemscript.to_slice()), channel_value_satoshis, secp256k1::global::SECP256K1); + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.sign_counterparty_commitment(&::bitcoin::secp256k1::SecretKey::from_slice(&unsafe { *funding_key}[..]).unwrap(), ::bitcoin::script::Script::from_bytes(funding_redeemscript.to_slice()), channel_value_satoshis, secp256k1::global::SECP256K1); crate::c_types::ECDSASignature::from_rust(&ret) } @@ -1758,7 +1849,7 @@ pub extern "C" fn BuiltCommitmentTransaction_sign_counterparty_commitment(this_a #[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::sign::EntropySource) -> crate::c_types::ECDSASignature { - 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_bytes(funding_redeemscript.to_slice()), channel_value_satoshis, entropy_source, secp256k1::global::SECP256K1); + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.sign_holder_commitment(&::bitcoin::secp256k1::SecretKey::from_slice(&unsafe { *funding_key}[..]).unwrap(), ::bitcoin::script::Script::from_bytes(funding_redeemscript.to_slice()), channel_value_satoshis, entropy_source, secp256k1::global::SECP256K1); crate::c_types::ECDSASignature::from_rust(&ret) } @@ -1786,6 +1877,12 @@ pub struct ClosingTransaction { pub is_owned: bool, } +impl core::ops::Deref for ClosingTransaction { + type Target = nativeClosingTransaction; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ClosingTransaction { } +unsafe impl core::marker::Sync for ClosingTransaction { } impl Drop for ClosingTransaction { fn drop(&mut self) { if self.is_owned && !<*mut nativeClosingTransaction>::is_null(self.inner) { @@ -1816,6 +1913,9 @@ impl ClosingTransaction { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } impl Clone for ClosingTransaction { fn clone(&self) -> Self { @@ -1859,7 +1959,7 @@ pub extern "C" fn ClosingTransaction_eq(a: &ClosingTransaction, b: &ClosingTrans #[must_use] #[no_mangle] pub extern "C" fn ClosingTransaction_new(mut to_holder_value_sat: u64, mut to_counterparty_value_sat: u64, mut to_holder_script: crate::c_types::derived::CVec_u8Z, mut to_counterparty_script: crate::c_types::derived::CVec_u8Z, mut funding_outpoint: crate::lightning::chain::transaction::OutPoint) -> crate::lightning::ln::chan_utils::ClosingTransaction { - let mut ret = lightning::ln::chan_utils::ClosingTransaction::new(to_holder_value_sat, to_counterparty_value_sat, ::bitcoin::blockdata::script::ScriptBuf::from(to_holder_script.into_rust()), ::bitcoin::blockdata::script::ScriptBuf::from(to_counterparty_script.into_rust()), crate::c_types::C_to_bitcoin_outpoint(funding_outpoint)); + let mut ret = lightning::ln::chan_utils::ClosingTransaction::new(to_holder_value_sat, to_counterparty_value_sat, ::bitcoin::script::ScriptBuf::from(to_holder_script.into_rust()), ::bitcoin::script::ScriptBuf::from(to_counterparty_script.into_rust()), crate::c_types::C_to_bitcoin_outpoint(funding_outpoint)); crate::lightning::ln::chan_utils::ClosingTransaction { inner: ObjOps::heap_alloc(ret), is_owned: true } } @@ -1947,6 +2047,12 @@ pub struct TrustedClosingTransaction { pub is_owned: bool, } +impl core::ops::Deref for TrustedClosingTransaction { + type Target = nativeTrustedClosingTransaction; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for TrustedClosingTransaction { } +unsafe impl core::marker::Sync for TrustedClosingTransaction { } impl Drop for TrustedClosingTransaction { fn drop(&mut self) { if self.is_owned && !<*mut nativeTrustedClosingTransaction>::is_null(self.inner) { @@ -1977,6 +2083,9 @@ impl TrustedClosingTransaction { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The pre-built Bitcoin commitment transaction #[must_use] @@ -1992,7 +2101,7 @@ pub extern "C" fn TrustedClosingTransaction_built_transaction(this_arg: &crate:: #[must_use] #[no_mangle] pub extern "C" fn TrustedClosingTransaction_get_sighash_all(this_arg: &crate::lightning::ln::chan_utils::TrustedClosingTransaction, mut funding_redeemscript: crate::c_types::u8slice, mut channel_value_satoshis: u64) -> crate::c_types::ThirtyTwoBytes { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_sighash_all(::bitcoin::blockdata::script::Script::from_bytes(funding_redeemscript.to_slice()), channel_value_satoshis); + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_sighash_all(::bitcoin::script::Script::from_bytes(funding_redeemscript.to_slice()), channel_value_satoshis); crate::c_types::ThirtyTwoBytes { data: ret.as_ref().clone() } } @@ -2001,7 +2110,7 @@ pub extern "C" fn TrustedClosingTransaction_get_sighash_all(this_arg: &crate::li #[must_use] #[no_mangle] pub extern "C" fn TrustedClosingTransaction_sign(this_arg: &crate::lightning::ln::chan_utils::TrustedClosingTransaction, funding_key: *const [u8; 32], mut funding_redeemscript: crate::c_types::u8slice, mut channel_value_satoshis: u64) -> crate::c_types::ECDSASignature { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.sign(&::bitcoin::secp256k1::SecretKey::from_slice(&unsafe { *funding_key}[..]).unwrap(), ::bitcoin::blockdata::script::Script::from_bytes(funding_redeemscript.to_slice()), channel_value_satoshis, secp256k1::global::SECP256K1); + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.sign(&::bitcoin::secp256k1::SecretKey::from_slice(&unsafe { *funding_key}[..]).unwrap(), ::bitcoin::script::Script::from_bytes(funding_redeemscript.to_slice()), channel_value_satoshis, secp256k1::global::SECP256K1); crate::c_types::ECDSASignature::from_rust(&ret) } @@ -2030,6 +2139,12 @@ pub struct CommitmentTransaction { pub is_owned: bool, } +impl core::ops::Deref for CommitmentTransaction { + type Target = nativeCommitmentTransaction; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for CommitmentTransaction { } +unsafe impl core::marker::Sync for CommitmentTransaction { } impl Drop for CommitmentTransaction { fn drop(&mut self) { if self.is_owned && !<*mut nativeCommitmentTransaction>::is_null(self.inner) { @@ -2060,6 +2175,9 @@ impl CommitmentTransaction { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } impl Clone for CommitmentTransaction { fn clone(&self) -> Self { @@ -2090,7 +2208,7 @@ pub extern "C" fn CommitmentTransaction_write(obj: &crate::lightning::ln::chan_u } #[allow(unused)] pub(crate) extern "C" fn CommitmentTransaction_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeCommitmentTransaction) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::chan_utils::nativeCommitmentTransaction) }) } #[no_mangle] /// Read a CommitmentTransaction from a byte array, created by CommitmentTransaction_write @@ -2191,6 +2309,12 @@ pub struct TrustedCommitmentTransaction { pub is_owned: bool, } +impl core::ops::Deref for TrustedCommitmentTransaction { + type Target = nativeTrustedCommitmentTransaction; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for TrustedCommitmentTransaction { } +unsafe impl core::marker::Sync for TrustedCommitmentTransaction { } impl Drop for TrustedCommitmentTransaction { fn drop(&mut self) { if self.is_owned && !<*mut nativeTrustedCommitmentTransaction>::is_null(self.inner) { @@ -2221,6 +2345,9 @@ impl TrustedCommitmentTransaction { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The transaction ID of the built Bitcoin transaction #[must_use] @@ -2249,9 +2376,9 @@ pub extern "C" fn TrustedCommitmentTransaction_keys(this_arg: &crate::lightning: /// Should anchors be used. #[must_use] #[no_mangle] -pub extern "C" fn TrustedCommitmentTransaction_channel_type_features(this_arg: &crate::lightning::ln::chan_utils::TrustedCommitmentTransaction) -> crate::lightning::ln::features::ChannelTypeFeatures { +pub extern "C" fn TrustedCommitmentTransaction_channel_type_features(this_arg: &crate::lightning::ln::chan_utils::TrustedCommitmentTransaction) -> crate::lightning_types::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 } + crate::lightning_types::features::ChannelTypeFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning_types::features::ChannelTypeFeatures<>) as *mut _) }, is_owned: false } } /// Get a signature for each HTLC which was included in the commitment transaction (ie for @@ -2299,7 +2426,7 @@ pub extern "C" fn TrustedCommitmentTransaction_revokeable_output_index(this_arg: #[must_use] #[no_mangle] pub extern "C" fn TrustedCommitmentTransaction_build_to_local_justice_tx(this_arg: &crate::lightning::ln::chan_utils::TrustedCommitmentTransaction, mut feerate_per_kw: u64, mut destination_script: crate::c_types::derived::CVec_u8Z) -> crate::c_types::derived::CResult_TransactionNoneZ { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.build_to_local_justice_tx(feerate_per_kw, ::bitcoin::blockdata::script::ScriptBuf::from(destination_script.into_rust())); + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.build_to_local_justice_tx(feerate_per_kw, ::bitcoin::script::ScriptBuf::from(destination_script.into_rust())); 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 } diff --git a/lightning-c-bindings/src/lightning/ln/channel_keys.rs b/lightning-c-bindings/src/lightning/ln/channel_keys.rs index adccac1..a713ef0 100644 --- a/lightning-c-bindings/src/lightning/ln/channel_keys.rs +++ b/lightning-c-bindings/src/lightning/ln/channel_keys.rs @@ -42,6 +42,12 @@ pub struct DelayedPaymentBasepoint { pub is_owned: bool, } +impl core::ops::Deref for DelayedPaymentBasepoint { + type Target = nativeDelayedPaymentBasepoint; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for DelayedPaymentBasepoint { } +unsafe impl core::marker::Sync for DelayedPaymentBasepoint { } impl Drop for DelayedPaymentBasepoint { fn drop(&mut self) { if self.is_owned && !<*mut nativeDelayedPaymentBasepoint>::is_null(self.inner) { @@ -72,6 +78,9 @@ impl DelayedPaymentBasepoint { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } #[no_mangle] pub extern "C" fn DelayedPaymentBasepoint_get_a(this_ptr: &DelayedPaymentBasepoint) -> crate::c_types::PublicKey { @@ -154,7 +163,7 @@ pub extern "C" fn DelayedPaymentBasepoint_write(obj: &crate::lightning::ln::chan } #[allow(unused)] pub(crate) extern "C" fn DelayedPaymentBasepoint_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeDelayedPaymentBasepoint) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::channel_keys::nativeDelayedPaymentBasepoint) }) } #[no_mangle] /// Read a DelayedPaymentBasepoint from a byte array, created by DelayedPaymentBasepoint_write @@ -174,7 +183,7 @@ pub(crate) type nativeDelayedPaymentKey = nativeDelayedPaymentKeyImport; /// punish and claim all the channel funds if the state broadcasted was previously revoked. /// /// [See the BOLT specs] -/// (https://github.com/lightning/bolts/blob/master/03-transactions.md#localpubkey-local_htlcpubkey-remote_htlcpubkey-local_delayedpubkey-and-remote_delayedpubkey-derivation) +/// /// for more information on key derivation details. #[must_use] #[repr(C)] @@ -191,6 +200,12 @@ pub struct DelayedPaymentKey { pub is_owned: bool, } +impl core::ops::Deref for DelayedPaymentKey { + type Target = nativeDelayedPaymentKey; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for DelayedPaymentKey { } +unsafe impl core::marker::Sync for DelayedPaymentKey { } impl Drop for DelayedPaymentKey { fn drop(&mut self) { if self.is_owned && !<*mut nativeDelayedPaymentKey>::is_null(self.inner) { @@ -221,6 +236,9 @@ impl DelayedPaymentKey { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } #[no_mangle] pub extern "C" fn DelayedPaymentKey_get_a(this_ptr: &DelayedPaymentKey) -> crate::c_types::PublicKey { @@ -301,7 +319,7 @@ pub extern "C" fn DelayedPaymentKey_write(obj: &crate::lightning::ln::channel_ke } #[allow(unused)] pub(crate) extern "C" fn DelayedPaymentKey_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeDelayedPaymentKey) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::channel_keys::nativeDelayedPaymentKey) }) } #[no_mangle] /// Read a DelayedPaymentKey from a byte array, created by DelayedPaymentKey_write @@ -334,6 +352,12 @@ pub struct HtlcBasepoint { pub is_owned: bool, } +impl core::ops::Deref for HtlcBasepoint { + type Target = nativeHtlcBasepoint; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for HtlcBasepoint { } +unsafe impl core::marker::Sync for HtlcBasepoint { } impl Drop for HtlcBasepoint { fn drop(&mut self) { if self.is_owned && !<*mut nativeHtlcBasepoint>::is_null(self.inner) { @@ -364,6 +388,9 @@ impl HtlcBasepoint { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } #[no_mangle] pub extern "C" fn HtlcBasepoint_get_a(this_ptr: &HtlcBasepoint) -> crate::c_types::PublicKey { @@ -446,7 +473,7 @@ pub extern "C" fn HtlcBasepoint_write(obj: &crate::lightning::ln::channel_keys:: } #[allow(unused)] pub(crate) extern "C" fn HtlcBasepoint_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeHtlcBasepoint) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::channel_keys::nativeHtlcBasepoint) }) } #[no_mangle] /// Read a HtlcBasepoint from a byte array, created by HtlcBasepoint_write @@ -466,7 +493,7 @@ pub(crate) type nativeHtlcKey = nativeHtlcKeyImport; /// Thus, both channel counterparties' HTLC keys will appears in each HTLC output's script. /// /// [See the BOLT specs] -/// (https://github.com/lightning/bolts/blob/master/03-transactions.md#localpubkey-local_htlcpubkey-remote_htlcpubkey-local_delayedpubkey-and-remote_delayedpubkey-derivation) +/// /// for more information on key derivation details. #[must_use] #[repr(C)] @@ -483,6 +510,12 @@ pub struct HtlcKey { pub is_owned: bool, } +impl core::ops::Deref for HtlcKey { + type Target = nativeHtlcKey; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for HtlcKey { } +unsafe impl core::marker::Sync for HtlcKey { } impl Drop for HtlcKey { fn drop(&mut self) { if self.is_owned && !<*mut nativeHtlcKey>::is_null(self.inner) { @@ -513,6 +546,9 @@ impl HtlcKey { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } #[no_mangle] pub extern "C" fn HtlcKey_get_a(this_ptr: &HtlcKey) -> crate::c_types::PublicKey { @@ -593,7 +629,7 @@ pub extern "C" fn HtlcKey_write(obj: &crate::lightning::ln::channel_keys::HtlcKe } #[allow(unused)] pub(crate) extern "C" fn HtlcKey_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeHtlcKey) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::channel_keys::nativeHtlcKey) }) } #[no_mangle] /// Read a HtlcKey from a byte array, created by HtlcKey_write @@ -632,6 +668,12 @@ pub struct RevocationBasepoint { pub is_owned: bool, } +impl core::ops::Deref for RevocationBasepoint { + type Target = nativeRevocationBasepoint; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for RevocationBasepoint { } +unsafe impl core::marker::Sync for RevocationBasepoint { } impl Drop for RevocationBasepoint { fn drop(&mut self) { if self.is_owned && !<*mut nativeRevocationBasepoint>::is_null(self.inner) { @@ -662,6 +704,9 @@ impl RevocationBasepoint { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } #[no_mangle] pub extern "C" fn RevocationBasepoint_get_a(this_ptr: &RevocationBasepoint) -> crate::c_types::PublicKey { @@ -736,7 +781,7 @@ pub extern "C" fn RevocationBasepoint_write(obj: &crate::lightning::ln::channel_ } #[allow(unused)] pub(crate) extern "C" fn RevocationBasepoint_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRevocationBasepoint) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::channel_keys::nativeRevocationBasepoint) }) } #[no_mangle] /// Read a RevocationBasepoint from a byte array, created by RevocationBasepoint_write @@ -756,7 +801,7 @@ pub(crate) type nativeRevocationKey = nativeRevocationKeyImport; /// per_commitment_point which is used in both commitment and HTLC transactions. /// /// See [the BOLT spec for derivation details] -/// (https://github.com/lightning/bolts/blob/master/03-transactions.md#revocationpubkey-derivation) +/// #[must_use] #[repr(C)] pub struct RevocationKey { @@ -772,6 +817,12 @@ pub struct RevocationKey { pub is_owned: bool, } +impl core::ops::Deref for RevocationKey { + type Target = nativeRevocationKey; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for RevocationKey { } +unsafe impl core::marker::Sync for RevocationKey { } impl Drop for RevocationKey { fn drop(&mut self) { if self.is_owned && !<*mut nativeRevocationKey>::is_null(self.inner) { @@ -802,6 +853,9 @@ impl RevocationKey { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } #[no_mangle] pub extern "C" fn RevocationKey_get_a(this_ptr: &RevocationKey) -> crate::c_types::PublicKey { @@ -892,7 +946,7 @@ pub extern "C" fn RevocationKey_write(obj: &crate::lightning::ln::channel_keys:: } #[allow(unused)] pub(crate) extern "C" fn RevocationKey_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRevocationKey) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::channel_keys::nativeRevocationKey) }) } #[no_mangle] /// Read a RevocationKey from a byte array, created by RevocationKey_write diff --git a/lightning-c-bindings/src/lightning/ln/channel_state.rs b/lightning-c-bindings/src/lightning/ln/channel_state.rs index 4ebd697..e9dee8a 100644 --- a/lightning-c-bindings/src/lightning/ln/channel_state.rs +++ b/lightning-c-bindings/src/lightning/ln/channel_state.rs @@ -169,6 +169,12 @@ pub struct InboundHTLCDetails { pub is_owned: bool, } +impl core::ops::Deref for InboundHTLCDetails { + type Target = nativeInboundHTLCDetails; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for InboundHTLCDetails { } +unsafe impl core::marker::Sync for InboundHTLCDetails { } impl Drop for InboundHTLCDetails { fn drop(&mut self) { if self.is_owned && !<*mut nativeInboundHTLCDetails>::is_null(self.inner) { @@ -199,6 +205,9 @@ impl InboundHTLCDetails { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The HTLC ID. /// The IDs are incremented by 1 starting from 0 for each offered HTLC. @@ -353,7 +362,7 @@ pub extern "C" fn InboundHTLCDetails_write(obj: &crate::lightning::ln::channel_s } #[allow(unused)] pub(crate) extern "C" fn InboundHTLCDetails_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInboundHTLCDetails) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::channel_state::nativeInboundHTLCDetails) }) } #[no_mangle] /// Read a InboundHTLCDetails from a byte array, created by InboundHTLCDetails_write @@ -511,6 +520,12 @@ pub struct OutboundHTLCDetails { pub is_owned: bool, } +impl core::ops::Deref for OutboundHTLCDetails { + type Target = nativeOutboundHTLCDetails; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for OutboundHTLCDetails { } +unsafe impl core::marker::Sync for OutboundHTLCDetails { } impl Drop for OutboundHTLCDetails { fn drop(&mut self) { if self.is_owned && !<*mut nativeOutboundHTLCDetails>::is_null(self.inner) { @@ -541,6 +556,9 @@ impl OutboundHTLCDetails { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The HTLC ID. /// The IDs are incremented by 1 starting from 0 for each offered HTLC. @@ -717,7 +735,7 @@ pub extern "C" fn OutboundHTLCDetails_write(obj: &crate::lightning::ln::channel_ } #[allow(unused)] pub(crate) extern "C" fn OutboundHTLCDetails_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOutboundHTLCDetails) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::channel_state::nativeOutboundHTLCDetails) }) } #[no_mangle] /// Read a OutboundHTLCDetails from a byte array, created by OutboundHTLCDetails_write @@ -746,6 +764,12 @@ pub struct CounterpartyForwardingInfo { pub is_owned: bool, } +impl core::ops::Deref for CounterpartyForwardingInfo { + type Target = nativeCounterpartyForwardingInfo; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for CounterpartyForwardingInfo { } +unsafe impl core::marker::Sync for CounterpartyForwardingInfo { } impl Drop for CounterpartyForwardingInfo { fn drop(&mut self) { if self.is_owned && !<*mut nativeCounterpartyForwardingInfo>::is_null(self.inner) { @@ -776,6 +800,9 @@ impl CounterpartyForwardingInfo { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Base routing fee in millisatoshis. #[no_mangle] @@ -853,7 +880,7 @@ pub extern "C" fn CounterpartyForwardingInfo_write(obj: &crate::lightning::ln::c } #[allow(unused)] pub(crate) extern "C" fn CounterpartyForwardingInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeCounterpartyForwardingInfo) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::channel_state::nativeCounterpartyForwardingInfo) }) } #[no_mangle] /// Read a CounterpartyForwardingInfo from a byte array, created by CounterpartyForwardingInfo_write @@ -883,6 +910,12 @@ pub struct ChannelCounterparty { pub is_owned: bool, } +impl core::ops::Deref for ChannelCounterparty { + type Target = nativeChannelCounterparty; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ChannelCounterparty { } +unsafe impl core::marker::Sync for ChannelCounterparty { } impl Drop for ChannelCounterparty { fn drop(&mut self) { if self.is_owned && !<*mut nativeChannelCounterparty>::is_null(self.inner) { @@ -913,6 +946,9 @@ impl ChannelCounterparty { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The node_id of our counterparty #[no_mangle] @@ -929,15 +965,15 @@ pub extern "C" fn ChannelCounterparty_set_node_id(this_ptr: &mut ChannelCounterp /// 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. #[no_mangle] -pub extern "C" fn ChannelCounterparty_get_features(this_ptr: &ChannelCounterparty) -> crate::lightning::ln::features::InitFeatures { +pub extern "C" fn ChannelCounterparty_get_features(this_ptr: &ChannelCounterparty) -> crate::lightning_types::features::InitFeatures { let mut inner_val = &mut this_ptr.get_native_mut_ref().features; - crate::lightning::ln::features::InitFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::features::InitFeatures<>) as *mut _) }, is_owned: false } + crate::lightning_types::features::InitFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning_types::features::InitFeatures<>) as *mut _) }, is_owned: false } } /// 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. #[no_mangle] -pub extern "C" fn ChannelCounterparty_set_features(this_ptr: &mut ChannelCounterparty, mut val: crate::lightning::ln::features::InitFeatures) { +pub extern "C" fn ChannelCounterparty_set_features(this_ptr: &mut ChannelCounterparty, mut val: crate::lightning_types::features::InitFeatures) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) }; } /// The value, in satoshis, that must always be held in the channel for our counterparty. This @@ -1017,7 +1053,7 @@ pub extern "C" fn ChannelCounterparty_set_outbound_htlc_maximum_msat(this_ptr: & /// Note that forwarding_info_arg (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn ChannelCounterparty_new(mut node_id_arg: crate::c_types::PublicKey, mut features_arg: crate::lightning::ln::features::InitFeatures, mut unspendable_punishment_reserve_arg: u64, mut forwarding_info_arg: crate::lightning::ln::channel_state::CounterpartyForwardingInfo, mut outbound_htlc_minimum_msat_arg: crate::c_types::derived::COption_u64Z, mut outbound_htlc_maximum_msat_arg: crate::c_types::derived::COption_u64Z) -> ChannelCounterparty { +pub extern "C" fn ChannelCounterparty_new(mut node_id_arg: crate::c_types::PublicKey, mut features_arg: crate::lightning_types::features::InitFeatures, mut unspendable_punishment_reserve_arg: u64, mut forwarding_info_arg: crate::lightning::ln::channel_state::CounterpartyForwardingInfo, mut outbound_htlc_minimum_msat_arg: crate::c_types::derived::COption_u64Z, mut outbound_htlc_maximum_msat_arg: crate::c_types::derived::COption_u64Z) -> ChannelCounterparty { let mut local_forwarding_info_arg = if forwarding_info_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(forwarding_info_arg.take_inner()) } }) }; let mut local_outbound_htlc_minimum_msat_arg = if outbound_htlc_minimum_msat_arg.is_some() { Some( { outbound_htlc_minimum_msat_arg.take() }) } else { None }; let mut local_outbound_htlc_maximum_msat_arg = if outbound_htlc_maximum_msat_arg.is_some() { Some( { outbound_htlc_maximum_msat_arg.take() }) } else { None }; @@ -1059,7 +1095,7 @@ pub extern "C" fn ChannelCounterparty_write(obj: &crate::lightning::ln::channel_ } #[allow(unused)] pub(crate) extern "C" fn ChannelCounterparty_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelCounterparty) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::channel_state::nativeChannelCounterparty) }) } #[no_mangle] /// Read a ChannelCounterparty from a byte array, created by ChannelCounterparty_write @@ -1074,8 +1110,14 @@ pub(crate) type nativeChannelDetails = nativeChannelDetailsImport; /// Details of a channel, as returned by [`ChannelManager::list_channels`] and [`ChannelManager::list_usable_channels`] /// +/// Balances of a channel are available through [`ChainMonitor::get_claimable_balances`] and +/// [`ChannelMonitor::get_claimable_balances`], calculated with respect to the corresponding on-chain +/// transactions. +/// /// [`ChannelManager::list_channels`]: crate::ln::channelmanager::ChannelManager::list_channels /// [`ChannelManager::list_usable_channels`]: crate::ln::channelmanager::ChannelManager::list_usable_channels +/// [`ChainMonitor::get_claimable_balances`]: crate::chain::chainmonitor::ChainMonitor::get_claimable_balances +/// [`ChannelMonitor::get_claimable_balances`]: crate::chain::channelmonitor::ChannelMonitor::get_claimable_balances #[must_use] #[repr(C)] pub struct ChannelDetails { @@ -1091,6 +1133,12 @@ pub struct ChannelDetails { pub is_owned: bool, } +impl core::ops::Deref for ChannelDetails { + type Target = nativeChannelDetails; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ChannelDetails { } +unsafe impl core::marker::Sync for ChannelDetails { } impl Drop for ChannelDetails { fn drop(&mut self) { if self.is_owned && !<*mut nativeChannelDetails>::is_null(self.inner) { @@ -1121,6 +1169,9 @@ impl ChannelDetails { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// 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). @@ -1175,9 +1226,9 @@ pub extern "C" fn ChannelDetails_set_funding_txo(this_ptr: &mut ChannelDetails, /// /// 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 ChannelDetails_get_channel_type(this_ptr: &ChannelDetails) -> crate::lightning::ln::features::ChannelTypeFeatures { +pub extern "C" fn ChannelDetails_get_channel_type(this_ptr: &ChannelDetails) -> crate::lightning_types::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 }; + let mut local_inner_val = crate::lightning_types::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_types::features::ChannelTypeFeatures<>) as *mut _ }, is_owned: false }; local_inner_val } /// The features which this channel operates with. See individual features for more info. @@ -1186,7 +1237,7 @@ pub extern "C" fn ChannelDetails_get_channel_type(this_ptr: &ChannelDetails) -> /// /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None #[no_mangle] -pub extern "C" fn ChannelDetails_set_channel_type(this_ptr: &mut ChannelDetails, mut val: crate::lightning::ln::features::ChannelTypeFeatures) { +pub extern "C" fn ChannelDetails_set_channel_type(this_ptr: &mut ChannelDetails, mut val: crate::lightning_types::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; } @@ -1643,14 +1694,14 @@ pub extern "C" fn ChannelDetails_set_is_usable(this_ptr: &mut ChannelDetails, mu } /// True if this channel is (or will be) publicly-announced. #[no_mangle] -pub extern "C" fn ChannelDetails_get_is_public(this_ptr: &ChannelDetails) -> bool { - let mut inner_val = &mut this_ptr.get_native_mut_ref().is_public; +pub extern "C" fn ChannelDetails_get_is_announced(this_ptr: &ChannelDetails) -> bool { + let mut inner_val = &mut this_ptr.get_native_mut_ref().is_announced; *inner_val } /// True if this channel is (or will be) publicly-announced. #[no_mangle] -pub extern "C" fn ChannelDetails_set_is_public(this_ptr: &mut ChannelDetails, mut val: bool) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.is_public = val; +pub extern "C" fn ChannelDetails_set_is_announced(this_ptr: &mut ChannelDetails, mut val: bool) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.is_announced = 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 @@ -1742,7 +1793,7 @@ pub extern "C" fn ChannelDetails_set_pending_outbound_htlcs(this_ptr: &mut Chann /// Note that config_arg (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn ChannelDetails_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut counterparty_arg: crate::lightning::ln::channel_state::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, mut pending_inbound_htlcs_arg: crate::c_types::derived::CVec_InboundHTLCDetailsZ, mut pending_outbound_htlcs_arg: crate::c_types::derived::CVec_OutboundHTLCDetailsZ) -> ChannelDetails { +pub extern "C" fn ChannelDetails_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut counterparty_arg: crate::lightning::ln::channel_state::ChannelCounterparty, mut funding_txo_arg: crate::lightning::chain::transaction::OutPoint, mut channel_type_arg: crate::lightning_types::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_announced_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, mut pending_inbound_htlcs_arg: crate::c_types::derived::CVec_InboundHTLCDetailsZ, mut pending_outbound_htlcs_arg: crate::c_types::derived::CVec_OutboundHTLCDetailsZ) -> 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 }; @@ -1783,7 +1834,7 @@ pub extern "C" fn ChannelDetails_new(mut channel_id_arg: crate::lightning::ln::t 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, + is_announced: is_announced_arg, inbound_htlc_minimum_msat: local_inbound_htlc_minimum_msat_arg, inbound_htlc_maximum_msat: local_inbound_htlc_maximum_msat_arg, config: local_config_arg, @@ -1850,7 +1901,7 @@ pub extern "C" fn ChannelDetails_write(obj: &crate::lightning::ln::channel_state } #[allow(unused)] pub(crate) extern "C" fn ChannelDetails_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelDetails) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::channel_state::nativeChannelDetails) }) } #[no_mangle] /// Read a ChannelDetails from a byte array, created by ChannelDetails_write diff --git a/lightning-c-bindings/src/lightning/ln/channelmanager.rs b/lightning-c-bindings/src/lightning/ln/channelmanager.rs index 1a29d9d..4ee248d 100644 --- a/lightning-c-bindings/src/lightning/ln/channelmanager.rs +++ b/lightning-c-bindings/src/lightning/ln/channelmanager.rs @@ -392,6 +392,12 @@ pub struct BlindedForward { pub is_owned: bool, } +impl core::ops::Deref for BlindedForward { + type Target = nativeBlindedForward; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for BlindedForward { } +unsafe impl core::marker::Sync for BlindedForward { } impl Drop for BlindedForward { fn drop(&mut self) { if self.is_owned && !<*mut nativeBlindedForward>::is_null(self.inner) { @@ -422,6 +428,9 @@ impl BlindedForward { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The `blinding_point` that was set in the inbound [`msgs::UpdateAddHTLC`], or in the inbound /// onion payload if we're the introduction node. Useful for calculating the next hop's @@ -451,13 +460,38 @@ pub extern "C" fn BlindedForward_get_failure(this_ptr: &BlindedForward) -> crate pub extern "C" fn BlindedForward_set_failure(this_ptr: &mut BlindedForward, mut val: crate::lightning::ln::channelmanager::BlindedFailure) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.failure = val.into_native(); } +/// Overrides the next hop's [`msgs::UpdateAddHTLC::blinding_point`]. Set if this HTLC is being +/// forwarded within a [`BlindedPaymentPath`] that was concatenated to another blinded path that +/// starts at the next hop. +/// +/// 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 BlindedForward_get_next_blinding_override(this_ptr: &BlindedForward) -> crate::c_types::PublicKey { + let mut inner_val = &mut this_ptr.get_native_mut_ref().next_blinding_override; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::PublicKey::null() } else { { crate::c_types::PublicKey::from_rust(&(inner_val.unwrap())) } }; + local_inner_val +} +/// Overrides the next hop's [`msgs::UpdateAddHTLC::blinding_point`]. Set if this HTLC is being +/// forwarded within a [`BlindedPaymentPath`] that was concatenated to another blinded path that +/// starts at the next hop. +/// +/// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None +#[no_mangle] +pub extern "C" fn BlindedForward_set_next_blinding_override(this_ptr: &mut BlindedForward, mut val: crate::c_types::PublicKey) { + let mut local_val = if val.is_null() { None } else { Some( { val.into_rust() }) }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_blinding_override = local_val; +} /// Constructs a new BlindedForward given each field +/// +/// Note that next_blinding_override_arg (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn BlindedForward_new(mut inbound_blinding_point_arg: crate::c_types::PublicKey, mut failure_arg: crate::lightning::ln::channelmanager::BlindedFailure) -> BlindedForward { +pub extern "C" fn BlindedForward_new(mut inbound_blinding_point_arg: crate::c_types::PublicKey, mut failure_arg: crate::lightning::ln::channelmanager::BlindedFailure, mut next_blinding_override_arg: crate::c_types::PublicKey) -> BlindedForward { + let mut local_next_blinding_override_arg = if next_blinding_override_arg.is_null() { None } else { Some( { next_blinding_override_arg.into_rust() }) }; BlindedForward { inner: ObjOps::heap_alloc(nativeBlindedForward { inbound_blinding_point: inbound_blinding_point_arg.into_rust(), failure: failure_arg.into_native(), + next_blinding_override: local_next_blinding_override_arg, }), is_owned: true } } impl Clone for BlindedForward { @@ -522,6 +556,12 @@ pub struct PendingHTLCInfo { pub is_owned: bool, } +impl core::ops::Deref for PendingHTLCInfo { + type Target = nativePendingHTLCInfo; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for PendingHTLCInfo { } +unsafe impl core::marker::Sync for PendingHTLCInfo { } impl Drop for PendingHTLCInfo { fn drop(&mut self) { if self.is_owned && !<*mut nativePendingHTLCInfo>::is_null(self.inner) { @@ -552,6 +592,9 @@ impl PendingHTLCInfo { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Further routing details based on whether the HTLC is being forwarded or received. #[no_mangle] @@ -987,7 +1030,7 @@ pub(crate) type nativeChannelManager = nativeChannelManagerImport { -/// assert_eq!(user_channel_id, 42); -/// let funding_transaction = wallet.create_funding_transaction( -/// channel_value_satoshis, output_script -/// ); -/// match channel_manager.funding_transaction_generated( -/// &temporary_channel_id, &counterparty_node_id, funding_transaction -/// ) { -/// Ok(()) => println!(\"Funding channel {}\", temporary_channel_id), -/// Err(e) => println!(\"Error funding channel {}: {:?}\", temporary_channel_id, e), -/// } -/// }, -/// Event::ChannelPending { channel_id, user_channel_id, former_temporary_channel_id, .. } => { -/// assert_eq!(user_channel_id, 42); -/// println!( -/// \"Channel {} now {} pending (funding transaction has been broadcasted)\", channel_id, -/// former_temporary_channel_id.unwrap() -/// ); -/// }, -/// Event::ChannelReady { channel_id, user_channel_id, .. } => { -/// assert_eq!(user_channel_id, 42); -/// println!(\"Channel {} ready\", channel_id); -/// }, -/// // ... -/// # _ => {}, +/// channel_manager.process_pending_events(&|event| { +/// match event { +/// Event::FundingGenerationReady { +/// temporary_channel_id, counterparty_node_id, channel_value_satoshis, output_script, +/// user_channel_id, .. +/// } => { +/// assert_eq!(user_channel_id, 42); +/// let funding_transaction = wallet.create_funding_transaction( +/// channel_value_satoshis, output_script +/// ); +/// match channel_manager.funding_transaction_generated( +/// temporary_channel_id, counterparty_node_id, funding_transaction +/// ) { +/// Ok(()) => println!(\"Funding channel {}\", temporary_channel_id), +/// Err(e) => println!(\"Error funding channel {}: {:?}\", temporary_channel_id, e), +/// } +/// }, +/// Event::ChannelPending { channel_id, user_channel_id, former_temporary_channel_id, .. } => { +/// assert_eq!(user_channel_id, 42); +/// println!( +/// \"Channel {} now {} pending (funding transaction has been broadcasted)\", channel_id, +/// former_temporary_channel_id.unwrap() +/// ); +/// }, +/// Event::ChannelReady { channel_id, user_channel_id, .. } => { +/// assert_eq!(user_channel_id, 42); +/// println!(\"Channel {} ready\", channel_id); +/// }, +/// // ... +/// # _ => {}, +/// } +/// Ok(()) /// }); /// # } /// ``` @@ -1173,28 +1219,32 @@ pub(crate) type nativeChannelManager = nativeChannelManagerImport(channel_manager: T) { /// # let channel_manager = channel_manager.get_cm(); -/// channel_manager.process_pending_events(&|event| match event { -/// Event::OpenChannelRequest { temporary_channel_id, counterparty_node_id, .. } => { -/// if !is_trusted(counterparty_node_id) { -/// match channel_manager.force_close_without_broadcasting_txn( -/// &temporary_channel_id, &counterparty_node_id -/// ) { -/// Ok(()) => println!(\"Rejecting channel {}\", temporary_channel_id), -/// Err(e) => println!(\"Error rejecting channel {}: {:?}\", temporary_channel_id, e), +/// # let error_message = \"Channel force-closed\"; +/// channel_manager.process_pending_events(&|event| { +/// match event { +/// Event::OpenChannelRequest { temporary_channel_id, counterparty_node_id, .. } => { +/// if !is_trusted(counterparty_node_id) { +/// match channel_manager.force_close_without_broadcasting_txn( +/// &temporary_channel_id, &counterparty_node_id, error_message.to_string() +/// ) { +/// Ok(()) => println!(\"Rejecting channel {}\", temporary_channel_id), +/// Err(e) => println!(\"Error rejecting channel {}: {:?}\", temporary_channel_id, e), +/// } +/// return Ok(()); /// } -/// return; -/// } /// -/// let user_channel_id = 43; -/// match channel_manager.accept_inbound_channel( -/// &temporary_channel_id, &counterparty_node_id, user_channel_id -/// ) { -/// Ok(()) => println!(\"Accepting channel {}\", temporary_channel_id), -/// Err(e) => println!(\"Error accepting channel {}: {:?}\", temporary_channel_id, e), -/// } -/// }, -/// // ... -/// # _ => {}, +/// let user_channel_id = 43; +/// match channel_manager.accept_inbound_channel( +/// &temporary_channel_id, &counterparty_node_id, user_channel_id +/// ) { +/// Ok(()) => println!(\"Accepting channel {}\", temporary_channel_id), +/// Err(e) => println!(\"Error accepting channel {}: {:?}\", temporary_channel_id, e), +/// } +/// }, +/// // ... +/// # _ => {}, +/// } +/// Ok(()) /// }); /// # } /// ``` @@ -1223,13 +1273,16 @@ pub(crate) type nativeChannelManager = nativeChannelManagerImport { -/// assert_eq!(user_channel_id, 42); -/// println!(\"Channel {} closed\", channel_id); -/// }, -/// // ... -/// # _ => {}, +/// channel_manager.process_pending_events(&|event| { +/// match event { +/// Event::ChannelClosed { channel_id, user_channel_id, .. } => { +/// assert_eq!(user_channel_id, 42); +/// println!(\"Channel {} closed\", channel_id); +/// }, +/// // ... +/// # _ => {}, +/// } +/// Ok(()) /// }); /// # } /// ``` @@ -1279,30 +1332,33 @@ pub(crate) type nativeChannelManager = nativeChannelManagerImport match purpose { -/// PaymentPurpose::Bolt11InvoicePayment { payment_preimage: Some(payment_preimage), .. } => { -/// assert_eq!(payment_hash, known_payment_hash); -/// println!(\"Claiming payment {}\", payment_hash); -/// channel_manager.claim_funds(payment_preimage); +/// channel_manager.process_pending_events(&|event| { +/// match event { +/// Event::PaymentClaimable { payment_hash, purpose, .. } => match purpose { +/// PaymentPurpose::Bolt11InvoicePayment { payment_preimage: Some(payment_preimage), .. } => { +/// assert_eq!(payment_hash, known_payment_hash); +/// println!(\"Claiming payment {}\", payment_hash); +/// channel_manager.claim_funds(payment_preimage); +/// }, +/// PaymentPurpose::Bolt11InvoicePayment { payment_preimage: None, .. } => { +/// println!(\"Unknown payment hash: {}\", payment_hash); +/// }, +/// PaymentPurpose::SpontaneousPayment(payment_preimage) => { +/// assert_ne!(payment_hash, known_payment_hash); +/// println!(\"Claiming spontaneous payment {}\", payment_hash); +/// channel_manager.claim_funds(payment_preimage); +/// }, +/// // ... +/// # _ => {}, /// }, -/// PaymentPurpose::Bolt11InvoicePayment { payment_preimage: None, .. } => { -/// println!(\"Unknown payment hash: {}\", payment_hash); -/// }, -/// PaymentPurpose::SpontaneousPayment(payment_preimage) => { -/// assert_ne!(payment_hash, known_payment_hash); -/// println!(\"Claiming spontaneous payment {}\", payment_hash); -/// channel_manager.claim_funds(payment_preimage); +/// Event::PaymentClaimed { payment_hash, amount_msat, .. } => { +/// assert_eq!(payment_hash, known_payment_hash); +/// println!(\"Claimed {} msats\", amount_msat); /// }, /// // ... -/// # _ => {}, -/// }, -/// Event::PaymentClaimed { payment_hash, amount_msat, .. } => { -/// assert_eq!(payment_hash, known_payment_hash); -/// println!(\"Claimed {} msats\", amount_msat); -/// }, -/// // ... -/// # _ => {}, +/// # _ => {}, +/// } +/// Ok(()) /// }); /// # } /// ``` @@ -1345,11 +1401,15 @@ pub(crate) type nativeChannelManager = nativeChannelManagerImport println!(\"Paid {}\", payment_hash), -/// Event::PaymentFailed { payment_hash, .. } => println!(\"Failed paying {}\", payment_hash), -/// // ... -/// # _ => {}, +/// channel_manager.process_pending_events(&|event| { +/// match event { +/// Event::PaymentSent { payment_hash, .. } => println!(\"Paid {}\", payment_hash), +/// Event::PaymentFailed { payment_hash: Some(payment_hash), .. } => +/// println!(\"Failed paying {}\", payment_hash), +/// // ... +/// # _ => {}, +/// } +/// Ok(()) /// }); /// # } /// ``` @@ -1370,8 +1430,9 @@ pub(crate) type nativeChannelManager = nativeChannelManagerImport(channel_manager: T) -> Result<(), Bolt12SemanticError> { /// # let channel_manager = channel_manager.get_cm(); +/// # let absolute_expiry = None; /// let offer = channel_manager -/// .create_offer_builder()? +/// .create_offer_builder(absolute_expiry)? /// # ; /// # // Needed for compiling for c_bindings /// # let builder: lightning::offers::offer::OfferBuilder<_, _> = offer.into(); @@ -1382,31 +1443,32 @@ pub(crate) type nativeChannelManager = nativeChannelManagerImport match purpose { -/// PaymentPurpose::Bolt12OfferPayment { payment_preimage: Some(payment_preimage), .. } => { -/// println!(\"Claiming payment {}\", payment_hash); -/// channel_manager.claim_funds(payment_preimage); +/// channel_manager.process_pending_events(&|event| { +/// match event { +/// Event::PaymentClaimable { payment_hash, purpose, .. } => match purpose { +/// PaymentPurpose::Bolt12OfferPayment { payment_preimage: Some(payment_preimage), .. } => { +/// println!(\"Claiming payment {}\", payment_hash); +/// channel_manager.claim_funds(payment_preimage); +/// }, +/// PaymentPurpose::Bolt12OfferPayment { payment_preimage: None, .. } => { +/// println!(\"Unknown payment hash: {}\", payment_hash); +/// } +/// # _ => {}, /// }, -/// PaymentPurpose::Bolt12OfferPayment { payment_preimage: None, .. } => { -/// println!(\"Unknown payment hash: {}\", payment_hash); +/// Event::PaymentClaimed { payment_hash, amount_msat, .. } => { +/// println!(\"Claimed {} msats\", amount_msat); /// }, /// // ... -/// # _ => {}, -/// }, -/// Event::PaymentClaimed { payment_hash, amount_msat, .. } => { -/// println!(\"Claimed {} msats\", amount_msat); -/// }, -/// // ... -/// # _ => {}, +/// # _ => {}, +/// } +/// Ok(()) /// }); /// # Ok(()) /// # } /// ``` /// /// Use [`pay_for_offer`] to initiated payment, which sends an [`InvoiceRequest`] for an [`Offer`] -/// and pays the [`Bolt12Invoice`] response. In addition to success and failure events, -/// [`ChannelManager`] may also generate an [`Event::InvoiceRequestFailed`]. +/// and pays the [`Bolt12Invoice`] response. /// /// ``` /// # use lightning::events::{Event, EventsProvider}; @@ -1444,12 +1506,14 @@ pub(crate) type nativeChannelManager = nativeChannelManagerImport println!(\"Paid {}\", payment_id), -/// Event::PaymentFailed { payment_id, .. } => println!(\"Failed paying {}\", payment_id), -/// Event::InvoiceRequestFailed { payment_id, .. } => println!(\"Failed paying {}\", payment_id), -/// // ... -/// # _ => {}, +/// channel_manager.process_pending_events(&|event| { +/// match event { +/// Event::PaymentSent { payment_id: Some(payment_id), .. } => println!(\"Paid {}\", payment_id), +/// Event::PaymentFailed { payment_id, .. } => println!(\"Failed paying {}\", payment_id), +/// // ... +/// # _ => {}, +/// } +/// Ok(()) /// }); /// # } /// ``` @@ -1504,11 +1568,14 @@ pub(crate) type nativeChannelManager = nativeChannelManagerImport println!(\"Paid {}\", payment_id), -/// Event::PaymentFailed { payment_id, .. } => println!(\"Failed paying {}\", payment_id), -/// // ... -/// # _ => {}, +/// channel_manager.process_pending_events(&|event| { +/// match event { +/// Event::PaymentSent { payment_id: Some(payment_id), .. } => println!(\"Paid {}\", payment_id), +/// Event::PaymentFailed { payment_id, .. } => println!(\"Failed paying {}\", payment_id), +/// // ... +/// # _ => {}, +/// } +/// Ok(()) /// }); /// # Ok(()) /// # } @@ -1534,18 +1601,19 @@ pub(crate) type nativeChannelManager = nativeChannelManagerImport match purpose { -/// \tPaymentPurpose::Bolt12RefundPayment { payment_preimage: Some(payment_preimage), .. } => { -/// assert_eq!(payment_hash, known_payment_hash); -/// println!(\"Claiming payment {}\", payment_hash); -/// channel_manager.claim_funds(payment_preimage); -/// }, -/// \tPaymentPurpose::Bolt12RefundPayment { payment_preimage: None, .. } => { -/// println!(\"Unknown payment hash: {}\", payment_hash); -/// \t}, -/// // ... -/// # _ => {}, +/// channel_manager.process_pending_events(&|event| { +/// match event { +/// Event::PaymentClaimable { payment_hash, purpose, .. } => match purpose { +/// PaymentPurpose::Bolt12RefundPayment { payment_preimage: Some(payment_preimage), .. } => { +/// assert_eq!(payment_hash, known_payment_hash); +/// println!(\"Claiming payment {}\", payment_hash); +/// channel_manager.claim_funds(payment_preimage); +/// }, +/// PaymentPurpose::Bolt12RefundPayment { payment_preimage: None, .. } => { +/// println!(\"Unknown payment hash: {}\", payment_hash); +/// }, +/// // ... +/// # _ => {}, /// }, /// Event::PaymentClaimed { payment_hash, amount_msat, .. } => { /// assert_eq!(payment_hash, known_payment_hash); @@ -1553,6 +1621,8 @@ pub(crate) type nativeChannelManager = nativeChannelManagerImport {}, +/// } +/// Ok(()) /// }); /// # } /// ``` @@ -1660,6 +1730,12 @@ pub struct ChannelManager { pub is_owned: bool, } +impl core::ops::Deref for ChannelManager { + type Target = nativeChannelManager; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ChannelManager { } +unsafe impl core::marker::Sync for ChannelManager { } impl Drop for ChannelManager { fn drop(&mut self) { if self.is_owned && !<*mut nativeChannelManager>::is_null(self.inner) { @@ -1690,6 +1766,9 @@ impl ChannelManager { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } use lightning::ln::channelmanager::ChainParameters as nativeChainParametersImport; @@ -1715,6 +1794,12 @@ pub struct ChainParameters { pub is_owned: bool, } +impl core::ops::Deref for ChainParameters { + type Target = nativeChainParameters; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ChainParameters { } +unsafe impl core::marker::Sync for ChainParameters { } impl Drop for ChainParameters { fn drop(&mut self) { if self.is_owned && !<*mut nativeChainParameters>::is_null(self.inner) { @@ -1745,6 +1830,9 @@ impl ChainParameters { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The network for determining the `chain_hash` in Lightning messages. #[no_mangle] @@ -2087,6 +2175,12 @@ pub struct PhantomRouteHints { pub is_owned: bool, } +impl core::ops::Deref for PhantomRouteHints { + type Target = nativePhantomRouteHints; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for PhantomRouteHints { } +unsafe impl core::marker::Sync for PhantomRouteHints { } impl Drop for PhantomRouteHints { fn drop(&mut self) { if self.is_owned && !<*mut nativePhantomRouteHints>::is_null(self.inner) { @@ -2117,6 +2211,9 @@ impl PhantomRouteHints { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The list of channels to be included in the invoice route hints. #[no_mangle] @@ -2383,48 +2480,66 @@ pub extern "C" fn ChannelManager_close_channel_with_feerate_and_script(this_arg: local_ret } -/// 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. +/// Force closes a channel, immediately broadcasting the latest local transaction(s), +/// rejecting new HTLCs. +/// +/// The provided `error_message` is sent to connected peers for closing +/// channels and should be a human-readable description of what went wrong. +/// +/// Fails if `channel_id` is unknown to the manager, or if the `counterparty_node_id` +/// isn't the counterparty of the corresponding channel. #[must_use] #[no_mangle] -pub extern "C" fn ChannelManager_force_close_broadcasting_latest_txn(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, channel_id: &crate::lightning::ln::types::ChannelId, mut counterparty_node_id: crate::c_types::PublicKey) -> crate::c_types::derived::CResult_NoneAPIErrorZ { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.force_close_broadcasting_latest_txn(channel_id.get_native_ref(), &counterparty_node_id.into_rust()); +pub extern "C" fn ChannelManager_force_close_broadcasting_latest_txn(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, channel_id: &crate::lightning::ln::types::ChannelId, mut counterparty_node_id: crate::c_types::PublicKey, mut error_message: crate::c_types::Str) -> crate::c_types::derived::CResult_NoneAPIErrorZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.force_close_broadcasting_latest_txn(channel_id.get_native_ref(), &counterparty_node_id.into_rust(), error_message.into_string()); 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 } /// 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. +/// the latest local transaction(s). /// +/// The provided `error_message` is sent to connected peers for closing channels and should +/// be a human-readable description of what went wrong. +/// +/// 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 broadcast the latest local transaction(s) via /// [`ChannelMonitor::broadcast_latest_holder_commitment_txn`]. #[must_use] #[no_mangle] -pub extern "C" fn ChannelManager_force_close_without_broadcasting_txn(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, channel_id: &crate::lightning::ln::types::ChannelId, mut counterparty_node_id: crate::c_types::PublicKey) -> crate::c_types::derived::CResult_NoneAPIErrorZ { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.force_close_without_broadcasting_txn(channel_id.get_native_ref(), &counterparty_node_id.into_rust()); +pub extern "C" fn ChannelManager_force_close_without_broadcasting_txn(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, channel_id: &crate::lightning::ln::types::ChannelId, mut counterparty_node_id: crate::c_types::PublicKey, mut error_message: crate::c_types::Str) -> crate::c_types::derived::CResult_NoneAPIErrorZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.force_close_without_broadcasting_txn(channel_id.get_native_ref(), &counterparty_node_id.into_rust(), error_message.into_string()); 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 } /// Force close all channels, immediately broadcasting the latest local commitment transaction /// for each to the chain and rejecting new HTLCs on each. +/// +/// The provided `error_message` is sent to connected peers for closing channels and should +/// be a human-readable description of what went wrong. #[no_mangle] -pub extern "C" fn ChannelManager_force_close_all_channels_broadcasting_latest_txn(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) { - unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.force_close_all_channels_broadcasting_latest_txn() +pub extern "C" fn ChannelManager_force_close_all_channels_broadcasting_latest_txn(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut error_message: crate::c_types::Str) { + unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.force_close_all_channels_broadcasting_latest_txn(error_message.into_string()) } /// Force close all channels rejecting new HTLCs on each but without broadcasting the latest /// local transaction(s). +/// +/// The provided `error_message` is sent to connected peers for closing channels and +/// should be a human-readable description of what went wrong. #[no_mangle] -pub extern "C" fn ChannelManager_force_close_all_channels_without_broadcasting_txn(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) { - unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.force_close_all_channels_without_broadcasting_txn() +pub extern "C" fn ChannelManager_force_close_all_channels_without_broadcasting_txn(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut error_message: crate::c_types::Str) { + unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.force_close_all_channels_without_broadcasting_txn(error_message.into_string()) } /// Sends a payment along a given route. /// +/// This method is *DEPRECATED*, use [`Self::send_payment`] instead. If you wish to fix the +/// route for a payment, do so by matching the [`PaymentId`] passed to +/// [`Router::find_route_with_id`]. +/// /// Value parameters are provided via the last hop in route, see documentation for [`RouteHop`] /// fields for more info. /// @@ -2476,8 +2591,8 @@ pub extern "C" fn ChannelManager_force_close_all_channels_without_broadcasting_t /// [`ChannelMonitorUpdateStatus::InProgress`]: crate::chain::ChannelMonitorUpdateStatus::InProgress #[must_use] #[no_mangle] -pub extern "C" fn ChannelManager_send_payment_with_route(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, route: &crate::lightning::routing::router::Route, mut payment_hash: 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_NonePaymentSendFailureZ { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.send_payment_with_route(route.get_native_ref(), ::lightning::ln::types::PaymentHash(payment_hash.data), *unsafe { Box::from_raw(recipient_onion.take_inner()) }, ::lightning::ln::channelmanager::PaymentId(payment_id.data)); +pub extern "C" fn ChannelManager_send_payment_with_route(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut route: crate::lightning::routing::router::Route, mut payment_hash: 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_NonePaymentSendFailureZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.send_payment_with_route(*unsafe { Box::from_raw(route.take_inner()) }, ::lightning::ln::types::PaymentHash(payment_hash.data), *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( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::outbound_payment::PaymentSendFailure::native_into(e) }).into() }; local_ret } @@ -2508,15 +2623,13 @@ pub extern "C" fn ChannelManager_send_payment(this_arg: &crate::lightning::ln::c /// # Requested Invoices /// /// In the case of paying a [`Bolt12Invoice`] via [`ChannelManager::pay_for_offer`], abandoning -/// the payment prior to receiving the invoice will result in an [`Event::InvoiceRequestFailed`] -/// and prevent any attempts at paying it once received. The other events may only be generated -/// once the invoice has been received. +/// the payment prior to receiving the invoice will result in an [`Event::PaymentFailed`] and +/// prevent any attempts at paying it once received. /// /// # Restart Behavior /// /// If an [`Event::PaymentFailed`] is generated and we restart without first persisting the -/// [`ChannelManager`], another [`Event::PaymentFailed`] may be generated; likewise for -/// [`Event::InvoiceRequestFailed`]. +/// [`ChannelManager`], another [`Event::PaymentFailed`] may be generated. /// /// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice #[no_mangle] @@ -2641,8 +2754,43 @@ pub extern "C" fn ChannelManager_send_preflight_probes(this_arg: &crate::lightni /// [`Event::ChannelClosed`]: crate::events::Event::ChannelClosed #[must_use] #[no_mangle] -pub extern "C" fn ChannelManager_funding_transaction_generated(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, temporary_channel_id: &crate::lightning::ln::types::ChannelId, mut counterparty_node_id: crate::c_types::PublicKey, mut funding_transaction: crate::c_types::Transaction) -> crate::c_types::derived::CResult_NoneAPIErrorZ { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.funding_transaction_generated(temporary_channel_id.get_native_ref(), &counterparty_node_id.into_rust(), funding_transaction.into_bitcoin()); +pub extern "C" fn ChannelManager_funding_transaction_generated(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut temporary_channel_id: crate::lightning::ln::types::ChannelId, mut counterparty_node_id: crate::c_types::PublicKey, mut funding_transaction: crate::c_types::Transaction) -> crate::c_types::derived::CResult_NoneAPIErrorZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.funding_transaction_generated(*unsafe { Box::from_raw(temporary_channel_id.take_inner()) }, counterparty_node_id.into_rust(), funding_transaction.into_bitcoin()); + 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 +} + +/// **Unsafe**: This method does not validate the spent output. It is the caller's +/// responsibility to ensure the spent outputs are SegWit, as well as making sure the funding +/// transaction has a final absolute locktime, i.e., its locktime is lower than the next block height. +/// +/// For a safer method, please refer to [`ChannelManager::funding_transaction_generated`]. +/// +/// Call this in response to a [`Event::FundingGenerationReady`] event. +/// +/// Note that if this method is called successfully, the funding transaction won't be +/// broadcasted and you are expected to broadcast it manually when receiving the +/// [`Event::FundingTxBroadcastSafe`] event. +/// +/// 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 funding output is duplicative with some other channel (note that this +/// should be trivially prevented by using unique funding transaction keys per-channel). +/// +/// 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::FundingTxBroadcastSafe`]: crate::events::Event::FundingTxBroadcastSafe +/// [`Event::ChannelClosed`]: crate::events::Event::ChannelClosed +/// [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelManager_unsafe_manual_funding_transaction_generated(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut temporary_channel_id: crate::lightning::ln::types::ChannelId, mut counterparty_node_id: crate::c_types::PublicKey, mut funding: crate::lightning::chain::transaction::OutPoint) -> crate::c_types::derived::CResult_NoneAPIErrorZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.unsafe_manual_funding_transaction_generated(*unsafe { Box::from_raw(temporary_channel_id.take_inner()) }, counterparty_node_id.into_rust(), *unsafe { Box::from_raw(funding.take_inner()) }); 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 } @@ -2938,16 +3086,15 @@ pub extern "C" fn ChannelManager_accept_inbound_channel_from_trusted_peer_0conf( } /// Creates an [`OfferBuilder`] such that the [`Offer`] it builds is recognized by the -/// [`ChannelManager`] when handling [`InvoiceRequest`] messages for the offer. The offer will -/// not have an expiration unless otherwise set on the builder. +/// [`ChannelManager`] when handling [`InvoiceRequest`] messages for the offer. The offer's +/// expiration will be `absolute_expiry` if `Some`, otherwise it will not expire. /// /// # Privacy /// -/// Uses [`MessageRouter::create_blinded_paths`] to construct a [`BlindedPath`] for the offer. -/// However, if one is not found, uses a one-hop [`BlindedPath`] with -/// [`ChannelManager::get_our_node_id`] as the introduction node instead. In the latter case, -/// the node must be announced, otherwise, there is no way to find a path to the introduction in -/// order to send the [`InvoiceRequest`]. +/// Uses [`MessageRouter`] to construct a [`BlindedMessagePath`] for the offer based on the given +/// `absolute_expiry` according to [`MAX_SHORT_LIVED_RELATIVE_EXPIRY`]. See those docs for +/// privacy implications as well as those of the parameterized [`Router`], which implements +/// [`MessageRouter`]. /// /// Also, uses a derived signing pubkey in the offer for recipient privacy. /// @@ -2964,8 +3111,9 @@ pub extern "C" fn ChannelManager_accept_inbound_channel_from_trusted_peer_0conf( /// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest #[must_use] #[no_mangle] -pub extern "C" fn ChannelManager_create_offer_builder(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::c_types::derived::CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.create_offer_builder(); +pub extern "C" fn ChannelManager_create_offer_builder(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut absolute_expiry: crate::c_types::derived::COption_u64Z) -> crate::c_types::derived::CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ { + let mut local_absolute_expiry = { /*absolute_expiry*/ let absolute_expiry_opt = absolute_expiry; if absolute_expiry_opt.is_none() { None } else { Some({ { core::time::Duration::from_secs({ absolute_expiry_opt.take() }) }})} }; + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.create_offer_builder(local_absolute_expiry); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::offer::OfferWithDerivedMetadataBuilder { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::offers::parse::Bolt12SemanticError::native_into(e) }).into() }; local_ret } @@ -2985,18 +3133,17 @@ pub extern "C" fn ChannelManager_create_offer_builder(this_arg: &crate::lightnin /// /// To revoke the refund, use [`ChannelManager::abandon_payment`] prior to receiving the /// invoice. If abandoned, or an invoice isn't received before expiration, the payment will fail -/// with an [`Event::InvoiceRequestFailed`]. +/// with an [`Event::PaymentFailed`]. /// /// If `max_total_routing_fee_msat` is not specified, The default from /// [`RouteParameters::from_payment_params_and_value`] is applied. /// /// # Privacy /// -/// Uses [`MessageRouter::create_blinded_paths`] to construct a [`BlindedPath`] for the refund. -/// However, if one is not found, uses a one-hop [`BlindedPath`] with -/// [`ChannelManager::get_our_node_id`] as the introduction node instead. In the latter case, -/// the node must be announced, otherwise, there is no way to find a path to the introduction in -/// order to send the [`Bolt12Invoice`]. +/// Uses [`MessageRouter`] to construct a [`BlindedMessagePath`] for the refund based on the given +/// `absolute_expiry` according to [`MAX_SHORT_LIVED_RELATIVE_EXPIRY`]. See those docs for +/// privacy implications as well as those of the parameterized [`Router`], which implements +/// [`MessageRouter`]. /// /// Also, uses a derived payer id in the refund for payer privacy. /// @@ -3048,14 +3195,13 @@ pub extern "C" fn ChannelManager_create_refund_builder(this_arg: &crate::lightni /// /// To revoke the request, use [`ChannelManager::abandon_payment`] prior to receiving the /// invoice. If abandoned, or an invoice isn't received in a reasonable amount of time, the -/// payment will fail with an [`Event::InvoiceRequestFailed`]. +/// payment will fail with an [`Event::PaymentFailed`]. /// /// # Privacy /// -/// Uses a one-hop [`BlindedPath`] for the reply path with [`ChannelManager::get_our_node_id`] -/// as the introduction node and a derived payer id for payer privacy. As such, currently, the -/// node must be announced. Otherwise, there is no way to find a path to the introduction node -/// in order to send the [`Bolt12Invoice`]. +/// For payer privacy, uses a derived payer id and uses [`MessageRouter::create_blinded_paths`] +/// to construct a [`BlindedMessagePath`] for the reply path. For further privacy implications, see the +/// docs of the parameterized [`Router`], which implements [`MessageRouter`]. /// /// # Limitations /// @@ -3095,8 +3241,8 @@ pub extern "C" fn ChannelManager_pay_for_offer(this_arg: &crate::lightning::ln:: /// message. /// /// The resulting invoice uses a [`PaymentHash`] recognized by the [`ChannelManager`] and a -/// [`BlindedPath`] containing the [`PaymentSecret`] needed to reconstruct the corresponding -/// [`PaymentPreimage`]. It is returned purely for informational purposes. +/// [`BlindedPaymentPath`] containing the [`PaymentSecret`] needed to reconstruct the +/// corresponding [`PaymentPreimage`]. It is returned purely for informational purposes. /// /// # Limitations /// @@ -3439,36 +3585,36 @@ pub extern "C" fn ChannelManager_current_best_block(this_arg: &crate::lightning: /// [`ChannelManager`]. #[must_use] #[no_mangle] -pub extern "C" fn ChannelManager_node_features(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::lightning::ln::features::NodeFeatures { +pub extern "C" fn ChannelManager_node_features(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::lightning_types::features::NodeFeatures { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.node_features(); - crate::lightning::ln::features::NodeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } + crate::lightning_types::features::NodeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } /// Fetches the set of [`ChannelFeatures`] flags that are provided by or required by /// [`ChannelManager`]. #[must_use] #[no_mangle] -pub extern "C" fn ChannelManager_channel_features(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::lightning::ln::features::ChannelFeatures { +pub extern "C" fn ChannelManager_channel_features(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::lightning_types::features::ChannelFeatures { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.channel_features(); - crate::lightning::ln::features::ChannelFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } + crate::lightning_types::features::ChannelFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } /// Fetches the set of [`ChannelTypeFeatures`] flags that are provided by or required by /// [`ChannelManager`]. #[must_use] #[no_mangle] -pub extern "C" fn ChannelManager_channel_type_features(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::lightning::ln::features::ChannelTypeFeatures { +pub extern "C" fn ChannelManager_channel_type_features(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::lightning_types::features::ChannelTypeFeatures { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.channel_type_features(); - crate::lightning::ln::features::ChannelTypeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } + crate::lightning_types::features::ChannelTypeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } /// Fetches the set of [`InitFeatures`] flags that are provided by or required by /// [`ChannelManager`]. #[must_use] #[no_mangle] -pub extern "C" fn ChannelManager_init_features(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::lightning::ln::features::InitFeatures { +pub extern "C" fn ChannelManager_init_features(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::lightning_types::features::InitFeatures { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.init_features(); - crate::lightning::ln::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } + crate::lightning_types::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } impl From for crate::lightning::ln::msgs::ChannelMessageHandler { @@ -3631,14 +3777,14 @@ extern "C" fn ChannelManager_ChannelMessageHandler_handle_error(this_arg: *const ::handle_error(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) } #[must_use] -extern "C" fn ChannelManager_ChannelMessageHandler_provided_node_features(this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures { +extern "C" fn ChannelManager_ChannelMessageHandler_provided_node_features(this_arg: *const c_void) -> crate::lightning_types::features::NodeFeatures { let mut ret = ::provided_node_features(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, ); - crate::lightning::ln::features::NodeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } + crate::lightning_types::features::NodeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } #[must_use] -extern "C" fn ChannelManager_ChannelMessageHandler_provided_init_features(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures { +extern "C" fn ChannelManager_ChannelMessageHandler_provided_init_features(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey) -> crate::lightning_types::features::InitFeatures { 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 } + crate::lightning_types::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } #[must_use] extern "C" fn ChannelManager_ChannelMessageHandler_get_chain_hashes(this_arg: *const c_void) -> crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ { @@ -3670,15 +3816,57 @@ pub extern "C" fn ChannelManager_as_OffersMessageHandler(this_arg: &ChannelManag } #[must_use] -extern "C" fn ChannelManager_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 nativeChannelManager) }, 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()) }) }; +extern "C" fn ChannelManager_OffersMessageHandler_handle_message(this_arg: *const c_void, mut message: crate::lightning::onion_message::offers::OffersMessage, mut context: crate::c_types::derived::COption_OffersContextZ, mut responder: crate::lightning::onion_message::messenger::Responder) -> crate::c_types::derived::COption_C2Tuple_OffersMessageResponseInstructionZZ { + let mut local_context = { /*context*/ let context_opt = context; if context_opt.is_none() { None } else { Some({ { { context_opt.take() }.into_native() }})} }; + let mut local_responder = if responder.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(responder.take_inner()) } }) }; + let mut ret = ::handle_message(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, message.into_native(), local_context, local_responder); + let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_C2Tuple_OffersMessageResponseInstructionZZ::None } else { crate::c_types::derived::COption_C2Tuple_OffersMessageResponseInstructionZZ::Some( { let (mut orig_ret_0_0, mut orig_ret_0_1) = (ret.unwrap()); let mut local_ret_0 = (crate::lightning::onion_message::offers::OffersMessage::native_into(orig_ret_0_0), crate::lightning::onion_message::messenger::ResponseInstruction { inner: ObjOps::heap_alloc(orig_ret_0_1), is_owned: true }).into(); local_ret_0 }) }; local_ret } #[must_use] -extern "C" fn ChannelManager_OffersMessageHandler_release_pending_messages(this_arg: *const c_void) -> crate::c_types::derived::CVec_C3Tuple_OffersMessageDestinationBlindedPathZZ { +extern "C" fn ChannelManager_OffersMessageHandler_release_pending_messages(this_arg: *const c_void) -> crate::c_types::derived::CVec_C2Tuple_OffersMessageMessageSendInstructionsZZ { let mut ret = ::release_pending_messages(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, mut orig_ret_0_2) = item; let mut local_orig_ret_0_2 = crate::lightning::blinded_path::BlindedPath { inner: if orig_ret_0_2.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((orig_ret_0_2.unwrap())) } }, is_owned: true }; let mut local_ret_0 = (crate::lightning::onion_message::offers::OffersMessage::native_into(orig_ret_0_0), crate::lightning::onion_message::messenger::Destination::native_into(orig_ret_0_1), local_orig_ret_0_2).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_ret_0 = (crate::lightning::onion_message::offers::OffersMessage::native_into(orig_ret_0_0), crate::lightning::onion_message::messenger::MessageSendInstructions::native_into(orig_ret_0_1)).into(); local_ret_0 }); }; + local_ret.into() +} + +impl From for crate::lightning::onion_message::async_payments::AsyncPaymentsMessageHandler { + fn from(obj: nativeChannelManager) -> Self { + let rust_obj = crate::lightning::ln::channelmanager::ChannelManager { inner: ObjOps::heap_alloc(obj), is_owned: true }; + let mut ret = ChannelManager_as_AsyncPaymentsMessageHandler(&rust_obj); + // We want to free rust_obj when ret gets drop()'d, not rust_obj, so forget it and set ret's free() fn + core::mem::forget(rust_obj); + ret.free = Some(ChannelManager_free_void); + ret + } +} +/// Constructs a new AsyncPaymentsMessageHandler which calls the relevant methods on this_arg. +/// This copies the `inner` pointer in this_arg and thus the returned AsyncPaymentsMessageHandler must be freed before this_arg is +#[no_mangle] +pub extern "C" fn ChannelManager_as_AsyncPaymentsMessageHandler(this_arg: &ChannelManager) -> crate::lightning::onion_message::async_payments::AsyncPaymentsMessageHandler { + crate::lightning::onion_message::async_payments::AsyncPaymentsMessageHandler { + this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, + free: None, + held_htlc_available: ChannelManager_AsyncPaymentsMessageHandler_held_htlc_available, + release_held_htlc: ChannelManager_AsyncPaymentsMessageHandler_release_held_htlc, + release_pending_messages: ChannelManager_AsyncPaymentsMessageHandler_release_pending_messages, + } +} + +#[must_use] +extern "C" fn ChannelManager_AsyncPaymentsMessageHandler_held_htlc_available(this_arg: *const c_void, mut message: crate::lightning::onion_message::async_payments::HeldHtlcAvailable, mut responder: crate::lightning::onion_message::messenger::Responder) -> crate::c_types::derived::COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ { + let mut local_responder = if responder.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(responder.take_inner()) } }) }; + let mut ret = ::held_htlc_available(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, *unsafe { Box::from_raw(message.take_inner()) }, local_responder); + let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ::None } else { crate::c_types::derived::COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ::Some( { let (mut orig_ret_0_0, mut orig_ret_0_1) = (ret.unwrap()); let mut local_ret_0 = (crate::lightning::onion_message::async_payments::ReleaseHeldHtlc { inner: ObjOps::heap_alloc(orig_ret_0_0), is_owned: true }, crate::lightning::onion_message::messenger::ResponseInstruction { inner: ObjOps::heap_alloc(orig_ret_0_1), is_owned: true }).into(); local_ret_0 }) }; + local_ret +} +extern "C" fn ChannelManager_AsyncPaymentsMessageHandler_release_held_htlc(this_arg: *const c_void, mut message: crate::lightning::onion_message::async_payments::ReleaseHeldHtlc) { + ::release_held_htlc(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, *unsafe { Box::from_raw(message.take_inner()) }) +} +#[must_use] +extern "C" fn ChannelManager_AsyncPaymentsMessageHandler_release_pending_messages(this_arg: *const c_void) -> crate::c_types::derived::CVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ { + let mut ret = ::release_pending_messages(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_ret_0 = (crate::lightning::onion_message::async_payments::AsyncPaymentsMessage::native_into(orig_ret_0_0), crate::lightning::onion_message::messenger::MessageSendInstructions::native_into(orig_ret_0_1)).into(); local_ret_0 }); }; local_ret.into() } @@ -3713,9 +3901,9 @@ extern "C" fn ChannelManager_NodeIdLookUp_next_node_id(this_arg: *const c_void, /// Fetches the set of [`InitFeatures`] flags that 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 { +pub extern "C" fn provided_init_features(config: &crate::lightning::util::config::UserConfig) -> crate::lightning_types::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 } + crate::lightning_types::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } #[no_mangle] @@ -3725,7 +3913,7 @@ pub extern "C" fn PhantomRouteHints_write(obj: &crate::lightning::ln::channelman } #[allow(unused)] pub(crate) extern "C" fn PhantomRouteHints_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePhantomRouteHints) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::channelmanager::nativePhantomRouteHints) }) } #[no_mangle] /// Read a PhantomRouteHints from a byte array, created by PhantomRouteHints_write @@ -3741,7 +3929,7 @@ pub extern "C" fn BlindedForward_write(obj: &crate::lightning::ln::channelmanage } #[allow(unused)] pub(crate) extern "C" fn BlindedForward_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeBlindedForward) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::channelmanager::nativeBlindedForward) }) } #[no_mangle] /// Read a BlindedForward from a byte array, created by BlindedForward_write @@ -3773,7 +3961,7 @@ pub extern "C" fn PendingHTLCInfo_write(obj: &crate::lightning::ln::channelmanag } #[allow(unused)] pub(crate) extern "C" fn PendingHTLCInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePendingHTLCInfo) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::channelmanager::nativePendingHTLCInfo) }) } #[no_mangle] /// Read a PendingHTLCInfo from a byte array, created by PendingHTLCInfo_write @@ -3805,7 +3993,7 @@ pub extern "C" fn ChannelManager_write(obj: &crate::lightning::ln::channelmanage } #[allow(unused)] 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) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::channelmanager::nativeChannelManager) }) } use lightning::ln::channelmanager::ChannelManagerReadArgs as nativeChannelManagerReadArgsImport; @@ -3858,6 +4046,12 @@ pub struct ChannelManagerReadArgs { pub is_owned: bool, } +impl core::ops::Deref for ChannelManagerReadArgs { + type Target = nativeChannelManagerReadArgs; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ChannelManagerReadArgs { } +unsafe impl core::marker::Sync for ChannelManagerReadArgs { } impl Drop for ChannelManagerReadArgs { fn drop(&mut self) { if self.is_owned && !<*mut nativeChannelManagerReadArgs>::is_null(self.inner) { @@ -3888,6 +4082,9 @@ impl ChannelManagerReadArgs { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// A cryptographically secure source of entropy. #[no_mangle] diff --git a/lightning-c-bindings/src/lightning/ln/features.rs b/lightning-c-bindings/src/lightning/ln/features.rs index 00a54bf..985db0d 100644 --- a/lightning-c-bindings/src/lightning/ln/features.rs +++ b/lightning-c-bindings/src/lightning/ln/features.rs @@ -8,84 +8,13 @@ //! Feature flag definitions for the Lightning protocol according to [BOLT #9]. //! -//! Lightning nodes advertise a supported set of operation through feature flags. Features are -//! applicable for a specific context as indicated in some [messages]. [`Features`] encapsulates -//! behavior for specifying and checking feature flags for a particular context. Each feature is -//! defined internally by a trait specifying the corresponding flags (i.e., even and odd bits). +//! See [`lightning_types::features`] for the list of features currently supported. //! -//! Whether a feature is considered \"known\" or \"unknown\" is relative to the implementation, whereas -//! the term \"supports\" is used in reference to a particular set of [`Features`]. That is, a node -//! supports a feature if it advertises the feature (as either required or optional) to its peers. -//! And the implementation can interpret a feature if the feature is known to it. -//! -//! The following features are currently required in the LDK: -//! - `VariableLengthOnion` - requires/supports variable-length routing onion payloads -//! (see [BOLT-4](https://github.com/lightning/bolts/blob/master/04-onion-routing.md) for more information). -//! - `StaticRemoteKey` - requires/supports static key for remote output -//! (see [BOLT-3](https://github.com/lightning/bolts/blob/master/03-transactions.md) for more information). -//! -//! The following features are currently supported in the LDK: -//! - `DataLossProtect` - requires/supports that a node which has somehow fallen behind, e.g., has been restored from an old backup, -//! can detect that it has fallen behind -//! (see [BOLT-2](https://github.com/lightning/bolts/blob/master/02-peer-protocol.md) for more information). -//! - `InitialRoutingSync` - requires/supports that the sending node needs a complete routing information dump -//! (see [BOLT-7](https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#initial-sync) for more information). -//! - `UpfrontShutdownScript` - commits to a shutdown scriptpubkey when opening a channel -//! (see [BOLT-2](https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-open_channel-message) for more information). -//! - `GossipQueries` - requires/supports more sophisticated gossip control -//! (see [BOLT-7](https://github.com/lightning/bolts/blob/master/07-routing-gossip.md) for more information). -//! - `PaymentSecret` - requires/supports that a node supports payment_secret field -//! (see [BOLT-4](https://github.com/lightning/bolts/blob/master/04-onion-routing.md) for more information). -//! - `BasicMPP` - requires/supports that a node can receive basic multi-part payments -//! (see [BOLT-4](https://github.com/lightning/bolts/blob/master/04-onion-routing.md#basic-multi-part-payments) for more information). -//! - `Wumbo` - requires/supports that a node create large channels. Called `option_support_large_channel` in the spec. -//! (see [BOLT-2](https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-open_channel-message) for more information). -//! - `AnchorsZeroFeeHtlcTx` - requires/supports that commitment transactions include anchor outputs -//! and HTLC transactions are pre-signed with zero fee (see -//! [BOLT-3](https://github.com/lightning/bolts/blob/master/03-transactions.md) for more -//! information). -//! - `RouteBlinding` - requires/supports that a node can relay payments over blinded paths -//! (see [BOLT-4](https://github.com/lightning/bolts/blob/master/04-onion-routing.md#route-blinding) for more information). -//! - `ShutdownAnySegwit` - requires/supports that future segwit versions are allowed in `shutdown` -//! (see [BOLT-2](https://github.com/lightning/bolts/blob/master/02-peer-protocol.md) for more information). -//! - `OnionMessages` - requires/supports forwarding onion messages -//! (see [BOLT-7](https://github.com/lightning/bolts/pull/759/files) for more information). -//! - `ChannelType` - node supports the channel_type field in open/accept -//! (see [BOLT-2](https://github.com/lightning/bolts/blob/master/02-peer-protocol.md) for more information). -//! - `SCIDPrivacy` - supply channel aliases for routing -//! (see [BOLT-2](https://github.com/lightning/bolts/blob/master/02-peer-protocol.md) for more information). -//! - `PaymentMetadata` - include additional data in invoices which is passed to recipients in the -//! onion. -//! (see [BOLT-11](https://github.com/lightning/bolts/blob/master/11-payment-encoding.md) for -//! more). -//! - `ZeroConf` - supports accepting HTLCs and using channels prior to funding confirmation -//! (see -//! [BOLT-2](https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-channel_ready-message) -//! for more info). -//! - `Keysend` - send funds to a node without an invoice -//! (see the [`Keysend` feature assignment proposal](https://github.com/lightning/bolts/issues/605#issuecomment-606679798) for more information). -//! - `Trampoline` - supports receiving and forwarding Trampoline payments -//! (see the [`Trampoline` feature proposal](https://github.com/lightning/bolts/pull/836) 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). +//! Note that the use of types via this module is deprecated and will be removed in a future +//! version. Instead, use feature objects via [`lightning::types::features`]. //! +//! [`lightning::types::features`]: crate::types::features //! [BOLT #9]: https://github.com/lightning/bolts/blob/master/09-features.md -//! [messages]: crate::ln::msgs - -use alloc::str::FromStr; -use alloc::string::String; -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}; - -mod sealed { use alloc::str::FromStr; use alloc::string::String; @@ -96,3110 +25,115 @@ use crate::c_types::*; #[cfg(feature="no-std")] use alloc::{vec::Vec, boxed::Box}; -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn InitFeatures_set_data_loss_protect_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_data_loss_protect_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn InitFeatures_set_data_loss_protect_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_data_loss_protect_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_supports_data_loss_protect(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_data_loss_protect(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_data_loss_protect_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_data_loss_protect_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_data_loss_protect_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_data_loss_protect_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_supports_data_loss_protect(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_data_loss_protect(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_requires_data_loss_protect(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_data_loss_protect(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_requires_data_loss_protect(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_data_loss_protect(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn InitFeatures_set_initial_routing_sync_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_initial_routing_sync_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn InitFeatures_set_initial_routing_sync_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_initial_routing_sync_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_initial_routing_sync(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.initial_routing_sync(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn InitFeatures_set_upfront_shutdown_script_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_upfront_shutdown_script_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn InitFeatures_set_upfront_shutdown_script_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_upfront_shutdown_script_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_supports_upfront_shutdown_script(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_upfront_shutdown_script(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_upfront_shutdown_script_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_upfront_shutdown_script_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_upfront_shutdown_script_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_upfront_shutdown_script_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_supports_upfront_shutdown_script(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_upfront_shutdown_script(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_requires_upfront_shutdown_script(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_upfront_shutdown_script(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_requires_upfront_shutdown_script(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_upfront_shutdown_script(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn InitFeatures_set_gossip_queries_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_gossip_queries_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn InitFeatures_set_gossip_queries_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_gossip_queries_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_supports_gossip_queries(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_gossip_queries(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_gossip_queries_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_gossip_queries_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_gossip_queries_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_gossip_queries_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_supports_gossip_queries(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_gossip_queries(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_requires_gossip_queries(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_gossip_queries(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_requires_gossip_queries(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_gossip_queries(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn InitFeatures_set_variable_length_onion_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_variable_length_onion_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn InitFeatures_set_variable_length_onion_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_variable_length_onion_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_supports_variable_length_onion(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_variable_length_onion(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_variable_length_onion_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_variable_length_onion_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_variable_length_onion_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_variable_length_onion_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_supports_variable_length_onion(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_variable_length_onion(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -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 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 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 -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_requires_variable_length_onion(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_variable_length_onion(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_requires_variable_length_onion(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_variable_length_onion(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -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 -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn InitFeatures_set_static_remote_key_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_static_remote_key_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn InitFeatures_set_static_remote_key_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_static_remote_key_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_supports_static_remote_key(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_static_remote_key(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_static_remote_key_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_static_remote_key_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_static_remote_key_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_static_remote_key_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_supports_static_remote_key(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_static_remote_key(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn ChannelTypeFeatures_set_static_remote_key_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_static_remote_key_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn ChannelTypeFeatures_set_static_remote_key_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_static_remote_key_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelTypeFeatures_supports_static_remote_key(this_arg: &crate::lightning::ln::features::ChannelTypeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_static_remote_key(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_requires_static_remote_key(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_static_remote_key(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_requires_static_remote_key(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_static_remote_key(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelTypeFeatures_requires_static_remote_key(this_arg: &crate::lightning::ln::features::ChannelTypeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_static_remote_key(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn InitFeatures_set_payment_secret_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_payment_secret_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn InitFeatures_set_payment_secret_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_payment_secret_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_supports_payment_secret(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_payment_secret(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_payment_secret_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_payment_secret_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_payment_secret_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_payment_secret_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_supports_payment_secret(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_payment_secret(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -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 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 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 -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_requires_payment_secret(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_payment_secret(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_requires_payment_secret(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_payment_secret(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -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 -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn InitFeatures_set_basic_mpp_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_basic_mpp_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn InitFeatures_set_basic_mpp_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_basic_mpp_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_supports_basic_mpp(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_basic_mpp(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_basic_mpp_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_basic_mpp_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_basic_mpp_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_basic_mpp_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_supports_basic_mpp(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_basic_mpp(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -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 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 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 -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn Bolt12InvoiceFeatures_set_basic_mpp_optional(this_arg: &mut crate::lightning::ln::features::Bolt12InvoiceFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeBolt12InvoiceFeatures)) }.set_basic_mpp_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn Bolt12InvoiceFeatures_set_basic_mpp_required(this_arg: &mut crate::lightning::ln::features::Bolt12InvoiceFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeBolt12InvoiceFeatures)) }.set_basic_mpp_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn Bolt12InvoiceFeatures_supports_basic_mpp(this_arg: &crate::lightning::ln::features::Bolt12InvoiceFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_basic_mpp(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_requires_basic_mpp(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_basic_mpp(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_requires_basic_mpp(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_basic_mpp(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -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 -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn Bolt12InvoiceFeatures_requires_basic_mpp(this_arg: &crate::lightning::ln::features::Bolt12InvoiceFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_basic_mpp(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn InitFeatures_set_wumbo_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_wumbo_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn InitFeatures_set_wumbo_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_wumbo_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_supports_wumbo(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_wumbo(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_wumbo_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_wumbo_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_wumbo_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_wumbo_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_supports_wumbo(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_wumbo(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_requires_wumbo(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_wumbo(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_requires_wumbo(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_wumbo(); - 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) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInitFeatures)) }.set_anchors_zero_fee_htlc_tx_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn InitFeatures_set_anchors_zero_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_zero_fee_htlc_tx_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_supports_anchors_zero_fee_htlc_tx(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_anchors_zero_fee_htlc_tx(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_anchors_zero_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_zero_fee_htlc_tx_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_anchors_zero_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_zero_fee_htlc_tx_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_supports_anchors_zero_fee_htlc_tx(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_anchors_zero_fee_htlc_tx(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn ChannelTypeFeatures_set_anchors_zero_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_zero_fee_htlc_tx_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn ChannelTypeFeatures_set_anchors_zero_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_zero_fee_htlc_tx_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelTypeFeatures_supports_anchors_zero_fee_htlc_tx(this_arg: &crate::lightning::ln::features::ChannelTypeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_anchors_zero_fee_htlc_tx(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_requires_anchors_zero_fee_htlc_tx(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_anchors_zero_fee_htlc_tx(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_requires_anchors_zero_fee_htlc_tx(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_anchors_zero_fee_htlc_tx(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelTypeFeatures_requires_anchors_zero_fee_htlc_tx(this_arg: &crate::lightning::ln::features::ChannelTypeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_anchors_zero_fee_htlc_tx(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn InitFeatures_set_route_blinding_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_route_blinding_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn InitFeatures_set_route_blinding_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_route_blinding_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_supports_route_blinding(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_route_blinding(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_route_blinding_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_route_blinding_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_route_blinding_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_route_blinding_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_supports_route_blinding(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_route_blinding(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_requires_route_blinding(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_route_blinding(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_requires_route_blinding(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_route_blinding(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn InitFeatures_set_shutdown_any_segwit_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_shutdown_any_segwit_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn InitFeatures_set_shutdown_any_segwit_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_shutdown_any_segwit_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_supports_shutdown_anysegwit(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_shutdown_anysegwit(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_shutdown_any_segwit_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_shutdown_any_segwit_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_shutdown_any_segwit_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_shutdown_any_segwit_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_supports_shutdown_anysegwit(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_shutdown_anysegwit(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_requires_shutdown_anysegwit(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_shutdown_anysegwit(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_requires_shutdown_anysegwit(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_shutdown_anysegwit(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn InitFeatures_set_taproot_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_taproot_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn InitFeatures_set_taproot_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_taproot_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_supports_taproot(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_taproot(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_taproot_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_taproot_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_taproot_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_taproot_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_supports_taproot(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_taproot(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn ChannelTypeFeatures_set_taproot_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_taproot_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn ChannelTypeFeatures_set_taproot_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_taproot_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelTypeFeatures_supports_taproot(this_arg: &crate::lightning::ln::features::ChannelTypeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_taproot(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_requires_taproot(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_taproot(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_requires_taproot(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_taproot(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelTypeFeatures_requires_taproot(this_arg: &crate::lightning::ln::features::ChannelTypeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_taproot(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn InitFeatures_set_onion_messages_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_onion_messages_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn InitFeatures_set_onion_messages_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_onion_messages_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_supports_onion_messages(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_onion_messages(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_onion_messages_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_onion_messages_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_onion_messages_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_onion_messages_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_supports_onion_messages(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_onion_messages(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_requires_onion_messages(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_onion_messages(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_requires_onion_messages(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_onion_messages(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn InitFeatures_set_channel_type_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_channel_type_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn InitFeatures_set_channel_type_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_channel_type_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_supports_channel_type(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_channel_type(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_channel_type_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_channel_type_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_channel_type_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_channel_type_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_supports_channel_type(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_channel_type(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_requires_channel_type(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_channel_type(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_requires_channel_type(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_channel_type(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn InitFeatures_set_scid_privacy_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_scid_privacy_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn InitFeatures_set_scid_privacy_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_scid_privacy_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_supports_scid_privacy(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_scid_privacy(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_scid_privacy_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_scid_privacy_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_scid_privacy_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_scid_privacy_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_supports_scid_privacy(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_scid_privacy(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn ChannelTypeFeatures_set_scid_privacy_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_scid_privacy_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn ChannelTypeFeatures_set_scid_privacy_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_scid_privacy_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelTypeFeatures_supports_scid_privacy(this_arg: &crate::lightning::ln::features::ChannelTypeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_scid_privacy(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_requires_scid_privacy(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_scid_privacy(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_requires_scid_privacy(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_scid_privacy(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelTypeFeatures_requires_scid_privacy(this_arg: &crate::lightning::ln::features::ChannelTypeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_scid_privacy(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -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 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 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 -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -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 -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn InitFeatures_set_zero_conf_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_zero_conf_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn InitFeatures_set_zero_conf_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_zero_conf_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_supports_zero_conf(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_zero_conf(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_zero_conf_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_zero_conf_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_zero_conf_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_zero_conf_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_supports_zero_conf(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_zero_conf(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn ChannelTypeFeatures_set_zero_conf_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_zero_conf_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn ChannelTypeFeatures_set_zero_conf_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_zero_conf_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelTypeFeatures_supports_zero_conf(this_arg: &crate::lightning::ln::features::ChannelTypeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_zero_conf(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_requires_zero_conf(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_zero_conf(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_requires_zero_conf(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_zero_conf(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelTypeFeatures_requires_zero_conf(this_arg: &crate::lightning::ln::features::ChannelTypeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_zero_conf(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_keysend_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_keysend_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_keysend_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_keysend_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_supports_keysend(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_keysend(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_requires_keysend(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_keysend(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn InitFeatures_set_trampoline_routing_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_trampoline_routing_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn InitFeatures_set_trampoline_routing_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_trampoline_routing_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_supports_trampoline_routing(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_trampoline_routing(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_trampoline_routing_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_trampoline_routing_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_trampoline_routing_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_trampoline_routing_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_supports_trampoline_routing(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_trampoline_routing(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn Bolt11InvoiceFeatures_set_trampoline_routing_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_trampoline_routing_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn Bolt11InvoiceFeatures_set_trampoline_routing_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_trampoline_routing_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn Bolt11InvoiceFeatures_supports_trampoline_routing(this_arg: &crate::lightning::ln::features::Bolt11InvoiceFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_trampoline_routing(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_requires_trampoline_routing(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_trampoline_routing(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_requires_trampoline_routing(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_trampoline_routing(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn Bolt11InvoiceFeatures_requires_trampoline_routing(this_arg: &crate::lightning::ln::features::Bolt11InvoiceFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_trampoline_routing(); - ret -} - -} -/// 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. -#[no_mangle] -pub extern "C" fn InitFeatures_eq(a: &InitFeatures, b: &InitFeatures) -> 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 } -} -/// 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. -#[no_mangle] -pub extern "C" fn NodeFeatures_eq(a: &NodeFeatures, b: &NodeFeatures) -> 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 } -} -/// 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. -#[no_mangle] -pub extern "C" fn ChannelFeatures_eq(a: &ChannelFeatures, b: &ChannelFeatures) -> 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 } -} -/// 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 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 } -} -/// 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. -#[no_mangle] -pub extern "C" fn OfferFeatures_eq(a: &OfferFeatures, b: &OfferFeatures) -> 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 } -} -/// 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. -#[no_mangle] -pub extern "C" fn InvoiceRequestFeatures_eq(a: &InvoiceRequestFeatures, b: &InvoiceRequestFeatures) -> 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 } -} -/// 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. -#[no_mangle] -pub extern "C" fn Bolt12InvoiceFeatures_eq(a: &Bolt12InvoiceFeatures, b: &Bolt12InvoiceFeatures) -> 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 } -} -/// 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. -#[no_mangle] -pub extern "C" fn BlindedHopFeatures_eq(a: &BlindedHopFeatures, b: &BlindedHopFeatures) -> 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 } -} -/// 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. -#[no_mangle] -pub extern "C" fn ChannelTypeFeatures_eq(a: &ChannelTypeFeatures, b: &ChannelTypeFeatures) -> 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 InitFeatures { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeInitFeatures>::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 InitFeatures_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeInitFeatures)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the InitFeatures -pub extern "C" fn InitFeatures_clone(orig: &InitFeatures) -> InitFeatures { - orig.clone() -} -impl Clone for NodeFeatures { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeNodeFeatures>::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 NodeFeatures_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeNodeFeatures)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the NodeFeatures -pub extern "C" fn NodeFeatures_clone(orig: &NodeFeatures) -> NodeFeatures { - orig.clone() -} -impl Clone for ChannelFeatures { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeChannelFeatures>::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 ChannelFeatures_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeChannelFeatures)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the ChannelFeatures -pub extern "C" fn ChannelFeatures_clone(orig: &ChannelFeatures) -> ChannelFeatures { - orig.clone() -} -impl Clone for Bolt11InvoiceFeatures { - fn clone(&self) -> Self { - Self { - 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, - } - } -} -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -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 *const nativeBolt11InvoiceFeatures)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the Bolt11InvoiceFeatures -pub extern "C" fn Bolt11InvoiceFeatures_clone(orig: &Bolt11InvoiceFeatures) -> Bolt11InvoiceFeatures { - orig.clone() -} -impl Clone for OfferFeatures { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeOfferFeatures>::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 OfferFeatures_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeOfferFeatures)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the OfferFeatures -pub extern "C" fn OfferFeatures_clone(orig: &OfferFeatures) -> OfferFeatures { - orig.clone() -} -impl Clone for InvoiceRequestFeatures { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeInvoiceRequestFeatures>::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 InvoiceRequestFeatures_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeInvoiceRequestFeatures)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the InvoiceRequestFeatures -pub extern "C" fn InvoiceRequestFeatures_clone(orig: &InvoiceRequestFeatures) -> InvoiceRequestFeatures { - orig.clone() -} -impl Clone for Bolt12InvoiceFeatures { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeBolt12InvoiceFeatures>::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 Bolt12InvoiceFeatures_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeBolt12InvoiceFeatures)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the Bolt12InvoiceFeatures -pub extern "C" fn Bolt12InvoiceFeatures_clone(orig: &Bolt12InvoiceFeatures) -> Bolt12InvoiceFeatures { - orig.clone() -} -impl Clone for BlindedHopFeatures { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeBlindedHopFeatures>::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 BlindedHopFeatures_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeBlindedHopFeatures)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the BlindedHopFeatures -pub extern "C" fn BlindedHopFeatures_clone(orig: &BlindedHopFeatures) -> BlindedHopFeatures { - orig.clone() -} -impl Clone for ChannelTypeFeatures { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeChannelTypeFeatures>::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 ChannelTypeFeatures_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeChannelTypeFeatures)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the ChannelTypeFeatures -pub extern "C" fn ChannelTypeFeatures_clone(orig: &ChannelTypeFeatures) -> ChannelTypeFeatures { - orig.clone() -} -/// Generates a non-cryptographic 64-bit hash of the InitFeatures. -#[no_mangle] -pub extern "C" fn InitFeatures_hash(o: &InitFeatures) -> 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) -} -/// Generates a non-cryptographic 64-bit hash of the NodeFeatures. -#[no_mangle] -pub extern "C" fn NodeFeatures_hash(o: &NodeFeatures) -> 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) -} -/// Generates a non-cryptographic 64-bit hash of the ChannelFeatures. -#[no_mangle] -pub extern "C" fn ChannelFeatures_hash(o: &ChannelFeatures) -> 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) -} -/// Generates a non-cryptographic 64-bit hash of the Bolt11InvoiceFeatures. -#[no_mangle] -pub extern "C" fn Bolt11InvoiceFeatures_hash(o: &Bolt11InvoiceFeatures) -> 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) -} -/// Generates a non-cryptographic 64-bit hash of the OfferFeatures. -#[no_mangle] -pub extern "C" fn OfferFeatures_hash(o: &OfferFeatures) -> 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) -} -/// Generates a non-cryptographic 64-bit hash of the InvoiceRequestFeatures. -#[no_mangle] -pub extern "C" fn InvoiceRequestFeatures_hash(o: &InvoiceRequestFeatures) -> 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) -} -/// Generates a non-cryptographic 64-bit hash of the Bolt12InvoiceFeatures. -#[no_mangle] -pub extern "C" fn Bolt12InvoiceFeatures_hash(o: &Bolt12InvoiceFeatures) -> 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) -} -/// Generates a non-cryptographic 64-bit hash of the BlindedHopFeatures. -#[no_mangle] -pub extern "C" fn BlindedHopFeatures_hash(o: &BlindedHopFeatures) -> 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) -} -/// Generates a non-cryptographic 64-bit hash of the ChannelTypeFeatures. -#[no_mangle] -pub extern "C" fn ChannelTypeFeatures_hash(o: &ChannelTypeFeatures) -> 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) -} -/// Get a string which allows debug introspection of a InitFeatures object -pub extern "C" fn InitFeatures_debug_str_void(o: *const c_void) -> Str { - alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::features::InitFeatures }).into()} -/// Get a string which allows debug introspection of a NodeFeatures object -pub extern "C" fn NodeFeatures_debug_str_void(o: *const c_void) -> Str { - alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::features::NodeFeatures }).into()} -/// Get a string which allows debug introspection of a ChannelFeatures object -pub extern "C" fn ChannelFeatures_debug_str_void(o: *const c_void) -> Str { - alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::features::ChannelFeatures }).into()} -/// Get a string which allows debug introspection of a Bolt11InvoiceFeatures object -pub extern "C" fn Bolt11InvoiceFeatures_debug_str_void(o: *const c_void) -> Str { - alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::features::Bolt11InvoiceFeatures }).into()} -/// Get a string which allows debug introspection of a OfferFeatures object -pub extern "C" fn OfferFeatures_debug_str_void(o: *const c_void) -> Str { - alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::features::OfferFeatures }).into()} -/// Get a string which allows debug introspection of a InvoiceRequestFeatures object -pub extern "C" fn InvoiceRequestFeatures_debug_str_void(o: *const c_void) -> Str { - alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::features::InvoiceRequestFeatures }).into()} -/// Get a string which allows debug introspection of a Bolt12InvoiceFeatures object -pub extern "C" fn Bolt12InvoiceFeatures_debug_str_void(o: *const c_void) -> Str { - alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::features::Bolt12InvoiceFeatures }).into()} -/// Get a string which allows debug introspection of a BlindedHopFeatures object -pub extern "C" fn BlindedHopFeatures_debug_str_void(o: *const c_void) -> Str { - alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::features::BlindedHopFeatures }).into()} -/// Get a string which allows debug introspection of a ChannelTypeFeatures object -pub extern "C" fn ChannelTypeFeatures_debug_str_void(o: *const c_void) -> Str { - alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::features::ChannelTypeFeatures }).into()} - -use lightning::ln::features::InitFeatures as nativeInitFeaturesImport; -pub(crate) type nativeInitFeatures = nativeInitFeaturesImport; - -/// Features used within an `init` message. -#[must_use] -#[repr(C)] -pub struct InitFeatures { - /// A pointer to the opaque Rust object. - - /// Nearly everywhere, 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 nativeInitFeatures, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust 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 InitFeatures { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeInitFeatures>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; - } - } -} -/// Frees any resources used by the InitFeatures, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn InitFeatures_free(this_obj: InitFeatures) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn InitFeatures_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeInitFeatures) }; -} -#[allow(unused)] -impl InitFeatures { - pub(crate) fn get_native_ref(&self) -> &'static nativeInitFeatures { - unsafe { &*ObjOps::untweak_ptr(self.inner) } - } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInitFeatures { - 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 nativeInitFeatures { - assert!(self.is_owned); - let ret = ObjOps::untweak_ptr(self.inner); - self.inner = core::ptr::null_mut(); - ret - } -} - -use lightning::ln::features::NodeFeatures as nativeNodeFeaturesImport; -pub(crate) type nativeNodeFeatures = nativeNodeFeaturesImport; - -/// Features used within a `node_announcement` message. -#[must_use] -#[repr(C)] -pub struct NodeFeatures { - /// A pointer to the opaque Rust object. - - /// Nearly everywhere, 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 nativeNodeFeatures, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust 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 NodeFeatures { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeNodeFeatures>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; - } - } -} -/// Frees any resources used by the NodeFeatures, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn NodeFeatures_free(this_obj: NodeFeatures) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn NodeFeatures_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeNodeFeatures) }; -} -#[allow(unused)] -impl NodeFeatures { - pub(crate) fn get_native_ref(&self) -> &'static nativeNodeFeatures { - unsafe { &*ObjOps::untweak_ptr(self.inner) } - } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeNodeFeatures { - 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 nativeNodeFeatures { - assert!(self.is_owned); - let ret = ObjOps::untweak_ptr(self.inner); - self.inner = core::ptr::null_mut(); - ret - } -} - -use lightning::ln::features::ChannelFeatures as nativeChannelFeaturesImport; -pub(crate) type nativeChannelFeatures = nativeChannelFeaturesImport; - -/// Features used within a `channel_announcement` message. -#[must_use] -#[repr(C)] -pub struct ChannelFeatures { - /// A pointer to the opaque Rust object. - - /// Nearly everywhere, 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 nativeChannelFeatures, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust 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 ChannelFeatures { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeChannelFeatures>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; - } - } -} -/// Frees any resources used by the ChannelFeatures, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn ChannelFeatures_free(this_obj: ChannelFeatures) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn ChannelFeatures_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelFeatures) }; -} -#[allow(unused)] -impl ChannelFeatures { - pub(crate) fn get_native_ref(&self) -> &'static nativeChannelFeatures { - unsafe { &*ObjOps::untweak_ptr(self.inner) } - } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelFeatures { - 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 nativeChannelFeatures { - assert!(self.is_owned); - let ret = ObjOps::untweak_ptr(self.inner); - self.inner = core::ptr::null_mut(); - ret - } -} - -use lightning::ln::features::Bolt11InvoiceFeatures as nativeBolt11InvoiceFeaturesImport; -pub(crate) type nativeBolt11InvoiceFeatures = nativeBolt11InvoiceFeaturesImport; - -/// Features used within an invoice. -#[must_use] -#[repr(C)] -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 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 - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for Bolt11InvoiceFeatures { - fn drop(&mut self) { - 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 Bolt11InvoiceFeatures, if is_owned is set and inner is non-NULL. -#[no_mangle] -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 Bolt11InvoiceFeatures_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeBolt11InvoiceFeatures) }; -} -#[allow(unused)] -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 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 nativeBolt11InvoiceFeatures { - assert!(self.is_owned); - let ret = ObjOps::untweak_ptr(self.inner); - self.inner = core::ptr::null_mut(); - ret - } -} - -use lightning::ln::features::OfferFeatures as nativeOfferFeaturesImport; -pub(crate) type nativeOfferFeatures = nativeOfferFeaturesImport; - -/// Features used within an `offer`. -#[must_use] -#[repr(C)] -pub struct OfferFeatures { - /// A pointer to the opaque Rust object. - - /// Nearly everywhere, 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 nativeOfferFeatures, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust 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 OfferFeatures { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeOfferFeatures>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; - } - } -} -/// Frees any resources used by the OfferFeatures, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn OfferFeatures_free(this_obj: OfferFeatures) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn OfferFeatures_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeOfferFeatures) }; -} -#[allow(unused)] -impl OfferFeatures { - pub(crate) fn get_native_ref(&self) -> &'static nativeOfferFeatures { - unsafe { &*ObjOps::untweak_ptr(self.inner) } - } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOfferFeatures { - 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 nativeOfferFeatures { - assert!(self.is_owned); - let ret = ObjOps::untweak_ptr(self.inner); - self.inner = core::ptr::null_mut(); - ret - } -} - -use lightning::ln::features::InvoiceRequestFeatures as nativeInvoiceRequestFeaturesImport; -pub(crate) type nativeInvoiceRequestFeatures = nativeInvoiceRequestFeaturesImport; - -/// Features used within an `invoice_request`. -#[must_use] -#[repr(C)] -pub struct InvoiceRequestFeatures { - /// A pointer to the opaque Rust object. - - /// Nearly everywhere, 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 nativeInvoiceRequestFeatures, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust 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 InvoiceRequestFeatures { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeInvoiceRequestFeatures>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; - } - } -} -/// Frees any resources used by the InvoiceRequestFeatures, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn InvoiceRequestFeatures_free(this_obj: InvoiceRequestFeatures) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn InvoiceRequestFeatures_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeInvoiceRequestFeatures) }; -} -#[allow(unused)] -impl InvoiceRequestFeatures { - pub(crate) fn get_native_ref(&self) -> &'static nativeInvoiceRequestFeatures { - unsafe { &*ObjOps::untweak_ptr(self.inner) } - } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInvoiceRequestFeatures { - 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 nativeInvoiceRequestFeatures { - assert!(self.is_owned); - let ret = ObjOps::untweak_ptr(self.inner); - self.inner = core::ptr::null_mut(); - ret - } -} - -use lightning::ln::features::Bolt12InvoiceFeatures as nativeBolt12InvoiceFeaturesImport; -pub(crate) type nativeBolt12InvoiceFeatures = nativeBolt12InvoiceFeaturesImport; - -/// Features used within an `invoice`. -#[must_use] -#[repr(C)] -pub struct Bolt12InvoiceFeatures { - /// A pointer to the opaque Rust object. - - /// Nearly everywhere, 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 nativeBolt12InvoiceFeatures, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust 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 Bolt12InvoiceFeatures { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeBolt12InvoiceFeatures>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; - } - } -} -/// Frees any resources used by the Bolt12InvoiceFeatures, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn Bolt12InvoiceFeatures_free(this_obj: Bolt12InvoiceFeatures) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn Bolt12InvoiceFeatures_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeBolt12InvoiceFeatures) }; -} -#[allow(unused)] -impl Bolt12InvoiceFeatures { - pub(crate) fn get_native_ref(&self) -> &'static nativeBolt12InvoiceFeatures { - unsafe { &*ObjOps::untweak_ptr(self.inner) } - } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeBolt12InvoiceFeatures { - 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 nativeBolt12InvoiceFeatures { - assert!(self.is_owned); - let ret = ObjOps::untweak_ptr(self.inner); - self.inner = core::ptr::null_mut(); - ret - } -} - -use lightning::ln::features::BlindedHopFeatures as nativeBlindedHopFeaturesImport; -pub(crate) type nativeBlindedHopFeatures = nativeBlindedHopFeaturesImport; - -/// Features used within BOLT 4 encrypted_data_tlv and BOLT 12 blinded_payinfo -#[must_use] -#[repr(C)] -pub struct BlindedHopFeatures { - /// A pointer to the opaque Rust object. - - /// Nearly everywhere, 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 nativeBlindedHopFeatures, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust 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 BlindedHopFeatures { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeBlindedHopFeatures>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; - } - } -} -/// Frees any resources used by the BlindedHopFeatures, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn BlindedHopFeatures_free(this_obj: BlindedHopFeatures) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn BlindedHopFeatures_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeBlindedHopFeatures) }; -} -#[allow(unused)] -impl BlindedHopFeatures { - pub(crate) fn get_native_ref(&self) -> &'static nativeBlindedHopFeatures { - unsafe { &*ObjOps::untweak_ptr(self.inner) } - } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeBlindedHopFeatures { - 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 nativeBlindedHopFeatures { - assert!(self.is_owned); - let ret = ObjOps::untweak_ptr(self.inner); - self.inner = core::ptr::null_mut(); - ret - } -} - -use lightning::ln::features::ChannelTypeFeatures as nativeChannelTypeFeaturesImport; -pub(crate) type nativeChannelTypeFeatures = nativeChannelTypeFeaturesImport; - -/// Features used within the channel_type field in an OpenChannel message. -/// -/// A channel is always of some known \"type\", describing the transaction formats used and the exact -/// semantics of our interaction with our peer. -/// -/// Note that because a channel is a specific type which is proposed by the opener and accepted by -/// the counterparty, only required features are allowed here. -/// -/// This is serialized differently from other feature types - it is not prefixed by a length, and -/// thus must only appear inside a TLV where its length is known in advance. -#[must_use] -#[repr(C)] -pub struct ChannelTypeFeatures { - /// A pointer to the opaque Rust object. - - /// Nearly everywhere, 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 nativeChannelTypeFeatures, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust 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 ChannelTypeFeatures { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeChannelTypeFeatures>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; - } - } -} -/// Frees any resources used by the ChannelTypeFeatures, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn ChannelTypeFeatures_free(this_obj: ChannelTypeFeatures) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn ChannelTypeFeatures_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelTypeFeatures) }; -} -#[allow(unused)] -impl ChannelTypeFeatures { - pub(crate) fn get_native_ref(&self) -> &'static nativeChannelTypeFeatures { - unsafe { &*ObjOps::untweak_ptr(self.inner) } - } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelTypeFeatures { - 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 nativeChannelTypeFeatures { - assert!(self.is_owned); - let ret = ObjOps::untweak_ptr(self.inner); - self.inner = core::ptr::null_mut(); - ret - } -} -/// Create a blank Features with no features set -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_empty() -> crate::lightning::ln::features::InitFeatures { - let mut ret = lightning::ln::features::InitFeatures::empty(); - 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] -#[no_mangle] -pub extern "C" fn InitFeatures_requires_unknown_bits(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits(); - ret -} - -/// Sets a required feature bit. Errors if `bit` is outside the feature range as defined -/// by [BOLT 9]. -/// -/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will -/// be set instead (i.e., `bit - 1`). -/// -/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_set_required_feature_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_feature_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 feature bit. Errors if `bit` is outside the feature range as defined -/// by [BOLT 9]. -/// -/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be -/// set instead (i.e., `bit + 1`). -/// -/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_set_optional_feature_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_feature_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 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] -pub extern "C" fn NodeFeatures_empty() -> crate::lightning::ln::features::NodeFeatures { - let mut ret = lightning::ln::features::NodeFeatures::empty(); - 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] -#[no_mangle] -pub extern "C" fn NodeFeatures_requires_unknown_bits(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits(); - ret -} - -/// Sets a required feature bit. Errors if `bit` is outside the feature range as defined -/// by [BOLT 9]. -/// -/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will -/// be set instead (i.e., `bit - 1`). -/// -/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_set_required_feature_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_feature_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 feature bit. Errors if `bit` is outside the feature range as defined -/// by [BOLT 9]. -/// -/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be -/// set instead (i.e., `bit + 1`). -/// -/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_set_optional_feature_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_feature_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 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] -pub extern "C" fn ChannelFeatures_empty() -> crate::lightning::ln::features::ChannelFeatures { - let mut ret = lightning::ln::features::ChannelFeatures::empty(); - 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] -#[no_mangle] -pub extern "C" fn ChannelFeatures_requires_unknown_bits(this_arg: &crate::lightning::ln::features::ChannelFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits(); - ret -} - -/// Sets a required feature bit. Errors if `bit` is outside the feature range as defined -/// by [BOLT 9]. -/// -/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will -/// be set instead (i.e., `bit - 1`). -/// -/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelFeatures_set_required_feature_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_feature_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 feature bit. Errors if `bit` is outside the feature range as defined -/// by [BOLT 9]. -/// -/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be -/// set instead (i.e., `bit + 1`). -/// -/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelFeatures_set_optional_feature_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_feature_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 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 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 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 feature bit. Errors if `bit` is outside the feature range as defined -/// by [BOLT 9]. -/// -/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will -/// be set instead (i.e., `bit - 1`). -/// -/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md -#[must_use] -#[no_mangle] -pub extern "C" fn Bolt11InvoiceFeatures_set_required_feature_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_feature_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 feature bit. Errors if `bit` is outside the feature range as defined -/// by [BOLT 9]. -/// -/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be -/// set instead (i.e., `bit + 1`). -/// -/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md -#[must_use] -#[no_mangle] -pub extern "C" fn Bolt11InvoiceFeatures_set_optional_feature_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_feature_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 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] -pub extern "C" fn OfferFeatures_empty() -> crate::lightning::ln::features::OfferFeatures { - let mut ret = lightning::ln::features::OfferFeatures::empty(); - 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] -#[no_mangle] -pub extern "C" fn OfferFeatures_requires_unknown_bits(this_arg: &crate::lightning::ln::features::OfferFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits(); - ret -} - -/// Sets a required feature bit. Errors if `bit` is outside the feature range as defined -/// by [BOLT 9]. -/// -/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will -/// be set instead (i.e., `bit - 1`). -/// -/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md -#[must_use] -#[no_mangle] -pub extern "C" fn OfferFeatures_set_required_feature_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_feature_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 feature bit. Errors if `bit` is outside the feature range as defined -/// by [BOLT 9]. -/// -/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be -/// set instead (i.e., `bit + 1`). -/// -/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md -#[must_use] -#[no_mangle] -pub extern "C" fn OfferFeatures_set_optional_feature_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_feature_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 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] -pub extern "C" fn InvoiceRequestFeatures_empty() -> crate::lightning::ln::features::InvoiceRequestFeatures { - let mut ret = lightning::ln::features::InvoiceRequestFeatures::empty(); - 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] -#[no_mangle] -pub extern "C" fn InvoiceRequestFeatures_requires_unknown_bits(this_arg: &crate::lightning::ln::features::InvoiceRequestFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits(); - ret -} - -/// Sets a required feature bit. Errors if `bit` is outside the feature range as defined -/// by [BOLT 9]. -/// -/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will -/// be set instead (i.e., `bit - 1`). -/// -/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md -#[must_use] -#[no_mangle] -pub extern "C" fn InvoiceRequestFeatures_set_required_feature_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_feature_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 feature bit. Errors if `bit` is outside the feature range as defined -/// by [BOLT 9]. -/// -/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be -/// set instead (i.e., `bit + 1`). -/// -/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md -#[must_use] -#[no_mangle] -pub extern "C" fn InvoiceRequestFeatures_set_optional_feature_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_feature_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 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] -pub extern "C" fn Bolt12InvoiceFeatures_empty() -> crate::lightning::ln::features::Bolt12InvoiceFeatures { - let mut ret = lightning::ln::features::Bolt12InvoiceFeatures::empty(); - 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] -#[no_mangle] -pub extern "C" fn Bolt12InvoiceFeatures_requires_unknown_bits(this_arg: &crate::lightning::ln::features::Bolt12InvoiceFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits(); - ret -} - -/// Sets a required feature bit. Errors if `bit` is outside the feature range as defined -/// by [BOLT 9]. -/// -/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will -/// be set instead (i.e., `bit - 1`). -/// -/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md -#[must_use] -#[no_mangle] -pub extern "C" fn Bolt12InvoiceFeatures_set_required_feature_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_feature_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 feature bit. Errors if `bit` is outside the feature range as defined -/// by [BOLT 9]. -/// -/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be -/// set instead (i.e., `bit + 1`). -/// -/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md -#[must_use] -#[no_mangle] -pub extern "C" fn Bolt12InvoiceFeatures_set_optional_feature_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_feature_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 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] -pub extern "C" fn BlindedHopFeatures_empty() -> crate::lightning::ln::features::BlindedHopFeatures { - let mut ret = lightning::ln::features::BlindedHopFeatures::empty(); - 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] -#[no_mangle] -pub extern "C" fn BlindedHopFeatures_requires_unknown_bits(this_arg: &crate::lightning::ln::features::BlindedHopFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits(); - ret -} - -/// Sets a required feature bit. Errors if `bit` is outside the feature range as defined -/// by [BOLT 9]. -/// -/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will -/// be set instead (i.e., `bit - 1`). -/// -/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md -#[must_use] -#[no_mangle] -pub extern "C" fn BlindedHopFeatures_set_required_feature_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_feature_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 feature bit. Errors if `bit` is outside the feature range as defined -/// by [BOLT 9]. -/// -/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be -/// set instead (i.e., `bit + 1`). -/// -/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md -#[must_use] -#[no_mangle] -pub extern "C" fn BlindedHopFeatures_set_optional_feature_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_feature_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 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] -pub extern "C" fn ChannelTypeFeatures_empty() -> crate::lightning::ln::features::ChannelTypeFeatures { - let mut ret = lightning::ln::features::ChannelTypeFeatures::empty(); - 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] -#[no_mangle] -pub extern "C" fn ChannelTypeFeatures_requires_unknown_bits(this_arg: &crate::lightning::ln::features::ChannelTypeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits(); - ret -} - -/// Sets a required feature bit. Errors if `bit` is outside the feature range as defined -/// by [BOLT 9]. -/// -/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will -/// be set instead (i.e., `bit - 1`). -/// -/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelTypeFeatures_set_required_feature_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_feature_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 feature bit. Errors if `bit` is outside the feature range as defined -/// by [BOLT 9]. -/// -/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be -/// set instead (i.e., `bit + 1`). -/// -/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelTypeFeatures_set_optional_feature_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_feature_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 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 { +pub extern "C" fn InitFeatures_write(obj: &crate::lightning_types::features::InitFeatures) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) } #[allow(unused)] pub(crate) extern "C" fn InitFeatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInitFeatures) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning_types::features::nativeInitFeatures) }) } #[no_mangle] /// Read a InitFeatures from a byte array, created by InitFeatures_write pub extern "C" fn InitFeatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_InitFeaturesDecodeErrorZ { - 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::InitFeatures { 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() }; + 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_types::features::InitFeatures { 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 ChannelFeatures object into a byte array which can be read by ChannelFeatures_read -pub extern "C" fn ChannelFeatures_write(obj: &crate::lightning::ln::features::ChannelFeatures) -> crate::c_types::derived::CVec_u8Z { +pub extern "C" fn ChannelFeatures_write(obj: &crate::lightning_types::features::ChannelFeatures) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) } #[allow(unused)] pub(crate) extern "C" fn ChannelFeatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelFeatures) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning_types::features::nativeChannelFeatures) }) } #[no_mangle] /// Read a ChannelFeatures from a byte array, created by ChannelFeatures_write pub extern "C" fn ChannelFeatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelFeaturesDecodeErrorZ { - 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::ChannelFeatures { 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() }; + 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_types::features::ChannelFeatures { 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 NodeFeatures object into a byte array which can be read by NodeFeatures_read -pub extern "C" fn NodeFeatures_write(obj: &crate::lightning::ln::features::NodeFeatures) -> crate::c_types::derived::CVec_u8Z { +pub extern "C" fn NodeFeatures_write(obj: &crate::lightning_types::features::NodeFeatures) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) } #[allow(unused)] pub(crate) extern "C" fn NodeFeatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeFeatures) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning_types::features::nativeNodeFeatures) }) } #[no_mangle] /// Read a NodeFeatures from a byte array, created by NodeFeatures_write pub extern "C" fn NodeFeatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NodeFeaturesDecodeErrorZ { - 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::NodeFeatures { 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() }; + 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_types::features::NodeFeatures { 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 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 { +pub extern "C" fn Bolt11InvoiceFeatures_write(obj: &crate::lightning_types::features::Bolt11InvoiceFeatures) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) } #[allow(unused)] 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) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning_types::features::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() }; + 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_types::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 { +pub extern "C" fn Bolt12InvoiceFeatures_write(obj: &crate::lightning_types::features::Bolt12InvoiceFeatures) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) } #[allow(unused)] 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) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning_types::features::nativeBolt12InvoiceFeatures) }) } #[no_mangle] /// 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() }; + 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_types::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] /// Serialize the BlindedHopFeatures object into a byte array which can be read by BlindedHopFeatures_read -pub extern "C" fn BlindedHopFeatures_write(obj: &crate::lightning::ln::features::BlindedHopFeatures) -> crate::c_types::derived::CVec_u8Z { +pub extern "C" fn BlindedHopFeatures_write(obj: &crate::lightning_types::features::BlindedHopFeatures) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) } #[allow(unused)] pub(crate) extern "C" fn BlindedHopFeatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeBlindedHopFeatures) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning_types::features::nativeBlindedHopFeatures) }) } #[no_mangle] /// Read a BlindedHopFeatures from a byte array, created by BlindedHopFeatures_write pub extern "C" fn BlindedHopFeatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_BlindedHopFeaturesDecodeErrorZ { - 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::BlindedHopFeatures { 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() }; + 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_types::features::BlindedHopFeatures { 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 ChannelTypeFeatures object into a byte array which can be read by ChannelTypeFeatures_read -pub extern "C" fn ChannelTypeFeatures_write(obj: &crate::lightning::ln::features::ChannelTypeFeatures) -> crate::c_types::derived::CVec_u8Z { +pub extern "C" fn ChannelTypeFeatures_write(obj: &crate::lightning_types::features::ChannelTypeFeatures) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) } #[allow(unused)] pub(crate) extern "C" fn ChannelTypeFeatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelTypeFeatures) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning_types::features::nativeChannelTypeFeatures) }) } #[no_mangle] /// Read a ChannelTypeFeatures from a byte array, created by ChannelTypeFeatures_write pub extern "C" fn ChannelTypeFeatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelTypeFeaturesDecodeErrorZ { - 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::ChannelTypeFeatures { 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() }; + 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_types::features::ChannelTypeFeatures { 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/ln/inbound_payment.rs b/lightning-c-bindings/src/lightning/ln/inbound_payment.rs index a5f5fb4..3d8972c 100644 --- a/lightning-c-bindings/src/lightning/ln/inbound_payment.rs +++ b/lightning-c-bindings/src/lightning/ln/inbound_payment.rs @@ -40,6 +40,12 @@ pub struct ExpandedKey { pub is_owned: bool, } +impl core::ops::Deref for ExpandedKey { + type Target = nativeExpandedKey; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ExpandedKey { } +unsafe impl core::marker::Sync for ExpandedKey { } impl Drop for ExpandedKey { fn drop(&mut self) { if self.is_owned && !<*mut nativeExpandedKey>::is_null(self.inner) { @@ -70,6 +76,9 @@ impl ExpandedKey { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Create a new [`ExpandedKey`] for generating an inbound payment hash and secret. /// diff --git a/lightning-c-bindings/src/lightning/ln/invoice_utils.rs b/lightning-c-bindings/src/lightning/ln/invoice_utils.rs new file mode 100644 index 0000000..b9835c8 --- /dev/null +++ b/lightning-c-bindings/src/lightning/ln/invoice_utils.rs @@ -0,0 +1,205 @@ +// 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. + +//! Convenient utilities to create an invoice. + +use alloc::str::FromStr; +use alloc::string::String; +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}; + +/// 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. +/// +/// `phantom_route_hints` parameter: +/// * Contains channel info for all nodes participating in the phantom invoice +/// * Entries are retrieved from a call to [`ChannelManager::get_phantom_route_hints`] on each +/// 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 +/// +/// `payment_hash` can be specified if you have a specific need for a custom payment hash (see the difference +/// between [`ChannelManager::create_inbound_payment`] and [`ChannelManager::create_inbound_payment_for_hash`]). +/// If `None` is provided for `payment_hash`, then one will be created. +/// +/// `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for +/// in excess of the current time. +/// +/// `duration_since_epoch` is the current time since epoch in seconds. +/// +/// You can specify a custom `min_final_cltv_expiry_delta`, or let LDK default it to +/// [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. The provided expiry must be at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`] - 3. +/// Note that LDK will add a buffer of 3 blocks to the delta to allow for up to a few new block +/// confirmations during routing. +/// +/// Note that the provided `keys_manager`'s `NodeSigner` implementation must support phantom +/// invoices in its `sign_invoice` implementation ([`PhantomKeysManager`] satisfies this +/// requirement). +/// +/// [`PhantomKeysManager`]: crate::sign::PhantomKeysManager +/// [`ChannelManager::get_phantom_route_hints`]: crate::ln::channelmanager::ChannelManager::get_phantom_route_hints +/// [`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 +/// [`PhantomRouteHints::channels`]: crate::ln::channelmanager::PhantomRouteHints::channels +/// [`MIN_FINAL_CLTV_EXPIRY_DETLA`]: crate::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA +/// +/// 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. +#[no_mangle] +pub extern "C" fn create_phantom_invoice(mut amt_msat: crate::c_types::derived::COption_u64Z, mut payment_hash: crate::c_types::derived::COption_ThirtyTwoBytesZ, 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 = { /*payment_hash*/ let payment_hash_opt = payment_hash; if payment_hash_opt.is_none() { None } else { Some({ { ::lightning::ln::types::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::ln::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 +} + +/// 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. +/// +/// `phantom_route_hints` parameter: +/// * Contains channel info for all nodes participating in the phantom invoice +/// * Entries are retrieved from a call to [`ChannelManager::get_phantom_route_hints`] on each +/// 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 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 +/// +/// `payment_hash` can be specified if you have a specific need for a custom payment hash (see the difference +/// between [`ChannelManager::create_inbound_payment`] and [`ChannelManager::create_inbound_payment_for_hash`]). +/// If `None` is provided for `payment_hash`, then one will be created. +/// +/// `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for +/// in excess of the current time. +/// +/// `duration_since_epoch` is the current time since epoch in seconds. +/// +/// Note that the provided `keys_manager`'s `NodeSigner` implementation must support phantom +/// invoices in its `sign_invoice` implementation ([`PhantomKeysManager`] satisfies this +/// requirement). +/// +/// [`PhantomKeysManager`]: crate::sign::PhantomKeysManager +/// [`ChannelManager::get_phantom_route_hints`]: crate::ln::channelmanager::ChannelManager::get_phantom_route_hints +/// [`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 +/// [`PhantomRouteHints::channels`]: crate::ln::channelmanager::PhantomRouteHints::channels +/// +/// 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. +#[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::derived::COption_ThirtyTwoBytesZ, 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 = { /*payment_hash*/ let payment_hash_opt = payment_hash; if payment_hash_opt.is_none() { None } else { Some({ { ::lightning::ln::types::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::ln::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 +} + +/// Utility to construct an invoice. Generally, unless you want to do something like a custom +/// cltv_expiry, this is what you should be using to create an invoice. The reason being, this +/// method stores the invoice's payment secret and preimage in `ChannelManager`, so (a) the user +/// doesn't have to store preimage/payment secret information and (b) `ChannelManager` can verify +/// that the payment secret is valid when the invoice is paid. +/// +/// `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for +/// in excess of the current time. +/// +/// You can specify a custom `min_final_cltv_expiry_delta`, or let LDK default it to +/// [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. The provided expiry must be at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. +/// Note that LDK will add a buffer of 3 blocks to the delta to allow for up to a few new block +/// confirmations during routing. +/// +/// [`MIN_FINAL_CLTV_EXPIRY_DETLA`]: crate::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::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::ln::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 +} + +/// Utility to construct an invoice. Generally, unless you want to do something like a custom +/// cltv_expiry, this is what you should be using to create an invoice. The reason being, this +/// method stores the invoice's payment secret and preimage in `ChannelManager`, so (a) the user +/// doesn't have to store preimage/payment secret information and (b) `ChannelManager` can verify +/// that the payment secret is valid when the invoice is paid. +/// Use this variant if you want to pass the `description_hash` to the invoice. +/// +/// `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for +/// in excess of the current time. +/// +/// You can specify a custom `min_final_cltv_expiry_delta`, or let LDK default it to +/// [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. The provided expiry must be at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. +/// Note that LDK will add a buffer of 3 blocks to the delta to allow for up to a few new block +/// confirmations during routing. +/// +/// [`MIN_FINAL_CLTV_EXPIRY_DETLA`]: crate::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::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::ln::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 +} + +/// 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. +#[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::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::ln::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 +} + +/// 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. +#[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::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::ln::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 +} + +/// See [`create_invoice_from_channelmanager_and_duration_since_epoch`] +/// This version allows for providing a custom [`PaymentHash`] for the invoice. +/// 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::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::ln::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::types::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/ln/mod.rs b/lightning-c-bindings/src/lightning/ln/mod.rs index 8b65861..6029722 100644 --- a/lightning-c-bindings/src/lightning/ln/mod.rs +++ b/lightning-c-bindings/src/lightning/ln/mod.rs @@ -7,6 +7,12 @@ // source was automatically generated. //! Implementations of various parts of the Lightning protocol are in this module. +//! +//! Note that the re-exports of [`PaymentHash`], [`PaymentPreimage`], and [`PaymentSecret`] here +//! are deprecated and will be removed in a future version. Instead, use them via +//! [`lightning::types::payment`]. +//! +//! [`lightning::types::payment`]: crate::types::payment use alloc::str::FromStr; use alloc::string::String; @@ -28,6 +34,8 @@ pub mod chan_utils; pub mod features; pub mod script; pub mod types; +pub mod invoice_utils; +pub mod bolt11_payment; pub mod outbound_payment; pub mod wire; mod peer_channel_encryptor { diff --git a/lightning-c-bindings/src/lightning/ln/msgs.rs b/lightning-c-bindings/src/lightning/ln/msgs.rs index 47dbcaa..89c8181 100644 --- a/lightning-c-bindings/src/lightning/ln/msgs.rs +++ b/lightning-c-bindings/src/lightning/ln/msgs.rs @@ -236,6 +236,12 @@ pub struct Init { pub is_owned: bool, } +impl core::ops::Deref for Init { + type Target = nativeInit; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for Init { } +unsafe impl core::marker::Sync for Init { } impl Drop for Init { fn drop(&mut self) { if self.is_owned && !<*mut nativeInit>::is_null(self.inner) { @@ -266,16 +272,19 @@ impl Init { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The relevant features which the sender supports. #[no_mangle] -pub extern "C" fn Init_get_features(this_ptr: &Init) -> crate::lightning::ln::features::InitFeatures { +pub extern "C" fn Init_get_features(this_ptr: &Init) -> crate::lightning_types::features::InitFeatures { let mut inner_val = &mut this_ptr.get_native_mut_ref().features; - crate::lightning::ln::features::InitFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::features::InitFeatures<>) as *mut _) }, is_owned: false } + crate::lightning_types::features::InitFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning_types::features::InitFeatures<>) as *mut _) }, is_owned: false } } /// The relevant features which the sender supports. #[no_mangle] -pub extern "C" fn Init_set_features(this_ptr: &mut Init, mut val: crate::lightning::ln::features::InitFeatures) { +pub extern "C" fn Init_set_features(this_ptr: &mut Init, mut val: crate::lightning_types::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. @@ -294,7 +303,7 @@ pub extern "C" fn Init_get_networks(this_ptr: &Init) -> crate::c_types::derived: /// 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_ThirtyTwoBytesZZ) { - 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 }})} }; + 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::constants::ChainHash::from(&item.data) }); }; local_val_0 }})} }; unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.networks = local_val; } /// The receipient's network address. @@ -323,8 +332,8 @@ 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 networks_arg: crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ, mut remote_network_address_arg: crate::c_types::derived::COption_SocketAddressZ) -> 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 }})} }; +pub extern "C" fn Init_new(mut features_arg: crate::lightning_types::features::InitFeatures, mut networks_arg: crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ, mut remote_network_address_arg: crate::c_types::derived::COption_SocketAddressZ) -> 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::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()) }, @@ -395,6 +404,12 @@ pub struct ErrorMessage { pub is_owned: bool, } +impl core::ops::Deref for ErrorMessage { + type Target = nativeErrorMessage; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ErrorMessage { } +unsafe impl core::marker::Sync for ErrorMessage { } impl Drop for ErrorMessage { fn drop(&mut self) { if self.is_owned && !<*mut nativeErrorMessage>::is_null(self.inner) { @@ -425,6 +440,9 @@ impl ErrorMessage { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The channel ID involved in the error. /// @@ -534,6 +552,12 @@ pub struct WarningMessage { pub is_owned: bool, } +impl core::ops::Deref for WarningMessage { + type Target = nativeWarningMessage; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for WarningMessage { } +unsafe impl core::marker::Sync for WarningMessage { } impl Drop for WarningMessage { fn drop(&mut self) { if self.is_owned && !<*mut nativeWarningMessage>::is_null(self.inner) { @@ -564,6 +588,9 @@ impl WarningMessage { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The channel ID involved in the warning. /// @@ -671,6 +698,12 @@ pub struct Ping { pub is_owned: bool, } +impl core::ops::Deref for Ping { + type Target = nativePing; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for Ping { } +unsafe impl core::marker::Sync for Ping { } impl Drop for Ping { fn drop(&mut self) { if self.is_owned && !<*mut nativePing>::is_null(self.inner) { @@ -701,6 +734,9 @@ impl Ping { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The desired response length. #[no_mangle] @@ -800,6 +836,12 @@ pub struct Pong { pub is_owned: bool, } +impl core::ops::Deref for Pong { + type Target = nativePong; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for Pong { } +unsafe impl core::marker::Sync for Pong { } impl Drop for Pong { fn drop(&mut self) { if self.is_owned && !<*mut nativePong>::is_null(self.inner) { @@ -830,6 +872,9 @@ impl Pong { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The pong packet size. /// @@ -917,6 +962,12 @@ pub struct CommonOpenChannelFields { pub is_owned: bool, } +impl core::ops::Deref for CommonOpenChannelFields { + type Target = nativeCommonOpenChannelFields; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for CommonOpenChannelFields { } +unsafe impl core::marker::Sync for CommonOpenChannelFields { } impl Drop for CommonOpenChannelFields { fn drop(&mut self) { if self.is_owned && !<*mut nativeCommonOpenChannelFields>::is_null(self.inner) { @@ -947,6 +998,9 @@ impl CommonOpenChannelFields { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The genesis hash of the blockchain where the channel is to be opened #[no_mangle] @@ -957,7 +1011,7 @@ pub extern "C" fn CommonOpenChannelFields_get_chain_hash(this_ptr: &CommonOpenCh /// The genesis hash of the blockchain where the channel is to be opened #[no_mangle] pub extern "C" fn CommonOpenChannelFields_set_chain_hash(this_ptr: &mut CommonOpenChannelFields, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data); + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::constants::ChainHash::from(&val.data); } /// A temporary channel ID /// For V2 channels: derived using a zeroed out value for the channel acceptor's revocation basepoint @@ -1150,7 +1204,7 @@ pub extern "C" fn CommonOpenChannelFields_get_shutdown_scriptpubkey(this_ptr: &C /// collaboratively close #[no_mangle] pub extern "C" fn CommonOpenChannelFields_set_shutdown_scriptpubkey(this_ptr: &mut CommonOpenChannelFields, 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({ { ::bitcoin::blockdata::script::ScriptBuf::from({ val_opt.take() }.into_rust()) }})} }; + let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::bitcoin::script::ScriptBuf::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 @@ -1160,9 +1214,9 @@ pub extern "C" fn CommonOpenChannelFields_set_shutdown_scriptpubkey(this_ptr: &m /// /// 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 CommonOpenChannelFields_get_channel_type(this_ptr: &CommonOpenChannelFields) -> crate::lightning::ln::features::ChannelTypeFeatures { +pub extern "C" fn CommonOpenChannelFields_get_channel_type(this_ptr: &CommonOpenChannelFields) -> crate::lightning_types::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 }; + let mut local_inner_val = crate::lightning_types::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_types::features::ChannelTypeFeatures<>) as *mut _ }, is_owned: false }; local_inner_val } /// The channel type that this channel will represent @@ -1172,7 +1226,7 @@ pub extern "C" fn CommonOpenChannelFields_get_channel_type(this_ptr: &CommonOpen /// /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None #[no_mangle] -pub extern "C" fn CommonOpenChannelFields_set_channel_type(this_ptr: &mut CommonOpenChannelFields, mut val: crate::lightning::ln::features::ChannelTypeFeatures) { +pub extern "C" fn CommonOpenChannelFields_set_channel_type(this_ptr: &mut CommonOpenChannelFields, mut val: crate::lightning_types::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; } @@ -1181,11 +1235,11 @@ pub extern "C" fn CommonOpenChannelFields_set_channel_type(this_ptr: &mut Common /// Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn CommonOpenChannelFields_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut temporary_channel_id_arg: crate::lightning::ln::types::ChannelId, 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 commitment_feerate_sat_per_1000_weight_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 channel_flags_arg: u8, mut shutdown_scriptpubkey_arg: crate::c_types::derived::COption_CVec_u8ZZ, mut channel_type_arg: crate::lightning::ln::features::ChannelTypeFeatures) -> CommonOpenChannelFields { - 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::ScriptBuf::from({ shutdown_scriptpubkey_arg_opt.take() }.into_rust()) }})} }; +pub extern "C" fn CommonOpenChannelFields_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut temporary_channel_id_arg: crate::lightning::ln::types::ChannelId, 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 commitment_feerate_sat_per_1000_weight_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 channel_flags_arg: u8, mut shutdown_scriptpubkey_arg: crate::c_types::derived::COption_CVec_u8ZZ, mut channel_type_arg: crate::lightning_types::features::ChannelTypeFeatures) -> CommonOpenChannelFields { + 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::script::ScriptBuf::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()) } }) }; CommonOpenChannelFields { inner: ObjOps::heap_alloc(nativeCommonOpenChannelFields { - chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data), + chain_hash: ::bitcoin::constants::ChainHash::from(&chain_hash_arg.data), temporary_channel_id: *unsafe { Box::from_raw(temporary_channel_id_arg.take_inner()) }, funding_satoshis: funding_satoshis_arg, dust_limit_satoshis: dust_limit_satoshis_arg, @@ -1246,6 +1300,201 @@ pub extern "C" fn CommonOpenChannelFields_eq(a: &CommonOpenChannelFields, b: &Co if a.inner.is_null() || b.inner.is_null() { return false; } if a.get_native_ref() == b.get_native_ref() { true } else { false } } +/// The [`ChannelParameters`] for this channel. +#[must_use] +#[no_mangle] +pub extern "C" fn CommonOpenChannelFields_channel_parameters(this_arg: &crate::lightning::ln::msgs::CommonOpenChannelFields) -> crate::lightning::ln::msgs::ChannelParameters { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.channel_parameters(); + crate::lightning::ln::msgs::ChannelParameters { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + + +use lightning::ln::msgs::ChannelParameters as nativeChannelParametersImport; +pub(crate) type nativeChannelParameters = nativeChannelParametersImport; + +/// A subset of [`CommonOpenChannelFields`], containing various parameters which are set by the +/// channel initiator and which are not part of the channel funding transaction. +#[must_use] +#[repr(C)] +pub struct ChannelParameters { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, 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 nativeChannelParameters, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust 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 core::ops::Deref for ChannelParameters { + type Target = nativeChannelParameters; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ChannelParameters { } +unsafe impl core::marker::Sync for ChannelParameters { } +impl Drop for ChannelParameters { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeChannelParameters>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the ChannelParameters, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn ChannelParameters_free(this_obj: ChannelParameters) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn ChannelParameters_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelParameters) }; +} +#[allow(unused)] +impl ChannelParameters { + pub(crate) fn get_native_ref(&self) -> &'static nativeChannelParameters { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelParameters { + 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 nativeChannelParameters { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// The threshold below which outputs on transactions broadcast by the channel initiator will be +/// omitted. +#[no_mangle] +pub extern "C" fn ChannelParameters_get_dust_limit_satoshis(this_ptr: &ChannelParameters) -> 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 ChannelParameters_set_dust_limit_satoshis(this_ptr: &mut ChannelParameters, 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 ChannelParameters_get_max_htlc_value_in_flight_msat(this_ptr: &ChannelParameters) -> 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 ChannelParameters_set_max_htlc_value_in_flight_msat(this_ptr: &mut ChannelParameters, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_value_in_flight_msat = val; +} +/// The minimum HTLC size for HTLCs towards the channel initiator, in milli-satoshi +#[no_mangle] +pub extern "C" fn ChannelParameters_get_htlc_minimum_msat(this_ptr: &ChannelParameters) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat; + *inner_val +} +/// The minimum HTLC size for HTLCs towards the channel initiator, in milli-satoshi +#[no_mangle] +pub extern "C" fn ChannelParameters_set_htlc_minimum_msat(this_ptr: &mut ChannelParameters, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val; +} +/// The feerate for the commitment transaction set by the channel initiator until updated by +/// [`UpdateFee`] +#[no_mangle] +pub extern "C" fn ChannelParameters_get_commitment_feerate_sat_per_1000_weight(this_ptr: &ChannelParameters) -> 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 until updated by +/// [`UpdateFee`] +#[no_mangle] +pub extern "C" fn ChannelParameters_set_commitment_feerate_sat_per_1000_weight(this_ptr: &mut ChannelParameters, mut val: u32) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.commitment_feerate_sat_per_1000_weight = val; +} +/// The number of blocks which the non-channel-initator will have to wait to claim on-chain +/// funds if they broadcast a commitment transaction. +#[no_mangle] +pub extern "C" fn ChannelParameters_get_to_self_delay(this_ptr: &ChannelParameters) -> u16 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay; + *inner_val +} +/// The number of blocks which the non-channel-initator will have to wait to claim on-chain +/// funds if they broadcast a commitment transaction. +#[no_mangle] +pub extern "C" fn ChannelParameters_set_to_self_delay(this_ptr: &mut ChannelParameters, mut val: u16) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val; +} +/// The maximum number of pending HTLCs towards the channel initiator. +#[no_mangle] +pub extern "C" fn ChannelParameters_get_max_accepted_htlcs(this_ptr: &ChannelParameters) -> u16 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs; + *inner_val +} +/// The maximum number of pending HTLCs towards the channel initiator. +#[no_mangle] +pub extern "C" fn ChannelParameters_set_max_accepted_htlcs(this_ptr: &mut ChannelParameters, mut val: u16) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val; +} +/// Constructs a new ChannelParameters given each field +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelParameters_new(mut dust_limit_satoshis_arg: u64, mut max_htlc_value_in_flight_msat_arg: u64, mut htlc_minimum_msat_arg: u64, mut commitment_feerate_sat_per_1000_weight_arg: u32, mut to_self_delay_arg: u16, mut max_accepted_htlcs_arg: u16) -> ChannelParameters { + ChannelParameters { inner: ObjOps::heap_alloc(nativeChannelParameters { + 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, + commitment_feerate_sat_per_1000_weight: commitment_feerate_sat_per_1000_weight_arg, + to_self_delay: to_self_delay_arg, + max_accepted_htlcs: max_accepted_htlcs_arg, + }), is_owned: true } +} +impl Clone for ChannelParameters { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeChannelParameters>::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 ChannelParameters_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeChannelParameters)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the ChannelParameters +pub extern "C" fn ChannelParameters_clone(orig: &ChannelParameters) -> ChannelParameters { + orig.clone() +} +/// Get a string which allows debug introspection of a ChannelParameters object +pub extern "C" fn ChannelParameters_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::ChannelParameters }).into()} +/// Generates a non-cryptographic 64-bit hash of the ChannelParameters. +#[no_mangle] +pub extern "C" fn ChannelParameters_hash(o: &ChannelParameters) -> 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 ChannelParameterss 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 ChannelParameters_eq(a: &ChannelParameters, b: &ChannelParameters) -> 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::OpenChannel as nativeOpenChannelImport; pub(crate) type nativeOpenChannel = nativeOpenChannelImport; @@ -1270,6 +1519,12 @@ pub struct OpenChannel { pub is_owned: bool, } +impl core::ops::Deref for OpenChannel { + type Target = nativeOpenChannel; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for OpenChannel { } +unsafe impl core::marker::Sync for OpenChannel { } impl Drop for OpenChannel { fn drop(&mut self) { if self.is_owned && !<*mut nativeOpenChannel>::is_null(self.inner) { @@ -1300,6 +1555,9 @@ impl OpenChannel { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Common fields of `open_channel(2)`-like messages #[no_mangle] @@ -1408,6 +1666,12 @@ pub struct OpenChannelV2 { pub is_owned: bool, } +impl core::ops::Deref for OpenChannelV2 { + type Target = nativeOpenChannelV2; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for OpenChannelV2 { } +unsafe impl core::marker::Sync for OpenChannelV2 { } impl Drop for OpenChannelV2 { fn drop(&mut self) { if self.is_owned && !<*mut nativeOpenChannelV2>::is_null(self.inner) { @@ -1438,6 +1702,9 @@ impl OpenChannelV2 { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Common fields of `open_channel(2)`-like messages #[no_mangle] @@ -1572,6 +1839,12 @@ pub struct CommonAcceptChannelFields { pub is_owned: bool, } +impl core::ops::Deref for CommonAcceptChannelFields { + type Target = nativeCommonAcceptChannelFields; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for CommonAcceptChannelFields { } +unsafe impl core::marker::Sync for CommonAcceptChannelFields { } impl Drop for CommonAcceptChannelFields { fn drop(&mut self) { if self.is_owned && !<*mut nativeCommonAcceptChannelFields>::is_null(self.inner) { @@ -1602,6 +1875,9 @@ impl CommonAcceptChannelFields { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The same `temporary_channel_id` received from the initiator's `open_channel2` or `open_channel` message. #[no_mangle] @@ -1764,7 +2040,7 @@ pub extern "C" fn CommonAcceptChannelFields_get_shutdown_scriptpubkey(this_ptr: /// collaboratively close #[no_mangle] pub extern "C" fn CommonAcceptChannelFields_set_shutdown_scriptpubkey(this_ptr: &mut CommonAcceptChannelFields, 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({ { ::bitcoin::blockdata::script::ScriptBuf::from({ val_opt.take() }.into_rust()) }})} }; + let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::bitcoin::script::ScriptBuf::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 @@ -1776,9 +2052,9 @@ pub extern "C" fn CommonAcceptChannelFields_set_shutdown_scriptpubkey(this_ptr: /// /// 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 CommonAcceptChannelFields_get_channel_type(this_ptr: &CommonAcceptChannelFields) -> crate::lightning::ln::features::ChannelTypeFeatures { +pub extern "C" fn CommonAcceptChannelFields_get_channel_type(this_ptr: &CommonAcceptChannelFields) -> crate::lightning_types::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 }; + let mut local_inner_val = crate::lightning_types::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_types::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 @@ -1790,7 +2066,7 @@ pub extern "C" fn CommonAcceptChannelFields_get_channel_type(this_ptr: &CommonAc /// /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None #[no_mangle] -pub extern "C" fn CommonAcceptChannelFields_set_channel_type(this_ptr: &mut CommonAcceptChannelFields, mut val: crate::lightning::ln::features::ChannelTypeFeatures) { +pub extern "C" fn CommonAcceptChannelFields_set_channel_type(this_ptr: &mut CommonAcceptChannelFields, mut val: crate::lightning_types::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; } @@ -1799,8 +2075,8 @@ pub extern "C" fn CommonAcceptChannelFields_set_channel_type(this_ptr: &mut Comm /// Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn CommonAcceptChannelFields_new(mut temporary_channel_id_arg: crate::lightning::ln::types::ChannelId, 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 shutdown_scriptpubkey_arg: crate::c_types::derived::COption_CVec_u8ZZ, mut channel_type_arg: crate::lightning::ln::features::ChannelTypeFeatures) -> CommonAcceptChannelFields { - 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::ScriptBuf::from({ shutdown_scriptpubkey_arg_opt.take() }.into_rust()) }})} }; +pub extern "C" fn CommonAcceptChannelFields_new(mut temporary_channel_id_arg: crate::lightning::ln::types::ChannelId, 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 shutdown_scriptpubkey_arg: crate::c_types::derived::COption_CVec_u8ZZ, mut channel_type_arg: crate::lightning_types::features::ChannelTypeFeatures) -> CommonAcceptChannelFields { + 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::script::ScriptBuf::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()) } }) }; CommonAcceptChannelFields { inner: ObjOps::heap_alloc(nativeCommonAcceptChannelFields { temporary_channel_id: *unsafe { Box::from_raw(temporary_channel_id_arg.take_inner()) }, @@ -1885,6 +2161,12 @@ pub struct AcceptChannel { pub is_owned: bool, } +impl core::ops::Deref for AcceptChannel { + type Target = nativeAcceptChannel; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for AcceptChannel { } +unsafe impl core::marker::Sync for AcceptChannel { } impl Drop for AcceptChannel { fn drop(&mut self) { if self.is_owned && !<*mut nativeAcceptChannel>::is_null(self.inner) { @@ -1915,6 +2197,9 @@ impl AcceptChannel { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Common fields of `accept_channel(2)`-like messages #[no_mangle] @@ -2011,6 +2296,12 @@ pub struct AcceptChannelV2 { pub is_owned: bool, } +impl core::ops::Deref for AcceptChannelV2 { + type Target = nativeAcceptChannelV2; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for AcceptChannelV2 { } +unsafe impl core::marker::Sync for AcceptChannelV2 { } impl Drop for AcceptChannelV2 { fn drop(&mut self) { if self.is_owned && !<*mut nativeAcceptChannelV2>::is_null(self.inner) { @@ -2041,6 +2332,9 @@ impl AcceptChannelV2 { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Common fields of `accept_channel(2)`-like messages #[no_mangle] @@ -2165,6 +2459,12 @@ pub struct FundingCreated { pub is_owned: bool, } +impl core::ops::Deref for FundingCreated { + type Target = nativeFundingCreated; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for FundingCreated { } +unsafe impl core::marker::Sync for FundingCreated { } impl Drop for FundingCreated { fn drop(&mut self) { if self.is_owned && !<*mut nativeFundingCreated>::is_null(self.inner) { @@ -2195,6 +2495,9 @@ impl FundingCreated { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// A temporary channel ID, until the funding is established #[no_mangle] @@ -2316,6 +2619,12 @@ pub struct FundingSigned { pub is_owned: bool, } +impl core::ops::Deref for FundingSigned { + type Target = nativeFundingSigned; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for FundingSigned { } +unsafe impl core::marker::Sync for FundingSigned { } impl Drop for FundingSigned { fn drop(&mut self) { if self.is_owned && !<*mut nativeFundingSigned>::is_null(self.inner) { @@ -2346,6 +2655,9 @@ impl FundingSigned { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The channel ID #[no_mangle] @@ -2441,6 +2753,12 @@ pub struct ChannelReady { pub is_owned: bool, } +impl core::ops::Deref for ChannelReady { + type Target = nativeChannelReady; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ChannelReady { } +unsafe impl core::marker::Sync for ChannelReady { } impl Drop for ChannelReady { fn drop(&mut self) { if self.is_owned && !<*mut nativeChannelReady>::is_null(self.inner) { @@ -2471,6 +2789,9 @@ impl ChannelReady { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The channel ID #[no_mangle] @@ -2569,7 +2890,8 @@ pub extern "C" fn ChannelReady_eq(a: &ChannelReady, b: &ChannelReady) -> bool { use lightning::ln::msgs::Stfu as nativeStfuImport; pub(crate) type nativeStfu = nativeStfuImport; -/// An stfu (quiescence) message to be sent by or received from the stfu initiator. +/// An `stfu` (quiescence) message to be sent by or received from the stfu initiator. +/// #[must_use] #[repr(C)] pub struct Stfu { @@ -2585,6 +2907,12 @@ pub struct Stfu { pub is_owned: bool, } +impl core::ops::Deref for Stfu { + type Target = nativeStfu; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for Stfu { } +unsafe impl core::marker::Sync for Stfu { } impl Drop for Stfu { fn drop(&mut self) { if self.is_owned && !<*mut nativeStfu>::is_null(self.inner) { @@ -2615,6 +2943,9 @@ impl Stfu { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The channel ID where quiescence is intended #[no_mangle] @@ -2679,18 +3010,19 @@ pub extern "C" fn Stfu_eq(a: &Stfu, b: &Stfu) -> bool { if a.get_native_ref() == b.get_native_ref() { true } else { false } } -use lightning::ln::msgs::Splice as nativeSpliceImport; -pub(crate) type nativeSplice = nativeSpliceImport; +use lightning::ln::msgs::SpliceInit as nativeSpliceInitImport; +pub(crate) type nativeSpliceInit = nativeSpliceInitImport; -/// A splice message to be sent by or received from the stfu initiator (splice initiator). +/// A `splice_init` message to be sent by or received from the stfu initiator (splice initiator). +/// #[must_use] #[repr(C)] -pub struct Splice { +pub struct SpliceInit { /// A pointer to the opaque Rust object. /// Nearly everywhere, 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 nativeSplice, + pub inner: *mut nativeSpliceInit, /// Indicates that this is the only struct which contains the same pointer. /// Rust functions which take ownership of an object provided via an argument require @@ -2698,122 +3030,134 @@ pub struct Splice { pub is_owned: bool, } -impl Drop for Splice { +impl core::ops::Deref for SpliceInit { + type Target = nativeSpliceInit; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for SpliceInit { } +unsafe impl core::marker::Sync for SpliceInit { } +impl Drop for SpliceInit { fn drop(&mut self) { - if self.is_owned && !<*mut nativeSplice>::is_null(self.inner) { + if self.is_owned && !<*mut nativeSpliceInit>::is_null(self.inner) { let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; } } } -/// Frees any resources used by the Splice, if is_owned is set and inner is non-NULL. +/// Frees any resources used by the SpliceInit, if is_owned is set and inner is non-NULL. #[no_mangle] -pub extern "C" fn Splice_free(this_obj: Splice) { } +pub extern "C" fn SpliceInit_free(this_obj: SpliceInit) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn Splice_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeSplice) }; +pub(crate) extern "C" fn SpliceInit_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeSpliceInit) }; } #[allow(unused)] -impl Splice { - pub(crate) fn get_native_ref(&self) -> &'static nativeSplice { +impl SpliceInit { + pub(crate) fn get_native_ref(&self) -> &'static nativeSpliceInit { unsafe { &*ObjOps::untweak_ptr(self.inner) } } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeSplice { + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeSpliceInit { 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 nativeSplice { + pub(crate) fn take_inner(mut self) -> *mut nativeSpliceInit { assert!(self.is_owned); let ret = ObjOps::untweak_ptr(self.inner); self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The channel ID where splicing is intended #[no_mangle] -pub extern "C" fn Splice_get_channel_id(this_ptr: &Splice) -> crate::lightning::ln::types::ChannelId { +pub extern "C" fn SpliceInit_get_channel_id(this_ptr: &SpliceInit) -> crate::lightning::ln::types::ChannelId { let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id; crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false } } /// The channel ID where splicing is intended #[no_mangle] -pub extern "C" fn Splice_set_channel_id(this_ptr: &mut Splice, mut val: crate::lightning::ln::types::ChannelId) { +pub extern "C" fn SpliceInit_set_channel_id(this_ptr: &mut SpliceInit, mut val: crate::lightning::ln::types::ChannelId) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) }; } -/// The genesis hash of the blockchain where the channel is intended to be spliced -#[no_mangle] -pub extern "C" fn Splice_get_chain_hash(this_ptr: &Splice) -> *const [u8; 32] { - let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash; - inner_val.as_ref() -} -/// The genesis hash of the blockchain where the channel is intended to be spliced +/// The amount the splice initiator is intending to add to its channel balance (splice-in) +/// or remove from its channel balance (splice-out). #[no_mangle] -pub extern "C" fn Splice_set_chain_hash(this_ptr: &mut Splice, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data); -} -/// The intended change in channel capacity: the amount to be added (positive value) -/// or removed (negative value) by the sender (splice initiator) by splicing into/from the channel. -#[no_mangle] -pub extern "C" fn Splice_get_relative_satoshis(this_ptr: &Splice) -> i64 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().relative_satoshis; +pub extern "C" fn SpliceInit_get_funding_contribution_satoshis(this_ptr: &SpliceInit) -> i64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_contribution_satoshis; *inner_val } -/// The intended change in channel capacity: the amount to be added (positive value) -/// or removed (negative value) by the sender (splice initiator) by splicing into/from the channel. +/// The amount the splice initiator is intending to add to its channel balance (splice-in) +/// or remove from its channel balance (splice-out). #[no_mangle] -pub extern "C" fn Splice_set_relative_satoshis(this_ptr: &mut Splice, mut val: i64) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.relative_satoshis = val; +pub extern "C" fn SpliceInit_set_funding_contribution_satoshis(this_ptr: &mut SpliceInit, mut val: i64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_contribution_satoshis = val; } /// The feerate for the new funding transaction, set by the splice initiator #[no_mangle] -pub extern "C" fn Splice_get_funding_feerate_perkw(this_ptr: &Splice) -> u32 { +pub extern "C" fn SpliceInit_get_funding_feerate_perkw(this_ptr: &SpliceInit) -> u32 { let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_feerate_perkw; *inner_val } /// The feerate for the new funding transaction, set by the splice initiator #[no_mangle] -pub extern "C" fn Splice_set_funding_feerate_perkw(this_ptr: &mut Splice, mut val: u32) { +pub extern "C" fn SpliceInit_set_funding_feerate_perkw(this_ptr: &mut SpliceInit, mut val: u32) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_feerate_perkw = val; } /// The locktime for the new funding transaction #[no_mangle] -pub extern "C" fn Splice_get_locktime(this_ptr: &Splice) -> u32 { +pub extern "C" fn SpliceInit_get_locktime(this_ptr: &SpliceInit) -> u32 { let mut inner_val = &mut this_ptr.get_native_mut_ref().locktime; *inner_val } /// The locktime for the new funding transaction #[no_mangle] -pub extern "C" fn Splice_set_locktime(this_ptr: &mut Splice, mut val: u32) { +pub extern "C" fn SpliceInit_set_locktime(this_ptr: &mut SpliceInit, mut val: u32) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.locktime = val; } /// The key of the sender (splice initiator) controlling the new funding transaction #[no_mangle] -pub extern "C" fn Splice_get_funding_pubkey(this_ptr: &Splice) -> crate::c_types::PublicKey { +pub extern "C" fn SpliceInit_get_funding_pubkey(this_ptr: &SpliceInit) -> 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 key of the sender (splice initiator) controlling the new funding transaction #[no_mangle] -pub extern "C" fn Splice_set_funding_pubkey(this_ptr: &mut Splice, mut val: crate::c_types::PublicKey) { +pub extern "C" fn SpliceInit_set_funding_pubkey(this_ptr: &mut SpliceInit, mut val: crate::c_types::PublicKey) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust(); } -/// Constructs a new Splice given each field +/// If set, only confirmed inputs added (by the splice acceptor) will be accepted +#[no_mangle] +pub extern "C" fn SpliceInit_get_require_confirmed_inputs(this_ptr: &SpliceInit) -> 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 +} +/// If set, only confirmed inputs added (by the splice acceptor) will be accepted +#[no_mangle] +pub extern "C" fn SpliceInit_set_require_confirmed_inputs(this_ptr: &mut SpliceInit, 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 SpliceInit given each field #[must_use] #[no_mangle] -pub extern "C" fn Splice_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut relative_satoshis_arg: i64, mut funding_feerate_perkw_arg: u32, mut locktime_arg: u32, mut funding_pubkey_arg: crate::c_types::PublicKey) -> Splice { - Splice { inner: ObjOps::heap_alloc(nativeSplice { +pub extern "C" fn SpliceInit_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut funding_contribution_satoshis_arg: i64, mut funding_feerate_perkw_arg: u32, mut locktime_arg: u32, mut funding_pubkey_arg: crate::c_types::PublicKey, mut require_confirmed_inputs_arg: crate::c_types::derived::COption_NoneZ) -> SpliceInit { + let mut local_require_confirmed_inputs_arg = if require_confirmed_inputs_arg.is_some() { Some( { () /*require_confirmed_inputs_arg.take()*/ }) } else { None }; + SpliceInit { inner: ObjOps::heap_alloc(nativeSpliceInit { channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) }, - chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data), - relative_satoshis: relative_satoshis_arg, + funding_contribution_satoshis: funding_contribution_satoshis_arg, funding_feerate_perkw: funding_feerate_perkw_arg, locktime: locktime_arg, funding_pubkey: funding_pubkey_arg.into_rust(), + require_confirmed_inputs: local_require_confirmed_inputs_arg, }), is_owned: true } } -impl Clone for Splice { +impl Clone for SpliceInit { fn clone(&self) -> Self { Self { - inner: if <*mut nativeSplice>::is_null(self.inner) { core::ptr::null_mut() } else { + inner: if <*mut nativeSpliceInit>::is_null(self.inner) { core::ptr::null_mut() } else { ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, is_owned: true, } @@ -2821,22 +3165,22 @@ impl Clone for Splice { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn Splice_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeSplice)).clone() })) as *mut c_void +pub(crate) extern "C" fn SpliceInit_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeSpliceInit)).clone() })) as *mut c_void } #[no_mangle] -/// Creates a copy of the Splice -pub extern "C" fn Splice_clone(orig: &Splice) -> Splice { +/// Creates a copy of the SpliceInit +pub extern "C" fn SpliceInit_clone(orig: &SpliceInit) -> SpliceInit { orig.clone() } -/// Get a string which allows debug introspection of a Splice object -pub extern "C" fn Splice_debug_str_void(o: *const c_void) -> Str { - alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::Splice }).into()} -/// Checks if two Splices contain equal inner contents. +/// Get a string which allows debug introspection of a SpliceInit object +pub extern "C" fn SpliceInit_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::SpliceInit }).into()} +/// Checks if two SpliceInits 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 Splice_eq(a: &Splice, b: &Splice) -> bool { +pub extern "C" fn SpliceInit_eq(a: &SpliceInit, b: &SpliceInit) -> 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 } @@ -2845,7 +3189,7 @@ pub extern "C" fn Splice_eq(a: &Splice, b: &Splice) -> bool { use lightning::ln::msgs::SpliceAck as nativeSpliceAckImport; pub(crate) type nativeSpliceAck = nativeSpliceAckImport; -/// A splice_ack message to be received by or sent to the splice initiator. +/// A `splice_ack` message to be received by or sent to the splice initiator. /// #[must_use] #[repr(C)] @@ -2862,6 +3206,12 @@ pub struct SpliceAck { pub is_owned: bool, } +impl core::ops::Deref for SpliceAck { + type Target = nativeSpliceAck; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for SpliceAck { } +unsafe impl core::marker::Sync for SpliceAck { } impl Drop for SpliceAck { fn drop(&mut self) { if self.is_owned && !<*mut nativeSpliceAck>::is_null(self.inner) { @@ -2892,6 +3242,9 @@ impl SpliceAck { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The channel ID where splicing is intended #[no_mangle] @@ -2904,29 +3257,18 @@ pub extern "C" fn SpliceAck_get_channel_id(this_ptr: &SpliceAck) -> crate::light pub extern "C" fn SpliceAck_set_channel_id(this_ptr: &mut SpliceAck, mut val: crate::lightning::ln::types::ChannelId) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) }; } -/// The genesis hash of the blockchain where the channel is intended to be spliced -#[no_mangle] -pub extern "C" fn SpliceAck_get_chain_hash(this_ptr: &SpliceAck) -> *const [u8; 32] { - let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash; - inner_val.as_ref() -} -/// The genesis hash of the blockchain where the channel is intended to be spliced -#[no_mangle] -pub extern "C" fn SpliceAck_set_chain_hash(this_ptr: &mut SpliceAck, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data); -} -/// The intended change in channel capacity: the amount to be added (positive value) -/// or removed (negative value) by the sender (splice acceptor) by splicing into/from the channel. +/// The amount the splice acceptor is intending to add to its channel balance (splice-in) +/// or remove from its channel balance (splice-out). #[no_mangle] -pub extern "C" fn SpliceAck_get_relative_satoshis(this_ptr: &SpliceAck) -> i64 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().relative_satoshis; +pub extern "C" fn SpliceAck_get_funding_contribution_satoshis(this_ptr: &SpliceAck) -> i64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_contribution_satoshis; *inner_val } -/// The intended change in channel capacity: the amount to be added (positive value) -/// or removed (negative value) by the sender (splice acceptor) by splicing into/from the channel. +/// The amount the splice acceptor is intending to add to its channel balance (splice-in) +/// or remove from its channel balance (splice-out). #[no_mangle] -pub extern "C" fn SpliceAck_set_relative_satoshis(this_ptr: &mut SpliceAck, mut val: i64) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.relative_satoshis = val; +pub extern "C" fn SpliceAck_set_funding_contribution_satoshis(this_ptr: &mut SpliceAck, mut val: i64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_contribution_satoshis = val; } /// The key of the sender (splice acceptor) controlling the new funding transaction #[no_mangle] @@ -2939,15 +3281,29 @@ pub extern "C" fn SpliceAck_get_funding_pubkey(this_ptr: &SpliceAck) -> crate::c pub extern "C" fn SpliceAck_set_funding_pubkey(this_ptr: &mut SpliceAck, mut val: crate::c_types::PublicKey) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust(); } +/// If set, only confirmed inputs added (by the splice initiator) will be accepted +#[no_mangle] +pub extern "C" fn SpliceAck_get_require_confirmed_inputs(this_ptr: &SpliceAck) -> 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 +} +/// If set, only confirmed inputs added (by the splice initiator) will be accepted +#[no_mangle] +pub extern "C" fn SpliceAck_set_require_confirmed_inputs(this_ptr: &mut SpliceAck, 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 SpliceAck given each field #[must_use] #[no_mangle] -pub extern "C" fn SpliceAck_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut relative_satoshis_arg: i64, mut funding_pubkey_arg: crate::c_types::PublicKey) -> SpliceAck { +pub extern "C" fn SpliceAck_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut funding_contribution_satoshis_arg: i64, mut funding_pubkey_arg: crate::c_types::PublicKey, mut require_confirmed_inputs_arg: crate::c_types::derived::COption_NoneZ) -> SpliceAck { + let mut local_require_confirmed_inputs_arg = if require_confirmed_inputs_arg.is_some() { Some( { () /*require_confirmed_inputs_arg.take()*/ }) } else { None }; SpliceAck { inner: ObjOps::heap_alloc(nativeSpliceAck { channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) }, - chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data), - relative_satoshis: relative_satoshis_arg, + funding_contribution_satoshis: funding_contribution_satoshis_arg, funding_pubkey: funding_pubkey_arg.into_rust(), + require_confirmed_inputs: local_require_confirmed_inputs_arg, }), is_owned: true } } impl Clone for SpliceAck { @@ -2985,7 +3341,7 @@ pub extern "C" fn SpliceAck_eq(a: &SpliceAck, b: &SpliceAck) -> bool { use lightning::ln::msgs::SpliceLocked as nativeSpliceLockedImport; pub(crate) type nativeSpliceLocked = nativeSpliceLockedImport; -/// A splice_locked message to be sent to or received from a peer. +/// A `splice_locked` message to be sent to or received from a peer. /// #[must_use] #[repr(C)] @@ -3002,6 +3358,12 @@ pub struct SpliceLocked { pub is_owned: bool, } +impl core::ops::Deref for SpliceLocked { + type Target = nativeSpliceLocked; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for SpliceLocked { } +unsafe impl core::marker::Sync for SpliceLocked { } impl Drop for SpliceLocked { fn drop(&mut self) { if self.is_owned && !<*mut nativeSpliceLocked>::is_null(self.inner) { @@ -3032,6 +3394,9 @@ impl SpliceLocked { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The channel ID #[no_mangle] @@ -3044,12 +3409,24 @@ pub extern "C" fn SpliceLocked_get_channel_id(this_ptr: &SpliceLocked) -> crate: pub extern "C" fn SpliceLocked_set_channel_id(this_ptr: &mut SpliceLocked, mut val: crate::lightning::ln::types::ChannelId) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) }; } +/// The ID of the new funding transaction that has been locked +#[no_mangle] +pub extern "C" fn SpliceLocked_get_splice_txid(this_ptr: &SpliceLocked) -> *const [u8; 32] { + let mut inner_val = &mut this_ptr.get_native_mut_ref().splice_txid; + inner_val.as_ref() +} +/// The ID of the new funding transaction that has been locked +#[no_mangle] +pub extern "C" fn SpliceLocked_set_splice_txid(this_ptr: &mut SpliceLocked, mut val: crate::c_types::ThirtyTwoBytes) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.splice_txid = ::bitcoin::hash_types::Txid::from_slice(&val.data[..]).unwrap(); +} /// Constructs a new SpliceLocked given each field #[must_use] #[no_mangle] -pub extern "C" fn SpliceLocked_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId) -> SpliceLocked { +pub extern "C" fn SpliceLocked_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut splice_txid_arg: crate::c_types::ThirtyTwoBytes) -> SpliceLocked { SpliceLocked { inner: ObjOps::heap_alloc(nativeSpliceLocked { channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) }, + splice_txid: ::bitcoin::hash_types::Txid::from_slice(&splice_txid_arg.data[..]).unwrap(), }), is_owned: true } } impl Clone for SpliceLocked { @@ -3104,6 +3481,12 @@ pub struct TxAddInput { pub is_owned: bool, } +impl core::ops::Deref for TxAddInput { + type Target = nativeTxAddInput; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for TxAddInput { } +unsafe impl core::marker::Sync for TxAddInput { } impl Drop for TxAddInput { fn drop(&mut self) { if self.is_owned && !<*mut nativeTxAddInput>::is_null(self.inner) { @@ -3134,6 +3517,9 @@ impl TxAddInput { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The channel ID #[no_mangle] @@ -3194,16 +3580,31 @@ pub extern "C" fn TxAddInput_get_sequence(this_ptr: &TxAddInput) -> u32 { pub extern "C" fn TxAddInput_set_sequence(this_ptr: &mut TxAddInput, mut val: u32) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.sequence = val; } +/// The ID of the previous funding transaction, when it is being added as an input during splicing +#[no_mangle] +pub extern "C" fn TxAddInput_get_shared_input_txid(this_ptr: &TxAddInput) -> crate::c_types::derived::COption_ThirtyTwoBytesZ { + let mut inner_val = &mut this_ptr.get_native_mut_ref().shared_input_txid; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_ThirtyTwoBytesZ::None } else { crate::c_types::derived::COption_ThirtyTwoBytesZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option is otherwise un-expressable. */ { crate::c_types::ThirtyTwoBytes { data: *(*inner_val.as_ref().unwrap()).clone().as_ref() } }) }; + local_inner_val +} +/// The ID of the previous funding transaction, when it is being added as an input during splicing +#[no_mangle] +pub extern "C" fn TxAddInput_set_shared_input_txid(this_ptr: &mut TxAddInput, mut val: crate::c_types::derived::COption_ThirtyTwoBytesZ) { + 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) }.shared_input_txid = local_val; +} /// Constructs a new TxAddInput given each field #[must_use] #[no_mangle] -pub extern "C" fn TxAddInput_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut serial_id_arg: u64, mut prevtx_arg: crate::lightning::util::ser::TransactionU16LenLimited, mut prevtx_out_arg: u32, mut sequence_arg: u32) -> TxAddInput { +pub extern "C" fn TxAddInput_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut serial_id_arg: u64, mut prevtx_arg: crate::lightning::util::ser::TransactionU16LenLimited, mut prevtx_out_arg: u32, mut sequence_arg: u32, mut shared_input_txid_arg: crate::c_types::derived::COption_ThirtyTwoBytesZ) -> TxAddInput { + let mut local_shared_input_txid_arg = { /*shared_input_txid_arg*/ let shared_input_txid_arg_opt = shared_input_txid_arg; if shared_input_txid_arg_opt.is_none() { None } else { Some({ { ::bitcoin::hash_types::Txid::from_slice(&{ shared_input_txid_arg_opt.take() }.data[..]).unwrap() }})} }; TxAddInput { inner: ObjOps::heap_alloc(nativeTxAddInput { channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) }, serial_id: serial_id_arg, prevtx: *unsafe { Box::from_raw(prevtx_arg.take_inner()) }, prevtx_out: prevtx_out_arg, sequence: sequence_arg, + shared_input_txid: local_shared_input_txid_arg, }), is_owned: true } } impl Clone for TxAddInput { @@ -3268,6 +3669,12 @@ pub struct TxAddOutput { pub is_owned: bool, } +impl core::ops::Deref for TxAddOutput { + type Target = nativeTxAddOutput; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for TxAddOutput { } +unsafe impl core::marker::Sync for TxAddOutput { } impl Drop for TxAddOutput { fn drop(&mut self) { if self.is_owned && !<*mut nativeTxAddOutput>::is_null(self.inner) { @@ -3298,6 +3705,9 @@ impl TxAddOutput { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The channel ID #[no_mangle] @@ -3343,7 +3753,7 @@ pub extern "C" fn TxAddOutput_get_script(this_ptr: &TxAddOutput) -> crate::c_typ /// 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::ScriptBuf::from(val.into_rust()); + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.script = ::bitcoin::script::ScriptBuf::from(val.into_rust()); } /// Constructs a new TxAddOutput given each field #[must_use] @@ -3353,7 +3763,7 @@ pub extern "C" fn TxAddOutput_new(mut channel_id_arg: crate::lightning::ln::type channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) }, serial_id: serial_id_arg, sats: sats_arg, - script: ::bitcoin::blockdata::script::ScriptBuf::from(script_arg.into_rust()), + script: ::bitcoin::script::ScriptBuf::from(script_arg.into_rust()), }), is_owned: true } } impl Clone for TxAddOutput { @@ -3418,6 +3828,12 @@ pub struct TxRemoveInput { pub is_owned: bool, } +impl core::ops::Deref for TxRemoveInput { + type Target = nativeTxRemoveInput; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for TxRemoveInput { } +unsafe impl core::marker::Sync for TxRemoveInput { } impl Drop for TxRemoveInput { fn drop(&mut self) { if self.is_owned && !<*mut nativeTxRemoveInput>::is_null(self.inner) { @@ -3448,6 +3864,9 @@ impl TxRemoveInput { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The channel ID #[no_mangle] @@ -3542,6 +3961,12 @@ pub struct TxRemoveOutput { pub is_owned: bool, } +impl core::ops::Deref for TxRemoveOutput { + type Target = nativeTxRemoveOutput; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for TxRemoveOutput { } +unsafe impl core::marker::Sync for TxRemoveOutput { } impl Drop for TxRemoveOutput { fn drop(&mut self) { if self.is_owned && !<*mut nativeTxRemoveOutput>::is_null(self.inner) { @@ -3572,6 +3997,9 @@ impl TxRemoveOutput { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The channel ID #[no_mangle] @@ -3667,6 +4095,12 @@ pub struct TxComplete { pub is_owned: bool, } +impl core::ops::Deref for TxComplete { + type Target = nativeTxComplete; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for TxComplete { } +unsafe impl core::marker::Sync for TxComplete { } impl Drop for TxComplete { fn drop(&mut self) { if self.is_owned && !<*mut nativeTxComplete>::is_null(self.inner) { @@ -3697,6 +4131,9 @@ impl TxComplete { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The channel ID #[no_mangle] @@ -3780,6 +4217,12 @@ pub struct TxSignatures { pub is_owned: bool, } +impl core::ops::Deref for TxSignatures { + type Target = nativeTxSignatures; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for TxSignatures { } +unsafe impl core::marker::Sync for TxSignatures { } impl Drop for TxSignatures { fn drop(&mut self) { if self.is_owned && !<*mut nativeTxSignatures>::is_null(self.inner) { @@ -3810,6 +4253,9 @@ impl TxSignatures { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The channel ID #[no_mangle] @@ -3850,28 +4296,28 @@ pub extern "C" fn TxSignatures_set_witnesses(this_ptr: &mut TxSignatures, mut va } /// Optional signature for the shared input -- the previous funding outpoint -- signed by both peers #[no_mangle] -pub extern "C" fn TxSignatures_get_funding_outpoint_sig(this_ptr: &TxSignatures) -> crate::c_types::derived::COption_ECDSASignatureZ { - let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_outpoint_sig; +pub extern "C" fn TxSignatures_get_shared_input_signature(this_ptr: &TxSignatures) -> crate::c_types::derived::COption_ECDSASignatureZ { + let mut inner_val = &mut this_ptr.get_native_mut_ref().shared_input_signature; let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_ECDSASignatureZ::None } else { crate::c_types::derived::COption_ECDSASignatureZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option is otherwise un-expressable. */ { crate::c_types::ECDSASignature::from_rust(&(*inner_val.as_ref().unwrap()).clone()) }) }; local_inner_val } /// Optional signature for the shared input -- the previous funding outpoint -- signed by both peers #[no_mangle] -pub extern "C" fn TxSignatures_set_funding_outpoint_sig(this_ptr: &mut TxSignatures, mut val: crate::c_types::derived::COption_ECDSASignatureZ) { +pub extern "C" fn TxSignatures_set_shared_input_signature(this_ptr: &mut TxSignatures, mut val: crate::c_types::derived::COption_ECDSASignatureZ) { 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) }.funding_outpoint_sig = local_val; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.shared_input_signature = local_val; } /// Constructs a new TxSignatures given each field #[must_use] #[no_mangle] -pub extern "C" fn TxSignatures_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut tx_hash_arg: crate::c_types::ThirtyTwoBytes, mut witnesses_arg: crate::c_types::derived::CVec_WitnessZ, mut funding_outpoint_sig_arg: crate::c_types::derived::COption_ECDSASignatureZ) -> TxSignatures { +pub extern "C" fn TxSignatures_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut tx_hash_arg: crate::c_types::ThirtyTwoBytes, mut witnesses_arg: crate::c_types::derived::CVec_WitnessZ, mut shared_input_signature_arg: crate::c_types::derived::COption_ECDSASignatureZ) -> TxSignatures { let mut local_witnesses_arg = Vec::new(); for mut item in witnesses_arg.into_rust().drain(..) { local_witnesses_arg.push( { item.into_bitcoin() }); }; - let mut local_funding_outpoint_sig_arg = { /*funding_outpoint_sig_arg*/ let funding_outpoint_sig_arg_opt = funding_outpoint_sig_arg; if funding_outpoint_sig_arg_opt.is_none() { None } else { Some({ { { funding_outpoint_sig_arg_opt.take() }.into_rust() }})} }; + let mut local_shared_input_signature_arg = { /*shared_input_signature_arg*/ let shared_input_signature_arg_opt = shared_input_signature_arg; if shared_input_signature_arg_opt.is_none() { None } else { Some({ { { shared_input_signature_arg_opt.take() }.into_rust() }})} }; TxSignatures { inner: ObjOps::heap_alloc(nativeTxSignatures { channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) }, tx_hash: ::bitcoin::hash_types::Txid::from_slice(&tx_hash_arg.data[..]).unwrap(), witnesses: local_witnesses_arg, - funding_outpoint_sig: local_funding_outpoint_sig_arg, + shared_input_signature: local_shared_input_signature_arg, }), is_owned: true } } impl Clone for TxSignatures { @@ -3937,6 +4383,12 @@ pub struct TxInitRbf { pub is_owned: bool, } +impl core::ops::Deref for TxInitRbf { + type Target = nativeTxInitRbf; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for TxInitRbf { } +unsafe impl core::marker::Sync for TxInitRbf { } impl Drop for TxInitRbf { fn drop(&mut self) { if self.is_owned && !<*mut nativeTxInitRbf>::is_null(self.inner) { @@ -3967,6 +4419,9 @@ impl TxInitRbf { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The channel ID #[no_mangle] @@ -4091,6 +4546,12 @@ pub struct TxAckRbf { pub is_owned: bool, } +impl core::ops::Deref for TxAckRbf { + type Target = nativeTxAckRbf; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for TxAckRbf { } +unsafe impl core::marker::Sync for TxAckRbf { } impl Drop for TxAckRbf { fn drop(&mut self) { if self.is_owned && !<*mut nativeTxAckRbf>::is_null(self.inner) { @@ -4121,6 +4582,9 @@ impl TxAckRbf { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The channel ID #[no_mangle] @@ -4220,6 +4684,12 @@ pub struct TxAbort { pub is_owned: bool, } +impl core::ops::Deref for TxAbort { + type Target = nativeTxAbort; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for TxAbort { } +unsafe impl core::marker::Sync for TxAbort { } impl Drop for TxAbort { fn drop(&mut self) { if self.is_owned && !<*mut nativeTxAbort>::is_null(self.inner) { @@ -4250,6 +4720,9 @@ impl TxAbort { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The channel ID #[no_mangle] @@ -4350,6 +4823,12 @@ pub struct Shutdown { pub is_owned: bool, } +impl core::ops::Deref for Shutdown { + type Target = nativeShutdown; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for Shutdown { } +unsafe impl core::marker::Sync for Shutdown { } impl Drop for Shutdown { fn drop(&mut self) { if self.is_owned && !<*mut nativeShutdown>::is_null(self.inner) { @@ -4380,6 +4859,9 @@ impl Shutdown { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The channel ID #[no_mangle] @@ -4405,7 +4887,7 @@ pub extern "C" fn Shutdown_get_scriptpubkey(this_ptr: &Shutdown) -> crate::c_typ /// Must be in one of these forms: P2PKH, P2SH, P2WPKH, P2WSH, P2TR. #[no_mangle] pub extern "C" fn Shutdown_set_scriptpubkey(this_ptr: &mut Shutdown, mut val: crate::c_types::derived::CVec_u8Z) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.scriptpubkey = ::bitcoin::blockdata::script::ScriptBuf::from(val.into_rust()); + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.scriptpubkey = ::bitcoin::script::ScriptBuf::from(val.into_rust()); } /// Constructs a new Shutdown given each field #[must_use] @@ -4413,7 +4895,7 @@ pub extern "C" fn Shutdown_set_scriptpubkey(this_ptr: &mut Shutdown, mut val: cr pub extern "C" fn Shutdown_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut scriptpubkey_arg: crate::c_types::derived::CVec_u8Z) -> Shutdown { Shutdown { inner: ObjOps::heap_alloc(nativeShutdown { channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) }, - scriptpubkey: ::bitcoin::blockdata::script::ScriptBuf::from(scriptpubkey_arg.into_rust()), + scriptpubkey: ::bitcoin::script::ScriptBuf::from(scriptpubkey_arg.into_rust()), }), is_owned: true } } impl Clone for Shutdown { @@ -4480,6 +4962,12 @@ pub struct ClosingSignedFeeRange { pub is_owned: bool, } +impl core::ops::Deref for ClosingSignedFeeRange { + type Target = nativeClosingSignedFeeRange; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ClosingSignedFeeRange { } +unsafe impl core::marker::Sync for ClosingSignedFeeRange { } impl Drop for ClosingSignedFeeRange { fn drop(&mut self) { if self.is_owned && !<*mut nativeClosingSignedFeeRange>::is_null(self.inner) { @@ -4510,6 +4998,9 @@ impl ClosingSignedFeeRange { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The minimum absolute fee, in satoshis, which the sender is willing to place on the closing /// transaction. @@ -4609,6 +5100,12 @@ pub struct ClosingSigned { pub is_owned: bool, } +impl core::ops::Deref for ClosingSigned { + type Target = nativeClosingSigned; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ClosingSigned { } +unsafe impl core::marker::Sync for ClosingSigned { } impl Drop for ClosingSigned { fn drop(&mut self) { if self.is_owned && !<*mut nativeClosingSigned>::is_null(self.inner) { @@ -4639,6 +5136,9 @@ impl ClosingSigned { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The channel ID #[no_mangle] @@ -4769,6 +5269,12 @@ pub struct UpdateAddHTLC { pub is_owned: bool, } +impl core::ops::Deref for UpdateAddHTLC { + type Target = nativeUpdateAddHTLC; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for UpdateAddHTLC { } +unsafe impl core::marker::Sync for UpdateAddHTLC { } impl Drop for UpdateAddHTLC { fn drop(&mut self) { if self.is_owned && !<*mut nativeUpdateAddHTLC>::is_null(self.inner) { @@ -4799,6 +5305,9 @@ impl UpdateAddHTLC { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The channel ID #[no_mangle] @@ -4985,6 +5494,12 @@ pub struct OnionMessage { pub is_owned: bool, } +impl core::ops::Deref for OnionMessage { + type Target = nativeOnionMessage; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for OnionMessage { } +unsafe impl core::marker::Sync for OnionMessage { } impl Drop for OnionMessage { fn drop(&mut self) { if self.is_owned && !<*mut nativeOnionMessage>::is_null(self.inner) { @@ -5015,6 +5530,9 @@ impl OnionMessage { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Used in decrypting the onion packet's payload. #[no_mangle] @@ -5110,6 +5628,12 @@ pub struct UpdateFulfillHTLC { pub is_owned: bool, } +impl core::ops::Deref for UpdateFulfillHTLC { + type Target = nativeUpdateFulfillHTLC; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for UpdateFulfillHTLC { } +unsafe impl core::marker::Sync for UpdateFulfillHTLC { } impl Drop for UpdateFulfillHTLC { fn drop(&mut self) { if self.is_owned && !<*mut nativeUpdateFulfillHTLC>::is_null(self.inner) { @@ -5140,6 +5664,9 @@ impl UpdateFulfillHTLC { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The channel ID #[no_mangle] @@ -5247,6 +5774,12 @@ pub struct UpdateFailHTLC { pub is_owned: bool, } +impl core::ops::Deref for UpdateFailHTLC { + type Target = nativeUpdateFailHTLC; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for UpdateFailHTLC { } +unsafe impl core::marker::Sync for UpdateFailHTLC { } impl Drop for UpdateFailHTLC { fn drop(&mut self) { if self.is_owned && !<*mut nativeUpdateFailHTLC>::is_null(self.inner) { @@ -5277,6 +5810,9 @@ impl UpdateFailHTLC { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The channel ID #[no_mangle] @@ -5363,6 +5899,12 @@ pub struct UpdateFailMalformedHTLC { pub is_owned: bool, } +impl core::ops::Deref for UpdateFailMalformedHTLC { + type Target = nativeUpdateFailMalformedHTLC; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for UpdateFailMalformedHTLC { } +unsafe impl core::marker::Sync for UpdateFailMalformedHTLC { } impl Drop for UpdateFailMalformedHTLC { fn drop(&mut self) { if self.is_owned && !<*mut nativeUpdateFailMalformedHTLC>::is_null(self.inner) { @@ -5393,6 +5935,9 @@ impl UpdateFailMalformedHTLC { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The channel ID #[no_mangle] @@ -5469,20 +6014,18 @@ pub extern "C" fn UpdateFailMalformedHTLC_eq(a: &UpdateFailMalformedHTLC, b: &Up if a.get_native_ref() == b.get_native_ref() { true } else { false } } -use lightning::ln::msgs::CommitmentSigned as nativeCommitmentSignedImport; -pub(crate) type nativeCommitmentSigned = nativeCommitmentSignedImport; +use lightning::ln::msgs::CommitmentSignedBatch as nativeCommitmentSignedBatchImport; +pub(crate) type nativeCommitmentSignedBatch = nativeCommitmentSignedBatchImport; -/// 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 +/// Optional batch parameters for `commitment_signed` message. #[must_use] #[repr(C)] -pub struct CommitmentSigned { +pub struct CommitmentSignedBatch { /// A pointer to the opaque Rust object. /// Nearly everywhere, 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 nativeCommitmentSigned, + pub inner: *mut nativeCommitmentSignedBatch, /// Indicates that this is the only struct which contains the same pointer. /// Rust functions which take ownership of an object provided via an argument require @@ -5490,7 +6033,147 @@ pub struct CommitmentSigned { pub is_owned: bool, } -impl Drop for CommitmentSigned { +impl core::ops::Deref for CommitmentSignedBatch { + type Target = nativeCommitmentSignedBatch; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for CommitmentSignedBatch { } +unsafe impl core::marker::Sync for CommitmentSignedBatch { } +impl Drop for CommitmentSignedBatch { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeCommitmentSignedBatch>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the CommitmentSignedBatch, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn CommitmentSignedBatch_free(this_obj: CommitmentSignedBatch) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn CommitmentSignedBatch_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeCommitmentSignedBatch) }; +} +#[allow(unused)] +impl CommitmentSignedBatch { + pub(crate) fn get_native_ref(&self) -> &'static nativeCommitmentSignedBatch { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCommitmentSignedBatch { + 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 nativeCommitmentSignedBatch { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// Batch size N: all N `commitment_signed` messages must be received before being processed +#[no_mangle] +pub extern "C" fn CommitmentSignedBatch_get_batch_size(this_ptr: &CommitmentSignedBatch) -> u16 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().batch_size; + *inner_val +} +/// Batch size N: all N `commitment_signed` messages must be received before being processed +#[no_mangle] +pub extern "C" fn CommitmentSignedBatch_set_batch_size(this_ptr: &mut CommitmentSignedBatch, mut val: u16) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.batch_size = val; +} +/// The funding transaction, to discriminate among multiple pending funding transactions (e.g. in case of splicing) +#[no_mangle] +pub extern "C" fn CommitmentSignedBatch_get_funding_txid(this_ptr: &CommitmentSignedBatch) -> *const [u8; 32] { + let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_txid; + inner_val.as_ref() +} +/// The funding transaction, to discriminate among multiple pending funding transactions (e.g. in case of splicing) +#[no_mangle] +pub extern "C" fn CommitmentSignedBatch_set_funding_txid(this_ptr: &mut CommitmentSignedBatch, mut val: crate::c_types::ThirtyTwoBytes) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_txid = ::bitcoin::hash_types::Txid::from_slice(&val.data[..]).unwrap(); +} +/// Constructs a new CommitmentSignedBatch given each field +#[must_use] +#[no_mangle] +pub extern "C" fn CommitmentSignedBatch_new(mut batch_size_arg: u16, mut funding_txid_arg: crate::c_types::ThirtyTwoBytes) -> CommitmentSignedBatch { + CommitmentSignedBatch { inner: ObjOps::heap_alloc(nativeCommitmentSignedBatch { + batch_size: batch_size_arg, + funding_txid: ::bitcoin::hash_types::Txid::from_slice(&funding_txid_arg.data[..]).unwrap(), + }), is_owned: true } +} +impl Clone for CommitmentSignedBatch { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeCommitmentSignedBatch>::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 CommitmentSignedBatch_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeCommitmentSignedBatch)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the CommitmentSignedBatch +pub extern "C" fn CommitmentSignedBatch_clone(orig: &CommitmentSignedBatch) -> CommitmentSignedBatch { + orig.clone() +} +/// Get a string which allows debug introspection of a CommitmentSignedBatch object +pub extern "C" fn CommitmentSignedBatch_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::CommitmentSignedBatch }).into()} +/// Generates a non-cryptographic 64-bit hash of the CommitmentSignedBatch. +#[no_mangle] +pub extern "C" fn CommitmentSignedBatch_hash(o: &CommitmentSignedBatch) -> 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 CommitmentSignedBatchs 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 CommitmentSignedBatch_eq(a: &CommitmentSignedBatch, b: &CommitmentSignedBatch) -> 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::CommitmentSigned as nativeCommitmentSignedImport; +pub(crate) type nativeCommitmentSigned = nativeCommitmentSignedImport; + +/// 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 +#[must_use] +#[repr(C)] +pub struct CommitmentSigned { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, 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 nativeCommitmentSigned, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust 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 core::ops::Deref for CommitmentSigned { + type Target = nativeCommitmentSigned; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for CommitmentSigned { } +unsafe impl core::marker::Sync for CommitmentSigned { } +impl Drop for CommitmentSigned { fn drop(&mut self) { if self.is_owned && !<*mut nativeCommitmentSigned>::is_null(self.inner) { let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; @@ -5520,6 +6203,9 @@ impl CommitmentSigned { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The channel ID #[no_mangle] @@ -5558,15 +6244,36 @@ pub extern "C" fn CommitmentSigned_set_htlc_signatures(this_ptr: &mut Commitment 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) }.htlc_signatures = local_val; } +/// Optional batch size and other parameters +/// +/// 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 CommitmentSigned_get_batch(this_ptr: &CommitmentSigned) -> crate::lightning::ln::msgs::CommitmentSignedBatch { + let mut inner_val = &mut this_ptr.get_native_mut_ref().batch; + let mut local_inner_val = crate::lightning::ln::msgs::CommitmentSignedBatch { 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::msgs::CommitmentSignedBatch<>) as *mut _ }, is_owned: false }; + local_inner_val +} +/// Optional batch size and other parameters +/// +/// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None +#[no_mangle] +pub extern "C" fn CommitmentSigned_set_batch(this_ptr: &mut CommitmentSigned, mut val: crate::lightning::ln::msgs::CommitmentSignedBatch) { + 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) }.batch = local_val; +} /// Constructs a new CommitmentSigned given each field +/// +/// Note that batch_arg (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn CommitmentSigned_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut signature_arg: crate::c_types::ECDSASignature, mut htlc_signatures_arg: crate::c_types::derived::CVec_ECDSASignatureZ) -> CommitmentSigned { +pub extern "C" fn CommitmentSigned_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut signature_arg: crate::c_types::ECDSASignature, mut htlc_signatures_arg: crate::c_types::derived::CVec_ECDSASignatureZ, mut batch_arg: crate::lightning::ln::msgs::CommitmentSignedBatch) -> CommitmentSigned { let mut local_htlc_signatures_arg = Vec::new(); for mut item in htlc_signatures_arg.into_rust().drain(..) { local_htlc_signatures_arg.push( { item.into_rust() }); }; + let mut local_batch_arg = if batch_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(batch_arg.take_inner()) } }) }; CommitmentSigned { inner: ObjOps::heap_alloc(nativeCommitmentSigned { channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) }, signature: signature_arg.into_rust(), htlc_signatures: local_htlc_signatures_arg, + batch: local_batch_arg, }), is_owned: true } } impl Clone for CommitmentSigned { @@ -5632,6 +6339,12 @@ pub struct RevokeAndACK { pub is_owned: bool, } +impl core::ops::Deref for RevokeAndACK { + type Target = nativeRevokeAndACK; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for RevokeAndACK { } +unsafe impl core::marker::Sync for RevokeAndACK { } impl Drop for RevokeAndACK { fn drop(&mut self) { if self.is_owned && !<*mut nativeRevokeAndACK>::is_null(self.inner) { @@ -5662,6 +6375,9 @@ impl RevokeAndACK { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The channel ID #[no_mangle] @@ -5769,6 +6485,12 @@ pub struct UpdateFee { pub is_owned: bool, } +impl core::ops::Deref for UpdateFee { + type Target = nativeUpdateFee; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for UpdateFee { } +unsafe impl core::marker::Sync for UpdateFee { } impl Drop for UpdateFee { fn drop(&mut self) { if self.is_owned && !<*mut nativeUpdateFee>::is_null(self.inner) { @@ -5799,6 +6521,9 @@ impl UpdateFee { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The channel ID #[no_mangle] @@ -5894,6 +6619,12 @@ pub struct ChannelReestablish { pub is_owned: bool, } +impl core::ops::Deref for ChannelReestablish { + type Target = nativeChannelReestablish; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ChannelReestablish { } +unsafe impl core::marker::Sync for ChannelReestablish { } impl Drop for ChannelReestablish { fn drop(&mut self) { if self.is_owned && !<*mut nativeChannelReestablish>::is_null(self.inner) { @@ -5924,6 +6655,9 @@ impl ChannelReestablish { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The channel ID #[no_mangle] @@ -6072,6 +6806,12 @@ pub struct AnnouncementSignatures { pub is_owned: bool, } +impl core::ops::Deref for AnnouncementSignatures { + type Target = nativeAnnouncementSignatures; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for AnnouncementSignatures { } +unsafe impl core::marker::Sync for AnnouncementSignatures { } impl Drop for AnnouncementSignatures { fn drop(&mut self) { if self.is_owned && !<*mut nativeAnnouncementSignatures>::is_null(self.inner) { @@ -6102,6 +6842,9 @@ impl AnnouncementSignatures { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The channel ID #[no_mangle] @@ -6821,6 +7564,12 @@ pub struct UnsignedNodeAnnouncement { pub is_owned: bool, } +impl core::ops::Deref for UnsignedNodeAnnouncement { + type Target = nativeUnsignedNodeAnnouncement; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for UnsignedNodeAnnouncement { } +unsafe impl core::marker::Sync for UnsignedNodeAnnouncement { } impl Drop for UnsignedNodeAnnouncement { fn drop(&mut self) { if self.is_owned && !<*mut nativeUnsignedNodeAnnouncement>::is_null(self.inner) { @@ -6851,16 +7600,19 @@ impl UnsignedNodeAnnouncement { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The advertised features #[no_mangle] -pub extern "C" fn UnsignedNodeAnnouncement_get_features(this_ptr: &UnsignedNodeAnnouncement) -> crate::lightning::ln::features::NodeFeatures { +pub extern "C" fn UnsignedNodeAnnouncement_get_features(this_ptr: &UnsignedNodeAnnouncement) -> crate::lightning_types::features::NodeFeatures { let mut inner_val = &mut this_ptr.get_native_mut_ref().features; - crate::lightning::ln::features::NodeFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::features::NodeFeatures<>) as *mut _) }, is_owned: false } + crate::lightning_types::features::NodeFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning_types::features::NodeFeatures<>) as *mut _) }, is_owned: false } } /// The advertised features #[no_mangle] -pub extern "C" fn UnsignedNodeAnnouncement_set_features(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::lightning::ln::features::NodeFeatures) { +pub extern "C" fn UnsignedNodeAnnouncement_set_features(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::lightning_types::features::NodeFeatures) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) }; } /// A strictly monotonic announcement counter, with gaps allowed @@ -6973,7 +7725,7 @@ pub extern "C" fn UnsignedNodeAnnouncement_set_excess_data(this_ptr: &mut Unsign /// Constructs a new UnsignedNodeAnnouncement given each field #[must_use] #[no_mangle] -pub extern "C" fn UnsignedNodeAnnouncement_new(mut features_arg: crate::lightning::ln::features::NodeFeatures, mut timestamp_arg: u32, mut node_id_arg: crate::lightning::routing::gossip::NodeId, mut rgb_arg: crate::c_types::ThreeBytes, mut alias_arg: crate::lightning::routing::gossip::NodeAlias, mut addresses_arg: crate::c_types::derived::CVec_SocketAddressZ, mut excess_address_data_arg: crate::c_types::derived::CVec_u8Z, mut excess_data_arg: crate::c_types::derived::CVec_u8Z) -> UnsignedNodeAnnouncement { +pub extern "C" fn UnsignedNodeAnnouncement_new(mut features_arg: crate::lightning_types::features::NodeFeatures, mut timestamp_arg: u32, mut node_id_arg: crate::lightning::routing::gossip::NodeId, mut rgb_arg: crate::c_types::ThreeBytes, mut alias_arg: crate::lightning::routing::gossip::NodeAlias, mut addresses_arg: crate::c_types::derived::CVec_SocketAddressZ, mut excess_address_data_arg: crate::c_types::derived::CVec_u8Z, mut excess_data_arg: crate::c_types::derived::CVec_u8Z) -> UnsignedNodeAnnouncement { let mut local_addresses_arg = Vec::new(); for mut item in addresses_arg.into_rust().drain(..) { local_addresses_arg.push( { item.into_native() }); }; let mut local_excess_address_data_arg = Vec::new(); for mut item in excess_address_data_arg.into_rust().drain(..) { local_excess_address_data_arg.push( { item }); }; let mut local_excess_data_arg = Vec::new(); for mut item in excess_data_arg.into_rust().drain(..) { local_excess_data_arg.push( { item }); }; @@ -7051,6 +7803,12 @@ pub struct NodeAnnouncement { pub is_owned: bool, } +impl core::ops::Deref for NodeAnnouncement { + type Target = nativeNodeAnnouncement; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for NodeAnnouncement { } +unsafe impl core::marker::Sync for NodeAnnouncement { } impl Drop for NodeAnnouncement { fn drop(&mut self) { if self.is_owned && !<*mut nativeNodeAnnouncement>::is_null(self.inner) { @@ -7081,6 +7839,9 @@ impl NodeAnnouncement { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The signature by the node key #[no_mangle] @@ -7176,6 +7937,12 @@ pub struct UnsignedChannelAnnouncement { pub is_owned: bool, } +impl core::ops::Deref for UnsignedChannelAnnouncement { + type Target = nativeUnsignedChannelAnnouncement; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for UnsignedChannelAnnouncement { } +unsafe impl core::marker::Sync for UnsignedChannelAnnouncement { } impl Drop for UnsignedChannelAnnouncement { fn drop(&mut self) { if self.is_owned && !<*mut nativeUnsignedChannelAnnouncement>::is_null(self.inner) { @@ -7206,16 +7973,19 @@ impl UnsignedChannelAnnouncement { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The advertised channel features #[no_mangle] -pub extern "C" fn UnsignedChannelAnnouncement_get_features(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::ln::features::ChannelFeatures { +pub extern "C" fn UnsignedChannelAnnouncement_get_features(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning_types::features::ChannelFeatures { let mut inner_val = &mut this_ptr.get_native_mut_ref().features; - crate::lightning::ln::features::ChannelFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::features::ChannelFeatures<>) as *mut _) }, is_owned: false } + crate::lightning_types::features::ChannelFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning_types::features::ChannelFeatures<>) as *mut _) }, is_owned: false } } /// The advertised channel features #[no_mangle] -pub extern "C" fn UnsignedChannelAnnouncement_set_features(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::ln::features::ChannelFeatures) { +pub extern "C" fn UnsignedChannelAnnouncement_set_features(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning_types::features::ChannelFeatures) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) }; } /// The genesis hash of the blockchain where the channel is to be opened @@ -7227,7 +7997,7 @@ pub extern "C" fn UnsignedChannelAnnouncement_get_chain_hash(this_ptr: &Unsigned /// The genesis hash of the blockchain where the channel is to be opened #[no_mangle] pub extern "C" fn UnsignedChannelAnnouncement_set_chain_hash(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data); + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::constants::ChainHash::from(&val.data); } /// The short channel ID #[no_mangle] @@ -7308,11 +8078,11 @@ pub extern "C" fn UnsignedChannelAnnouncement_set_excess_data(this_ptr: &mut Uns /// Constructs a new UnsignedChannelAnnouncement given each field #[must_use] #[no_mangle] -pub extern "C" fn UnsignedChannelAnnouncement_new(mut features_arg: crate::lightning::ln::features::ChannelFeatures, mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut short_channel_id_arg: u64, mut node_id_1_arg: crate::lightning::routing::gossip::NodeId, mut node_id_2_arg: crate::lightning::routing::gossip::NodeId, mut bitcoin_key_1_arg: crate::lightning::routing::gossip::NodeId, mut bitcoin_key_2_arg: crate::lightning::routing::gossip::NodeId, mut excess_data_arg: crate::c_types::derived::CVec_u8Z) -> UnsignedChannelAnnouncement { +pub extern "C" fn UnsignedChannelAnnouncement_new(mut features_arg: crate::lightning_types::features::ChannelFeatures, mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut short_channel_id_arg: u64, mut node_id_1_arg: crate::lightning::routing::gossip::NodeId, mut node_id_2_arg: crate::lightning::routing::gossip::NodeId, mut bitcoin_key_1_arg: crate::lightning::routing::gossip::NodeId, mut bitcoin_key_2_arg: crate::lightning::routing::gossip::NodeId, mut excess_data_arg: crate::c_types::derived::CVec_u8Z) -> UnsignedChannelAnnouncement { let mut local_excess_data_arg = Vec::new(); for mut item in excess_data_arg.into_rust().drain(..) { local_excess_data_arg.push( { item }); }; UnsignedChannelAnnouncement { inner: ObjOps::heap_alloc(nativeUnsignedChannelAnnouncement { features: *unsafe { Box::from_raw(features_arg.take_inner()) }, - chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data), + chain_hash: ::bitcoin::constants::ChainHash::from(&chain_hash_arg.data), short_channel_id: short_channel_id_arg, node_id_1: *unsafe { Box::from_raw(node_id_1_arg.take_inner()) }, node_id_2: *unsafe { Box::from_raw(node_id_2_arg.take_inner()) }, @@ -7384,6 +8154,12 @@ pub struct ChannelAnnouncement { pub is_owned: bool, } +impl core::ops::Deref for ChannelAnnouncement { + type Target = nativeChannelAnnouncement; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ChannelAnnouncement { } +unsafe impl core::marker::Sync for ChannelAnnouncement { } impl Drop for ChannelAnnouncement { fn drop(&mut self) { if self.is_owned && !<*mut nativeChannelAnnouncement>::is_null(self.inner) { @@ -7414,6 +8190,9 @@ impl ChannelAnnouncement { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Authentication of the announcement by the first public node #[no_mangle] @@ -7545,6 +8324,12 @@ pub struct UnsignedChannelUpdate { pub is_owned: bool, } +impl core::ops::Deref for UnsignedChannelUpdate { + type Target = nativeUnsignedChannelUpdate; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for UnsignedChannelUpdate { } +unsafe impl core::marker::Sync for UnsignedChannelUpdate { } impl Drop for UnsignedChannelUpdate { fn drop(&mut self) { if self.is_owned && !<*mut nativeUnsignedChannelUpdate>::is_null(self.inner) { @@ -7575,6 +8360,9 @@ impl UnsignedChannelUpdate { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The genesis hash of the blockchain where the channel is to be opened #[no_mangle] @@ -7585,7 +8373,7 @@ pub extern "C" fn UnsignedChannelUpdate_get_chain_hash(this_ptr: &UnsignedChanne /// The genesis hash of the blockchain where the channel is to be opened #[no_mangle] pub extern "C" fn UnsignedChannelUpdate_set_chain_hash(this_ptr: &mut UnsignedChannelUpdate, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data); + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::constants::ChainHash::from(&val.data); } /// The short channel ID #[no_mangle] @@ -7609,16 +8397,29 @@ pub extern "C" fn UnsignedChannelUpdate_get_timestamp(this_ptr: &UnsignedChannel pub extern "C" fn UnsignedChannelUpdate_set_timestamp(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp = val; } -/// Channel flags +/// Flags pertaining to this message. +#[no_mangle] +pub extern "C" fn UnsignedChannelUpdate_get_message_flags(this_ptr: &UnsignedChannelUpdate) -> u8 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().message_flags; + *inner_val +} +/// Flags pertaining to this message. #[no_mangle] -pub extern "C" fn UnsignedChannelUpdate_get_flags(this_ptr: &UnsignedChannelUpdate) -> u8 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().flags; +pub extern "C" fn UnsignedChannelUpdate_set_message_flags(this_ptr: &mut UnsignedChannelUpdate, mut val: u8) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.message_flags = val; +} +/// Flags pertaining to the channel, including to which direction in the channel this update +/// applies and whether the direction is currently able to forward HTLCs. +#[no_mangle] +pub extern "C" fn UnsignedChannelUpdate_get_channel_flags(this_ptr: &UnsignedChannelUpdate) -> u8 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_flags; *inner_val } -/// Channel flags +/// Flags pertaining to the channel, including to which direction in the channel this update +/// applies and whether the direction is currently able to forward HTLCs. #[no_mangle] -pub extern "C" fn UnsignedChannelUpdate_set_flags(this_ptr: &mut UnsignedChannelUpdate, mut val: u8) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.flags = val; +pub extern "C" fn UnsignedChannelUpdate_set_channel_flags(this_ptr: &mut UnsignedChannelUpdate, mut val: u8) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_flags = val; } /// The number of blocks such that if: /// `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta` @@ -7717,13 +8518,14 @@ pub extern "C" fn UnsignedChannelUpdate_set_excess_data(this_ptr: &mut UnsignedC /// Constructs a new UnsignedChannelUpdate given each field #[must_use] #[no_mangle] -pub extern "C" fn UnsignedChannelUpdate_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut short_channel_id_arg: u64, mut timestamp_arg: u32, mut flags_arg: u8, mut cltv_expiry_delta_arg: u16, mut htlc_minimum_msat_arg: u64, mut htlc_maximum_msat_arg: u64, mut fee_base_msat_arg: u32, mut fee_proportional_millionths_arg: u32, mut excess_data_arg: crate::c_types::derived::CVec_u8Z) -> UnsignedChannelUpdate { +pub extern "C" fn UnsignedChannelUpdate_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut short_channel_id_arg: u64, mut timestamp_arg: u32, mut message_flags_arg: u8, mut channel_flags_arg: u8, mut cltv_expiry_delta_arg: u16, mut htlc_minimum_msat_arg: u64, mut htlc_maximum_msat_arg: u64, mut fee_base_msat_arg: u32, mut fee_proportional_millionths_arg: u32, mut excess_data_arg: crate::c_types::derived::CVec_u8Z) -> UnsignedChannelUpdate { let mut local_excess_data_arg = Vec::new(); for mut item in excess_data_arg.into_rust().drain(..) { local_excess_data_arg.push( { item }); }; UnsignedChannelUpdate { inner: ObjOps::heap_alloc(nativeUnsignedChannelUpdate { - chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data), + chain_hash: ::bitcoin::constants::ChainHash::from(&chain_hash_arg.data), short_channel_id: short_channel_id_arg, timestamp: timestamp_arg, - flags: flags_arg, + message_flags: message_flags_arg, + channel_flags: channel_flags_arg, cltv_expiry_delta: cltv_expiry_delta_arg, htlc_minimum_msat: htlc_minimum_msat_arg, htlc_maximum_msat: htlc_maximum_msat_arg, @@ -7795,6 +8597,12 @@ pub struct ChannelUpdate { pub is_owned: bool, } +impl core::ops::Deref for ChannelUpdate { + type Target = nativeChannelUpdate; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ChannelUpdate { } +unsafe impl core::marker::Sync for ChannelUpdate { } impl Drop for ChannelUpdate { fn drop(&mut self) { if self.is_owned && !<*mut nativeChannelUpdate>::is_null(self.inner) { @@ -7825,6 +8633,9 @@ impl ChannelUpdate { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// A signature of the channel update #[no_mangle] @@ -7923,6 +8734,12 @@ pub struct QueryChannelRange { pub is_owned: bool, } +impl core::ops::Deref for QueryChannelRange { + type Target = nativeQueryChannelRange; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for QueryChannelRange { } +unsafe impl core::marker::Sync for QueryChannelRange { } impl Drop for QueryChannelRange { fn drop(&mut self) { if self.is_owned && !<*mut nativeQueryChannelRange>::is_null(self.inner) { @@ -7953,6 +8770,9 @@ impl QueryChannelRange { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The genesis hash of the blockchain being queried #[no_mangle] @@ -7963,7 +8783,7 @@ pub extern "C" fn QueryChannelRange_get_chain_hash(this_ptr: &QueryChannelRange) /// The genesis hash of the blockchain being queried #[no_mangle] pub extern "C" fn QueryChannelRange_set_chain_hash(this_ptr: &mut QueryChannelRange, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data); + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::constants::ChainHash::from(&val.data); } /// The height of the first block for the channel UTXOs being queried #[no_mangle] @@ -7992,7 +8812,7 @@ pub extern "C" fn QueryChannelRange_set_number_of_blocks(this_ptr: &mut QueryCha #[no_mangle] pub extern "C" fn QueryChannelRange_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut first_blocknum_arg: u32, mut number_of_blocks_arg: u32) -> QueryChannelRange { QueryChannelRange { inner: ObjOps::heap_alloc(nativeQueryChannelRange { - chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data), + chain_hash: ::bitcoin::constants::ChainHash::from(&chain_hash_arg.data), first_blocknum: first_blocknum_arg, number_of_blocks: number_of_blocks_arg, }), is_owned: true } @@ -8068,6 +8888,12 @@ pub struct ReplyChannelRange { pub is_owned: bool, } +impl core::ops::Deref for ReplyChannelRange { + type Target = nativeReplyChannelRange; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ReplyChannelRange { } +unsafe impl core::marker::Sync for ReplyChannelRange { } impl Drop for ReplyChannelRange { fn drop(&mut self) { if self.is_owned && !<*mut nativeReplyChannelRange>::is_null(self.inner) { @@ -8098,6 +8924,9 @@ impl ReplyChannelRange { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The genesis hash of the blockchain being queried #[no_mangle] @@ -8108,7 +8937,7 @@ pub extern "C" fn ReplyChannelRange_get_chain_hash(this_ptr: &ReplyChannelRange) /// The genesis hash of the blockchain being queried #[no_mangle] pub extern "C" fn ReplyChannelRange_set_chain_hash(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data); + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::constants::ChainHash::from(&val.data); } /// The height of the first block in the range of the reply #[no_mangle] @@ -8164,7 +8993,7 @@ pub extern "C" fn ReplyChannelRange_set_short_channel_ids(this_ptr: &mut ReplyCh pub extern "C" fn ReplyChannelRange_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut first_blocknum_arg: u32, mut number_of_blocks_arg: u32, mut sync_complete_arg: bool, mut short_channel_ids_arg: crate::c_types::derived::CVec_u64Z) -> ReplyChannelRange { let mut local_short_channel_ids_arg = Vec::new(); for mut item in short_channel_ids_arg.into_rust().drain(..) { local_short_channel_ids_arg.push( { item }); }; ReplyChannelRange { inner: ObjOps::heap_alloc(nativeReplyChannelRange { - chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data), + chain_hash: ::bitcoin::constants::ChainHash::from(&chain_hash_arg.data), first_blocknum: first_blocknum_arg, number_of_blocks: number_of_blocks_arg, sync_complete: sync_complete_arg, @@ -8242,6 +9071,12 @@ pub struct QueryShortChannelIds { pub is_owned: bool, } +impl core::ops::Deref for QueryShortChannelIds { + type Target = nativeQueryShortChannelIds; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for QueryShortChannelIds { } +unsafe impl core::marker::Sync for QueryShortChannelIds { } impl Drop for QueryShortChannelIds { fn drop(&mut self) { if self.is_owned && !<*mut nativeQueryShortChannelIds>::is_null(self.inner) { @@ -8272,6 +9107,9 @@ impl QueryShortChannelIds { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The genesis hash of the blockchain being queried #[no_mangle] @@ -8282,7 +9120,7 @@ pub extern "C" fn QueryShortChannelIds_get_chain_hash(this_ptr: &QueryShortChann /// The genesis hash of the blockchain being queried #[no_mangle] pub extern "C" fn QueryShortChannelIds_set_chain_hash(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data); + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::constants::ChainHash::from(&val.data); } /// The short_channel_ids that are being queried /// @@ -8305,7 +9143,7 @@ pub extern "C" fn QueryShortChannelIds_set_short_channel_ids(this_ptr: &mut Quer pub extern "C" fn QueryShortChannelIds_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut short_channel_ids_arg: crate::c_types::derived::CVec_u64Z) -> QueryShortChannelIds { let mut local_short_channel_ids_arg = Vec::new(); for mut item in short_channel_ids_arg.into_rust().drain(..) { local_short_channel_ids_arg.push( { item }); }; QueryShortChannelIds { inner: ObjOps::heap_alloc(nativeQueryShortChannelIds { - chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data), + chain_hash: ::bitcoin::constants::ChainHash::from(&chain_hash_arg.data), short_channel_ids: local_short_channel_ids_arg, }), is_owned: true } } @@ -8375,6 +9213,12 @@ pub struct ReplyShortChannelIdsEnd { pub is_owned: bool, } +impl core::ops::Deref for ReplyShortChannelIdsEnd { + type Target = nativeReplyShortChannelIdsEnd; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ReplyShortChannelIdsEnd { } +unsafe impl core::marker::Sync for ReplyShortChannelIdsEnd { } impl Drop for ReplyShortChannelIdsEnd { fn drop(&mut self) { if self.is_owned && !<*mut nativeReplyShortChannelIdsEnd>::is_null(self.inner) { @@ -8405,6 +9249,9 @@ impl ReplyShortChannelIdsEnd { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The genesis hash of the blockchain that was queried #[no_mangle] @@ -8415,7 +9262,7 @@ pub extern "C" fn ReplyShortChannelIdsEnd_get_chain_hash(this_ptr: &ReplyShortCh /// The genesis hash of the blockchain that was queried #[no_mangle] pub extern "C" fn ReplyShortChannelIdsEnd_set_chain_hash(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data); + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::constants::ChainHash::from(&val.data); } /// Indicates if the query recipient maintains up-to-date channel /// information for the `chain_hash` @@ -8435,7 +9282,7 @@ pub extern "C" fn ReplyShortChannelIdsEnd_set_full_information(this_ptr: &mut Re #[no_mangle] pub extern "C" fn ReplyShortChannelIdsEnd_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut full_information_arg: bool) -> ReplyShortChannelIdsEnd { ReplyShortChannelIdsEnd { inner: ObjOps::heap_alloc(nativeReplyShortChannelIdsEnd { - chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data), + chain_hash: ::bitcoin::constants::ChainHash::from(&chain_hash_arg.data), full_information: full_information_arg, }), is_owned: true } } @@ -8504,6 +9351,12 @@ pub struct GossipTimestampFilter { pub is_owned: bool, } +impl core::ops::Deref for GossipTimestampFilter { + type Target = nativeGossipTimestampFilter; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for GossipTimestampFilter { } +unsafe impl core::marker::Sync for GossipTimestampFilter { } impl Drop for GossipTimestampFilter { fn drop(&mut self) { if self.is_owned && !<*mut nativeGossipTimestampFilter>::is_null(self.inner) { @@ -8534,6 +9387,9 @@ impl GossipTimestampFilter { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The genesis hash of the blockchain for channel and node information #[no_mangle] @@ -8544,7 +9400,7 @@ pub extern "C" fn GossipTimestampFilter_get_chain_hash(this_ptr: &GossipTimestam /// The genesis hash of the blockchain for channel and node information #[no_mangle] pub extern "C" fn GossipTimestampFilter_set_chain_hash(this_ptr: &mut GossipTimestampFilter, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data); + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::constants::ChainHash::from(&val.data); } /// The starting unix timestamp #[no_mangle] @@ -8573,7 +9429,7 @@ pub extern "C" fn GossipTimestampFilter_set_timestamp_range(this_ptr: &mut Gossi #[no_mangle] pub extern "C" fn GossipTimestampFilter_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut first_timestamp_arg: u32, mut timestamp_range_arg: u32) -> GossipTimestampFilter { GossipTimestampFilter { inner: ObjOps::heap_alloc(nativeGossipTimestampFilter { - chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data), + chain_hash: ::bitcoin::constants::ChainHash::from(&chain_hash_arg.data), first_timestamp: first_timestamp_arg, timestamp_range: timestamp_range_arg, }), is_owned: true } @@ -8907,6 +9763,12 @@ pub struct LightningError { pub is_owned: bool, } +impl core::ops::Deref for LightningError { + type Target = nativeLightningError; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for LightningError { } +unsafe impl core::marker::Sync for LightningError { } impl Drop for LightningError { fn drop(&mut self) { if self.is_owned && !<*mut nativeLightningError>::is_null(self.inner) { @@ -8937,6 +9799,9 @@ impl LightningError { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// A human-readable message describing the error #[no_mangle] @@ -9012,6 +9877,12 @@ pub struct CommitmentUpdate { pub is_owned: bool, } +impl core::ops::Deref for CommitmentUpdate { + type Target = nativeCommitmentUpdate; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for CommitmentUpdate { } +unsafe impl core::marker::Sync for CommitmentUpdate { } impl Drop for CommitmentUpdate { fn drop(&mut self) { if self.is_owned && !<*mut nativeCommitmentUpdate>::is_null(self.inner) { @@ -9042,6 +9913,9 @@ impl CommitmentUpdate { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// `update_add_htlc` messages which should be sent #[no_mangle] @@ -9264,13 +10138,13 @@ 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. - pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures, + pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning_types::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`]. - pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures, + pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning_types::features::InitFeatures, /// Gets the chain hashes for this `ChannelMessageHandler` indicating which chains it supports. /// /// If it's `None`, then no particular network chain hash compatibility will be enforced when @@ -9334,6 +10208,13 @@ impl lightning::events::MessageSendEventsProvider for ChannelMessageHandler { local_ret } } +impl lightning::events::MessageSendEventsProvider for ChannelMessageHandlerRef { + fn get_and_clear_pending_msg_events(&self) -> Vec { + let mut ret = (self.0.MessageSendEventsProvider.get_and_clear_pending_msg_events)(self.0.MessageSendEventsProvider.this_arg); + let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); }; + local_ret + } +} use lightning::ln::msgs::ChannelMessageHandler as rustChannelMessageHandler; impl rustChannelMessageHandler for ChannelMessageHandler { @@ -9435,17 +10316,132 @@ impl rustChannelMessageHandler for ChannelMessageHandler { fn handle_error(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ErrorMessage) { (self.handle_error)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::ErrorMessage { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::ErrorMessage<>) as *mut _) }, is_owned: false }) } - fn provided_node_features(&self) -> lightning::ln::features::NodeFeatures { + fn provided_node_features(&self) -> lightning_types::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 { + fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning_types::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()) } } - fn get_chain_hashes(&self) -> Option> { + fn get_chain_hashes(&self) -> Option> { let mut ret = (self.get_chain_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 }})} }; + 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::constants::ChainHash::from(&item.data) }); }; local_ret_0 }})} }; + local_ret + } +} + +pub struct ChannelMessageHandlerRef(ChannelMessageHandler); +impl rustChannelMessageHandler for ChannelMessageHandlerRef { + fn handle_open_channel(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::OpenChannel) { + (self.0.handle_open_channel)(self.0.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.0.handle_open_channel_v2)(self.0.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.0.handle_accept_channel)(self.0.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.0.handle_accept_channel_v2)(self.0.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.0.handle_funding_created)(self.0.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 }) + } + fn handle_funding_signed(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::FundingSigned) { + (self.0.handle_funding_signed)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::FundingSigned { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::FundingSigned<>) as *mut _) }, is_owned: false }) + } + fn handle_channel_ready(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ChannelReady) { + (self.0.handle_channel_ready)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::ChannelReady { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::ChannelReady<>) as *mut _) }, is_owned: false }) + } + fn handle_shutdown(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::Shutdown) { + (self.0.handle_shutdown)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::Shutdown { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::Shutdown<>) as *mut _) }, is_owned: false }) + } + fn handle_closing_signed(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ClosingSigned) { + (self.0.handle_closing_signed)(self.0.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_stfu(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::Stfu) { + (self.0.handle_stfu)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::Stfu { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::Stfu<>) 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.0.handle_tx_add_input)(self.0.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.0.handle_tx_add_output)(self.0.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.0.handle_tx_remove_input)(self.0.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.0.handle_tx_remove_output)(self.0.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.0.handle_tx_complete)(self.0.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.0.handle_tx_signatures)(self.0.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.0.handle_tx_init_rbf)(self.0.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.0.handle_tx_ack_rbf)(self.0.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.0.handle_tx_abort)(self.0.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.0.handle_update_add_htlc)(self.0.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 }) + } + fn handle_update_fulfill_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFulfillHTLC) { + (self.0.handle_update_fulfill_htlc)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::UpdateFulfillHTLC { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::UpdateFulfillHTLC<>) as *mut _) }, is_owned: false }) + } + fn handle_update_fail_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFailHTLC) { + (self.0.handle_update_fail_htlc)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::UpdateFailHTLC { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::UpdateFailHTLC<>) as *mut _) }, is_owned: false }) + } + fn handle_update_fail_malformed_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFailMalformedHTLC) { + (self.0.handle_update_fail_malformed_htlc)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::UpdateFailMalformedHTLC { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::UpdateFailMalformedHTLC<>) as *mut _) }, is_owned: false }) + } + fn handle_commitment_signed(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::CommitmentSigned) { + (self.0.handle_commitment_signed)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::CommitmentSigned { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::CommitmentSigned<>) as *mut _) }, is_owned: false }) + } + fn handle_revoke_and_ack(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::RevokeAndACK) { + (self.0.handle_revoke_and_ack)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::RevokeAndACK { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::RevokeAndACK<>) as *mut _) }, is_owned: false }) + } + fn handle_update_fee(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFee) { + (self.0.handle_update_fee)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::UpdateFee { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::UpdateFee<>) as *mut _) }, is_owned: false }) + } + fn handle_announcement_signatures(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::AnnouncementSignatures) { + (self.0.handle_announcement_signatures)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::AnnouncementSignatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::AnnouncementSignatures<>) as *mut _) }, is_owned: false }) + } + fn peer_disconnected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) { + (self.0.peer_disconnected)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id)) + } + fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::Init, mut inbound: bool) -> Result<(), ()> { + let mut ret = (self.0.peer_connected)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::Init { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::Init<>) as *mut _) }, is_owned: false }, inbound); + 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 handle_channel_reestablish(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ChannelReestablish) { + (self.0.handle_channel_reestablish)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::ChannelReestablish { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::ChannelReestablish<>) as *mut _) }, is_owned: false }) + } + fn handle_channel_update(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ChannelUpdate) { + (self.0.handle_channel_update)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::ChannelUpdate { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::ChannelUpdate<>) as *mut _) }, is_owned: false }) + } + fn handle_error(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ErrorMessage) { + (self.0.handle_error)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::ErrorMessage { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::ErrorMessage<>) as *mut _) }, is_owned: false }) + } + fn provided_node_features(&self) -> lightning_types::features::NodeFeatures { + let mut ret = (self.0.provided_node_features)(self.0.this_arg); + *unsafe { Box::from_raw(ret.take_inner()) } + } + fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning_types::features::InitFeatures { + let mut ret = (self.0.provided_init_features)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id)); + *unsafe { Box::from_raw(ret.take_inner()) } + } + fn get_chain_hashes(&self) -> Option> { + let mut ret = (self.0.get_chain_hashes)(self.0.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::constants::ChainHash::from(&item.data) }); }; local_ret_0 }})} }; local_ret } } @@ -9453,14 +10449,14 @@ impl rustChannelMessageHandler for ChannelMessageHandler { // 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 ChannelMessageHandler { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = ChannelMessageHandlerRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const ChannelMessageHandlerRef) } } } impl core::ops::DerefMut for ChannelMessageHandler { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut ChannelMessageHandlerRef { + unsafe { &mut *(self as *mut _ as *mut ChannelMessageHandlerRef) } } } /// Calls the free function if one is set @@ -9537,13 +10533,13 @@ pub struct RoutingMessageHandler { /// 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. - pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures, + pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning_types::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`]. - pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures, + pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning_types::features::InitFeatures, /// Implementation of MessageSendEventsProvider for this object. pub MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider, /// Frees any resources associated with this object given its this_arg pointer. @@ -9580,6 +10576,13 @@ impl lightning::events::MessageSendEventsProvider for RoutingMessageHandler { local_ret } } +impl lightning::events::MessageSendEventsProvider for RoutingMessageHandlerRef { + fn get_and_clear_pending_msg_events(&self) -> Vec { + let mut ret = (self.0.MessageSendEventsProvider.get_and_clear_pending_msg_events)(self.0.MessageSendEventsProvider.this_arg); + let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); }; + local_ret + } +} use lightning::ln::msgs::RoutingMessageHandler as rustRoutingMessageHandler; impl rustRoutingMessageHandler for RoutingMessageHandler { @@ -9638,27 +10641,94 @@ impl rustRoutingMessageHandler for RoutingMessageHandler { let mut ret = (self.processing_queue_high)(self.this_arg); ret } - fn provided_node_features(&self) -> lightning::ln::features::NodeFeatures { + fn provided_node_features(&self) -> lightning_types::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 { + fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning_types::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()) } } } +pub struct RoutingMessageHandlerRef(RoutingMessageHandler); +impl rustRoutingMessageHandler for RoutingMessageHandlerRef { + fn handle_node_announcement(&self, mut msg: &lightning::ln::msgs::NodeAnnouncement) -> Result { + let mut ret = (self.0.handle_node_announcement)(self.0.this_arg, &crate::lightning::ln::msgs::NodeAnnouncement { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::NodeAnnouncement<>) 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((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })}; + local_ret + } + fn handle_channel_announcement(&self, mut msg: &lightning::ln::msgs::ChannelAnnouncement) -> Result { + let mut ret = (self.0.handle_channel_announcement)(self.0.this_arg, &crate::lightning::ln::msgs::ChannelAnnouncement { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::ChannelAnnouncement<>) 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((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })}; + local_ret + } + fn handle_channel_update(&self, mut msg: &lightning::ln::msgs::ChannelUpdate) -> Result { + let mut ret = (self.0.handle_channel_update)(self.0.this_arg, &crate::lightning::ln::msgs::ChannelUpdate { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::ChannelUpdate<>) 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((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })}; + local_ret + } + fn get_next_channel_announcement(&self, mut starting_point: u64) -> Option<(lightning::ln::msgs::ChannelAnnouncement, Option, Option)> { + let mut ret = (self.0.get_next_channel_announcement)(self.0.this_arg, starting_point); + let mut local_ret = if ret.is_some() { Some( { let (mut orig_ret_0_0, mut orig_ret_0_1, mut orig_ret_0_2) = ret.take().to_rust(); let mut local_orig_ret_0_1 = if orig_ret_0_1.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(orig_ret_0_1.take_inner()) } }) }; let mut local_orig_ret_0_2 = if orig_ret_0_2.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(orig_ret_0_2.take_inner()) } }) }; let mut local_ret_0 = (*unsafe { Box::from_raw(orig_ret_0_0.take_inner()) }, local_orig_ret_0_1, local_orig_ret_0_2); local_ret_0 }) } else { None }; + local_ret + } + fn get_next_node_announcement(&self, mut starting_point: Option<&lightning::routing::gossip::NodeId>) -> Option { + let mut local_starting_point = crate::lightning::routing::gossip::NodeId { inner: unsafe { (if starting_point.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (starting_point.unwrap()) }) } as *const lightning::routing::gossip::NodeId<>) as *mut _ }, is_owned: false }; + let mut ret = (self.0.get_next_node_announcement)(self.0.this_arg, local_starting_point); + let mut local_ret = if ret.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(ret.take_inner()) } }) }; + local_ret + } + fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut init: &lightning::ln::msgs::Init, mut inbound: bool) -> Result<(), ()> { + let mut ret = (self.0.peer_connected)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::Init { inner: unsafe { ObjOps::nonnull_ptr_to_inner((init as *const lightning::ln::msgs::Init<>) as *mut _) }, is_owned: false }, inbound); + 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 handle_reply_channel_range(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: lightning::ln::msgs::ReplyChannelRange) -> Result<(), lightning::ln::msgs::LightningError> { + let mut ret = (self.0.handle_reply_channel_range)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), crate::lightning::ln::msgs::ReplyChannelRange { inner: ObjOps::heap_alloc(msg), is_owned: true }); + 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((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })}; + local_ret + } + fn handle_reply_short_channel_ids_end(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: lightning::ln::msgs::ReplyShortChannelIdsEnd) -> Result<(), lightning::ln::msgs::LightningError> { + let mut ret = (self.0.handle_reply_short_channel_ids_end)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), crate::lightning::ln::msgs::ReplyShortChannelIdsEnd { inner: ObjOps::heap_alloc(msg), is_owned: true }); + 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((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })}; + local_ret + } + fn handle_query_channel_range(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: lightning::ln::msgs::QueryChannelRange) -> Result<(), lightning::ln::msgs::LightningError> { + let mut ret = (self.0.handle_query_channel_range)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), crate::lightning::ln::msgs::QueryChannelRange { inner: ObjOps::heap_alloc(msg), is_owned: true }); + 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((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })}; + local_ret + } + fn handle_query_short_channel_ids(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: lightning::ln::msgs::QueryShortChannelIds) -> Result<(), lightning::ln::msgs::LightningError> { + let mut ret = (self.0.handle_query_short_channel_ids)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), crate::lightning::ln::msgs::QueryShortChannelIds { inner: ObjOps::heap_alloc(msg), is_owned: true }); + 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((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })}; + local_ret + } + fn processing_queue_high(&self) -> bool { + let mut ret = (self.0.processing_queue_high)(self.0.this_arg); + ret + } + fn provided_node_features(&self) -> lightning_types::features::NodeFeatures { + let mut ret = (self.0.provided_node_features)(self.0.this_arg); + *unsafe { Box::from_raw(ret.take_inner()) } + } + fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning_types::features::InitFeatures { + let mut ret = (self.0.provided_init_features)(self.0.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 // directly as a Deref trait in higher-level structs: impl core::ops::Deref for RoutingMessageHandler { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = RoutingMessageHandlerRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const RoutingMessageHandlerRef) } } } impl core::ops::DerefMut for RoutingMessageHandler { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut RoutingMessageHandlerRef { + unsafe { &mut *(self as *mut _ as *mut RoutingMessageHandlerRef) } } } /// Calls the free function if one is set @@ -9677,14 +10747,6 @@ pub struct OnionMessageHandler { /// 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, - /// Because much of the lightning network does not yet support forwarding onion messages, we - /// may need to directly connect to a node which will forward a message for us. In such a case, - /// this method will return the set of nodes which need connection by node_id and the - /// corresponding socket addresses where they may accept incoming connections. - /// - /// Thus, this method should be polled regularly to detect messages await such a direct - /// connection. - pub get_and_clear_connections_needed: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ, /// Handle an incoming `onion_message` message from the given peer. pub handle_onion_message: extern "C" fn (this_arg: *const c_void, peer_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::OnionMessage), /// Returns the next pending onion message for the peer with the given node id. @@ -9707,13 +10769,13 @@ 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. - pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures, + pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning_types::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`]. - pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures, + pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning_types::features::InitFeatures, /// 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, @@ -9724,7 +10786,6 @@ unsafe impl Sync for OnionMessageHandler {} pub(crate) fn OnionMessageHandler_clone_fields(orig: &OnionMessageHandler) -> OnionMessageHandler { OnionMessageHandler { this_arg: orig.this_arg, - get_and_clear_connections_needed: Clone::clone(&orig.get_and_clear_connections_needed), handle_onion_message: Clone::clone(&orig.handle_onion_message), next_onion_message_for_peer: Clone::clone(&orig.next_onion_message_for_peer), peer_connected: Clone::clone(&orig.peer_connected), @@ -9738,11 +10799,6 @@ pub(crate) fn OnionMessageHandler_clone_fields(orig: &OnionMessageHandler) -> On use lightning::ln::msgs::OnionMessageHandler as rustOnionMessageHandler; impl rustOnionMessageHandler for OnionMessageHandler { - fn get_and_clear_connections_needed(&self) -> Vec<(bitcoin::secp256k1::PublicKey, Vec)> { - let mut ret = (self.get_and_clear_connections_needed)(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 = Vec::new(); for mut item in orig_ret_0_1.into_rust().drain(..) { local_orig_ret_0_1.push( { item.into_native() }); }; let mut local_ret_0 = (orig_ret_0_0.into_rust(), local_orig_ret_0_1); local_ret_0 }); }; - local_ret - } fn handle_onion_message(&self, mut peer_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::OnionMessage) { (self.handle_onion_message)(self.this_arg, crate::c_types::PublicKey::from_rust(&peer_node_id), &crate::lightning::ln::msgs::OnionMessage { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::OnionMessage<>) as *mut _) }, is_owned: false }) } @@ -9762,27 +10818,58 @@ impl rustOnionMessageHandler for OnionMessageHandler { fn timer_tick_occurred(&self) { (self.timer_tick_occurred)(self.this_arg) } - fn provided_node_features(&self) -> lightning::ln::features::NodeFeatures { + fn provided_node_features(&self) -> lightning_types::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 { + fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning_types::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()) } } } +pub struct OnionMessageHandlerRef(OnionMessageHandler); +impl rustOnionMessageHandler for OnionMessageHandlerRef { + fn handle_onion_message(&self, mut peer_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::OnionMessage) { + (self.0.handle_onion_message)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&peer_node_id), &crate::lightning::ln::msgs::OnionMessage { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::OnionMessage<>) as *mut _) }, is_owned: false }) + } + fn next_onion_message_for_peer(&self, mut peer_node_id: bitcoin::secp256k1::PublicKey) -> Option { + let mut ret = (self.0.next_onion_message_for_peer)(self.0.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 + } + fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut init: &lightning::ln::msgs::Init, mut inbound: bool) -> Result<(), ()> { + let mut ret = (self.0.peer_connected)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::Init { inner: unsafe { ObjOps::nonnull_ptr_to_inner((init as *const lightning::ln::msgs::Init<>) as *mut _) }, is_owned: false }, inbound); + 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 peer_disconnected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) { + (self.0.peer_disconnected)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id)) + } + fn timer_tick_occurred(&self) { + (self.0.timer_tick_occurred)(self.0.this_arg) + } + fn provided_node_features(&self) -> lightning_types::features::NodeFeatures { + let mut ret = (self.0.provided_node_features)(self.0.this_arg); + *unsafe { Box::from_raw(ret.take_inner()) } + } + fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning_types::features::InitFeatures { + let mut ret = (self.0.provided_init_features)(self.0.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 // directly as a Deref trait in higher-level structs: impl core::ops::Deref for OnionMessageHandler { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = OnionMessageHandlerRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const OnionMessageHandlerRef) } } } impl core::ops::DerefMut for OnionMessageHandler { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut OnionMessageHandlerRef { + unsafe { &mut *(self as *mut _ as *mut OnionMessageHandlerRef) } } } /// Calls the free function if one is set @@ -9816,6 +10903,12 @@ pub struct FinalOnionHopData { pub is_owned: bool, } +impl core::ops::Deref for FinalOnionHopData { + type Target = nativeFinalOnionHopData; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for FinalOnionHopData { } +unsafe impl core::marker::Sync for FinalOnionHopData { } impl Drop for FinalOnionHopData { fn drop(&mut self) { if self.is_owned && !<*mut nativeFinalOnionHopData>::is_null(self.inner) { @@ -9846,6 +10939,9 @@ impl FinalOnionHopData { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// When sending a multi-part payment, this secret is used to identify a payment across HTLCs. /// Because it is generated by the recipient and included in the invoice, it also provides @@ -9937,6 +11033,12 @@ pub struct OnionPacket { pub is_owned: bool, } +impl core::ops::Deref for OnionPacket { + type Target = nativeOnionPacket; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for OnionPacket { } +unsafe impl core::marker::Sync for OnionPacket { } impl Drop for OnionPacket { fn drop(&mut self) { if self.is_owned && !<*mut nativeOnionPacket>::is_null(self.inner) { @@ -9967,6 +11069,9 @@ impl OnionPacket { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// BOLT 4 version number. #[no_mangle] @@ -10074,6 +11179,12 @@ pub struct TrampolineOnionPacket { pub is_owned: bool, } +impl core::ops::Deref for TrampolineOnionPacket { + type Target = nativeTrampolineOnionPacket; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for TrampolineOnionPacket { } +unsafe impl core::marker::Sync for TrampolineOnionPacket { } impl Drop for TrampolineOnionPacket { fn drop(&mut self) { if self.is_owned && !<*mut nativeTrampolineOnionPacket>::is_null(self.inner) { @@ -10104,6 +11215,9 @@ impl TrampolineOnionPacket { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Bolt 04 version number #[no_mangle] @@ -10210,7 +11324,7 @@ pub extern "C" fn TrampolineOnionPacket_write(obj: &crate::lightning::ln::msgs:: } #[allow(unused)] pub(crate) extern "C" fn TrampolineOnionPacket_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTrampolineOnionPacket) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeTrampolineOnionPacket) }) } /// Get a string which allows debug introspection of a TrampolineOnionPacket object pub extern "C" fn TrampolineOnionPacket_debug_str_void(o: *const c_void) -> Str { @@ -10227,7 +11341,7 @@ pub extern "C" fn AcceptChannel_write(obj: &crate::lightning::ln::msgs::AcceptCh } #[allow(unused)] pub(crate) extern "C" fn AcceptChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAcceptChannel) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeAcceptChannel) }) } #[no_mangle] /// Read a AcceptChannel from a byte array, created by AcceptChannel_write @@ -10243,7 +11357,7 @@ pub extern "C" fn AcceptChannelV2_write(obj: &crate::lightning::ln::msgs::Accept } #[allow(unused)] 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) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeAcceptChannelV2) }) } #[no_mangle] /// Read a AcceptChannelV2 from a byte array, created by AcceptChannelV2_write @@ -10259,7 +11373,7 @@ pub extern "C" fn Stfu_write(obj: &crate::lightning::ln::msgs::Stfu) -> crate::c } #[allow(unused)] pub(crate) extern "C" fn Stfu_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeStfu) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeStfu) }) } #[no_mangle] /// Read a Stfu from a byte array, created by Stfu_write @@ -10269,19 +11383,19 @@ pub extern "C" fn Stfu_read(ser: crate::c_types::u8slice) -> crate::c_types::der local_res } #[no_mangle] -/// Serialize the Splice object into a byte array which can be read by Splice_read -pub extern "C" fn Splice_write(obj: &crate::lightning::ln::msgs::Splice) -> crate::c_types::derived::CVec_u8Z { +/// Serialize the SpliceInit object into a byte array which can be read by SpliceInit_read +pub extern "C" fn SpliceInit_write(obj: &crate::lightning::ln::msgs::SpliceInit) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) } #[allow(unused)] -pub(crate) extern "C" fn Splice_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeSplice) }) +pub(crate) extern "C" fn SpliceInit_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeSpliceInit) }) } #[no_mangle] -/// Read a Splice from a byte array, created by Splice_write -pub extern "C" fn Splice_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_SpliceDecodeErrorZ { - 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::Splice { 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 SpliceInit from a byte array, created by SpliceInit_write +pub extern "C" fn SpliceInit_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_SpliceInitDecodeErrorZ { + 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::SpliceInit { 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] @@ -10291,7 +11405,7 @@ pub extern "C" fn SpliceAck_write(obj: &crate::lightning::ln::msgs::SpliceAck) - } #[allow(unused)] pub(crate) extern "C" fn SpliceAck_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeSpliceAck) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeSpliceAck) }) } #[no_mangle] /// Read a SpliceAck from a byte array, created by SpliceAck_write @@ -10307,7 +11421,7 @@ pub extern "C" fn SpliceLocked_write(obj: &crate::lightning::ln::msgs::SpliceLoc } #[allow(unused)] pub(crate) extern "C" fn SpliceLocked_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeSpliceLocked) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeSpliceLocked) }) } #[no_mangle] /// Read a SpliceLocked from a byte array, created by SpliceLocked_write @@ -10323,7 +11437,7 @@ pub extern "C" fn TxAddInput_write(obj: &crate::lightning::ln::msgs::TxAddInput) } #[allow(unused)] 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) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeTxAddInput) }) } #[no_mangle] /// Read a TxAddInput from a byte array, created by TxAddInput_write @@ -10339,7 +11453,7 @@ pub extern "C" fn TxAddOutput_write(obj: &crate::lightning::ln::msgs::TxAddOutpu } #[allow(unused)] 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) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeTxAddOutput) }) } #[no_mangle] /// Read a TxAddOutput from a byte array, created by TxAddOutput_write @@ -10355,7 +11469,7 @@ pub extern "C" fn TxRemoveInput_write(obj: &crate::lightning::ln::msgs::TxRemove } #[allow(unused)] 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) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeTxRemoveInput) }) } #[no_mangle] /// Read a TxRemoveInput from a byte array, created by TxRemoveInput_write @@ -10371,7 +11485,7 @@ pub extern "C" fn TxRemoveOutput_write(obj: &crate::lightning::ln::msgs::TxRemov } #[allow(unused)] 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) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeTxRemoveOutput) }) } #[no_mangle] /// Read a TxRemoveOutput from a byte array, created by TxRemoveOutput_write @@ -10387,7 +11501,7 @@ pub extern "C" fn TxComplete_write(obj: &crate::lightning::ln::msgs::TxComplete) } #[allow(unused)] 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) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeTxComplete) }) } #[no_mangle] /// Read a TxComplete from a byte array, created by TxComplete_write @@ -10403,7 +11517,7 @@ pub extern "C" fn TxSignatures_write(obj: &crate::lightning::ln::msgs::TxSignatu } #[allow(unused)] 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) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeTxSignatures) }) } #[no_mangle] /// Read a TxSignatures from a byte array, created by TxSignatures_write @@ -10419,7 +11533,7 @@ pub extern "C" fn TxInitRbf_write(obj: &crate::lightning::ln::msgs::TxInitRbf) - } #[allow(unused)] 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) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeTxInitRbf) }) } #[no_mangle] /// Read a TxInitRbf from a byte array, created by TxInitRbf_write @@ -10435,7 +11549,7 @@ pub extern "C" fn TxAckRbf_write(obj: &crate::lightning::ln::msgs::TxAckRbf) -> } #[allow(unused)] 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) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeTxAckRbf) }) } #[no_mangle] /// Read a TxAckRbf from a byte array, created by TxAckRbf_write @@ -10451,7 +11565,7 @@ pub extern "C" fn TxAbort_write(obj: &crate::lightning::ln::msgs::TxAbort) -> cr } #[allow(unused)] 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) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeTxAbort) }) } #[no_mangle] /// Read a TxAbort from a byte array, created by TxAbort_write @@ -10467,7 +11581,7 @@ pub extern "C" fn AnnouncementSignatures_write(obj: &crate::lightning::ln::msgs: } #[allow(unused)] pub(crate) extern "C" fn AnnouncementSignatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAnnouncementSignatures) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeAnnouncementSignatures) }) } #[no_mangle] /// Read a AnnouncementSignatures from a byte array, created by AnnouncementSignatures_write @@ -10483,7 +11597,7 @@ pub extern "C" fn ChannelReestablish_write(obj: &crate::lightning::ln::msgs::Cha } #[allow(unused)] pub(crate) extern "C" fn ChannelReestablish_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelReestablish) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeChannelReestablish) }) } #[no_mangle] /// Read a ChannelReestablish from a byte array, created by ChannelReestablish_write @@ -10499,7 +11613,7 @@ pub extern "C" fn ClosingSigned_write(obj: &crate::lightning::ln::msgs::ClosingS } #[allow(unused)] pub(crate) extern "C" fn ClosingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClosingSigned) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeClosingSigned) }) } #[no_mangle] /// Read a ClosingSigned from a byte array, created by ClosingSigned_write @@ -10515,7 +11629,7 @@ pub extern "C" fn ClosingSignedFeeRange_write(obj: &crate::lightning::ln::msgs:: } #[allow(unused)] pub(crate) extern "C" fn ClosingSignedFeeRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClosingSignedFeeRange) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeClosingSignedFeeRange) }) } #[no_mangle] /// Read a ClosingSignedFeeRange from a byte array, created by ClosingSignedFeeRange_write @@ -10525,13 +11639,29 @@ pub extern "C" fn ClosingSignedFeeRange_read(ser: crate::c_types::u8slice) -> cr local_res } #[no_mangle] +/// Serialize the CommitmentSignedBatch object into a byte array which can be read by CommitmentSignedBatch_read +pub extern "C" fn CommitmentSignedBatch_write(obj: &crate::lightning::ln::msgs::CommitmentSignedBatch) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[allow(unused)] +pub(crate) extern "C" fn CommitmentSignedBatch_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeCommitmentSignedBatch) }) +} +#[no_mangle] +/// Read a CommitmentSignedBatch from a byte array, created by CommitmentSignedBatch_write +pub extern "C" fn CommitmentSignedBatch_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_CommitmentSignedBatchDecodeErrorZ { + 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::CommitmentSignedBatch { 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 CommitmentSigned object into a byte array which can be read by CommitmentSigned_read pub extern "C" fn CommitmentSigned_write(obj: &crate::lightning::ln::msgs::CommitmentSigned) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) } #[allow(unused)] pub(crate) extern "C" fn CommitmentSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeCommitmentSigned) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeCommitmentSigned) }) } #[no_mangle] /// Read a CommitmentSigned from a byte array, created by CommitmentSigned_write @@ -10547,7 +11677,7 @@ pub extern "C" fn FundingCreated_write(obj: &crate::lightning::ln::msgs::Funding } #[allow(unused)] pub(crate) extern "C" fn FundingCreated_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingCreated) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeFundingCreated) }) } #[no_mangle] /// Read a FundingCreated from a byte array, created by FundingCreated_write @@ -10563,7 +11693,7 @@ pub extern "C" fn FundingSigned_write(obj: &crate::lightning::ln::msgs::FundingS } #[allow(unused)] pub(crate) extern "C" fn FundingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingSigned) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeFundingSigned) }) } #[no_mangle] /// Read a FundingSigned from a byte array, created by FundingSigned_write @@ -10579,7 +11709,7 @@ pub extern "C" fn ChannelReady_write(obj: &crate::lightning::ln::msgs::ChannelRe } #[allow(unused)] pub(crate) extern "C" fn ChannelReady_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelReady) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeChannelReady) }) } #[no_mangle] /// Read a ChannelReady from a byte array, created by ChannelReady_write @@ -10595,7 +11725,7 @@ pub extern "C" fn Init_write(obj: &crate::lightning::ln::msgs::Init) -> crate::c } #[allow(unused)] pub(crate) extern "C" fn Init_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInit) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeInit) }) } #[no_mangle] /// Read a Init from a byte array, created by Init_write @@ -10611,7 +11741,7 @@ pub extern "C" fn OpenChannel_write(obj: &crate::lightning::ln::msgs::OpenChanne } #[allow(unused)] pub(crate) extern "C" fn OpenChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOpenChannel) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeOpenChannel) }) } #[no_mangle] /// Read a OpenChannel from a byte array, created by OpenChannel_write @@ -10627,7 +11757,7 @@ pub extern "C" fn OpenChannelV2_write(obj: &crate::lightning::ln::msgs::OpenChan } #[allow(unused)] 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) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeOpenChannelV2) }) } #[no_mangle] /// Read a OpenChannelV2 from a byte array, created by OpenChannelV2_write @@ -10643,7 +11773,7 @@ pub extern "C" fn RevokeAndACK_write(obj: &crate::lightning::ln::msgs::RevokeAnd } #[allow(unused)] pub(crate) extern "C" fn RevokeAndACK_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRevokeAndACK) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeRevokeAndACK) }) } #[no_mangle] /// Read a RevokeAndACK from a byte array, created by RevokeAndACK_write @@ -10659,7 +11789,7 @@ pub extern "C" fn Shutdown_write(obj: &crate::lightning::ln::msgs::Shutdown) -> } #[allow(unused)] pub(crate) extern "C" fn Shutdown_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeShutdown) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeShutdown) }) } #[no_mangle] /// Read a Shutdown from a byte array, created by Shutdown_write @@ -10675,7 +11805,7 @@ pub extern "C" fn UpdateFailHTLC_write(obj: &crate::lightning::ln::msgs::UpdateF } #[allow(unused)] pub(crate) extern "C" fn UpdateFailHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailHTLC) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeUpdateFailHTLC) }) } #[no_mangle] /// Read a UpdateFailHTLC from a byte array, created by UpdateFailHTLC_write @@ -10691,7 +11821,7 @@ pub extern "C" fn UpdateFailMalformedHTLC_write(obj: &crate::lightning::ln::msgs } #[allow(unused)] pub(crate) extern "C" fn UpdateFailMalformedHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailMalformedHTLC) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeUpdateFailMalformedHTLC) }) } #[no_mangle] /// Read a UpdateFailMalformedHTLC from a byte array, created by UpdateFailMalformedHTLC_write @@ -10707,7 +11837,7 @@ pub extern "C" fn UpdateFee_write(obj: &crate::lightning::ln::msgs::UpdateFee) - } #[allow(unused)] pub(crate) extern "C" fn UpdateFee_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFee) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeUpdateFee) }) } #[no_mangle] /// Read a UpdateFee from a byte array, created by UpdateFee_write @@ -10723,7 +11853,7 @@ pub extern "C" fn UpdateFulfillHTLC_write(obj: &crate::lightning::ln::msgs::Upda } #[allow(unused)] pub(crate) extern "C" fn UpdateFulfillHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFulfillHTLC) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeUpdateFulfillHTLC) }) } #[no_mangle] /// Read a UpdateFulfillHTLC from a byte array, created by UpdateFulfillHTLC_write @@ -10739,7 +11869,7 @@ pub extern "C" fn OnionPacket_write(obj: &crate::lightning::ln::msgs::OnionPacke } #[allow(unused)] pub(crate) extern "C" fn OnionPacket_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOnionPacket) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeOnionPacket) }) } #[no_mangle] /// Read a OnionPacket from a byte array, created by OnionPacket_write @@ -10755,7 +11885,7 @@ pub extern "C" fn UpdateAddHTLC_write(obj: &crate::lightning::ln::msgs::UpdateAd } #[allow(unused)] pub(crate) extern "C" fn UpdateAddHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateAddHTLC) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeUpdateAddHTLC) }) } #[no_mangle] /// Read a UpdateAddHTLC from a byte array, created by UpdateAddHTLC_write @@ -10778,7 +11908,7 @@ pub extern "C" fn OnionMessage_write(obj: &crate::lightning::ln::msgs::OnionMess } #[allow(unused)] pub(crate) extern "C" fn OnionMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOnionMessage) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeOnionMessage) }) } #[no_mangle] /// Serialize the FinalOnionHopData object into a byte array which can be read by FinalOnionHopData_read @@ -10787,7 +11917,7 @@ pub extern "C" fn FinalOnionHopData_write(obj: &crate::lightning::ln::msgs::Fina } #[allow(unused)] pub(crate) extern "C" fn FinalOnionHopData_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFinalOnionHopData) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeFinalOnionHopData) }) } #[no_mangle] /// Read a FinalOnionHopData from a byte array, created by FinalOnionHopData_write @@ -10803,7 +11933,7 @@ pub extern "C" fn Ping_write(obj: &crate::lightning::ln::msgs::Ping) -> crate::c } #[allow(unused)] pub(crate) extern "C" fn Ping_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePing) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativePing) }) } #[no_mangle] /// Read a Ping from a byte array, created by Ping_write @@ -10819,7 +11949,7 @@ pub extern "C" fn Pong_write(obj: &crate::lightning::ln::msgs::Pong) -> crate::c } #[allow(unused)] pub(crate) extern "C" fn Pong_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePong) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativePong) }) } #[no_mangle] /// Read a Pong from a byte array, created by Pong_write @@ -10835,7 +11965,7 @@ pub extern "C" fn UnsignedChannelAnnouncement_write(obj: &crate::lightning::ln:: } #[allow(unused)] pub(crate) extern "C" fn UnsignedChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelAnnouncement) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeUnsignedChannelAnnouncement) }) } #[no_mangle] /// Read a UnsignedChannelAnnouncement from a byte array, created by UnsignedChannelAnnouncement_write @@ -10851,7 +11981,7 @@ pub extern "C" fn ChannelAnnouncement_write(obj: &crate::lightning::ln::msgs::Ch } #[allow(unused)] pub(crate) extern "C" fn ChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelAnnouncement) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeChannelAnnouncement) }) } #[no_mangle] /// Read a ChannelAnnouncement from a byte array, created by ChannelAnnouncement_write @@ -10867,7 +11997,7 @@ pub extern "C" fn UnsignedChannelUpdate_write(obj: &crate::lightning::ln::msgs:: } #[allow(unused)] pub(crate) extern "C" fn UnsignedChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelUpdate) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeUnsignedChannelUpdate) }) } #[no_mangle] /// Read a UnsignedChannelUpdate from a byte array, created by UnsignedChannelUpdate_write @@ -10883,7 +12013,7 @@ pub extern "C" fn ChannelUpdate_write(obj: &crate::lightning::ln::msgs::ChannelU } #[allow(unused)] pub(crate) extern "C" fn ChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelUpdate) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeChannelUpdate) }) } #[no_mangle] /// Read a ChannelUpdate from a byte array, created by ChannelUpdate_write @@ -10899,7 +12029,7 @@ pub extern "C" fn ErrorMessage_write(obj: &crate::lightning::ln::msgs::ErrorMess } #[allow(unused)] pub(crate) extern "C" fn ErrorMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeErrorMessage) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeErrorMessage) }) } #[no_mangle] /// Read a ErrorMessage from a byte array, created by ErrorMessage_write @@ -10915,7 +12045,7 @@ pub extern "C" fn WarningMessage_write(obj: &crate::lightning::ln::msgs::Warning } #[allow(unused)] pub(crate) extern "C" fn WarningMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeWarningMessage) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeWarningMessage) }) } #[no_mangle] /// Read a WarningMessage from a byte array, created by WarningMessage_write @@ -10931,7 +12061,7 @@ pub extern "C" fn UnsignedNodeAnnouncement_write(obj: &crate::lightning::ln::msg } #[allow(unused)] pub(crate) extern "C" fn UnsignedNodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedNodeAnnouncement) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeUnsignedNodeAnnouncement) }) } #[no_mangle] /// Read a UnsignedNodeAnnouncement from a byte array, created by UnsignedNodeAnnouncement_write @@ -10947,7 +12077,7 @@ pub extern "C" fn NodeAnnouncement_write(obj: &crate::lightning::ln::msgs::NodeA } #[allow(unused)] pub(crate) extern "C" fn NodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeAnnouncement) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeNodeAnnouncement) }) } #[no_mangle] /// Read a NodeAnnouncement from a byte array, created by NodeAnnouncement_write @@ -10970,7 +12100,7 @@ pub extern "C" fn QueryShortChannelIds_write(obj: &crate::lightning::ln::msgs::Q } #[allow(unused)] pub(crate) extern "C" fn QueryShortChannelIds_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryShortChannelIds) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeQueryShortChannelIds) }) } #[no_mangle] /// Serialize the ReplyShortChannelIdsEnd object into a byte array which can be read by ReplyShortChannelIdsEnd_read @@ -10979,7 +12109,7 @@ pub extern "C" fn ReplyShortChannelIdsEnd_write(obj: &crate::lightning::ln::msgs } #[allow(unused)] pub(crate) extern "C" fn ReplyShortChannelIdsEnd_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyShortChannelIdsEnd) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeReplyShortChannelIdsEnd) }) } #[no_mangle] /// Read a ReplyShortChannelIdsEnd from a byte array, created by ReplyShortChannelIdsEnd_write @@ -11005,7 +12135,7 @@ pub extern "C" fn QueryChannelRange_write(obj: &crate::lightning::ln::msgs::Quer } #[allow(unused)] pub(crate) extern "C" fn QueryChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryChannelRange) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeQueryChannelRange) }) } #[no_mangle] /// Read a QueryChannelRange from a byte array, created by QueryChannelRange_write @@ -11028,7 +12158,7 @@ pub extern "C" fn ReplyChannelRange_write(obj: &crate::lightning::ln::msgs::Repl } #[allow(unused)] pub(crate) extern "C" fn ReplyChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyChannelRange) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeReplyChannelRange) }) } #[no_mangle] /// Serialize the GossipTimestampFilter object into a byte array which can be read by GossipTimestampFilter_read @@ -11037,7 +12167,7 @@ pub extern "C" fn GossipTimestampFilter_write(obj: &crate::lightning::ln::msgs:: } #[allow(unused)] pub(crate) extern "C" fn GossipTimestampFilter_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeGossipTimestampFilter) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeGossipTimestampFilter) }) } #[no_mangle] /// Read a GossipTimestampFilter from a byte array, created by GossipTimestampFilter_write diff --git a/lightning-c-bindings/src/lightning/ln/onion_payment.rs b/lightning-c-bindings/src/lightning/ln/onion_payment.rs index ac3a60a..2ff175b 100644 --- a/lightning-c-bindings/src/lightning/ln/onion_payment.rs +++ b/lightning-c-bindings/src/lightning/ln/onion_payment.rs @@ -40,6 +40,12 @@ pub struct InboundHTLCErr { pub is_owned: bool, } +impl core::ops::Deref for InboundHTLCErr { + type Target = nativeInboundHTLCErr; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for InboundHTLCErr { } +unsafe impl core::marker::Sync for InboundHTLCErr { } impl Drop for InboundHTLCErr { fn drop(&mut self) { if self.is_owned && !<*mut nativeInboundHTLCErr>::is_null(self.inner) { @@ -70,6 +76,9 @@ impl InboundHTLCErr { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// BOLT 4 error code. #[no_mangle] @@ -170,7 +179,7 @@ pub extern "C" fn InboundHTLCErr_eq(a: &InboundHTLCErr, b: &InboundHTLCErr) -> b /// /// [`Event::PaymentClaimable`]: crate::events::Event::PaymentClaimable #[no_mangle] -pub extern "C" fn peel_payment_onion(msg: &crate::lightning::ln::msgs::UpdateAddHTLC, node_signer: &crate::lightning::sign::NodeSigner, logger: &crate::lightning::util::logger::Logger, mut cur_height: u32, mut accept_mpp_keysend: bool, mut allow_skimmed_fees: bool) -> crate::c_types::derived::CResult_PendingHTLCInfoInboundHTLCErrZ { +pub extern "C" fn peel_payment_onion(msg: &crate::lightning::ln::msgs::UpdateAddHTLC, mut node_signer: crate::lightning::sign::NodeSigner, mut logger: crate::lightning::util::logger::Logger, mut cur_height: u32, mut accept_mpp_keysend: bool, mut allow_skimmed_fees: bool) -> crate::c_types::derived::CResult_PendingHTLCInfoInboundHTLCErrZ { let mut ret = lightning::ln::onion_payment::peel_payment_onion(msg.get_native_ref(), node_signer, logger, secp256k1::global::SECP256K1, cur_height, accept_mpp_keysend, allow_skimmed_fees); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::channelmanager::PendingHTLCInfo { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::onion_payment::InboundHTLCErr { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; local_ret diff --git a/lightning-c-bindings/src/lightning/ln/outbound_payment.rs b/lightning-c-bindings/src/lightning/ln/outbound_payment.rs index 6878551..c54bbee 100644 --- a/lightning-c-bindings/src/lightning/ln/outbound_payment.rs +++ b/lightning-c-bindings/src/lightning/ln/outbound_payment.rs @@ -192,6 +192,12 @@ pub enum RetryableSendFailure { /// [`Event::PaymentSent`]: crate::events::Event::PaymentSent /// [`Event::PaymentFailed`]: crate::events::Event::PaymentFailed DuplicatePayment, + /// The [`RecipientOnionFields::payment_metadata`], [`RecipientOnionFields::custom_tlvs`], or + /// [`BlindedPaymentPath`]s provided are too large and caused us to exceed the maximum onion + /// packet size of 1300 bytes. + /// + /// [`BlindedPaymentPath`]: crate::blinded_path::payment::BlindedPaymentPath + OnionPacketSizeExceeded, } use lightning::ln::outbound_payment::RetryableSendFailure as RetryableSendFailureImport; pub(crate) type nativeRetryableSendFailure = RetryableSendFailureImport; @@ -203,6 +209,7 @@ impl RetryableSendFailure { RetryableSendFailure::PaymentExpired => nativeRetryableSendFailure::PaymentExpired, RetryableSendFailure::RouteNotFound => nativeRetryableSendFailure::RouteNotFound, RetryableSendFailure::DuplicatePayment => nativeRetryableSendFailure::DuplicatePayment, + RetryableSendFailure::OnionPacketSizeExceeded => nativeRetryableSendFailure::OnionPacketSizeExceeded, } } #[allow(unused)] @@ -211,6 +218,7 @@ impl RetryableSendFailure { RetryableSendFailure::PaymentExpired => nativeRetryableSendFailure::PaymentExpired, RetryableSendFailure::RouteNotFound => nativeRetryableSendFailure::RouteNotFound, RetryableSendFailure::DuplicatePayment => nativeRetryableSendFailure::DuplicatePayment, + RetryableSendFailure::OnionPacketSizeExceeded => nativeRetryableSendFailure::OnionPacketSizeExceeded, } } #[allow(unused)] @@ -220,6 +228,7 @@ impl RetryableSendFailure { nativeRetryableSendFailure::PaymentExpired => RetryableSendFailure::PaymentExpired, nativeRetryableSendFailure::RouteNotFound => RetryableSendFailure::RouteNotFound, nativeRetryableSendFailure::DuplicatePayment => RetryableSendFailure::DuplicatePayment, + nativeRetryableSendFailure::OnionPacketSizeExceeded => RetryableSendFailure::OnionPacketSizeExceeded, } } #[allow(unused)] @@ -228,6 +237,7 @@ impl RetryableSendFailure { nativeRetryableSendFailure::PaymentExpired => RetryableSendFailure::PaymentExpired, nativeRetryableSendFailure::RouteNotFound => RetryableSendFailure::RouteNotFound, nativeRetryableSendFailure::DuplicatePayment => RetryableSendFailure::DuplicatePayment, + nativeRetryableSendFailure::OnionPacketSizeExceeded => RetryableSendFailure::OnionPacketSizeExceeded, } } } @@ -258,6 +268,10 @@ 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} +#[no_mangle] +/// Utility method to constructs a new OnionPacketSizeExceeded-variant RetryableSendFailure +pub extern "C" fn RetryableSendFailure_onion_packet_size_exceeded() -> RetryableSendFailure { + RetryableSendFailure::OnionPacketSizeExceeded} /// Get a string which allows debug introspection of a RetryableSendFailure object pub extern "C" fn RetryableSendFailure_debug_str_void(o: *const c_void) -> Str { alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::outbound_payment::RetryableSendFailure }).into()} @@ -544,6 +558,125 @@ pub extern "C" fn PaymentSendFailure_debug_str_void(o: *const c_void) -> Str { pub extern "C" fn PaymentSendFailure_eq(a: &PaymentSendFailure, b: &PaymentSendFailure) -> bool { if &a.to_native() == &b.to_native() { true } else { false } } +/// An error when attempting to pay a [`Bolt12Invoice`]. +#[derive(Clone)] +#[must_use] +#[repr(C)] +pub enum Bolt12PaymentError { + /// The invoice was not requested. + UnexpectedInvoice, + /// Payment for an invoice with the corresponding [`PaymentId`] was already initiated. + DuplicateInvoice, + /// The invoice was valid for the corresponding [`PaymentId`], but required unknown features. + UnknownRequiredFeatures, + /// The invoice was valid for the corresponding [`PaymentId`], but sending the payment failed. + SendingFailed( + crate::lightning::ln::outbound_payment::RetryableSendFailure), +} +use lightning::ln::outbound_payment::Bolt12PaymentError as Bolt12PaymentErrorImport; +pub(crate) type nativeBolt12PaymentError = Bolt12PaymentErrorImport; + +impl Bolt12PaymentError { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeBolt12PaymentError { + match self { + Bolt12PaymentError::UnexpectedInvoice => nativeBolt12PaymentError::UnexpectedInvoice, + Bolt12PaymentError::DuplicateInvoice => nativeBolt12PaymentError::DuplicateInvoice, + Bolt12PaymentError::UnknownRequiredFeatures => nativeBolt12PaymentError::UnknownRequiredFeatures, + Bolt12PaymentError::SendingFailed (ref a, ) => { + let mut a_nonref = Clone::clone(a); + nativeBolt12PaymentError::SendingFailed ( + a_nonref.into_native(), + ) + }, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeBolt12PaymentError { + match self { + Bolt12PaymentError::UnexpectedInvoice => nativeBolt12PaymentError::UnexpectedInvoice, + Bolt12PaymentError::DuplicateInvoice => nativeBolt12PaymentError::DuplicateInvoice, + Bolt12PaymentError::UnknownRequiredFeatures => nativeBolt12PaymentError::UnknownRequiredFeatures, + Bolt12PaymentError::SendingFailed (mut a, ) => { + nativeBolt12PaymentError::SendingFailed ( + a.into_native(), + ) + }, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &Bolt12PaymentErrorImport) -> Self { + let native = unsafe { &*(native as *const _ as *const c_void as *const nativeBolt12PaymentError) }; + match native { + nativeBolt12PaymentError::UnexpectedInvoice => Bolt12PaymentError::UnexpectedInvoice, + nativeBolt12PaymentError::DuplicateInvoice => Bolt12PaymentError::DuplicateInvoice, + nativeBolt12PaymentError::UnknownRequiredFeatures => Bolt12PaymentError::UnknownRequiredFeatures, + nativeBolt12PaymentError::SendingFailed (ref a, ) => { + let mut a_nonref = Clone::clone(a); + Bolt12PaymentError::SendingFailed ( + crate::lightning::ln::outbound_payment::RetryableSendFailure::native_into(a_nonref), + ) + }, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeBolt12PaymentError) -> Self { + match native { + nativeBolt12PaymentError::UnexpectedInvoice => Bolt12PaymentError::UnexpectedInvoice, + nativeBolt12PaymentError::DuplicateInvoice => Bolt12PaymentError::DuplicateInvoice, + nativeBolt12PaymentError::UnknownRequiredFeatures => Bolt12PaymentError::UnknownRequiredFeatures, + nativeBolt12PaymentError::SendingFailed (mut a, ) => { + Bolt12PaymentError::SendingFailed ( + crate::lightning::ln::outbound_payment::RetryableSendFailure::native_into(a), + ) + }, + } + } +} +/// Frees any resources used by the Bolt12PaymentError +#[no_mangle] +pub extern "C" fn Bolt12PaymentError_free(this_ptr: Bolt12PaymentError) { } +/// Creates a copy of the Bolt12PaymentError +#[no_mangle] +pub extern "C" fn Bolt12PaymentError_clone(orig: &Bolt12PaymentError) -> Bolt12PaymentError { + orig.clone() +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn Bolt12PaymentError_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const Bolt12PaymentError)).clone() })) as *mut c_void +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn Bolt12PaymentError_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut Bolt12PaymentError) }; +} +#[no_mangle] +/// Utility method to constructs a new UnexpectedInvoice-variant Bolt12PaymentError +pub extern "C" fn Bolt12PaymentError_unexpected_invoice() -> Bolt12PaymentError { + Bolt12PaymentError::UnexpectedInvoice} +#[no_mangle] +/// Utility method to constructs a new DuplicateInvoice-variant Bolt12PaymentError +pub extern "C" fn Bolt12PaymentError_duplicate_invoice() -> Bolt12PaymentError { + Bolt12PaymentError::DuplicateInvoice} +#[no_mangle] +/// Utility method to constructs a new UnknownRequiredFeatures-variant Bolt12PaymentError +pub extern "C" fn Bolt12PaymentError_unknown_required_features() -> Bolt12PaymentError { + Bolt12PaymentError::UnknownRequiredFeatures} +#[no_mangle] +/// Utility method to constructs a new SendingFailed-variant Bolt12PaymentError +pub extern "C" fn Bolt12PaymentError_sending_failed(a: crate::lightning::ln::outbound_payment::RetryableSendFailure) -> Bolt12PaymentError { + Bolt12PaymentError::SendingFailed(a, ) +} +/// Get a string which allows debug introspection of a Bolt12PaymentError object +pub extern "C" fn Bolt12PaymentError_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::outbound_payment::Bolt12PaymentError }).into()} +/// Checks if two Bolt12PaymentErrors contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +#[no_mangle] +pub extern "C" fn Bolt12PaymentError_eq(a: &Bolt12PaymentError, b: &Bolt12PaymentError) -> bool { + if &a.to_native() == &b.to_native() { true } else { false } +} /// Indicates that we failed to send a payment probe. Further errors may be surfaced later via /// [`Event::ProbeFailed`]. /// @@ -669,6 +802,12 @@ pub struct RecipientOnionFields { pub is_owned: bool, } +impl core::ops::Deref for RecipientOnionFields { + type Target = nativeRecipientOnionFields; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for RecipientOnionFields { } +unsafe impl core::marker::Sync for RecipientOnionFields { } impl Drop for RecipientOnionFields { fn drop(&mut self) { if self.is_owned && !<*mut nativeRecipientOnionFields>::is_null(self.inner) { @@ -699,6 +838,9 @@ impl RecipientOnionFields { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// 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 @@ -808,7 +950,7 @@ pub extern "C" fn RecipientOnionFields_write(obj: &crate::lightning::ln::outboun } #[allow(unused)] pub(crate) extern "C" fn RecipientOnionFields_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRecipientOnionFields) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::outbound_payment::nativeRecipientOnionFields) }) } #[no_mangle] /// Read a RecipientOnionFields from a byte array, created by RecipientOnionFields_write diff --git a/lightning-c-bindings/src/lightning/ln/peer_handler.rs b/lightning-c-bindings/src/lightning/ln/peer_handler.rs index 63f443e..672610e 100644 --- a/lightning-c-bindings/src/lightning/ln/peer_handler.rs +++ b/lightning-c-bindings/src/lightning/ln/peer_handler.rs @@ -44,18 +44,26 @@ pub struct CustomMessageHandler { /// 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. pub get_and_clear_pending_msg: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_C2Tuple_PublicKeyTypeZZ, + /// Indicates a peer disconnected. + pub peer_disconnected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey), + /// Handle a peer connecting. + /// + /// 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. + 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, /// 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, + pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning_types::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, + pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning_types::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. @@ -70,6 +78,8 @@ pub(crate) fn CustomMessageHandler_clone_fields(orig: &CustomMessageHandler) -> 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), + peer_disconnected: Clone::clone(&orig.peer_disconnected), + peer_connected: Clone::clone(&orig.peer_connected), 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), @@ -84,6 +94,14 @@ impl lightning::ln::wire::CustomMessageReader for CustomMessageHandler { local_ret } } +impl lightning::ln::wire::CustomMessageReader for CustomMessageHandlerRef { + type CustomMessage = crate::lightning::ln::wire::Type; + fn read(&self, mut message_type: u16, mut buffer: &mut R) -> Result, lightning::ln::msgs::DecodeError> { + let mut ret = (self.0.CustomMessageReader.read)(self.0.CustomMessageReader.this_arg, message_type, crate::c_types::u8slice::from_vec(&crate::c_types::reader_to_vec(buffer))); + let mut local_ret = match ret.result_ok { true => Ok( { let mut local_ret_0 = { /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ let ret_0_opt = (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }); if ret_0_opt.is_none() { None } else { Some({ { { ret_0_opt.take() } }})} }; local_ret_0 }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).into_native() })}; + local_ret + } +} use lightning::ln::peer_handler::CustomMessageHandler as rustCustomMessageHandler; impl rustCustomMessageHandler for CustomMessageHandler { @@ -97,27 +115,65 @@ 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 { + fn peer_disconnected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) { + (self.peer_disconnected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id)) + } + fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::Init, mut inbound: bool) -> Result<(), ()> { + let mut ret = (self.peer_connected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::Init { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::Init<>) as *mut _) }, is_owned: false }, inbound); + 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 provided_node_features(&self) -> lightning_types::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 { + fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning_types::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()) } } } +pub struct CustomMessageHandlerRef(CustomMessageHandler); +impl rustCustomMessageHandler for CustomMessageHandlerRef { + fn handle_custom_message(&self, mut msg: crate::lightning::ln::wire::Type, mut sender_node_id: &bitcoin::secp256k1::PublicKey) -> Result<(), lightning::ln::msgs::LightningError> { + let mut ret = (self.0.handle_custom_message)(self.0.this_arg, Into::into(msg), crate::c_types::PublicKey::from_rust(&sender_node_id)); + 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((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })}; + local_ret + } + fn get_and_clear_pending_msg(&self) -> Vec<(bitcoin::secp256k1::PublicKey, crate::lightning::ln::wire::Type)> { + let mut ret = (self.0.get_and_clear_pending_msg)(self.0.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_ret_0 = (orig_ret_0_0.into_rust(), orig_ret_0_1); local_ret_0 }); }; + local_ret + } + fn peer_disconnected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) { + (self.0.peer_disconnected)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id)) + } + fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::Init, mut inbound: bool) -> Result<(), ()> { + let mut ret = (self.0.peer_connected)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::Init { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::Init<>) as *mut _) }, is_owned: false }, inbound); + 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 provided_node_features(&self) -> lightning_types::features::NodeFeatures { + let mut ret = (self.0.provided_node_features)(self.0.this_arg); + *unsafe { Box::from_raw(ret.take_inner()) } + } + fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning_types::features::InitFeatures { + let mut ret = (self.0.provided_init_features)(self.0.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 // directly as a Deref trait in higher-level structs: impl core::ops::Deref for CustomMessageHandler { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = CustomMessageHandlerRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const CustomMessageHandlerRef) } } } impl core::ops::DerefMut for CustomMessageHandler { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut CustomMessageHandlerRef { + unsafe { &mut *(self as *mut _ as *mut CustomMessageHandlerRef) } } } /// Calls the free function if one is set @@ -151,6 +207,12 @@ pub struct IgnoringMessageHandler { pub is_owned: bool, } +impl core::ops::Deref for IgnoringMessageHandler { + type Target = nativeIgnoringMessageHandler; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for IgnoringMessageHandler { } +unsafe impl core::marker::Sync for IgnoringMessageHandler { } impl Drop for IgnoringMessageHandler { fn drop(&mut self) { if self.is_owned && !<*mut nativeIgnoringMessageHandler>::is_null(self.inner) { @@ -181,6 +243,9 @@ impl IgnoringMessageHandler { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Constructs a new IgnoringMessageHandler given each field #[must_use] @@ -189,31 +254,6 @@ pub extern "C" fn IgnoringMessageHandler_new() -> IgnoringMessageHandler { IgnoringMessageHandler { inner: ObjOps::heap_alloc(nativeIgnoringMessageHandler { }), is_owned: true } } -impl From for crate::lightning::events::EventsProvider { - fn from(obj: nativeIgnoringMessageHandler) -> Self { - let rust_obj = crate::lightning::ln::peer_handler::IgnoringMessageHandler { inner: ObjOps::heap_alloc(obj), is_owned: true }; - let mut ret = IgnoringMessageHandler_as_EventsProvider(&rust_obj); - // We want to free rust_obj when ret gets drop()'d, not rust_obj, so forget it and set ret's free() fn - core::mem::forget(rust_obj); - ret.free = Some(IgnoringMessageHandler_free_void); - ret - } -} -/// 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 -#[no_mangle] -pub extern "C" fn IgnoringMessageHandler_as_EventsProvider(this_arg: &IgnoringMessageHandler) -> crate::lightning::events::EventsProvider { - crate::lightning::events::EventsProvider { - this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, - free: None, - process_pending_events: IgnoringMessageHandler_EventsProvider_process_pending_events, - } -} - -extern "C" fn IgnoringMessageHandler_EventsProvider_process_pending_events(this_arg: *const c_void, mut handler: crate::lightning::events::EventHandler) { - ::process_pending_events(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, handler) -} - impl From for crate::lightning::events::MessageSendEventsProvider { fn from(obj: nativeIgnoringMessageHandler) -> Self { let rust_obj = crate::lightning::ln::peer_handler::IgnoringMessageHandler { inner: ObjOps::heap_alloc(obj), is_owned: true }; @@ -347,14 +387,14 @@ extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_processing_queue_high ret } #[must_use] -extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_provided_node_features(this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures { +extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_provided_node_features(this_arg: *const c_void) -> crate::lightning_types::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 } + crate::lightning_types::features::NodeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } #[must_use] -extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_provided_init_features(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures { +extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_provided_init_features(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey) -> crate::lightning_types::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 } + crate::lightning_types::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } impl From for crate::lightning::ln::msgs::OnionMessageHandler { @@ -374,7 +414,6 @@ pub extern "C" fn IgnoringMessageHandler_as_OnionMessageHandler(this_arg: &Ignor crate::lightning::ln::msgs::OnionMessageHandler { this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, free: None, - get_and_clear_connections_needed: IgnoringMessageHandler_OnionMessageHandler_get_and_clear_connections_needed, handle_onion_message: IgnoringMessageHandler_OnionMessageHandler_handle_onion_message, next_onion_message_for_peer: IgnoringMessageHandler_OnionMessageHandler_next_onion_message_for_peer, peer_connected: IgnoringMessageHandler_OnionMessageHandler_peer_connected, @@ -385,12 +424,6 @@ pub extern "C" fn IgnoringMessageHandler_as_OnionMessageHandler(this_arg: &Ignor } } -#[must_use] -extern "C" fn IgnoringMessageHandler_OnionMessageHandler_get_and_clear_connections_needed(this_arg: *const c_void) -> crate::c_types::derived::CVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ { - let mut ret = ::get_and_clear_connections_needed(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, ); - 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( { crate::lightning::ln::msgs::SocketAddress::native_into(item) }); }; let mut local_ret_0 = (crate::c_types::PublicKey::from_rust(&orig_ret_0_0), local_orig_ret_0_1.into()).into(); local_ret_0 }); }; - local_ret.into() -} extern "C" fn IgnoringMessageHandler_OnionMessageHandler_handle_onion_message(this_arg: *const c_void, mut peer_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::OnionMessage) { ::handle_onion_message(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, &peer_node_id.into_rust(), msg.get_native_ref()) } @@ -413,14 +446,14 @@ extern "C" fn IgnoringMessageHandler_OnionMessageHandler_timer_tick_occurred(thi ::timer_tick_occurred(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, ) } #[must_use] -extern "C" fn IgnoringMessageHandler_OnionMessageHandler_provided_node_features(this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures { +extern "C" fn IgnoringMessageHandler_OnionMessageHandler_provided_node_features(this_arg: *const c_void) -> crate::lightning_types::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 } + crate::lightning_types::features::NodeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } #[must_use] -extern "C" fn IgnoringMessageHandler_OnionMessageHandler_provided_init_features(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures { +extern "C" fn IgnoringMessageHandler_OnionMessageHandler_provided_init_features(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey) -> crate::lightning_types::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 } + crate::lightning_types::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } impl From for crate::lightning::onion_message::offers::OffersMessageHandler { @@ -446,15 +479,57 @@ pub extern "C" fn IgnoringMessageHandler_as_OffersMessageHandler(this_arg: &Igno } #[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()) }) }; +extern "C" fn IgnoringMessageHandler_OffersMessageHandler_handle_message(this_arg: *const c_void, mut message: crate::lightning::onion_message::offers::OffersMessage, mut context: crate::c_types::derived::COption_OffersContextZ, mut responder: crate::lightning::onion_message::messenger::Responder) -> crate::c_types::derived::COption_C2Tuple_OffersMessageResponseInstructionZZ { + let mut local_context = { /*context*/ let context_opt = context; if context_opt.is_none() { None } else { Some({ { { context_opt.take() }.into_native() }})} }; + let mut local_responder = if responder.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(responder.take_inner()) } }) }; + let mut ret = ::handle_message(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, message.into_native(), local_context, local_responder); + let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_C2Tuple_OffersMessageResponseInstructionZZ::None } else { crate::c_types::derived::COption_C2Tuple_OffersMessageResponseInstructionZZ::Some( { let (mut orig_ret_0_0, mut orig_ret_0_1) = (ret.unwrap()); let mut local_ret_0 = (crate::lightning::onion_message::offers::OffersMessage::native_into(orig_ret_0_0), crate::lightning::onion_message::messenger::ResponseInstruction { inner: ObjOps::heap_alloc(orig_ret_0_1), is_owned: true }).into(); local_ret_0 }) }; local_ret } #[must_use] -extern "C" fn IgnoringMessageHandler_OffersMessageHandler_release_pending_messages(this_arg: *const c_void) -> crate::c_types::derived::CVec_C3Tuple_OffersMessageDestinationBlindedPathZZ { +extern "C" fn IgnoringMessageHandler_OffersMessageHandler_release_pending_messages(this_arg: *const c_void) -> crate::c_types::derived::CVec_C2Tuple_OffersMessageMessageSendInstructionsZZ { let mut ret = ::release_pending_messages(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, ); - 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, mut orig_ret_0_2) = item; let mut local_orig_ret_0_2 = crate::lightning::blinded_path::BlindedPath { inner: if orig_ret_0_2.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((orig_ret_0_2.unwrap())) } }, is_owned: true }; let mut local_ret_0 = (crate::lightning::onion_message::offers::OffersMessage::native_into(orig_ret_0_0), crate::lightning::onion_message::messenger::Destination::native_into(orig_ret_0_1), local_orig_ret_0_2).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_ret_0 = (crate::lightning::onion_message::offers::OffersMessage::native_into(orig_ret_0_0), crate::lightning::onion_message::messenger::MessageSendInstructions::native_into(orig_ret_0_1)).into(); local_ret_0 }); }; + local_ret.into() +} + +impl From for crate::lightning::onion_message::async_payments::AsyncPaymentsMessageHandler { + fn from(obj: nativeIgnoringMessageHandler) -> Self { + let rust_obj = crate::lightning::ln::peer_handler::IgnoringMessageHandler { inner: ObjOps::heap_alloc(obj), is_owned: true }; + let mut ret = IgnoringMessageHandler_as_AsyncPaymentsMessageHandler(&rust_obj); + // We want to free rust_obj when ret gets drop()'d, not rust_obj, so forget it and set ret's free() fn + core::mem::forget(rust_obj); + ret.free = Some(IgnoringMessageHandler_free_void); + ret + } +} +/// Constructs a new AsyncPaymentsMessageHandler which calls the relevant methods on this_arg. +/// This copies the `inner` pointer in this_arg and thus the returned AsyncPaymentsMessageHandler must be freed before this_arg is +#[no_mangle] +pub extern "C" fn IgnoringMessageHandler_as_AsyncPaymentsMessageHandler(this_arg: &IgnoringMessageHandler) -> crate::lightning::onion_message::async_payments::AsyncPaymentsMessageHandler { + crate::lightning::onion_message::async_payments::AsyncPaymentsMessageHandler { + this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, + free: None, + held_htlc_available: IgnoringMessageHandler_AsyncPaymentsMessageHandler_held_htlc_available, + release_held_htlc: IgnoringMessageHandler_AsyncPaymentsMessageHandler_release_held_htlc, + release_pending_messages: IgnoringMessageHandler_AsyncPaymentsMessageHandler_release_pending_messages, + } +} + +#[must_use] +extern "C" fn IgnoringMessageHandler_AsyncPaymentsMessageHandler_held_htlc_available(this_arg: *const c_void, mut message: crate::lightning::onion_message::async_payments::HeldHtlcAvailable, mut responder: crate::lightning::onion_message::messenger::Responder) -> crate::c_types::derived::COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ { + let mut local_responder = if responder.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(responder.take_inner()) } }) }; + let mut ret = ::held_htlc_available(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, *unsafe { Box::from_raw(message.take_inner()) }, local_responder); + let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ::None } else { crate::c_types::derived::COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ::Some( { let (mut orig_ret_0_0, mut orig_ret_0_1) = (ret.unwrap()); let mut local_ret_0 = (crate::lightning::onion_message::async_payments::ReleaseHeldHtlc { inner: ObjOps::heap_alloc(orig_ret_0_0), is_owned: true }, crate::lightning::onion_message::messenger::ResponseInstruction { inner: ObjOps::heap_alloc(orig_ret_0_1), is_owned: true }).into(); local_ret_0 }) }; + local_ret +} +extern "C" fn IgnoringMessageHandler_AsyncPaymentsMessageHandler_release_held_htlc(this_arg: *const c_void, mut message: crate::lightning::onion_message::async_payments::ReleaseHeldHtlc) { + ::release_held_htlc(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, *unsafe { Box::from_raw(message.take_inner()) }) +} +#[must_use] +extern "C" fn IgnoringMessageHandler_AsyncPaymentsMessageHandler_release_pending_messages(this_arg: *const c_void) -> crate::c_types::derived::CVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ { + let mut ret = ::release_pending_messages(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, ); + 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::lightning::onion_message::async_payments::AsyncPaymentsMessage::native_into(orig_ret_0_0), crate::lightning::onion_message::messenger::MessageSendInstructions::native_into(orig_ret_0_1)).into(); local_ret_0 }); }; local_ret.into() } @@ -482,7 +557,7 @@ pub extern "C" fn IgnoringMessageHandler_as_CustomOnionMessageHandler(this_arg: } #[must_use] -extern "C" fn IgnoringMessageHandler_CustomOnionMessageHandler_handle_custom_message(this_arg: *const c_void, mut msg: crate::lightning::onion_message::packet::OnionMessageContents) -> crate::c_types::derived::COption_OnionMessageContentsZ { +extern "C" fn IgnoringMessageHandler_CustomOnionMessageHandler_handle_custom_message(this_arg: *const c_void, mut message: crate::lightning::onion_message::packet::OnionMessageContents, mut context: crate::c_types::derived::COption_CVec_u8ZZ, mut responder: crate::lightning::onion_message::messenger::Responder) -> crate::c_types::derived::COption_C2Tuple_OnionMessageContentsResponseInstructionZZ { unreachable!(); } #[must_use] @@ -492,9 +567,9 @@ extern "C" fn IgnoringMessageHandler_CustomOnionMessageHandler_read_custom_messa local_ret } #[must_use] -extern "C" fn IgnoringMessageHandler_CustomOnionMessageHandler_release_pending_custom_messages(this_arg: *const c_void) -> crate::c_types::derived::CVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ { +extern "C" fn IgnoringMessageHandler_CustomOnionMessageHandler_release_pending_custom_messages(this_arg: *const c_void) -> crate::c_types::derived::CVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ { let mut ret = ::release_pending_custom_messages(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, ); - 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, mut orig_ret_0_2) = item; let mut local_orig_ret_0_2 = crate::lightning::blinded_path::BlindedPath { inner: if orig_ret_0_2.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((orig_ret_0_2.unwrap())) } }, is_owned: true }; let mut local_ret_0 = (Into::into(orig_ret_0_0), crate::lightning::onion_message::messenger::Destination::native_into(orig_ret_0_1), local_orig_ret_0_2).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_ret_0 = (Into::into(orig_ret_0_0), crate::lightning::onion_message::messenger::MessageSendInstructions::native_into(orig_ret_0_1)).into(); local_ret_0 }); }; local_ret.into() } @@ -555,6 +630,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, + peer_disconnected: IgnoringMessageHandler_CustomMessageHandler_peer_disconnected, + peer_connected: IgnoringMessageHandler_CustomMessageHandler_peer_connected, provided_node_features: IgnoringMessageHandler_CustomMessageHandler_provided_node_features, provided_init_features: IgnoringMessageHandler_CustomMessageHandler_provided_init_features, CustomMessageReader: crate::lightning::ln::wire::CustomMessageReader { @@ -575,15 +652,24 @@ 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() } +extern "C" fn IgnoringMessageHandler_CustomMessageHandler_peer_disconnected(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey) { + ::peer_disconnected(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, &their_node_id.into_rust()) +} #[must_use] -extern "C" fn IgnoringMessageHandler_CustomMessageHandler_provided_node_features(this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures { +extern "C" fn IgnoringMessageHandler_CustomMessageHandler_peer_connected(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::Init, mut inbound: bool) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = ::peer_connected(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref(), inbound); + 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 IgnoringMessageHandler_CustomMessageHandler_provided_node_features(this_arg: *const c_void) -> crate::lightning_types::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 } + crate::lightning_types::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 { +extern "C" fn IgnoringMessageHandler_CustomMessageHandler_provided_init_features(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey) -> crate::lightning_types::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 } + crate::lightning_types::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } @@ -607,6 +693,12 @@ pub struct ErroringMessageHandler { pub is_owned: bool, } +impl core::ops::Deref for ErroringMessageHandler { + type Target = nativeErroringMessageHandler; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ErroringMessageHandler { } +unsafe impl core::marker::Sync for ErroringMessageHandler { } impl Drop for ErroringMessageHandler { fn drop(&mut self) { if self.is_owned && !<*mut nativeErroringMessageHandler>::is_null(self.inner) { @@ -637,6 +729,9 @@ impl ErroringMessageHandler { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Constructs a new ErroringMessageHandler #[must_use] @@ -834,14 +929,14 @@ extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_error(this_arg ::handle_error(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) } #[must_use] -extern "C" fn ErroringMessageHandler_ChannelMessageHandler_provided_node_features(this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures { +extern "C" fn ErroringMessageHandler_ChannelMessageHandler_provided_node_features(this_arg: *const c_void) -> crate::lightning_types::features::NodeFeatures { let mut ret = ::provided_node_features(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, ); - crate::lightning::ln::features::NodeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } + crate::lightning_types::features::NodeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } #[must_use] -extern "C" fn ErroringMessageHandler_ChannelMessageHandler_provided_init_features(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures { +extern "C" fn ErroringMessageHandler_ChannelMessageHandler_provided_init_features(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey) -> crate::lightning_types::features::InitFeatures { 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 } + crate::lightning_types::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } #[must_use] extern "C" fn ErroringMessageHandler_ChannelMessageHandler_get_chain_hashes(this_arg: *const c_void) -> crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ { @@ -870,6 +965,12 @@ pub struct MessageHandler { pub is_owned: bool, } +impl core::ops::Deref for MessageHandler { + type Target = nativeMessageHandler; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for MessageHandler { } +unsafe impl core::marker::Sync for MessageHandler { } impl Drop for MessageHandler { fn drop(&mut self) { if self.is_owned && !<*mut nativeMessageHandler>::is_null(self.inner) { @@ -900,6 +1001,9 @@ impl MessageHandler { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// A message handler which handles messages specific to channels. Usually this is just a /// [`ChannelManager`] object or an [`ErroringMessageHandler`]. @@ -1047,9 +1151,16 @@ impl core::cmp::Eq for SocketDescriptor {} impl core::cmp::PartialEq for SocketDescriptor { fn eq(&self, o: &Self) -> bool { (self.eq)(self.this_arg, o) } } +impl core::cmp::Eq for SocketDescriptorRef {} +impl core::cmp::PartialEq for SocketDescriptorRef { + fn eq(&self, o: &Self) -> bool { (self.0.eq)(self.0.this_arg, &o.0) } +} impl core::hash::Hash for SocketDescriptor { fn hash(&self, hasher: &mut H) { hasher.write_u64((self.hash)(self.this_arg)) } } +impl core::hash::Hash for SocketDescriptorRef { + fn hash(&self, hasher: &mut H) { hasher.write_u64((self.0.hash)(self.0.this_arg)) } +} #[no_mangle] /// Creates a copy of a SocketDescriptor pub extern "C" fn SocketDescriptor_clone(orig: &SocketDescriptor) -> SocketDescriptor { @@ -1062,6 +1173,11 @@ impl Clone for SocketDescriptor { SocketDescriptor_clone(self) } } +impl Clone for SocketDescriptorRef { + fn clone(&self) -> Self { + Self(SocketDescriptor_clone(&self.0)) + } +} use lightning::ln::peer_handler::SocketDescriptor as rustSocketDescriptor; impl rustSocketDescriptor for SocketDescriptor { @@ -1075,17 +1191,29 @@ impl rustSocketDescriptor for SocketDescriptor { } } +pub struct SocketDescriptorRef(SocketDescriptor); +impl rustSocketDescriptor for SocketDescriptorRef { + fn send_data(&mut self, mut data: &[u8], mut resume_read: bool) -> usize { + let mut local_data = crate::c_types::u8slice::from_slice(data); + let mut ret = (self.0.send_data)(self.0.this_arg, local_data, resume_read); + ret + } + fn disconnect_socket(&mut self) { + (self.0.disconnect_socket)(self.0.this_arg) + } +} + // 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 SocketDescriptor { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = SocketDescriptorRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const SocketDescriptorRef) } } } impl core::ops::DerefMut for SocketDescriptor { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut SocketDescriptorRef { + unsafe { &mut *(self as *mut _ as *mut SocketDescriptorRef) } } } /// Calls the free function if one is set @@ -1118,6 +1246,12 @@ pub struct PeerDetails { pub is_owned: bool, } +impl core::ops::Deref for PeerDetails { + type Target = nativePeerDetails; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for PeerDetails { } +unsafe impl core::marker::Sync for PeerDetails { } impl Drop for PeerDetails { fn drop(&mut self) { if self.is_owned && !<*mut nativePeerDetails>::is_null(self.inner) { @@ -1148,6 +1282,9 @@ impl PeerDetails { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The node id of the peer. /// @@ -1189,13 +1326,13 @@ pub extern "C" fn PeerDetails_set_socket_address(this_ptr: &mut PeerDetails, mut } /// The features the peer provided in the initial handshake. #[no_mangle] -pub extern "C" fn PeerDetails_get_init_features(this_ptr: &PeerDetails) -> crate::lightning::ln::features::InitFeatures { +pub extern "C" fn PeerDetails_get_init_features(this_ptr: &PeerDetails) -> crate::lightning_types::features::InitFeatures { let mut inner_val = &mut this_ptr.get_native_mut_ref().init_features; - crate::lightning::ln::features::InitFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::features::InitFeatures<>) as *mut _) }, is_owned: false } + crate::lightning_types::features::InitFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning_types::features::InitFeatures<>) as *mut _) }, is_owned: false } } /// The features the peer provided in the initial handshake. #[no_mangle] -pub extern "C" fn PeerDetails_set_init_features(this_ptr: &mut PeerDetails, mut val: crate::lightning::ln::features::InitFeatures) { +pub extern "C" fn PeerDetails_set_init_features(this_ptr: &mut PeerDetails, mut val: crate::lightning_types::features::InitFeatures) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.init_features = *unsafe { Box::from_raw(val.take_inner()) }; } /// Indicates the direction of the peer connection. @@ -1216,7 +1353,7 @@ pub extern "C" fn PeerDetails_set_is_inbound_connection(this_ptr: &mut PeerDetai /// Constructs a new PeerDetails given each field #[must_use] #[no_mangle] -pub extern "C" fn PeerDetails_new(mut counterparty_node_id_arg: crate::c_types::PublicKey, mut socket_address_arg: crate::c_types::derived::COption_SocketAddressZ, mut init_features_arg: crate::lightning::ln::features::InitFeatures, mut is_inbound_connection_arg: bool) -> PeerDetails { +pub extern "C" fn PeerDetails_new(mut counterparty_node_id_arg: crate::c_types::PublicKey, mut socket_address_arg: crate::c_types::derived::COption_SocketAddressZ, mut init_features_arg: crate::lightning_types::features::InitFeatures, mut is_inbound_connection_arg: bool) -> PeerDetails { let mut local_socket_address_arg = { /*socket_address_arg*/ let socket_address_arg_opt = socket_address_arg; if socket_address_arg_opt.is_none() { None } else { Some({ { { socket_address_arg_opt.take() }.into_native() }})} }; PeerDetails { inner: ObjOps::heap_alloc(nativePeerDetails { counterparty_node_id: counterparty_node_id_arg.into_rust(), @@ -1247,6 +1384,12 @@ pub struct PeerHandleError { pub is_owned: bool, } +impl core::ops::Deref for PeerHandleError { + type Target = nativePeerHandleError; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for PeerHandleError { } +unsafe impl core::marker::Sync for PeerHandleError { } impl Drop for PeerHandleError { fn drop(&mut self) { if self.is_owned && !<*mut nativePeerHandleError>::is_null(self.inner) { @@ -1277,6 +1420,9 @@ impl PeerHandleError { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Constructs a new PeerHandleError given each field #[must_use] @@ -1350,6 +1496,12 @@ pub struct PeerManager { pub is_owned: bool, } +impl core::ops::Deref for PeerManager { + type Target = nativePeerManager; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for PeerManager { } +unsafe impl core::marker::Sync for PeerManager { } impl Drop for PeerManager { fn drop(&mut self) { if self.is_owned && !<*mut nativePeerManager>::is_null(self.inner) { @@ -1380,6 +1532,9 @@ impl PeerManager { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Constructs a new `PeerManager` with the given message handlers. /// diff --git a/lightning-c-bindings/src/lightning/ln/script.rs b/lightning-c-bindings/src/lightning/ln/script.rs index 3806636..9d21f8a 100644 --- a/lightning-c-bindings/src/lightning/ln/script.rs +++ b/lightning-c-bindings/src/lightning/ln/script.rs @@ -39,6 +39,12 @@ pub struct ShutdownScript { pub is_owned: bool, } +impl core::ops::Deref for ShutdownScript { + type Target = nativeShutdownScript; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ShutdownScript { } +unsafe impl core::marker::Sync for ShutdownScript { } impl Drop for ShutdownScript { fn drop(&mut self) { if self.is_owned && !<*mut nativeShutdownScript>::is_null(self.inner) { @@ -69,6 +75,9 @@ impl ShutdownScript { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } impl Clone for ShutdownScript { fn clone(&self) -> Self { @@ -118,6 +127,12 @@ pub struct InvalidShutdownScript { pub is_owned: bool, } +impl core::ops::Deref for InvalidShutdownScript { + type Target = nativeInvalidShutdownScript; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for InvalidShutdownScript { } +unsafe impl core::marker::Sync for InvalidShutdownScript { } impl Drop for InvalidShutdownScript { fn drop(&mut self) { if self.is_owned && !<*mut nativeInvalidShutdownScript>::is_null(self.inner) { @@ -148,6 +163,9 @@ impl InvalidShutdownScript { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The script that did not meet the requirements from [BOLT #2]. /// @@ -162,14 +180,14 @@ pub extern "C" fn InvalidShutdownScript_get_script(this_ptr: &InvalidShutdownScr /// [BOLT #2]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md #[no_mangle] pub extern "C" fn InvalidShutdownScript_set_script(this_ptr: &mut InvalidShutdownScript, mut val: crate::c_types::derived::CVec_u8Z) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.script = ::bitcoin::blockdata::script::ScriptBuf::from(val.into_rust()); + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.script = ::bitcoin::script::ScriptBuf::from(val.into_rust()); } /// Constructs a new InvalidShutdownScript given each field #[must_use] #[no_mangle] pub extern "C" fn InvalidShutdownScript_new(mut script_arg: crate::c_types::derived::CVec_u8Z) -> InvalidShutdownScript { InvalidShutdownScript { inner: ObjOps::heap_alloc(nativeInvalidShutdownScript { - script: ::bitcoin::blockdata::script::ScriptBuf::from(script_arg.into_rust()), + script: ::bitcoin::script::ScriptBuf::from(script_arg.into_rust()), }), is_owned: true } } impl Clone for InvalidShutdownScript { @@ -201,7 +219,7 @@ pub extern "C" fn ShutdownScript_write(obj: &crate::lightning::ln::script::Shutd } #[allow(unused)] pub(crate) extern "C" fn ShutdownScript_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeShutdownScript) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::script::nativeShutdownScript) }) } #[no_mangle] /// Read a ShutdownScript from a byte array, created by ShutdownScript_write @@ -214,7 +232,7 @@ pub extern "C" fn ShutdownScript_read(ser: crate::c_types::u8slice) -> crate::c_ #[must_use] #[no_mangle] pub extern "C" fn ShutdownScript_new_p2wpkh(pubkey_hash: *const [u8; 20]) -> crate::lightning::ln::script::ShutdownScript { - let mut ret = lightning::ln::script::ShutdownScript::new_p2wpkh(&bitcoin::hash_types::WPubkeyHash::from_raw_hash(bitcoin::hashes::Hash::from_byte_array(unsafe { *pubkey_hash }.clone()))); + let mut ret = lightning::ln::script::ShutdownScript::new_p2wpkh(&bitcoin::WPubkeyHash::from_raw_hash(bitcoin::hashes::Hash::from_byte_array(unsafe { *pubkey_hash }.clone()))); crate::lightning::ln::script::ShutdownScript { inner: ObjOps::heap_alloc(ret), is_owned: true } } @@ -222,7 +240,7 @@ pub extern "C" fn ShutdownScript_new_p2wpkh(pubkey_hash: *const [u8; 20]) -> cra #[must_use] #[no_mangle] pub extern "C" fn ShutdownScript_new_p2wsh(script_hash: *const [u8; 32]) -> crate::lightning::ln::script::ShutdownScript { - let mut ret = lightning::ln::script::ShutdownScript::new_p2wsh(&bitcoin::hash_types::WScriptHash::from_raw_hash(bitcoin::hashes::Hash::from_byte_array(unsafe { *script_hash }.clone()))); + let mut ret = lightning::ln::script::ShutdownScript::new_p2wsh(&bitcoin::WScriptHash::from_raw_hash(bitcoin::hashes::Hash::from_byte_array(unsafe { *script_hash }.clone()))); crate::lightning::ln::script::ShutdownScript { inner: ObjOps::heap_alloc(ret), is_owned: true } } @@ -266,7 +284,7 @@ pub extern "C" fn ShutdownScript_as_legacy_pubkey(this_arg: &crate::lightning::l /// Specifically, checks for compliance with feature `option_shutdown_anysegwit`. #[must_use] #[no_mangle] -pub extern "C" fn ShutdownScript_is_compatible(this_arg: &crate::lightning::ln::script::ShutdownScript, features: &crate::lightning::ln::features::InitFeatures) -> bool { +pub extern "C" fn ShutdownScript_is_compatible(this_arg: &crate::lightning::ln::script::ShutdownScript, features: &crate::lightning_types::features::InitFeatures) -> bool { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.is_compatible(features.get_native_ref()); ret } diff --git a/lightning-c-bindings/src/lightning/ln/types.rs b/lightning-c-bindings/src/lightning/ln/types.rs index 7d07ff0..dfccfda 100644 --- a/lightning-c-bindings/src/lightning/ln/types.rs +++ b/lightning-c-bindings/src/lightning/ln/types.rs @@ -7,6 +7,12 @@ // source was automatically generated. //! Various wrapper types (most around 32-byte arrays) for use in lightning. +//! +//! Note that the re-exports of [`PaymentHash`], [`PaymentPreimage`], and [`PaymentSecret`] here +//! are deprecated and will be removed in a future version. Instead, use them via +//! [`lightning::types::payment`]. +//! +//! [`lightning::types::payment`]: crate::types::payment use alloc::str::FromStr; use alloc::string::String; @@ -44,6 +50,12 @@ pub struct ChannelId { pub is_owned: bool, } +impl core::ops::Deref for ChannelId { + type Target = nativeChannelId; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ChannelId { } +unsafe impl core::marker::Sync for ChannelId { } impl Drop for ChannelId { fn drop(&mut self) { if self.is_owned && !<*mut nativeChannelId>::is_null(self.inner) { @@ -74,6 +86,9 @@ impl ChannelId { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } #[no_mangle] pub extern "C" fn ChannelId_get_a(this_ptr: &ChannelId) -> *const [u8; 32] { @@ -208,7 +223,7 @@ pub extern "C" fn ChannelId_write(obj: &crate::lightning::ln::types::ChannelId) } #[allow(unused)] pub(crate) extern "C" fn ChannelId_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelId) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::types::nativeChannelId) }) } #[no_mangle] /// Read a ChannelId from a byte array, created by ChannelId_write diff --git a/lightning-c-bindings/src/lightning/ln/wire.rs b/lightning-c-bindings/src/lightning/ln/wire.rs index 39a696a..e5747f6 100644 --- a/lightning-c-bindings/src/lightning/ln/wire.rs +++ b/lightning-c-bindings/src/lightning/ln/wire.rs @@ -57,17 +57,27 @@ impl rustCustomMessageReader for CustomMessageReader { } } +pub struct CustomMessageReaderRef(CustomMessageReader); +impl rustCustomMessageReader for CustomMessageReaderRef { + type CustomMessage = crate::lightning::ln::wire::Type; + fn read(&self, mut message_type: u16, mut buffer: &mut R) -> Result, lightning::ln::msgs::DecodeError> { + let mut ret = (self.0.read)(self.0.this_arg, message_type, crate::c_types::u8slice::from_vec(&crate::c_types::reader_to_vec(buffer))); + let mut local_ret = match ret.result_ok { true => Ok( { let mut local_ret_0 = { /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ let ret_0_opt = (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }); if ret_0_opt.is_none() { None } else { Some({ { { ret_0_opt.take() } }})} }; local_ret_0 }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).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 CustomMessageReader { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = CustomMessageReaderRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const CustomMessageReaderRef) } } } impl core::ops::DerefMut for CustomMessageReader { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut CustomMessageReaderRef { + unsafe { &mut *(self as *mut _ as *mut CustomMessageReaderRef) } } } /// Calls the free function if one is set @@ -132,12 +142,23 @@ impl core::fmt::Debug for Type { f.write_str((self.debug_str)(self.this_arg).into_str()) } } +impl core::fmt::Debug for TypeRef { + fn fmt(&self, f: &mut core::fmt::Formatter) -> Result<(), core::fmt::Error> { + f.write_str((self.0.debug_str)(self.0.this_arg).into_str()) + } +} impl lightning::util::ser::Writeable for Type { 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()) } } +impl lightning::util::ser::Writeable for TypeRef { + fn write(&self, w: &mut W) -> Result<(), crate::c_types::io::Error> { + let vec = (self.0.write)(self.0.this_arg); + w.write_all(vec.as_slice()) + } +} #[no_mangle] /// Creates a copy of a Type pub extern "C" fn Type_clone(orig: &Type) -> Type { @@ -150,6 +171,11 @@ impl Clone for Type { Type_clone(self) } } +impl Clone for TypeRef { + fn clone(&self) -> Self { + Self(Type_clone(&self.0)) + } +} use lightning::ln::wire::Type as rustType; impl rustType for Type { @@ -159,17 +185,25 @@ impl rustType for Type { } } +pub struct TypeRef(Type); +impl rustType for TypeRef { + fn type_id(&self) -> u16 { + let mut ret = (self.0.type_id)(self.0.this_arg); + 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 Type { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = TypeRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const TypeRef) } } } impl core::ops::DerefMut for Type { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut TypeRef { + unsafe { &mut *(self as *mut _ as *mut TypeRef) } } } /// Calls the free function if one is set diff --git a/lightning-c-bindings/src/lightning/mod.rs b/lightning-c-bindings/src/lightning/mod.rs index 4eb7beb..6b19d5f 100644 --- a/lightning-c-bindings/src/lightning/mod.rs +++ b/lightning-c-bindings/src/lightning/mod.rs @@ -53,6 +53,7 @@ pub mod sign; pub mod onion_message; pub mod blinded_path; pub mod events; +pub mod io; mod crypto { use alloc::str::FromStr; diff --git a/lightning-c-bindings/src/lightning/offers/invoice.rs b/lightning-c-bindings/src/lightning/offers/invoice.rs index c382ac8..61f2bdb 100644 --- a/lightning-c-bindings/src/lightning/offers/invoice.rs +++ b/lightning-c-bindings/src/lightning/offers/invoice.rs @@ -13,14 +13,14 @@ //! 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. +//! receipt, and one or more [`BlindedPaymentPath`]s for the payer to use when sending the payment. //! //! ``` //! extern crate bitcoin; //! extern crate lightning; //! //! use bitcoin::hashes::Hash; -//! use bitcoin::secp256k1::{KeyPair, PublicKey, Secp256k1, SecretKey}; +//! use bitcoin::secp256k1::{Keypair, PublicKey, Secp256k1, SecretKey}; //! use core::convert::TryFrom; //! use lightning::offers::invoice::UnsignedBolt12Invoice; //! use lightning::offers::invoice_request::InvoiceRequest; @@ -28,17 +28,17 @@ //! use lightning::util::ser::Writeable; //! //! # use lightning::ln::types::PaymentHash; -//! # use lightning::offers::invoice::{BlindedPayInfo, ExplicitSigningPubkey, InvoiceBuilder}; -//! # use lightning::blinded_path::BlindedPath; +//! # use lightning::offers::invoice::{ExplicitSigningPubkey, InvoiceBuilder}; +//! # use lightning::blinded_path::payment::{BlindedPayInfo, BlindedPaymentPath}; //! # -//! # fn create_payment_paths() -> Vec<(BlindedPayInfo, BlindedPath)> { unimplemented!() } +//! # fn create_payment_paths() -> Vec { unimplemented!() } //! # fn create_payment_hash() -> PaymentHash { unimplemented!() } //! # //! # 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(); -//! let keys = KeyPair::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32])?); +//! let keys = Keypair::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32])?); //! let pubkey = PublicKey::from(keys); //! let wpubkey_hash = bitcoin::key::PublicKey::new(pubkey).wpubkey_hash().unwrap(); //! let mut buffer = Vec::new(); @@ -67,7 +67,7 @@ //! # let payment_paths = create_payment_paths(); //! # let payment_hash = create_payment_hash(); //! # let secp_ctx = Secp256k1::new(); -//! # let keys = KeyPair::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32])?); +//! # let keys = Keypair::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32])?); //! # let pubkey = PublicKey::from(keys); //! # let wpubkey_hash = bitcoin::key::PublicKey::new(pubkey).wpubkey_hash().unwrap(); //! # let mut buffer = Vec::new(); @@ -132,6 +132,12 @@ pub struct InvoiceWithExplicitSigningPubkeyBuilder { pub is_owned: bool, } +impl core::ops::Deref for InvoiceWithExplicitSigningPubkeyBuilder { + type Target = nativeInvoiceWithExplicitSigningPubkeyBuilder; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for InvoiceWithExplicitSigningPubkeyBuilder { } +unsafe impl core::marker::Sync for InvoiceWithExplicitSigningPubkeyBuilder { } impl Drop for InvoiceWithExplicitSigningPubkeyBuilder { fn drop(&mut self) { if self.is_owned && !<*mut nativeInvoiceWithExplicitSigningPubkeyBuilder>::is_null(self.inner) { @@ -162,6 +168,9 @@ impl InvoiceWithExplicitSigningPubkeyBuilder { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } use lightning::offers::invoice::InvoiceWithDerivedSigningPubkeyBuilder as nativeInvoiceWithDerivedSigningPubkeyBuilderImport; @@ -191,6 +200,12 @@ pub struct InvoiceWithDerivedSigningPubkeyBuilder { pub is_owned: bool, } +impl core::ops::Deref for InvoiceWithDerivedSigningPubkeyBuilder { + type Target = nativeInvoiceWithDerivedSigningPubkeyBuilder; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for InvoiceWithDerivedSigningPubkeyBuilder { } +unsafe impl core::marker::Sync for InvoiceWithDerivedSigningPubkeyBuilder { } impl Drop for InvoiceWithDerivedSigningPubkeyBuilder { fn drop(&mut self) { if self.is_owned && !<*mut nativeInvoiceWithDerivedSigningPubkeyBuilder>::is_null(self.inner) { @@ -221,6 +236,9 @@ impl InvoiceWithDerivedSigningPubkeyBuilder { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Builds an unsigned [`Bolt12Invoice`] after checking for valid semantics. It can be signed by /// [`UnsignedBolt12Invoice::sign`]. @@ -232,9 +250,10 @@ pub extern "C" fn InvoiceWithExplicitSigningPubkeyBuilder_build(mut this_arg: cr local_ret } -/// Sets the [`Bolt12Invoice::relative_expiry`] as seconds since [`Bolt12Invoice::created_at`]. -/// Any expiry that has already passed is valid and can be checked for using -/// [`Bolt12Invoice::is_expired`]. +///Sets the [`Bolt12Invoice::relative_expiry`] +///as seconds since [`Bolt12Invoice::created_at`]. +///Any expiry that has already passed is valid and can be checked for using +///[`Bolt12Invoice::is_expired`]. /// /// Successive calls to this method will override the previous setting. #[must_use] @@ -244,29 +263,29 @@ pub extern "C" fn InvoiceWithExplicitSigningPubkeyBuilder_relative_expiry(mut th () /*ret*/ } -/// Adds a P2WSH address to [`Bolt12Invoice::fallbacks`]. +///Adds a P2WSH address to [`Bolt12Invoice::fallbacks`]. /// /// Successive calls to this method will add another address. Caller is responsible for not /// adding duplicate addresses and only calling if capable of receiving to P2WSH addresses. #[must_use] #[no_mangle] pub extern "C" fn InvoiceWithExplicitSigningPubkeyBuilder_fallback_v0_p2wsh(mut this_arg: crate::lightning::offers::invoice::InvoiceWithExplicitSigningPubkeyBuilder, script_hash: *const [u8; 32]) { - let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).fallback_v0_p2wsh(&bitcoin::hash_types::WScriptHash::from_raw_hash(bitcoin::hashes::Hash::from_byte_array(unsafe { *script_hash }.clone()))); + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).fallback_v0_p2wsh(&bitcoin::WScriptHash::from_raw_hash(bitcoin::hashes::Hash::from_byte_array(unsafe { *script_hash }.clone()))); () /*ret*/ } -/// Adds a P2WPKH address to [`Bolt12Invoice::fallbacks`]. +///Adds a P2WPKH address to [`Bolt12Invoice::fallbacks`]. /// /// Successive calls to this method will add another address. Caller is responsible for not /// adding duplicate addresses and only calling if capable of receiving to P2WPKH addresses. #[must_use] #[no_mangle] pub extern "C" fn InvoiceWithExplicitSigningPubkeyBuilder_fallback_v0_p2wpkh(mut this_arg: crate::lightning::offers::invoice::InvoiceWithExplicitSigningPubkeyBuilder, pubkey_hash: *const [u8; 20]) { - let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).fallback_v0_p2wpkh(&bitcoin::hash_types::WPubkeyHash::from_raw_hash(bitcoin::hashes::Hash::from_byte_array(unsafe { *pubkey_hash }.clone()))); + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).fallback_v0_p2wpkh(&bitcoin::WPubkeyHash::from_raw_hash(bitcoin::hashes::Hash::from_byte_array(unsafe { *pubkey_hash }.clone()))); () /*ret*/ } -/// Adds a P2TR address to [`Bolt12Invoice::fallbacks`]. +///Adds a P2TR address to [`Bolt12Invoice::fallbacks`]. /// /// Successive calls to this method will add another address. Caller is responsible for not /// adding duplicate addresses and only calling if capable of receiving to P2TR addresses. @@ -277,8 +296,8 @@ pub extern "C" fn InvoiceWithExplicitSigningPubkeyBuilder_fallback_v1_p2tr_tweak () /*ret*/ } -/// Sets [`Bolt12Invoice::invoice_features`] to indicate MPP may be used. Otherwise, MPP is -/// disallowed. +///Sets [`Bolt12Invoice::invoice_features`] +///to indicate MPP may be used. Otherwise, MPP is disallowed. #[must_use] #[no_mangle] pub extern "C" fn InvoiceWithExplicitSigningPubkeyBuilder_allow_mpp(mut this_arg: crate::lightning::offers::invoice::InvoiceWithExplicitSigningPubkeyBuilder) { @@ -295,9 +314,10 @@ pub extern "C" fn InvoiceWithDerivedSigningPubkeyBuilder_build_and_sign(mut this local_ret } -/// Sets the [`Bolt12Invoice::relative_expiry`] as seconds since [`Bolt12Invoice::created_at`]. -/// Any expiry that has already passed is valid and can be checked for using -/// [`Bolt12Invoice::is_expired`]. +///Sets the [`Bolt12Invoice::relative_expiry`] +///as seconds since [`Bolt12Invoice::created_at`]. +///Any expiry that has already passed is valid and can be checked for using +///[`Bolt12Invoice::is_expired`]. /// /// Successive calls to this method will override the previous setting. #[must_use] @@ -307,29 +327,29 @@ pub extern "C" fn InvoiceWithDerivedSigningPubkeyBuilder_relative_expiry(mut thi () /*ret*/ } -/// Adds a P2WSH address to [`Bolt12Invoice::fallbacks`]. +///Adds a P2WSH address to [`Bolt12Invoice::fallbacks`]. /// /// Successive calls to this method will add another address. Caller is responsible for not /// adding duplicate addresses and only calling if capable of receiving to P2WSH addresses. #[must_use] #[no_mangle] pub extern "C" fn InvoiceWithDerivedSigningPubkeyBuilder_fallback_v0_p2wsh(mut this_arg: crate::lightning::offers::invoice::InvoiceWithDerivedSigningPubkeyBuilder, script_hash: *const [u8; 32]) { - let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).fallback_v0_p2wsh(&bitcoin::hash_types::WScriptHash::from_raw_hash(bitcoin::hashes::Hash::from_byte_array(unsafe { *script_hash }.clone()))); + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).fallback_v0_p2wsh(&bitcoin::WScriptHash::from_raw_hash(bitcoin::hashes::Hash::from_byte_array(unsafe { *script_hash }.clone()))); () /*ret*/ } -/// Adds a P2WPKH address to [`Bolt12Invoice::fallbacks`]. +///Adds a P2WPKH address to [`Bolt12Invoice::fallbacks`]. /// /// Successive calls to this method will add another address. Caller is responsible for not /// adding duplicate addresses and only calling if capable of receiving to P2WPKH addresses. #[must_use] #[no_mangle] pub extern "C" fn InvoiceWithDerivedSigningPubkeyBuilder_fallback_v0_p2wpkh(mut this_arg: crate::lightning::offers::invoice::InvoiceWithDerivedSigningPubkeyBuilder, pubkey_hash: *const [u8; 20]) { - let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).fallback_v0_p2wpkh(&bitcoin::hash_types::WPubkeyHash::from_raw_hash(bitcoin::hashes::Hash::from_byte_array(unsafe { *pubkey_hash }.clone()))); + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).fallback_v0_p2wpkh(&bitcoin::WPubkeyHash::from_raw_hash(bitcoin::hashes::Hash::from_byte_array(unsafe { *pubkey_hash }.clone()))); () /*ret*/ } -/// Adds a P2TR address to [`Bolt12Invoice::fallbacks`]. +///Adds a P2TR address to [`Bolt12Invoice::fallbacks`]. /// /// Successive calls to this method will add another address. Caller is responsible for not /// adding duplicate addresses and only calling if capable of receiving to P2TR addresses. @@ -340,8 +360,8 @@ pub extern "C" fn InvoiceWithDerivedSigningPubkeyBuilder_fallback_v1_p2tr_tweake () /*ret*/ } -/// Sets [`Bolt12Invoice::invoice_features`] to indicate MPP may be used. Otherwise, MPP is -/// disallowed. +///Sets [`Bolt12Invoice::invoice_features`] +///to indicate MPP may be used. Otherwise, MPP is disallowed. #[must_use] #[no_mangle] pub extern "C" fn InvoiceWithDerivedSigningPubkeyBuilder_allow_mpp(mut this_arg: crate::lightning::offers::invoice::InvoiceWithDerivedSigningPubkeyBuilder) { @@ -374,6 +394,12 @@ pub struct UnsignedBolt12Invoice { pub is_owned: bool, } +impl core::ops::Deref for UnsignedBolt12Invoice { + type Target = nativeUnsignedBolt12Invoice; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for UnsignedBolt12Invoice { } +unsafe impl core::marker::Sync for UnsignedBolt12Invoice { } impl Drop for UnsignedBolt12Invoice { fn drop(&mut self) { if self.is_owned && !<*mut nativeUnsignedBolt12Invoice>::is_null(self.inner) { @@ -404,6 +430,9 @@ impl UnsignedBolt12Invoice { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } impl Clone for UnsignedBolt12Invoice { fn clone(&self) -> Self { @@ -456,17 +485,26 @@ impl rustSignBolt12InvoiceFn for SignBolt12InvoiceFn { } } +pub struct SignBolt12InvoiceFnRef(SignBolt12InvoiceFn); +impl rustSignBolt12InvoiceFn for SignBolt12InvoiceFnRef { + fn sign_invoice(&self, mut message: &lightning::offers::invoice::UnsignedBolt12Invoice) -> Result { + let mut ret = (self.0.sign_invoice)(self.0.this_arg, &crate::lightning::offers::invoice::UnsignedBolt12Invoice { inner: unsafe { ObjOps::nonnull_ptr_to_inner((message as *const lightning::offers::invoice::UnsignedBolt12Invoice<>) 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 SignBolt12InvoiceFn { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = SignBolt12InvoiceFnRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const SignBolt12InvoiceFnRef) } } } impl core::ops::DerefMut for SignBolt12InvoiceFn { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut SignBolt12InvoiceFnRef { + unsafe { &mut *(self as *mut _ as *mut SignBolt12InvoiceFnRef) } } } /// Calls the free function if one is set @@ -514,6 +552,12 @@ pub struct Bolt12Invoice { pub is_owned: bool, } +impl core::ops::Deref for Bolt12Invoice { + type Target = nativeBolt12Invoice; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for Bolt12Invoice { } +unsafe impl core::marker::Sync for Bolt12Invoice { } impl Drop for Bolt12Invoice { fn drop(&mut self) { if self.is_owned && !<*mut nativeBolt12Invoice>::is_null(self.inner) { @@ -544,6 +588,9 @@ impl Bolt12Invoice { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } impl Clone for Bolt12Invoice { fn clone(&self) -> Self { @@ -567,6 +614,58 @@ pub extern "C" fn Bolt12Invoice_clone(orig: &Bolt12Invoice) -> Bolt12Invoice { /// Get a string which allows debug introspection of a Bolt12Invoice object pub extern "C" fn Bolt12Invoice_debug_str_void(o: *const c_void) -> Str { alloc::format!("{:?}", unsafe { o as *const crate::lightning::offers::invoice::Bolt12Invoice }).into()} +/// Duration since the Unix epoch when the invoice was created. +#[must_use] +#[no_mangle] +pub extern "C" fn UnsignedBolt12Invoice_created_at(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> 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 UnsignedBolt12Invoice_relative_expiry(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> 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 UnsignedBolt12Invoice_is_expired(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.is_expired(); + ret +} + +/// Fallback addresses for paying the invoice on-chain, in order of most-preferred to +/// least-preferred. +#[must_use] +#[no_mangle] +pub extern "C" fn UnsignedBolt12Invoice_fallbacks(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::derived::CVec_StrZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.fallbacks(); + 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() +} + +/// Features pertaining to paying an invoice. +#[must_use] +#[no_mangle] +pub extern "C" fn UnsignedBolt12Invoice_invoice_features(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::lightning_types::features::Bolt12InvoiceFeatures { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.invoice_features(); + crate::lightning_types::features::Bolt12InvoiceFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning_types::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 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) +} + /// The chains that may be used when paying a requested invoice. /// /// From [`Offer::chains`]; `None` if the invoice was created in response to a [`Refund`]. @@ -635,9 +734,9 @@ pub extern "C" fn UnsignedBolt12Invoice_amount(this_arg: &crate::lightning::offe /// 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 UnsignedBolt12Invoice_offer_features(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::lightning::ln::features::OfferFeatures { +pub extern "C" fn UnsignedBolt12Invoice_offer_features(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::lightning_types::features::OfferFeatures { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.offer_features(); - let mut local_ret = crate::lightning::ln::features::OfferFeatures { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning::ln::features::OfferFeatures<>) as *mut _ }, is_owned: false }; + let mut local_ret = crate::lightning_types::features::OfferFeatures { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning_types::features::OfferFeatures<>) as *mut _ }, is_owned: false }; local_ret } @@ -650,9 +749,9 @@ pub extern "C" fn UnsignedBolt12Invoice_offer_features(this_arg: &crate::lightni /// 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 UnsignedBolt12Invoice_description(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::lightning::util::string::PrintableString { +pub extern "C" fn UnsignedBolt12Invoice_description(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::lightning_types::string::PrintableString { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.description(); - let mut local_ret = crate::lightning::util::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; + let mut local_ret = crate::lightning_types::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; local_ret } @@ -678,9 +777,9 @@ pub extern "C" fn UnsignedBolt12Invoice_absolute_expiry(this_arg: &crate::lightn /// 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 UnsignedBolt12Invoice_issuer(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::lightning::util::string::PrintableString { +pub extern "C" fn UnsignedBolt12Invoice_issuer(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::lightning_types::string::PrintableString { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.issuer(); - let mut local_ret = crate::lightning::util::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; + let mut local_ret = crate::lightning_types::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; local_ret } @@ -691,9 +790,9 @@ pub extern "C" fn UnsignedBolt12Invoice_issuer(this_arg: &crate::lightning::offe /// [`Offer::paths`]: crate::offers::offer::Offer::paths #[must_use] #[no_mangle] -pub extern "C" fn UnsignedBolt12Invoice_message_paths(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::derived::CVec_BlindedPathZ { +pub extern "C" fn UnsignedBolt12Invoice_message_paths(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::derived::CVec_BlindedMessagePathZ { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.message_paths(); - let mut local_ret_clone = Vec::new(); local_ret_clone.extend_from_slice(ret); let mut ret = local_ret_clone; let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::blinded_path::BlindedPath { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; + let mut local_ret_clone = Vec::new(); local_ret_clone.extend_from_slice(ret); let mut ret = local_ret_clone; let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::blinded_path::message::BlindedMessagePath { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; local_ret.into() } @@ -727,9 +826,9 @@ pub extern "C" fn UnsignedBolt12Invoice_payer_metadata(this_arg: &crate::lightni /// From [`InvoiceRequest::invoice_request_features`] or [`Refund::features`]. #[must_use] #[no_mangle] -pub extern "C" fn UnsignedBolt12Invoice_invoice_request_features(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::lightning::ln::features::InvoiceRequestFeatures { +pub extern "C" fn UnsignedBolt12Invoice_invoice_request_features(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::lightning_types::features::InvoiceRequestFeatures { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.invoice_request_features(); - crate::lightning::ln::features::InvoiceRequestFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::InvoiceRequestFeatures<>) as *mut _) }, is_owned: false } + crate::lightning_types::features::InvoiceRequestFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning_types::features::InvoiceRequestFeatures<>) as *mut _) }, is_owned: false } } /// The quantity of items requested or refunded for. @@ -761,25 +860,42 @@ pub extern "C" fn UnsignedBolt12Invoice_payer_id(this_arg: &crate::lightning::of /// 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 UnsignedBolt12Invoice_payer_note(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::lightning::util::string::PrintableString { +pub extern "C" fn UnsignedBolt12Invoice_payer_note(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::lightning_types::string::PrintableString { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_note(); - let mut local_ret = crate::lightning::util::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; + let mut local_ret = crate::lightning_types::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; local_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 UnsignedBolt12Invoice_payment_hash(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> 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 UnsignedBolt12Invoice_amount_msats(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> u64 { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount_msats(); + ret +} + /// Duration since the Unix epoch when the invoice was created. #[must_use] #[no_mangle] -pub extern "C" fn UnsignedBolt12Invoice_created_at(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> u64 { +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. +/// 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 UnsignedBolt12Invoice_relative_expiry(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> u64 { +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() } @@ -787,39 +903,33 @@ pub extern "C" fn UnsignedBolt12Invoice_relative_expiry(this_arg: &crate::lightn /// Whether the invoice has expired. #[must_use] #[no_mangle] -pub extern "C" fn UnsignedBolt12Invoice_is_expired(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> bool { +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. +/// Fallback addresses for paying the invoice on-chain, in order of most-preferred to +/// least-preferred. #[must_use] #[no_mangle] -pub extern "C" fn UnsignedBolt12Invoice_payment_hash(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> 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 UnsignedBolt12Invoice_amount_msats(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> u64 { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount_msats(); - ret +pub extern "C" fn Bolt12Invoice_fallbacks(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::derived::CVec_StrZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.fallbacks(); + 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() } /// Features pertaining to paying an invoice. #[must_use] #[no_mangle] -pub extern "C" fn UnsignedBolt12Invoice_invoice_features(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::lightning::ln::features::Bolt12InvoiceFeatures { +pub extern "C" fn Bolt12Invoice_invoice_features(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::lightning_types::features::Bolt12InvoiceFeatures { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.invoice_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 } + crate::lightning_types::features::Bolt12InvoiceFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning_types::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 UnsignedBolt12Invoice_signing_pubkey(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::PublicKey { +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) } @@ -892,9 +1002,9 @@ pub extern "C" fn Bolt12Invoice_amount(this_arg: &crate::lightning::offers::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 Bolt12Invoice_offer_features(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::lightning::ln::features::OfferFeatures { +pub extern "C" fn Bolt12Invoice_offer_features(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::lightning_types::features::OfferFeatures { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.offer_features(); - let mut local_ret = crate::lightning::ln::features::OfferFeatures { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning::ln::features::OfferFeatures<>) as *mut _ }, is_owned: false }; + let mut local_ret = crate::lightning_types::features::OfferFeatures { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning_types::features::OfferFeatures<>) as *mut _ }, is_owned: false }; local_ret } @@ -907,9 +1017,9 @@ pub extern "C" fn Bolt12Invoice_offer_features(this_arg: &crate::lightning::offe /// 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 Bolt12Invoice_description(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::lightning::util::string::PrintableString { +pub extern "C" fn Bolt12Invoice_description(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::lightning_types::string::PrintableString { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.description(); - let mut local_ret = crate::lightning::util::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; + let mut local_ret = crate::lightning_types::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; local_ret } @@ -935,9 +1045,9 @@ pub extern "C" fn Bolt12Invoice_absolute_expiry(this_arg: &crate::lightning::off /// 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 Bolt12Invoice_issuer(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::lightning::util::string::PrintableString { +pub extern "C" fn Bolt12Invoice_issuer(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::lightning_types::string::PrintableString { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.issuer(); - let mut local_ret = crate::lightning::util::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; + let mut local_ret = crate::lightning_types::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; local_ret } @@ -948,9 +1058,9 @@ pub extern "C" fn Bolt12Invoice_issuer(this_arg: &crate::lightning::offers::invo /// [`Offer::paths`]: crate::offers::offer::Offer::paths #[must_use] #[no_mangle] -pub extern "C" fn Bolt12Invoice_message_paths(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::derived::CVec_BlindedPathZ { +pub extern "C" fn Bolt12Invoice_message_paths(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::derived::CVec_BlindedMessagePathZ { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.message_paths(); - let mut local_ret_clone = Vec::new(); local_ret_clone.extend_from_slice(ret); let mut ret = local_ret_clone; let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::blinded_path::BlindedPath { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; + let mut local_ret_clone = Vec::new(); local_ret_clone.extend_from_slice(ret); let mut ret = local_ret_clone; let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::blinded_path::message::BlindedMessagePath { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; local_ret.into() } @@ -984,9 +1094,9 @@ pub extern "C" fn Bolt12Invoice_payer_metadata(this_arg: &crate::lightning::offe /// From [`InvoiceRequest::invoice_request_features`] or [`Refund::features`]. #[must_use] #[no_mangle] -pub extern "C" fn Bolt12Invoice_invoice_request_features(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::lightning::ln::features::InvoiceRequestFeatures { +pub extern "C" fn Bolt12Invoice_invoice_request_features(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::lightning_types::features::InvoiceRequestFeatures { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.invoice_request_features(); - crate::lightning::ln::features::InvoiceRequestFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::InvoiceRequestFeatures<>) as *mut _) }, is_owned: false } + crate::lightning_types::features::InvoiceRequestFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning_types::features::InvoiceRequestFeatures<>) as *mut _) }, is_owned: false } } /// The quantity of items requested or refunded for. @@ -1018,37 +1128,12 @@ pub extern "C" fn Bolt12Invoice_payer_id(this_arg: &crate::lightning::offers::in /// 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 Bolt12Invoice_payer_note(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::lightning::util::string::PrintableString { +pub extern "C" fn Bolt12Invoice_payer_note(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::lightning_types::string::PrintableString { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_note(); - let mut local_ret = crate::lightning::util::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; + let mut local_ret = crate::lightning_types::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; local_ret } -/// 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] @@ -1065,22 +1150,6 @@ pub extern "C" fn Bolt12Invoice_amount_msats(this_arg: &crate::lightning::offers ret } -/// Features pertaining to paying an invoice. -#[must_use] -#[no_mangle] -pub extern "C" fn Bolt12Invoice_invoice_features(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::lightning::ln::features::Bolt12InvoiceFeatures { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.invoice_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) -} - /// Signature of the invoice verified using [`Bolt12Invoice::signing_pubkey`]. #[must_use] #[no_mangle] @@ -1097,12 +1166,25 @@ pub extern "C" fn Bolt12Invoice_signable_hash(this_arg: &crate::lightning::offer crate::c_types::ThirtyTwoBytes { data: ret } } -/// Verifies that the invoice was for a request or refund created using the given key. Returns -/// the associated [`PaymentId`] to use when sending the payment. +/// Verifies that the invoice was for a request or refund created using the given key by +/// checking the payer metadata from the invoice request. +/// +/// Returns the associated [`PaymentId`] to use when sending the payment. +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt12Invoice_verify_using_metadata(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice, key: &crate::lightning::ln::inbound_payment::ExpandedKey) -> crate::c_types::derived::CResult_ThirtyTwoBytesNoneZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.verify_using_metadata(key.get_native_ref(), secp256k1::global::SECP256K1); + 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( { () /*e*/ }).into() }; + local_ret +} + +/// Verifies that the invoice was for a request or refund created using the given key by +/// checking a payment id and nonce included with the [`BlindedMessagePath`] for which the invoice was +/// sent through. #[must_use] #[no_mangle] -pub extern "C" fn Bolt12Invoice_verify(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice, key: &crate::lightning::ln::inbound_payment::ExpandedKey) -> crate::c_types::derived::CResult_ThirtyTwoBytesNoneZ { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.verify(key.get_native_ref(), secp256k1::global::SECP256K1); +pub extern "C" fn Bolt12Invoice_verify_using_payer_data(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice, mut payment_id: crate::c_types::ThirtyTwoBytes, mut nonce: crate::lightning::offers::nonce::Nonce, key: &crate::lightning::ln::inbound_payment::ExpandedKey) -> crate::c_types::derived::CResult_ThirtyTwoBytesNoneZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.verify_using_payer_data(::lightning::ln::channelmanager::PaymentId(payment_id.data), *unsafe { Box::from_raw(nonce.take_inner()) }, key.get_native_ref(), secp256k1::global::SECP256K1); 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( { () /*e*/ }).into() }; local_ret } @@ -1124,7 +1206,7 @@ pub extern "C" fn UnsignedBolt12Invoice_write(obj: &crate::lightning::offers::in } #[allow(unused)] pub(crate) extern "C" fn UnsignedBolt12Invoice_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedBolt12Invoice) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::offers::invoice::nativeUnsignedBolt12Invoice) }) } #[no_mangle] /// Serialize the Bolt12Invoice object into a byte array which can be read by Bolt12Invoice_read @@ -1133,206 +1215,12 @@ pub extern "C" fn Bolt12Invoice_write(obj: &crate::lightning::offers::invoice::B } #[allow(unused)] 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; - -/// Information needed to route a payment across a [`BlindedPath`]. -#[must_use] -#[repr(C)] -pub struct BlindedPayInfo { - /// A pointer to the opaque Rust object. - - /// Nearly everywhere, 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 nativeBlindedPayInfo, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust 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 BlindedPayInfo { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeBlindedPayInfo>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; - } - } -} -/// Frees any resources used by the BlindedPayInfo, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn BlindedPayInfo_free(this_obj: BlindedPayInfo) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn BlindedPayInfo_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeBlindedPayInfo) }; -} -#[allow(unused)] -impl BlindedPayInfo { - pub(crate) fn get_native_ref(&self) -> &'static nativeBlindedPayInfo { - unsafe { &*ObjOps::untweak_ptr(self.inner) } - } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeBlindedPayInfo { - 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 nativeBlindedPayInfo { - assert!(self.is_owned); - let ret = ObjOps::untweak_ptr(self.inner); - self.inner = core::ptr::null_mut(); - ret - } -} -/// Base fee charged (in millisatoshi) for the entire blinded path. -#[no_mangle] -pub extern "C" fn BlindedPayInfo_get_fee_base_msat(this_ptr: &BlindedPayInfo) -> u32 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_base_msat; - *inner_val -} -/// Base fee charged (in millisatoshi) for the entire blinded path. -#[no_mangle] -pub extern "C" fn BlindedPayInfo_set_fee_base_msat(this_ptr: &mut BlindedPayInfo, mut val: u32) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_base_msat = val; -} -/// Liquidity fee charged (in millionths of the amount transferred) for the entire blinded path -/// (i.e., 10,000 is 1%). -#[no_mangle] -pub extern "C" fn BlindedPayInfo_get_fee_proportional_millionths(this_ptr: &BlindedPayInfo) -> u32 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_proportional_millionths; - *inner_val -} -/// Liquidity fee charged (in millionths of the amount transferred) for the entire blinded path -/// (i.e., 10,000 is 1%). -#[no_mangle] -pub extern "C" fn BlindedPayInfo_set_fee_proportional_millionths(this_ptr: &mut BlindedPayInfo, mut val: u32) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_proportional_millionths = val; -} -/// Number of blocks subtracted from an incoming HTLC's `cltv_expiry` for the entire blinded -/// path. -#[no_mangle] -pub extern "C" fn BlindedPayInfo_get_cltv_expiry_delta(this_ptr: &BlindedPayInfo) -> u16 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta; - *inner_val -} -/// Number of blocks subtracted from an incoming HTLC's `cltv_expiry` for the entire blinded -/// path. -#[no_mangle] -pub extern "C" fn BlindedPayInfo_set_cltv_expiry_delta(this_ptr: &mut BlindedPayInfo, mut val: u16) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = 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. -#[no_mangle] -pub extern "C" fn BlindedPayInfo_get_htlc_minimum_msat(this_ptr: &BlindedPayInfo) -> u64 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat; - *inner_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. -#[no_mangle] -pub extern "C" fn BlindedPayInfo_set_htlc_minimum_msat(this_ptr: &mut BlindedPayInfo, mut val: u64) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val; -} -/// 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. -#[no_mangle] -pub extern "C" fn BlindedPayInfo_get_htlc_maximum_msat(this_ptr: &BlindedPayInfo) -> u64 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_maximum_msat; - *inner_val -} -/// 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. -#[no_mangle] -pub extern "C" fn BlindedPayInfo_set_htlc_maximum_msat(this_ptr: &mut BlindedPayInfo, mut val: u64) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_maximum_msat = val; -} -/// Features set in `encrypted_data_tlv` for the `encrypted_recipient_data` TLV record in an -/// onion payload. -#[no_mangle] -pub extern "C" fn BlindedPayInfo_get_features(this_ptr: &BlindedPayInfo) -> crate::lightning::ln::features::BlindedHopFeatures { - let mut inner_val = &mut this_ptr.get_native_mut_ref().features; - crate::lightning::ln::features::BlindedHopFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::features::BlindedHopFeatures<>) as *mut _) }, is_owned: false } -} -/// Features set in `encrypted_data_tlv` for the `encrypted_recipient_data` TLV record in an -/// onion payload. -#[no_mangle] -pub extern "C" fn BlindedPayInfo_set_features(this_ptr: &mut BlindedPayInfo, mut val: crate::lightning::ln::features::BlindedHopFeatures) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) }; -} -/// Constructs a new BlindedPayInfo given each field -#[must_use] -#[no_mangle] -pub extern "C" fn BlindedPayInfo_new(mut fee_base_msat_arg: u32, mut fee_proportional_millionths_arg: u32, mut cltv_expiry_delta_arg: u16, mut htlc_minimum_msat_arg: u64, mut htlc_maximum_msat_arg: u64, mut features_arg: crate::lightning::ln::features::BlindedHopFeatures) -> BlindedPayInfo { - BlindedPayInfo { inner: ObjOps::heap_alloc(nativeBlindedPayInfo { - fee_base_msat: fee_base_msat_arg, - fee_proportional_millionths: fee_proportional_millionths_arg, - cltv_expiry_delta: cltv_expiry_delta_arg, - htlc_minimum_msat: htlc_minimum_msat_arg, - htlc_maximum_msat: htlc_maximum_msat_arg, - features: *unsafe { Box::from_raw(features_arg.take_inner()) }, - }), is_owned: true } -} -impl Clone for BlindedPayInfo { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeBlindedPayInfo>::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 BlindedPayInfo_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeBlindedPayInfo)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the BlindedPayInfo -pub extern "C" fn BlindedPayInfo_clone(orig: &BlindedPayInfo) -> BlindedPayInfo { - orig.clone() -} -/// Get a string which allows debug introspection of a BlindedPayInfo object -pub extern "C" fn BlindedPayInfo_debug_str_void(o: *const c_void) -> Str { - alloc::format!("{:?}", unsafe { o as *const crate::lightning::offers::invoice::BlindedPayInfo }).into()} -/// Generates a non-cryptographic 64-bit hash of the BlindedPayInfo. -#[no_mangle] -pub extern "C" fn BlindedPayInfo_hash(o: &BlindedPayInfo) -> 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 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. -#[no_mangle] -pub extern "C" fn BlindedPayInfo_eq(a: &BlindedPayInfo, b: &BlindedPayInfo) -> 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 BlindedPayInfo object into a byte array which can be read by BlindedPayInfo_read -pub extern "C" fn BlindedPayInfo_write(obj: &crate::lightning::offers::invoice::BlindedPayInfo) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) -} -#[allow(unused)] -pub(crate) extern "C" fn BlindedPayInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeBlindedPayInfo) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::offers::invoice::nativeBolt12Invoice) }) } #[no_mangle] -/// Read a BlindedPayInfo from a byte array, created by BlindedPayInfo_write -pub extern "C" fn BlindedPayInfo_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_BlindedPayInfoDecodeErrorZ { - 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::BlindedPayInfo { 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 Bolt12Invoice from a byte array, created by Bolt12Invoice_write +pub extern "C" fn Bolt12Invoice_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_Bolt12InvoiceDecodeErrorZ { + 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::Bolt12Invoice { 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_error.rs b/lightning-c-bindings/src/lightning/offers/invoice_error.rs index 11b392d..7557481 100644 --- a/lightning-c-bindings/src/lightning/offers/invoice_error.rs +++ b/lightning-c-bindings/src/lightning/offers/invoice_error.rs @@ -40,6 +40,12 @@ pub struct InvoiceError { pub is_owned: bool, } +impl core::ops::Deref for InvoiceError { + type Target = nativeInvoiceError; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for InvoiceError { } +unsafe impl core::marker::Sync for InvoiceError { } impl Drop for InvoiceError { fn drop(&mut self) { if self.is_owned && !<*mut nativeInvoiceError>::is_null(self.inner) { @@ -70,6 +76,9 @@ impl InvoiceError { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The field in the [`InvoiceRequest`] or the [`Bolt12Invoice`] that contained an error. /// @@ -96,13 +105,13 @@ pub extern "C" fn InvoiceError_set_erroneous_field(this_ptr: &mut InvoiceError, } /// An explanation of the error. #[no_mangle] -pub extern "C" fn InvoiceError_get_message(this_ptr: &InvoiceError) -> crate::lightning::util::string::UntrustedString { +pub extern "C" fn InvoiceError_get_message(this_ptr: &InvoiceError) -> crate::lightning_types::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 } + crate::lightning_types::string::UntrustedString { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning_types::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) { +pub extern "C" fn InvoiceError_set_message(this_ptr: &mut InvoiceError, mut val: crate::lightning_types::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 @@ -110,7 +119,7 @@ pub extern "C" fn InvoiceError_set_message(this_ptr: &mut InvoiceError, mut val: /// Note that erroneous_field_arg (or a relevant inner pointer) may be NULL or all-0s to represent None #[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 { +pub extern "C" fn InvoiceError_new(mut erroneous_field_arg: crate::lightning::offers::invoice_error::ErroneousField, mut message_arg: crate::lightning_types::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, @@ -162,6 +171,12 @@ pub struct ErroneousField { pub is_owned: bool, } +impl core::ops::Deref for ErroneousField { + type Target = nativeErroneousField; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ErroneousField { } +unsafe impl core::marker::Sync for ErroneousField { } impl Drop for ErroneousField { fn drop(&mut self) { if self.is_owned && !<*mut nativeErroneousField>::is_null(self.inner) { @@ -192,6 +207,9 @@ impl ErroneousField { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The type number of the TLV field containing the error. #[no_mangle] @@ -271,7 +289,7 @@ pub extern "C" fn InvoiceError_write(obj: &crate::lightning::offers::invoice_err } #[allow(unused)] 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) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::offers::invoice_error::nativeInvoiceError) }) } #[no_mangle] /// Read a InvoiceError from a byte array, created by InvoiceError_write diff --git a/lightning-c-bindings/src/lightning/offers/invoice_request.rs b/lightning-c-bindings/src/lightning/offers/invoice_request.rs index e9ebad0..9f8565d 100644 --- a/lightning-c-bindings/src/lightning/offers/invoice_request.rs +++ b/lightning-c-bindings/src/lightning/offers/invoice_request.rs @@ -22,8 +22,8 @@ //! extern crate bitcoin; //! extern crate lightning; //! -//! use bitcoin::network::constants::Network; -//! use bitcoin::secp256k1::{KeyPair, PublicKey, Secp256k1, SecretKey}; +//! use bitcoin::network::Network; +//! use bitcoin::secp256k1::{Keypair, PublicKey, Secp256k1, SecretKey}; //! use lightning::ln::features::OfferFeatures; //! use lightning::offers::invoice_request::UnsignedInvoiceRequest; //! use lightning::offers::offer::Offer; @@ -31,7 +31,7 @@ //! //! # 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 keys = Keypair::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32])?); //! let pubkey = PublicKey::from(keys); //! let mut buffer = Vec::new(); //! @@ -89,6 +89,12 @@ pub struct InvoiceRequestWithExplicitPayerIdBuilder { pub is_owned: bool, } +impl core::ops::Deref for InvoiceRequestWithExplicitPayerIdBuilder { + type Target = nativeInvoiceRequestWithExplicitPayerIdBuilder; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for InvoiceRequestWithExplicitPayerIdBuilder { } +unsafe impl core::marker::Sync for InvoiceRequestWithExplicitPayerIdBuilder { } impl Drop for InvoiceRequestWithExplicitPayerIdBuilder { fn drop(&mut self) { if self.is_owned && !<*mut nativeInvoiceRequestWithExplicitPayerIdBuilder>::is_null(self.inner) { @@ -119,6 +125,9 @@ impl InvoiceRequestWithExplicitPayerIdBuilder { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } use lightning::offers::invoice_request::InvoiceRequestWithDerivedPayerIdBuilder as nativeInvoiceRequestWithDerivedPayerIdBuilderImport; @@ -144,6 +153,12 @@ pub struct InvoiceRequestWithDerivedPayerIdBuilder { pub is_owned: bool, } +impl core::ops::Deref for InvoiceRequestWithDerivedPayerIdBuilder { + type Target = nativeInvoiceRequestWithDerivedPayerIdBuilder; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for InvoiceRequestWithDerivedPayerIdBuilder { } +unsafe impl core::marker::Sync for InvoiceRequestWithDerivedPayerIdBuilder { } impl Drop for InvoiceRequestWithDerivedPayerIdBuilder { fn drop(&mut self) { if self.is_owned && !<*mut nativeInvoiceRequestWithDerivedPayerIdBuilder>::is_null(self.inner) { @@ -174,6 +189,9 @@ impl InvoiceRequestWithDerivedPayerIdBuilder { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Builds an unsigned [`InvoiceRequest`] after checking for valid semantics. It can be signed /// by [`UnsignedInvoiceRequest::sign`]. @@ -317,6 +335,12 @@ pub struct UnsignedInvoiceRequest { pub is_owned: bool, } +impl core::ops::Deref for UnsignedInvoiceRequest { + type Target = nativeUnsignedInvoiceRequest; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for UnsignedInvoiceRequest { } +unsafe impl core::marker::Sync for UnsignedInvoiceRequest { } impl Drop for UnsignedInvoiceRequest { fn drop(&mut self) { if self.is_owned && !<*mut nativeUnsignedInvoiceRequest>::is_null(self.inner) { @@ -347,6 +371,9 @@ impl UnsignedInvoiceRequest { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } impl Clone for UnsignedInvoiceRequest { fn clone(&self) -> Self { @@ -399,17 +426,26 @@ impl rustSignInvoiceRequestFn for SignInvoiceRequestFn { } } +pub struct SignInvoiceRequestFnRef(SignInvoiceRequestFn); +impl rustSignInvoiceRequestFn for SignInvoiceRequestFnRef { + fn sign_invoice_request(&self, mut message: &lightning::offers::invoice_request::UnsignedInvoiceRequest) -> Result { + let mut ret = (self.0.sign_invoice_request)(self.0.this_arg, &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest { inner: unsafe { ObjOps::nonnull_ptr_to_inner((message as *const lightning::offers::invoice_request::UnsignedInvoiceRequest<>) 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 SignInvoiceRequestFn { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = SignInvoiceRequestFnRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const SignInvoiceRequestFnRef) } } } impl core::ops::DerefMut for SignInvoiceRequestFn { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut SignInvoiceRequestFnRef { + unsafe { &mut *(self as *mut _ as *mut SignInvoiceRequestFnRef) } } } /// Calls the free function if one is set @@ -456,6 +492,12 @@ pub struct InvoiceRequest { pub is_owned: bool, } +impl core::ops::Deref for InvoiceRequest { + type Target = nativeInvoiceRequest; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for InvoiceRequest { } +unsafe impl core::marker::Sync for InvoiceRequest { } impl Drop for InvoiceRequest { fn drop(&mut self) { if self.is_owned && !<*mut nativeInvoiceRequest>::is_null(self.inner) { @@ -486,6 +528,9 @@ impl InvoiceRequest { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } impl Clone for InvoiceRequest { fn clone(&self) -> Self { @@ -513,8 +558,9 @@ pub extern "C" fn InvoiceRequest_debug_str_void(o: *const c_void) -> Str { use lightning::offers::invoice_request::VerifiedInvoiceRequest as nativeVerifiedInvoiceRequestImport; pub(crate) type nativeVerifiedInvoiceRequest = nativeVerifiedInvoiceRequestImport; -/// An [`InvoiceRequest`] that has been verified by [`InvoiceRequest::verify`] and exposes different -/// ways to respond depending on whether the signing keys were derived. +/// An [`InvoiceRequest`] that has been verified by [`InvoiceRequest::verify_using_metadata`] or +/// [`InvoiceRequest::verify_using_recipient_data`] and exposes different ways to respond depending +/// on whether the signing keys were derived. #[must_use] #[repr(C)] pub struct VerifiedInvoiceRequest { @@ -530,6 +576,12 @@ pub struct VerifiedInvoiceRequest { pub is_owned: bool, } +impl core::ops::Deref for VerifiedInvoiceRequest { + type Target = nativeVerifiedInvoiceRequest; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for VerifiedInvoiceRequest { } +unsafe impl core::marker::Sync for VerifiedInvoiceRequest { } impl Drop for VerifiedInvoiceRequest { fn drop(&mut self) { if self.is_owned && !<*mut nativeVerifiedInvoiceRequest>::is_null(self.inner) { @@ -560,6 +612,9 @@ impl VerifiedInvoiceRequest { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The identifier of the [`Offer`] for which the [`InvoiceRequest`] was made. #[no_mangle] @@ -572,33 +627,6 @@ pub extern "C" fn VerifiedInvoiceRequest_get_offer_id(this_ptr: &VerifiedInvoice pub extern "C" fn VerifiedInvoiceRequest_set_offer_id(this_ptr: &mut VerifiedInvoiceRequest, mut val: crate::lightning::offers::offer::OfferId) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.offer_id = *unsafe { Box::from_raw(val.take_inner()) }; } -/// Keys used for signing a [`Bolt12Invoice`] if they can be derived. -/// -/// If `Some`, must call [`respond_using_derived_keys`] when responding. Otherwise, call -/// [`respond_with`]. -/// -/// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice -/// [`respond_using_derived_keys`]: Self::respond_using_derived_keys -/// [`respond_with`]: Self::respond_with -#[no_mangle] -pub extern "C" fn VerifiedInvoiceRequest_get_keys(this_ptr: &VerifiedInvoiceRequest) -> crate::c_types::derived::COption_SecretKeyZ { - let mut inner_val = &mut this_ptr.get_native_mut_ref().keys; - let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_SecretKeyZ::None } else { crate::c_types::derived::COption_SecretKeyZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option is otherwise un-expressable. */ { crate::c_types::SecretKey::from_rust((*inner_val.as_ref().unwrap()).clone().secret_key()) }) }; - local_inner_val -} -/// Keys used for signing a [`Bolt12Invoice`] if they can be derived. -/// -/// If `Some`, must call [`respond_using_derived_keys`] when responding. Otherwise, call -/// [`respond_with`]. -/// -/// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice -/// [`respond_using_derived_keys`]: Self::respond_using_derived_keys -/// [`respond_with`]: Self::respond_with -#[no_mangle] -pub extern "C" fn VerifiedInvoiceRequest_set_keys(this_ptr: &mut VerifiedInvoiceRequest, mut val: crate::c_types::derived::COption_SecretKeyZ) { - let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::bitcoin::secp256k1::KeyPair::from_secret_key(&secp256k1::global::SECP256K1, &{ val_opt.take() }.into_rust()) }})} }; - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.keys = local_val; -} impl Clone for VerifiedInvoiceRequest { fn clone(&self) -> Self { Self { @@ -657,18 +685,18 @@ pub extern "C" fn UnsignedInvoiceRequest_amount(this_arg: &crate::lightning::off /// 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 UnsignedInvoiceRequest_description(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::lightning::util::string::PrintableString { +pub extern "C" fn UnsignedInvoiceRequest_description(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::lightning_types::string::PrintableString { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.description(); - let mut local_ret = crate::lightning::util::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; + let mut local_ret = crate::lightning_types::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; local_ret } /// Features pertaining to the offer. #[must_use] #[no_mangle] -pub extern "C" fn UnsignedInvoiceRequest_offer_features(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::lightning::ln::features::OfferFeatures { +pub extern "C" fn UnsignedInvoiceRequest_offer_features(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::lightning_types::features::OfferFeatures { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.offer_features(); - crate::lightning::ln::features::OfferFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::OfferFeatures<>) as *mut _) }, is_owned: false } + crate::lightning_types::features::OfferFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning_types::features::OfferFeatures<>) as *mut _) }, is_owned: false } } /// Duration since the Unix epoch when an invoice should no longer be requested. @@ -688,9 +716,9 @@ pub extern "C" fn UnsignedInvoiceRequest_absolute_expiry(this_arg: &crate::light /// 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 UnsignedInvoiceRequest_issuer(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::lightning::util::string::PrintableString { +pub extern "C" fn UnsignedInvoiceRequest_issuer(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::lightning_types::string::PrintableString { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.issuer(); - let mut local_ret = crate::lightning::util::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; + let mut local_ret = crate::lightning_types::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; local_ret } @@ -698,9 +726,9 @@ pub extern "C" fn UnsignedInvoiceRequest_issuer(this_arg: &crate::lightning::off /// recipient privacy by obfuscating its node id. #[must_use] #[no_mangle] -pub extern "C" fn UnsignedInvoiceRequest_paths(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::derived::CVec_BlindedPathZ { +pub extern "C" fn UnsignedInvoiceRequest_paths(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::derived::CVec_BlindedMessagePathZ { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.paths(); - let mut local_ret_clone = Vec::new(); local_ret_clone.extend_from_slice(ret); let mut ret = local_ret_clone; let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::blinded_path::BlindedPath { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; + let mut local_ret_clone = Vec::new(); local_ret_clone.extend_from_slice(ret); let mut ret = local_ret_clone; let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::blinded_path::message::BlindedMessagePath { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; local_ret.into() } @@ -758,9 +786,9 @@ pub extern "C" fn UnsignedInvoiceRequest_amount_msats(this_arg: &crate::lightnin /// Features pertaining to requesting an invoice. #[must_use] #[no_mangle] -pub extern "C" fn UnsignedInvoiceRequest_invoice_request_features(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::lightning::ln::features::InvoiceRequestFeatures { +pub extern "C" fn UnsignedInvoiceRequest_invoice_request_features(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::lightning_types::features::InvoiceRequestFeatures { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.invoice_request_features(); - crate::lightning::ln::features::InvoiceRequestFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::InvoiceRequestFeatures<>) as *mut _) }, is_owned: false } + crate::lightning_types::features::InvoiceRequestFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning_types::features::InvoiceRequestFeatures<>) as *mut _) }, is_owned: false } } /// The quantity of the offer's item conforming to [`Offer::is_valid_quantity`]. @@ -786,9 +814,9 @@ pub extern "C" fn UnsignedInvoiceRequest_payer_id(this_arg: &crate::lightning::o /// 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 UnsignedInvoiceRequest_payer_note(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::lightning::util::string::PrintableString { +pub extern "C" fn UnsignedInvoiceRequest_payer_note(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::lightning_types::string::PrintableString { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_note(); - let mut local_ret = crate::lightning::util::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; + let mut local_ret = crate::lightning_types::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; local_ret } @@ -828,18 +856,18 @@ pub extern "C" fn InvoiceRequest_amount(this_arg: &crate::lightning::offers::inv /// 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 InvoiceRequest_description(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::lightning::util::string::PrintableString { +pub extern "C" fn InvoiceRequest_description(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::lightning_types::string::PrintableString { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.description(); - let mut local_ret = crate::lightning::util::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; + let mut local_ret = crate::lightning_types::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; local_ret } /// Features pertaining to the offer. #[must_use] #[no_mangle] -pub extern "C" fn InvoiceRequest_offer_features(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::lightning::ln::features::OfferFeatures { +pub extern "C" fn InvoiceRequest_offer_features(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::lightning_types::features::OfferFeatures { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.offer_features(); - crate::lightning::ln::features::OfferFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::OfferFeatures<>) as *mut _) }, is_owned: false } + crate::lightning_types::features::OfferFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning_types::features::OfferFeatures<>) as *mut _) }, is_owned: false } } /// Duration since the Unix epoch when an invoice should no longer be requested. @@ -859,9 +887,9 @@ pub extern "C" fn InvoiceRequest_absolute_expiry(this_arg: &crate::lightning::of /// 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 InvoiceRequest_issuer(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::lightning::util::string::PrintableString { +pub extern "C" fn InvoiceRequest_issuer(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::lightning_types::string::PrintableString { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.issuer(); - let mut local_ret = crate::lightning::util::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; + let mut local_ret = crate::lightning_types::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; local_ret } @@ -869,9 +897,9 @@ pub extern "C" fn InvoiceRequest_issuer(this_arg: &crate::lightning::offers::inv /// recipient privacy by obfuscating its node id. #[must_use] #[no_mangle] -pub extern "C" fn InvoiceRequest_paths(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::derived::CVec_BlindedPathZ { +pub extern "C" fn InvoiceRequest_paths(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::derived::CVec_BlindedMessagePathZ { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.paths(); - let mut local_ret_clone = Vec::new(); local_ret_clone.extend_from_slice(ret); let mut ret = local_ret_clone; let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::blinded_path::BlindedPath { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; + let mut local_ret_clone = Vec::new(); local_ret_clone.extend_from_slice(ret); let mut ret = local_ret_clone; let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::blinded_path::message::BlindedMessagePath { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; local_ret.into() } @@ -929,9 +957,9 @@ pub extern "C" fn InvoiceRequest_amount_msats(this_arg: &crate::lightning::offer /// Features pertaining to requesting an invoice. #[must_use] #[no_mangle] -pub extern "C" fn InvoiceRequest_invoice_request_features(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::lightning::ln::features::InvoiceRequestFeatures { +pub extern "C" fn InvoiceRequest_invoice_request_features(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::lightning_types::features::InvoiceRequestFeatures { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.invoice_request_features(); - crate::lightning::ln::features::InvoiceRequestFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::InvoiceRequestFeatures<>) as *mut _) }, is_owned: false } + crate::lightning_types::features::InvoiceRequestFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning_types::features::InvoiceRequestFeatures<>) as *mut _) }, is_owned: false } } /// The quantity of the offer's item conforming to [`Offer::is_valid_quantity`]. @@ -957,9 +985,9 @@ pub extern "C" fn InvoiceRequest_payer_id(this_arg: &crate::lightning::offers::i /// 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 InvoiceRequest_payer_note(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::lightning::util::string::PrintableString { +pub extern "C" fn InvoiceRequest_payer_note(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::lightning_types::string::PrintableString { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_note(); - let mut local_ret = crate::lightning::util::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; + let mut local_ret = crate::lightning_types::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; local_ret } @@ -972,8 +1000,8 @@ pub extern "C" fn InvoiceRequest_payer_note(this_arg: &crate::lightning::offers: /// [`Duration`]: core::time::Duration #[must_use] #[no_mangle] -pub extern "C" fn InvoiceRequest_respond_with(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest, mut payment_paths: crate::c_types::derived::CVec_C2Tuple_BlindedPayInfoBlindedPathZZ, mut payment_hash: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ { - let mut local_payment_paths = Vec::new(); for mut item in payment_paths.into_rust().drain(..) { local_payment_paths.push( { let (mut orig_payment_paths_0_0, mut orig_payment_paths_0_1) = item.to_rust(); let mut local_payment_paths_0 = (*unsafe { Box::from_raw(orig_payment_paths_0_0.take_inner()) }, *unsafe { Box::from_raw(orig_payment_paths_0_1.take_inner()) }); local_payment_paths_0 }); }; +pub extern "C" fn InvoiceRequest_respond_with(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest, mut payment_paths: crate::c_types::derived::CVec_BlindedPaymentPathZ, mut payment_hash: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ { + let mut local_payment_paths = Vec::new(); for mut item in payment_paths.into_rust().drain(..) { local_payment_paths.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.respond_with(local_payment_paths, ::lightning::ln::types::PaymentHash(payment_hash.data)); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::invoice::InvoiceWithExplicitSigningPubkeyBuilder { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::offers::parse::Bolt12SemanticError::native_into(e) }).into() }; local_ret @@ -998,28 +1026,47 @@ pub extern "C" fn InvoiceRequest_respond_with(this_arg: &crate::lightning::offer /// # Note /// /// If the originating [`Offer`] was created using [`OfferBuilder::deriving_signing_pubkey`], -/// then use [`InvoiceRequest::verify`] and [`VerifiedInvoiceRequest`] methods instead. +/// then first use [`InvoiceRequest::verify_using_metadata`] or +/// [`InvoiceRequest::verify_using_recipient_data`] and then [`VerifiedInvoiceRequest`] methods +/// instead. /// /// [`Bolt12Invoice::created_at`]: crate::offers::invoice::Bolt12Invoice::created_at /// [`OfferBuilder::deriving_signing_pubkey`]: crate::offers::offer::OfferBuilder::deriving_signing_pubkey #[must_use] #[no_mangle] -pub extern "C" fn InvoiceRequest_respond_with_no_std(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest, mut payment_paths: crate::c_types::derived::CVec_C2Tuple_BlindedPayInfoBlindedPathZZ, mut payment_hash: crate::c_types::ThirtyTwoBytes, mut created_at: u64) -> crate::c_types::derived::CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ { - let mut local_payment_paths = Vec::new(); for mut item in payment_paths.into_rust().drain(..) { local_payment_paths.push( { let (mut orig_payment_paths_0_0, mut orig_payment_paths_0_1) = item.to_rust(); let mut local_payment_paths_0 = (*unsafe { Box::from_raw(orig_payment_paths_0_0.take_inner()) }, *unsafe { Box::from_raw(orig_payment_paths_0_1.take_inner()) }); local_payment_paths_0 }); }; +pub extern "C" fn InvoiceRequest_respond_with_no_std(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest, mut payment_paths: crate::c_types::derived::CVec_BlindedPaymentPathZ, mut payment_hash: crate::c_types::ThirtyTwoBytes, mut created_at: u64) -> crate::c_types::derived::CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ { + let mut local_payment_paths = Vec::new(); for mut item in payment_paths.into_rust().drain(..) { local_payment_paths.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.respond_with_no_std(local_payment_paths, ::lightning::ln::types::PaymentHash(payment_hash.data), core::time::Duration::from_secs(created_at)); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::invoice::InvoiceWithExplicitSigningPubkeyBuilder { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::offers::parse::Bolt12SemanticError::native_into(e) }).into() }; local_ret } -/// Verifies that the request was for an offer created using the given key. Returns the verified -/// request which contains the derived keys needed to sign a [`Bolt12Invoice`] for the request -/// if they could be extracted from the metadata. +/// Verifies that the request was for an offer created using the given key by checking the +/// metadata from the offer. +/// +/// Returns the verified request which contains the derived keys needed to sign a +/// [`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(mut this_arg: crate::lightning::offers::invoice_request::InvoiceRequest, key: &crate::lightning::ln::inbound_payment::ExpandedKey) -> crate::c_types::derived::CResult_VerifiedInvoiceRequestNoneZ { - let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).verify(key.get_native_ref(), secp256k1::global::SECP256K1); +pub extern "C" fn InvoiceRequest_verify_using_metadata(mut this_arg: crate::lightning::offers::invoice_request::InvoiceRequest, key: &crate::lightning::ln::inbound_payment::ExpandedKey) -> crate::c_types::derived::CResult_VerifiedInvoiceRequestNoneZ { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).verify_using_metadata(key.get_native_ref(), secp256k1::global::SECP256K1); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::invoice_request::VerifiedInvoiceRequest { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Verifies that the request was for an offer created using the given key by checking a nonce +/// included with the [`BlindedMessagePath`] for which the request was sent through. +/// +/// Returns the verified request which contains the derived keys needed to sign a +/// [`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_using_recipient_data(mut this_arg: crate::lightning::offers::invoice_request::InvoiceRequest, mut nonce: crate::lightning::offers::nonce::Nonce, key: &crate::lightning::ln::inbound_payment::ExpandedKey) -> crate::c_types::derived::CResult_VerifiedInvoiceRequestNoneZ { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).verify_using_recipient_data(*unsafe { Box::from_raw(nonce.take_inner()) }, key.get_native_ref(), secp256k1::global::SECP256K1); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::invoice_request::VerifiedInvoiceRequest { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; local_ret } @@ -1070,18 +1117,18 @@ pub extern "C" fn VerifiedInvoiceRequest_amount(this_arg: &crate::lightning::off /// 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 VerifiedInvoiceRequest_description(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::lightning::util::string::PrintableString { +pub extern "C" fn VerifiedInvoiceRequest_description(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::lightning_types::string::PrintableString { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.description(); - let mut local_ret = crate::lightning::util::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; + let mut local_ret = crate::lightning_types::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; local_ret } /// Features pertaining to the offer. #[must_use] #[no_mangle] -pub extern "C" fn VerifiedInvoiceRequest_offer_features(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::lightning::ln::features::OfferFeatures { +pub extern "C" fn VerifiedInvoiceRequest_offer_features(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::lightning_types::features::OfferFeatures { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.offer_features(); - crate::lightning::ln::features::OfferFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::OfferFeatures<>) as *mut _) }, is_owned: false } + crate::lightning_types::features::OfferFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning_types::features::OfferFeatures<>) as *mut _) }, is_owned: false } } /// Duration since the Unix epoch when an invoice should no longer be requested. @@ -1101,9 +1148,9 @@ pub extern "C" fn VerifiedInvoiceRequest_absolute_expiry(this_arg: &crate::light /// 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 VerifiedInvoiceRequest_issuer(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::lightning::util::string::PrintableString { +pub extern "C" fn VerifiedInvoiceRequest_issuer(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::lightning_types::string::PrintableString { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.issuer(); - let mut local_ret = crate::lightning::util::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; + let mut local_ret = crate::lightning_types::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; local_ret } @@ -1111,9 +1158,9 @@ pub extern "C" fn VerifiedInvoiceRequest_issuer(this_arg: &crate::lightning::off /// recipient privacy by obfuscating its node id. #[must_use] #[no_mangle] -pub extern "C" fn VerifiedInvoiceRequest_paths(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::c_types::derived::CVec_BlindedPathZ { +pub extern "C" fn VerifiedInvoiceRequest_paths(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::c_types::derived::CVec_BlindedMessagePathZ { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.paths(); - let mut local_ret_clone = Vec::new(); local_ret_clone.extend_from_slice(ret); let mut ret = local_ret_clone; let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::blinded_path::BlindedPath { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; + let mut local_ret_clone = Vec::new(); local_ret_clone.extend_from_slice(ret); let mut ret = local_ret_clone; let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::blinded_path::message::BlindedMessagePath { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; local_ret.into() } @@ -1171,9 +1218,9 @@ pub extern "C" fn VerifiedInvoiceRequest_amount_msats(this_arg: &crate::lightnin /// Features pertaining to requesting an invoice. #[must_use] #[no_mangle] -pub extern "C" fn VerifiedInvoiceRequest_invoice_request_features(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::lightning::ln::features::InvoiceRequestFeatures { +pub extern "C" fn VerifiedInvoiceRequest_invoice_request_features(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::lightning_types::features::InvoiceRequestFeatures { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.invoice_request_features(); - crate::lightning::ln::features::InvoiceRequestFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::InvoiceRequestFeatures<>) as *mut _) }, is_owned: false } + crate::lightning_types::features::InvoiceRequestFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning_types::features::InvoiceRequestFeatures<>) as *mut _) }, is_owned: false } } /// The quantity of the offer's item conforming to [`Offer::is_valid_quantity`]. @@ -1199,9 +1246,9 @@ pub extern "C" fn VerifiedInvoiceRequest_payer_id(this_arg: &crate::lightning::o /// 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 VerifiedInvoiceRequest_payer_note(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::lightning::util::string::PrintableString { +pub extern "C" fn VerifiedInvoiceRequest_payer_note(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::lightning_types::string::PrintableString { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_note(); - let mut local_ret = crate::lightning::util::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; + let mut local_ret = crate::lightning_types::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; local_ret } @@ -1214,8 +1261,8 @@ pub extern "C" fn VerifiedInvoiceRequest_payer_note(this_arg: &crate::lightning: /// [`Duration`]: core::time::Duration #[must_use] #[no_mangle] -pub extern "C" fn VerifiedInvoiceRequest_respond_with(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest, mut payment_paths: crate::c_types::derived::CVec_C2Tuple_BlindedPayInfoBlindedPathZZ, mut payment_hash: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ { - let mut local_payment_paths = Vec::new(); for mut item in payment_paths.into_rust().drain(..) { local_payment_paths.push( { let (mut orig_payment_paths_0_0, mut orig_payment_paths_0_1) = item.to_rust(); let mut local_payment_paths_0 = (*unsafe { Box::from_raw(orig_payment_paths_0_0.take_inner()) }, *unsafe { Box::from_raw(orig_payment_paths_0_1.take_inner()) }); local_payment_paths_0 }); }; +pub extern "C" fn VerifiedInvoiceRequest_respond_with(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest, mut payment_paths: crate::c_types::derived::CVec_BlindedPaymentPathZ, mut payment_hash: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ { + let mut local_payment_paths = Vec::new(); for mut item in payment_paths.into_rust().drain(..) { local_payment_paths.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.respond_with(local_payment_paths, ::lightning::ln::types::PaymentHash(payment_hash.data)); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::invoice::InvoiceWithExplicitSigningPubkeyBuilder { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::offers::parse::Bolt12SemanticError::native_into(e) }).into() }; local_ret @@ -1240,14 +1287,16 @@ pub extern "C" fn VerifiedInvoiceRequest_respond_with(this_arg: &crate::lightnin /// # Note /// /// If the originating [`Offer`] was created using [`OfferBuilder::deriving_signing_pubkey`], -/// then use [`InvoiceRequest::verify`] and [`VerifiedInvoiceRequest`] methods instead. +/// then first use [`InvoiceRequest::verify_using_metadata`] or +/// [`InvoiceRequest::verify_using_recipient_data`] and then [`VerifiedInvoiceRequest`] methods +/// instead. /// /// [`Bolt12Invoice::created_at`]: crate::offers::invoice::Bolt12Invoice::created_at /// [`OfferBuilder::deriving_signing_pubkey`]: crate::offers::offer::OfferBuilder::deriving_signing_pubkey #[must_use] #[no_mangle] -pub extern "C" fn VerifiedInvoiceRequest_respond_with_no_std(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest, mut payment_paths: crate::c_types::derived::CVec_C2Tuple_BlindedPayInfoBlindedPathZZ, mut payment_hash: crate::c_types::ThirtyTwoBytes, mut created_at: u64) -> crate::c_types::derived::CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ { - let mut local_payment_paths = Vec::new(); for mut item in payment_paths.into_rust().drain(..) { local_payment_paths.push( { let (mut orig_payment_paths_0_0, mut orig_payment_paths_0_1) = item.to_rust(); let mut local_payment_paths_0 = (*unsafe { Box::from_raw(orig_payment_paths_0_0.take_inner()) }, *unsafe { Box::from_raw(orig_payment_paths_0_1.take_inner()) }); local_payment_paths_0 }); }; +pub extern "C" fn VerifiedInvoiceRequest_respond_with_no_std(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest, mut payment_paths: crate::c_types::derived::CVec_BlindedPaymentPathZ, mut payment_hash: crate::c_types::ThirtyTwoBytes, mut created_at: u64) -> crate::c_types::derived::CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ { + let mut local_payment_paths = Vec::new(); for mut item in payment_paths.into_rust().drain(..) { local_payment_paths.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.respond_with_no_std(local_payment_paths, ::lightning::ln::types::PaymentHash(payment_hash.data), core::time::Duration::from_secs(created_at)); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::invoice::InvoiceWithExplicitSigningPubkeyBuilder { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::offers::parse::Bolt12SemanticError::native_into(e) }).into() }; local_ret @@ -1262,8 +1311,8 @@ pub extern "C" fn VerifiedInvoiceRequest_respond_with_no_std(this_arg: &crate::l /// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice #[must_use] #[no_mangle] -pub extern "C" fn VerifiedInvoiceRequest_respond_using_derived_keys(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest, mut payment_paths: crate::c_types::derived::CVec_C2Tuple_BlindedPayInfoBlindedPathZZ, mut payment_hash: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ { - let mut local_payment_paths = Vec::new(); for mut item in payment_paths.into_rust().drain(..) { local_payment_paths.push( { let (mut orig_payment_paths_0_0, mut orig_payment_paths_0_1) = item.to_rust(); let mut local_payment_paths_0 = (*unsafe { Box::from_raw(orig_payment_paths_0_0.take_inner()) }, *unsafe { Box::from_raw(orig_payment_paths_0_1.take_inner()) }); local_payment_paths_0 }); }; +pub extern "C" fn VerifiedInvoiceRequest_respond_using_derived_keys(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest, mut payment_paths: crate::c_types::derived::CVec_BlindedPaymentPathZ, mut payment_hash: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ { + let mut local_payment_paths = Vec::new(); for mut item in payment_paths.into_rust().drain(..) { local_payment_paths.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.respond_using_derived_keys(local_payment_paths, ::lightning::ln::types::PaymentHash(payment_hash.data)); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::invoice::InvoiceWithDerivedSigningPubkeyBuilder { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::offers::parse::Bolt12SemanticError::native_into(e) }).into() }; local_ret @@ -1278,8 +1327,8 @@ pub extern "C" fn VerifiedInvoiceRequest_respond_using_derived_keys(this_arg: &c /// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice #[must_use] #[no_mangle] -pub extern "C" fn VerifiedInvoiceRequest_respond_using_derived_keys_no_std(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest, mut payment_paths: crate::c_types::derived::CVec_C2Tuple_BlindedPayInfoBlindedPathZZ, mut payment_hash: crate::c_types::ThirtyTwoBytes, mut created_at: u64) -> crate::c_types::derived::CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ { - let mut local_payment_paths = Vec::new(); for mut item in payment_paths.into_rust().drain(..) { local_payment_paths.push( { let (mut orig_payment_paths_0_0, mut orig_payment_paths_0_1) = item.to_rust(); let mut local_payment_paths_0 = (*unsafe { Box::from_raw(orig_payment_paths_0_0.take_inner()) }, *unsafe { Box::from_raw(orig_payment_paths_0_1.take_inner()) }); local_payment_paths_0 }); }; +pub extern "C" fn VerifiedInvoiceRequest_respond_using_derived_keys_no_std(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest, mut payment_paths: crate::c_types::derived::CVec_BlindedPaymentPathZ, mut payment_hash: crate::c_types::ThirtyTwoBytes, mut created_at: u64) -> crate::c_types::derived::CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ { + let mut local_payment_paths = Vec::new(); for mut item in payment_paths.into_rust().drain(..) { local_payment_paths.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.respond_using_derived_keys_no_std(local_payment_paths, ::lightning::ln::types::PaymentHash(payment_hash.data), core::time::Duration::from_secs(created_at)); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::invoice::InvoiceWithDerivedSigningPubkeyBuilder { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::offers::parse::Bolt12SemanticError::native_into(e) }).into() }; local_ret @@ -1292,7 +1341,7 @@ pub extern "C" fn UnsignedInvoiceRequest_write(obj: &crate::lightning::offers::i } #[allow(unused)] pub(crate) extern "C" fn UnsignedInvoiceRequest_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedInvoiceRequest) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::offers::invoice_request::nativeUnsignedInvoiceRequest) }) } #[no_mangle] /// Serialize the InvoiceRequest object into a byte array which can be read by InvoiceRequest_read @@ -1301,7 +1350,7 @@ pub extern "C" fn InvoiceRequest_write(obj: &crate::lightning::offers::invoice_r } #[allow(unused)] pub(crate) extern "C" fn InvoiceRequest_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInvoiceRequest) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::offers::invoice_request::nativeInvoiceRequest) }) } use lightning::offers::invoice_request::InvoiceRequestFields as nativeInvoiceRequestFieldsImport; @@ -1325,6 +1374,12 @@ pub struct InvoiceRequestFields { pub is_owned: bool, } +impl core::ops::Deref for InvoiceRequestFields { + type Target = nativeInvoiceRequestFields; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for InvoiceRequestFields { } +unsafe impl core::marker::Sync for InvoiceRequestFields { } impl Drop for InvoiceRequestFields { fn drop(&mut self) { if self.is_owned && !<*mut nativeInvoiceRequestFields>::is_null(self.inner) { @@ -1355,6 +1410,9 @@ impl InvoiceRequestFields { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// A possibly transient pubkey used to sign the invoice request. #[no_mangle] @@ -1385,9 +1443,9 @@ pub extern "C" fn InvoiceRequestFields_set_quantity(this_ptr: &mut InvoiceReques /// /// 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 InvoiceRequestFields_get_payer_note_truncated(this_ptr: &InvoiceRequestFields) -> crate::lightning::util::string::UntrustedString { +pub extern "C" fn InvoiceRequestFields_get_payer_note_truncated(this_ptr: &InvoiceRequestFields) -> crate::lightning_types::string::UntrustedString { let mut inner_val = &mut this_ptr.get_native_mut_ref().payer_note_truncated; - let mut local_inner_val = crate::lightning::util::string::UntrustedString { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::util::string::UntrustedString<>) as *mut _ }, is_owned: false }; + let mut local_inner_val = crate::lightning_types::string::UntrustedString { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning_types::string::UntrustedString<>) as *mut _ }, is_owned: false }; local_inner_val } /// A payer-provided note which will be seen by the recipient and reflected back in the invoice @@ -1395,7 +1453,7 @@ pub extern "C" fn InvoiceRequestFields_get_payer_note_truncated(this_ptr: &Invoi /// /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None #[no_mangle] -pub extern "C" fn InvoiceRequestFields_set_payer_note_truncated(this_ptr: &mut InvoiceRequestFields, mut val: crate::lightning::util::string::UntrustedString) { +pub extern "C" fn InvoiceRequestFields_set_payer_note_truncated(this_ptr: &mut InvoiceRequestFields, mut val: crate::lightning_types::string::UntrustedString) { 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) }.payer_note_truncated = local_val; } @@ -1404,7 +1462,7 @@ pub extern "C" fn InvoiceRequestFields_set_payer_note_truncated(this_ptr: &mut I /// Note that payer_note_truncated_arg (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn InvoiceRequestFields_new(mut payer_id_arg: crate::c_types::PublicKey, mut quantity_arg: crate::c_types::derived::COption_u64Z, mut payer_note_truncated_arg: crate::lightning::util::string::UntrustedString) -> InvoiceRequestFields { +pub extern "C" fn InvoiceRequestFields_new(mut payer_id_arg: crate::c_types::PublicKey, mut quantity_arg: crate::c_types::derived::COption_u64Z, mut payer_note_truncated_arg: crate::lightning_types::string::UntrustedString) -> InvoiceRequestFields { let mut local_quantity_arg = if quantity_arg.is_some() { Some( { quantity_arg.take() }) } else { None }; let mut local_payer_note_truncated_arg = if payer_note_truncated_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(payer_note_truncated_arg.take_inner()) } }) }; InvoiceRequestFields { inner: ObjOps::heap_alloc(nativeInvoiceRequestFields { @@ -1455,7 +1513,7 @@ pub extern "C" fn InvoiceRequestFields_write(obj: &crate::lightning::offers::inv } #[allow(unused)] pub(crate) extern "C" fn InvoiceRequestFields_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInvoiceRequestFields) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::offers::invoice_request::nativeInvoiceRequestFields) }) } #[no_mangle] /// Read a InvoiceRequestFields from a byte array, created by InvoiceRequestFields_write diff --git a/lightning-c-bindings/src/lightning/offers/merkle.rs b/lightning-c-bindings/src/lightning/offers/merkle.rs index b0ea39d..72c8014 100644 --- a/lightning-c-bindings/src/lightning/offers/merkle.rs +++ b/lightning-c-bindings/src/lightning/offers/merkle.rs @@ -41,6 +41,12 @@ pub struct TaggedHash { pub is_owned: bool, } +impl core::ops::Deref for TaggedHash { + type Target = nativeTaggedHash; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for TaggedHash { } +unsafe impl core::marker::Sync for TaggedHash { } impl Drop for TaggedHash { fn drop(&mut self) { if self.is_owned && !<*mut nativeTaggedHash>::is_null(self.inner) { @@ -71,6 +77,9 @@ impl TaggedHash { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } impl Clone for TaggedHash { fn clone(&self) -> Self { diff --git a/lightning-c-bindings/src/lightning/offers/mod.rs b/lightning-c-bindings/src/lightning/offers/mod.rs index 68d2175..9d8e1f2 100644 --- a/lightning-c-bindings/src/lightning/offers/mod.rs +++ b/lightning-c-bindings/src/lightning/offers/mod.rs @@ -25,8 +25,21 @@ pub mod invoice; pub mod invoice_error; pub mod invoice_request; pub mod merkle; +pub mod nonce; pub mod parse; pub mod refund; +mod invoice_macros { + +use alloc::str::FromStr; +use alloc::string::String; +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}; + +} mod payer { use alloc::str::FromStr; diff --git a/lightning-c-bindings/src/lightning/offers/nonce.rs b/lightning-c-bindings/src/lightning/offers/nonce.rs new file mode 100644 index 0000000..aad51df --- /dev/null +++ b/lightning-c-bindings/src/lightning/offers/nonce.rs @@ -0,0 +1,150 @@ +// 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. + +//! A number used only once. + +use alloc::str::FromStr; +use alloc::string::String; +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::nonce::Nonce as nativeNonceImport; +pub(crate) type nativeNonce = nativeNonceImport; + +/// A 128-bit number used only once. +/// +/// Needed when constructing [`Offer::metadata`] and deriving [`Offer::signing_pubkey`] from +/// [`ExpandedKey`]. Must not be reused for any other derivation without first hashing. +/// +/// [`Offer::metadata`]: crate::offers::offer::Offer::metadata +/// [`Offer::signing_pubkey`]: crate::offers::offer::Offer::signing_pubkey +/// [`ExpandedKey`]: crate::ln::inbound_payment::ExpandedKey +#[must_use] +#[repr(C)] +pub struct Nonce { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, 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 nativeNonce, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust 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 core::ops::Deref for Nonce { + type Target = nativeNonce; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for Nonce { } +unsafe impl core::marker::Sync for Nonce { } +impl Drop for Nonce { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeNonce>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the Nonce, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn Nonce_free(this_obj: Nonce) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn Nonce_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeNonce) }; +} +#[allow(unused)] +impl Nonce { + pub(crate) fn get_native_ref(&self) -> &'static nativeNonce { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeNonce { + 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 nativeNonce { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +impl Clone for Nonce { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeNonce>::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 Nonce_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeNonce)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the Nonce +pub extern "C" fn Nonce_clone(orig: &Nonce) -> Nonce { + orig.clone() +} +/// Get a string which allows debug introspection of a Nonce object +pub extern "C" fn Nonce_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::offers::nonce::Nonce }).into()} +/// Checks if two Nonces 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 Nonce_eq(a: &Nonce, b: &Nonce) -> 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 } +} +/// Creates a `Nonce` from the given [`EntropySource`]. +#[must_use] +#[no_mangle] +pub extern "C" fn Nonce_from_entropy_source(mut entropy_source: crate::lightning::sign::EntropySource) -> crate::lightning::offers::nonce::Nonce { + let mut ret = lightning::offers::nonce::Nonce::from_entropy_source(entropy_source); + crate::lightning::offers::nonce::Nonce { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Returns a slice of the underlying bytes of size [`Nonce::LENGTH`]. +#[must_use] +#[no_mangle] +pub extern "C" fn Nonce_as_slice(this_arg: &crate::lightning::offers::nonce::Nonce) -> crate::c_types::u8slice { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.as_slice(); + let mut local_ret = crate::c_types::u8slice::from_slice(ret); + local_ret +} + +#[no_mangle] +/// Serialize the Nonce object into a byte array which can be read by Nonce_read +pub extern "C" fn Nonce_write(obj: &crate::lightning::offers::nonce::Nonce) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[allow(unused)] +pub(crate) extern "C" fn Nonce_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::offers::nonce::nativeNonce) }) +} +#[no_mangle] +/// Read a Nonce from a byte array, created by Nonce_write +pub extern "C" fn Nonce_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NonceDecodeErrorZ { + 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::nonce::Nonce { 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/offer.rs b/lightning-c-bindings/src/lightning/offers/offer.rs index 3fd90e2..a8520bd 100644 --- a/lightning-c-bindings/src/lightning/offers/offer.rs +++ b/lightning-c-bindings/src/lightning/offers/offer.rs @@ -23,22 +23,22 @@ //! use core::num::NonZeroU64; //! use core::time::Duration; //! -//! use bitcoin::secp256k1::{KeyPair, PublicKey, Secp256k1, SecretKey}; +//! use bitcoin::secp256k1::{Keypair, PublicKey, Secp256k1, SecretKey}; //! use lightning::offers::offer::{Offer, OfferBuilder, Quantity}; //! use lightning::offers::parse::Bolt12ParseError; //! use lightning::util::ser::{Readable, Writeable}; //! -//! # use lightning::blinded_path::BlindedPath; +//! # use lightning::blinded_path::message::BlindedMessagePath; //! # #[cfg(feature = \"std\")] //! # use std::time::SystemTime; //! # -//! # fn create_blinded_path() -> BlindedPath { unimplemented!() } -//! # fn create_another_blinded_path() -> BlindedPath { unimplemented!() } +//! # fn create_blinded_path() -> BlindedMessagePath { unimplemented!() } +//! # fn create_another_blinded_path() -> BlindedMessagePath { unimplemented!() } //! # //! # #[cfg(feature = \"std\")] //! # fn build() -> Result<(), Bolt12ParseError> { //! let secp_ctx = Secp256k1::new(); -//! let keys = KeyPair::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32]).unwrap()); +//! let keys = Keypair::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32]).unwrap()); //! let pubkey = PublicKey::from(keys); //! //! let expiration = SystemTime::now() + Duration::from_secs(24 * 60 * 60); @@ -105,6 +105,12 @@ pub struct OfferId { pub is_owned: bool, } +impl core::ops::Deref for OfferId { + type Target = nativeOfferId; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for OfferId { } +unsafe impl core::marker::Sync for OfferId { } impl Drop for OfferId { fn drop(&mut self) { if self.is_owned && !<*mut nativeOfferId>::is_null(self.inner) { @@ -135,6 +141,9 @@ impl OfferId { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } #[no_mangle] pub extern "C" fn OfferId_get_a(this_ptr: &OfferId) -> *const [u8; 32] { @@ -191,7 +200,7 @@ pub extern "C" fn OfferId_write(obj: &crate::lightning::offers::offer::OfferId) } #[allow(unused)] pub(crate) extern "C" fn OfferId_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOfferId) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::offers::offer::nativeOfferId) }) } #[no_mangle] /// Read a OfferId from a byte array, created by OfferId_write @@ -224,6 +233,12 @@ pub struct OfferWithExplicitMetadataBuilder { pub is_owned: bool, } +impl core::ops::Deref for OfferWithExplicitMetadataBuilder { + type Target = nativeOfferWithExplicitMetadataBuilder; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for OfferWithExplicitMetadataBuilder { } +unsafe impl core::marker::Sync for OfferWithExplicitMetadataBuilder { } impl Drop for OfferWithExplicitMetadataBuilder { fn drop(&mut self) { if self.is_owned && !<*mut nativeOfferWithExplicitMetadataBuilder>::is_null(self.inner) { @@ -254,6 +269,9 @@ impl OfferWithExplicitMetadataBuilder { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } impl Clone for OfferWithExplicitMetadataBuilder { fn clone(&self) -> Self { @@ -298,6 +316,12 @@ pub struct OfferWithDerivedMetadataBuilder { pub is_owned: bool, } +impl core::ops::Deref for OfferWithDerivedMetadataBuilder { + type Target = nativeOfferWithDerivedMetadataBuilder; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for OfferWithDerivedMetadataBuilder { } +unsafe impl core::marker::Sync for OfferWithDerivedMetadataBuilder { } impl Drop for OfferWithDerivedMetadataBuilder { fn drop(&mut self) { if self.is_owned && !<*mut nativeOfferWithDerivedMetadataBuilder>::is_null(self.inner) { @@ -328,6 +352,9 @@ impl OfferWithDerivedMetadataBuilder { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } impl Clone for OfferWithDerivedMetadataBuilder { fn clone(&self) -> Self { @@ -440,7 +467,7 @@ pub extern "C" fn OfferWithExplicitMetadataBuilder_issuer(mut this_arg: crate::l /// adding duplicate paths. #[must_use] #[no_mangle] -pub extern "C" fn OfferWithExplicitMetadataBuilder_path(mut this_arg: crate::lightning::offers::offer::OfferWithExplicitMetadataBuilder, mut path: crate::lightning::blinded_path::BlindedPath) { +pub extern "C" fn OfferWithExplicitMetadataBuilder_path(mut this_arg: crate::lightning::offers::offer::OfferWithExplicitMetadataBuilder, mut path: crate::lightning::blinded_path::message::BlindedMessagePath) { let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).path(*unsafe { Box::from_raw(path.take_inner()) }); () /*ret*/ } @@ -466,20 +493,23 @@ pub extern "C" fn OfferWithExplicitMetadataBuilder_build(mut this_arg: crate::li } /// Similar to [`OfferBuilder::new`] except, if [`OfferBuilder::path`] is called, the signing -/// pubkey is derived from the given [`ExpandedKey`] and [`EntropySource`]. This provides -/// recipient privacy by using a different signing pubkey for each offer. Otherwise, the -/// provided `node_id` is used for the signing pubkey. +/// pubkey is derived from the given [`ExpandedKey`] and [`Nonce`]. This provides recipient +/// privacy by using a different signing pubkey for each offer. Otherwise, the provided +/// `node_id` is used for the signing pubkey. /// /// Also, sets the metadata when [`OfferBuilder::build`] is called such that it can be used by -/// [`InvoiceRequest::verify`] to determine if the request was produced for the offer given an -/// [`ExpandedKey`]. +/// [`InvoiceRequest::verify_using_metadata`] to determine if the request was produced for the +/// offer given an [`ExpandedKey`]. However, if [`OfferBuilder::path`] is called, then the +/// metadata will not be set and must be included in each [`BlindedMessagePath`] instead. In this case, +/// use [`InvoiceRequest::verify_using_recipient_data`]. /// -/// [`InvoiceRequest::verify`]: crate::offers::invoice_request::InvoiceRequest::verify +/// [`InvoiceRequest::verify_using_metadata`]: crate::offers::invoice_request::InvoiceRequest::verify_using_metadata +/// [`InvoiceRequest::verify_using_recipient_data`]: crate::offers::invoice_request::InvoiceRequest::verify_using_recipient_data /// [`ExpandedKey`]: crate::ln::inbound_payment::ExpandedKey #[must_use] #[no_mangle] -pub extern "C" fn OfferWithDerivedMetadataBuilder_deriving_signing_pubkey(mut node_id: crate::c_types::PublicKey, expanded_key: &crate::lightning::ln::inbound_payment::ExpandedKey, mut entropy_source: crate::lightning::sign::EntropySource) -> crate::lightning::offers::offer::OfferWithDerivedMetadataBuilder { - let mut ret = lightning::offers::offer::OfferWithDerivedMetadataBuilder::deriving_signing_pubkey(node_id.into_rust(), expanded_key.get_native_ref(), entropy_source, secp256k1::global::SECP256K1); +pub extern "C" fn OfferWithDerivedMetadataBuilder_deriving_signing_pubkey(mut node_id: crate::c_types::PublicKey, expanded_key: &crate::lightning::ln::inbound_payment::ExpandedKey, mut nonce: crate::lightning::offers::nonce::Nonce) -> crate::lightning::offers::offer::OfferWithDerivedMetadataBuilder { + let mut ret = lightning::offers::offer::OfferWithDerivedMetadataBuilder::deriving_signing_pubkey(node_id.into_rust(), expanded_key.get_native_ref(), *unsafe { Box::from_raw(nonce.take_inner()) }, secp256k1::global::SECP256K1); crate::lightning::offers::offer::OfferWithDerivedMetadataBuilder { inner: ObjOps::heap_alloc(ret), is_owned: true } } @@ -544,7 +574,7 @@ pub extern "C" fn OfferWithDerivedMetadataBuilder_issuer(mut this_arg: crate::li /// adding duplicate paths. #[must_use] #[no_mangle] -pub extern "C" fn OfferWithDerivedMetadataBuilder_path(mut this_arg: crate::lightning::offers::offer::OfferWithDerivedMetadataBuilder, mut path: crate::lightning::blinded_path::BlindedPath) { +pub extern "C" fn OfferWithDerivedMetadataBuilder_path(mut this_arg: crate::lightning::offers::offer::OfferWithDerivedMetadataBuilder, mut path: crate::lightning::blinded_path::message::BlindedMessagePath) { let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).path(*unsafe { Box::from_raw(path.take_inner()) }); () /*ret*/ } @@ -582,7 +612,7 @@ pub(crate) type nativeOffer = nativeOfferImport; /// 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. +/// Through the use of [`BlindedMessagePath`]s, offers provide recipient privacy. /// /// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest /// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice @@ -601,6 +631,12 @@ pub struct Offer { pub is_owned: bool, } +impl core::ops::Deref for Offer { + type Target = nativeOffer; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for Offer { } +unsafe impl core::marker::Sync for Offer { } impl Drop for Offer { fn drop(&mut self) { if self.is_owned && !<*mut nativeOffer>::is_null(self.inner) { @@ -631,6 +667,9 @@ impl Offer { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } impl Clone for Offer { fn clone(&self) -> Self { @@ -690,18 +729,18 @@ pub extern "C" fn Offer_amount(this_arg: &crate::lightning::offers::offer::Offer /// 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 Offer_description(this_arg: &crate::lightning::offers::offer::Offer) -> crate::lightning::util::string::PrintableString { +pub extern "C" fn Offer_description(this_arg: &crate::lightning::offers::offer::Offer) -> crate::lightning_types::string::PrintableString { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.description(); - let mut local_ret = crate::lightning::util::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; + let mut local_ret = crate::lightning_types::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; local_ret } /// Features pertaining to the offer. #[must_use] #[no_mangle] -pub extern "C" fn Offer_offer_features(this_arg: &crate::lightning::offers::offer::Offer) -> crate::lightning::ln::features::OfferFeatures { +pub extern "C" fn Offer_offer_features(this_arg: &crate::lightning::offers::offer::Offer) -> crate::lightning_types::features::OfferFeatures { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.offer_features(); - crate::lightning::ln::features::OfferFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::OfferFeatures<>) as *mut _) }, is_owned: false } + crate::lightning_types::features::OfferFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning_types::features::OfferFeatures<>) as *mut _) }, is_owned: false } } /// Duration since the Unix epoch when an invoice should no longer be requested. @@ -721,9 +760,9 @@ pub extern "C" fn Offer_absolute_expiry(this_arg: &crate::lightning::offers::off /// 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 Offer_issuer(this_arg: &crate::lightning::offers::offer::Offer) -> crate::lightning::util::string::PrintableString { +pub extern "C" fn Offer_issuer(this_arg: &crate::lightning::offers::offer::Offer) -> crate::lightning_types::string::PrintableString { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.issuer(); - let mut local_ret = crate::lightning::util::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; + let mut local_ret = crate::lightning_types::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; local_ret } @@ -731,9 +770,9 @@ pub extern "C" fn Offer_issuer(this_arg: &crate::lightning::offers::offer::Offer /// recipient privacy by obfuscating its node id. #[must_use] #[no_mangle] -pub extern "C" fn Offer_paths(this_arg: &crate::lightning::offers::offer::Offer) -> crate::c_types::derived::CVec_BlindedPathZ { +pub extern "C" fn Offer_paths(this_arg: &crate::lightning::offers::offer::Offer) -> crate::c_types::derived::CVec_BlindedMessagePathZ { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.paths(); - let mut local_ret_clone = Vec::new(); local_ret_clone.extend_from_slice(ret); let mut ret = local_ret_clone; let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::blinded_path::BlindedPath { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; + let mut local_ret_clone = Vec::new(); local_ret_clone.extend_from_slice(ret); let mut ret = local_ret_clone; let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::blinded_path::message::BlindedMessagePath { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; local_ret.into() } @@ -768,7 +807,7 @@ pub extern "C" fn Offer_id(this_arg: &crate::lightning::offers::offer::Offer) -> #[must_use] #[no_mangle] pub extern "C" fn Offer_supports_chain(this_arg: &crate::lightning::offers::offer::Offer, mut chain: crate::c_types::ThirtyTwoBytes) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_chain(::bitcoin::blockdata::constants::ChainHash::from(&chain.data)); + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_chain(::bitcoin::constants::ChainHash::from(&chain.data)); ret } @@ -810,8 +849,9 @@ pub extern "C" fn Offer_expects_quantity(this_arg: &crate::lightning::offers::of /// - derives the [`InvoiceRequest::payer_id`] such that a different key can be used for each /// request, /// - sets [`InvoiceRequest::payer_metadata`] when [`InvoiceRequestBuilder::build`] is called -/// such that it can be used by [`Bolt12Invoice::verify`] to determine if the invoice was -/// requested using a base [`ExpandedKey`] from which the payer id was derived, and +/// such that it can be used by [`Bolt12Invoice::verify_using_metadata`] to determine if the +/// invoice was requested using a base [`ExpandedKey`] from which the payer id was derived, +/// and /// - includes the [`PaymentId`] encrypted in [`InvoiceRequest::payer_metadata`] so that it can /// be used when sending the payment for the requested invoice. /// @@ -819,12 +859,12 @@ pub extern "C" fn Offer_expects_quantity(this_arg: &crate::lightning::offers::of /// /// [`InvoiceRequest::payer_id`]: crate::offers::invoice_request::InvoiceRequest::payer_id /// [`InvoiceRequest::payer_metadata`]: crate::offers::invoice_request::InvoiceRequest::payer_metadata -/// [`Bolt12Invoice::verify`]: crate::offers::invoice::Bolt12Invoice::verify +/// [`Bolt12Invoice::verify_using_metadata`]: crate::offers::invoice::Bolt12Invoice::verify_using_metadata /// [`ExpandedKey`]: crate::ln::inbound_payment::ExpandedKey #[must_use] #[no_mangle] -pub extern "C" fn Offer_request_invoice_deriving_payer_id(this_arg: &crate::lightning::offers::offer::Offer, expanded_key: &crate::lightning::ln::inbound_payment::ExpandedKey, mut entropy_source: crate::lightning::sign::EntropySource, mut payment_id: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.request_invoice_deriving_payer_id(expanded_key.get_native_ref(), entropy_source, secp256k1::global::SECP256K1, ::lightning::ln::channelmanager::PaymentId(payment_id.data)); +pub extern "C" fn Offer_request_invoice_deriving_payer_id(this_arg: &crate::lightning::offers::offer::Offer, expanded_key: &crate::lightning::ln::inbound_payment::ExpandedKey, mut nonce: crate::lightning::offers::nonce::Nonce, mut payment_id: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.request_invoice_deriving_payer_id(expanded_key.get_native_ref(), *unsafe { Box::from_raw(nonce.take_inner()) }, secp256k1::global::SECP256K1, ::lightning::ln::channelmanager::PaymentId(payment_id.data)); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::invoice_request::InvoiceRequestWithDerivedPayerIdBuilder { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::offers::parse::Bolt12SemanticError::native_into(e) }).into() }; local_ret } @@ -837,8 +877,8 @@ pub extern "C" fn Offer_request_invoice_deriving_payer_id(this_arg: &crate::ligh /// [`InvoiceRequest::payer_id`]: crate::offers::invoice_request::InvoiceRequest::payer_id #[must_use] #[no_mangle] -pub extern "C" fn Offer_request_invoice_deriving_metadata(this_arg: &crate::lightning::offers::offer::Offer, mut payer_id: crate::c_types::PublicKey, expanded_key: &crate::lightning::ln::inbound_payment::ExpandedKey, mut entropy_source: crate::lightning::sign::EntropySource, mut payment_id: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.request_invoice_deriving_metadata(payer_id.into_rust(), expanded_key.get_native_ref(), entropy_source, ::lightning::ln::channelmanager::PaymentId(payment_id.data)); +pub extern "C" fn Offer_request_invoice_deriving_metadata(this_arg: &crate::lightning::offers::offer::Offer, mut payer_id: crate::c_types::PublicKey, expanded_key: &crate::lightning::ln::inbound_payment::ExpandedKey, mut nonce: crate::lightning::offers::nonce::Nonce, mut payment_id: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.request_invoice_deriving_metadata(payer_id.into_rust(), expanded_key.get_native_ref(), *unsafe { Box::from_raw(nonce.take_inner()) }, ::lightning::ln::channelmanager::PaymentId(payment_id.data)); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::invoice_request::InvoiceRequestWithExplicitPayerIdBuilder { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::offers::parse::Bolt12SemanticError::native_into(e) }).into() }; local_ret } @@ -876,13 +916,20 @@ pub extern "C" fn Offer_hash(o: &Offer) -> u64 { core::hash::Hasher::finish(&hasher) } #[no_mangle] +/// Read a Offer from a byte array, created by Offer_write +pub extern "C" fn Offer_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OfferDecodeErrorZ { + 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::offer::Offer { 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 Offer object into a byte array which can be read by Offer_read pub extern "C" fn Offer_write(obj: &crate::lightning::offers::offer::Offer) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) } #[allow(unused)] pub(crate) extern "C" fn Offer_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOffer) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::offers::offer::nativeOffer) }) } /// The minimum amount required for an item in an [`Offer`], denominated in either bitcoin or /// another currency. diff --git a/lightning-c-bindings/src/lightning/offers/parse.rs b/lightning-c-bindings/src/lightning/offers/parse.rs index 34920bc..f7b438c 100644 --- a/lightning-c-bindings/src/lightning/offers/parse.rs +++ b/lightning-c-bindings/src/lightning/offers/parse.rs @@ -49,6 +49,12 @@ pub struct Bolt12ParseError { pub is_owned: bool, } +impl core::ops::Deref for Bolt12ParseError { + type Target = nativeBolt12ParseError; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for Bolt12ParseError { } +unsafe impl core::marker::Sync for Bolt12ParseError { } impl Drop for Bolt12ParseError { fn drop(&mut self) { if self.is_owned && !<*mut nativeBolt12ParseError>::is_null(self.inner) { @@ -79,6 +85,9 @@ impl Bolt12ParseError { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } impl Clone for Bolt12ParseError { fn clone(&self) -> Self { @@ -161,6 +170,8 @@ pub enum Bolt12SemanticError { MissingCreationTime, /// An invoice payment hash was expected but was missing. MissingPaymentHash, + /// An invoice payment hash was provided but was not expected. + UnexpectedPaymentHash, /// A signature was expected but was missing. MissingSignature, } @@ -198,6 +209,7 @@ impl Bolt12SemanticError { Bolt12SemanticError::InvalidPayInfo => nativeBolt12SemanticError::InvalidPayInfo, Bolt12SemanticError::MissingCreationTime => nativeBolt12SemanticError::MissingCreationTime, Bolt12SemanticError::MissingPaymentHash => nativeBolt12SemanticError::MissingPaymentHash, + Bolt12SemanticError::UnexpectedPaymentHash => nativeBolt12SemanticError::UnexpectedPaymentHash, Bolt12SemanticError::MissingSignature => nativeBolt12SemanticError::MissingSignature, } } @@ -231,6 +243,7 @@ impl Bolt12SemanticError { Bolt12SemanticError::InvalidPayInfo => nativeBolt12SemanticError::InvalidPayInfo, Bolt12SemanticError::MissingCreationTime => nativeBolt12SemanticError::MissingCreationTime, Bolt12SemanticError::MissingPaymentHash => nativeBolt12SemanticError::MissingPaymentHash, + Bolt12SemanticError::UnexpectedPaymentHash => nativeBolt12SemanticError::UnexpectedPaymentHash, Bolt12SemanticError::MissingSignature => nativeBolt12SemanticError::MissingSignature, } } @@ -265,6 +278,7 @@ impl Bolt12SemanticError { nativeBolt12SemanticError::InvalidPayInfo => Bolt12SemanticError::InvalidPayInfo, nativeBolt12SemanticError::MissingCreationTime => Bolt12SemanticError::MissingCreationTime, nativeBolt12SemanticError::MissingPaymentHash => Bolt12SemanticError::MissingPaymentHash, + nativeBolt12SemanticError::UnexpectedPaymentHash => Bolt12SemanticError::UnexpectedPaymentHash, nativeBolt12SemanticError::MissingSignature => Bolt12SemanticError::MissingSignature, } } @@ -298,6 +312,7 @@ impl Bolt12SemanticError { nativeBolt12SemanticError::InvalidPayInfo => Bolt12SemanticError::InvalidPayInfo, nativeBolt12SemanticError::MissingCreationTime => Bolt12SemanticError::MissingCreationTime, nativeBolt12SemanticError::MissingPaymentHash => Bolt12SemanticError::MissingPaymentHash, + nativeBolt12SemanticError::UnexpectedPaymentHash => Bolt12SemanticError::UnexpectedPaymentHash, nativeBolt12SemanticError::MissingSignature => Bolt12SemanticError::MissingSignature, } } @@ -426,6 +441,10 @@ pub extern "C" fn Bolt12SemanticError_missing_creation_time() -> Bolt12SemanticE pub extern "C" fn Bolt12SemanticError_missing_payment_hash() -> Bolt12SemanticError { Bolt12SemanticError::MissingPaymentHash} #[no_mangle] +/// Utility method to constructs a new UnexpectedPaymentHash-variant Bolt12SemanticError +pub extern "C" fn Bolt12SemanticError_unexpected_payment_hash() -> Bolt12SemanticError { + Bolt12SemanticError::UnexpectedPaymentHash} +#[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 6d7d390..011aa19 100644 --- a/lightning-c-bindings/src/lightning/offers/refund.rs +++ b/lightning-c-bindings/src/lightning/offers/refund.rs @@ -27,23 +27,23 @@ //! use core::convert::TryFrom; //! use core::time::Duration; //! -//! use bitcoin::network::constants::Network; -//! use bitcoin::secp256k1::{KeyPair, PublicKey, Secp256k1, SecretKey}; +//! use bitcoin::network::Network; +//! use bitcoin::secp256k1::{Keypair, PublicKey, Secp256k1, SecretKey}; //! use lightning::offers::parse::Bolt12ParseError; //! use lightning::offers::refund::{Refund, RefundBuilder}; //! use lightning::util::ser::{Readable, Writeable}; //! -//! # use lightning::blinded_path::BlindedPath; +//! # use lightning::blinded_path::message::BlindedMessagePath; //! # #[cfg(feature = \"std\")] //! # use std::time::SystemTime; //! # -//! # fn create_blinded_path() -> BlindedPath { unimplemented!() } -//! # fn create_another_blinded_path() -> BlindedPath { unimplemented!() } +//! # fn create_blinded_path() -> BlindedMessagePath { unimplemented!() } +//! # fn create_another_blinded_path() -> BlindedMessagePath { unimplemented!() } //! # //! # #[cfg(feature = \"std\")] //! # fn build() -> Result<(), Bolt12ParseError> { //! let secp_ctx = Secp256k1::new(); -//! let keys = KeyPair::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32]).unwrap()); +//! let keys = Keypair::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32]).unwrap()); //! let pubkey = PublicKey::from(keys); //! //! let expiration = SystemTime::now() + Duration::from_secs(24 * 60 * 60); @@ -114,6 +114,12 @@ pub struct RefundMaybeWithDerivedMetadataBuilder { pub is_owned: bool, } +impl core::ops::Deref for RefundMaybeWithDerivedMetadataBuilder { + type Target = nativeRefundMaybeWithDerivedMetadataBuilder; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for RefundMaybeWithDerivedMetadataBuilder { } +unsafe impl core::marker::Sync for RefundMaybeWithDerivedMetadataBuilder { } impl Drop for RefundMaybeWithDerivedMetadataBuilder { fn drop(&mut self) { if self.is_owned && !<*mut nativeRefundMaybeWithDerivedMetadataBuilder>::is_null(self.inner) { @@ -144,6 +150,9 @@ impl RefundMaybeWithDerivedMetadataBuilder { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } impl Clone for RefundMaybeWithDerivedMetadataBuilder { fn clone(&self) -> Self { @@ -191,18 +200,22 @@ pub extern "C" fn RefundMaybeWithDerivedMetadataBuilder_new(mut metadata: crate: /// different payer id for each refund, assuming a different nonce is used. Otherwise, the /// provided `node_id` is used for the payer id. /// -/// Also, sets the metadata when [`RefundBuilder::build`] is called such that it can be used to -/// verify that an [`InvoiceRequest`] was produced for the refund given an [`ExpandedKey`]. +/// Also, sets the metadata when [`RefundBuilder::build`] is called such that it can be used by +/// [`Bolt12Invoice::verify_using_metadata`] to determine if the invoice was produced for the +/// refund given an [`ExpandedKey`]. However, if [`RefundBuilder::path`] is called, then the +/// metadata must be included in each [`BlindedMessagePath`] instead. In this case, use +/// [`Bolt12Invoice::verify_using_payer_data`]. /// /// The `payment_id` is encrypted in the metadata and should be unique. This ensures that only /// one invoice will be paid for the refund and that payments can be uniquely identified. /// -/// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest +/// [`Bolt12Invoice::verify_using_metadata`]: crate::offers::invoice::Bolt12Invoice::verify_using_metadata +/// [`Bolt12Invoice::verify_using_payer_data`]: crate::offers::invoice::Bolt12Invoice::verify_using_payer_data /// [`ExpandedKey`]: crate::ln::inbound_payment::ExpandedKey #[must_use] #[no_mangle] -pub extern "C" fn RefundMaybeWithDerivedMetadataBuilder_deriving_payer_id(mut node_id: crate::c_types::PublicKey, expanded_key: &crate::lightning::ln::inbound_payment::ExpandedKey, mut entropy_source: crate::lightning::sign::EntropySource, mut amount_msats: u64, mut payment_id: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ { - let mut ret = lightning::offers::refund::RefundMaybeWithDerivedMetadataBuilder::deriving_payer_id(node_id.into_rust(), expanded_key.get_native_ref(), entropy_source, secp256k1::global::SECP256K1, amount_msats, ::lightning::ln::channelmanager::PaymentId(payment_id.data)); +pub extern "C" fn RefundMaybeWithDerivedMetadataBuilder_deriving_payer_id(mut node_id: crate::c_types::PublicKey, expanded_key: &crate::lightning::ln::inbound_payment::ExpandedKey, mut nonce: crate::lightning::offers::nonce::Nonce, mut amount_msats: u64, mut payment_id: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ { + let mut ret = lightning::offers::refund::RefundMaybeWithDerivedMetadataBuilder::deriving_payer_id(node_id.into_rust(), expanded_key.get_native_ref(), *unsafe { Box::from_raw(nonce.take_inner()) }, secp256k1::global::SECP256K1, amount_msats, ::lightning::ln::channelmanager::PaymentId(payment_id.data)); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::refund::RefundMaybeWithDerivedMetadataBuilder { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::offers::parse::Bolt12SemanticError::native_into(e) }).into() }; local_ret } @@ -245,7 +258,7 @@ pub extern "C" fn RefundMaybeWithDerivedMetadataBuilder_issuer(mut this_arg: cra /// adding duplicate paths. #[must_use] #[no_mangle] -pub extern "C" fn RefundMaybeWithDerivedMetadataBuilder_path(mut this_arg: crate::lightning::offers::refund::RefundMaybeWithDerivedMetadataBuilder, mut path: crate::lightning::blinded_path::BlindedPath) { +pub extern "C" fn RefundMaybeWithDerivedMetadataBuilder_path(mut this_arg: crate::lightning::offers::refund::RefundMaybeWithDerivedMetadataBuilder, mut path: crate::lightning::blinded_path::message::BlindedMessagePath) { let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).path(*unsafe { Box::from_raw(path.take_inner()) }); () /*ret*/ } @@ -323,6 +336,12 @@ pub struct Refund { pub is_owned: bool, } +impl core::ops::Deref for Refund { + type Target = nativeRefund; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for Refund { } +unsafe impl core::marker::Sync for Refund { } impl Drop for Refund { fn drop(&mut self) { if self.is_owned && !<*mut nativeRefund>::is_null(self.inner) { @@ -353,6 +372,9 @@ impl Refund { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } impl Clone for Refund { fn clone(&self) -> Self { @@ -380,9 +402,9 @@ pub extern "C" fn Refund_debug_str_void(o: *const c_void) -> Str { /// but with the caveat that it has not been verified in any way. #[must_use] #[no_mangle] -pub extern "C" fn Refund_description(this_arg: &crate::lightning::offers::refund::Refund) -> crate::lightning::util::string::PrintableString { +pub extern "C" fn Refund_description(this_arg: &crate::lightning::offers::refund::Refund) -> crate::lightning_types::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 } + crate::lightning_types::string::PrintableString { inner: ObjOps::heap_alloc(ret), is_owned: true } } /// Duration since the Unix epoch when an invoice should no longer be sent. @@ -418,9 +440,9 @@ pub extern "C" fn Refund_is_expired_no_std(this_arg: &crate::lightning::offers:: /// 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 Refund_issuer(this_arg: &crate::lightning::offers::refund::Refund) -> crate::lightning::util::string::PrintableString { +pub extern "C" fn Refund_issuer(this_arg: &crate::lightning::offers::refund::Refund) -> crate::lightning_types::string::PrintableString { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.issuer(); - let mut local_ret = crate::lightning::util::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; + let mut local_ret = crate::lightning_types::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; local_ret } @@ -428,9 +450,9 @@ pub extern "C" fn Refund_issuer(this_arg: &crate::lightning::offers::refund::Ref /// privacy by obfuscating its node id. #[must_use] #[no_mangle] -pub extern "C" fn Refund_paths(this_arg: &crate::lightning::offers::refund::Refund) -> crate::c_types::derived::CVec_BlindedPathZ { +pub extern "C" fn Refund_paths(this_arg: &crate::lightning::offers::refund::Refund) -> crate::c_types::derived::CVec_BlindedMessagePathZ { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.paths(); - let mut local_ret_clone = Vec::new(); local_ret_clone.extend_from_slice(ret); let mut ret = local_ret_clone; let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::blinded_path::BlindedPath { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; + let mut local_ret_clone = Vec::new(); local_ret_clone.extend_from_slice(ret); let mut ret = local_ret_clone; let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::blinded_path::message::BlindedMessagePath { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; local_ret.into() } @@ -467,9 +489,9 @@ pub extern "C" fn Refund_amount_msats(this_arg: &crate::lightning::offers::refun /// Features pertaining to requesting an invoice. #[must_use] #[no_mangle] -pub extern "C" fn Refund_features(this_arg: &crate::lightning::offers::refund::Refund) -> crate::lightning::ln::features::InvoiceRequestFeatures { +pub extern "C" fn Refund_features(this_arg: &crate::lightning::offers::refund::Refund) -> crate::lightning_types::features::InvoiceRequestFeatures { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.features(); - crate::lightning::ln::features::InvoiceRequestFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::InvoiceRequestFeatures<>) as *mut _) }, is_owned: false } + crate::lightning_types::features::InvoiceRequestFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning_types::features::InvoiceRequestFeatures<>) as *mut _) }, is_owned: false } } /// The quantity of an item that refund is for. @@ -497,9 +519,9 @@ pub extern "C" fn Refund_payer_id(this_arg: &crate::lightning::offers::refund::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 Refund_payer_note(this_arg: &crate::lightning::offers::refund::Refund) -> crate::lightning::util::string::PrintableString { +pub extern "C" fn Refund_payer_note(this_arg: &crate::lightning::offers::refund::Refund) -> crate::lightning_types::string::PrintableString { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_note(); - let mut local_ret = crate::lightning::util::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; + let mut local_ret = crate::lightning_types::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; local_ret } @@ -514,13 +536,20 @@ pub extern "C" fn Refund_hash(o: &Refund) -> u64 { core::hash::Hasher::finish(&hasher) } #[no_mangle] +/// Read a Refund from a byte array, created by Refund_write +pub extern "C" fn Refund_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RefundDecodeErrorZ { + 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::refund::Refund { 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 Refund object into a byte array which can be read by Refund_read pub extern "C" fn Refund_write(obj: &crate::lightning::offers::refund::Refund) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) } #[allow(unused)] 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) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::offers::refund::nativeRefund) }) } #[no_mangle] /// Read a Refund object from a string diff --git a/lightning-c-bindings/src/lightning/onion_message/async_payments.rs b/lightning-c-bindings/src/lightning/onion_message/async_payments.rs new file mode 100644 index 0000000..dc778f6 --- /dev/null +++ b/lightning-c-bindings/src/lightning/onion_message/async_payments.rs @@ -0,0 +1,575 @@ +// 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 async payments. + +use alloc::str::FromStr; +use alloc::string::String; +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 an async payments message as its payload. +/// +/// [`OnionMessage`]: crate::ln::msgs::OnionMessage +#[repr(C)] +pub struct AsyncPaymentsMessageHandler { + /// 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, + /// Handle a [`HeldHtlcAvailable`] message. A [`ReleaseHeldHtlc`] should be returned to release + /// the held funds. + /// + /// Note that responder (or a relevant inner pointer) may be NULL or all-0s to represent None + pub held_htlc_available: extern "C" fn (this_arg: *const c_void, message: crate::lightning::onion_message::async_payments::HeldHtlcAvailable, responder: crate::lightning::onion_message::messenger::Responder) -> crate::c_types::derived::COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ, + /// Handle a [`ReleaseHeldHtlc`] message. If authentication of the message succeeds, an HTLC + /// should be released to the corresponding payee. + pub release_held_htlc: extern "C" fn (this_arg: *const c_void, message: crate::lightning::onion_message::async_payments::ReleaseHeldHtlc), + /// Release any [`AsyncPaymentsMessage`]s that need to be sent. + /// + /// Typically, this is used for messages initiating an async payment flow rather than in response + /// to another message. + pub release_pending_messages: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ, + /// 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 AsyncPaymentsMessageHandler {} +unsafe impl Sync for AsyncPaymentsMessageHandler {} +#[allow(unused)] +pub(crate) fn AsyncPaymentsMessageHandler_clone_fields(orig: &AsyncPaymentsMessageHandler) -> AsyncPaymentsMessageHandler { + AsyncPaymentsMessageHandler { + this_arg: orig.this_arg, + held_htlc_available: Clone::clone(&orig.held_htlc_available), + release_held_htlc: Clone::clone(&orig.release_held_htlc), + release_pending_messages: Clone::clone(&orig.release_pending_messages), + free: Clone::clone(&orig.free), + } +} + +use lightning::onion_message::async_payments::AsyncPaymentsMessageHandler as rustAsyncPaymentsMessageHandler; +impl rustAsyncPaymentsMessageHandler for AsyncPaymentsMessageHandler { + fn held_htlc_available(&self, mut message: lightning::onion_message::async_payments::HeldHtlcAvailable, mut responder: Option) -> Option<(lightning::onion_message::async_payments::ReleaseHeldHtlc, lightning::onion_message::messenger::ResponseInstruction)> { + let mut local_responder = crate::lightning::onion_message::messenger::Responder { inner: if responder.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((responder.unwrap())) } }, is_owned: true }; + let mut ret = (self.held_htlc_available)(self.this_arg, crate::lightning::onion_message::async_payments::HeldHtlcAvailable { inner: ObjOps::heap_alloc(message), is_owned: true }, local_responder); + let mut local_ret = if ret.is_some() { Some( { let (mut orig_ret_0_0, mut orig_ret_0_1) = ret.take().to_rust(); let mut local_ret_0 = (*unsafe { Box::from_raw(orig_ret_0_0.take_inner()) }, *unsafe { Box::from_raw(orig_ret_0_1.take_inner()) }); local_ret_0 }) } else { None }; + local_ret + } + fn release_held_htlc(&self, mut message: lightning::onion_message::async_payments::ReleaseHeldHtlc) { + (self.release_held_htlc)(self.this_arg, crate::lightning::onion_message::async_payments::ReleaseHeldHtlc { inner: ObjOps::heap_alloc(message), is_owned: true }) + } + fn release_pending_messages(&self) -> Vec<(lightning::onion_message::async_payments::AsyncPaymentsMessage, lightning::onion_message::messenger::MessageSendInstructions)> { + let mut ret = (self.release_pending_messages)(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_ret_0 = (orig_ret_0_0.into_native(), orig_ret_0_1.into_native()); local_ret_0 }); }; + local_ret + } +} + +pub struct AsyncPaymentsMessageHandlerRef(AsyncPaymentsMessageHandler); +impl rustAsyncPaymentsMessageHandler for AsyncPaymentsMessageHandlerRef { + fn held_htlc_available(&self, mut message: lightning::onion_message::async_payments::HeldHtlcAvailable, mut responder: Option) -> Option<(lightning::onion_message::async_payments::ReleaseHeldHtlc, lightning::onion_message::messenger::ResponseInstruction)> { + let mut local_responder = crate::lightning::onion_message::messenger::Responder { inner: if responder.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((responder.unwrap())) } }, is_owned: true }; + let mut ret = (self.0.held_htlc_available)(self.0.this_arg, crate::lightning::onion_message::async_payments::HeldHtlcAvailable { inner: ObjOps::heap_alloc(message), is_owned: true }, local_responder); + let mut local_ret = if ret.is_some() { Some( { let (mut orig_ret_0_0, mut orig_ret_0_1) = ret.take().to_rust(); let mut local_ret_0 = (*unsafe { Box::from_raw(orig_ret_0_0.take_inner()) }, *unsafe { Box::from_raw(orig_ret_0_1.take_inner()) }); local_ret_0 }) } else { None }; + local_ret + } + fn release_held_htlc(&self, mut message: lightning::onion_message::async_payments::ReleaseHeldHtlc) { + (self.0.release_held_htlc)(self.0.this_arg, crate::lightning::onion_message::async_payments::ReleaseHeldHtlc { inner: ObjOps::heap_alloc(message), is_owned: true }) + } + fn release_pending_messages(&self) -> Vec<(lightning::onion_message::async_payments::AsyncPaymentsMessage, lightning::onion_message::messenger::MessageSendInstructions)> { + let mut ret = (self.0.release_pending_messages)(self.0.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_ret_0 = (orig_ret_0_0.into_native(), orig_ret_0_1.into_native()); local_ret_0 }); }; + 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 AsyncPaymentsMessageHandler { + type Target = AsyncPaymentsMessageHandlerRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const AsyncPaymentsMessageHandlerRef) } + } +} +impl core::ops::DerefMut for AsyncPaymentsMessageHandler { + fn deref_mut(&mut self) -> &mut AsyncPaymentsMessageHandlerRef { + unsafe { &mut *(self as *mut _ as *mut AsyncPaymentsMessageHandlerRef) } + } +} +/// Calls the free function if one is set +#[no_mangle] +pub extern "C" fn AsyncPaymentsMessageHandler_free(this_ptr: AsyncPaymentsMessageHandler) { } +impl Drop for AsyncPaymentsMessageHandler { + fn drop(&mut self) { + if let Some(f) = self.free { + f(self.this_arg); + } + } +} +/// Possible async payment messages sent and received via an [`OnionMessage`]. +/// +/// [`OnionMessage`]: crate::ln::msgs::OnionMessage +#[derive(Clone)] +#[must_use] +#[repr(C)] +pub enum AsyncPaymentsMessage { + /// An HTLC is being held upstream for the often-offline recipient, to be released via + /// [`ReleaseHeldHtlc`]. + HeldHtlcAvailable( + crate::lightning::onion_message::async_payments::HeldHtlcAvailable), + /// Releases the HTLC corresponding to an inbound [`HeldHtlcAvailable`] message. + ReleaseHeldHtlc( + crate::lightning::onion_message::async_payments::ReleaseHeldHtlc), +} +use lightning::onion_message::async_payments::AsyncPaymentsMessage as AsyncPaymentsMessageImport; +pub(crate) type nativeAsyncPaymentsMessage = AsyncPaymentsMessageImport; + +impl AsyncPaymentsMessage { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeAsyncPaymentsMessage { + match self { + AsyncPaymentsMessage::HeldHtlcAvailable (ref a, ) => { + let mut a_nonref = Clone::clone(a); + nativeAsyncPaymentsMessage::HeldHtlcAvailable ( + *unsafe { Box::from_raw(a_nonref.take_inner()) }, + ) + }, + AsyncPaymentsMessage::ReleaseHeldHtlc (ref a, ) => { + let mut a_nonref = Clone::clone(a); + nativeAsyncPaymentsMessage::ReleaseHeldHtlc ( + *unsafe { Box::from_raw(a_nonref.take_inner()) }, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeAsyncPaymentsMessage { + match self { + AsyncPaymentsMessage::HeldHtlcAvailable (mut a, ) => { + nativeAsyncPaymentsMessage::HeldHtlcAvailable ( + *unsafe { Box::from_raw(a.take_inner()) }, + ) + }, + AsyncPaymentsMessage::ReleaseHeldHtlc (mut a, ) => { + nativeAsyncPaymentsMessage::ReleaseHeldHtlc ( + *unsafe { Box::from_raw(a.take_inner()) }, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &AsyncPaymentsMessageImport) -> Self { + let native = unsafe { &*(native as *const _ as *const c_void as *const nativeAsyncPaymentsMessage) }; + match native { + nativeAsyncPaymentsMessage::HeldHtlcAvailable (ref a, ) => { + let mut a_nonref = Clone::clone(a); + AsyncPaymentsMessage::HeldHtlcAvailable ( + crate::lightning::onion_message::async_payments::HeldHtlcAvailable { inner: ObjOps::heap_alloc(a_nonref), is_owned: true }, + ) + }, + nativeAsyncPaymentsMessage::ReleaseHeldHtlc (ref a, ) => { + let mut a_nonref = Clone::clone(a); + AsyncPaymentsMessage::ReleaseHeldHtlc ( + crate::lightning::onion_message::async_payments::ReleaseHeldHtlc { inner: ObjOps::heap_alloc(a_nonref), is_owned: true }, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeAsyncPaymentsMessage) -> Self { + match native { + nativeAsyncPaymentsMessage::HeldHtlcAvailable (mut a, ) => { + AsyncPaymentsMessage::HeldHtlcAvailable ( + crate::lightning::onion_message::async_payments::HeldHtlcAvailable { inner: ObjOps::heap_alloc(a), is_owned: true }, + ) + }, + nativeAsyncPaymentsMessage::ReleaseHeldHtlc (mut a, ) => { + AsyncPaymentsMessage::ReleaseHeldHtlc ( + crate::lightning::onion_message::async_payments::ReleaseHeldHtlc { inner: ObjOps::heap_alloc(a), is_owned: true }, + ) + }, + } + } +} +/// Frees any resources used by the AsyncPaymentsMessage +#[no_mangle] +pub extern "C" fn AsyncPaymentsMessage_free(this_ptr: AsyncPaymentsMessage) { } +/// Creates a copy of the AsyncPaymentsMessage +#[no_mangle] +pub extern "C" fn AsyncPaymentsMessage_clone(orig: &AsyncPaymentsMessage) -> AsyncPaymentsMessage { + orig.clone() +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn AsyncPaymentsMessage_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const AsyncPaymentsMessage)).clone() })) as *mut c_void +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn AsyncPaymentsMessage_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut AsyncPaymentsMessage) }; +} +#[no_mangle] +/// Utility method to constructs a new HeldHtlcAvailable-variant AsyncPaymentsMessage +pub extern "C" fn AsyncPaymentsMessage_held_htlc_available(a: crate::lightning::onion_message::async_payments::HeldHtlcAvailable) -> AsyncPaymentsMessage { + AsyncPaymentsMessage::HeldHtlcAvailable(a, ) +} +#[no_mangle] +/// Utility method to constructs a new ReleaseHeldHtlc-variant AsyncPaymentsMessage +pub extern "C" fn AsyncPaymentsMessage_release_held_htlc(a: crate::lightning::onion_message::async_payments::ReleaseHeldHtlc) -> AsyncPaymentsMessage { + AsyncPaymentsMessage::ReleaseHeldHtlc(a, ) +} +/// Get a string which allows debug introspection of a AsyncPaymentsMessage object +pub extern "C" fn AsyncPaymentsMessage_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::onion_message::async_payments::AsyncPaymentsMessage }).into()} + +use lightning::onion_message::async_payments::HeldHtlcAvailable as nativeHeldHtlcAvailableImport; +pub(crate) type nativeHeldHtlcAvailable = nativeHeldHtlcAvailableImport; + +/// An HTLC destined for the recipient of this message is being held upstream. The reply path +/// accompanying this onion message should be used to send a [`ReleaseHeldHtlc`] response, which +/// will cause the upstream HTLC to be released. +#[must_use] +#[repr(C)] +pub struct HeldHtlcAvailable { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, 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 nativeHeldHtlcAvailable, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust 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 core::ops::Deref for HeldHtlcAvailable { + type Target = nativeHeldHtlcAvailable; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for HeldHtlcAvailable { } +unsafe impl core::marker::Sync for HeldHtlcAvailable { } +impl Drop for HeldHtlcAvailable { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeHeldHtlcAvailable>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the HeldHtlcAvailable, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn HeldHtlcAvailable_free(this_obj: HeldHtlcAvailable) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn HeldHtlcAvailable_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeHeldHtlcAvailable) }; +} +#[allow(unused)] +impl HeldHtlcAvailable { + pub(crate) fn get_native_ref(&self) -> &'static nativeHeldHtlcAvailable { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeHeldHtlcAvailable { + 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 nativeHeldHtlcAvailable { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// The secret that will be used by the recipient of this message to release the held HTLC. +#[no_mangle] +pub extern "C" fn HeldHtlcAvailable_get_payment_release_secret(this_ptr: &HeldHtlcAvailable) -> *const [u8; 32] { + let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_release_secret; + inner_val +} +/// The secret that will be used by the recipient of this message to release the held HTLC. +#[no_mangle] +pub extern "C" fn HeldHtlcAvailable_set_payment_release_secret(this_ptr: &mut HeldHtlcAvailable, mut val: crate::c_types::ThirtyTwoBytes) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_release_secret = val.data; +} +/// Constructs a new HeldHtlcAvailable given each field +#[must_use] +#[no_mangle] +pub extern "C" fn HeldHtlcAvailable_new(mut payment_release_secret_arg: crate::c_types::ThirtyTwoBytes) -> HeldHtlcAvailable { + HeldHtlcAvailable { inner: ObjOps::heap_alloc(nativeHeldHtlcAvailable { + payment_release_secret: payment_release_secret_arg.data, + }), is_owned: true } +} +impl Clone for HeldHtlcAvailable { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeHeldHtlcAvailable>::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 HeldHtlcAvailable_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeHeldHtlcAvailable)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the HeldHtlcAvailable +pub extern "C" fn HeldHtlcAvailable_clone(orig: &HeldHtlcAvailable) -> HeldHtlcAvailable { + orig.clone() +} +/// Get a string which allows debug introspection of a HeldHtlcAvailable object +pub extern "C" fn HeldHtlcAvailable_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::onion_message::async_payments::HeldHtlcAvailable }).into()} + +use lightning::onion_message::async_payments::ReleaseHeldHtlc as nativeReleaseHeldHtlcImport; +pub(crate) type nativeReleaseHeldHtlc = nativeReleaseHeldHtlcImport; + +/// Releases the HTLC corresponding to an inbound [`HeldHtlcAvailable`] message. +#[must_use] +#[repr(C)] +pub struct ReleaseHeldHtlc { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, 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 nativeReleaseHeldHtlc, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust 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 core::ops::Deref for ReleaseHeldHtlc { + type Target = nativeReleaseHeldHtlc; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ReleaseHeldHtlc { } +unsafe impl core::marker::Sync for ReleaseHeldHtlc { } +impl Drop for ReleaseHeldHtlc { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeReleaseHeldHtlc>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the ReleaseHeldHtlc, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn ReleaseHeldHtlc_free(this_obj: ReleaseHeldHtlc) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn ReleaseHeldHtlc_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeReleaseHeldHtlc) }; +} +#[allow(unused)] +impl ReleaseHeldHtlc { + pub(crate) fn get_native_ref(&self) -> &'static nativeReleaseHeldHtlc { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeReleaseHeldHtlc { + 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 nativeReleaseHeldHtlc { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// Used to release the HTLC held upstream if it matches the corresponding +/// [`HeldHtlcAvailable::payment_release_secret`]. +#[no_mangle] +pub extern "C" fn ReleaseHeldHtlc_get_payment_release_secret(this_ptr: &ReleaseHeldHtlc) -> *const [u8; 32] { + let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_release_secret; + inner_val +} +/// Used to release the HTLC held upstream if it matches the corresponding +/// [`HeldHtlcAvailable::payment_release_secret`]. +#[no_mangle] +pub extern "C" fn ReleaseHeldHtlc_set_payment_release_secret(this_ptr: &mut ReleaseHeldHtlc, mut val: crate::c_types::ThirtyTwoBytes) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_release_secret = val.data; +} +/// Constructs a new ReleaseHeldHtlc given each field +#[must_use] +#[no_mangle] +pub extern "C" fn ReleaseHeldHtlc_new(mut payment_release_secret_arg: crate::c_types::ThirtyTwoBytes) -> ReleaseHeldHtlc { + ReleaseHeldHtlc { inner: ObjOps::heap_alloc(nativeReleaseHeldHtlc { + payment_release_secret: payment_release_secret_arg.data, + }), is_owned: true } +} +impl Clone for ReleaseHeldHtlc { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeReleaseHeldHtlc>::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 ReleaseHeldHtlc_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeReleaseHeldHtlc)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the ReleaseHeldHtlc +pub extern "C" fn ReleaseHeldHtlc_clone(orig: &ReleaseHeldHtlc) -> ReleaseHeldHtlc { + orig.clone() +} +/// Get a string which allows debug introspection of a ReleaseHeldHtlc object +pub extern "C" fn ReleaseHeldHtlc_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::onion_message::async_payments::ReleaseHeldHtlc }).into()} +impl From for crate::lightning::onion_message::packet::OnionMessageContents { + fn from(obj: nativeReleaseHeldHtlc) -> Self { + let rust_obj = crate::lightning::onion_message::async_payments::ReleaseHeldHtlc { inner: ObjOps::heap_alloc(obj), is_owned: true }; + let mut ret = ReleaseHeldHtlc_as_OnionMessageContents(&rust_obj); + // We want to free rust_obj when ret gets drop()'d, not rust_obj, so forget it and set ret's free() fn + core::mem::forget(rust_obj); + ret.free = Some(ReleaseHeldHtlc_free_void); + ret + } +} +/// Constructs a new OnionMessageContents which calls the relevant methods on this_arg. +/// This copies the `inner` pointer in this_arg and thus the returned OnionMessageContents must be freed before this_arg is +#[no_mangle] +pub extern "C" fn ReleaseHeldHtlc_as_OnionMessageContents(this_arg: &ReleaseHeldHtlc) -> crate::lightning::onion_message::packet::OnionMessageContents { + crate::lightning::onion_message::packet::OnionMessageContents { + this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, + free: None, + tlv_type: ReleaseHeldHtlc_OnionMessageContents_tlv_type, + msg_type: ReleaseHeldHtlc_OnionMessageContents_msg_type, + write: ReleaseHeldHtlc_write_void, + debug_str: ReleaseHeldHtlc_debug_str_void, + cloned: Some(OnionMessageContents_ReleaseHeldHtlc_cloned), + } +} + +#[must_use] +extern "C" fn ReleaseHeldHtlc_OnionMessageContents_tlv_type(this_arg: *const c_void) -> u64 { + let mut ret = ::tlv_type(unsafe { &mut *(this_arg as *mut nativeReleaseHeldHtlc) }, ); + ret +} +#[must_use] +extern "C" fn ReleaseHeldHtlc_OnionMessageContents_msg_type(this_arg: *const c_void) -> crate::c_types::Str { + let mut ret = ::msg_type(unsafe { &mut *(this_arg as *mut nativeReleaseHeldHtlc) }, ); + ret.into() +} +extern "C" fn OnionMessageContents_ReleaseHeldHtlc_cloned(new_obj: &mut crate::lightning::onion_message::packet::OnionMessageContents) { + new_obj.this_arg = ReleaseHeldHtlc_clone_void(new_obj.this_arg); + new_obj.free = Some(ReleaseHeldHtlc_free_void); +} + +#[no_mangle] +/// Serialize the HeldHtlcAvailable object into a byte array which can be read by HeldHtlcAvailable_read +pub extern "C" fn HeldHtlcAvailable_write(obj: &crate::lightning::onion_message::async_payments::HeldHtlcAvailable) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[allow(unused)] +pub(crate) extern "C" fn HeldHtlcAvailable_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::onion_message::async_payments::nativeHeldHtlcAvailable) }) +} +#[no_mangle] +/// Read a HeldHtlcAvailable from a byte array, created by HeldHtlcAvailable_write +pub extern "C" fn HeldHtlcAvailable_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_HeldHtlcAvailableDecodeErrorZ { + 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::onion_message::async_payments::HeldHtlcAvailable { 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 ReleaseHeldHtlc object into a byte array which can be read by ReleaseHeldHtlc_read +pub extern "C" fn ReleaseHeldHtlc_write(obj: &crate::lightning::onion_message::async_payments::ReleaseHeldHtlc) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[allow(unused)] +pub(crate) extern "C" fn ReleaseHeldHtlc_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::onion_message::async_payments::nativeReleaseHeldHtlc) }) +} +#[no_mangle] +/// Read a ReleaseHeldHtlc from a byte array, created by ReleaseHeldHtlc_write +pub extern "C" fn ReleaseHeldHtlc_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReleaseHeldHtlcDecodeErrorZ { + 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::onion_message::async_payments::ReleaseHeldHtlc { 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 +} +/// Returns whether `tlv_type` corresponds to a TLV record for async payment messages. +#[must_use] +#[no_mangle] +pub extern "C" fn AsyncPaymentsMessage_is_known_type(mut tlv_type: u64) -> bool { + let mut ret = lightning::onion_message::async_payments::AsyncPaymentsMessage::is_known_type(tlv_type); + ret +} + +impl From for crate::lightning::onion_message::packet::OnionMessageContents { + fn from(obj: nativeAsyncPaymentsMessage) -> Self { + let rust_obj = crate::lightning::onion_message::async_payments::AsyncPaymentsMessage::native_into(obj); + let mut ret = AsyncPaymentsMessage_as_OnionMessageContents(&rust_obj); + // We want to free rust_obj when ret gets drop()'d, not rust_obj, so forget it and set ret's free() fn + core::mem::forget(rust_obj); + ret.free = Some(AsyncPaymentsMessage_free_void); + ret + } +} +/// Constructs a new OnionMessageContents which calls the relevant methods on this_arg. +/// This copies the `inner` pointer in this_arg and thus the returned OnionMessageContents must be freed before this_arg is +#[no_mangle] +pub extern "C" fn AsyncPaymentsMessage_as_OnionMessageContents(this_arg: &AsyncPaymentsMessage) -> crate::lightning::onion_message::packet::OnionMessageContents { + crate::lightning::onion_message::packet::OnionMessageContents { + this_arg: unsafe { ObjOps::untweak_ptr(this_arg as *const AsyncPaymentsMessage as *mut AsyncPaymentsMessage) as *mut c_void }, + free: None, + tlv_type: AsyncPaymentsMessage_OnionMessageContents_tlv_type, + msg_type: AsyncPaymentsMessage_OnionMessageContents_msg_type, + write: AsyncPaymentsMessage_write_void, + debug_str: AsyncPaymentsMessage_debug_str_void, + cloned: Some(OnionMessageContents_AsyncPaymentsMessage_cloned), + } +} + +#[must_use] +extern "C" fn AsyncPaymentsMessage_OnionMessageContents_tlv_type(this_arg: *const c_void) -> u64 { + let mut ret = ::tlv_type(unsafe { &mut *(this_arg as *mut nativeAsyncPaymentsMessage) }, ); + ret +} +#[must_use] +extern "C" fn AsyncPaymentsMessage_OnionMessageContents_msg_type(this_arg: *const c_void) -> crate::c_types::Str { + let mut ret = ::msg_type(unsafe { &mut *(this_arg as *mut nativeAsyncPaymentsMessage) }, ); + ret.into() +} +extern "C" fn OnionMessageContents_AsyncPaymentsMessage_cloned(new_obj: &mut crate::lightning::onion_message::packet::OnionMessageContents) { + new_obj.this_arg = AsyncPaymentsMessage_clone_void(new_obj.this_arg); + new_obj.free = Some(AsyncPaymentsMessage_free_void); +} + +#[no_mangle] +/// Serialize the AsyncPaymentsMessage object into a byte array which can be read by AsyncPaymentsMessage_read +pub extern "C" fn AsyncPaymentsMessage_write(obj: &crate::lightning::onion_message::async_payments::AsyncPaymentsMessage) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(&unsafe { &*obj }.to_native()) +} +#[allow(unused)] +pub(crate) extern "C" fn AsyncPaymentsMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + AsyncPaymentsMessage_write(unsafe { &*(obj as *const AsyncPaymentsMessage) }) +} +#[no_mangle] +/// Read a AsyncPaymentsMessage from a byte array, created by AsyncPaymentsMessage_write +pub extern "C" fn AsyncPaymentsMessage_read(ser: crate::c_types::u8slice, arg: u64) -> crate::c_types::derived::CResult_AsyncPaymentsMessageDecodeErrorZ { + 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::onion_message::async_payments::AsyncPaymentsMessage::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/messenger.rs b/lightning-c-bindings/src/lightning/onion_message/messenger.rs index 05be30d..a5323a8 100644 --- a/lightning-c-bindings/src/lightning/onion_message/messenger.rs +++ b/lightning-c-bindings/src/lightning/onion_message/messenger.rs @@ -20,7 +20,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 [`OnionMessage`]s. /// @@ -43,12 +43,13 @@ pub(crate) type nativeOnionMessenger = nativeOnionMessengerImport( -/// # &self, _recipient: PublicKey, _peers: Vec, _secp_ctx: &Secp256k1 -/// # ) -> Result, ()> { +/// # &self, _recipient: PublicKey, _context: MessageContext, _peers: Vec, _secp_ctx: &Secp256k1 +/// # ) -> Result, ()> { /// # unreachable!() /// # } /// # } @@ -90,11 +91,12 @@ pub(crate) type nativeOnionMessenger = nativeOnionMessengerImport &'static str { \"YourCustomMessageType\" } /// } /// // Send a custom onion message to a node id. /// let destination = Destination::Node(destination_node_id); -/// let reply_path = None; +/// let instructions = MessageSendInstructions::WithoutReplyPath { destination }; /// # let message = YourCustomMessage {}; -/// onion_messenger.send_onion_message(message, destination, reply_path); +/// onion_messenger.send_onion_message(message, instructions); /// /// // 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(); +/// let hops = [ +/// \tMessageForwardNode { node_id: hop_node_id3, short_channel_id: None }, +/// \tMessageForwardNode { node_id: hop_node_id4, short_channel_id: None }, +/// ]; +/// let context = MessageContext::Custom(Vec::new()); +/// let blinded_path = BlindedMessagePath::new(&hops, your_node_id, context, &keys_manager, &secp_ctx).unwrap(); /// /// // Send a custom onion message to a blinded path. /// let destination = Destination::BlindedPath(blinded_path); -/// let reply_path = None; +/// let instructions = MessageSendInstructions::WithoutReplyPath { destination }; /// # let message = YourCustomMessage {}; -/// onion_messenger.send_onion_message(message, destination, reply_path); +/// onion_messenger.send_onion_message(message, instructions); /// ``` /// /// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest @@ -146,6 +153,12 @@ pub struct OnionMessenger { pub is_owned: bool, } +impl core::ops::Deref for OnionMessenger { + type Target = nativeOnionMessenger; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for OnionMessenger { } +unsafe impl core::marker::Sync for OnionMessenger { } impl Drop for OnionMessenger { fn drop(&mut self) { if self.is_owned && !<*mut nativeOnionMessenger>::is_null(self.inner) { @@ -176,6 +189,424 @@ impl OnionMessenger { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} + +use lightning::onion_message::messenger::Responder as nativeResponderImport; +pub(crate) type nativeResponder = nativeResponderImport; + +/// The `Responder` struct creates an appropriate [`ResponseInstruction`] for responding to a +/// message. +#[must_use] +#[repr(C)] +pub struct Responder { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, 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 nativeResponder, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust 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 core::ops::Deref for Responder { + type Target = nativeResponder; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for Responder { } +unsafe impl core::marker::Sync for Responder { } +impl Drop for Responder { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeResponder>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the Responder, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn Responder_free(this_obj: Responder) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn Responder_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeResponder) }; +} +#[allow(unused)] +impl Responder { + pub(crate) fn get_native_ref(&self) -> &'static nativeResponder { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeResponder { + 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 nativeResponder { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +impl Clone for Responder { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeResponder>::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 Responder_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeResponder)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the Responder +pub extern "C" fn Responder_clone(orig: &Responder) -> Responder { + orig.clone() +} +/// Get a string which allows debug introspection of a Responder object +pub extern "C" fn Responder_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::onion_message::messenger::Responder }).into()} +/// Checks if two Responders 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 Responder_eq(a: &Responder, b: &Responder) -> 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 Responder object into a byte array which can be read by Responder_read +pub extern "C" fn Responder_write(obj: &crate::lightning::onion_message::messenger::Responder) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[allow(unused)] +pub(crate) extern "C" fn Responder_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::onion_message::messenger::nativeResponder) }) +} +#[no_mangle] +/// Read a Responder from a byte array, created by Responder_write +pub extern "C" fn Responder_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ResponderDecodeErrorZ { + 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::onion_message::messenger::Responder { 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 +} +/// Creates a [`ResponseInstruction`] for responding without including a reply path. +/// +/// Use when the recipient doesn't need to send back a reply to us. +#[must_use] +#[no_mangle] +pub extern "C" fn Responder_respond(mut this_arg: crate::lightning::onion_message::messenger::Responder) -> crate::lightning::onion_message::messenger::ResponseInstruction { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).respond(); + crate::lightning::onion_message::messenger::ResponseInstruction { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Creates a [`ResponseInstruction`] for responding including a reply path. +/// +/// Use when the recipient needs to send back a reply to us. +#[must_use] +#[no_mangle] +pub extern "C" fn Responder_respond_with_reply_path(mut this_arg: crate::lightning::onion_message::messenger::Responder, mut context: crate::lightning::blinded_path::message::MessageContext) -> crate::lightning::onion_message::messenger::ResponseInstruction { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).respond_with_reply_path(context.into_native()); + crate::lightning::onion_message::messenger::ResponseInstruction { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + + +use lightning::onion_message::messenger::ResponseInstruction as nativeResponseInstructionImport; +pub(crate) type nativeResponseInstruction = nativeResponseInstructionImport; + +/// Instructions for how and where to send the response to an onion message. +#[must_use] +#[repr(C)] +pub struct ResponseInstruction { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, 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 nativeResponseInstruction, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust 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 core::ops::Deref for ResponseInstruction { + type Target = nativeResponseInstruction; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ResponseInstruction { } +unsafe impl core::marker::Sync for ResponseInstruction { } +impl Drop for ResponseInstruction { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeResponseInstruction>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the ResponseInstruction, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn ResponseInstruction_free(this_obj: ResponseInstruction) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn ResponseInstruction_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeResponseInstruction) }; +} +#[allow(unused)] +impl ResponseInstruction { + pub(crate) fn get_native_ref(&self) -> &'static nativeResponseInstruction { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeResponseInstruction { + 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 nativeResponseInstruction { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +impl Clone for ResponseInstruction { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeResponseInstruction>::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 ResponseInstruction_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeResponseInstruction)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the ResponseInstruction +pub extern "C" fn ResponseInstruction_clone(orig: &ResponseInstruction) -> ResponseInstruction { + orig.clone() +} +/// Instructions for how and where to send a message. +#[derive(Clone)] +#[must_use] +#[repr(C)] +pub enum MessageSendInstructions { + /// Indicates that a message should be sent including the provided reply path for the recipient + /// to respond. + WithSpecifiedReplyPath { + /// The destination where we need to send our message. + destination: crate::lightning::onion_message::messenger::Destination, + /// The reply path which should be included in the message. + reply_path: crate::lightning::blinded_path::message::BlindedMessagePath, + }, + /// Indicates that a message should be sent including a reply path for the recipient to + /// respond. + WithReplyPath { + /// The destination where we need to send our message. + destination: crate::lightning::onion_message::messenger::Destination, + /// The context to include in the reply path we'll give the recipient so they can respond + /// to us. + context: crate::lightning::blinded_path::message::MessageContext, + }, + /// Indicates that a message should be sent without including a reply path, preventing the + /// recipient from responding. + WithoutReplyPath { + /// The destination where we need to send our message. + destination: crate::lightning::onion_message::messenger::Destination, + }, + /// Indicates that a message is being sent as a reply to a received message. + ForReply { + /// The instructions provided by the [`Responder`]. + instructions: crate::lightning::onion_message::messenger::ResponseInstruction, + }, +} +use lightning::onion_message::messenger::MessageSendInstructions as MessageSendInstructionsImport; +pub(crate) type nativeMessageSendInstructions = MessageSendInstructionsImport; + +impl MessageSendInstructions { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeMessageSendInstructions { + match self { + MessageSendInstructions::WithSpecifiedReplyPath {ref destination, ref reply_path, } => { + let mut destination_nonref = Clone::clone(destination); + let mut reply_path_nonref = Clone::clone(reply_path); + nativeMessageSendInstructions::WithSpecifiedReplyPath { + destination: destination_nonref.into_native(), + reply_path: *unsafe { Box::from_raw(reply_path_nonref.take_inner()) }, + } + }, + MessageSendInstructions::WithReplyPath {ref destination, ref context, } => { + let mut destination_nonref = Clone::clone(destination); + let mut context_nonref = Clone::clone(context); + nativeMessageSendInstructions::WithReplyPath { + destination: destination_nonref.into_native(), + context: context_nonref.into_native(), + } + }, + MessageSendInstructions::WithoutReplyPath {ref destination, } => { + let mut destination_nonref = Clone::clone(destination); + nativeMessageSendInstructions::WithoutReplyPath { + destination: destination_nonref.into_native(), + } + }, + MessageSendInstructions::ForReply {ref instructions, } => { + let mut instructions_nonref = Clone::clone(instructions); + nativeMessageSendInstructions::ForReply { + instructions: *unsafe { Box::from_raw(instructions_nonref.take_inner()) }, + } + }, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeMessageSendInstructions { + match self { + MessageSendInstructions::WithSpecifiedReplyPath {mut destination, mut reply_path, } => { + nativeMessageSendInstructions::WithSpecifiedReplyPath { + destination: destination.into_native(), + reply_path: *unsafe { Box::from_raw(reply_path.take_inner()) }, + } + }, + MessageSendInstructions::WithReplyPath {mut destination, mut context, } => { + nativeMessageSendInstructions::WithReplyPath { + destination: destination.into_native(), + context: context.into_native(), + } + }, + MessageSendInstructions::WithoutReplyPath {mut destination, } => { + nativeMessageSendInstructions::WithoutReplyPath { + destination: destination.into_native(), + } + }, + MessageSendInstructions::ForReply {mut instructions, } => { + nativeMessageSendInstructions::ForReply { + instructions: *unsafe { Box::from_raw(instructions.take_inner()) }, + } + }, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &MessageSendInstructionsImport) -> Self { + let native = unsafe { &*(native as *const _ as *const c_void as *const nativeMessageSendInstructions) }; + match native { + nativeMessageSendInstructions::WithSpecifiedReplyPath {ref destination, ref reply_path, } => { + let mut destination_nonref = Clone::clone(destination); + let mut reply_path_nonref = Clone::clone(reply_path); + MessageSendInstructions::WithSpecifiedReplyPath { + destination: crate::lightning::onion_message::messenger::Destination::native_into(destination_nonref), + reply_path: crate::lightning::blinded_path::message::BlindedMessagePath { inner: ObjOps::heap_alloc(reply_path_nonref), is_owned: true }, + } + }, + nativeMessageSendInstructions::WithReplyPath {ref destination, ref context, } => { + let mut destination_nonref = Clone::clone(destination); + let mut context_nonref = Clone::clone(context); + MessageSendInstructions::WithReplyPath { + destination: crate::lightning::onion_message::messenger::Destination::native_into(destination_nonref), + context: crate::lightning::blinded_path::message::MessageContext::native_into(context_nonref), + } + }, + nativeMessageSendInstructions::WithoutReplyPath {ref destination, } => { + let mut destination_nonref = Clone::clone(destination); + MessageSendInstructions::WithoutReplyPath { + destination: crate::lightning::onion_message::messenger::Destination::native_into(destination_nonref), + } + }, + nativeMessageSendInstructions::ForReply {ref instructions, } => { + let mut instructions_nonref = Clone::clone(instructions); + MessageSendInstructions::ForReply { + instructions: crate::lightning::onion_message::messenger::ResponseInstruction { inner: ObjOps::heap_alloc(instructions_nonref), is_owned: true }, + } + }, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeMessageSendInstructions) -> Self { + match native { + nativeMessageSendInstructions::WithSpecifiedReplyPath {mut destination, mut reply_path, } => { + MessageSendInstructions::WithSpecifiedReplyPath { + destination: crate::lightning::onion_message::messenger::Destination::native_into(destination), + reply_path: crate::lightning::blinded_path::message::BlindedMessagePath { inner: ObjOps::heap_alloc(reply_path), is_owned: true }, + } + }, + nativeMessageSendInstructions::WithReplyPath {mut destination, mut context, } => { + MessageSendInstructions::WithReplyPath { + destination: crate::lightning::onion_message::messenger::Destination::native_into(destination), + context: crate::lightning::blinded_path::message::MessageContext::native_into(context), + } + }, + nativeMessageSendInstructions::WithoutReplyPath {mut destination, } => { + MessageSendInstructions::WithoutReplyPath { + destination: crate::lightning::onion_message::messenger::Destination::native_into(destination), + } + }, + nativeMessageSendInstructions::ForReply {mut instructions, } => { + MessageSendInstructions::ForReply { + instructions: crate::lightning::onion_message::messenger::ResponseInstruction { inner: ObjOps::heap_alloc(instructions), is_owned: true }, + } + }, + } + } +} +/// Frees any resources used by the MessageSendInstructions +#[no_mangle] +pub extern "C" fn MessageSendInstructions_free(this_ptr: MessageSendInstructions) { } +/// Creates a copy of the MessageSendInstructions +#[no_mangle] +pub extern "C" fn MessageSendInstructions_clone(orig: &MessageSendInstructions) -> MessageSendInstructions { + orig.clone() +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn MessageSendInstructions_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const MessageSendInstructions)).clone() })) as *mut c_void +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn MessageSendInstructions_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut MessageSendInstructions) }; +} +#[no_mangle] +/// Utility method to constructs a new WithSpecifiedReplyPath-variant MessageSendInstructions +pub extern "C" fn MessageSendInstructions_with_specified_reply_path(destination: crate::lightning::onion_message::messenger::Destination, reply_path: crate::lightning::blinded_path::message::BlindedMessagePath) -> MessageSendInstructions { + MessageSendInstructions::WithSpecifiedReplyPath { + destination, + reply_path, + } +} +#[no_mangle] +/// Utility method to constructs a new WithReplyPath-variant MessageSendInstructions +pub extern "C" fn MessageSendInstructions_with_reply_path(destination: crate::lightning::onion_message::messenger::Destination, context: crate::lightning::blinded_path::message::MessageContext) -> MessageSendInstructions { + MessageSendInstructions::WithReplyPath { + destination, + context, + } +} +#[no_mangle] +/// Utility method to constructs a new WithoutReplyPath-variant MessageSendInstructions +pub extern "C" fn MessageSendInstructions_without_reply_path(destination: crate::lightning::onion_message::messenger::Destination) -> MessageSendInstructions { + MessageSendInstructions::WithoutReplyPath { + destination, + } +} +#[no_mangle] +/// Utility method to constructs a new ForReply-variant MessageSendInstructions +pub extern "C" fn MessageSendInstructions_for_reply(instructions: crate::lightning::onion_message::messenger::ResponseInstruction) -> MessageSendInstructions { + MessageSendInstructions::ForReply { + instructions, + } } /// A trait defining behavior for routing an [`OnionMessage`]. #[repr(C)] @@ -185,9 +616,23 @@ pub struct MessageRouter { pub this_arg: *mut c_void, /// Returns a route for sending an [`OnionMessage`] to the given [`Destination`]. 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, - /// Creates [`BlindedPath`]s to the `recipient` node. The nodes in `peers` are assumed to be - /// direct peers with the `recipient`. - pub create_blinded_paths: extern "C" fn (this_arg: *const c_void, recipient: crate::c_types::PublicKey, peers: crate::c_types::derived::CVec_PublicKeyZ) -> crate::c_types::derived::CResult_CVec_BlindedPathZNoneZ, + /// Creates [`BlindedMessagePath`]s to the `recipient` node. The nodes in `peers` are assumed to + /// be direct peers with the `recipient`. + pub create_blinded_paths: extern "C" fn (this_arg: *const c_void, recipient: crate::c_types::PublicKey, context: crate::lightning::blinded_path::message::MessageContext, peers: crate::c_types::derived::CVec_PublicKeyZ) -> crate::c_types::derived::CResult_CVec_BlindedMessagePathZNoneZ, + /// Creates compact [`BlindedMessagePath`]s to the `recipient` node. The nodes in `peers` are + /// assumed to be direct peers with the `recipient`. + /// + /// Compact blinded paths use short channel ids instead of pubkeys for a smaller serialization, + /// which is beneficial when a QR code is used to transport the data. The SCID is passed using + /// a [`MessageForwardNode`] but may be `None` for graceful degradation. + /// + /// Implementations using additional intermediate nodes are responsible for using a + /// [`MessageForwardNode`] with `Some` short channel id, if possible. Similarly, implementations + /// should call [`BlindedMessagePath::use_compact_introduction_node`]. + /// + /// The provided implementation simply delegates to [`MessageRouter::create_blinded_paths`], + /// ignoring the short channel ids. + pub create_compact_blinded_paths: extern "C" fn (this_arg: *const c_void, recipient: crate::c_types::PublicKey, context: crate::lightning::blinded_path::message::MessageContext, peers: crate::c_types::derived::CVec_MessageForwardNodeZ) -> crate::c_types::derived::CResult_CVec_BlindedMessagePathZNoneZ, /// 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, @@ -200,6 +645,7 @@ pub(crate) fn MessageRouter_clone_fields(orig: &MessageRouter) -> MessageRouter this_arg: orig.this_arg, find_path: Clone::clone(&orig.find_path), create_blinded_paths: Clone::clone(&orig.create_blinded_paths), + create_compact_blinded_paths: Clone::clone(&orig.create_compact_blinded_paths), free: Clone::clone(&orig.free), } } @@ -212,9 +658,37 @@ impl rustMessageRouter for MessageRouter { 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 create_blinded_paths(&self, mut recipient: bitcoin::secp256k1::PublicKey, mut peers: Vec, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result, ()> { + fn create_blinded_paths(&self, mut recipient: bitcoin::secp256k1::PublicKey, mut context: lightning::blinded_path::message::MessageContext, mut peers: Vec, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> 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.create_blinded_paths)(self.this_arg, crate::c_types::PublicKey::from_rust(&recipient), crate::lightning::blinded_path::message::MessageContext::native_into(context), local_peers.into()); + 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 create_compact_blinded_paths(&self, mut recipient: bitcoin::secp256k1::PublicKey, mut context: lightning::blinded_path::message::MessageContext, mut peers: Vec, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result, ()> { + let mut local_peers = Vec::new(); for mut item in peers.drain(..) { local_peers.push( { crate::lightning::blinded_path::message::MessageForwardNode { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; + let mut ret = (self.create_compact_blinded_paths)(self.this_arg, crate::c_types::PublicKey::from_rust(&recipient), crate::lightning::blinded_path::message::MessageContext::native_into(context), local_peers.into()); + 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 + } +} + +pub struct MessageRouterRef(MessageRouter); +impl rustMessageRouter for MessageRouterRef { + 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.0.find_path)(self.0.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 + } + fn create_blinded_paths(&self, mut recipient: bitcoin::secp256k1::PublicKey, mut context: lightning::blinded_path::message::MessageContext, mut peers: Vec, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> 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.create_blinded_paths)(self.this_arg, crate::c_types::PublicKey::from_rust(&recipient), local_peers.into()); + let mut ret = (self.0.create_blinded_paths)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&recipient), crate::lightning::blinded_path::message::MessageContext::native_into(context), local_peers.into()); + 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 create_compact_blinded_paths(&self, mut recipient: bitcoin::secp256k1::PublicKey, mut context: lightning::blinded_path::message::MessageContext, mut peers: Vec, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result, ()> { + let mut local_peers = Vec::new(); for mut item in peers.drain(..) { local_peers.push( { crate::lightning::blinded_path::message::MessageForwardNode { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; + let mut ret = (self.0.create_compact_blinded_paths)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&recipient), crate::lightning::blinded_path::message::MessageContext::native_into(context), local_peers.into()); 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 } @@ -223,14 +697,14 @@ impl rustMessageRouter for MessageRouter { // 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 + type Target = MessageRouterRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const MessageRouterRef) } } } impl core::ops::DerefMut for MessageRouter { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut MessageRouterRef { + unsafe { &mut *(self as *mut _ as *mut MessageRouterRef) } } } /// Calls the free function if one is set @@ -248,6 +722,13 @@ use lightning::onion_message::messenger::DefaultMessageRouter as nativeDefaultMe pub(crate) type nativeDefaultMessageRouter = nativeDefaultMessageRouterImport<&'static lightning::routing::gossip::NetworkGraph, crate::lightning::util::logger::Logger, crate::lightning::sign::EntropySource, >; /// A [`MessageRouter`] that can only route to a directly connected [`Destination`]. +/// +/// # Privacy +/// +/// Creating [`BlindedMessagePath`]s may affect privacy since, if a suitable path cannot be found, +/// it will create a one-hop path using the recipient as the introduction node if it is a announced +/// node. Otherwise, there is no way to find a path to the introduction node in order to send a +/// message, and thus an `Err` is returned. #[must_use] #[repr(C)] pub struct DefaultMessageRouter { @@ -263,6 +744,12 @@ pub struct DefaultMessageRouter { pub is_owned: bool, } +impl core::ops::Deref for DefaultMessageRouter { + type Target = nativeDefaultMessageRouter; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for DefaultMessageRouter { } +unsafe impl core::marker::Sync for DefaultMessageRouter { } impl Drop for DefaultMessageRouter { fn drop(&mut self) { if self.is_owned && !<*mut nativeDefaultMessageRouter>::is_null(self.inner) { @@ -293,6 +780,9 @@ impl DefaultMessageRouter { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Creates a [`DefaultMessageRouter`] using the given [`NetworkGraph`]. #[must_use] @@ -321,6 +811,7 @@ pub extern "C" fn DefaultMessageRouter_as_MessageRouter(this_arg: &DefaultMessag free: None, find_path: DefaultMessageRouter_MessageRouter_find_path, create_blinded_paths: DefaultMessageRouter_MessageRouter_create_blinded_paths, + create_compact_blinded_paths: DefaultMessageRouter_MessageRouter_create_compact_blinded_paths, } } @@ -332,10 +823,17 @@ extern "C" fn DefaultMessageRouter_MessageRouter_find_path(this_arg: *const c_vo local_ret } #[must_use] -extern "C" fn DefaultMessageRouter_MessageRouter_create_blinded_paths(this_arg: *const c_void, mut recipient: crate::c_types::PublicKey, mut peers: crate::c_types::derived::CVec_PublicKeyZ) -> crate::c_types::derived::CResult_CVec_BlindedPathZNoneZ { +extern "C" fn DefaultMessageRouter_MessageRouter_create_blinded_paths(this_arg: *const c_void, mut recipient: crate::c_types::PublicKey, mut context: crate::lightning::blinded_path::message::MessageContext, mut peers: crate::c_types::derived::CVec_PublicKeyZ) -> crate::c_types::derived::CResult_CVec_BlindedMessagePathZNoneZ { let mut local_peers = Vec::new(); for mut item in peers.into_rust().drain(..) { local_peers.push( { item.into_rust() }); }; - let mut ret = ::create_blinded_paths(unsafe { &mut *(this_arg as *mut nativeDefaultMessageRouter) }, recipient.into_rust(), local_peers, 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::lightning::blinded_path::BlindedPath { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; local_ret_0.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + let mut ret = ::create_blinded_paths(unsafe { &mut *(this_arg as *mut nativeDefaultMessageRouter) }, recipient.into_rust(), context.into_native(), local_peers, 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::lightning::blinded_path::message::BlindedMessagePath { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; local_ret_0.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} +#[must_use] +extern "C" fn DefaultMessageRouter_MessageRouter_create_compact_blinded_paths(this_arg: *const c_void, mut recipient: crate::c_types::PublicKey, mut context: crate::lightning::blinded_path::message::MessageContext, mut peers: crate::c_types::derived::CVec_MessageForwardNodeZ) -> crate::c_types::derived::CResult_CVec_BlindedMessagePathZNoneZ { + let mut local_peers = Vec::new(); for mut item in peers.into_rust().drain(..) { local_peers.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; + let mut ret = ::create_compact_blinded_paths(unsafe { &mut *(this_arg as *mut nativeDefaultMessageRouter) }, recipient.into_rust(), context.into_native(), local_peers, 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::lightning::blinded_path::message::BlindedMessagePath { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; local_ret_0.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; local_ret } @@ -359,6 +857,12 @@ pub struct OnionMessagePath { pub is_owned: bool, } +impl core::ops::Deref for OnionMessagePath { + type Target = nativeOnionMessagePath; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for OnionMessagePath { } +unsafe impl core::marker::Sync for OnionMessagePath { } impl Drop for OnionMessagePath { fn drop(&mut self) { if self.is_owned && !<*mut nativeOnionMessagePath>::is_null(self.inner) { @@ -389,6 +893,9 @@ impl OnionMessagePath { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Nodes on the path between the sender and the destination. /// @@ -489,7 +996,7 @@ pub enum Destination { crate::c_types::PublicKey), /// We're sending this onion message to a blinded path. BlindedPath( - crate::lightning::blinded_path::BlindedPath), + crate::lightning::blinded_path::message::BlindedMessagePath), } use lightning::onion_message::messenger::Destination as DestinationImport; pub(crate) type nativeDestination = DestinationImport; @@ -540,7 +1047,7 @@ impl Destination { nativeDestination::BlindedPath (ref a, ) => { let mut a_nonref = Clone::clone(a); Destination::BlindedPath ( - crate::lightning::blinded_path::BlindedPath { inner: ObjOps::heap_alloc(a_nonref), is_owned: true }, + crate::lightning::blinded_path::message::BlindedMessagePath { inner: ObjOps::heap_alloc(a_nonref), is_owned: true }, ) }, } @@ -555,7 +1062,7 @@ impl Destination { }, nativeDestination::BlindedPath (mut a, ) => { Destination::BlindedPath ( - crate::lightning::blinded_path::BlindedPath { inner: ObjOps::heap_alloc(a), is_owned: true }, + crate::lightning::blinded_path::message::BlindedMessagePath { inner: ObjOps::heap_alloc(a), is_owned: true }, ) }, } @@ -586,7 +1093,7 @@ pub extern "C" fn Destination_node(a: crate::c_types::PublicKey) -> Destination } #[no_mangle] /// Utility method to constructs a new BlindedPath-variant Destination -pub extern "C" fn Destination_blinded_path(a: crate::lightning::blinded_path::BlindedPath) -> Destination { +pub extern "C" fn Destination_blinded_path(a: crate::lightning::blinded_path::message::BlindedMessagePath) -> Destination { Destination::BlindedPath(a, ) } /// Generates a non-cryptographic 64-bit hash of the Destination. @@ -740,13 +1247,17 @@ pub enum SendError { /// 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. TooBigPacket, - /// The provided [`Destination`] was an invalid [`BlindedPath`] due to not having any blinded - /// hops. + /// The provided [`Destination`] was an invalid [`BlindedMessagePath`] due to not having any + /// blinded hops. TooFewBlindedHops, /// The first hop is not a peer and doesn't have a known [`SocketAddress`]. InvalidFirstHop( crate::c_types::PublicKey), - /// A path from the sender to the destination could not be found by the [`MessageRouter`]. + /// Indicates that a path could not be found by the [`MessageRouter`]. + /// + /// This occurs when either: + /// - No path from the sender to the destination was found to send the onion message + /// - No reply path to the sender could be created when responding to an onion message PathNotFound, /// Onion message contents must have a TLV type >= 64. InvalidMessage, @@ -964,7 +1475,9 @@ pub struct CustomOnionMessageHandler { /// Called with the custom message that was received, returning a response to send, if any. /// /// The returned [`Self::CustomMessage`], if any, is enqueued to be sent by [`OnionMessenger`]. - pub handle_custom_message: extern "C" fn (this_arg: *const c_void, msg: crate::lightning::onion_message::packet::OnionMessageContents) -> crate::c_types::derived::COption_OnionMessageContentsZ, + /// + /// Note that responder (or a relevant inner pointer) may be NULL or all-0s to represent None + pub handle_custom_message: extern "C" fn (this_arg: *const c_void, message: crate::lightning::onion_message::packet::OnionMessageContents, context: crate::c_types::derived::COption_CVec_u8ZZ, responder: crate::lightning::onion_message::messenger::Responder) -> crate::c_types::derived::COption_C2Tuple_OnionMessageContentsResponseInstructionZZ, /// Read a custom message of type `message_type` from `buffer`, returning `Ok(None)` if the /// message type is unknown. 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_OnionMessageContentsZDecodeErrorZ, @@ -972,7 +1485,7 @@ pub struct CustomOnionMessageHandler { /// /// Typically, this is used for messages initiating a message flow rather than in response to /// another message. The latter should use the return value of [`Self::handle_custom_message`]. - pub release_pending_custom_messages: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ, + pub release_pending_custom_messages: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ, /// 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, @@ -993,9 +1506,11 @@ pub(crate) fn CustomOnionMessageHandler_clone_fields(orig: &CustomOnionMessageHa use lightning::onion_message::messenger::CustomOnionMessageHandler as rustCustomOnionMessageHandler; impl rustCustomOnionMessageHandler for CustomOnionMessageHandler { type CustomMessage = crate::lightning::onion_message::packet::OnionMessageContents; - fn handle_custom_message(&self, mut msg: crate::lightning::onion_message::packet::OnionMessageContents) -> 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() } }})} }; + fn handle_custom_message(&self, mut message: crate::lightning::onion_message::packet::OnionMessageContents, mut context: Option>, mut responder: Option) -> Option<(crate::lightning::onion_message::packet::OnionMessageContents, lightning::onion_message::messenger::ResponseInstruction)> { + let mut local_context = if context.is_none() { crate::c_types::derived::COption_CVec_u8ZZ::None } else { crate::c_types::derived::COption_CVec_u8ZZ::Some( { let mut local_context_0 = Vec::new(); for mut item in context.unwrap().drain(..) { local_context_0.push( { item }); }; local_context_0.into() }) }; + let mut local_responder = crate::lightning::onion_message::messenger::Responder { inner: if responder.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((responder.unwrap())) } }, is_owned: true }; + let mut ret = (self.handle_custom_message)(self.this_arg, Into::into(message), local_context, local_responder); + let mut local_ret = if ret.is_some() { Some( { let (mut orig_ret_0_0, mut orig_ret_0_1) = ret.take().to_rust(); let mut local_ret_0 = (orig_ret_0_0, *unsafe { Box::from_raw(orig_ret_0_1.take_inner()) }); local_ret_0 }) } else { None }; local_ret } fn read_custom_message(&self, mut message_type: u64, mut buffer: &mut R) -> Result, lightning::ln::msgs::DecodeError> { @@ -1003,9 +1518,31 @@ impl rustCustomOnionMessageHandler for CustomOnionMessageHandler { let mut local_ret = match ret.result_ok { true => Ok( { let mut local_ret_0 = { /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ let ret_0_opt = (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }); if ret_0_opt.is_none() { None } else { Some({ { { ret_0_opt.take() } }})} }; local_ret_0 }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).into_native() })}; local_ret } - fn release_pending_custom_messages(&self) -> Vec<(crate::lightning::onion_message::packet::OnionMessageContents, lightning::onion_message::messenger::Destination, Option)> { + fn release_pending_custom_messages(&self) -> Vec<(crate::lightning::onion_message::packet::OnionMessageContents, lightning::onion_message::messenger::MessageSendInstructions)> { let mut ret = (self.release_pending_custom_messages)(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, mut orig_ret_0_2) = item.to_rust(); let mut local_orig_ret_0_2 = if orig_ret_0_2.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(orig_ret_0_2.take_inner()) } }) }; let mut local_ret_0 = (orig_ret_0_0, orig_ret_0_1.into_native(), local_orig_ret_0_2); 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_ret_0 = (orig_ret_0_0, orig_ret_0_1.into_native()); local_ret_0 }); }; + local_ret + } +} + +pub struct CustomOnionMessageHandlerRef(CustomOnionMessageHandler); +impl rustCustomOnionMessageHandler for CustomOnionMessageHandlerRef { + type CustomMessage = crate::lightning::onion_message::packet::OnionMessageContents; + fn handle_custom_message(&self, mut message: crate::lightning::onion_message::packet::OnionMessageContents, mut context: Option>, mut responder: Option) -> Option<(crate::lightning::onion_message::packet::OnionMessageContents, lightning::onion_message::messenger::ResponseInstruction)> { + let mut local_context = if context.is_none() { crate::c_types::derived::COption_CVec_u8ZZ::None } else { crate::c_types::derived::COption_CVec_u8ZZ::Some( { let mut local_context_0 = Vec::new(); for mut item in context.unwrap().drain(..) { local_context_0.push( { item }); }; local_context_0.into() }) }; + let mut local_responder = crate::lightning::onion_message::messenger::Responder { inner: if responder.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((responder.unwrap())) } }, is_owned: true }; + let mut ret = (self.0.handle_custom_message)(self.0.this_arg, Into::into(message), local_context, local_responder); + let mut local_ret = if ret.is_some() { Some( { let (mut orig_ret_0_0, mut orig_ret_0_1) = ret.take().to_rust(); let mut local_ret_0 = (orig_ret_0_0, *unsafe { Box::from_raw(orig_ret_0_1.take_inner()) }); local_ret_0 }) } else { None }; + local_ret + } + fn read_custom_message(&self, mut message_type: u64, mut buffer: &mut R) -> Result, lightning::ln::msgs::DecodeError> { + let mut ret = (self.0.read_custom_message)(self.0.this_arg, message_type, crate::c_types::u8slice::from_vec(&crate::c_types::reader_to_vec(buffer))); + let mut local_ret = match ret.result_ok { true => Ok( { let mut local_ret_0 = { /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ let ret_0_opt = (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }); if ret_0_opt.is_none() { None } else { Some({ { { ret_0_opt.take() } }})} }; local_ret_0 }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).into_native() })}; + local_ret + } + fn release_pending_custom_messages(&self) -> Vec<(crate::lightning::onion_message::packet::OnionMessageContents, lightning::onion_message::messenger::MessageSendInstructions)> { + let mut ret = (self.0.release_pending_custom_messages)(self.0.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_ret_0 = (orig_ret_0_0, orig_ret_0_1.into_native()); local_ret_0 }); }; local_ret } } @@ -1013,14 +1550,14 @@ impl rustCustomOnionMessageHandler for CustomOnionMessageHandler { // 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 CustomOnionMessageHandler { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = CustomOnionMessageHandlerRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const CustomOnionMessageHandlerRef) } } } impl core::ops::DerefMut for CustomOnionMessageHandler { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut CustomOnionMessageHandlerRef { + unsafe { &mut *(self as *mut _ as *mut CustomOnionMessageHandlerRef) } } } /// Calls the free function if one is set @@ -1041,17 +1578,15 @@ impl Drop for CustomOnionMessageHandler { pub enum PeeledOnion { /// Forwarded onion, with the next node id and a new onion Forward( - crate::lightning::blinded_path::NextMessageHop, + crate::lightning::blinded_path::message::NextMessageHop, crate::lightning::ln::msgs::OnionMessage), - /// Received onion message, with decrypted contents, path_id, and reply path + /// Received onion message, with decrypted contents, context, and reply path Receive( crate::lightning::onion_message::packet::ParsedOnionMessageContents, + crate::c_types::derived::COption_MessageContextZ, /// /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None - crate::c_types::ThirtyTwoBytes, - /// - /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None - crate::lightning::blinded_path::BlindedPath), + crate::lightning::blinded_path::message::BlindedMessagePath), } use lightning::onion_message::messenger::PeeledOnion as PeeledOnionImport; pub(crate) type nativePeeledOnion = PeeledOnionImport; @@ -1071,7 +1606,7 @@ impl PeeledOnion { PeeledOnion::Receive (ref a, ref b, ref c, ) => { let mut a_nonref = Clone::clone(a); let mut b_nonref = Clone::clone(b); - let mut local_b_nonref = if b_nonref.data == [0; 32] { None } else { Some( { b_nonref.data }) }; + let mut local_b_nonref = { /*b_nonref*/ let b_nonref_opt = b_nonref; if b_nonref_opt.is_none() { None } else { Some({ { { b_nonref_opt.take() }.into_native() }})} }; let mut c_nonref = Clone::clone(c); let mut local_c_nonref = if c_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(c_nonref.take_inner()) } }) }; nativePeeledOnion::Receive ( @@ -1092,7 +1627,7 @@ impl PeeledOnion { ) }, PeeledOnion::Receive (mut a, mut b, mut c, ) => { - let mut local_b = if b.data == [0; 32] { None } else { Some( { b.data }) }; + let mut local_b = { /*b*/ let b_opt = b; if b_opt.is_none() { None } else { Some({ { { b_opt.take() }.into_native() }})} }; let mut local_c = if c.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(c.take_inner()) } }) }; nativePeeledOnion::Receive ( a.into_native(), @@ -1110,16 +1645,16 @@ impl PeeledOnion { let mut a_nonref = Clone::clone(a); let mut b_nonref = Clone::clone(b); PeeledOnion::Forward ( - crate::lightning::blinded_path::NextMessageHop::native_into(a_nonref), + crate::lightning::blinded_path::message::NextMessageHop::native_into(a_nonref), crate::lightning::ln::msgs::OnionMessage { inner: ObjOps::heap_alloc(b_nonref), is_owned: true }, ) }, nativePeeledOnion::Receive (ref a, ref b, ref c, ) => { let mut a_nonref = Clone::clone(a); let mut b_nonref = Clone::clone(b); - let mut local_b_nonref = if b_nonref.is_none() { crate::c_types::ThirtyTwoBytes { data: [0; 32] } } else { { crate::c_types::ThirtyTwoBytes { data: (b_nonref.unwrap()) } } }; + let mut local_b_nonref = if b_nonref.is_none() { crate::c_types::derived::COption_MessageContextZ::None } else { crate::c_types::derived::COption_MessageContextZ::Some( { crate::lightning::blinded_path::message::MessageContext::native_into(b_nonref.unwrap()) }) }; let mut c_nonref = Clone::clone(c); - let mut local_c_nonref = crate::lightning::blinded_path::BlindedPath { inner: if c_nonref.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((c_nonref.unwrap())) } }, is_owned: true }; + let mut local_c_nonref = crate::lightning::blinded_path::message::BlindedMessagePath { inner: if c_nonref.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((c_nonref.unwrap())) } }, is_owned: true }; PeeledOnion::Receive ( crate::lightning::onion_message::packet::ParsedOnionMessageContents::native_into(a_nonref), local_b_nonref, @@ -1133,13 +1668,13 @@ impl PeeledOnion { match native { nativePeeledOnion::Forward (mut a, mut b, ) => { PeeledOnion::Forward ( - crate::lightning::blinded_path::NextMessageHop::native_into(a), + crate::lightning::blinded_path::message::NextMessageHop::native_into(a), crate::lightning::ln::msgs::OnionMessage { inner: ObjOps::heap_alloc(b), is_owned: true }, ) }, nativePeeledOnion::Receive (mut a, mut b, mut c, ) => { - let mut local_b = if b.is_none() { crate::c_types::ThirtyTwoBytes { data: [0; 32] } } else { { crate::c_types::ThirtyTwoBytes { data: (b.unwrap()) } } }; - let mut local_c = crate::lightning::blinded_path::BlindedPath { inner: if c.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((c.unwrap())) } }, is_owned: true }; + let mut local_b = if b.is_none() { crate::c_types::derived::COption_MessageContextZ::None } else { crate::c_types::derived::COption_MessageContextZ::Some( { crate::lightning::blinded_path::message::MessageContext::native_into(b.unwrap()) }) }; + let mut local_c = crate::lightning::blinded_path::message::BlindedMessagePath { inner: if c.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((c.unwrap())) } }, is_owned: true }; PeeledOnion::Receive ( crate::lightning::onion_message::packet::ParsedOnionMessageContents::native_into(a), local_b, @@ -1169,12 +1704,12 @@ pub(crate) extern "C" fn PeeledOnion_free_void(this_ptr: *mut c_void) { } #[no_mangle] /// Utility method to constructs a new Forward-variant PeeledOnion -pub extern "C" fn PeeledOnion_forward(a: crate::lightning::blinded_path::NextMessageHop,b: crate::lightning::ln::msgs::OnionMessage) -> PeeledOnion { +pub extern "C" fn PeeledOnion_forward(a: crate::lightning::blinded_path::message::NextMessageHop,b: crate::lightning::ln::msgs::OnionMessage) -> PeeledOnion { PeeledOnion::Forward(a, b, ) } #[no_mangle] /// Utility method to constructs a new Receive-variant PeeledOnion -pub extern "C" fn PeeledOnion_receive(a: crate::lightning::onion_message::packet::ParsedOnionMessageContents,b: crate::c_types::ThirtyTwoBytes,c: crate::lightning::blinded_path::BlindedPath) -> PeeledOnion { +pub extern "C" fn PeeledOnion_receive(a: crate::lightning::onion_message::packet::ParsedOnionMessageContents,b: crate::c_types::derived::COption_MessageContextZ,c: crate::lightning::blinded_path::message::BlindedMessagePath) -> PeeledOnion { PeeledOnion::Receive(a, b, c, ) } /// Get a string which allows debug introspection of a PeeledOnion object @@ -1189,7 +1724,7 @@ pub extern "C" fn PeeledOnion_debug_str_void(o: *const c_void) -> Str { /// /// Note that reply_path (or a relevant inner pointer) may be NULL or all-0s to represent None #[no_mangle] -pub extern "C" fn create_onion_message_resolving_destination(entropy_source: &crate::lightning::sign::EntropySource, node_signer: &crate::lightning::sign::NodeSigner, node_id_lookup: &crate::lightning::blinded_path::NodeIdLookUp, network_graph: &crate::lightning::routing::gossip::ReadOnlyNetworkGraph, mut path: crate::lightning::onion_message::messenger::OnionMessagePath, mut contents: crate::lightning::onion_message::packet::OnionMessageContents, mut reply_path: crate::lightning::blinded_path::BlindedPath) -> crate::c_types::derived::CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ { +pub extern "C" fn create_onion_message_resolving_destination(entropy_source: &crate::lightning::sign::EntropySource, node_signer: &crate::lightning::sign::NodeSigner, node_id_lookup: &crate::lightning::blinded_path::NodeIdLookUp, network_graph: &crate::lightning::routing::gossip::ReadOnlyNetworkGraph, mut path: crate::lightning::onion_message::messenger::OnionMessagePath, mut contents: crate::lightning::onion_message::packet::OnionMessageContents, mut reply_path: crate::lightning::blinded_path::message::BlindedMessagePath) -> crate::c_types::derived::CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ { 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 = lightning::onion_message::messenger::create_onion_message_resolving_destination::(entropy_source, node_signer, node_id_lookup, network_graph.get_native_ref(), secp256k1::global::SECP256K1, *unsafe { Box::from_raw(path.take_inner()) }, contents, local_reply_path); 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, mut orig_ret_0_2) = o; let mut local_orig_ret_0_2 = if orig_ret_0_2.is_none() { crate::c_types::derived::COption_CVec_SocketAddressZZ::None } else { crate::c_types::derived::COption_CVec_SocketAddressZZ::Some( { let mut local_orig_ret_0_2_0 = Vec::new(); for mut item in orig_ret_0_2.unwrap().drain(..) { local_orig_ret_0_2_0.push( { crate::lightning::ln::msgs::SocketAddress::native_into(item) }); }; local_orig_ret_0_2_0.into() }) }; let mut local_ret_0 = (crate::c_types::PublicKey::from_rust(&orig_ret_0_0), crate::lightning::ln::msgs::OnionMessage { inner: ObjOps::heap_alloc(orig_ret_0_1), is_owned: true }, local_orig_ret_0_2).into(); local_ret_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::onion_message::messenger::SendError::native_into(e) }).into() }; @@ -1210,7 +1745,7 @@ pub extern "C" fn create_onion_message_resolving_destination(entropy_source: &cr /// /// Note that reply_path (or a relevant inner pointer) may be NULL or all-0s to represent None #[no_mangle] -pub extern "C" fn create_onion_message(entropy_source: &crate::lightning::sign::EntropySource, node_signer: &crate::lightning::sign::NodeSigner, node_id_lookup: &crate::lightning::blinded_path::NodeIdLookUp, mut path: crate::lightning::onion_message::messenger::OnionMessagePath, mut contents: crate::lightning::onion_message::packet::OnionMessageContents, mut reply_path: crate::lightning::blinded_path::BlindedPath) -> crate::c_types::derived::CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ { +pub extern "C" fn create_onion_message(entropy_source: &crate::lightning::sign::EntropySource, node_signer: &crate::lightning::sign::NodeSigner, node_id_lookup: &crate::lightning::blinded_path::NodeIdLookUp, mut path: crate::lightning::onion_message::messenger::OnionMessagePath, mut contents: crate::lightning::onion_message::packet::OnionMessageContents, mut reply_path: crate::lightning::blinded_path::message::BlindedMessagePath) -> crate::c_types::derived::CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ { 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 = lightning::onion_message::messenger::create_onion_message::(entropy_source, node_signer, node_id_lookup, secp256k1::global::SECP256K1, *unsafe { Box::from_raw(path.take_inner()) }, contents, local_reply_path); 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, mut orig_ret_0_2) = o; let mut local_orig_ret_0_2 = if orig_ret_0_2.is_none() { crate::c_types::derived::COption_CVec_SocketAddressZZ::None } else { crate::c_types::derived::COption_CVec_SocketAddressZZ::Some( { let mut local_orig_ret_0_2_0 = Vec::new(); for mut item in orig_ret_0_2.unwrap().drain(..) { local_orig_ret_0_2_0.push( { crate::lightning::ln::msgs::SocketAddress::native_into(item) }); }; local_orig_ret_0_2_0.into() }) }; let mut local_ret_0 = (crate::c_types::PublicKey::from_rust(&orig_ret_0_0), crate::lightning::ln::msgs::OnionMessage { inner: ObjOps::heap_alloc(orig_ret_0_1), is_owned: true }, local_orig_ret_0_2).into(); local_ret_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::onion_message::messenger::SendError::native_into(e) }).into() }; @@ -1232,25 +1767,115 @@ pub extern "C" fn peel_onion_message(msg: &crate::lightning::ln::msgs::OnionMess /// their respective handlers. #[must_use] #[no_mangle] -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 node_id_lookup: crate::lightning::blinded_path::NodeIdLookUp, 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, node_id_lookup, message_router, offers_handler, 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 node_id_lookup: crate::lightning::blinded_path::NodeIdLookUp, mut message_router: crate::lightning::onion_message::messenger::MessageRouter, mut offers_handler: crate::lightning::onion_message::offers::OffersMessageHandler, mut async_payments_handler: crate::lightning::onion_message::async_payments::AsyncPaymentsMessageHandler, 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, node_id_lookup, message_router, offers_handler, async_payments_handler, custom_handler); crate::lightning::onion_message::messenger::OnionMessenger { inner: ObjOps::heap_alloc(ret), is_owned: true } } -/// Sends an [`OnionMessage`] with the given `contents` to `destination`. +/// Similar to [`Self::new`], but rather than dropping onion messages that are +/// intended to be forwarded to offline peers, we will intercept them for +/// later forwarding. /// -/// See [`OnionMessenger`] for example usage. +/// Interception flow: +/// 1. If an onion message for an offline peer is received, `OnionMessenger` will +/// generate an [`Event::OnionMessageIntercepted`]. Event handlers can +/// then choose to persist this onion message for later forwarding, or drop +/// it. +/// 2. When the offline peer later comes back online, `OnionMessenger` will +/// generate an [`Event::OnionMessagePeerConnected`]. Event handlers will +/// then fetch all previously intercepted onion messages for this peer. +/// 3. Once the stored onion messages are fetched, they can finally be +/// forwarded to the now-online peer via [`Self::forward_onion_message`]. /// -/// Note that reply_path (or a relevant inner pointer) may be NULL or all-0s to represent None +/// # Note +/// +/// LDK will not rate limit how many [`Event::OnionMessageIntercepted`]s +/// are generated, so it is the caller's responsibility to limit how many +/// onion messages are persisted and only persist onion messages for relevant +/// peers. #[must_use] #[no_mangle] -pub extern "C" fn OnionMessenger_send_onion_message(this_arg: &crate::lightning::onion_message::messenger::OnionMessenger, mut contents: crate::lightning::onion_message::packet::OnionMessageContents, mut destination: crate::lightning::onion_message::messenger::Destination, mut reply_path: crate::lightning::blinded_path::BlindedPath) -> crate::c_types::derived::CResult_SendSuccessSendErrorZ { - 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(contents, destination.into_native(), local_reply_path); +pub extern "C" fn OnionMessenger_new_with_offline_peer_interception(mut entropy_source: crate::lightning::sign::EntropySource, mut node_signer: crate::lightning::sign::NodeSigner, mut logger: crate::lightning::util::logger::Logger, mut node_id_lookup: crate::lightning::blinded_path::NodeIdLookUp, mut message_router: crate::lightning::onion_message::messenger::MessageRouter, mut offers_handler: crate::lightning::onion_message::offers::OffersMessageHandler, mut async_payments_handler: crate::lightning::onion_message::async_payments::AsyncPaymentsMessageHandler, mut custom_handler: crate::lightning::onion_message::messenger::CustomOnionMessageHandler) -> crate::lightning::onion_message::messenger::OnionMessenger { + let mut ret = lightning::onion_message::messenger::OnionMessenger::new_with_offline_peer_interception(entropy_source, node_signer, logger, node_id_lookup, message_router, offers_handler, async_payments_handler, custom_handler); + crate::lightning::onion_message::messenger::OnionMessenger { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Sends an [`OnionMessage`] based on its [`MessageSendInstructions`]. +#[must_use] +#[no_mangle] +pub extern "C" fn OnionMessenger_send_onion_message(this_arg: &crate::lightning::onion_message::messenger::OnionMessenger, mut contents: crate::lightning::onion_message::packet::OnionMessageContents, mut instructions: crate::lightning::onion_message::messenger::MessageSendInstructions) -> crate::c_types::derived::CResult_SendSuccessSendErrorZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.send_onion_message(contents, instructions.into_native()); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::onion_message::messenger::SendSuccess::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::onion_message::messenger::SendError::native_into(e) }).into() }; local_ret } +/// Forwards an [`OnionMessage`] to `peer_node_id`. Useful if we initialized +/// the [`OnionMessenger`] with [`Self::new_with_offline_peer_interception`] +/// and want to forward a previously intercepted onion message to a peer that +/// has just come online. +#[must_use] +#[no_mangle] +pub extern "C" fn OnionMessenger_forward_onion_message(this_arg: &crate::lightning::onion_message::messenger::OnionMessenger, mut message: crate::lightning::ln::msgs::OnionMessage, mut peer_node_id: crate::c_types::PublicKey) -> crate::c_types::derived::CResult_NoneSendErrorZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.forward_onion_message(*unsafe { Box::from_raw(message.take_inner()) }, &peer_node_id.into_rust()); + 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 +} + +/// Handles the response to an [`OnionMessage`] based on its [`ResponseInstruction`], +/// enqueueing any response for sending. +/// +/// This function is useful for asynchronous handling of [`OnionMessage`]s. +/// Handlers have the option to return `None`, indicating that no immediate response should be +/// sent. Then, they can transfer the associated [`Responder`] to another task responsible for +/// generating the response asynchronously. Subsequently, when the response is prepared and +/// ready for sending, that task can invoke this method to enqueue the response for delivery. +#[must_use] +#[no_mangle] +pub extern "C" fn OnionMessenger_handle_onion_message_response(this_arg: &crate::lightning::onion_message::messenger::OnionMessenger, mut response: crate::lightning::onion_message::packet::OnionMessageContents, mut instructions: crate::lightning::onion_message::messenger::ResponseInstruction) -> crate::c_types::derived::CResult_SendSuccessSendErrorZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.handle_onion_message_response(response, *unsafe { Box::from_raw(instructions.take_inner()) }); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::onion_message::messenger::SendSuccess::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::onion_message::messenger::SendError::native_into(e) }).into() }; + local_ret +} + +/// Gets a [`Future`] that completes when an event is available via +/// [`EventsProvider::process_pending_events`] or [`Self::process_pending_events_async`]. +/// +/// Note that callbacks registered on the [`Future`] MUST NOT call back into this +/// [`OnionMessenger`] and should instead register actions to be taken later. +/// +/// [`EventsProvider::process_pending_events`]: crate::events::EventsProvider::process_pending_events +#[must_use] +#[no_mangle] +pub extern "C" fn OnionMessenger_get_update_future(this_arg: &crate::lightning::onion_message::messenger::OnionMessenger) -> crate::lightning::util::wakers::Future { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_update_future(); + crate::lightning::util::wakers::Future { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +impl From for crate::lightning::events::EventsProvider { + fn from(obj: nativeOnionMessenger) -> Self { + let rust_obj = crate::lightning::onion_message::messenger::OnionMessenger { inner: ObjOps::heap_alloc(obj), is_owned: true }; + let mut ret = OnionMessenger_as_EventsProvider(&rust_obj); + // We want to free rust_obj when ret gets drop()'d, not rust_obj, so forget it and set ret's free() fn + core::mem::forget(rust_obj); + ret.free = Some(OnionMessenger_free_void); + ret + } +} +/// 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 +#[no_mangle] +pub extern "C" fn OnionMessenger_as_EventsProvider(this_arg: &OnionMessenger) -> crate::lightning::events::EventsProvider { + crate::lightning::events::EventsProvider { + this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, + free: None, + process_pending_events: OnionMessenger_EventsProvider_process_pending_events, + } +} + +extern "C" fn OnionMessenger_EventsProvider_process_pending_events(this_arg: *const c_void, mut handler: crate::lightning::events::EventHandler) { + ::process_pending_events(unsafe { &mut *(this_arg as *mut nativeOnionMessenger) }, handler) +} + impl From for crate::lightning::ln::msgs::OnionMessageHandler { fn from(obj: nativeOnionMessenger) -> Self { let rust_obj = crate::lightning::onion_message::messenger::OnionMessenger { inner: ObjOps::heap_alloc(obj), is_owned: true }; @@ -1268,7 +1893,6 @@ pub extern "C" fn OnionMessenger_as_OnionMessageHandler(this_arg: &OnionMessenge crate::lightning::ln::msgs::OnionMessageHandler { this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, free: None, - get_and_clear_connections_needed: OnionMessenger_OnionMessageHandler_get_and_clear_connections_needed, handle_onion_message: OnionMessenger_OnionMessageHandler_handle_onion_message, next_onion_message_for_peer: OnionMessenger_OnionMessageHandler_next_onion_message_for_peer, peer_connected: OnionMessenger_OnionMessageHandler_peer_connected, @@ -1279,12 +1903,6 @@ pub extern "C" fn OnionMessenger_as_OnionMessageHandler(this_arg: &OnionMessenge } } -#[must_use] -extern "C" fn OnionMessenger_OnionMessageHandler_get_and_clear_connections_needed(this_arg: *const c_void) -> crate::c_types::derived::CVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ { - let mut ret = ::get_and_clear_connections_needed(unsafe { &mut *(this_arg as *mut nativeOnionMessenger) }, ); - 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( { crate::lightning::ln::msgs::SocketAddress::native_into(item) }); }; let mut local_ret_0 = (crate::c_types::PublicKey::from_rust(&orig_ret_0_0), local_orig_ret_0_1.into()).into(); local_ret_0 }); }; - local_ret.into() -} extern "C" fn OnionMessenger_OnionMessageHandler_handle_onion_message(this_arg: *const c_void, mut peer_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::OnionMessage) { ::handle_onion_message(unsafe { &mut *(this_arg as *mut nativeOnionMessenger) }, &peer_node_id.into_rust(), msg.get_native_ref()) } @@ -1307,13 +1925,13 @@ extern "C" fn OnionMessenger_OnionMessageHandler_timer_tick_occurred(this_arg: * ::timer_tick_occurred(unsafe { &mut *(this_arg as *mut nativeOnionMessenger) }, ) } #[must_use] -extern "C" fn OnionMessenger_OnionMessageHandler_provided_node_features(this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures { +extern "C" fn OnionMessenger_OnionMessageHandler_provided_node_features(this_arg: *const c_void) -> crate::lightning_types::features::NodeFeatures { let mut ret = ::provided_node_features(unsafe { &mut *(this_arg as *mut nativeOnionMessenger) }, ); - crate::lightning::ln::features::NodeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } + crate::lightning_types::features::NodeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } #[must_use] -extern "C" fn OnionMessenger_OnionMessageHandler_provided_init_features(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures { +extern "C" fn OnionMessenger_OnionMessageHandler_provided_init_features(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey) -> crate::lightning_types::features::InitFeatures { let mut ret = ::provided_init_features(unsafe { &mut *(this_arg as *mut nativeOnionMessenger) }, &their_node_id.into_rust()); - crate::lightning::ln::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } + crate::lightning_types::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } diff --git a/lightning-c-bindings/src/lightning/onion_message/mod.rs b/lightning-c-bindings/src/lightning/onion_message/mod.rs index e900a34..f4c9ae5 100644 --- a/lightning-c-bindings/src/lightning/onion_message/mod.rs +++ b/lightning-c-bindings/src/lightning/onion_message/mod.rs @@ -17,7 +17,7 @@ //! information on its usage. //! //! [offers]: -//! [blinded paths]: crate::blinded_path::BlindedPath +//! [blinded paths]: crate::blinded_path::message::BlindedMessagePath //! [`OnionMessenger`]: self::messenger::OnionMessenger use alloc::str::FromStr; @@ -29,6 +29,7 @@ use crate::c_types::*; #[cfg(feature="no-std")] use alloc::{vec::Vec, boxed::Box}; +pub mod async_payments; 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 index 206c887..e99e5fb 100644 --- a/lightning-c-bindings/src/lightning/onion_message/offers.rs +++ b/lightning-c-bindings/src/lightning/onion_message/offers.rs @@ -31,12 +31,14 @@ pub struct OffersMessageHandler { /// The returned [`OffersMessage`], if any, is enqueued to be sent by [`OnionMessenger`]. /// /// [`OnionMessenger`]: crate::onion_message::messenger::OnionMessenger - pub handle_message: extern "C" fn (this_arg: *const c_void, message: crate::lightning::onion_message::offers::OffersMessage) -> crate::c_types::derived::COption_OffersMessageZ, + /// + /// Note that responder (or a relevant inner pointer) may be NULL or all-0s to represent None + pub handle_message: extern "C" fn (this_arg: *const c_void, message: crate::lightning::onion_message::offers::OffersMessage, context: crate::c_types::derived::COption_OffersContextZ, responder: crate::lightning::onion_message::messenger::Responder) -> crate::c_types::derived::COption_C2Tuple_OffersMessageResponseInstructionZZ, /// Releases any [`OffersMessage`]s that need to be sent. /// /// Typically, this is used for messages initiating a payment flow rather than in response to /// another message. The latter should use the return value of [`Self::handle_message`]. - pub release_pending_messages: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_C3Tuple_OffersMessageDestinationBlindedPathZZ, + pub release_pending_messages: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_C2Tuple_OffersMessageMessageSendInstructionsZZ, /// 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, @@ -55,14 +57,32 @@ pub(crate) fn OffersMessageHandler_clone_fields(orig: &OffersMessageHandler) -> 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() }})} }; + fn handle_message(&self, mut message: lightning::onion_message::offers::OffersMessage, mut context: Option, mut responder: Option) -> Option<(lightning::onion_message::offers::OffersMessage, lightning::onion_message::messenger::ResponseInstruction)> { + let mut local_context = if context.is_none() { crate::c_types::derived::COption_OffersContextZ::None } else { crate::c_types::derived::COption_OffersContextZ::Some( { crate::lightning::blinded_path::message::OffersContext::native_into(context.unwrap()) }) }; + let mut local_responder = crate::lightning::onion_message::messenger::Responder { inner: if responder.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((responder.unwrap())) } }, is_owned: true }; + let mut ret = (self.handle_message)(self.this_arg, crate::lightning::onion_message::offers::OffersMessage::native_into(message), local_context, local_responder); + let mut local_ret = if ret.is_some() { Some( { let (mut orig_ret_0_0, mut orig_ret_0_1) = ret.take().to_rust(); let mut local_ret_0 = (orig_ret_0_0.into_native(), *unsafe { Box::from_raw(orig_ret_0_1.take_inner()) }); local_ret_0 }) } else { None }; local_ret } - fn release_pending_messages(&self) -> Vec<(lightning::onion_message::offers::OffersMessage, lightning::onion_message::messenger::Destination, Option)> { + fn release_pending_messages(&self) -> Vec<(lightning::onion_message::offers::OffersMessage, lightning::onion_message::messenger::MessageSendInstructions)> { let mut ret = (self.release_pending_messages)(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, mut orig_ret_0_2) = item.to_rust(); let mut local_orig_ret_0_2 = if orig_ret_0_2.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(orig_ret_0_2.take_inner()) } }) }; let mut local_ret_0 = (orig_ret_0_0.into_native(), orig_ret_0_1.into_native(), local_orig_ret_0_2); 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_ret_0 = (orig_ret_0_0.into_native(), orig_ret_0_1.into_native()); local_ret_0 }); }; + local_ret + } +} + +pub struct OffersMessageHandlerRef(OffersMessageHandler); +impl rustOffersMessageHandler for OffersMessageHandlerRef { + fn handle_message(&self, mut message: lightning::onion_message::offers::OffersMessage, mut context: Option, mut responder: Option) -> Option<(lightning::onion_message::offers::OffersMessage, lightning::onion_message::messenger::ResponseInstruction)> { + let mut local_context = if context.is_none() { crate::c_types::derived::COption_OffersContextZ::None } else { crate::c_types::derived::COption_OffersContextZ::Some( { crate::lightning::blinded_path::message::OffersContext::native_into(context.unwrap()) }) }; + let mut local_responder = crate::lightning::onion_message::messenger::Responder { inner: if responder.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((responder.unwrap())) } }, is_owned: true }; + let mut ret = (self.0.handle_message)(self.0.this_arg, crate::lightning::onion_message::offers::OffersMessage::native_into(message), local_context, local_responder); + let mut local_ret = if ret.is_some() { Some( { let (mut orig_ret_0_0, mut orig_ret_0_1) = ret.take().to_rust(); let mut local_ret_0 = (orig_ret_0_0.into_native(), *unsafe { Box::from_raw(orig_ret_0_1.take_inner()) }); local_ret_0 }) } else { None }; + local_ret + } + fn release_pending_messages(&self) -> Vec<(lightning::onion_message::offers::OffersMessage, lightning::onion_message::messenger::MessageSendInstructions)> { + let mut ret = (self.0.release_pending_messages)(self.0.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_ret_0 = (orig_ret_0_0.into_native(), orig_ret_0_1.into_native()); local_ret_0 }); }; local_ret } } @@ -70,14 +90,14 @@ impl rustOffersMessageHandler for OffersMessageHandler { // 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 + type Target = OffersMessageHandlerRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const OffersMessageHandlerRef) } } } impl core::ops::DerefMut for OffersMessageHandler { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut OffersMessageHandlerRef { + unsafe { &mut *(self as *mut _ as *mut OffersMessageHandlerRef) } } } /// Calls the free function if one is set @@ -265,6 +285,7 @@ pub extern "C" fn OffersMessage_as_OnionMessageContents(this_arg: &OffersMessage this_arg: unsafe { ObjOps::untweak_ptr(this_arg as *const OffersMessage as *mut OffersMessage) as *mut c_void }, free: None, tlv_type: OffersMessage_OnionMessageContents_tlv_type, + msg_type: OffersMessage_OnionMessageContents_msg_type, write: OffersMessage_write_void, debug_str: OffersMessage_debug_str_void, cloned: Some(OnionMessageContents_OffersMessage_cloned), @@ -276,6 +297,11 @@ extern "C" fn OffersMessage_OnionMessageContents_tlv_type(this_arg: *const c_voi let mut ret = ::tlv_type(unsafe { &mut *(this_arg as *mut nativeOffersMessage) }, ); ret } +#[must_use] +extern "C" fn OffersMessage_OnionMessageContents_msg_type(this_arg: *const c_void) -> crate::c_types::Str { + let mut ret = ::msg_type(unsafe { &mut *(this_arg as *mut nativeOffersMessage) }, ); + ret.into() +} extern "C" fn OnionMessageContents_OffersMessage_cloned(new_obj: &mut crate::lightning::onion_message::packet::OnionMessageContents) { new_obj.this_arg = OffersMessage_clone_void(new_obj.this_arg); new_obj.free = Some(OffersMessage_free_void); diff --git a/lightning-c-bindings/src/lightning/onion_message/packet.rs b/lightning-c-bindings/src/lightning/onion_message/packet.rs index 7506842..0288684 100644 --- a/lightning-c-bindings/src/lightning/onion_message/packet.rs +++ b/lightning-c-bindings/src/lightning/onion_message/packet.rs @@ -37,6 +37,12 @@ pub struct Packet { pub is_owned: bool, } +impl core::ops::Deref for Packet { + type Target = nativePacket; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for Packet { } +unsafe impl core::marker::Sync for Packet { } impl Drop for Packet { fn drop(&mut self) { if self.is_owned && !<*mut nativePacket>::is_null(self.inner) { @@ -67,6 +73,9 @@ impl Packet { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Bolt 04 version number #[no_mangle] @@ -147,9 +156,6 @@ pub(crate) extern "C" fn Packet_clone_void(this_ptr: *const c_void) -> *mut c_vo pub extern "C" fn Packet_clone(orig: &Packet) -> Packet { orig.clone() } -/// Get a string which allows debug introspection of a Packet object -pub extern "C" fn Packet_debug_str_void(o: *const c_void) -> Str { - alloc::format!("{:?}", unsafe { o as *const crate::lightning::onion_message::packet::Packet }).into()} /// Generates a non-cryptographic 64-bit hash of the Packet. #[no_mangle] pub extern "C" fn Packet_hash(o: &Packet) -> u64 { @@ -169,6 +175,9 @@ pub extern "C" fn Packet_eq(a: &Packet, b: &Packet) -> bool { if a.inner.is_null() || b.inner.is_null() { return false; } if a.get_native_ref() == b.get_native_ref() { true } else { false } } +/// Get a string which allows debug introspection of a Packet object +pub extern "C" fn Packet_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::onion_message::packet::Packet }).into()} #[no_mangle] /// Serialize the Packet object into a byte array which can be read by Packet_read pub extern "C" fn Packet_write(obj: &crate::lightning::onion_message::packet::Packet) -> crate::c_types::derived::CVec_u8Z { @@ -176,7 +185,7 @@ pub extern "C" fn Packet_write(obj: &crate::lightning::onion_message::packet::Pa } #[allow(unused)] pub(crate) extern "C" fn Packet_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePacket) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::onion_message::packet::nativePacket) }) } /// The contents of an [`OnionMessage`] as read from the wire. /// @@ -311,6 +320,7 @@ pub extern "C" fn ParsedOnionMessageContents_as_OnionMessageContents(this_arg: & this_arg: unsafe { ObjOps::untweak_ptr(this_arg as *const ParsedOnionMessageContents as *mut ParsedOnionMessageContents) as *mut c_void }, free: None, tlv_type: ParsedOnionMessageContents_OnionMessageContents_tlv_type, + msg_type: ParsedOnionMessageContents_OnionMessageContents_msg_type, write: ParsedOnionMessageContents_write_void, debug_str: ParsedOnionMessageContents_debug_str_void, cloned: Some(OnionMessageContents_ParsedOnionMessageContents_cloned), @@ -322,6 +332,11 @@ extern "C" fn ParsedOnionMessageContents_OnionMessageContents_tlv_type(this_arg: let mut ret = ::tlv_type(unsafe { &mut *(this_arg as *mut nativeParsedOnionMessageContents) }, ); ret } +#[must_use] +extern "C" fn ParsedOnionMessageContents_OnionMessageContents_msg_type(this_arg: *const c_void) -> crate::c_types::Str { + let mut ret = ::msg_type(unsafe { &mut *(this_arg as *mut nativeParsedOnionMessageContents) }, ); + ret.into() +} extern "C" fn OnionMessageContents_ParsedOnionMessageContents_cloned(new_obj: &mut crate::lightning::onion_message::packet::OnionMessageContents) { new_obj.this_arg = ParsedOnionMessageContents_clone_void(new_obj.this_arg); new_obj.free = Some(ParsedOnionMessageContents_free_void); @@ -344,6 +359,8 @@ pub struct OnionMessageContents { pub this_arg: *mut c_void, /// Returns the TLV type identifying the message contents. MUST be >= 64. pub tlv_type: extern "C" fn (this_arg: *const c_void) -> u64, + /// Returns the message type + pub msg_type: extern "C" fn (this_arg: *const c_void) -> crate::c_types::Str, /// Serialize the object into a byte array pub write: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_u8Z, /// Return a human-readable "debug" string describing this object @@ -363,6 +380,7 @@ pub(crate) fn OnionMessageContents_clone_fields(orig: &OnionMessageContents) -> OnionMessageContents { this_arg: orig.this_arg, tlv_type: Clone::clone(&orig.tlv_type), + msg_type: Clone::clone(&orig.msg_type), write: Clone::clone(&orig.write), debug_str: Clone::clone(&orig.debug_str), cloned: Clone::clone(&orig.cloned), @@ -375,11 +393,22 @@ impl lightning::util::ser::Writeable for OnionMessageContents { w.write_all(vec.as_slice()) } } +impl lightning::util::ser::Writeable for OnionMessageContentsRef { + fn write(&self, w: &mut W) -> Result<(), crate::c_types::io::Error> { + let vec = (self.0.write)(self.0.this_arg); + w.write_all(vec.as_slice()) + } +} impl core::fmt::Debug for OnionMessageContents { fn fmt(&self, f: &mut core::fmt::Formatter) -> Result<(), core::fmt::Error> { f.write_str((self.debug_str)(self.this_arg).into_str()) } } +impl core::fmt::Debug for OnionMessageContentsRef { + fn fmt(&self, f: &mut core::fmt::Formatter) -> Result<(), core::fmt::Error> { + f.write_str((self.0.debug_str)(self.0.this_arg).into_str()) + } +} #[no_mangle] /// Creates a copy of a OnionMessageContents pub extern "C" fn OnionMessageContents_clone(orig: &OnionMessageContents) -> OnionMessageContents { @@ -392,6 +421,11 @@ impl Clone for OnionMessageContents { OnionMessageContents_clone(self) } } +impl Clone for OnionMessageContentsRef { + fn clone(&self) -> Self { + Self(OnionMessageContents_clone(&self.0)) + } +} use lightning::onion_message::packet::OnionMessageContents as rustOnionMessageContents; impl rustOnionMessageContents for OnionMessageContents { @@ -399,19 +433,35 @@ impl rustOnionMessageContents for OnionMessageContents { let mut ret = (self.tlv_type)(self.this_arg); ret } + fn msg_type(&self) -> String { + let mut ret = (self.msg_type)(self.this_arg); + ret.into_string() + } +} + +pub struct OnionMessageContentsRef(OnionMessageContents); +impl rustOnionMessageContents for OnionMessageContentsRef { + fn tlv_type(&self) -> u64 { + let mut ret = (self.0.tlv_type)(self.0.this_arg); + ret + } + fn msg_type(&self) -> String { + let mut ret = (self.0.msg_type)(self.0.this_arg); + ret.into_string() + } } // 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 OnionMessageContents { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = OnionMessageContentsRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const OnionMessageContentsRef) } } } impl core::ops::DerefMut for OnionMessageContents { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut OnionMessageContentsRef { + unsafe { &mut *(self as *mut _ as *mut OnionMessageContentsRef) } } } /// Calls the free function if one is set diff --git a/lightning-c-bindings/src/lightning/routing/gossip.rs b/lightning-c-bindings/src/lightning/routing/gossip.rs index f199905..39db985 100644 --- a/lightning-c-bindings/src/lightning/routing/gossip.rs +++ b/lightning-c-bindings/src/lightning/routing/gossip.rs @@ -37,6 +37,12 @@ pub struct NodeId { pub is_owned: bool, } +impl core::ops::Deref for NodeId { + type Target = nativeNodeId; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for NodeId { } +unsafe impl core::marker::Sync for NodeId { } impl Drop for NodeId { fn drop(&mut self) { if self.is_owned && !<*mut nativeNodeId>::is_null(self.inner) { @@ -67,6 +73,9 @@ impl NodeId { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } impl Clone for NodeId { fn clone(&self) -> Self { @@ -87,6 +96,15 @@ pub(crate) extern "C" fn NodeId_clone_void(this_ptr: *const c_void) -> *mut c_vo pub extern "C" fn NodeId_clone(orig: &NodeId) -> NodeId { orig.clone() } +/// Checks if two NodeIds 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 NodeId_eq(a: &NodeId, b: &NodeId) -> 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 } +} /// Create a new NodeId from a public key #[must_use] #[no_mangle] @@ -155,7 +173,7 @@ pub extern "C" fn NodeId_write(obj: &crate::lightning::routing::gossip::NodeId) } #[allow(unused)] pub(crate) extern "C" fn NodeId_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeId) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::routing::gossip::nativeNodeId) }) } #[no_mangle] /// Read a NodeId from a byte array, created by NodeId_write @@ -184,6 +202,12 @@ pub struct NetworkGraph { pub is_owned: bool, } +impl core::ops::Deref for NetworkGraph { + type Target = nativeNetworkGraph; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for NetworkGraph { } +unsafe impl core::marker::Sync for NetworkGraph { } impl Drop for NetworkGraph { fn drop(&mut self) { if self.is_owned && !<*mut nativeNetworkGraph>::is_null(self.inner) { @@ -214,6 +238,9 @@ impl NetworkGraph { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } use lightning::routing::gossip::ReadOnlyNetworkGraph as nativeReadOnlyNetworkGraphImport; @@ -235,6 +262,12 @@ pub struct ReadOnlyNetworkGraph { pub is_owned: bool, } +impl core::ops::Deref for ReadOnlyNetworkGraph { + type Target = nativeReadOnlyNetworkGraph; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ReadOnlyNetworkGraph { } +unsafe impl core::marker::Sync for ReadOnlyNetworkGraph { } impl Drop for ReadOnlyNetworkGraph { fn drop(&mut self) { if self.is_owned && !<*mut nativeReadOnlyNetworkGraph>::is_null(self.inner) { @@ -265,6 +298,9 @@ impl ReadOnlyNetworkGraph { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Update to the [`NetworkGraph`] based on payment failure information conveyed via the Onion /// return packet by a node along the route. See [BOLT #4] for details. @@ -274,12 +310,6 @@ impl ReadOnlyNetworkGraph { #[must_use] #[repr(C)] pub enum NetworkUpdate { - /// An error indicating a `channel_update` messages should be applied via - /// [`NetworkGraph::update_channel`]. - ChannelUpdateMessage { - /// The update to apply via [`NetworkGraph::update_channel`]. - msg: crate::lightning::ln::msgs::ChannelUpdate, - }, /// An error indicating that a channel failed to route a payment, which should be applied via /// [`NetworkGraph::channel_failed_permanent`] if permanent. ChannelFailure { @@ -306,12 +336,6 @@ impl NetworkUpdate { #[allow(unused)] pub(crate) fn to_native(&self) -> nativeNetworkUpdate { match self { - NetworkUpdate::ChannelUpdateMessage {ref msg, } => { - let mut msg_nonref = Clone::clone(msg); - nativeNetworkUpdate::ChannelUpdateMessage { - msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, - } - }, NetworkUpdate::ChannelFailure {ref short_channel_id, ref is_permanent, } => { let mut short_channel_id_nonref = Clone::clone(short_channel_id); let mut is_permanent_nonref = Clone::clone(is_permanent); @@ -333,11 +357,6 @@ impl NetworkUpdate { #[allow(unused)] pub(crate) fn into_native(self) -> nativeNetworkUpdate { match self { - NetworkUpdate::ChannelUpdateMessage {mut msg, } => { - nativeNetworkUpdate::ChannelUpdateMessage { - msg: *unsafe { Box::from_raw(msg.take_inner()) }, - } - }, NetworkUpdate::ChannelFailure {mut short_channel_id, mut is_permanent, } => { nativeNetworkUpdate::ChannelFailure { short_channel_id: short_channel_id, @@ -356,12 +375,6 @@ impl NetworkUpdate { pub(crate) fn from_native(native: &NetworkUpdateImport) -> Self { let native = unsafe { &*(native as *const _ as *const c_void as *const nativeNetworkUpdate) }; match native { - nativeNetworkUpdate::ChannelUpdateMessage {ref msg, } => { - let mut msg_nonref = Clone::clone(msg); - NetworkUpdate::ChannelUpdateMessage { - msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, - } - }, nativeNetworkUpdate::ChannelFailure {ref short_channel_id, ref is_permanent, } => { let mut short_channel_id_nonref = Clone::clone(short_channel_id); let mut is_permanent_nonref = Clone::clone(is_permanent); @@ -383,11 +396,6 @@ impl NetworkUpdate { #[allow(unused)] pub(crate) fn native_into(native: nativeNetworkUpdate) -> Self { match native { - nativeNetworkUpdate::ChannelUpdateMessage {mut msg, } => { - NetworkUpdate::ChannelUpdateMessage { - msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(msg), is_owned: true }, - } - }, nativeNetworkUpdate::ChannelFailure {mut short_channel_id, mut is_permanent, } => { NetworkUpdate::ChannelFailure { short_channel_id: short_channel_id, @@ -422,13 +430,6 @@ pub(crate) extern "C" fn NetworkUpdate_free_void(this_ptr: *mut c_void) { let _ = unsafe { Box::from_raw(this_ptr as *mut NetworkUpdate) }; } #[no_mangle] -/// Utility method to constructs a new ChannelUpdateMessage-variant NetworkUpdate -pub extern "C" fn NetworkUpdate_channel_update_message(msg: crate::lightning::ln::msgs::ChannelUpdate) -> NetworkUpdate { - NetworkUpdate::ChannelUpdateMessage { - msg, - } -} -#[no_mangle] /// Utility method to constructs a new ChannelFailure-variant NetworkUpdate pub extern "C" fn NetworkUpdate_channel_failure(short_channel_id: u64, is_permanent: bool) -> NetworkUpdate { NetworkUpdate::ChannelFailure { @@ -493,6 +494,12 @@ pub struct P2PGossipSync { pub is_owned: bool, } +impl core::ops::Deref for P2PGossipSync { + type Target = nativeP2PGossipSync; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for P2PGossipSync { } +unsafe impl core::marker::Sync for P2PGossipSync { } impl Drop for P2PGossipSync { fn drop(&mut self) { if self.is_owned && !<*mut nativeP2PGossipSync>::is_null(self.inner) { @@ -523,6 +530,9 @@ impl P2PGossipSync { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Creates a new tracker of the actual state of the network of channels and nodes, /// assuming an existing [`NetworkGraph`]. @@ -546,8 +556,6 @@ pub extern "C" fn P2PGossipSync_add_utxo_lookup(this_arg: &crate::lightning::rou } /// Handles any network updates originating from [`Event`]s. -/// Note that this will skip applying any [`NetworkUpdate::ChannelUpdateMessage`] to avoid -/// leaking possibly identifying information of the sender to the public network. /// /// [`Event`]: crate::events::Event #[no_mangle] @@ -688,14 +696,14 @@ extern "C" fn P2PGossipSync_RoutingMessageHandler_processing_queue_high(this_arg ret } #[must_use] -extern "C" fn P2PGossipSync_RoutingMessageHandler_provided_node_features(this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures { +extern "C" fn P2PGossipSync_RoutingMessageHandler_provided_node_features(this_arg: *const c_void) -> crate::lightning_types::features::NodeFeatures { let mut ret = ::provided_node_features(unsafe { &mut *(this_arg as *mut nativeP2PGossipSync) }, ); - crate::lightning::ln::features::NodeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } + crate::lightning_types::features::NodeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } #[must_use] -extern "C" fn P2PGossipSync_RoutingMessageHandler_provided_init_features(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures { +extern "C" fn P2PGossipSync_RoutingMessageHandler_provided_init_features(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey) -> crate::lightning_types::features::InitFeatures { let mut ret = ::provided_init_features(unsafe { &mut *(this_arg as *mut nativeP2PGossipSync) }, &their_node_id.into_rust()); - crate::lightning::ln::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } + crate::lightning_types::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } impl From for crate::lightning::events::MessageSendEventsProvider { @@ -746,6 +754,12 @@ pub struct ChannelUpdateInfo { pub is_owned: bool, } +impl core::ops::Deref for ChannelUpdateInfo { + type Target = nativeChannelUpdateInfo; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ChannelUpdateInfo { } +unsafe impl core::marker::Sync for ChannelUpdateInfo { } impl Drop for ChannelUpdateInfo { fn drop(&mut self) { if self.is_owned && !<*mut nativeChannelUpdateInfo>::is_null(self.inner) { @@ -776,41 +790,9 @@ impl ChannelUpdateInfo { self.inner = core::ptr::null_mut(); ret } -} -/// When the last update to the channel direction was issued. -/// Value is opaque, as set in the announcement. -#[no_mangle] -pub extern "C" fn ChannelUpdateInfo_get_last_update(this_ptr: &ChannelUpdateInfo) -> u32 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().last_update; - *inner_val -} -/// When the last update to the channel direction was issued. -/// Value is opaque, as set in the announcement. -#[no_mangle] -pub extern "C" fn ChannelUpdateInfo_set_last_update(this_ptr: &mut ChannelUpdateInfo, mut val: u32) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.last_update = val; -} -/// Whether the channel can be currently used for payments (in this one direction). -#[no_mangle] -pub extern "C" fn ChannelUpdateInfo_get_enabled(this_ptr: &ChannelUpdateInfo) -> bool { - let mut inner_val = &mut this_ptr.get_native_mut_ref().enabled; - *inner_val -} -/// Whether the channel can be currently used for payments (in this one direction). -#[no_mangle] -pub extern "C" fn ChannelUpdateInfo_set_enabled(this_ptr: &mut ChannelUpdateInfo, mut val: bool) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.enabled = val; -} -/// The difference in CLTV values that you must have when routing through this channel. -#[no_mangle] -pub extern "C" fn ChannelUpdateInfo_get_cltv_expiry_delta(this_ptr: &ChannelUpdateInfo) -> u16 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta; - *inner_val -} -/// The difference in CLTV values that you must have when routing through this channel. -#[no_mangle] -pub extern "C" fn ChannelUpdateInfo_set_cltv_expiry_delta(this_ptr: &mut ChannelUpdateInfo, mut val: u16) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val; + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The minimum value, which must be relayed to the next hop via the channel #[no_mangle] @@ -836,15 +818,50 @@ pub extern "C" fn ChannelUpdateInfo_set_htlc_maximum_msat(this_ptr: &mut Channel } /// Fees charged when the channel is used for routing #[no_mangle] -pub extern "C" fn ChannelUpdateInfo_get_fees(this_ptr: &ChannelUpdateInfo) -> crate::lightning::routing::gossip::RoutingFees { +pub extern "C" fn ChannelUpdateInfo_get_fees(this_ptr: &ChannelUpdateInfo) -> crate::lightning_types::routing::RoutingFees { let mut inner_val = &mut this_ptr.get_native_mut_ref().fees; - crate::lightning::routing::gossip::RoutingFees { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::routing::gossip::RoutingFees<>) as *mut _) }, is_owned: false } + crate::lightning_types::routing::RoutingFees { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning_types::routing::RoutingFees<>) as *mut _) }, is_owned: false } } /// Fees charged when the channel is used for routing #[no_mangle] -pub extern "C" fn ChannelUpdateInfo_set_fees(this_ptr: &mut ChannelUpdateInfo, mut val: crate::lightning::routing::gossip::RoutingFees) { +pub extern "C" fn ChannelUpdateInfo_set_fees(this_ptr: &mut ChannelUpdateInfo, mut val: crate::lightning_types::routing::RoutingFees) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fees = *unsafe { Box::from_raw(val.take_inner()) }; } +/// When the last update to the channel direction was issued. +/// Value is opaque, as set in the announcement. +#[no_mangle] +pub extern "C" fn ChannelUpdateInfo_get_last_update(this_ptr: &ChannelUpdateInfo) -> u32 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().last_update; + *inner_val +} +/// When the last update to the channel direction was issued. +/// Value is opaque, as set in the announcement. +#[no_mangle] +pub extern "C" fn ChannelUpdateInfo_set_last_update(this_ptr: &mut ChannelUpdateInfo, mut val: u32) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.last_update = val; +} +/// The difference in CLTV values that you must have when routing through this channel. +#[no_mangle] +pub extern "C" fn ChannelUpdateInfo_get_cltv_expiry_delta(this_ptr: &ChannelUpdateInfo) -> u16 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta; + *inner_val +} +/// The difference in CLTV values that you must have when routing through this channel. +#[no_mangle] +pub extern "C" fn ChannelUpdateInfo_set_cltv_expiry_delta(this_ptr: &mut ChannelUpdateInfo, mut val: u16) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val; +} +/// Whether the channel can be currently used for payments (in this one direction). +#[no_mangle] +pub extern "C" fn ChannelUpdateInfo_get_enabled(this_ptr: &ChannelUpdateInfo) -> bool { + let mut inner_val = &mut this_ptr.get_native_mut_ref().enabled; + *inner_val +} +/// Whether the channel can be currently used for payments (in this one direction). +#[no_mangle] +pub extern "C" fn ChannelUpdateInfo_set_enabled(this_ptr: &mut ChannelUpdateInfo, mut val: bool) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.enabled = val; +} /// 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. @@ -873,15 +890,15 @@ pub extern "C" fn ChannelUpdateInfo_set_last_update_message(this_ptr: &mut Chann /// Note that last_update_message_arg (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn ChannelUpdateInfo_new(mut last_update_arg: u32, mut enabled_arg: bool, mut cltv_expiry_delta_arg: u16, mut htlc_minimum_msat_arg: u64, mut htlc_maximum_msat_arg: u64, mut fees_arg: crate::lightning::routing::gossip::RoutingFees, mut last_update_message_arg: crate::lightning::ln::msgs::ChannelUpdate) -> ChannelUpdateInfo { +pub extern "C" fn ChannelUpdateInfo_new(mut htlc_minimum_msat_arg: u64, mut htlc_maximum_msat_arg: u64, mut fees_arg: crate::lightning_types::routing::RoutingFees, mut last_update_arg: u32, mut cltv_expiry_delta_arg: u16, mut enabled_arg: bool, mut last_update_message_arg: crate::lightning::ln::msgs::ChannelUpdate) -> ChannelUpdateInfo { let mut local_last_update_message_arg = if last_update_message_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(last_update_message_arg.take_inner()) } }) }; ChannelUpdateInfo { inner: ObjOps::heap_alloc(nativeChannelUpdateInfo { - last_update: last_update_arg, - enabled: enabled_arg, - cltv_expiry_delta: cltv_expiry_delta_arg, htlc_minimum_msat: htlc_minimum_msat_arg, htlc_maximum_msat: htlc_maximum_msat_arg, fees: *unsafe { Box::from_raw(fees_arg.take_inner()) }, + last_update: last_update_arg, + cltv_expiry_delta: cltv_expiry_delta_arg, + enabled: enabled_arg, last_update_message: local_last_update_message_arg, }), is_owned: true } } @@ -928,7 +945,7 @@ pub extern "C" fn ChannelUpdateInfo_write(obj: &crate::lightning::routing::gossi } #[allow(unused)] pub(crate) extern "C" fn ChannelUpdateInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelUpdateInfo) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::routing::gossip::nativeChannelUpdateInfo) }) } #[no_mangle] /// Read a ChannelUpdateInfo from a byte array, created by ChannelUpdateInfo_write @@ -958,6 +975,12 @@ pub struct ChannelInfo { pub is_owned: bool, } +impl core::ops::Deref for ChannelInfo { + type Target = nativeChannelInfo; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ChannelInfo { } +unsafe impl core::marker::Sync for ChannelInfo { } impl Drop for ChannelInfo { fn drop(&mut self) { if self.is_owned && !<*mut nativeChannelInfo>::is_null(self.inner) { @@ -988,16 +1011,19 @@ impl ChannelInfo { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Protocol features of a channel communicated during its announcement #[no_mangle] -pub extern "C" fn ChannelInfo_get_features(this_ptr: &ChannelInfo) -> crate::lightning::ln::features::ChannelFeatures { +pub extern "C" fn ChannelInfo_get_features(this_ptr: &ChannelInfo) -> crate::lightning_types::features::ChannelFeatures { let mut inner_val = &mut this_ptr.get_native_mut_ref().features; - crate::lightning::ln::features::ChannelFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::features::ChannelFeatures<>) as *mut _) }, is_owned: false } + crate::lightning_types::features::ChannelFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning_types::features::ChannelFeatures<>) as *mut _) }, is_owned: false } } /// Protocol features of a channel communicated during its announcement #[no_mangle] -pub extern "C" fn ChannelInfo_set_features(this_ptr: &mut ChannelInfo, mut val: crate::lightning::ln::features::ChannelFeatures) { +pub extern "C" fn ChannelInfo_set_features(this_ptr: &mut ChannelInfo, mut val: crate::lightning_types::features::ChannelFeatures) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) }; } /// Source node of the first direction of a channel @@ -1011,6 +1037,30 @@ pub extern "C" fn ChannelInfo_get_node_one(this_ptr: &ChannelInfo) -> crate::lig pub extern "C" fn ChannelInfo_set_node_one(this_ptr: &mut ChannelInfo, mut val: crate::lightning::routing::gossip::NodeId) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_one = *unsafe { Box::from_raw(val.take_inner()) }; } +/// Source node of the second direction of a channel +#[no_mangle] +pub extern "C" fn ChannelInfo_get_node_two(this_ptr: &ChannelInfo) -> crate::lightning::routing::gossip::NodeId { + let mut inner_val = &mut this_ptr.get_native_mut_ref().node_two; + crate::lightning::routing::gossip::NodeId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::routing::gossip::NodeId<>) as *mut _) }, is_owned: false } +} +/// Source node of the second direction of a channel +#[no_mangle] +pub extern "C" fn ChannelInfo_set_node_two(this_ptr: &mut ChannelInfo, mut val: crate::lightning::routing::gossip::NodeId) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_two = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// The channel capacity as seen on-chain, if chain lookup is available. +#[no_mangle] +pub extern "C" fn ChannelInfo_get_capacity_sats(this_ptr: &ChannelInfo) -> crate::c_types::derived::COption_u64Z { + let mut inner_val = &mut this_ptr.get_native_mut_ref().capacity_sats; + 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 channel capacity as seen on-chain, if chain lookup is available. +#[no_mangle] +pub extern "C" fn ChannelInfo_set_capacity_sats(this_ptr: &mut ChannelInfo, 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) }.capacity_sats = local_val; +} /// 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 @@ -1028,17 +1078,6 @@ pub extern "C" fn ChannelInfo_set_one_to_two(this_ptr: &mut ChannelInfo, mut val 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) }.one_to_two = local_val; } -/// Source node of the second direction of a channel -#[no_mangle] -pub extern "C" fn ChannelInfo_get_node_two(this_ptr: &ChannelInfo) -> crate::lightning::routing::gossip::NodeId { - let mut inner_val = &mut this_ptr.get_native_mut_ref().node_two; - crate::lightning::routing::gossip::NodeId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::routing::gossip::NodeId<>) as *mut _) }, is_owned: false } -} -/// Source node of the second direction of a channel -#[no_mangle] -pub extern "C" fn ChannelInfo_set_node_two(this_ptr: &mut ChannelInfo, mut val: crate::lightning::routing::gossip::NodeId) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_two = *unsafe { Box::from_raw(val.take_inner()) }; -} /// 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 @@ -1056,19 +1095,6 @@ pub extern "C" fn ChannelInfo_set_two_to_one(this_ptr: &mut ChannelInfo, mut val 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) }.two_to_one = local_val; } -/// The channel capacity as seen on-chain, if chain lookup is available. -#[no_mangle] -pub extern "C" fn ChannelInfo_get_capacity_sats(this_ptr: &ChannelInfo) -> crate::c_types::derived::COption_u64Z { - let mut inner_val = &mut this_ptr.get_native_mut_ref().capacity_sats; - 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 channel capacity as seen on-chain, if chain lookup is available. -#[no_mangle] -pub extern "C" fn ChannelInfo_set_capacity_sats(this_ptr: &mut ChannelInfo, 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) }.capacity_sats = local_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. @@ -1146,7 +1172,7 @@ pub extern "C" fn ChannelInfo_write(obj: &crate::lightning::routing::gossip::Cha } #[allow(unused)] pub(crate) extern "C" fn ChannelInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelInfo) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::routing::gossip::nativeChannelInfo) }) } #[no_mangle] /// Read a ChannelInfo from a byte array, created by ChannelInfo_write @@ -1176,6 +1202,12 @@ pub struct DirectedChannelInfo { pub is_owned: bool, } +impl core::ops::Deref for DirectedChannelInfo { + type Target = nativeDirectedChannelInfo; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for DirectedChannelInfo { } +unsafe impl core::marker::Sync for DirectedChannelInfo { } impl Drop for DirectedChannelInfo { fn drop(&mut self) { if self.is_owned && !<*mut nativeDirectedChannelInfo>::is_null(self.inner) { @@ -1206,6 +1238,9 @@ impl DirectedChannelInfo { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } impl Clone for DirectedChannelInfo { fn clone(&self) -> Self { @@ -1507,160 +1542,35 @@ pub extern "C" fn EffectiveCapacity_as_msat(this_arg: &crate::lightning::routing ret } - -use lightning::routing::gossip::RoutingFees as nativeRoutingFeesImport; -pub(crate) type nativeRoutingFees = nativeRoutingFeesImport; - -/// Fees for routing via a given channel or a node -#[must_use] -#[repr(C)] -pub struct RoutingFees { - /// A pointer to the opaque Rust object. - - /// Nearly everywhere, 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 nativeRoutingFees, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust 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 RoutingFees { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeRoutingFees>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; - } - } -} -/// Frees any resources used by the RoutingFees, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn RoutingFees_free(this_obj: RoutingFees) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn RoutingFees_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeRoutingFees) }; -} -#[allow(unused)] -impl RoutingFees { - pub(crate) fn get_native_ref(&self) -> &'static nativeRoutingFees { - unsafe { &*ObjOps::untweak_ptr(self.inner) } - } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeRoutingFees { - 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 nativeRoutingFees { - assert!(self.is_owned); - let ret = ObjOps::untweak_ptr(self.inner); - self.inner = core::ptr::null_mut(); - ret - } -} -/// Flat routing fee in millisatoshis. -#[no_mangle] -pub extern "C" fn RoutingFees_get_base_msat(this_ptr: &RoutingFees) -> u32 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().base_msat; - *inner_val -} -/// Flat routing fee in millisatoshis. -#[no_mangle] -pub extern "C" fn RoutingFees_set_base_msat(this_ptr: &mut RoutingFees, mut val: u32) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.base_msat = val; -} -/// Liquidity-based routing fee in millionths of a routed amount. -/// In other words, 10000 is 1%. -#[no_mangle] -pub extern "C" fn RoutingFees_get_proportional_millionths(this_ptr: &RoutingFees) -> u32 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().proportional_millionths; - *inner_val -} -/// Liquidity-based routing fee in millionths of a routed amount. -/// In other words, 10000 is 1%. -#[no_mangle] -pub extern "C" fn RoutingFees_set_proportional_millionths(this_ptr: &mut RoutingFees, mut val: u32) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.proportional_millionths = val; -} -/// Constructs a new RoutingFees given each field -#[must_use] -#[no_mangle] -pub extern "C" fn RoutingFees_new(mut base_msat_arg: u32, mut proportional_millionths_arg: u32) -> RoutingFees { - RoutingFees { inner: ObjOps::heap_alloc(nativeRoutingFees { - base_msat: base_msat_arg, - proportional_millionths: proportional_millionths_arg, - }), is_owned: true } -} -/// 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. -#[no_mangle] -pub extern "C" fn RoutingFees_eq(a: &RoutingFees, b: &RoutingFees) -> 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 RoutingFees { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeRoutingFees>::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 RoutingFees_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeRoutingFees)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the RoutingFees -pub extern "C" fn RoutingFees_clone(orig: &RoutingFees) -> RoutingFees { - orig.clone() -} -/// Get a string which allows debug introspection of a RoutingFees object -pub extern "C" fn RoutingFees_debug_str_void(o: *const c_void) -> Str { - alloc::format!("{:?}", unsafe { o as *const crate::lightning::routing::gossip::RoutingFees }).into()} -/// Generates a non-cryptographic 64-bit hash of the RoutingFees. -#[no_mangle] -pub extern "C" fn RoutingFees_hash(o: &RoutingFees) -> 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) -} #[no_mangle] /// Serialize the RoutingFees object into a byte array which can be read by RoutingFees_read -pub extern "C" fn RoutingFees_write(obj: &crate::lightning::routing::gossip::RoutingFees) -> crate::c_types::derived::CVec_u8Z { +pub extern "C" fn RoutingFees_write(obj: &crate::lightning_types::routing::RoutingFees) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) } #[allow(unused)] pub(crate) extern "C" fn RoutingFees_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRoutingFees) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning_types::routing::nativeRoutingFees) }) } #[no_mangle] /// Read a RoutingFees from a byte array, created by RoutingFees_write pub extern "C" fn RoutingFees_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RoutingFeesDecodeErrorZ { - 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::routing::gossip::RoutingFees { 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() }; + 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_types::routing::RoutingFees { 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::routing::gossip::NodeAnnouncementInfo as nativeNodeAnnouncementInfoImport; -pub(crate) type nativeNodeAnnouncementInfo = nativeNodeAnnouncementInfoImport; +use lightning::routing::gossip::NodeAnnouncementDetails as nativeNodeAnnouncementDetailsImport; +pub(crate) type nativeNodeAnnouncementDetails = nativeNodeAnnouncementDetailsImport; -/// Information received in the latest node_announcement from this node. +/// Non-relayable information received in the latest node_announcement from this node. #[must_use] #[repr(C)] -pub struct NodeAnnouncementInfo { +pub struct NodeAnnouncementDetails { /// A pointer to the opaque Rust object. /// Nearly everywhere, 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 nativeNodeAnnouncementInfo, + pub inner: *mut nativeNodeAnnouncementDetails, /// Indicates that this is the only struct which contains the same pointer. /// Rust functions which take ownership of an object provided via an argument require @@ -1668,77 +1578,86 @@ pub struct NodeAnnouncementInfo { pub is_owned: bool, } -impl Drop for NodeAnnouncementInfo { +impl core::ops::Deref for NodeAnnouncementDetails { + type Target = nativeNodeAnnouncementDetails; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for NodeAnnouncementDetails { } +unsafe impl core::marker::Sync for NodeAnnouncementDetails { } +impl Drop for NodeAnnouncementDetails { fn drop(&mut self) { - if self.is_owned && !<*mut nativeNodeAnnouncementInfo>::is_null(self.inner) { + if self.is_owned && !<*mut nativeNodeAnnouncementDetails>::is_null(self.inner) { let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; } } } -/// Frees any resources used by the NodeAnnouncementInfo, if is_owned is set and inner is non-NULL. +/// Frees any resources used by the NodeAnnouncementDetails, if is_owned is set and inner is non-NULL. #[no_mangle] -pub extern "C" fn NodeAnnouncementInfo_free(this_obj: NodeAnnouncementInfo) { } +pub extern "C" fn NodeAnnouncementDetails_free(this_obj: NodeAnnouncementDetails) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn NodeAnnouncementInfo_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeNodeAnnouncementInfo) }; +pub(crate) extern "C" fn NodeAnnouncementDetails_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeNodeAnnouncementDetails) }; } #[allow(unused)] -impl NodeAnnouncementInfo { - pub(crate) fn get_native_ref(&self) -> &'static nativeNodeAnnouncementInfo { +impl NodeAnnouncementDetails { + pub(crate) fn get_native_ref(&self) -> &'static nativeNodeAnnouncementDetails { unsafe { &*ObjOps::untweak_ptr(self.inner) } } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeNodeAnnouncementInfo { + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeNodeAnnouncementDetails { 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 nativeNodeAnnouncementInfo { + pub(crate) fn take_inner(mut self) -> *mut nativeNodeAnnouncementDetails { assert!(self.is_owned); let ret = ObjOps::untweak_ptr(self.inner); self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Protocol features the node announced support for #[no_mangle] -pub extern "C" fn NodeAnnouncementInfo_get_features(this_ptr: &NodeAnnouncementInfo) -> crate::lightning::ln::features::NodeFeatures { +pub extern "C" fn NodeAnnouncementDetails_get_features(this_ptr: &NodeAnnouncementDetails) -> crate::lightning_types::features::NodeFeatures { let mut inner_val = &mut this_ptr.get_native_mut_ref().features; - crate::lightning::ln::features::NodeFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::features::NodeFeatures<>) as *mut _) }, is_owned: false } + crate::lightning_types::features::NodeFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning_types::features::NodeFeatures<>) as *mut _) }, is_owned: false } } /// Protocol features the node announced support for #[no_mangle] -pub extern "C" fn NodeAnnouncementInfo_set_features(this_ptr: &mut NodeAnnouncementInfo, mut val: crate::lightning::ln::features::NodeFeatures) { +pub extern "C" fn NodeAnnouncementDetails_set_features(this_ptr: &mut NodeAnnouncementDetails, mut val: crate::lightning_types::features::NodeFeatures) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) }; } /// When the last known update to the node state was issued. /// Value is opaque, as set in the announcement. #[no_mangle] -pub extern "C" fn NodeAnnouncementInfo_get_last_update(this_ptr: &NodeAnnouncementInfo) -> u32 { +pub extern "C" fn NodeAnnouncementDetails_get_last_update(this_ptr: &NodeAnnouncementDetails) -> u32 { let mut inner_val = &mut this_ptr.get_native_mut_ref().last_update; *inner_val } /// When the last known update to the node state was issued. /// Value is opaque, as set in the announcement. #[no_mangle] -pub extern "C" fn NodeAnnouncementInfo_set_last_update(this_ptr: &mut NodeAnnouncementInfo, mut val: u32) { +pub extern "C" fn NodeAnnouncementDetails_set_last_update(this_ptr: &mut NodeAnnouncementDetails, mut val: u32) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.last_update = val; } /// Color assigned to the node #[no_mangle] -pub extern "C" fn NodeAnnouncementInfo_get_rgb(this_ptr: &NodeAnnouncementInfo) -> *const [u8; 3] { +pub extern "C" fn NodeAnnouncementDetails_get_rgb(this_ptr: &NodeAnnouncementDetails) -> *const [u8; 3] { let mut inner_val = &mut this_ptr.get_native_mut_ref().rgb; inner_val } /// Color assigned to the node #[no_mangle] -pub extern "C" fn NodeAnnouncementInfo_set_rgb(this_ptr: &mut NodeAnnouncementInfo, mut val: crate::c_types::ThreeBytes) { +pub extern "C" fn NodeAnnouncementDetails_set_rgb(this_ptr: &mut NodeAnnouncementDetails, mut val: crate::c_types::ThreeBytes) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.rgb = val.data; } /// Moniker assigned to the node. /// May be invalid or malicious (eg control chars), /// should not be exposed to the user. #[no_mangle] -pub extern "C" fn NodeAnnouncementInfo_get_alias(this_ptr: &NodeAnnouncementInfo) -> crate::lightning::routing::gossip::NodeAlias { +pub extern "C" fn NodeAnnouncementDetails_get_alias(this_ptr: &NodeAnnouncementDetails) -> crate::lightning::routing::gossip::NodeAlias { let mut inner_val = &mut this_ptr.get_native_mut_ref().alias; crate::lightning::routing::gossip::NodeAlias { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::routing::gossip::NodeAlias<>) as *mut _) }, is_owned: false } } @@ -1746,51 +1665,41 @@ pub extern "C" fn NodeAnnouncementInfo_get_alias(this_ptr: &NodeAnnouncementInfo /// May be invalid or malicious (eg control chars), /// should not be exposed to the user. #[no_mangle] -pub extern "C" fn NodeAnnouncementInfo_set_alias(this_ptr: &mut NodeAnnouncementInfo, mut val: crate::lightning::routing::gossip::NodeAlias) { +pub extern "C" fn NodeAnnouncementDetails_set_alias(this_ptr: &mut NodeAnnouncementDetails, mut val: crate::lightning::routing::gossip::NodeAlias) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.alias = *unsafe { Box::from_raw(val.take_inner()) }; } -/// 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. +/// Internet-level addresses via which one can connect to the node /// -/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None +/// Returns a copy of the field. #[no_mangle] -pub extern "C" fn NodeAnnouncementInfo_get_announcement_message(this_ptr: &NodeAnnouncementInfo) -> crate::lightning::ln::msgs::NodeAnnouncement { - let mut inner_val = &mut this_ptr.get_native_mut_ref().announcement_message; - let mut local_inner_val = crate::lightning::ln::msgs::NodeAnnouncement { 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::msgs::NodeAnnouncement<>) as *mut _ }, is_owned: false }; - local_inner_val +pub extern "C" fn NodeAnnouncementDetails_get_addresses(this_ptr: &NodeAnnouncementDetails) -> crate::c_types::derived::CVec_SocketAddressZ { + let mut inner_val = this_ptr.get_native_mut_ref().addresses.clone(); + let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { crate::lightning::ln::msgs::SocketAddress::native_into(item) }); }; + local_inner_val.into() } -/// 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 +/// Internet-level addresses via which one can connect to the node #[no_mangle] -pub extern "C" fn NodeAnnouncementInfo_set_announcement_message(this_ptr: &mut NodeAnnouncementInfo, mut val: crate::lightning::ln::msgs::NodeAnnouncement) { - 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) }.announcement_message = local_val; +pub extern "C" fn NodeAnnouncementDetails_set_addresses(this_ptr: &mut NodeAnnouncementDetails, mut val: crate::c_types::derived::CVec_SocketAddressZ) { + let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_native() }); }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.addresses = local_val; } -/// Constructs a new NodeAnnouncementInfo given each field -/// -/// Note that announcement_message_arg (or a relevant inner pointer) may be NULL or all-0s to represent None +/// Constructs a new NodeAnnouncementDetails given each field #[must_use] #[no_mangle] -pub extern "C" fn NodeAnnouncementInfo_new(mut features_arg: crate::lightning::ln::features::NodeFeatures, mut last_update_arg: u32, mut rgb_arg: crate::c_types::ThreeBytes, mut alias_arg: crate::lightning::routing::gossip::NodeAlias, mut announcement_message_arg: crate::lightning::ln::msgs::NodeAnnouncement) -> NodeAnnouncementInfo { - let mut local_announcement_message_arg = if announcement_message_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(announcement_message_arg.take_inner()) } }) }; - NodeAnnouncementInfo { inner: ObjOps::heap_alloc(nativeNodeAnnouncementInfo { +pub extern "C" fn NodeAnnouncementDetails_new(mut features_arg: crate::lightning_types::features::NodeFeatures, mut last_update_arg: u32, mut rgb_arg: crate::c_types::ThreeBytes, mut alias_arg: crate::lightning::routing::gossip::NodeAlias, mut addresses_arg: crate::c_types::derived::CVec_SocketAddressZ) -> NodeAnnouncementDetails { + let mut local_addresses_arg = Vec::new(); for mut item in addresses_arg.into_rust().drain(..) { local_addresses_arg.push( { item.into_native() }); }; + NodeAnnouncementDetails { inner: ObjOps::heap_alloc(nativeNodeAnnouncementDetails { features: *unsafe { Box::from_raw(features_arg.take_inner()) }, last_update: last_update_arg, rgb: rgb_arg.data, alias: *unsafe { Box::from_raw(alias_arg.take_inner()) }, - announcement_message: local_announcement_message_arg, + addresses: local_addresses_arg, }), is_owned: true } } -impl Clone for NodeAnnouncementInfo { +impl Clone for NodeAnnouncementDetails { fn clone(&self) -> Self { Self { - inner: if <*mut nativeNodeAnnouncementInfo>::is_null(self.inner) { core::ptr::null_mut() } else { + inner: if <*mut nativeNodeAnnouncementDetails>::is_null(self.inner) { core::ptr::null_mut() } else { ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, is_owned: true, } @@ -1798,49 +1707,219 @@ impl Clone for NodeAnnouncementInfo { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn NodeAnnouncementInfo_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeNodeAnnouncementInfo)).clone() })) as *mut c_void +pub(crate) extern "C" fn NodeAnnouncementDetails_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeNodeAnnouncementDetails)).clone() })) as *mut c_void } #[no_mangle] +/// Creates a copy of the NodeAnnouncementDetails +pub extern "C" fn NodeAnnouncementDetails_clone(orig: &NodeAnnouncementDetails) -> NodeAnnouncementDetails { + orig.clone() +} +/// Get a string which allows debug introspection of a NodeAnnouncementDetails object +pub extern "C" fn NodeAnnouncementDetails_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::routing::gossip::NodeAnnouncementDetails }).into()} +/// Checks if two NodeAnnouncementDetailss 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 NodeAnnouncementDetails_eq(a: &NodeAnnouncementDetails, b: &NodeAnnouncementDetails) -> 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 } +} +/// Information received in the latest node_announcement from this node. +#[derive(Clone)] +#[must_use] +#[repr(C)] +pub enum NodeAnnouncementInfo { + /// An initial announcement of the node + /// Everything else is useful only for sending out for initial routing sync. + /// Not stored if contains excess data to prevent DoS. + Relayed( + crate::lightning::ln::msgs::NodeAnnouncement), + /// Non-relayable information received in the latest node_announcement from this node. + Local( + crate::lightning::routing::gossip::NodeAnnouncementDetails), +} +use lightning::routing::gossip::NodeAnnouncementInfo as NodeAnnouncementInfoImport; +pub(crate) type nativeNodeAnnouncementInfo = NodeAnnouncementInfoImport; + +impl NodeAnnouncementInfo { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeNodeAnnouncementInfo { + match self { + NodeAnnouncementInfo::Relayed (ref a, ) => { + let mut a_nonref = Clone::clone(a); + nativeNodeAnnouncementInfo::Relayed ( + *unsafe { Box::from_raw(a_nonref.take_inner()) }, + ) + }, + NodeAnnouncementInfo::Local (ref a, ) => { + let mut a_nonref = Clone::clone(a); + nativeNodeAnnouncementInfo::Local ( + *unsafe { Box::from_raw(a_nonref.take_inner()) }, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeNodeAnnouncementInfo { + match self { + NodeAnnouncementInfo::Relayed (mut a, ) => { + nativeNodeAnnouncementInfo::Relayed ( + *unsafe { Box::from_raw(a.take_inner()) }, + ) + }, + NodeAnnouncementInfo::Local (mut a, ) => { + nativeNodeAnnouncementInfo::Local ( + *unsafe { Box::from_raw(a.take_inner()) }, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &NodeAnnouncementInfoImport) -> Self { + let native = unsafe { &*(native as *const _ as *const c_void as *const nativeNodeAnnouncementInfo) }; + match native { + nativeNodeAnnouncementInfo::Relayed (ref a, ) => { + let mut a_nonref = Clone::clone(a); + NodeAnnouncementInfo::Relayed ( + crate::lightning::ln::msgs::NodeAnnouncement { inner: ObjOps::heap_alloc(a_nonref), is_owned: true }, + ) + }, + nativeNodeAnnouncementInfo::Local (ref a, ) => { + let mut a_nonref = Clone::clone(a); + NodeAnnouncementInfo::Local ( + crate::lightning::routing::gossip::NodeAnnouncementDetails { inner: ObjOps::heap_alloc(a_nonref), is_owned: true }, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeNodeAnnouncementInfo) -> Self { + match native { + nativeNodeAnnouncementInfo::Relayed (mut a, ) => { + NodeAnnouncementInfo::Relayed ( + crate::lightning::ln::msgs::NodeAnnouncement { inner: ObjOps::heap_alloc(a), is_owned: true }, + ) + }, + nativeNodeAnnouncementInfo::Local (mut a, ) => { + NodeAnnouncementInfo::Local ( + crate::lightning::routing::gossip::NodeAnnouncementDetails { inner: ObjOps::heap_alloc(a), is_owned: true }, + ) + }, + } + } +} +/// Frees any resources used by the NodeAnnouncementInfo +#[no_mangle] +pub extern "C" fn NodeAnnouncementInfo_free(this_ptr: NodeAnnouncementInfo) { } /// Creates a copy of the NodeAnnouncementInfo +#[no_mangle] pub extern "C" fn NodeAnnouncementInfo_clone(orig: &NodeAnnouncementInfo) -> NodeAnnouncementInfo { orig.clone() } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn NodeAnnouncementInfo_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const NodeAnnouncementInfo)).clone() })) as *mut c_void +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn NodeAnnouncementInfo_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut NodeAnnouncementInfo) }; +} +#[no_mangle] +/// Utility method to constructs a new Relayed-variant NodeAnnouncementInfo +pub extern "C" fn NodeAnnouncementInfo_relayed(a: crate::lightning::ln::msgs::NodeAnnouncement) -> NodeAnnouncementInfo { + NodeAnnouncementInfo::Relayed(a, ) +} +#[no_mangle] +/// Utility method to constructs a new Local-variant NodeAnnouncementInfo +pub extern "C" fn NodeAnnouncementInfo_local(a: crate::lightning::routing::gossip::NodeAnnouncementDetails) -> NodeAnnouncementInfo { + NodeAnnouncementInfo::Local(a, ) +} /// Get a string which allows debug introspection of a NodeAnnouncementInfo object pub extern "C" fn NodeAnnouncementInfo_debug_str_void(o: *const c_void) -> Str { alloc::format!("{:?}", unsafe { o as *const crate::lightning::routing::gossip::NodeAnnouncementInfo }).into()} /// 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. #[no_mangle] pub extern "C" fn NodeAnnouncementInfo_eq(a: &NodeAnnouncementInfo, b: &NodeAnnouncementInfo) -> 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 } + if &a.to_native() == &b.to_native() { true } else { false } +} +/// Protocol features the node announced support for +#[must_use] +#[no_mangle] +pub extern "C" fn NodeAnnouncementInfo_features(this_arg: &crate::lightning::routing::gossip::NodeAnnouncementInfo) -> crate::lightning_types::features::NodeFeatures { + let mut ret = this_arg.to_native().features(); + crate::lightning_types::features::NodeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } + +/// When the last known update to the node state was issued. +/// +/// Value may or may not be a timestamp, depending on the policy of the origin node. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeAnnouncementInfo_last_update(this_arg: &crate::lightning::routing::gossip::NodeAnnouncementInfo) -> u32 { + let mut ret = this_arg.to_native().last_update(); + ret +} + +/// Color assigned to the node +#[must_use] +#[no_mangle] +pub extern "C" fn NodeAnnouncementInfo_rgb(this_arg: &crate::lightning::routing::gossip::NodeAnnouncementInfo) -> crate::c_types::ThreeBytes { + let mut ret = this_arg.to_native().rgb(); + crate::c_types::ThreeBytes { data: ret } +} + +/// Moniker assigned to the node. +/// +/// May be invalid or malicious (eg control chars), should not be exposed to the user. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeAnnouncementInfo_alias(this_arg: &crate::lightning::routing::gossip::NodeAnnouncementInfo) -> crate::lightning::routing::gossip::NodeAlias { + let mut ret = this_arg.to_native().alias(); + crate::lightning::routing::gossip::NodeAlias { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + /// Internet-level addresses via which one can connect to the node #[must_use] #[no_mangle] pub extern "C" fn NodeAnnouncementInfo_addresses(this_arg: &crate::lightning::routing::gossip::NodeAnnouncementInfo) -> crate::c_types::derived::CVec_SocketAddressZ { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.addresses(); - let mut local_ret_clone = Vec::new(); local_ret_clone.extend_from_slice(ret); let mut ret = local_ret_clone; let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::ln::msgs::SocketAddress::native_into(item) }); }; + let mut ret = this_arg.to_native().addresses(); + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::ln::msgs::SocketAddress::native_into(item) }); }; local_ret.into() } +/// An initial announcement of the node +/// +/// 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] +#[no_mangle] +pub extern "C" fn NodeAnnouncementInfo_announcement_message(this_arg: &crate::lightning::routing::gossip::NodeAnnouncementInfo) -> crate::lightning::ln::msgs::NodeAnnouncement { + let mut ret = this_arg.to_native().announcement_message(); + let mut local_ret = crate::lightning::ln::msgs::NodeAnnouncement { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; + local_ret +} + #[no_mangle] /// Serialize the NodeAnnouncementInfo object into a byte array which can be read by NodeAnnouncementInfo_read pub extern "C" fn NodeAnnouncementInfo_write(obj: &crate::lightning::routing::gossip::NodeAnnouncementInfo) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) + crate::c_types::serialize_obj(&unsafe { &*obj }.to_native()) } #[allow(unused)] pub(crate) extern "C" fn NodeAnnouncementInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeAnnouncementInfo) }) + NodeAnnouncementInfo_write(unsafe { &*(obj as *const NodeAnnouncementInfo) }) } #[no_mangle] /// Read a NodeAnnouncementInfo from a byte array, created by NodeAnnouncementInfo_write pub extern "C" fn NodeAnnouncementInfo_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NodeAnnouncementInfoDecodeErrorZ { 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::routing::gossip::NodeAnnouncementInfo { 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() }; + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::gossip::NodeAnnouncementInfo::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; local_res } @@ -1866,6 +1945,12 @@ pub struct NodeAlias { pub is_owned: bool, } +impl core::ops::Deref for NodeAlias { + type Target = nativeNodeAlias; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for NodeAlias { } +unsafe impl core::marker::Sync for NodeAlias { } impl Drop for NodeAlias { fn drop(&mut self) { if self.is_owned && !<*mut nativeNodeAlias>::is_null(self.inner) { @@ -1896,6 +1981,9 @@ impl NodeAlias { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } #[no_mangle] pub extern "C" fn NodeAlias_get_a(this_ptr: &NodeAlias) -> *const [u8; 32] { @@ -1967,7 +2055,7 @@ pub extern "C" fn NodeAlias_write(obj: &crate::lightning::routing::gossip::NodeA } #[allow(unused)] pub(crate) extern "C" fn NodeAlias_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeAlias) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::routing::gossip::nativeNodeAlias) }) } #[no_mangle] /// Read a NodeAlias from a byte array, created by NodeAlias_write @@ -1996,6 +2084,12 @@ pub struct NodeInfo { pub is_owned: bool, } +impl core::ops::Deref for NodeInfo { + type Target = nativeNodeInfo; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for NodeInfo { } +unsafe impl core::marker::Sync for NodeInfo { } impl Drop for NodeInfo { fn drop(&mut self) { if self.is_owned && !<*mut nativeNodeInfo>::is_null(self.inner) { @@ -2026,6 +2120,9 @@ impl NodeInfo { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// All valid channels a node has announced /// @@ -2046,36 +2143,21 @@ pub extern "C" fn NodeInfo_set_channels(this_ptr: &mut NodeInfo, mut val: crate: /// 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 +/// Returns a copy of the field. #[no_mangle] -pub extern "C" fn NodeInfo_get_announcement_info(this_ptr: &NodeInfo) -> crate::lightning::routing::gossip::NodeAnnouncementInfo { - let mut inner_val = &mut this_ptr.get_native_mut_ref().announcement_info; - let mut local_inner_val = crate::lightning::routing::gossip::NodeAnnouncementInfo { 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::gossip::NodeAnnouncementInfo<>) as *mut _ }, is_owned: false }; +pub extern "C" fn NodeInfo_get_announcement_info(this_ptr: &NodeInfo) -> crate::c_types::derived::COption_NodeAnnouncementInfoZ { + let mut inner_val = this_ptr.get_native_mut_ref().announcement_info.clone(); + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_NodeAnnouncementInfoZ::None } else { crate::c_types::derived::COption_NodeAnnouncementInfoZ::Some( { crate::lightning::routing::gossip::NodeAnnouncementInfo::native_into(inner_val.unwrap()) }) }; local_inner_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 val (or a relevant inner pointer) may be NULL or all-0s to represent None #[no_mangle] -pub extern "C" fn NodeInfo_set_announcement_info(this_ptr: &mut NodeInfo, mut val: crate::lightning::routing::gossip::NodeAnnouncementInfo) { - let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; +pub extern "C" fn NodeInfo_set_announcement_info(this_ptr: &mut NodeInfo, mut val: crate::c_types::derived::COption_NodeAnnouncementInfoZ) { + 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) }.announcement_info = local_val; } -/// Constructs a new NodeInfo given each field -/// -/// Note that announcement_info_arg (or a relevant inner pointer) may be NULL or all-0s to represent None -#[must_use] -#[no_mangle] -pub extern "C" fn NodeInfo_new(mut channels_arg: crate::c_types::derived::CVec_u64Z, mut announcement_info_arg: crate::lightning::routing::gossip::NodeAnnouncementInfo) -> NodeInfo { - let mut local_channels_arg = Vec::new(); for mut item in channels_arg.into_rust().drain(..) { local_channels_arg.push( { item }); }; - let mut local_announcement_info_arg = if announcement_info_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(announcement_info_arg.take_inner()) } }) }; - NodeInfo { inner: ObjOps::heap_alloc(nativeNodeInfo { - channels: local_channels_arg, - announcement_info: local_announcement_info_arg, - }), is_owned: true } -} impl Clone for NodeInfo { fn clone(&self) -> Self { Self { @@ -2127,7 +2209,7 @@ pub extern "C" fn NodeInfo_write(obj: &crate::lightning::routing::gossip::NodeIn } #[allow(unused)] pub(crate) extern "C" fn NodeInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeInfo) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::routing::gossip::nativeNodeInfo) }) } #[no_mangle] /// Read a NodeInfo from a byte array, created by NodeInfo_write @@ -2143,7 +2225,7 @@ pub extern "C" fn NetworkGraph_write(obj: &crate::lightning::routing::gossip::Ne } #[allow(unused)] pub(crate) extern "C" fn NetworkGraph_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNetworkGraph) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::routing::gossip::nativeNetworkGraph) }) } #[no_mangle] /// Read a NetworkGraph from a byte array, created by NetworkGraph_write @@ -2272,7 +2354,7 @@ pub extern "C" fn NetworkGraph_update_channel_from_unsigned_announcement(this_ar /// All other parameters as used in [`msgs::UnsignedChannelAnnouncement`] fields. #[must_use] #[no_mangle] -pub extern "C" fn NetworkGraph_add_channel_from_partial_announcement(this_arg: &crate::lightning::routing::gossip::NetworkGraph, mut short_channel_id: u64, mut timestamp: u64, mut features: crate::lightning::ln::features::ChannelFeatures, mut node_id_1: crate::c_types::PublicKey, mut node_id_2: crate::c_types::PublicKey) -> crate::c_types::derived::CResult_NoneLightningErrorZ { +pub extern "C" fn NetworkGraph_add_channel_from_partial_announcement(this_arg: &crate::lightning::routing::gossip::NetworkGraph, mut short_channel_id: u64, mut timestamp: u64, mut features: crate::lightning_types::features::ChannelFeatures, mut node_id_1: crate::c_types::PublicKey, mut node_id_2: crate::c_types::PublicKey) -> crate::c_types::derived::CResult_NoneLightningErrorZ { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.add_channel_from_partial_announcement(short_channel_id, timestamp, *unsafe { Box::from_raw(features.take_inner()) }, node_id_1.into_rust(), node_id_2.into_rust()); 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 diff --git a/lightning-c-bindings/src/lightning/routing/mod.rs b/lightning-c-bindings/src/lightning/routing/mod.rs index ec19271..96c6c3c 100644 --- a/lightning-c-bindings/src/lightning/routing/mod.rs +++ b/lightning-c-bindings/src/lightning/routing/mod.rs @@ -21,3 +21,15 @@ pub mod utxo; pub mod gossip; pub mod router; pub mod scoring; +mod log_approx { + +use alloc::str::FromStr; +use alloc::string::String; +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}; + +} diff --git a/lightning-c-bindings/src/lightning/routing/router.rs b/lightning-c-bindings/src/lightning/routing/router.rs index aa6acd8..84e3a73 100644 --- a/lightning-c-bindings/src/lightning/routing/router.rs +++ b/lightning-c-bindings/src/lightning/routing/router.rs @@ -22,6 +22,11 @@ use lightning::routing::router::DefaultRouter as nativeDefaultRouterImport; pub(crate) type nativeDefaultRouter = nativeDefaultRouterImport<&'static lightning::routing::gossip::NetworkGraph, crate::lightning::util::logger::Logger, crate::lightning::sign::EntropySource, crate::lightning::routing::scoring::LockableScore, >; /// A [`Router`] implemented using [`find_route`]. +/// +/// # Privacy +/// +/// Implements [`MessageRouter`] by delegating to [`DefaultMessageRouter`]. See those docs for +/// privacy implications. #[must_use] #[repr(C)] pub struct DefaultRouter { @@ -37,6 +42,12 @@ pub struct DefaultRouter { pub is_owned: bool, } +impl core::ops::Deref for DefaultRouter { + type Target = nativeDefaultRouter; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for DefaultRouter { } +unsafe impl core::marker::Sync for DefaultRouter { } impl Drop for DefaultRouter { fn drop(&mut self) { if self.is_owned && !<*mut nativeDefaultRouter>::is_null(self.inner) { @@ -67,6 +78,9 @@ impl DefaultRouter { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Creates a new router. #[must_use] @@ -101,6 +115,7 @@ pub extern "C" fn DefaultRouter_as_Router(this_arg: &DefaultRouter) -> crate::li free: None, find_path: DefaultRouter_MessageRouter_find_path, create_blinded_paths: DefaultRouter_MessageRouter_create_blinded_paths, + create_compact_blinded_paths: DefaultRouter_MessageRouter_create_compact_blinded_paths, }, } } @@ -120,10 +135,10 @@ extern "C" fn DefaultRouter_Router_find_route_with_id(this_arg: *const c_void, m local_ret } #[must_use] -extern "C" fn DefaultRouter_Router_create_blinded_payment_paths(this_arg: *const c_void, mut recipient: crate::c_types::PublicKey, mut first_hops: crate::c_types::derived::CVec_ChannelDetailsZ, mut tlvs: crate::lightning::blinded_path::payment::ReceiveTlvs, mut amount_msats: u64) -> crate::c_types::derived::CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ { +extern "C" fn DefaultRouter_Router_create_blinded_payment_paths(this_arg: *const c_void, mut recipient: crate::c_types::PublicKey, mut first_hops: crate::c_types::derived::CVec_ChannelDetailsZ, mut tlvs: crate::lightning::blinded_path::payment::ReceiveTlvs, mut amount_msats: u64) -> crate::c_types::derived::CResult_CVec_BlindedPaymentPathZNoneZ { let mut local_first_hops = Vec::new(); for mut item in first_hops.into_rust().drain(..) { local_first_hops.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; let mut ret = ::create_blinded_payment_paths(unsafe { &mut *(this_arg as *mut nativeDefaultRouter) }, recipient.into_rust(), local_first_hops, *unsafe { Box::from_raw(tlvs.take_inner()) }, amount_msats, 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 orig_ret_0_0_0, mut orig_ret_0_0_1) = item; let mut local_ret_0_0 = (crate::lightning::offers::invoice::BlindedPayInfo { inner: ObjOps::heap_alloc(orig_ret_0_0_0), is_owned: true }, crate::lightning::blinded_path::BlindedPath { 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( { () /*e*/ }).into() }; + 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::lightning::blinded_path::payment::BlindedPaymentPath { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; local_ret_0.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; local_ret } @@ -146,6 +161,7 @@ pub extern "C" fn DefaultRouter_as_MessageRouter(this_arg: &DefaultRouter) -> cr free: None, find_path: DefaultRouter_MessageRouter_find_path, create_blinded_paths: DefaultRouter_MessageRouter_create_blinded_paths, + create_compact_blinded_paths: DefaultRouter_MessageRouter_create_compact_blinded_paths, } } @@ -157,10 +173,17 @@ extern "C" fn DefaultRouter_MessageRouter_find_path(this_arg: *const c_void, mut local_ret } #[must_use] -extern "C" fn DefaultRouter_MessageRouter_create_blinded_paths(this_arg: *const c_void, mut recipient: crate::c_types::PublicKey, mut peers: crate::c_types::derived::CVec_PublicKeyZ) -> crate::c_types::derived::CResult_CVec_BlindedPathZNoneZ { +extern "C" fn DefaultRouter_MessageRouter_create_blinded_paths(this_arg: *const c_void, mut recipient: crate::c_types::PublicKey, mut context: crate::lightning::blinded_path::message::MessageContext, mut peers: crate::c_types::derived::CVec_PublicKeyZ) -> crate::c_types::derived::CResult_CVec_BlindedMessagePathZNoneZ { let mut local_peers = Vec::new(); for mut item in peers.into_rust().drain(..) { local_peers.push( { item.into_rust() }); }; - let mut ret = ::create_blinded_paths(unsafe { &mut *(this_arg as *mut nativeDefaultRouter) }, recipient.into_rust(), local_peers, 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::lightning::blinded_path::BlindedPath { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; local_ret_0.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + let mut ret = ::create_blinded_paths(unsafe { &mut *(this_arg as *mut nativeDefaultRouter) }, recipient.into_rust(), context.into_native(), local_peers, 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::lightning::blinded_path::message::BlindedMessagePath { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; local_ret_0.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} +#[must_use] +extern "C" fn DefaultRouter_MessageRouter_create_compact_blinded_paths(this_arg: *const c_void, mut recipient: crate::c_types::PublicKey, mut context: crate::lightning::blinded_path::message::MessageContext, mut peers: crate::c_types::derived::CVec_MessageForwardNodeZ) -> crate::c_types::derived::CResult_CVec_BlindedMessagePathZNoneZ { + let mut local_peers = Vec::new(); for mut item in peers.into_rust().drain(..) { local_peers.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; + let mut ret = ::create_compact_blinded_paths(unsafe { &mut *(this_arg as *mut nativeDefaultRouter) }, recipient.into_rust(), context.into_native(), local_peers, 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::lightning::blinded_path::message::BlindedMessagePath { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; local_ret_0.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; local_ret } @@ -187,10 +210,10 @@ pub struct Router { /// /// Note that first_hops (or a relevant inner pointer) may be NULL or all-0s to represent None 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, - /// Creates [`BlindedPath`]s for payment to the `recipient` node. The channels in `first_hops` + /// Creates [`BlindedPaymentPath`]s for payment to the `recipient` node. The channels in `first_hops` /// are assumed to be with the `recipient`'s peers. The payment secret and any constraints are /// given in `tlvs`. - pub create_blinded_payment_paths: extern "C" fn (this_arg: *const c_void, recipient: crate::c_types::PublicKey, first_hops: crate::c_types::derived::CVec_ChannelDetailsZ, tlvs: crate::lightning::blinded_path::payment::ReceiveTlvs, amount_msats: u64) -> crate::c_types::derived::CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ, + pub create_blinded_payment_paths: extern "C" fn (this_arg: *const c_void, recipient: crate::c_types::PublicKey, first_hops: crate::c_types::derived::CVec_ChannelDetailsZ, tlvs: crate::lightning::blinded_path::payment::ReceiveTlvs, amount_msats: u64) -> crate::c_types::derived::CResult_CVec_BlindedPaymentPathZNoneZ, /// Implementation of MessageRouter for this object. pub MessageRouter: crate::lightning::onion_message::messenger::MessageRouter, /// Frees any resources associated with this object given its this_arg pointer. @@ -217,9 +240,35 @@ impl lightning::onion_message::messenger::MessageRouter for Router { 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 create_blinded_paths(&self, mut recipient: bitcoin::secp256k1::PublicKey, mut peers: Vec, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result, ()> { + fn create_blinded_paths(&self, mut recipient: bitcoin::secp256k1::PublicKey, mut context: lightning::blinded_path::message::MessageContext, mut peers: Vec, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> 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.MessageRouter.create_blinded_paths)(self.MessageRouter.this_arg, crate::c_types::PublicKey::from_rust(&recipient), crate::lightning::blinded_path::message::MessageContext::native_into(context), local_peers.into()); + 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 create_compact_blinded_paths(&self, mut recipient: bitcoin::secp256k1::PublicKey, mut context: lightning::blinded_path::message::MessageContext, mut peers: Vec, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result, ()> { + let mut local_peers = Vec::new(); for mut item in peers.drain(..) { local_peers.push( { crate::lightning::blinded_path::message::MessageForwardNode { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; + let mut ret = (self.MessageRouter.create_compact_blinded_paths)(self.MessageRouter.this_arg, crate::c_types::PublicKey::from_rust(&recipient), crate::lightning::blinded_path::message::MessageContext::native_into(context), local_peers.into()); + 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 + } +} +impl lightning::onion_message::messenger::MessageRouter for RouterRef { + 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.0.MessageRouter.find_path)(self.0.MessageRouter.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 + } + fn create_blinded_paths(&self, mut recipient: bitcoin::secp256k1::PublicKey, mut context: lightning::blinded_path::message::MessageContext, mut peers: Vec, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> 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.MessageRouter.create_blinded_paths)(self.MessageRouter.this_arg, crate::c_types::PublicKey::from_rust(&recipient), local_peers.into()); + let mut ret = (self.0.MessageRouter.create_blinded_paths)(self.0.MessageRouter.this_arg, crate::c_types::PublicKey::from_rust(&recipient), crate::lightning::blinded_path::message::MessageContext::native_into(context), local_peers.into()); + 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 create_compact_blinded_paths(&self, mut recipient: bitcoin::secp256k1::PublicKey, mut context: lightning::blinded_path::message::MessageContext, mut peers: Vec, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result, ()> { + let mut local_peers = Vec::new(); for mut item in peers.drain(..) { local_peers.push( { crate::lightning::blinded_path::message::MessageForwardNode { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; + let mut ret = (self.0.MessageRouter.create_compact_blinded_paths)(self.0.MessageRouter.this_arg, crate::c_types::PublicKey::from_rust(&recipient), crate::lightning::blinded_path::message::MessageContext::native_into(context), local_peers.into()); 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 } @@ -233,16 +282,38 @@ impl rustRouter for Router { 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::channel_state::ChannelDetails]>, mut inflight_htlcs: lightning::routing::router::InFlightHtlcs, mut _payment_hash: lightning::ln::types::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::channel_state::ChannelDetails]>, mut inflight_htlcs: lightning::routing::router::InFlightHtlcs, mut _payment_hash: lightning_types::payment::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::channel_state::ChannelDetails { inner: unsafe { ObjOps::nonnull_ptr_to_inner(((*item) as *const lightning::ln::channel_state::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: 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 } - fn create_blinded_payment_paths(&self, mut recipient: bitcoin::secp256k1::PublicKey, mut first_hops: Vec, mut tlvs: lightning::blinded_path::payment::ReceiveTlvs, mut amount_msats: u64, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result, ()> { + fn create_blinded_payment_paths(&self, mut recipient: bitcoin::secp256k1::PublicKey, mut first_hops: Vec, mut tlvs: lightning::blinded_path::payment::ReceiveTlvs, mut amount_msats: u64, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result, ()> { let mut local_first_hops = Vec::new(); for mut item in first_hops.drain(..) { local_first_hops.push( { crate::lightning::ln::channel_state::ChannelDetails { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; let mut ret = (self.create_blinded_payment_paths)(self.this_arg, crate::c_types::PublicKey::from_rust(&recipient), local_first_hops.into(), crate::lightning::blinded_path::payment::ReceiveTlvs { inner: ObjOps::heap_alloc(tlvs), is_owned: true }, amount_msats); - 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( { let (mut orig_ret_0_0_0, mut orig_ret_0_0_1) = item.to_rust(); let mut local_ret_0_0 = (*unsafe { Box::from_raw(orig_ret_0_0_0.take_inner()) }, *unsafe { Box::from_raw(orig_ret_0_0_1.take_inner()) }); local_ret_0_0 }); }; local_ret_0 }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + 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 + } +} + +pub struct RouterRef(Router); +impl rustRouter for RouterRef { + fn find_route(&self, mut payer: &bitcoin::secp256k1::PublicKey, mut route_params: &lightning::routing::router::RouteParameters, mut first_hops: Option<&[&lightning::ln::channel_state::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::channel_state::ChannelDetails { inner: unsafe { ObjOps::nonnull_ptr_to_inner(((*item) as *const lightning::ln::channel_state::ChannelDetails<>) as *mut _) }, is_owned: false } }); }; local_first_hops_0.into() }) }; let mut local_first_hops = *local_first_hops_base; + let mut ret = (self.0.find_route)(self.0.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::channel_state::ChannelDetails]>, mut inflight_htlcs: lightning::routing::router::InFlightHtlcs, mut _payment_hash: lightning_types::payment::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::channel_state::ChannelDetails { inner: unsafe { ObjOps::nonnull_ptr_to_inner(((*item) as *const lightning::ln::channel_state::ChannelDetails<>) as *mut _) }, is_owned: false } }); }; local_first_hops_0.into() }) }; let mut local_first_hops = *local_first_hops_base; + let mut ret = (self.0.find_route_with_id)(self.0.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 + } + fn create_blinded_payment_paths(&self, mut recipient: bitcoin::secp256k1::PublicKey, mut first_hops: Vec, mut tlvs: lightning::blinded_path::payment::ReceiveTlvs, mut amount_msats: u64, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result, ()> { + let mut local_first_hops = Vec::new(); for mut item in first_hops.drain(..) { local_first_hops.push( { crate::lightning::ln::channel_state::ChannelDetails { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; + let mut ret = (self.0.create_blinded_payment_paths)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&recipient), local_first_hops.into(), crate::lightning::blinded_path::payment::ReceiveTlvs { inner: ObjOps::heap_alloc(tlvs), is_owned: true }, amount_msats); + 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 } } @@ -250,14 +321,14 @@ impl rustRouter for Router { // 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 Router { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = RouterRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const RouterRef) } } } impl core::ops::DerefMut for Router { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut RouterRef { + unsafe { &mut *(self as *mut _ as *mut RouterRef) } } } /// Calls the free function if one is set @@ -295,6 +366,12 @@ pub struct ScorerAccountingForInFlightHtlcs { pub is_owned: bool, } +impl core::ops::Deref for ScorerAccountingForInFlightHtlcs { + type Target = nativeScorerAccountingForInFlightHtlcs; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ScorerAccountingForInFlightHtlcs { } +unsafe impl core::marker::Sync for ScorerAccountingForInFlightHtlcs { } impl Drop for ScorerAccountingForInFlightHtlcs { fn drop(&mut self) { if self.is_owned && !<*mut nativeScorerAccountingForInFlightHtlcs>::is_null(self.inner) { @@ -325,6 +402,9 @@ impl ScorerAccountingForInFlightHtlcs { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Initialize a new `ScorerAccountingForInFlightHtlcs`. #[must_use] @@ -382,6 +462,12 @@ pub struct InFlightHtlcs { pub is_owned: bool, } +impl core::ops::Deref for InFlightHtlcs { + type Target = nativeInFlightHtlcs; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for InFlightHtlcs { } +unsafe impl core::marker::Sync for InFlightHtlcs { } impl Drop for InFlightHtlcs { fn drop(&mut self) { if self.is_owned && !<*mut nativeInFlightHtlcs>::is_null(self.inner) { @@ -412,6 +498,9 @@ impl InFlightHtlcs { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } impl Clone for InFlightHtlcs { fn clone(&self) -> Self { @@ -470,7 +559,7 @@ pub extern "C" fn InFlightHtlcs_write(obj: &crate::lightning::routing::router::I } #[allow(unused)] pub(crate) extern "C" fn InFlightHtlcs_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInFlightHtlcs) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::routing::router::nativeInFlightHtlcs) }) } #[no_mangle] /// Read a InFlightHtlcs from a byte array, created by InFlightHtlcs_write @@ -500,6 +589,12 @@ pub struct RouteHop { pub is_owned: bool, } +impl core::ops::Deref for RouteHop { + type Target = nativeRouteHop; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for RouteHop { } +unsafe impl core::marker::Sync for RouteHop { } impl Drop for RouteHop { fn drop(&mut self) { if self.is_owned && !<*mut nativeRouteHop>::is_null(self.inner) { @@ -530,6 +625,9 @@ impl RouteHop { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The node_id of the node at this hop. #[no_mangle] @@ -545,14 +643,14 @@ pub extern "C" fn RouteHop_set_pubkey(this_ptr: &mut RouteHop, mut val: crate::c /// 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. #[no_mangle] -pub extern "C" fn RouteHop_get_node_features(this_ptr: &RouteHop) -> crate::lightning::ln::features::NodeFeatures { +pub extern "C" fn RouteHop_get_node_features(this_ptr: &RouteHop) -> crate::lightning_types::features::NodeFeatures { let mut inner_val = &mut this_ptr.get_native_mut_ref().node_features; - crate::lightning::ln::features::NodeFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::features::NodeFeatures<>) as *mut _) }, is_owned: false } + crate::lightning_types::features::NodeFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning_types::features::NodeFeatures<>) as *mut _) }, is_owned: false } } /// 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. #[no_mangle] -pub extern "C" fn RouteHop_set_node_features(this_ptr: &mut RouteHop, mut val: crate::lightning::ln::features::NodeFeatures) { +pub extern "C" fn RouteHop_set_node_features(this_ptr: &mut RouteHop, mut val: crate::lightning_types::features::NodeFeatures) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_features = *unsafe { Box::from_raw(val.take_inner()) }; } /// The channel that should be used from the previous hop to reach this node. @@ -569,22 +667,21 @@ pub extern "C" fn RouteHop_set_short_channel_id(this_ptr: &mut RouteHop, mut val /// The channel_announcement features of the channel that should be used from the previous hop /// to reach this node. #[no_mangle] -pub extern "C" fn RouteHop_get_channel_features(this_ptr: &RouteHop) -> crate::lightning::ln::features::ChannelFeatures { +pub extern "C" fn RouteHop_get_channel_features(this_ptr: &RouteHop) -> crate::lightning_types::features::ChannelFeatures { let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_features; - crate::lightning::ln::features::ChannelFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::features::ChannelFeatures<>) as *mut _) }, is_owned: false } + crate::lightning_types::features::ChannelFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning_types::features::ChannelFeatures<>) as *mut _) }, is_owned: false } } /// The channel_announcement features of the channel that should be used from the previous hop /// to reach this node. #[no_mangle] -pub extern "C" fn RouteHop_set_channel_features(this_ptr: &mut RouteHop, mut val: crate::lightning::ln::features::ChannelFeatures) { +pub extern "C" fn RouteHop_set_channel_features(this_ptr: &mut RouteHop, mut val: crate::lightning_types::features::ChannelFeatures) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_features = *unsafe { Box::from_raw(val.take_inner()) }; } /// 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 +/// * if we're sending to a [`BlindedPaymentPath`], 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 #[no_mangle] pub extern "C" fn RouteHop_get_fee_msat(this_ptr: &RouteHop) -> u64 { let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_msat; @@ -592,20 +689,18 @@ pub extern "C" fn RouteHop_get_fee_msat(this_ptr: &RouteHop) -> u64 { } /// 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 +/// * if we're sending to a [`BlindedPaymentPath`], 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 #[no_mangle] pub extern "C" fn RouteHop_set_fee_msat(this_ptr: &mut RouteHop, mut val: u64) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_msat = 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 +/// * if we're sending to a [`BlindedPaymentPath`], 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 #[no_mangle] pub extern "C" fn RouteHop_get_cltv_expiry_delta(this_ptr: &RouteHop) -> u32 { let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta; @@ -613,10 +708,9 @@ pub extern "C" fn RouteHop_get_cltv_expiry_delta(this_ptr: &RouteHop) -> u32 { } /// 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 +/// * if we're sending to a [`BlindedPaymentPath`], 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 #[no_mangle] pub extern "C" fn RouteHop_set_cltv_expiry_delta(this_ptr: &mut RouteHop, mut val: u32) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val; @@ -649,7 +743,7 @@ pub extern "C" fn RouteHop_set_maybe_announced_channel(this_ptr: &mut RouteHop, /// Constructs a new RouteHop given each field #[must_use] #[no_mangle] -pub extern "C" fn RouteHop_new(mut pubkey_arg: crate::c_types::PublicKey, mut node_features_arg: crate::lightning::ln::features::NodeFeatures, mut short_channel_id_arg: u64, mut channel_features_arg: crate::lightning::ln::features::ChannelFeatures, mut fee_msat_arg: u64, mut cltv_expiry_delta_arg: u32, mut maybe_announced_channel_arg: bool) -> RouteHop { +pub extern "C" fn RouteHop_new(mut pubkey_arg: crate::c_types::PublicKey, mut node_features_arg: crate::lightning_types::features::NodeFeatures, mut short_channel_id_arg: u64, mut channel_features_arg: crate::lightning_types::features::ChannelFeatures, mut fee_msat_arg: u64, mut cltv_expiry_delta_arg: u32, mut maybe_announced_channel_arg: bool) -> RouteHop { RouteHop { inner: ObjOps::heap_alloc(nativeRouteHop { pubkey: pubkey_arg.into_rust(), node_features: *unsafe { Box::from_raw(node_features_arg.take_inner()) }, @@ -708,7 +802,7 @@ pub extern "C" fn RouteHop_write(obj: &crate::lightning::routing::router::RouteH } #[allow(unused)] pub(crate) extern "C" fn RouteHop_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRouteHop) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::routing::router::nativeRouteHop) }) } #[no_mangle] /// Read a RouteHop from a byte array, created by RouteHop_write @@ -740,6 +834,12 @@ pub struct BlindedTail { pub is_owned: bool, } +impl core::ops::Deref for BlindedTail { + type Target = nativeBlindedTail; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for BlindedTail { } +unsafe impl core::marker::Sync for BlindedTail { } impl Drop for BlindedTail { fn drop(&mut self) { if self.is_owned && !<*mut nativeBlindedTail>::is_null(self.inner) { @@ -770,35 +870,30 @@ impl BlindedTail { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } -/// The hops of the [`BlindedPath`] provided by the recipient. -/// -/// [`BlindedPath`]: crate::blinded_path::BlindedPath +/// The hops of the [`BlindedPaymentPath`] provided by the recipient. #[no_mangle] pub extern "C" fn BlindedTail_get_hops(this_ptr: &BlindedTail) -> crate::c_types::derived::CVec_BlindedHopZ { let mut inner_val = &mut this_ptr.get_native_mut_ref().hops; let mut local_inner_val = Vec::new(); for item in inner_val.iter() { local_inner_val.push( { crate::lightning::blinded_path::BlindedHop { inner: unsafe { ObjOps::nonnull_ptr_to_inner((item as *const lightning::blinded_path::BlindedHop<>) as *mut _) }, is_owned: false } }); }; local_inner_val.into() } -/// The hops of the [`BlindedPath`] provided by the recipient. -/// -/// [`BlindedPath`]: crate::blinded_path::BlindedPath +/// The hops of the [`BlindedPaymentPath`] provided by the recipient. #[no_mangle] pub extern "C" fn BlindedTail_set_hops(this_ptr: &mut BlindedTail, mut val: crate::c_types::derived::CVec_BlindedHopZ) { 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) }.hops = local_val; } -/// The blinding point of the [`BlindedPath`] provided by the recipient. -/// -/// [`BlindedPath`]: crate::blinded_path::BlindedPath +/// The blinding point of the [`BlindedPaymentPath`] provided by the recipient. #[no_mangle] pub extern "C" fn BlindedTail_get_blinding_point(this_ptr: &BlindedTail) -> crate::c_types::PublicKey { let mut inner_val = &mut this_ptr.get_native_mut_ref().blinding_point; crate::c_types::PublicKey::from_rust(&inner_val) } -/// The blinding point of the [`BlindedPath`] provided by the recipient. -/// -/// [`BlindedPath`]: crate::blinded_path::BlindedPath +/// The blinding point of the [`BlindedPaymentPath`] provided by the recipient. #[no_mangle] pub extern "C" fn BlindedTail_set_blinding_point(this_ptr: &mut BlindedTail, mut val: crate::c_types::PublicKey) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.blinding_point = val.into_rust(); @@ -887,7 +982,7 @@ pub extern "C" fn BlindedTail_write(obj: &crate::lightning::routing::router::Bli } #[allow(unused)] pub(crate) extern "C" fn BlindedTail_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeBlindedTail) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::routing::router::nativeBlindedTail) }) } #[no_mangle] /// Read a BlindedTail from a byte array, created by BlindedTail_write @@ -917,6 +1012,12 @@ pub struct Path { pub is_owned: bool, } +impl core::ops::Deref for Path { + type Target = nativePath; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for Path { } +unsafe impl core::marker::Sync for Path { } impl Drop for Path { fn drop(&mut self) { if self.is_owned && !<*mut nativePath>::is_null(self.inner) { @@ -947,6 +1048,9 @@ impl Path { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The list of unblinded hops in this [`Path`]. Must be at least length one. #[no_mangle] @@ -1078,6 +1182,12 @@ pub struct Route { pub is_owned: bool, } +impl core::ops::Deref for Route { + type Target = nativeRoute; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for Route { } +unsafe impl core::marker::Sync for Route { } impl Drop for Route { fn drop(&mut self) { if self.is_owned && !<*mut nativeRoute>::is_null(self.inner) { @@ -1108,6 +1218,9 @@ impl Route { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// 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 @@ -1244,7 +1357,7 @@ pub extern "C" fn Route_write(obj: &crate::lightning::routing::router::Route) -> } #[allow(unused)] pub(crate) extern "C" fn Route_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRoute) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::routing::router::nativeRoute) }) } #[no_mangle] /// Read a Route from a byte array, created by Route_write @@ -1275,6 +1388,12 @@ pub struct RouteParameters { pub is_owned: bool, } +impl core::ops::Deref for RouteParameters { + type Target = nativeRouteParameters; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for RouteParameters { } +unsafe impl core::marker::Sync for RouteParameters { } impl Drop for RouteParameters { fn drop(&mut self) { if self.is_owned && !<*mut nativeRouteParameters>::is_null(self.inner) { @@ -1305,6 +1424,9 @@ impl RouteParameters { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The parameters of the failed payment path. #[no_mangle] @@ -1413,6 +1535,16 @@ pub extern "C" fn RouteParameters_from_payment_params_and_value(mut payment_para crate::lightning::routing::router::RouteParameters { inner: ObjOps::heap_alloc(ret), is_owned: true } } +/// Sets the maximum number of hops that can be included in a payment path, based on the provided +/// [`RecipientOnionFields`] and blinded paths. +#[must_use] +#[no_mangle] +pub extern "C" fn RouteParameters_set_max_path_length(this_arg: &mut crate::lightning::routing::router::RouteParameters, recipient_onion: &crate::lightning::ln::outbound_payment::RecipientOnionFields, mut is_keysend: bool, mut best_block_height: u32) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::routing::router::nativeRouteParameters)) }.set_max_path_length(recipient_onion.get_native_ref(), is_keysend, best_block_height); + 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 RouteParameters object into a byte array which can be read by RouteParameters_read pub extern "C" fn RouteParameters_write(obj: &crate::lightning::routing::router::RouteParameters) -> crate::c_types::derived::CVec_u8Z { @@ -1420,7 +1552,7 @@ pub extern "C" fn RouteParameters_write(obj: &crate::lightning::routing::router: } #[allow(unused)] pub(crate) extern "C" fn RouteParameters_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRouteParameters) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::routing::router::nativeRouteParameters) }) } #[no_mangle] /// Read a RouteParameters from a byte array, created by RouteParameters_write @@ -1437,6 +1569,11 @@ pub static DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA: u32 = lightning::routing::router #[no_mangle] pub static DEFAULT_MAX_PATH_COUNT: u8 = lightning::routing::router::DEFAULT_MAX_PATH_COUNT; +/// Estimated maximum number of hops that can be included in a payment path. May be inaccurate if +/// payment metadata, custom TLVs, or blinded paths are included in the payment. + +#[no_mangle] +pub static MAX_PATH_LENGTH_ESTIMATE: u8 = lightning::routing::router::MAX_PATH_LENGTH_ESTIMATE; use lightning::routing::router::PaymentParameters as nativePaymentParametersImport; pub(crate) type nativePaymentParameters = nativePaymentParametersImport; @@ -1457,6 +1594,12 @@ pub struct PaymentParameters { pub is_owned: bool, } +impl core::ops::Deref for PaymentParameters { + type Target = nativePaymentParameters; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for PaymentParameters { } +unsafe impl core::marker::Sync for PaymentParameters { } impl Drop for PaymentParameters { fn drop(&mut self) { if self.is_owned && !<*mut nativePaymentParameters>::is_null(self.inner) { @@ -1487,6 +1630,9 @@ impl PaymentParameters { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Information about the payee, such as their features and route hints for their channels. #[no_mangle] @@ -1538,6 +1684,19 @@ pub extern "C" fn PaymentParameters_get_max_path_count(this_ptr: &PaymentParamet pub extern "C" fn PaymentParameters_set_max_path_count(this_ptr: &mut PaymentParameters, mut val: u8) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_path_count = val; } +/// The maximum number of [`Path::hops`] in any returned path. +/// Defaults to [`MAX_PATH_LENGTH_ESTIMATE`]. +#[no_mangle] +pub extern "C" fn PaymentParameters_get_max_path_length(this_ptr: &PaymentParameters) -> u8 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().max_path_length; + *inner_val +} +/// The maximum number of [`Path::hops`] in any returned path. +/// Defaults to [`MAX_PATH_LENGTH_ESTIMATE`]. +#[no_mangle] +pub extern "C" fn PaymentParameters_set_max_path_length(this_ptr: &mut PaymentParameters, mut val: u8) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_path_length = val; +} /// 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 @@ -1614,7 +1773,7 @@ pub extern "C" fn PaymentParameters_set_previously_failed_blinded_path_idxs(this /// Constructs a new PaymentParameters given each field #[must_use] #[no_mangle] -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, mut previously_failed_blinded_path_idxs_arg: crate::c_types::derived::CVec_u64Z) -> PaymentParameters { +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_path_length_arg: u8, mut max_channel_saturation_power_of_half_arg: u8, mut previously_failed_channels_arg: crate::c_types::derived::CVec_u64Z, mut previously_failed_blinded_path_idxs_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 }); }; let mut local_previously_failed_blinded_path_idxs_arg = Vec::new(); for mut item in previously_failed_blinded_path_idxs_arg.into_rust().drain(..) { local_previously_failed_blinded_path_idxs_arg.push( { item }); }; @@ -1623,6 +1782,7 @@ pub extern "C" fn PaymentParameters_new(mut payee_arg: crate::lightning::routing 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_path_length: max_path_length_arg, max_channel_saturation_power_of_half: max_channel_saturation_power_of_half_arg, previously_failed_channels: local_previously_failed_channels_arg, previously_failed_blinded_path_idxs: local_previously_failed_blinded_path_idxs_arg, @@ -1676,7 +1836,7 @@ pub extern "C" fn PaymentParameters_write(obj: &crate::lightning::routing::route } #[allow(unused)] pub(crate) extern "C" fn PaymentParameters_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePaymentParameters) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::routing::router::nativePaymentParameters) }) } #[no_mangle] /// Read a PaymentParameters from a byte array, created by PaymentParameters_write @@ -1728,8 +1888,8 @@ pub extern "C" fn PaymentParameters_from_bolt12_invoice(invoice: &crate::lightni /// Creates parameters for paying to a blinded payee from the provided blinded route hints. #[must_use] #[no_mangle] -pub extern "C" fn PaymentParameters_blinded(mut blinded_route_hints: crate::c_types::derived::CVec_C2Tuple_BlindedPayInfoBlindedPathZZ) -> crate::lightning::routing::router::PaymentParameters { - let mut local_blinded_route_hints = Vec::new(); for mut item in blinded_route_hints.into_rust().drain(..) { local_blinded_route_hints.push( { let (mut orig_blinded_route_hints_0_0, mut orig_blinded_route_hints_0_1) = item.to_rust(); let mut local_blinded_route_hints_0 = (*unsafe { Box::from_raw(orig_blinded_route_hints_0_0.take_inner()) }, *unsafe { Box::from_raw(orig_blinded_route_hints_0_1.take_inner()) }); local_blinded_route_hints_0 }); }; +pub extern "C" fn PaymentParameters_blinded(mut blinded_route_hints: crate::c_types::derived::CVec_BlindedPaymentPathZ) -> crate::lightning::routing::router::PaymentParameters { + let mut local_blinded_route_hints = Vec::new(); for mut item in blinded_route_hints.into_rust().drain(..) { local_blinded_route_hints.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; let mut ret = lightning::routing::router::PaymentParameters::blinded(local_blinded_route_hints); crate::lightning::routing::router::PaymentParameters { inner: ObjOps::heap_alloc(ret), is_owned: true } } @@ -1745,14 +1905,14 @@ pub enum Payee { 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, + route_hints: crate::c_types::derived::CVec_BlindedPaymentPathZ, /// 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, + features: crate::lightning_types::features::Bolt12InvoiceFeatures, }, /// The recipient included these route hints in their BOLT11 invoice. Clear { @@ -1768,7 +1928,7 @@ pub enum Payee { /// [`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, + features: crate::lightning_types::features::Bolt11InvoiceFeatures, /// The minimum CLTV delta at the end of the route. This value must not be zero. final_cltv_expiry_delta: u32, }, @@ -1782,7 +1942,7 @@ impl Payee { match self { 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 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()) } }) }; nativePayee::Blinded { @@ -1810,7 +1970,7 @@ impl Payee { pub(crate) fn into_native(self) -> nativePayee { match self { 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_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::Blinded { route_hints: local_route_hints, @@ -1835,9 +1995,9 @@ impl Payee { match native { 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 local_route_hints_nonref = Vec::new(); for mut item in route_hints_nonref.drain(..) { local_route_hints_nonref.push( { crate::lightning::blinded_path::payment::BlindedPaymentPath { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; 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 }; + let mut local_features_nonref = crate::lightning_types::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, @@ -1846,9 +2006,9 @@ impl Payee { 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 local_route_hints_nonref = Vec::new(); for mut item in route_hints_nonref.drain(..) { local_route_hints_nonref.push( { crate::lightning_types::routing::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 local_features_nonref = crate::lightning_types::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), @@ -1863,16 +2023,16 @@ impl Payee { pub(crate) fn native_into(native: nativePayee) -> Self { match native { 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 }; + let mut local_route_hints = Vec::new(); for mut item in route_hints.drain(..) { local_route_hints.push( { crate::lightning::blinded_path::payment::BlindedPaymentPath { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; + let mut local_features = crate::lightning_types::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, } }, 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 }; + let mut local_route_hints = Vec::new(); for mut item in route_hints.drain(..) { local_route_hints.push( { crate::lightning_types::routing::RouteHint { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; + let mut local_features = crate::lightning_types::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(), @@ -1903,7 +2063,7 @@ pub(crate) extern "C" fn Payee_free_void(this_ptr: *mut c_void) { } #[no_mangle] /// 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 { +pub extern "C" fn Payee_blinded(route_hints: crate::c_types::derived::CVec_BlindedPaymentPathZ, features: crate::lightning_types::features::Bolt12InvoiceFeatures) -> Payee { Payee::Blinded { route_hints, features, @@ -1911,7 +2071,7 @@ pub extern "C" fn Payee_blinded(route_hints: crate::c_types::derived::CVec_C2Tup } #[no_mangle] /// 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 { +pub extern "C" fn Payee_clear(node_id: crate::c_types::PublicKey, route_hints: crate::c_types::derived::CVec_RouteHintZ, features: crate::lightning_types::features::Bolt11InvoiceFeatures, final_cltv_expiry_delta: u32) -> Payee { Payee::Clear { node_id, route_hints, @@ -1937,329 +2097,36 @@ pub extern "C" fn Payee_hash(o: &Payee) -> u64 { pub extern "C" fn Payee_eq(a: &Payee, b: &Payee) -> bool { if &a.to_native() == &b.to_native() { true } else { false } } - -use lightning::routing::router::RouteHint as nativeRouteHintImport; -pub(crate) type nativeRouteHint = nativeRouteHintImport; - -/// A list of hops along a payment path terminating with a channel to the recipient. -#[must_use] -#[repr(C)] -pub struct RouteHint { - /// A pointer to the opaque Rust object. - - /// Nearly everywhere, 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 nativeRouteHint, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust 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 RouteHint { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeRouteHint>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; - } - } -} -/// Frees any resources used by the RouteHint, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn RouteHint_free(this_obj: RouteHint) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn RouteHint_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeRouteHint) }; -} -#[allow(unused)] -impl RouteHint { - pub(crate) fn get_native_ref(&self) -> &'static nativeRouteHint { - unsafe { &*ObjOps::untweak_ptr(self.inner) } - } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeRouteHint { - 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 nativeRouteHint { - assert!(self.is_owned); - let ret = ObjOps::untweak_ptr(self.inner); - self.inner = core::ptr::null_mut(); - ret - } -} -#[no_mangle] -pub extern "C" fn RouteHint_get_a(this_ptr: &RouteHint) -> crate::c_types::derived::CVec_RouteHintHopZ { - let mut inner_val = &mut this_ptr.get_native_mut_ref().0; - let mut local_inner_val = Vec::new(); for item in inner_val.iter() { local_inner_val.push( { crate::lightning::routing::router::RouteHintHop { inner: unsafe { ObjOps::nonnull_ptr_to_inner((item as *const lightning::routing::router::RouteHintHop<>) as *mut _) }, is_owned: false } }); }; - local_inner_val.into() -} -#[no_mangle] -pub extern "C" fn RouteHint_set_a(this_ptr: &mut RouteHint, mut val: crate::c_types::derived::CVec_RouteHintHopZ) { - 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) }.0 = local_val; -} -/// Constructs a new RouteHint given each field -#[must_use] -#[no_mangle] -pub extern "C" fn RouteHint_new(mut a_arg: crate::c_types::derived::CVec_RouteHintHopZ) -> RouteHint { - let mut local_a_arg = Vec::new(); for mut item in a_arg.into_rust().drain(..) { local_a_arg.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; - RouteHint { inner: ObjOps::heap_alloc(lightning::routing::router::RouteHint ( - local_a_arg, - )), is_owned: true } -} -impl Clone for RouteHint { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeRouteHint>::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 RouteHint_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeRouteHint)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the RouteHint -pub extern "C" fn RouteHint_clone(orig: &RouteHint) -> RouteHint { - orig.clone() -} -/// Get a string which allows debug introspection of a RouteHint object -pub extern "C" fn RouteHint_debug_str_void(o: *const c_void) -> Str { - alloc::format!("{:?}", unsafe { o as *const crate::lightning::routing::router::RouteHint }).into()} -/// Generates a non-cryptographic 64-bit hash of the RouteHint. -#[no_mangle] -pub extern "C" fn RouteHint_hash(o: &RouteHint) -> 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 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. -#[no_mangle] -pub extern "C" fn RouteHint_eq(a: &RouteHint, b: &RouteHint) -> 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 RouteHint object into a byte array which can be read by RouteHint_read -pub extern "C" fn RouteHint_write(obj: &crate::lightning::routing::router::RouteHint) -> crate::c_types::derived::CVec_u8Z { +pub extern "C" fn RouteHint_write(obj: &crate::lightning_types::routing::RouteHint) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) } #[allow(unused)] pub(crate) extern "C" fn RouteHint_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRouteHint) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning_types::routing::nativeRouteHint) }) } #[no_mangle] /// Read a RouteHint from a byte array, created by RouteHint_write pub extern "C" fn RouteHint_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RouteHintDecodeErrorZ { - 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::routing::router::RouteHint { 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() }; + 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_types::routing::RouteHint { 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::routing::router::RouteHintHop as nativeRouteHintHopImport; -pub(crate) type nativeRouteHintHop = nativeRouteHintHopImport; - -/// A channel descriptor for a hop along a payment path. -/// -/// While this generally comes from BOLT 11's `r` field, this struct includes more fields than are -/// available in BOLT 11. Thus, encoding and decoding this via `lightning-invoice` is lossy, as -/// fields not supported in BOLT 11 will be stripped. -#[must_use] -#[repr(C)] -pub struct RouteHintHop { - /// A pointer to the opaque Rust object. - - /// Nearly everywhere, 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 nativeRouteHintHop, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust 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 RouteHintHop { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeRouteHintHop>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; - } - } -} -/// Frees any resources used by the RouteHintHop, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn RouteHintHop_free(this_obj: RouteHintHop) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn RouteHintHop_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeRouteHintHop) }; -} -#[allow(unused)] -impl RouteHintHop { - pub(crate) fn get_native_ref(&self) -> &'static nativeRouteHintHop { - unsafe { &*ObjOps::untweak_ptr(self.inner) } - } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeRouteHintHop { - 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 nativeRouteHintHop { - assert!(self.is_owned); - let ret = ObjOps::untweak_ptr(self.inner); - self.inner = core::ptr::null_mut(); - ret - } -} -/// The node_id of the non-target end of the route -#[no_mangle] -pub extern "C" fn RouteHintHop_get_src_node_id(this_ptr: &RouteHintHop) -> crate::c_types::PublicKey { - let mut inner_val = &mut this_ptr.get_native_mut_ref().src_node_id; - crate::c_types::PublicKey::from_rust(&inner_val) -} -/// The node_id of the non-target end of the route -#[no_mangle] -pub extern "C" fn RouteHintHop_set_src_node_id(this_ptr: &mut RouteHintHop, mut val: crate::c_types::PublicKey) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.src_node_id = val.into_rust(); -} -/// The short_channel_id of this channel -#[no_mangle] -pub extern "C" fn RouteHintHop_get_short_channel_id(this_ptr: &RouteHintHop) -> u64 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id; - *inner_val -} -/// The short_channel_id of this channel -#[no_mangle] -pub extern "C" fn RouteHintHop_set_short_channel_id(this_ptr: &mut RouteHintHop, mut val: u64) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val; -} -/// The fees which must be paid to use this channel -#[no_mangle] -pub extern "C" fn RouteHintHop_get_fees(this_ptr: &RouteHintHop) -> crate::lightning::routing::gossip::RoutingFees { - let mut inner_val = &mut this_ptr.get_native_mut_ref().fees; - crate::lightning::routing::gossip::RoutingFees { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::routing::gossip::RoutingFees<>) as *mut _) }, is_owned: false } -} -/// The fees which must be paid to use this channel -#[no_mangle] -pub extern "C" fn RouteHintHop_set_fees(this_ptr: &mut RouteHintHop, mut val: crate::lightning::routing::gossip::RoutingFees) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fees = *unsafe { Box::from_raw(val.take_inner()) }; -} -/// The difference in CLTV values between this node and the next node. -#[no_mangle] -pub extern "C" fn RouteHintHop_get_cltv_expiry_delta(this_ptr: &RouteHintHop) -> u16 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta; - *inner_val -} -/// The difference in CLTV values between this node and the next node. -#[no_mangle] -pub extern "C" fn RouteHintHop_set_cltv_expiry_delta(this_ptr: &mut RouteHintHop, mut val: u16) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val; -} -/// The minimum value, in msat, which must be relayed to the next hop. -#[no_mangle] -pub extern "C" fn RouteHintHop_get_htlc_minimum_msat(this_ptr: &RouteHintHop) -> crate::c_types::derived::COption_u64Z { - let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_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 minimum value, in msat, which must be relayed to the next hop. -#[no_mangle] -pub extern "C" fn RouteHintHop_set_htlc_minimum_msat(this_ptr: &mut RouteHintHop, 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) }.htlc_minimum_msat = local_val; -} -/// The maximum value in msat available for routing with a single HTLC. -#[no_mangle] -pub extern "C" fn RouteHintHop_get_htlc_maximum_msat(this_ptr: &RouteHintHop) -> crate::c_types::derived::COption_u64Z { - let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_maximum_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 maximum value in msat available for routing with a single HTLC. -#[no_mangle] -pub extern "C" fn RouteHintHop_set_htlc_maximum_msat(this_ptr: &mut RouteHintHop, 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) }.htlc_maximum_msat = local_val; -} -/// Constructs a new RouteHintHop given each field -#[must_use] -#[no_mangle] -pub extern "C" fn RouteHintHop_new(mut src_node_id_arg: crate::c_types::PublicKey, mut short_channel_id_arg: u64, mut fees_arg: crate::lightning::routing::gossip::RoutingFees, mut cltv_expiry_delta_arg: u16, mut htlc_minimum_msat_arg: crate::c_types::derived::COption_u64Z, mut htlc_maximum_msat_arg: crate::c_types::derived::COption_u64Z) -> RouteHintHop { - let mut local_htlc_minimum_msat_arg = if htlc_minimum_msat_arg.is_some() { Some( { htlc_minimum_msat_arg.take() }) } else { None }; - let mut local_htlc_maximum_msat_arg = if htlc_maximum_msat_arg.is_some() { Some( { htlc_maximum_msat_arg.take() }) } else { None }; - RouteHintHop { inner: ObjOps::heap_alloc(nativeRouteHintHop { - src_node_id: src_node_id_arg.into_rust(), - short_channel_id: short_channel_id_arg, - fees: *unsafe { Box::from_raw(fees_arg.take_inner()) }, - cltv_expiry_delta: cltv_expiry_delta_arg, - htlc_minimum_msat: local_htlc_minimum_msat_arg, - htlc_maximum_msat: local_htlc_maximum_msat_arg, - }), is_owned: true } -} -impl Clone for RouteHintHop { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeRouteHintHop>::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 RouteHintHop_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeRouteHintHop)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the RouteHintHop -pub extern "C" fn RouteHintHop_clone(orig: &RouteHintHop) -> RouteHintHop { - orig.clone() -} -/// Get a string which allows debug introspection of a RouteHintHop object -pub extern "C" fn RouteHintHop_debug_str_void(o: *const c_void) -> Str { - alloc::format!("{:?}", unsafe { o as *const crate::lightning::routing::router::RouteHintHop }).into()} -/// Generates a non-cryptographic 64-bit hash of the RouteHintHop. -#[no_mangle] -pub extern "C" fn RouteHintHop_hash(o: &RouteHintHop) -> 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 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. -#[no_mangle] -pub extern "C" fn RouteHintHop_eq(a: &RouteHintHop, b: &RouteHintHop) -> 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 RouteHintHop object into a byte array which can be read by RouteHintHop_read -pub extern "C" fn RouteHintHop_write(obj: &crate::lightning::routing::router::RouteHintHop) -> crate::c_types::derived::CVec_u8Z { +pub extern "C" fn RouteHintHop_write(obj: &crate::lightning_types::routing::RouteHintHop) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) } #[allow(unused)] pub(crate) extern "C" fn RouteHintHop_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRouteHintHop) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning_types::routing::nativeRouteHintHop) }) } #[no_mangle] /// Read a RouteHintHop from a byte array, created by RouteHintHop_write pub extern "C" fn RouteHintHop_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RouteHintHopDecodeErrorZ { - 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::routing::router::RouteHintHop { 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() }; + 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_types::routing::RouteHintHop { 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 } @@ -2282,6 +2149,12 @@ pub struct FirstHopCandidate { pub is_owned: bool, } +impl core::ops::Deref for FirstHopCandidate { + type Target = nativeFirstHopCandidate; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for FirstHopCandidate { } +unsafe impl core::marker::Sync for FirstHopCandidate { } impl Drop for FirstHopCandidate { fn drop(&mut self) { if self.is_owned && !<*mut nativeFirstHopCandidate>::is_null(self.inner) { @@ -2312,6 +2185,9 @@ impl FirstHopCandidate { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } impl Clone for FirstHopCandidate { fn clone(&self) -> Self { @@ -2355,6 +2231,12 @@ pub struct PublicHopCandidate { pub is_owned: bool, } +impl core::ops::Deref for PublicHopCandidate { + type Target = nativePublicHopCandidate; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for PublicHopCandidate { } +unsafe impl core::marker::Sync for PublicHopCandidate { } impl Drop for PublicHopCandidate { fn drop(&mut self) { if self.is_owned && !<*mut nativePublicHopCandidate>::is_null(self.inner) { @@ -2385,6 +2267,9 @@ impl PublicHopCandidate { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The short channel ID of the channel, i.e. the identifier by which we refer to this /// channel. @@ -2441,6 +2326,12 @@ pub struct PrivateHopCandidate { pub is_owned: bool, } +impl core::ops::Deref for PrivateHopCandidate { + type Target = nativePrivateHopCandidate; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for PrivateHopCandidate { } +unsafe impl core::marker::Sync for PrivateHopCandidate { } impl Drop for PrivateHopCandidate { fn drop(&mut self) { if self.is_owned && !<*mut nativePrivateHopCandidate>::is_null(self.inner) { @@ -2471,6 +2362,9 @@ impl PrivateHopCandidate { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } impl Clone for PrivateHopCandidate { fn clone(&self) -> Self { @@ -2514,6 +2408,12 @@ pub struct BlindedPathCandidate { pub is_owned: bool, } +impl core::ops::Deref for BlindedPathCandidate { + type Target = nativeBlindedPathCandidate; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for BlindedPathCandidate { } +unsafe impl core::marker::Sync for BlindedPathCandidate { } impl Drop for BlindedPathCandidate { fn drop(&mut self) { if self.is_owned && !<*mut nativeBlindedPathCandidate>::is_null(self.inner) { @@ -2544,6 +2444,9 @@ impl BlindedPathCandidate { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } impl Clone for BlindedPathCandidate { fn clone(&self) -> Self { @@ -2587,6 +2490,12 @@ pub struct OneHopBlindedPathCandidate { pub is_owned: bool, } +impl core::ops::Deref for OneHopBlindedPathCandidate { + type Target = nativeOneHopBlindedPathCandidate; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for OneHopBlindedPathCandidate { } +unsafe impl core::marker::Sync for OneHopBlindedPathCandidate { } impl Drop for OneHopBlindedPathCandidate { fn drop(&mut self) { if self.is_owned && !<*mut nativeOneHopBlindedPathCandidate>::is_null(self.inner) { @@ -2617,6 +2526,9 @@ impl OneHopBlindedPathCandidate { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } impl Clone for OneHopBlindedPathCandidate { fn clone(&self) -> Self { @@ -2681,6 +2593,8 @@ pub enum CandidateRouteHop { /// /// This primarily exists to track that we need to included a blinded path at the end of our /// [`Route`], even though it doesn't actually add an additional hop in the payment. + /// + /// [`BlindedPayInfo`]: crate::blinded_path::payment::BlindedPayInfo OneHopBlinded( crate::lightning::routing::router::OneHopBlindedPathCandidate), } @@ -2902,9 +2816,9 @@ pub extern "C" fn CandidateRouteHop_htlc_minimum_msat(this_arg: &crate::lightnin /// Returns the fees that must be paid to route an HTLC over this channel. #[must_use] #[no_mangle] -pub extern "C" fn CandidateRouteHop_fees(this_arg: &crate::lightning::routing::router::CandidateRouteHop) -> crate::lightning::routing::gossip::RoutingFees { +pub extern "C" fn CandidateRouteHop_fees(this_arg: &crate::lightning::routing::router::CandidateRouteHop) -> crate::lightning_types::routing::RoutingFees { let mut ret = this_arg.to_native().fees(); - crate::lightning::routing::gossip::RoutingFees { inner: ObjOps::heap_alloc(ret), is_owned: true } + crate::lightning_types::routing::RoutingFees { inner: ObjOps::heap_alloc(ret), is_owned: true } } /// Returns the source node id of current hop. diff --git a/lightning-c-bindings/src/lightning/routing/scoring.rs b/lightning-c-bindings/src/lightning/routing/scoring.rs index 7d4c3e2..59e0e98 100644 --- a/lightning-c-bindings/src/lightning/routing/scoring.rs +++ b/lightning-c-bindings/src/lightning/routing/scoring.rs @@ -48,11 +48,6 @@ //! # } //! ``` //! -//! # Note -//! -//! Persisting when built with feature `no-std` and restoring without it, or vice versa, uses -//! different types and thus is undefined. -//! //! [`find_route`]: crate::routing::router::find_route use alloc::str::FromStr; @@ -106,17 +101,25 @@ impl rustScoreLookUp for ScoreLookUp { } } +pub struct ScoreLookUpRef(ScoreLookUp); +impl rustScoreLookUp for ScoreLookUpRef { + fn channel_penalty_msat(&self, mut candidate: &lightning::routing::router::CandidateRouteHop, mut usage: lightning::routing::scoring::ChannelUsage, mut score_params: &lightning::routing::scoring::ProbabilisticScoringFeeParameters) -> u64 { + let mut ret = (self.0.channel_penalty_msat)(self.0.this_arg, &crate::lightning::routing::router::CandidateRouteHop::from_native(candidate), 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 + } +} + // 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 ScoreLookUp { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = ScoreLookUpRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const ScoreLookUpRef) } } } impl core::ops::DerefMut for ScoreLookUp { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut ScoreLookUpRef { + unsafe { &mut *(self as *mut _ as *mut ScoreLookUpRef) } } } /// Calls the free function if one is set @@ -186,17 +189,36 @@ impl rustScoreUpdate for ScoreUpdate { } } +pub struct ScoreUpdateRef(ScoreUpdate); +impl rustScoreUpdate for ScoreUpdateRef { + fn payment_path_failed(&mut self, mut path: &lightning::routing::router::Path, mut short_channel_id: u64, mut duration_since_epoch: core::time::Duration) { + (self.0.payment_path_failed)(self.0.this_arg, &crate::lightning::routing::router::Path { inner: unsafe { ObjOps::nonnull_ptr_to_inner((path as *const lightning::routing::router::Path<>) as *mut _) }, is_owned: false }, short_channel_id, duration_since_epoch.as_secs()) + } + fn payment_path_successful(&mut self, mut path: &lightning::routing::router::Path, mut duration_since_epoch: core::time::Duration) { + (self.0.payment_path_successful)(self.0.this_arg, &crate::lightning::routing::router::Path { inner: unsafe { ObjOps::nonnull_ptr_to_inner((path as *const lightning::routing::router::Path<>) as *mut _) }, is_owned: false }, duration_since_epoch.as_secs()) + } + fn probe_failed(&mut self, mut path: &lightning::routing::router::Path, mut short_channel_id: u64, mut duration_since_epoch: core::time::Duration) { + (self.0.probe_failed)(self.0.this_arg, &crate::lightning::routing::router::Path { inner: unsafe { ObjOps::nonnull_ptr_to_inner((path as *const lightning::routing::router::Path<>) as *mut _) }, is_owned: false }, short_channel_id, duration_since_epoch.as_secs()) + } + fn probe_successful(&mut self, mut path: &lightning::routing::router::Path, mut duration_since_epoch: core::time::Duration) { + (self.0.probe_successful)(self.0.this_arg, &crate::lightning::routing::router::Path { inner: unsafe { ObjOps::nonnull_ptr_to_inner((path as *const lightning::routing::router::Path<>) as *mut _) }, is_owned: false }, duration_since_epoch.as_secs()) + } + fn time_passed(&mut self, mut duration_since_epoch: core::time::Duration) { + (self.0.time_passed)(self.0.this_arg, duration_since_epoch.as_secs()) + } +} + // 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 ScoreUpdate { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = ScoreUpdateRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const ScoreUpdateRef) } } } impl core::ops::DerefMut for ScoreUpdate { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut ScoreUpdateRef { + unsafe { &mut *(self as *mut _ as *mut ScoreUpdateRef) } } } /// Calls the free function if one is set @@ -248,6 +270,12 @@ impl lightning::routing::scoring::ScoreLookUp for Score { ret } } +impl lightning::routing::scoring::ScoreLookUp for ScoreRef { + fn channel_penalty_msat(&self, mut candidate: &lightning::routing::router::CandidateRouteHop, mut usage: lightning::routing::scoring::ChannelUsage, mut score_params: &lightning::routing::scoring::ProbabilisticScoringFeeParameters) -> u64 { + let mut ret = (self.0.ScoreLookUp.channel_penalty_msat)(self.0.ScoreLookUp.this_arg, &crate::lightning::routing::router::CandidateRouteHop::from_native(candidate), 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 + } +} impl lightning::routing::scoring::ScoreUpdate for Score { fn payment_path_failed(&mut self, mut path: &lightning::routing::router::Path, mut short_channel_id: u64, mut duration_since_epoch: core::time::Duration) { (self.ScoreUpdate.payment_path_failed)(self.ScoreUpdate.this_arg, &crate::lightning::routing::router::Path { inner: unsafe { ObjOps::nonnull_ptr_to_inner((path as *const lightning::routing::router::Path<>) as *mut _) }, is_owned: false }, short_channel_id, duration_since_epoch.as_secs()) @@ -265,28 +293,55 @@ impl lightning::routing::scoring::ScoreUpdate for Score { (self.ScoreUpdate.time_passed)(self.ScoreUpdate.this_arg, duration_since_epoch.as_secs()) } } +impl lightning::routing::scoring::ScoreUpdate for ScoreRef { + fn payment_path_failed(&mut self, mut path: &lightning::routing::router::Path, mut short_channel_id: u64, mut duration_since_epoch: core::time::Duration) { + (self.0.ScoreUpdate.payment_path_failed)(self.0.ScoreUpdate.this_arg, &crate::lightning::routing::router::Path { inner: unsafe { ObjOps::nonnull_ptr_to_inner((path as *const lightning::routing::router::Path<>) as *mut _) }, is_owned: false }, short_channel_id, duration_since_epoch.as_secs()) + } + fn payment_path_successful(&mut self, mut path: &lightning::routing::router::Path, mut duration_since_epoch: core::time::Duration) { + (self.0.ScoreUpdate.payment_path_successful)(self.0.ScoreUpdate.this_arg, &crate::lightning::routing::router::Path { inner: unsafe { ObjOps::nonnull_ptr_to_inner((path as *const lightning::routing::router::Path<>) as *mut _) }, is_owned: false }, duration_since_epoch.as_secs()) + } + fn probe_failed(&mut self, mut path: &lightning::routing::router::Path, mut short_channel_id: u64, mut duration_since_epoch: core::time::Duration) { + (self.0.ScoreUpdate.probe_failed)(self.0.ScoreUpdate.this_arg, &crate::lightning::routing::router::Path { inner: unsafe { ObjOps::nonnull_ptr_to_inner((path as *const lightning::routing::router::Path<>) as *mut _) }, is_owned: false }, short_channel_id, duration_since_epoch.as_secs()) + } + fn probe_successful(&mut self, mut path: &lightning::routing::router::Path, mut duration_since_epoch: core::time::Duration) { + (self.0.ScoreUpdate.probe_successful)(self.0.ScoreUpdate.this_arg, &crate::lightning::routing::router::Path { inner: unsafe { ObjOps::nonnull_ptr_to_inner((path as *const lightning::routing::router::Path<>) as *mut _) }, is_owned: false }, duration_since_epoch.as_secs()) + } + fn time_passed(&mut self, mut duration_since_epoch: core::time::Duration) { + (self.0.ScoreUpdate.time_passed)(self.0.ScoreUpdate.this_arg, duration_since_epoch.as_secs()) + } +} impl lightning::util::ser::Writeable for Score { 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()) } } +impl lightning::util::ser::Writeable for ScoreRef { + fn write(&self, w: &mut W) -> Result<(), crate::c_types::io::Error> { + let vec = (self.0.write)(self.0.this_arg); + w.write_all(vec.as_slice()) + } +} use lightning::routing::scoring::Score as rustScore; impl rustScore for Score { } +pub struct ScoreRef(Score); +impl rustScore for ScoreRef { +} + // 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 Score { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = ScoreRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const ScoreRef) } } } impl core::ops::DerefMut for Score { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut ScoreRef { + unsafe { &mut *(self as *mut _ as *mut ScoreRef) } } } /// Calls the free function if one is set @@ -334,8 +389,8 @@ pub(crate) fn LockableScore_clone_fields(orig: &LockableScore) -> LockableScore use lightning::routing::scoring::LockableScore as rustLockableScore; impl<'a> rustLockableScore<'a, > for LockableScore { - type ScoreUpdate = crate::lightning::routing::scoring::ScoreUpdate; - type ScoreLookUp = crate::lightning::routing::scoring::ScoreLookUp; + type ScoreUpdate = crate::lightning::routing::scoring::ScoreUpdateRef; + type ScoreLookUp = crate::lightning::routing::scoring::ScoreLookUpRef; type WriteLocked = crate::lightning::routing::scoring::ScoreUpdate; type ReadLocked = crate::lightning::routing::scoring::ScoreLookUp; fn read_lock(&'a self) -> crate::lightning::routing::scoring::ScoreLookUp { @@ -348,17 +403,33 @@ impl<'a> rustLockableScore<'a, > for LockableScore { } } +pub struct LockableScoreRef(LockableScore); +impl<'a> rustLockableScore<'a, > for LockableScoreRef { + type ScoreUpdate = crate::lightning::routing::scoring::ScoreUpdateRef; + type ScoreLookUp = crate::lightning::routing::scoring::ScoreLookUpRef; + type WriteLocked = crate::lightning::routing::scoring::ScoreUpdate; + type ReadLocked = crate::lightning::routing::scoring::ScoreLookUp; + fn read_lock(&'a self) -> crate::lightning::routing::scoring::ScoreLookUp { + let mut ret = (self.0.read_lock)(self.0.this_arg); + ret + } + fn write_lock(&'a self) -> crate::lightning::routing::scoring::ScoreUpdate { + let mut ret = (self.0.write_lock)(self.0.this_arg); + 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 LockableScore { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = LockableScoreRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const LockableScoreRef) } } } impl core::ops::DerefMut for LockableScore { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut LockableScoreRef { + unsafe { &mut *(self as *mut _ as *mut LockableScoreRef) } } } /// Calls the free function if one is set @@ -400,8 +471,8 @@ pub(crate) fn WriteableScore_clone_fields(orig: &WriteableScore) -> WriteableSco } } impl<'a> lightning::routing::scoring::LockableScore<'a, > for WriteableScore { - type ScoreUpdate = crate::lightning::routing::scoring::ScoreUpdate; - type ScoreLookUp = crate::lightning::routing::scoring::ScoreLookUp; + type ScoreUpdate = crate::lightning::routing::scoring::ScoreUpdateRef; + type ScoreLookUp = crate::lightning::routing::scoring::ScoreLookUpRef; type WriteLocked = crate::lightning::routing::scoring::ScoreUpdate; type ReadLocked = crate::lightning::routing::scoring::ScoreLookUp; fn read_lock(&'a self) -> crate::lightning::routing::scoring::ScoreLookUp { @@ -413,28 +484,52 @@ impl<'a> lightning::routing::scoring::LockableScore<'a, > for WriteableScore { ret } } +impl<'a> lightning::routing::scoring::LockableScore<'a, > for WriteableScoreRef { + type ScoreUpdate = crate::lightning::routing::scoring::ScoreUpdateRef; + type ScoreLookUp = crate::lightning::routing::scoring::ScoreLookUpRef; + type WriteLocked = crate::lightning::routing::scoring::ScoreUpdate; + type ReadLocked = crate::lightning::routing::scoring::ScoreLookUp; + fn read_lock(&'a self) -> crate::lightning::routing::scoring::ScoreLookUp { + let mut ret = (self.0.LockableScore.read_lock)(self.0.LockableScore.this_arg); + ret + } + fn write_lock(&'a self) -> crate::lightning::routing::scoring::ScoreUpdate { + let mut ret = (self.0.LockableScore.write_lock)(self.0.LockableScore.this_arg); + ret + } +} impl lightning::util::ser::Writeable for WriteableScore { 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()) } } +impl lightning::util::ser::Writeable for WriteableScoreRef { + fn write(&self, w: &mut W) -> Result<(), crate::c_types::io::Error> { + let vec = (self.0.write)(self.0.this_arg); + w.write_all(vec.as_slice()) + } +} use lightning::routing::scoring::WriteableScore as rustWriteableScore; impl<'a> rustWriteableScore<'a, > for WriteableScore { } +pub struct WriteableScoreRef(WriteableScore); +impl<'a> rustWriteableScore<'a, > for WriteableScoreRef { +} + // 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 WriteableScore { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = WriteableScoreRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const WriteableScoreRef) } } } impl core::ops::DerefMut for WriteableScore { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut WriteableScoreRef { + unsafe { &mut *(self as *mut _ as *mut WriteableScoreRef) } } } /// Calls the free function if one is set @@ -467,6 +562,12 @@ pub struct MultiThreadedLockableScore { pub is_owned: bool, } +impl core::ops::Deref for MultiThreadedLockableScore { + type Target = nativeMultiThreadedLockableScore; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for MultiThreadedLockableScore { } +unsafe impl core::marker::Sync for MultiThreadedLockableScore { } impl Drop for MultiThreadedLockableScore { fn drop(&mut self) { if self.is_owned && !<*mut nativeMultiThreadedLockableScore>::is_null(self.inner) { @@ -497,6 +598,9 @@ impl MultiThreadedLockableScore { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } impl From for crate::lightning::routing::scoring::LockableScore { fn from(obj: nativeMultiThreadedLockableScore) -> Self { @@ -538,7 +642,7 @@ pub extern "C" fn MultiThreadedLockableScore_write(obj: &crate::lightning::routi } #[allow(unused)] 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) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::routing::scoring::nativeMultiThreadedLockableScore) }) } impl From for crate::lightning::routing::scoring::WriteableScore { fn from(obj: nativeMultiThreadedLockableScore) -> Self { @@ -596,6 +700,12 @@ pub struct MultiThreadedScoreLockRead { pub is_owned: bool, } +impl core::ops::Deref for MultiThreadedScoreLockRead { + type Target = nativeMultiThreadedScoreLockRead; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for MultiThreadedScoreLockRead { } +unsafe impl core::marker::Sync for MultiThreadedScoreLockRead { } impl Drop for MultiThreadedScoreLockRead { fn drop(&mut self) { if self.is_owned && !<*mut nativeMultiThreadedScoreLockRead>::is_null(self.inner) { @@ -626,6 +736,9 @@ impl MultiThreadedScoreLockRead { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } use lightning::routing::scoring::MultiThreadedScoreLockWrite as nativeMultiThreadedScoreLockWriteImport; @@ -647,6 +760,12 @@ pub struct MultiThreadedScoreLockWrite { pub is_owned: bool, } +impl core::ops::Deref for MultiThreadedScoreLockWrite { + type Target = nativeMultiThreadedScoreLockWrite; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for MultiThreadedScoreLockWrite { } +unsafe impl core::marker::Sync for MultiThreadedScoreLockWrite { } impl Drop for MultiThreadedScoreLockWrite { fn drop(&mut self) { if self.is_owned && !<*mut nativeMultiThreadedScoreLockWrite>::is_null(self.inner) { @@ -677,6 +796,9 @@ impl MultiThreadedScoreLockWrite { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } impl From for crate::lightning::routing::scoring::ScoreLookUp { fn from(obj: nativeMultiThreadedScoreLockRead) -> Self { @@ -712,7 +834,7 @@ pub extern "C" fn MultiThreadedScoreLockWrite_write(obj: &crate::lightning::rout } #[allow(unused)] pub(crate) extern "C" fn MultiThreadedScoreLockWrite_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeMultiThreadedScoreLockWrite) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::routing::scoring::nativeMultiThreadedScoreLockWrite) }) } impl From for crate::lightning::routing::scoring::ScoreUpdate { fn from(obj: nativeMultiThreadedScoreLockWrite) -> Self { @@ -775,6 +897,12 @@ pub struct ChannelUsage { pub is_owned: bool, } +impl core::ops::Deref for ChannelUsage { + type Target = nativeChannelUsage; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ChannelUsage { } +unsafe impl core::marker::Sync for ChannelUsage { } impl Drop for ChannelUsage { fn drop(&mut self) { if self.is_owned && !<*mut nativeChannelUsage>::is_null(self.inner) { @@ -805,6 +933,9 @@ impl ChannelUsage { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The amount to send through the channel, denominated in millisatoshis. #[no_mangle] @@ -893,6 +1024,12 @@ pub struct FixedPenaltyScorer { pub is_owned: bool, } +impl core::ops::Deref for FixedPenaltyScorer { + type Target = nativeFixedPenaltyScorer; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for FixedPenaltyScorer { } +unsafe impl core::marker::Sync for FixedPenaltyScorer { } impl Drop for FixedPenaltyScorer { fn drop(&mut self) { if self.is_owned && !<*mut nativeFixedPenaltyScorer>::is_null(self.inner) { @@ -923,6 +1060,9 @@ impl FixedPenaltyScorer { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } impl Clone for FixedPenaltyScorer { fn clone(&self) -> Self { @@ -1026,7 +1166,7 @@ pub extern "C" fn FixedPenaltyScorer_write(obj: &crate::lightning::routing::scor } #[allow(unused)] pub(crate) extern "C" fn FixedPenaltyScorer_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFixedPenaltyScorer) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::routing::scoring::nativeFixedPenaltyScorer) }) } #[no_mangle] /// Read a FixedPenaltyScorer from a byte array, created by FixedPenaltyScorer_write @@ -1086,6 +1226,12 @@ pub struct ProbabilisticScorer { pub is_owned: bool, } +impl core::ops::Deref for ProbabilisticScorer { + type Target = nativeProbabilisticScorer; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ProbabilisticScorer { } +unsafe impl core::marker::Sync for ProbabilisticScorer { } impl Drop for ProbabilisticScorer { fn drop(&mut self) { if self.is_owned && !<*mut nativeProbabilisticScorer>::is_null(self.inner) { @@ -1116,6 +1262,9 @@ impl ProbabilisticScorer { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } use lightning::routing::scoring::ProbabilisticScoringFeeParameters as nativeProbabilisticScoringFeeParametersImport; @@ -1143,6 +1292,12 @@ pub struct ProbabilisticScoringFeeParameters { pub is_owned: bool, } +impl core::ops::Deref for ProbabilisticScoringFeeParameters { + type Target = nativeProbabilisticScoringFeeParameters; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ProbabilisticScoringFeeParameters { } +unsafe impl core::marker::Sync for ProbabilisticScoringFeeParameters { } impl Drop for ProbabilisticScoringFeeParameters { fn drop(&mut self) { if self.is_owned && !<*mut nativeProbabilisticScoringFeeParameters>::is_null(self.inner) { @@ -1173,6 +1328,9 @@ impl ProbabilisticScoringFeeParameters { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// A fixed penalty in msats to apply to each channel. /// @@ -1601,6 +1759,12 @@ pub struct ProbabilisticScoringDecayParameters { pub is_owned: bool, } +impl core::ops::Deref for ProbabilisticScoringDecayParameters { + type Target = nativeProbabilisticScoringDecayParameters; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ProbabilisticScoringDecayParameters { } +unsafe impl core::marker::Sync for ProbabilisticScoringDecayParameters { } impl Drop for ProbabilisticScoringDecayParameters { fn drop(&mut self) { if self.is_owned && !<*mut nativeProbabilisticScoringDecayParameters>::is_null(self.inner) { @@ -1631,6 +1795,9 @@ impl ProbabilisticScoringDecayParameters { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// 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 @@ -1925,18 +2092,6 @@ pub extern "C" fn ProbabilisticScorer_as_Score(this_arg: &ProbabilisticScorer) - } -mod approx { - -use alloc::str::FromStr; -use alloc::string::String; -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}; - -} mod bucketed_history { use alloc::str::FromStr; @@ -1956,7 +2111,7 @@ pub extern "C" fn ProbabilisticScorer_write(obj: &crate::lightning::routing::sco } #[allow(unused)] pub(crate) extern "C" fn ProbabilisticScorer_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeProbabilisticScorer) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::routing::scoring::nativeProbabilisticScorer) }) } #[no_mangle] /// Read a ProbabilisticScorer from a byte array, created by ProbabilisticScorer_write diff --git a/lightning-c-bindings/src/lightning/routing/utxo.rs b/lightning-c-bindings/src/lightning/routing/utxo.rs index b978317..517d633 100644 --- a/lightning-c-bindings/src/lightning/routing/utxo.rs +++ b/lightning-c-bindings/src/lightning/routing/utxo.rs @@ -243,23 +243,31 @@ pub(crate) fn UtxoLookup_clone_fields(orig: &UtxoLookup) -> UtxoLookup { use lightning::routing::utxo::UtxoLookup as rustUtxoLookup; impl rustUtxoLookup for UtxoLookup { - fn get_utxo(&self, mut chain_hash: &bitcoin::blockdata::constants::ChainHash, mut short_channel_id: u64) -> lightning::routing::utxo::UtxoResult { + fn get_utxo(&self, mut chain_hash: &bitcoin::constants::ChainHash, mut short_channel_id: u64) -> lightning::routing::utxo::UtxoResult { let mut ret = (self.get_utxo)(self.this_arg, chain_hash.as_ref(), short_channel_id); ret.into_native() } } +pub struct UtxoLookupRef(UtxoLookup); +impl rustUtxoLookup for UtxoLookupRef { + fn get_utxo(&self, mut chain_hash: &bitcoin::constants::ChainHash, mut short_channel_id: u64) -> lightning::routing::utxo::UtxoResult { + let mut ret = (self.0.get_utxo)(self.0.this_arg, chain_hash.as_ref(), short_channel_id); + ret.into_native() + } +} + // 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 UtxoLookup { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = UtxoLookupRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const UtxoLookupRef) } } } impl core::ops::DerefMut for UtxoLookup { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut UtxoLookupRef { + unsafe { &mut *(self as *mut _ as *mut UtxoLookupRef) } } } /// Calls the free function if one is set @@ -294,6 +302,12 @@ pub struct UtxoFuture { pub is_owned: bool, } +impl core::ops::Deref for UtxoFuture { + type Target = nativeUtxoFuture; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for UtxoFuture { } +unsafe impl core::marker::Sync for UtxoFuture { } impl Drop for UtxoFuture { fn drop(&mut self) { if self.is_owned && !<*mut nativeUtxoFuture>::is_null(self.inner) { @@ -324,6 +338,9 @@ impl UtxoFuture { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } impl Clone for UtxoFuture { fn clone(&self) -> Self { diff --git a/lightning-c-bindings/src/lightning/sign/ecdsa.rs b/lightning-c-bindings/src/lightning/sign/ecdsa.rs index 70bfe99..78668f2 100644 --- a/lightning-c-bindings/src/lightning/sign/ecdsa.rs +++ b/lightning-c-bindings/src/lightning/sign/ecdsa.rs @@ -180,6 +180,10 @@ pub struct EcdsaChannelSigner { 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_ECDSASignatureNoneZ, /// Implementation of ChannelSigner for this object. pub ChannelSigner: crate::lightning::sign::ChannelSigner, + /// Called, if set, after this EcdsaChannelSigner has been cloned into a duplicate object. + /// The new EcdsaChannelSigner 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. + pub cloned: Option, /// 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, @@ -200,19 +204,22 @@ pub(crate) fn EcdsaChannelSigner_clone_fields(orig: &EcdsaChannelSigner) -> Ecds 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), + cloned: Clone::clone(&orig.cloned), 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 { + fn get_per_commitment_point(&self, mut idx: u64, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { let mut ret = (self.ChannelSigner.get_per_commitment_point)(self.ChannelSigner.this_arg, idx); - ret.into_rust() + 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 release_commitment_secret(&self, mut idx: u64) -> [u8; 32] { + fn release_commitment_secret(&self, mut idx: u64) -> Result<[u8; 32], ()> { let mut ret = (self.ChannelSigner.release_commitment_secret)(self.ChannelSigner.this_arg, idx); - ret.data + let mut local_ret = match ret.result_ok { true => Ok( { (*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 validate_holder_commitment(&self, mut holder_tx: &lightning::ln::chan_utils::HolderCommitmentTransaction, mut outbound_htlc_preimages: Vec) -> Result<(), ()> { + fn validate_holder_commitment(&self, mut holder_tx: &lightning::ln::chan_utils::HolderCommitmentTransaction, mut outbound_htlc_preimages: Vec) -> Result<(), ()> { let mut local_outbound_htlc_preimages = Vec::new(); for mut item in outbound_htlc_preimages.drain(..) { local_outbound_htlc_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_outbound_htlc_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)) })*/ })}; @@ -237,10 +244,63 @@ impl lightning::sign::ChannelSigner for EcdsaChannelSigner { (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 }) } } +impl lightning::sign::ChannelSigner for EcdsaChannelSignerRef { + fn get_per_commitment_point(&self, mut idx: u64, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { + let mut ret = (self.0.ChannelSigner.get_per_commitment_point)(self.0.ChannelSigner.this_arg, idx); + 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 release_commitment_secret(&self, mut idx: u64) -> Result<[u8; 32], ()> { + let mut ret = (self.0.ChannelSigner.release_commitment_secret)(self.0.ChannelSigner.this_arg, idx); + let mut local_ret = match ret.result_ok { true => Ok( { (*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 validate_holder_commitment(&self, mut holder_tx: &lightning::ln::chan_utils::HolderCommitmentTransaction, mut outbound_htlc_preimages: Vec) -> Result<(), ()> { + let mut local_outbound_htlc_preimages = Vec::new(); for mut item in outbound_htlc_preimages.drain(..) { local_outbound_htlc_preimages.push( { crate::c_types::ThirtyTwoBytes { data: item.0 } }); }; + let mut ret = (self.0.ChannelSigner.validate_holder_commitment)(self.0.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_outbound_htlc_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 validate_counterparty_revocation(&self, mut idx: u64, mut secret: &bitcoin::secp256k1::SecretKey) -> Result<(), ()> { + let mut ret = (self.0.ChannelSigner.validate_counterparty_revocation)(self.0.ChannelSigner.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 pubkeys(&self) -> &lightning::ln::chan_utils::ChannelPublicKeys { + if let Some(f) = self.0.ChannelSigner.set_pubkeys { + (f)(&self.0.ChannelSigner); + } + unsafe { &*self.0.ChannelSigner.pubkeys.get() }.get_native_ref() + } + fn channel_keys_id(&self) -> [u8; 32] { + let mut ret = (self.0.ChannelSigner.channel_keys_id)(self.0.ChannelSigner.this_arg); + ret.data + } + fn provide_channel_parameters(&mut self, mut channel_parameters: &lightning::ln::chan_utils::ChannelTransactionParameters) { + (self.0.ChannelSigner.provide_channel_parameters)(self.0.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 }) + } +} +#[no_mangle] +/// Creates a copy of a EcdsaChannelSigner +pub extern "C" fn EcdsaChannelSigner_clone(orig: &EcdsaChannelSigner) -> EcdsaChannelSigner { + let mut res = EcdsaChannelSigner_clone_fields(orig); + if let Some(f) = orig.cloned { (f)(&mut res) }; + res +} +impl Clone for EcdsaChannelSigner { + fn clone(&self) -> Self { + EcdsaChannelSigner_clone(self) + } +} +impl Clone for EcdsaChannelSignerRef { + fn clone(&self) -> Self { + Self(EcdsaChannelSigner_clone(&self.0)) + } +} use lightning::sign::ecdsa::EcdsaChannelSigner as rustEcdsaChannelSigner; impl rustEcdsaChannelSigner for EcdsaChannelSigner { - fn sign_counterparty_commitment(&self, mut commitment_tx: &lightning::ln::chan_utils::CommitmentTransaction, mut inbound_htlc_preimages: Vec, mut outbound_htlc_preimages: Vec, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result<(bitcoin::secp256k1::ecdsa::Signature, Vec), ()> { + fn sign_counterparty_commitment(&self, mut commitment_tx: &lightning::ln::chan_utils::CommitmentTransaction, mut inbound_htlc_preimages: Vec, mut outbound_htlc_preimages: Vec, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result<(bitcoin::secp256k1::ecdsa::Signature, Vec), ()> { let mut local_inbound_htlc_preimages = Vec::new(); for mut item in inbound_htlc_preimages.drain(..) { local_inbound_htlc_preimages.push( { crate::c_types::ThirtyTwoBytes { data: item.0 } }); }; let mut local_outbound_htlc_preimages = Vec::new(); for mut item in outbound_htlc_preimages.drain(..) { local_outbound_htlc_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_inbound_htlc_preimages.into(), local_outbound_htlc_preimages.into()); @@ -252,22 +312,22 @@ impl rustEcdsaChannelSigner for EcdsaChannelSigner { 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_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 { + fn sign_justice_revoked_output(&self, mut justice_tx: &bitcoin::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 { + fn sign_justice_revoked_htlc(&self, mut justice_tx: &bitcoin::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::sign::HTLCDescriptor, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { + fn sign_holder_htlc_transaction(&self, mut htlc_tx: &bitcoin::transaction::Transaction, mut input: usize, mut htlc_descriptor: &lightning::sign::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::sign::HTLCDescriptor { inner: unsafe { ObjOps::nonnull_ptr_to_inner((htlc_descriptor as *const lightning::sign::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 { + fn sign_counterparty_htlc_transaction(&self, mut htlc_tx: &bitcoin::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 @@ -277,7 +337,7 @@ impl rustEcdsaChannelSigner for EcdsaChannelSigner { 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 { + fn sign_holder_anchor_input(&self, mut anchor_tx: &bitcoin::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 @@ -289,188 +349,74 @@ impl rustEcdsaChannelSigner for EcdsaChannelSigner { } } -// 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 - } -} -impl core::ops::DerefMut for EcdsaChannelSigner { - fn deref_mut(&mut self) -> &mut 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::ecdsa::EcdsaChannelSigner, - /// Serialize the object into a byte array - pub write: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_u8Z, - /// Called, if set, after this WriteableEcdsaChannelSigner has been cloned into a duplicate object. - /// The new WriteableEcdsaChannelSigner 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. - pub cloned: Option, - /// 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 {} -#[allow(unused)] -pub(crate) fn WriteableEcdsaChannelSigner_clone_fields(orig: &WriteableEcdsaChannelSigner) -> WriteableEcdsaChannelSigner { - WriteableEcdsaChannelSigner { - this_arg: orig.this_arg, - EcdsaChannelSigner: crate::lightning::sign::ecdsa::EcdsaChannelSigner_clone_fields(&orig.EcdsaChannelSigner), - write: Clone::clone(&orig.write), - cloned: Clone::clone(&orig.cloned), - free: Clone::clone(&orig.free), - } -} -impl lightning::sign::ecdsa::EcdsaChannelSigner for WriteableEcdsaChannelSigner { - fn sign_counterparty_commitment(&self, mut commitment_tx: &lightning::ln::chan_utils::CommitmentTransaction, mut inbound_htlc_preimages: Vec, mut outbound_htlc_preimages: Vec, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result<(bitcoin::secp256k1::ecdsa::Signature, Vec), ()> { +pub struct EcdsaChannelSignerRef(EcdsaChannelSigner); +impl rustEcdsaChannelSigner for EcdsaChannelSignerRef { + fn sign_counterparty_commitment(&self, mut commitment_tx: &lightning::ln::chan_utils::CommitmentTransaction, mut inbound_htlc_preimages: Vec, mut outbound_htlc_preimages: Vec, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result<(bitcoin::secp256k1::ecdsa::Signature, Vec), ()> { let mut local_inbound_htlc_preimages = Vec::new(); for mut item in inbound_htlc_preimages.drain(..) { local_inbound_htlc_preimages.push( { crate::c_types::ThirtyTwoBytes { data: item.0 } }); }; let mut local_outbound_htlc_preimages = Vec::new(); for mut item in outbound_htlc_preimages.drain(..) { local_outbound_htlc_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_inbound_htlc_preimages.into(), local_outbound_htlc_preimages.into()); + let mut ret = (self.0.sign_counterparty_commitment)(self.0.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_inbound_htlc_preimages.into(), local_outbound_htlc_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 sign_holder_commitment(&self, mut commitment_tx: &lightning::ln::chan_utils::HolderCommitmentTransaction, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { - let mut ret = (self.EcdsaChannelSigner.sign_holder_commitment)(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 ret = (self.0.sign_holder_commitment)(self.0.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( { (*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_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()); + fn sign_justice_revoked_output(&self, mut justice_tx: &bitcoin::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.0.sign_justice_revoked_output)(self.0.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 }); + fn sign_justice_revoked_htlc(&self, mut justice_tx: &bitcoin::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.0.sign_justice_revoked_htlc)(self.0.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::sign::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::sign::HTLCDescriptor { inner: unsafe { ObjOps::nonnull_ptr_to_inner((htlc_descriptor as *const lightning::sign::HTLCDescriptor<>) as *mut _) }, is_owned: false }); + fn sign_holder_htlc_transaction(&self, mut htlc_tx: &bitcoin::transaction::Transaction, mut input: usize, mut htlc_descriptor: &lightning::sign::HTLCDescriptor, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { + let mut ret = (self.0.sign_holder_htlc_transaction)(self.0.this_arg, crate::c_types::Transaction::from_bitcoin(htlc_tx), input, &crate::lightning::sign::HTLCDescriptor { inner: unsafe { ObjOps::nonnull_ptr_to_inner((htlc_descriptor as *const lightning::sign::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 }); + fn sign_counterparty_htlc_transaction(&self, mut htlc_tx: &bitcoin::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.0.sign_counterparty_htlc_transaction)(self.0.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 ret = (self.0.sign_closing_transaction)(self.0.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); + fn sign_holder_anchor_input(&self, mut anchor_tx: &bitcoin::transaction::Transaction, mut input: usize, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { + let mut ret = (self.0.sign_holder_anchor_input)(self.0.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 ret = (self.0.sign_channel_announcement_with_funding_key)(self.0.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 outbound_htlc_preimages: Vec) -> Result<(), ()> { - let mut local_outbound_htlc_preimages = Vec::new(); for mut item in outbound_htlc_preimages.drain(..) { local_outbound_htlc_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_outbound_htlc_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 validate_counterparty_revocation(&self, mut idx: u64, mut secret: &bitcoin::secp256k1::SecretKey) -> Result<(), ()> { - let mut ret = (self.EcdsaChannelSigner.ChannelSigner.validate_counterparty_revocation)(self.EcdsaChannelSigner.ChannelSigner.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 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()) - } -} -#[no_mangle] -/// Creates a copy of a WriteableEcdsaChannelSigner -pub extern "C" fn WriteableEcdsaChannelSigner_clone(orig: &WriteableEcdsaChannelSigner) -> WriteableEcdsaChannelSigner { - let mut res = WriteableEcdsaChannelSigner_clone_fields(orig); - if let Some(f) = orig.cloned { (f)(&mut res) }; - res -} -impl Clone for WriteableEcdsaChannelSigner { - fn clone(&self) -> Self { - WriteableEcdsaChannelSigner_clone(self) - } -} - -use lightning::sign::ecdsa::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 +impl core::ops::Deref for EcdsaChannelSigner { + type Target = EcdsaChannelSignerRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const EcdsaChannelSignerRef) } } } -impl core::ops::DerefMut for WriteableEcdsaChannelSigner { - fn deref_mut(&mut self) -> &mut Self { - self +impl core::ops::DerefMut for EcdsaChannelSigner { + fn deref_mut(&mut self) -> &mut EcdsaChannelSignerRef { + unsafe { &mut *(self as *mut _ as *mut EcdsaChannelSignerRef) } } } /// Calls the free function if one is set #[no_mangle] -pub extern "C" fn WriteableEcdsaChannelSigner_free(this_ptr: WriteableEcdsaChannelSigner) { } -impl Drop for WriteableEcdsaChannelSigner { +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); diff --git a/lightning-c-bindings/src/lightning/sign/mod.rs b/lightning-c-bindings/src/lightning/sign/mod.rs index 2c6ce8d..1f4b228 100644 --- a/lightning-c-bindings/src/lightning/sign/mod.rs +++ b/lightning-c-bindings/src/lightning/sign/mod.rs @@ -55,6 +55,12 @@ pub struct DelayedPaymentOutputDescriptor { pub is_owned: bool, } +impl core::ops::Deref for DelayedPaymentOutputDescriptor { + type Target = nativeDelayedPaymentOutputDescriptor; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for DelayedPaymentOutputDescriptor { } +unsafe impl core::marker::Sync for DelayedPaymentOutputDescriptor { } impl Drop for DelayedPaymentOutputDescriptor { fn drop(&mut self) { if self.is_owned && !<*mut nativeDelayedPaymentOutputDescriptor>::is_null(self.inner) { @@ -85,6 +91,9 @@ impl DelayedPaymentOutputDescriptor { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The outpoint which is spendable. #[no_mangle] @@ -258,7 +267,7 @@ pub extern "C" fn DelayedPaymentOutputDescriptor_write(obj: &crate::lightning::s } #[allow(unused)] 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) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::sign::nativeDelayedPaymentOutputDescriptor) }) } #[no_mangle] /// Read a DelayedPaymentOutputDescriptor from a byte array, created by DelayedPaymentOutputDescriptor_write @@ -289,6 +298,12 @@ pub struct StaticPaymentOutputDescriptor { pub is_owned: bool, } +impl core::ops::Deref for StaticPaymentOutputDescriptor { + type Target = nativeStaticPaymentOutputDescriptor; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for StaticPaymentOutputDescriptor { } +unsafe impl core::marker::Sync for StaticPaymentOutputDescriptor { } impl Drop for StaticPaymentOutputDescriptor { fn drop(&mut self) { if self.is_owned && !<*mut nativeStaticPaymentOutputDescriptor>::is_null(self.inner) { @@ -319,6 +334,9 @@ impl StaticPaymentOutputDescriptor { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The outpoint which is spendable. #[no_mangle] @@ -474,7 +492,7 @@ pub extern "C" fn StaticPaymentOutputDescriptor_write(obj: &crate::lightning::si } #[allow(unused)] 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) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::sign::nativeStaticPaymentOutputDescriptor) }) } #[no_mangle] /// Read a StaticPaymentOutputDescriptor from a byte array, created by StaticPaymentOutputDescriptor_write @@ -760,7 +778,7 @@ pub extern "C" fn SpendableOutputDescriptor_read(ser: crate::c_types::u8slice) - 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 +/// Creates an unsigned [`Psbt`] 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. /// @@ -781,8 +799,8 @@ pub extern "C" fn SpendableOutputDescriptor_read(ser: crate::c_types::u8slice) - 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_u32Z) -> crate::c_types::derived::CResult_C2Tuple_CVec_u8Zu64ZNoneZ { 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::blockdata::locktime::absolute::LockTime::from_consensus({ locktime_opt.take() }) }})} }; - let mut ret = lightning::sign::SpendableOutputDescriptor::create_spendable_outputs_psbt(secp256k1::global::SECP256K1, &local_descriptors.iter().collect::>()[..], local_outputs, ::bitcoin::blockdata::script::ScriptBuf::from(change_destination_script.into_rust()), feerate_sat_per_1000_weight, local_locktime); + let mut local_locktime = { /*locktime*/ let locktime_opt = locktime; if locktime_opt.is_none() { None } else { Some({ { ::bitcoin::locktime::absolute::LockTime::from_consensus({ locktime_opt.take() }) }})} }; + let mut ret = lightning::sign::SpendableOutputDescriptor::create_spendable_outputs_psbt(secp256k1::global::SECP256K1, &local_descriptors.iter().collect::>()[..], local_outputs, ::bitcoin::script::ScriptBuf::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 = (orig_ret_0_0.serialize().into(), orig_ret_0_1).into(); local_ret_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; local_ret } @@ -807,6 +825,12 @@ pub struct ChannelDerivationParameters { pub is_owned: bool, } +impl core::ops::Deref for ChannelDerivationParameters { + type Target = nativeChannelDerivationParameters; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ChannelDerivationParameters { } +unsafe impl core::marker::Sync for ChannelDerivationParameters { } impl Drop for ChannelDerivationParameters { fn drop(&mut self) { if self.is_owned && !<*mut nativeChannelDerivationParameters>::is_null(self.inner) { @@ -837,6 +861,9 @@ impl ChannelDerivationParameters { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The value in satoshis of the channel we're attempting to spend the anchor output of. #[no_mangle] @@ -921,7 +948,7 @@ pub extern "C" fn ChannelDerivationParameters_write(obj: &crate::lightning::sign } #[allow(unused)] pub(crate) extern "C" fn ChannelDerivationParameters_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelDerivationParameters) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::sign::nativeChannelDerivationParameters) }) } #[no_mangle] /// Read a ChannelDerivationParameters from a byte array, created by ChannelDerivationParameters_write @@ -950,6 +977,12 @@ pub struct HTLCDescriptor { pub is_owned: bool, } +impl core::ops::Deref for HTLCDescriptor { + type Target = nativeHTLCDescriptor; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for HTLCDescriptor { } +unsafe impl core::marker::Sync for HTLCDescriptor { } impl Drop for HTLCDescriptor { fn drop(&mut self) { if self.is_owned && !<*mut nativeHTLCDescriptor>::is_null(self.inner) { @@ -980,6 +1013,9 @@ impl HTLCDescriptor { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The parameters required to derive the signer for the HTLC input. #[no_mangle] @@ -1139,7 +1175,7 @@ pub extern "C" fn HTLCDescriptor_write(obj: &crate::lightning::sign::HTLCDescrip } #[allow(unused)] pub(crate) extern "C" fn HTLCDescriptor_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeHTLCDescriptor) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::sign::nativeHTLCDescriptor) }) } #[no_mangle] /// Read a HTLCDescriptor from a byte array, created by HTLCDescriptor_write @@ -1197,20 +1233,24 @@ pub extern "C" fn HTLCDescriptor_witness_script(this_arg: &crate::lightning::sig #[must_use] #[no_mangle] pub extern "C" fn HTLCDescriptor_tx_input_witness(this_arg: &crate::lightning::sign::HTLCDescriptor, mut signature: crate::c_types::ECDSASignature, 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_bytes(witness_script.to_slice())); + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.tx_input_witness(&signature.into_rust(), ::bitcoin::script::Script::from_bytes(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::sign::HTLCDescriptor, signer_provider: &crate::lightning::sign::SignerProvider) -> crate::lightning::sign::ecdsa::WriteableEcdsaChannelSigner { +pub extern "C" fn HTLCDescriptor_derive_channel_signer(this_arg: &crate::lightning::sign::HTLCDescriptor, signer_provider: &crate::lightning::sign::SignerProvider) -> crate::lightning::sign::ecdsa::EcdsaChannelSigner { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.derive_channel_signer(signer_provider); Into::into(ret) } /// A trait to handle Lightning channel key material without concretizing the channel type or /// the signature mechanism. +/// +/// Several methods allow error types to be returned to support async signing. This feature +/// is not yet complete, and panics may occur in certain situations when returning errors +/// for these methods. #[repr(C)] pub struct ChannelSigner { /// An opaque pointer which is passed to your function implementations as an argument. @@ -1219,7 +1259,12 @@ pub struct ChannelSigner { /// 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, + /// + /// If the signer returns `Err`, then the user is responsible for either force-closing the channel + /// or calling `ChannelManager::signer_unblocked` (this method is only available when the + /// `async_signing` cfg flag is enabled) once the signature is ready. + /// + pub get_per_commitment_point: extern "C" fn (this_arg: *const c_void, idx: u64) -> crate::c_types::derived::CResult_PublicKeyNoneZ, /// 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 @@ -1228,7 +1273,7 @@ pub struct ChannelSigner { /// 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, + pub release_commitment_secret: extern "C" fn (this_arg: *const c_void, idx: u64) -> crate::c_types::derived::CResult__u832NoneZ, /// 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 @@ -1292,15 +1337,17 @@ pub(crate) fn ChannelSigner_clone_fields(orig: &ChannelSigner) -> ChannelSigner 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 { + fn get_per_commitment_point(&self, mut idx: u64, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { let mut ret = (self.get_per_commitment_point)(self.this_arg, idx); - ret.into_rust() + 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 release_commitment_secret(&self, mut idx: u64) -> [u8; 32] { + fn release_commitment_secret(&self, mut idx: u64) -> Result<[u8; 32], ()> { let mut ret = (self.release_commitment_secret)(self.this_arg, idx); - ret.data + let mut local_ret = match ret.result_ok { true => Ok( { (*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 validate_holder_commitment(&self, mut holder_tx: &lightning::ln::chan_utils::HolderCommitmentTransaction, mut outbound_htlc_preimages: Vec) -> Result<(), ()> { + fn validate_holder_commitment(&self, mut holder_tx: &lightning::ln::chan_utils::HolderCommitmentTransaction, mut outbound_htlc_preimages: Vec) -> Result<(), ()> { let mut local_outbound_htlc_preimages = Vec::new(); for mut item in outbound_htlc_preimages.drain(..) { local_outbound_htlc_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_outbound_htlc_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)) })*/ })}; @@ -1326,17 +1373,55 @@ impl rustChannelSigner for ChannelSigner { } } +pub struct ChannelSignerRef(ChannelSigner); +impl rustChannelSigner for ChannelSignerRef { + fn get_per_commitment_point(&self, mut idx: u64, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { + let mut ret = (self.0.get_per_commitment_point)(self.0.this_arg, idx); + 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 release_commitment_secret(&self, mut idx: u64) -> Result<[u8; 32], ()> { + let mut ret = (self.0.release_commitment_secret)(self.0.this_arg, idx); + let mut local_ret = match ret.result_ok { true => Ok( { (*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 validate_holder_commitment(&self, mut holder_tx: &lightning::ln::chan_utils::HolderCommitmentTransaction, mut outbound_htlc_preimages: Vec) -> Result<(), ()> { + let mut local_outbound_htlc_preimages = Vec::new(); for mut item in outbound_htlc_preimages.drain(..) { local_outbound_htlc_preimages.push( { crate::c_types::ThirtyTwoBytes { data: item.0 } }); }; + let mut ret = (self.0.validate_holder_commitment)(self.0.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_outbound_htlc_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 validate_counterparty_revocation(&self, mut idx: u64, mut secret: &bitcoin::secp256k1::SecretKey) -> Result<(), ()> { + let mut ret = (self.0.validate_counterparty_revocation)(self.0.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 pubkeys(&self) -> &lightning::ln::chan_utils::ChannelPublicKeys { + if let Some(f) = self.0.set_pubkeys { + (f)(&self.0); + } + unsafe { &*self.0.pubkeys.get() }.get_native_ref() + } + fn channel_keys_id(&self) -> [u8; 32] { + let mut ret = (self.0.channel_keys_id)(self.0.this_arg); + ret.data + } + fn provide_channel_parameters(&mut self, mut channel_parameters: &lightning::ln::chan_utils::ChannelTransactionParameters) { + (self.0.provide_channel_parameters)(self.0.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 + type Target = ChannelSignerRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const ChannelSignerRef) } } } impl core::ops::DerefMut for ChannelSigner { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut ChannelSignerRef { + unsafe { &mut *(self as *mut _ as *mut ChannelSignerRef) } } } /// Calls the free function if one is set @@ -1454,17 +1539,25 @@ impl rustEntropySource for EntropySource { } } +pub struct EntropySourceRef(EntropySource); +impl rustEntropySource for EntropySourceRef { + fn get_secure_random_bytes(&self) -> [u8; 32] { + let mut ret = (self.0.get_secure_random_bytes)(self.0.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 + type Target = EntropySourceRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const EntropySourceRef) } } } impl core::ops::DerefMut for EntropySource { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut EntropySourceRef { + unsafe { &mut *(self as *mut _ as *mut EntropySourceRef) } } } /// Calls the free function if one is set @@ -1520,7 +1613,7 @@ pub struct NodeSigner { /// 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, + pub sign_invoice: extern "C" fn (this_arg: *const c_void, invoice: &crate::lightning_invoice::RawBolt11Invoice, recipient: crate::lightning::sign::Recipient) -> crate::c_types::derived::CResult_RecoverableSignatureNoneZ, /// Signs the [`TaggedHash`] of a BOLT 12 invoice request. /// /// May be called by a function passed to [`UnsignedInvoiceRequest::sign`] where @@ -1590,10 +1683,8 @@ impl rustNodeSigner for NodeSigner { 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)); + fn sign_invoice(&self, mut invoice: &lightning_invoice::RawBolt11Invoice, mut recipient: lightning::sign::Recipient) -> Result { + let mut ret = (self.sign_invoice)(self.this_arg, &crate::lightning_invoice::RawBolt11Invoice { inner: unsafe { ObjOps::nonnull_ptr_to_inner((invoice as *const lightning_invoice::RawBolt11Invoice<>) as *mut _) }, is_owned: false }, 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 } @@ -1614,17 +1705,56 @@ impl rustNodeSigner for NodeSigner { } } +pub struct NodeSignerRef(NodeSigner); +impl rustNodeSigner for NodeSignerRef { + fn get_inbound_payment_key_material(&self) -> lightning::sign::KeyMaterial { + let mut ret = (self.0.get_inbound_payment_key_material)(self.0.this_arg); + ::lightning::sign::KeyMaterial(ret.data) + } + fn get_node_id(&self, mut recipient: lightning::sign::Recipient) -> Result { + let mut ret = (self.0.get_node_id)(self.0.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_BigEndianScalarZ::None } else { crate::c_types::derived::COption_BigEndianScalarZ::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.0.ecdh)(self.0.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 invoice: &lightning_invoice::RawBolt11Invoice, mut recipient: lightning::sign::Recipient) -> Result { + let mut ret = (self.0.sign_invoice)(self.0.this_arg, &crate::lightning_invoice::RawBolt11Invoice { inner: unsafe { ObjOps::nonnull_ptr_to_inner((invoice as *const lightning_invoice::RawBolt11Invoice<>) as *mut _) }, is_owned: false }, 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_bolt12_invoice_request(&self, mut invoice_request: &lightning::offers::invoice_request::UnsignedInvoiceRequest) -> Result { + let mut ret = (self.0.sign_bolt12_invoice_request)(self.0.this_arg, &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest { inner: unsafe { ObjOps::nonnull_ptr_to_inner((invoice_request as *const lightning::offers::invoice_request::UnsignedInvoiceRequest<>) 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_bolt12_invoice(&self, mut invoice: &lightning::offers::invoice::UnsignedBolt12Invoice) -> Result { + let mut ret = (self.0.sign_bolt12_invoice)(self.0.this_arg, &crate::lightning::offers::invoice::UnsignedBolt12Invoice { inner: unsafe { ObjOps::nonnull_ptr_to_inner((invoice as *const lightning::offers::invoice::UnsignedBolt12Invoice<>) 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_gossip_message(&self, mut msg: lightning::ln::msgs::UnsignedGossipMessage) -> Result { + let mut ret = (self.0.sign_gossip_message)(self.0.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 + type Target = NodeSignerRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const NodeSignerRef) } } } impl core::ops::DerefMut for NodeSigner { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut NodeSignerRef { + unsafe { &mut *(self as *mut _ as *mut NodeSignerRef) } } } /// Calls the free function if one is set @@ -1674,7 +1804,7 @@ pub(crate) fn OutputSpender_clone_fields(orig: &OutputSpender) -> OutputSpender use lightning::sign::OutputSpender as rustOutputSpender; impl rustOutputSpender for OutputSpender { - fn spend_spendable_outputs(&self, mut descriptors: &[&lightning::sign::SpendableOutputDescriptor], mut outputs: Vec, mut change_destination_script: bitcoin::blockdata::script::ScriptBuf, mut feerate_sat_per_1000_weight: u32, mut locktime: Option, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { + fn spend_spendable_outputs(&self, mut descriptors: &[&lightning::sign::SpendableOutputDescriptor], mut outputs: Vec, mut change_destination_script: bitcoin::script::ScriptBuf, mut feerate_sat_per_1000_weight: u32, mut locktime: Option, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { let mut local_descriptors = Vec::new(); for item in descriptors.iter() { local_descriptors.push( { crate::lightning::sign::SpendableOutputDescriptor::from_native((*item)) }); }; let mut local_outputs = Vec::new(); for mut item in outputs.drain(..) { local_outputs.push( { crate::c_types::TxOut::from_rust(&item) }); }; let mut local_locktime = if locktime.is_none() { crate::c_types::derived::COption_u32Z::None } else { crate::c_types::derived::COption_u32Z::Some( { locktime.unwrap().to_consensus_u32() }) }; @@ -1684,17 +1814,29 @@ impl rustOutputSpender for OutputSpender { } } +pub struct OutputSpenderRef(OutputSpender); +impl rustOutputSpender for OutputSpenderRef { + fn spend_spendable_outputs(&self, mut descriptors: &[&lightning::sign::SpendableOutputDescriptor], mut outputs: Vec, mut change_destination_script: bitcoin::script::ScriptBuf, mut feerate_sat_per_1000_weight: u32, mut locktime: Option, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { + let mut local_descriptors = Vec::new(); for item in descriptors.iter() { local_descriptors.push( { crate::lightning::sign::SpendableOutputDescriptor::from_native((*item)) }); }; + let mut local_outputs = Vec::new(); for mut item in outputs.drain(..) { local_outputs.push( { crate::c_types::TxOut::from_rust(&item) }); }; + let mut local_locktime = if locktime.is_none() { crate::c_types::derived::COption_u32Z::None } else { crate::c_types::derived::COption_u32Z::Some( { locktime.unwrap().to_consensus_u32() }) }; + let mut ret = (self.0.spend_spendable_outputs)(self.0.this_arg, local_descriptors.into(), local_outputs.into(), change_destination_script.to_bytes().into(), feerate_sat_per_1000_weight, local_locktime); + 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 OutputSpender { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = OutputSpenderRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const OutputSpenderRef) } } } impl core::ops::DerefMut for OutputSpender { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut OutputSpenderRef { + unsafe { &mut *(self as *mut _ as *mut OutputSpenderRef) } } } /// Calls the free function if one is set @@ -1726,10 +1868,10 @@ pub struct SignerProvider { /// [`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::ecdsa::WriteableEcdsaChannelSigner, + 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::ecdsa::EcdsaChannelSigner, /// 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). + /// [`EcdsaChannelSigner`]-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. @@ -1740,7 +1882,7 @@ pub struct SignerProvider { /// [`Signer`]: Self::EcdsaSigner /// [`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, + pub read_chan_signer: extern "C" fn (this_arg: *const c_void, reader: crate::c_types::u8slice) -> crate::c_types::derived::CResult_EcdsaChannelSignerDecodeErrorZ, /// 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. @@ -1779,24 +1921,24 @@ pub(crate) fn SignerProvider_clone_fields(orig: &SignerProvider) -> SignerProvid use lightning::sign::SignerProvider as rustSignerProvider; impl rustSignerProvider for SignerProvider { - type EcdsaSigner = crate::lightning::sign::ecdsa::WriteableEcdsaChannelSigner; + type EcdsaSigner = crate::lightning::sign::ecdsa::EcdsaChannelSigner; 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::ecdsa::WriteableEcdsaChannelSigner { + fn derive_channel_signer(&self, mut channel_value_satoshis: u64, mut channel_keys_id: [u8; 32]) -> crate::lightning::sign::ecdsa::EcdsaChannelSigner { 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 { + 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, mut channel_keys_id: [u8; 32]) -> Result { + fn get_destination_script(&self, mut channel_keys_id: [u8; 32]) -> Result { let mut ret = (self.get_destination_script)(self.this_arg, crate::c_types::ThirtyTwoBytes { data: channel_keys_id }); - let mut local_ret = match ret.result_ok { true => Ok( { ::bitcoin::blockdata::script::ScriptBuf::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)) })*/ })}; + let mut local_ret = match ret.result_ok { true => Ok( { ::bitcoin::script::ScriptBuf::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 { @@ -1806,17 +1948,46 @@ impl rustSignerProvider for SignerProvider { } } +pub struct SignerProviderRef(SignerProvider); +impl rustSignerProvider for SignerProviderRef { + type EcdsaSigner = crate::lightning::sign::ecdsa::EcdsaChannelSigner; + 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.0.generate_channel_keys_id)(self.0.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::ecdsa::EcdsaChannelSigner { + let mut ret = (self.0.derive_channel_signer)(self.0.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.0.read_chan_signer)(self.0.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, mut channel_keys_id: [u8; 32]) -> Result { + let mut ret = (self.0.get_destination_script)(self.0.this_arg, crate::c_types::ThirtyTwoBytes { data: channel_keys_id }); + let mut local_ret = match ret.result_ok { true => Ok( { ::bitcoin::script::ScriptBuf::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.0.get_shutdown_scriptpubkey)(self.0.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 + type Target = SignerProviderRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const SignerProviderRef) } } } impl core::ops::DerefMut for SignerProvider { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut SignerProviderRef { + unsafe { &mut *(self as *mut _ as *mut SignerProviderRef) } } } /// Calls the free function if one is set @@ -1859,9 +2030,18 @@ pub(crate) fn ChangeDestinationSource_clone_fields(orig: &ChangeDestinationSourc use lightning::sign::ChangeDestinationSource as rustChangeDestinationSource; impl rustChangeDestinationSource for ChangeDestinationSource { - fn get_change_destination_script(&self) -> Result { + fn get_change_destination_script(&self) -> Result { let mut ret = (self.get_change_destination_script)(self.this_arg); - let mut local_ret = match ret.result_ok { true => Ok( { ::bitcoin::blockdata::script::ScriptBuf::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)) })*/ })}; + let mut local_ret = match ret.result_ok { true => Ok( { ::bitcoin::script::ScriptBuf::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 + } +} + +pub struct ChangeDestinationSourceRef(ChangeDestinationSource); +impl rustChangeDestinationSource for ChangeDestinationSourceRef { + fn get_change_destination_script(&self) -> Result { + let mut ret = (self.0.get_change_destination_script)(self.0.this_arg); + let mut local_ret = match ret.result_ok { true => Ok( { ::bitcoin::script::ScriptBuf::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 } } @@ -1869,14 +2049,14 @@ impl rustChangeDestinationSource for ChangeDestinationSource { // 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 ChangeDestinationSource { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = ChangeDestinationSourceRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const ChangeDestinationSourceRef) } } } impl core::ops::DerefMut for ChangeDestinationSource { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut ChangeDestinationSourceRef { + unsafe { &mut *(self as *mut _ as *mut ChangeDestinationSourceRef) } } } /// Calls the free function if one is set @@ -1893,7 +2073,7 @@ impl Drop for ChangeDestinationSource { use lightning::sign::InMemorySigner as nativeInMemorySignerImport; pub(crate) type nativeInMemorySigner = nativeInMemorySignerImport; -/// A simple implementation of [`WriteableEcdsaChannelSigner`] that just keeps the private keys in memory. +/// A simple implementation of [`EcdsaChannelSigner`] that just keeps the private keys in memory. /// /// This implementation performs no policy checks and is insufficient by itself as /// a secure external signer. @@ -1912,6 +2092,12 @@ pub struct InMemorySigner { pub is_owned: bool, } +impl core::ops::Deref for InMemorySigner { + type Target = nativeInMemorySigner; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for InMemorySigner { } +unsafe impl core::marker::Sync for InMemorySigner { } impl Drop for InMemorySigner { fn drop(&mut self) { if self.is_owned && !<*mut nativeInMemorySigner>::is_null(self.inner) { @@ -1942,6 +2128,9 @@ impl InMemorySigner { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// 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. @@ -2133,9 +2322,9 @@ pub extern "C" fn InMemorySigner_get_channel_parameters(this_arg: &crate::lightn /// 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 InMemorySigner_channel_type_features(this_arg: &crate::lightning::sign::InMemorySigner) -> crate::lightning::ln::features::ChannelTypeFeatures { +pub extern "C" fn InMemorySigner_channel_type_features(this_arg: &crate::lightning::sign::InMemorySigner) -> crate::lightning_types::features::ChannelTypeFeatures { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.channel_type_features(); - let mut local_ret = crate::lightning::ln::features::ChannelTypeFeatures { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning::ln::features::ChannelTypeFeatures<>) as *mut _ }, is_owned: false }; + let mut local_ret = crate::lightning_types::features::ChannelTypeFeatures { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning_types::features::ChannelTypeFeatures<>) as *mut _ }, is_owned: false }; local_ret } @@ -2230,14 +2419,16 @@ pub extern "C" fn InMemorySigner_as_ChannelSigner(this_arg: &InMemorySigner) -> } #[must_use] -extern "C" fn InMemorySigner_ChannelSigner_get_per_commitment_point(this_arg: *const c_void, mut idx: u64) -> crate::c_types::PublicKey { +extern "C" fn InMemorySigner_ChannelSigner_get_per_commitment_point(this_arg: *const c_void, mut idx: u64) -> crate::c_types::derived::CResult_PublicKeyNoneZ { 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) + 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 InMemorySigner_ChannelSigner_release_commitment_secret(this_arg: *const c_void, mut idx: u64) -> crate::c_types::ThirtyTwoBytes { +extern "C" fn InMemorySigner_ChannelSigner_release_commitment_secret(this_arg: *const c_void, mut idx: u64) -> crate::c_types::derived::CResult__u832NoneZ { let mut ret = ::release_commitment_secret(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, idx); - crate::c_types::ThirtyTwoBytes { data: ret } + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ThirtyTwoBytes { data: o } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_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 outbound_htlc_preimages: crate::c_types::derived::CVec_ThirtyTwoBytesZ) -> crate::c_types::derived::CResult_NoneNoneZ { @@ -2257,11 +2448,11 @@ extern "C" fn InMemorySigner_ChannelSigner_pubkeys(this_arg: *const c_void) -> c 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) { +extern "C" fn InMemorySigner_ChannelSigner_set_pubkeys(trait_self_arg: &crate::lightning::sign::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(); + *unsafe { &mut *(&*(trait_self_arg as *const crate::lightning::sign::ChannelSigner)).pubkeys.get() } = InMemorySigner_ChannelSigner_pubkeys(trait_self_arg.this_arg).into(); } } #[must_use] @@ -2312,6 +2503,7 @@ pub extern "C" fn InMemorySigner_as_EcdsaChannelSigner(this_arg: &InMemorySigner channel_keys_id: InMemorySigner_ChannelSigner_channel_keys_id, provide_channel_parameters: InMemorySigner_ChannelSigner_provide_channel_parameters, }, + cloned: Some(EcdsaChannelSigner_InMemorySigner_cloned), } } @@ -2371,62 +2563,11 @@ extern "C" fn InMemorySigner_EcdsaChannelSigner_sign_channel_announcement_with_f let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ECDSASignature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; local_ret } - -impl From for crate::lightning::sign::ecdsa::WriteableEcdsaChannelSigner { - fn from(obj: nativeInMemorySigner) -> Self { - let rust_obj = crate::lightning::sign::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 forget it and set ret's free() fn - core::mem::forget(rust_obj); - 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::ecdsa::WriteableEcdsaChannelSigner { - crate::lightning::sign::ecdsa::WriteableEcdsaChannelSigner { - this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, - free: None, - EcdsaChannelSigner: crate::lightning::sign::ecdsa::EcdsaChannelSigner { - this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, - free: None, - sign_counterparty_commitment: InMemorySigner_EcdsaChannelSigner_sign_counterparty_commitment, - sign_holder_commitment: InMemorySigner_EcdsaChannelSigner_sign_holder_commitment, - 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, - validate_counterparty_revocation: InMemorySigner_ChannelSigner_validate_counterparty_revocation, - - 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, - cloned: Some(WriteableEcdsaChannelSigner_InMemorySigner_cloned), - } -} - -extern "C" fn WriteableEcdsaChannelSigner_InMemorySigner_cloned(new_obj: &mut crate::lightning::sign::ecdsa::WriteableEcdsaChannelSigner) { +extern "C" fn EcdsaChannelSigner_InMemorySigner_cloned(new_obj: &mut crate::lightning::sign::ecdsa::EcdsaChannelSigner) { new_obj.this_arg = InMemorySigner_clone_void(new_obj.this_arg); new_obj.free = Some(InMemorySigner_free_void); - new_obj.EcdsaChannelSigner.this_arg = new_obj.this_arg; - new_obj.EcdsaChannelSigner.free = None; - new_obj.EcdsaChannelSigner.ChannelSigner.this_arg = new_obj.this_arg; - new_obj.EcdsaChannelSigner.ChannelSigner.free = None; + new_obj.ChannelSigner.this_arg = new_obj.this_arg; + new_obj.ChannelSigner.free = None; } #[no_mangle] @@ -2436,7 +2577,7 @@ pub extern "C" fn InMemorySigner_write(obj: &crate::lightning::sign::InMemorySig } #[allow(unused)] 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) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::sign::nativeInMemorySigner) }) } #[no_mangle] /// Read a InMemorySigner from a byte array, created by InMemorySigner_write @@ -2478,6 +2619,12 @@ pub struct KeysManager { pub is_owned: bool, } +impl core::ops::Deref for KeysManager { + type Target = nativeKeysManager; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for KeysManager { } +unsafe impl core::marker::Sync for KeysManager { } impl Drop for KeysManager { fn drop(&mut self) { if self.is_owned && !<*mut nativeKeysManager>::is_null(self.inner) { @@ -2508,6 +2655,9 @@ impl KeysManager { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// 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). @@ -2541,7 +2691,7 @@ pub extern "C" fn KeysManager_get_node_secret_key(this_arg: &crate::lightning::s crate::c_types::SecretKey::from_rust(ret) } -/// Derive an old [`WriteableEcdsaChannelSigner`] containing per-channel secrets based on a key derivation parameters. +/// Derive an old [`EcdsaChannelSigner`] 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 { @@ -2549,7 +2699,7 @@ pub extern "C" fn KeysManager_derive_channel_keys(this_arg: &crate::lightning::s crate::lightning::sign::InMemorySigner { inner: ObjOps::heap_alloc(ret), is_owned: true } } -/// Signs the given [`PartiallySignedTransaction`] which spends the given [`SpendableOutputDescriptor`]s. +/// Signs the given [`Psbt`] 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. /// @@ -2561,7 +2711,7 @@ pub extern "C" fn KeysManager_derive_channel_keys(this_arg: &crate::lightning::s #[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_CVec_u8ZNoneZ { 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::psbt::PartiallySignedTransaction::deserialize(psbt.as_slice()).expect("Invalid PSBT format"), secp256k1::global::SECP256K1); + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.sign_spendable_outputs_psbt(&local_descriptors.iter().collect::>()[..], ::bitcoin::Psbt::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( { o.serialize().into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; local_ret } @@ -2639,9 +2789,8 @@ extern "C" fn KeysManager_NodeSigner_ecdh(this_arg: *const c_void, mut recipient 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()); +extern "C" fn KeysManager_NodeSigner_sign_invoice(this_arg: *const c_void, invoice: &crate::lightning_invoice::RawBolt11Invoice, mut recipient: crate::lightning::sign::Recipient) -> crate::c_types::derived::CResult_RecoverableSignatureNoneZ { + let mut ret = ::sign_invoice(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, invoice.get_native_ref(), 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 } @@ -2689,8 +2838,8 @@ pub extern "C" fn KeysManager_as_OutputSpender(this_arg: &KeysManager) -> crate: extern "C" fn KeysManager_OutputSpender_spend_spendable_outputs(this_arg: *const c_void, 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_u32Z) -> 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::blockdata::locktime::absolute::LockTime::from_consensus({ locktime_opt.take() }) }})} }; - let mut ret = ::spend_spendable_outputs(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, &local_descriptors.iter().collect::>()[..], local_outputs, ::bitcoin::blockdata::script::ScriptBuf::from(change_destination_script.into_rust()), feerate_sat_per_1000_weight, local_locktime, secp256k1::global::SECP256K1); + let mut local_locktime = { /*locktime*/ let locktime_opt = locktime; if locktime_opt.is_none() { None } else { Some({ { ::bitcoin::locktime::absolute::LockTime::from_consensus({ locktime_opt.take() }) }})} }; + let mut ret = ::spend_spendable_outputs(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, &local_descriptors.iter().collect::>()[..], local_outputs, ::bitcoin::script::ScriptBuf::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 } @@ -2726,12 +2875,12 @@ extern "C" fn KeysManager_SignerProvider_generate_channel_keys_id(this_arg: *con 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::ecdsa::WriteableEcdsaChannelSigner { +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::ecdsa::EcdsaChannelSigner { 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 { +extern "C" fn KeysManager_SignerProvider_read_chan_signer(this_arg: *const c_void, mut reader: crate::c_types::u8slice) -> crate::c_types::derived::CResult_EcdsaChannelSignerDecodeErrorZ { 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 @@ -2783,6 +2932,12 @@ pub struct PhantomKeysManager { pub is_owned: bool, } +impl core::ops::Deref for PhantomKeysManager { + type Target = nativePhantomKeysManager; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for PhantomKeysManager { } +unsafe impl core::marker::Sync for PhantomKeysManager { } impl Drop for PhantomKeysManager { fn drop(&mut self) { if self.is_owned && !<*mut nativePhantomKeysManager>::is_null(self.inner) { @@ -2813,6 +2968,9 @@ impl PhantomKeysManager { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } impl From for crate::lightning::sign::EntropySource { fn from(obj: nativePhantomKeysManager) -> Self { @@ -2887,9 +3045,8 @@ extern "C" fn PhantomKeysManager_NodeSigner_ecdh(this_arg: *const c_void, mut re 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()); +extern "C" fn PhantomKeysManager_NodeSigner_sign_invoice(this_arg: *const c_void, invoice: &crate::lightning_invoice::RawBolt11Invoice, mut recipient: crate::lightning::sign::Recipient) -> crate::c_types::derived::CResult_RecoverableSignatureNoneZ { + let mut ret = ::sign_invoice(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, invoice.get_native_ref(), 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 } @@ -2937,8 +3094,8 @@ pub extern "C" fn PhantomKeysManager_as_OutputSpender(this_arg: &PhantomKeysMana extern "C" fn PhantomKeysManager_OutputSpender_spend_spendable_outputs(this_arg: *const c_void, 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_u32Z) -> 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::blockdata::locktime::absolute::LockTime::from_consensus({ locktime_opt.take() }) }})} }; - let mut ret = ::spend_spendable_outputs(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, &local_descriptors.iter().collect::>()[..], local_outputs, ::bitcoin::blockdata::script::ScriptBuf::from(change_destination_script.into_rust()), feerate_sat_per_1000_weight, local_locktime, secp256k1::global::SECP256K1); + let mut local_locktime = { /*locktime*/ let locktime_opt = locktime; if locktime_opt.is_none() { None } else { Some({ { ::bitcoin::locktime::absolute::LockTime::from_consensus({ locktime_opt.take() }) }})} }; + let mut ret = ::spend_spendable_outputs(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, &local_descriptors.iter().collect::>()[..], local_outputs, ::bitcoin::script::ScriptBuf::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 } @@ -2974,12 +3131,12 @@ extern "C" fn PhantomKeysManager_SignerProvider_generate_channel_keys_id(this_ar 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::ecdsa::WriteableEcdsaChannelSigner { +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::ecdsa::EcdsaChannelSigner { 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 { +extern "C" fn PhantomKeysManager_SignerProvider_read_chan_signer(this_arg: *const c_void, mut reader: crate::c_types::u8slice) -> crate::c_types::derived::CResult_EcdsaChannelSignerDecodeErrorZ { 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 @@ -3060,6 +3217,12 @@ pub struct RandomBytes { pub is_owned: bool, } +impl core::ops::Deref for RandomBytes { + type Target = nativeRandomBytes; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for RandomBytes { } +unsafe impl core::marker::Sync for RandomBytes { } impl Drop for RandomBytes { fn drop(&mut self) { if self.is_owned && !<*mut nativeRandomBytes>::is_null(self.inner) { @@ -3090,6 +3253,9 @@ impl RandomBytes { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Get a string which allows debug introspection of a RandomBytes object pub extern "C" fn RandomBytes_debug_str_void(o: *const c_void) -> Str { diff --git a/lightning-c-bindings/src/lightning/util/config.rs b/lightning-c-bindings/src/lightning/util/config.rs index bfea17b..5573510 100644 --- a/lightning-c-bindings/src/lightning/util/config.rs +++ b/lightning-c-bindings/src/lightning/util/config.rs @@ -24,7 +24,7 @@ pub(crate) type nativeChannelHandshakeConfig = nativeChannelHandshakeConfigImpor /// Configuration we set when applicable. /// -/// Default::default() provides sane defaults. +/// `Default::default()` provides sane defaults. #[must_use] #[repr(C)] pub struct ChannelHandshakeConfig { @@ -40,6 +40,12 @@ pub struct ChannelHandshakeConfig { pub is_owned: bool, } +impl core::ops::Deref for ChannelHandshakeConfig { + type Target = nativeChannelHandshakeConfig; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ChannelHandshakeConfig { } +unsafe impl core::marker::Sync for ChannelHandshakeConfig { } impl Drop for ChannelHandshakeConfig { fn drop(&mut self) { if self.is_owned && !<*mut nativeChannelHandshakeConfig>::is_null(self.inner) { @@ -70,17 +76,20 @@ impl ChannelHandshakeConfig { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Confirmations we will wait for before considering the channel locked in. -/// Applied only for inbound channels (see ChannelHandshakeLimits::max_minimum_depth for the +/// 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 +/// 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. +/// 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 @@ -90,15 +99,15 @@ pub extern "C" fn ChannelHandshakeConfig_get_minimum_depth(this_ptr: &ChannelHan *inner_val } /// Confirmations we will wait for before considering the channel locked in. -/// Applied only for inbound channels (see ChannelHandshakeLimits::max_minimum_depth for the +/// 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 +/// 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. +/// 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 @@ -119,8 +128,8 @@ pub extern "C" fn ChannelHandshakeConfig_set_minimum_depth(this_ptr: &mut Channe /// 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. +/// 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.) #[no_mangle] pub extern "C" fn ChannelHandshakeConfig_get_our_to_self_delay(this_ptr: &ChannelHandshakeConfig) -> u16 { let mut inner_val = &mut this_ptr.get_native_mut_ref().our_to_self_delay; @@ -139,8 +148,8 @@ pub extern "C" fn ChannelHandshakeConfig_get_our_to_self_delay(this_ptr: &Channe /// 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. +/// 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.) #[no_mangle] pub extern "C" fn ChannelHandshakeConfig_set_our_to_self_delay(this_ptr: &mut ChannelHandshakeConfig, mut val: u16) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.our_to_self_delay = val; @@ -150,8 +159,8 @@ pub extern "C" fn ChannelHandshakeConfig_set_our_to_self_delay(this_ptr: &mut Ch /// 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. +/// Default value: `1` (If the value is less than `1`, it is ignored and set to `1`, as is +/// required by the protocol. #[no_mangle] pub extern "C" fn ChannelHandshakeConfig_get_our_htlc_minimum_msat(this_ptr: &ChannelHandshakeConfig) -> u64 { let mut inner_val = &mut this_ptr.get_native_mut_ref().our_htlc_minimum_msat; @@ -162,8 +171,8 @@ pub extern "C" fn ChannelHandshakeConfig_get_our_htlc_minimum_msat(this_ptr: &Ch /// 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. +/// Default value: `1` (If the value is less than `1`, it is ignored and set to `1`, as is +/// required by the protocol. #[no_mangle] pub extern "C" fn ChannelHandshakeConfig_set_our_htlc_minimum_msat(this_ptr: &mut ChannelHandshakeConfig, mut val: u64) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.our_htlc_minimum_msat = val; @@ -175,22 +184,24 @@ pub extern "C" fn ChannelHandshakeConfig_set_our_htlc_minimum_msat(this_ptr: &mu /// 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`. +/// * 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. +/// 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. +/// 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` /// -/// 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. +/// Minimum value: `1` (Any values less will be treated as `1` instead.) +/// +/// Maximum value: `100` (Any values larger will be treated as `100` instead.) #[no_mangle] pub extern "C" fn ChannelHandshakeConfig_get_max_inbound_htlc_value_in_flight_percent_of_channel(this_ptr: &ChannelHandshakeConfig) -> u8 { let mut inner_val = &mut this_ptr.get_native_mut_ref().max_inbound_htlc_value_in_flight_percent_of_channel; @@ -203,22 +214,24 @@ pub extern "C" fn ChannelHandshakeConfig_get_max_inbound_htlc_value_in_flight_pe /// 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`. +/// * 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. +/// 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. +/// 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` /// -/// 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. +/// Minimum value: `1` (Any values less will be treated as `1` instead.) +/// +/// Maximum value: `100` (Any values larger will be treated as `100` instead.) #[no_mangle] pub extern "C" fn ChannelHandshakeConfig_set_max_inbound_htlc_value_in_flight_percent_of_channel(this_ptr: &mut ChannelHandshakeConfig, mut val: u8) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_inbound_htlc_value_in_flight_percent_of_channel = val; @@ -237,10 +250,10 @@ pub extern "C" fn ChannelHandshakeConfig_set_max_inbound_htlc_value_in_flight_pe /// private channel without that option. /// /// Ignored if the channel is negotiated to be announced, see -/// [`ChannelHandshakeConfig::announced_channel`] and +/// [`ChannelHandshakeConfig::announce_for_forwarding`] and /// [`ChannelHandshakeLimits::force_announced_channel_preference`] for more. /// -/// Default value: false. This value is likely to change to true in the future. +/// 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 @@ -263,10 +276,10 @@ pub extern "C" fn ChannelHandshakeConfig_get_negotiate_scid_privacy(this_ptr: &C /// private channel without that option. /// /// Ignored if the channel is negotiated to be announced, see -/// [`ChannelHandshakeConfig::announced_channel`] and +/// [`ChannelHandshakeConfig::announce_for_forwarding`] and /// [`ChannelHandshakeLimits::force_announced_channel_preference`] for more. /// -/// Default value: false. This value is likely to change to true in the future. +/// 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 @@ -282,10 +295,10 @@ pub extern "C" fn ChannelHandshakeConfig_set_negotiate_scid_privacy(this_ptr: &m /// 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. +/// Default value: `false` #[no_mangle] -pub extern "C" fn ChannelHandshakeConfig_get_announced_channel(this_ptr: &ChannelHandshakeConfig) -> bool { - let mut inner_val = &mut this_ptr.get_native_mut_ref().announced_channel; +pub extern "C" fn ChannelHandshakeConfig_get_announce_for_forwarding(this_ptr: &ChannelHandshakeConfig) -> bool { + let mut inner_val = &mut this_ptr.get_native_mut_ref().announce_for_forwarding; *inner_val } /// Set to announce the channel publicly and notify all nodes that they can route via this @@ -296,10 +309,10 @@ pub extern "C" fn ChannelHandshakeConfig_get_announced_channel(this_ptr: &Channe /// 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. +/// Default value: `false` #[no_mangle] -pub extern "C" fn ChannelHandshakeConfig_set_announced_channel(this_ptr: &mut ChannelHandshakeConfig, mut val: bool) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.announced_channel = val; +pub extern "C" fn ChannelHandshakeConfig_set_announce_for_forwarding(this_ptr: &mut ChannelHandshakeConfig, mut val: bool) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.announce_for_forwarding = val; } /// 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 @@ -311,7 +324,7 @@ pub extern "C" fn ChannelHandshakeConfig_set_announced_channel(this_ptr: &mut Ch /// /// The upfront key committed is provided from [`SignerProvider::get_shutdown_scriptpubkey`]. /// -/// Default value: true. +/// Default value: `true` /// /// [`SignerProvider::get_shutdown_scriptpubkey`]: crate::sign::SignerProvider::get_shutdown_scriptpubkey #[no_mangle] @@ -329,7 +342,7 @@ pub extern "C" fn ChannelHandshakeConfig_get_commit_upfront_shutdown_pubkey(this /// /// The upfront key committed is provided from [`SignerProvider::get_shutdown_scriptpubkey`]. /// -/// Default value: true. +/// Default value: `true` /// /// [`SignerProvider::get_shutdown_scriptpubkey`]: crate::sign::SignerProvider::get_shutdown_scriptpubkey #[no_mangle] @@ -353,11 +366,15 @@ pub extern "C" fn ChannelHandshakeConfig_set_commit_upfront_shutdown_pubkey(this /// 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. +/// Default value: `10_000` millionths (i.e., 1% of channel value) +/// +/// 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` (i.e., 100% of channel value. Any values larger than one million +/// will be treated as one million instead, although channel negotiations will +/// fail in that case.) #[no_mangle] pub extern "C" fn ChannelHandshakeConfig_get_their_channel_reserve_proportional_millionths(this_ptr: &ChannelHandshakeConfig) -> u32 { let mut inner_val = &mut this_ptr.get_native_mut_ref().their_channel_reserve_proportional_millionths; @@ -380,11 +397,15 @@ pub extern "C" fn ChannelHandshakeConfig_get_their_channel_reserve_proportional_ /// 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. +/// Default value: `10_000` millionths (i.e., 1% of channel value) +/// +/// 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` (i.e., 100% of channel value. Any values larger than one million +/// will be treated as one million instead, although channel negotiations will +/// fail in that case.) #[no_mangle] 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; @@ -411,7 +432,7 @@ pub extern "C" fn ChannelHandshakeConfig_set_their_channel_reserve_proportional_ /// 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. +/// 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 @@ -444,7 +465,7 @@ pub extern "C" fn ChannelHandshakeConfig_get_negotiate_anchors_zero_fee_htlc_tx( /// 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. +/// 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 @@ -462,9 +483,10 @@ pub extern "C" fn ChannelHandshakeConfig_set_negotiate_anchors_zero_fee_htlc_tx( /// 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`. +/// 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`.) #[no_mangle] pub extern "C" fn ChannelHandshakeConfig_get_our_max_accepted_htlcs(this_ptr: &ChannelHandshakeConfig) -> u16 { let mut inner_val = &mut this_ptr.get_native_mut_ref().our_max_accepted_htlcs; @@ -478,9 +500,10 @@ pub extern "C" fn ChannelHandshakeConfig_get_our_max_accepted_htlcs(this_ptr: &C /// 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`. +/// 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`.) #[no_mangle] pub extern "C" fn ChannelHandshakeConfig_set_our_max_accepted_htlcs(this_ptr: &mut ChannelHandshakeConfig, mut val: u16) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.our_max_accepted_htlcs = val; @@ -488,14 +511,14 @@ 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 negotiate_anchors_zero_fee_htlc_tx_arg: bool, 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 announce_for_forwarding_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, our_htlc_minimum_msat: our_htlc_minimum_msat_arg, max_inbound_htlc_value_in_flight_percent_of_channel: max_inbound_htlc_value_in_flight_percent_of_channel_arg, negotiate_scid_privacy: negotiate_scid_privacy_arg, - announced_channel: announced_channel_arg, + announce_for_forwarding: announce_for_forwarding_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, @@ -538,7 +561,7 @@ pub(crate) type nativeChannelHandshakeLimits = nativeChannelHandshakeLimitsImpor /// /// These limits are only applied to our counterparty's limits, not our own. /// -/// Use 0/`::max_value()` as appropriate to skip checking. +/// Use `0` or `::max_value()` as appropriate to skip checking. /// /// Provides sane defaults for most configurations. /// @@ -560,6 +583,12 @@ pub struct ChannelHandshakeLimits { pub is_owned: bool, } +impl core::ops::Deref for ChannelHandshakeLimits { + type Target = nativeChannelHandshakeLimits; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ChannelHandshakeLimits { } +unsafe impl core::marker::Sync for ChannelHandshakeLimits { } impl Drop for ChannelHandshakeLimits { fn drop(&mut self) { if self.is_owned && !<*mut nativeChannelHandshakeLimits>::is_null(self.inner) { @@ -590,11 +619,15 @@ impl ChannelHandshakeLimits { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Minimum allowed satoshis when a channel is funded. This is supplied by the sender and so /// only applies to inbound channels. /// -/// Default value: 0. +/// Default value: `1000` +/// (Minimum of [`ChannelHandshakeConfig::their_channel_reserve_proportional_millionths`]) #[no_mangle] pub extern "C" fn ChannelHandshakeLimits_get_min_funding_satoshis(this_ptr: &ChannelHandshakeLimits) -> u64 { let mut inner_val = &mut this_ptr.get_native_mut_ref().min_funding_satoshis; @@ -603,7 +636,8 @@ pub extern "C" fn ChannelHandshakeLimits_get_min_funding_satoshis(this_ptr: &Cha /// Minimum allowed satoshis when a channel is funded. This is supplied by the sender and so /// only applies to inbound channels. /// -/// Default value: 0. +/// Default value: `1000` +/// (Minimum of [`ChannelHandshakeConfig::their_channel_reserve_proportional_millionths`]) #[no_mangle] pub extern "C" fn ChannelHandshakeLimits_set_min_funding_satoshis(this_ptr: &mut ChannelHandshakeLimits, mut val: u64) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.min_funding_satoshis = val; @@ -611,7 +645,7 @@ pub extern "C" fn ChannelHandshakeLimits_set_min_funding_satoshis(this_ptr: &mut /// 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. +/// Default value: `2^24 - 1` #[no_mangle] pub extern "C" fn ChannelHandshakeLimits_get_max_funding_satoshis(this_ptr: &ChannelHandshakeLimits) -> u64 { let mut inner_val = &mut this_ptr.get_native_mut_ref().max_funding_satoshis; @@ -620,7 +654,7 @@ pub extern "C" fn ChannelHandshakeLimits_get_max_funding_satoshis(this_ptr: &Cha /// 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. +/// Default value: `2^24 - 1` #[no_mangle] pub extern "C" fn ChannelHandshakeLimits_set_max_funding_satoshis(this_ptr: &mut ChannelHandshakeLimits, mut val: u64) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_funding_satoshis = val; @@ -628,7 +662,7 @@ pub extern "C" fn ChannelHandshakeLimits_set_max_funding_satoshis(this_ptr: &mut /// 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. +/// Default value: `u64::max_value` #[no_mangle] pub extern "C" fn ChannelHandshakeLimits_get_max_htlc_minimum_msat(this_ptr: &ChannelHandshakeLimits) -> u64 { let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_minimum_msat; @@ -637,7 +671,7 @@ pub extern "C" fn ChannelHandshakeLimits_get_max_htlc_minimum_msat(this_ptr: &Ch /// 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. +/// Default value: `u64::max_value` #[no_mangle] pub extern "C" fn ChannelHandshakeLimits_set_max_htlc_minimum_msat(this_ptr: &mut ChannelHandshakeLimits, mut val: u64) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_minimum_msat = val; @@ -645,7 +679,7 @@ pub extern "C" fn ChannelHandshakeLimits_set_max_htlc_minimum_msat(this_ptr: &mu /// 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. +/// Default value: `0` #[no_mangle] pub extern "C" fn ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(this_ptr: &ChannelHandshakeLimits) -> u64 { let mut inner_val = &mut this_ptr.get_native_mut_ref().min_max_htlc_value_in_flight_msat; @@ -654,7 +688,7 @@ pub extern "C" fn ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(t /// 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. +/// Default value: `0` #[no_mangle] pub extern "C" fn ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(this_ptr: &mut ChannelHandshakeLimits, mut val: u64) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.min_max_htlc_value_in_flight_msat = val; @@ -663,7 +697,7 @@ pub extern "C" fn ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(t /// 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. +/// Default value: `u64::max_value`. #[no_mangle] pub extern "C" fn ChannelHandshakeLimits_get_max_channel_reserve_satoshis(this_ptr: &ChannelHandshakeLimits) -> u64 { let mut inner_val = &mut this_ptr.get_native_mut_ref().max_channel_reserve_satoshis; @@ -673,7 +707,7 @@ pub extern "C" fn ChannelHandshakeLimits_get_max_channel_reserve_satoshis(this_p /// 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. +/// Default value: `u64::max_value`. #[no_mangle] pub extern "C" fn ChannelHandshakeLimits_set_max_channel_reserve_satoshis(this_ptr: &mut ChannelHandshakeLimits, mut val: u64) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_channel_reserve_satoshis = val; @@ -681,7 +715,7 @@ pub extern "C" fn ChannelHandshakeLimits_set_max_channel_reserve_satoshis(this_p /// 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. +/// Default value: `0` #[no_mangle] pub extern "C" fn ChannelHandshakeLimits_get_min_max_accepted_htlcs(this_ptr: &ChannelHandshakeLimits) -> u16 { let mut inner_val = &mut this_ptr.get_native_mut_ref().min_max_accepted_htlcs; @@ -690,7 +724,7 @@ pub extern "C" fn ChannelHandshakeLimits_get_min_max_accepted_htlcs(this_ptr: &C /// 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. +/// Default value: `0` #[no_mangle] pub extern "C" fn ChannelHandshakeLimits_set_min_max_accepted_htlcs(this_ptr: &mut ChannelHandshakeLimits, mut val: u16) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.min_max_accepted_htlcs = val; @@ -700,7 +734,7 @@ pub extern "C" fn ChannelHandshakeLimits_set_min_max_accepted_htlcs(this_ptr: &m /// 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. +/// Default value: `144`, or roughly one day and only applies to outbound channels #[no_mangle] pub extern "C" fn ChannelHandshakeLimits_get_max_minimum_depth(this_ptr: &ChannelHandshakeLimits) -> u32 { let mut inner_val = &mut this_ptr.get_native_mut_ref().max_minimum_depth; @@ -711,7 +745,7 @@ pub extern "C" fn ChannelHandshakeLimits_get_max_minimum_depth(this_ptr: &Channe /// 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. +/// Default value: `144`, or roughly one day and only applies to outbound channels #[no_mangle] pub extern "C" fn ChannelHandshakeLimits_set_max_minimum_depth(this_ptr: &mut ChannelHandshakeLimits, mut val: u32) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_minimum_depth = val; @@ -727,12 +761,12 @@ pub extern "C" fn ChannelHandshakeLimits_set_max_minimum_depth(this_ptr: &mut Ch /// 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. +/// 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). +/// `true` (`0`) and `false` (`1`). /// -/// Default value: true +/// Default value: `true` #[no_mangle] pub extern "C" fn ChannelHandshakeLimits_get_trust_own_funding_0conf(this_ptr: &ChannelHandshakeLimits) -> bool { let mut inner_val = &mut this_ptr.get_native_mut_ref().trust_own_funding_0conf; @@ -749,37 +783,37 @@ pub extern "C" fn ChannelHandshakeLimits_get_trust_own_funding_0conf(this_ptr: & /// 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. +/// 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). +/// `true` (`0`) and `false` (`1`). /// -/// Default value: true +/// Default value: `true` #[no_mangle] pub extern "C" fn ChannelHandshakeLimits_set_trust_own_funding_0conf(this_ptr: &mut ChannelHandshakeLimits, mut val: bool) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.trust_own_funding_0conf = val; } /// Set to force an incoming channel to match our announced channel preference in -/// [`ChannelHandshakeConfig::announced_channel`]. +/// [`ChannelHandshakeConfig::announce_for_forwarding`]. /// /// 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) +/// [`ChannelHandshakeConfig::announce_for_forwarding`] set to false, ensuring that no announced (aka public) /// channels will ever be opened. /// -/// Default value: true. +/// Default value: `true` #[no_mangle] pub extern "C" fn ChannelHandshakeLimits_get_force_announced_channel_preference(this_ptr: &ChannelHandshakeLimits) -> bool { let mut inner_val = &mut this_ptr.get_native_mut_ref().force_announced_channel_preference; *inner_val } /// Set to force an incoming channel to match our announced channel preference in -/// [`ChannelHandshakeConfig::announced_channel`]. +/// [`ChannelHandshakeConfig::announce_for_forwarding`]. /// /// 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) +/// [`ChannelHandshakeConfig::announce_for_forwarding`] set to false, ensuring that no announced (aka public) /// channels will ever be opened. /// -/// Default value: true. +/// Default value: `true` #[no_mangle] pub extern "C" fn ChannelHandshakeLimits_set_force_announced_channel_preference(this_ptr: &mut ChannelHandshakeLimits, mut val: bool) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.force_announced_channel_preference = val; @@ -789,7 +823,7 @@ pub extern "C" fn ChannelHandshakeLimits_set_force_announced_channel_preference( /// 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 +/// 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) #[no_mangle] pub extern "C" fn ChannelHandshakeLimits_get_their_to_self_delay(this_ptr: &ChannelHandshakeLimits) -> u16 { @@ -801,7 +835,7 @@ pub extern "C" fn ChannelHandshakeLimits_get_their_to_self_delay(this_ptr: &Chan /// 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 +/// 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) #[no_mangle] pub extern "C" fn ChannelHandshakeLimits_set_their_to_self_delay(this_ptr: &mut ChannelHandshakeLimits, mut val: u16) { @@ -869,17 +903,17 @@ pub enum MaxDustHTLCExposure { /// exposure and the new minimum value for HTLCs to be economically viable to claim. FixedLimitMsat( u64), - /// This sets a multiplier on the [`ConfirmationTarget::OnChainSweep`] feerate (in sats/KW) to - /// determine the maximum allowed dust exposure. If this variant is used then the maximum dust - /// exposure in millisatoshis is calculated as: + /// This sets a multiplier on the [`ConfirmationTarget::MaximumFeeEstimate`] feerate (in + /// sats/KW) to determine the maximum allowed dust exposure. If this variant is used then the + /// maximum dust exposure in millisatoshis is calculated as: /// `feerate_per_kw * value`. For example, with our default value /// `FeeRateMultiplier(10_000)`: /// /// - 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 * 10_000 = 2,530,000 msats. + /// defaults to 253 sats/KW for rounding, see [`FeeEstimator`]), the max dust exposure would + /// be 253 * 10_000 = 2,530,000 msats. /// - For a fee rate of 30 sat/vByte (7500 sat/KW), the max dust exposure would be - /// 7500 * 50_000 = 75,000,000 msats (0.00075 BTC). + /// 7500 * 50_000 = 75,000,000 msats (0.00075 BTC). /// /// 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, @@ -894,7 +928,7 @@ pub enum MaxDustHTLCExposure { /// by default this will be set to a [`Self::FixedLimitMsat`] of 5,000,000 msat. /// /// [`FeeEstimator`]: crate::chain::chaininterface::FeeEstimator - /// [`ConfirmationTarget::OnChainSweep`]: crate::chain::chaininterface::ConfirmationTarget::OnChainSweep + /// [`ConfirmationTarget::MaximumFeeEstimate`]: crate::chain::chaininterface::ConfirmationTarget::MaximumFeeEstimate FeeRateMultiplier( u64), } @@ -1042,6 +1076,12 @@ pub struct ChannelConfig { pub is_owned: bool, } +impl core::ops::Deref for ChannelConfig { + type Target = nativeChannelConfig; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ChannelConfig { } +unsafe impl core::marker::Sync for ChannelConfig { } impl Drop for ChannelConfig { fn drop(&mut self) { if self.is_owned && !<*mut nativeChannelConfig>::is_null(self.inner) { @@ -1072,13 +1112,16 @@ impl ChannelConfig { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// 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. +/// Default value: `0` #[no_mangle] pub extern "C" fn ChannelConfig_get_forwarding_fee_proportional_millionths(this_ptr: &ChannelConfig) -> u32 { let mut inner_val = &mut this_ptr.get_native_mut_ref().forwarding_fee_proportional_millionths; @@ -1089,7 +1132,7 @@ pub extern "C" fn ChannelConfig_get_forwarding_fee_proportional_millionths(this_ /// 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. +/// Default value: `0` #[no_mangle] pub extern "C" fn ChannelConfig_set_forwarding_fee_proportional_millionths(this_ptr: &mut ChannelConfig, mut val: u32) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.forwarding_fee_proportional_millionths = val; @@ -1103,7 +1146,7 @@ pub extern "C" fn ChannelConfig_set_forwarding_fee_proportional_millionths(this_ /// as of July 2021. Adjusting it upwards or downwards may change whether nodes route through /// this node. /// -/// Default value: 1000. +/// Default value: `1000` /// /// [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths #[no_mangle] @@ -1120,7 +1163,7 @@ pub extern "C" fn ChannelConfig_get_forwarding_fee_base_msat(this_ptr: &ChannelC /// as of July 2021. Adjusting it upwards or downwards may change whether nodes route through /// this node. /// -/// Default value: 1000. +/// Default value: `1000` /// /// [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths #[no_mangle] @@ -1141,9 +1184,10 @@ pub extern "C" fn ChannelConfig_set_forwarding_fee_base_msat(this_ptr: &mut Chan /// 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. +/// 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 #[no_mangle] @@ -1165,9 +1209,10 @@ pub extern "C" fn ChannelConfig_get_cltv_expiry_delta(this_ptr: &ChannelConfig) /// 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. +/// 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 #[no_mangle] @@ -1222,12 +1267,12 @@ pub extern "C" fn ChannelConfig_set_cltv_expiry_delta(this_ptr: &mut ChannelConf /// Note that when using [`MaxDustHTLCExposure::FeeRateMultiplier`] this maximum disagreement /// will scale linearly with increases (or decreases) in the our feerate estimates. Further, /// for anchor channels we expect our counterparty to use a relatively low feerate estimate -/// while we use [`ConfirmationTarget::OnChainSweep`] (which should be relatively high) and -/// feerate disagreement force-closures should only occur when theirs is higher than ours. +/// while we use [`ConfirmationTarget::MaximumFeeEstimate`] (which should be relatively high) +/// and feerate disagreement force-closures should only occur when theirs is higher than ours. /// -/// Default value: [`MaxDustHTLCExposure::FeeRateMultiplier`] with a multiplier of 10_000. +/// Default value: [`MaxDustHTLCExposure::FeeRateMultiplier`] with a multiplier of `10_000` /// -/// [`ConfirmationTarget::OnChainSweep`]: crate::chain::chaininterface::ConfirmationTarget::OnChainSweep +/// [`ConfirmationTarget::MaximumFeeEstimate`]: crate::chain::chaininterface::ConfirmationTarget::MaximumFeeEstimate #[no_mangle] 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; @@ -1281,12 +1326,12 @@ pub extern "C" fn ChannelConfig_get_max_dust_htlc_exposure(this_ptr: &ChannelCon /// Note that when using [`MaxDustHTLCExposure::FeeRateMultiplier`] this maximum disagreement /// will scale linearly with increases (or decreases) in the our feerate estimates. Further, /// for anchor channels we expect our counterparty to use a relatively low feerate estimate -/// while we use [`ConfirmationTarget::OnChainSweep`] (which should be relatively high) and -/// feerate disagreement force-closures should only occur when theirs is higher than ours. +/// while we use [`ConfirmationTarget::MaximumFeeEstimate`] (which should be relatively high) +/// and feerate disagreement force-closures should only occur when theirs is higher than ours. /// -/// Default value: [`MaxDustHTLCExposure::FeeRateMultiplier`] with a multiplier of 10_000. +/// Default value: [`MaxDustHTLCExposure::FeeRateMultiplier`] with a multiplier of `10_000` /// -/// [`ConfirmationTarget::OnChainSweep`]: crate::chain::chaininterface::ConfirmationTarget::OnChainSweep +/// [`ConfirmationTarget::MaximumFeeEstimate`]: crate::chain::chaininterface::ConfirmationTarget::MaximumFeeEstimate #[no_mangle] 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(); @@ -1309,7 +1354,7 @@ pub extern "C" fn ChannelConfig_set_max_dust_htlc_exposure(this_ptr: &mut Channe /// [`ChannelCloseMinimum`] 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. +/// Default value: `1000` /// /// [`NonAnchorChannelFee`]: crate::chain::chaininterface::ConfirmationTarget::NonAnchorChannelFee /// [`ChannelCloseMinimum`]: crate::chain::chaininterface::ConfirmationTarget::ChannelCloseMinimum @@ -1336,7 +1381,7 @@ pub extern "C" fn ChannelConfig_get_force_close_avoidance_max_fee_satoshis(this_ /// [`ChannelCloseMinimum`] 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. +/// Default value: `1000` /// /// [`NonAnchorChannelFee`]: crate::chain::chaininterface::ConfirmationTarget::NonAnchorChannelFee /// [`ChannelCloseMinimum`]: crate::chain::chaininterface::ConfirmationTarget::ChannelCloseMinimum @@ -1367,7 +1412,7 @@ pub extern "C" fn ChannelConfig_set_force_close_avoidance_max_fee_satoshis(this_ /// 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. +/// Default value: `false` /// /// [intercept scids]: crate::ln::channelmanager::ChannelManager::get_intercept_scid /// [`forward_intercepted_htlc`]: crate::ln::channelmanager::ChannelManager::forward_intercepted_htlc @@ -1403,7 +1448,7 @@ pub extern "C" fn ChannelConfig_get_accept_underpaying_htlcs(this_ptr: &ChannelC /// 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. +/// Default value: `false` /// /// [intercept scids]: crate::ln::channelmanager::ChannelManager::get_intercept_scid /// [`forward_intercepted_htlc`]: crate::ln::channelmanager::ChannelManager::forward_intercepted_htlc @@ -1478,7 +1523,7 @@ pub extern "C" fn ChannelConfig_write(obj: &crate::lightning::util::config::Chan } #[allow(unused)] pub(crate) extern "C" fn ChannelConfig_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelConfig) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::util::config::nativeChannelConfig) }) } #[no_mangle] /// Read a ChannelConfig from a byte array, created by ChannelConfig_write @@ -1507,6 +1552,12 @@ pub struct ChannelConfigUpdate { pub is_owned: bool, } +impl core::ops::Deref for ChannelConfigUpdate { + type Target = nativeChannelConfigUpdate; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ChannelConfigUpdate { } +unsafe impl core::marker::Sync for ChannelConfigUpdate { } impl Drop for ChannelConfigUpdate { fn drop(&mut self) { if self.is_owned && !<*mut nativeChannelConfigUpdate>::is_null(self.inner) { @@ -1537,6 +1588,9 @@ impl ChannelConfigUpdate { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } #[no_mangle] pub extern "C" fn ChannelConfigUpdate_get_forwarding_fee_proportional_millionths(this_ptr: &ChannelConfigUpdate) -> crate::c_types::derived::COption_u32Z { @@ -1612,20 +1666,14 @@ pub extern "C" fn ChannelConfigUpdate_new(mut forwarding_fee_proportional_millio 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; /// Top-level config which holds ChannelHandshakeLimits and ChannelConfig. /// -/// Default::default() provides sane defaults for most configurations -/// (but currently with 0 relay fees!) +/// `Default::default()` provides sane defaults for most configurations +/// (but currently with zero relay fees!) #[must_use] #[repr(C)] pub struct UserConfig { @@ -1641,6 +1689,12 @@ pub struct UserConfig { pub is_owned: bool, } +impl core::ops::Deref for UserConfig { + type Target = nativeUserConfig; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for UserConfig { } +unsafe impl core::marker::Sync for UserConfig { } impl Drop for UserConfig { fn drop(&mut self) { if self.is_owned && !<*mut nativeUserConfig>::is_null(self.inner) { @@ -1671,6 +1725,9 @@ impl UserConfig { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Channel handshake config that we propose to our counterparty. #[no_mangle] @@ -1705,13 +1762,13 @@ pub extern "C" fn UserConfig_get_channel_config(this_ptr: &UserConfig) -> crate: pub extern "C" fn UserConfig_set_channel_config(this_ptr: &mut UserConfig, mut val: crate::lightning::util::config::ChannelConfig) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_config = *unsafe { Box::from_raw(val.take_inner()) }; } -/// If this is set to false, we will reject any HTLCs which were to be forwarded over private +/// 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 +/// (using [`ChannelHandshakeConfig::announce_for_forwarding`] 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 @@ -1720,19 +1777,19 @@ pub extern "C" fn UserConfig_set_channel_config(this_ptr: &mut UserConfig, mut v /// 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. +/// Default value: `false` #[no_mangle] pub extern "C" fn UserConfig_get_accept_forwards_to_priv_channels(this_ptr: &UserConfig) -> bool { let mut inner_val = &mut this_ptr.get_native_mut_ref().accept_forwards_to_priv_channels; *inner_val } -/// If this is set to false, we will reject any HTLCs which were to be forwarded over private +/// 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 +/// (using [`ChannelHandshakeConfig::announce_for_forwarding`] 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 @@ -1741,33 +1798,35 @@ pub extern "C" fn UserConfig_get_accept_forwards_to_priv_channels(this_ptr: &Use /// 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. +/// Default value: `false` #[no_mangle] pub extern "C" fn UserConfig_set_accept_forwards_to_priv_channels(this_ptr: &mut UserConfig, mut val: bool) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.accept_forwards_to_priv_channels = val; } -/// If this is set to false, we do not accept inbound requests to open a new channel. -/// Default value: true. +/// If this is set to `false`, we do not accept inbound requests to open a new channel. +/// +/// Default value: `true` #[no_mangle] pub extern "C" fn UserConfig_get_accept_inbound_channels(this_ptr: &UserConfig) -> bool { let mut inner_val = &mut this_ptr.get_native_mut_ref().accept_inbound_channels; *inner_val } -/// If this is set to false, we do not accept inbound requests to open a new channel. -/// Default value: true. +/// If this is set to `false`, we do not accept inbound requests to open a new channel. +/// +/// Default value: `true` #[no_mangle] pub extern "C" fn UserConfig_set_accept_inbound_channels(this_ptr: &mut UserConfig, mut val: bool) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.accept_inbound_channels = val; } -/// If this is set to true, the user needs to manually accept inbound requests to open a new +/// 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 +/// 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. +/// Default value: `false` /// /// [`Event::OpenChannelRequest`]: crate::events::Event::OpenChannelRequest /// [`msgs::OpenChannel`]: crate::ln::msgs::OpenChannel @@ -1777,15 +1836,15 @@ pub extern "C" fn UserConfig_get_manually_accept_inbound_channels(this_ptr: &Use let mut inner_val = &mut this_ptr.get_native_mut_ref().manually_accept_inbound_channels; *inner_val } -/// If this is set to true, the user needs to manually accept inbound requests to open a new +/// 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 +/// 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. +/// Default value: `false` /// /// [`Event::OpenChannelRequest`]: crate::events::Event::OpenChannelRequest /// [`msgs::OpenChannel`]: crate::ln::msgs::OpenChannel @@ -1794,13 +1853,13 @@ pub extern "C" fn UserConfig_get_manually_accept_inbound_channels(this_ptr: &Use pub extern "C" fn UserConfig_set_manually_accept_inbound_channels(this_ptr: &mut UserConfig, mut val: bool) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.manually_accept_inbound_channels = val; } -/// If this is set to true, LDK will intercept HTLCs that are attempting to be forwarded over +/// 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. +/// Setting this to `true` may break backwards compatibility with LDK versions < 0.0.113. /// -/// Default value: false. +/// Default value: `false` /// /// [`ChannelManager::get_intercept_scid`]: crate::ln::channelmanager::ChannelManager::get_intercept_scid /// [`Event::HTLCIntercepted`]: crate::events::Event::HTLCIntercepted @@ -1809,13 +1868,13 @@ pub extern "C" fn UserConfig_get_accept_intercept_htlcs(this_ptr: &UserConfig) - let mut inner_val = &mut this_ptr.get_native_mut_ref().accept_intercept_htlcs; *inner_val } -/// If this is set to true, LDK will intercept HTLCs that are attempting to be forwarded over +/// 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. +/// Setting this to `true` may break backwards compatibility with LDK versions < 0.0.113. /// -/// Default value: false. +/// Default value: `false` /// /// [`ChannelManager::get_intercept_scid`]: crate::ln::channelmanager::ChannelManager::get_intercept_scid /// [`Event::HTLCIntercepted`]: crate::events::Event::HTLCIntercepted @@ -1823,14 +1882,14 @@ 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. +/// 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 +/// Setting this to `true` will break backwards compatibility upon downgrading to an LDK +/// version prior to 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. +/// Default value: `false` /// /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager #[no_mangle] @@ -1838,24 +1897,59 @@ pub extern "C" fn UserConfig_get_accept_mpp_keysend(this_ptr: &UserConfig) -> bo 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. +/// 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 +/// Setting this to `true` will break backwards compatibility upon downgrading to an LDK +/// version prior to 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. +/// 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; } +/// If this is set to `true`, the user needs to manually pay [`Bolt12Invoice`]s when received. +/// +/// When set to `true`, [`Event::InvoiceReceived`] will be generated for each received +/// [`Bolt12Invoice`] instead of being automatically paid after verification. Use +/// [`ChannelManager::send_payment_for_bolt12_invoice`] to pay the invoice or +/// [`ChannelManager::abandon_payment`] to abandon the associated payment. +/// +/// Default value: `false` +/// +/// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice +/// [`Event::InvoiceReceived`]: crate::events::Event::InvoiceReceived +/// [`ChannelManager::send_payment_for_bolt12_invoice`]: crate::ln::channelmanager::ChannelManager::send_payment_for_bolt12_invoice +/// [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment +#[no_mangle] +pub extern "C" fn UserConfig_get_manually_handle_bolt12_invoices(this_ptr: &UserConfig) -> bool { + let mut inner_val = &mut this_ptr.get_native_mut_ref().manually_handle_bolt12_invoices; + *inner_val +} +/// If this is set to `true`, the user needs to manually pay [`Bolt12Invoice`]s when received. +/// +/// When set to `true`, [`Event::InvoiceReceived`] will be generated for each received +/// [`Bolt12Invoice`] instead of being automatically paid after verification. Use +/// [`ChannelManager::send_payment_for_bolt12_invoice`] to pay the invoice or +/// [`ChannelManager::abandon_payment`] to abandon the associated payment. +/// +/// Default value: `false` +/// +/// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice +/// [`Event::InvoiceReceived`]: crate::events::Event::InvoiceReceived +/// [`ChannelManager::send_payment_for_bolt12_invoice`]: crate::ln::channelmanager::ChannelManager::send_payment_for_bolt12_invoice +/// [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment +#[no_mangle] +pub extern "C" fn UserConfig_set_manually_handle_bolt12_invoices(this_ptr: &mut UserConfig, mut val: bool) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.manually_handle_bolt12_invoices = 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, mut accept_mpp_keysend_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, mut manually_handle_bolt12_invoices_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()) }, @@ -1865,6 +1959,7 @@ pub extern "C" fn UserConfig_new(mut channel_handshake_config_arg: crate::lightn manually_accept_inbound_channels: manually_accept_inbound_channels_arg, accept_intercept_htlcs: accept_intercept_htlcs_arg, accept_mpp_keysend: accept_mpp_keysend_arg, + manually_handle_bolt12_invoices: manually_handle_bolt12_invoices_arg, }), is_owned: true } } impl Clone for UserConfig { diff --git a/lightning-c-bindings/src/lightning/util/invoice.rs b/lightning-c-bindings/src/lightning/util/invoice.rs deleted file mode 100644 index 5d78528..0000000 --- a/lightning-c-bindings/src/lightning/util/invoice.rs +++ /dev/null @@ -1,28 +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. - -//! Low level invoice utilities. - -use alloc::str::FromStr; -use alloc::string::String; -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}; - -/// Construct the invoice's HRP and signatureless data into a preimage to be hashed. -#[no_mangle] -pub extern "C" fn construct_invoice_preimage(mut hrp_bytes: crate::c_types::u8slice, mut data_without_signature: crate::c_types::derived::CVec_U5Z) -> crate::c_types::derived::CVec_u8Z { - let mut local_data_without_signature = Vec::new(); for mut item in data_without_signature.into_rust().drain(..) { local_data_without_signature.push( { item.into() }); }; - let mut ret = lightning::util::invoice::construct_invoice_preimage(hrp_bytes.to_slice(), &local_data_without_signature[..]); - let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { item }); }; - local_ret.into() -} - diff --git a/lightning-c-bindings/src/lightning/util/logger.rs b/lightning-c-bindings/src/lightning/util/logger.rs index af9ceef..de9816d 100644 --- a/lightning-c-bindings/src/lightning/util/logger.rs +++ b/lightning-c-bindings/src/lightning/util/logger.rs @@ -181,6 +181,12 @@ pub struct Record { pub is_owned: bool, } +impl core::ops::Deref for Record { + type Target = nativeRecord; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for Record { } +unsafe impl core::marker::Sync for Record { } impl Drop for Record { fn drop(&mut self) { if self.is_owned && !<*mut nativeRecord>::is_null(self.inner) { @@ -211,6 +217,9 @@ impl Record { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The verbosity level of the message. #[no_mangle] @@ -311,15 +320,35 @@ pub extern "C" fn Record_get_line(this_ptr: &Record) -> u32 { pub extern "C" fn Record_set_line(this_ptr: &mut Record, mut val: u32) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.line = val; } +/// The payment hash. +/// +/// Note that this is only filled in for logs pertaining to a specific payment, and will be +/// `None` for logs which are not directly related to a payment. +#[no_mangle] +pub extern "C" fn Record_get_payment_hash(this_ptr: &Record) -> crate::c_types::derived::COption_ThirtyTwoBytesZ { + let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_hash; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_ThirtyTwoBytesZ::None } else { crate::c_types::derived::COption_ThirtyTwoBytesZ::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 payment hash. +/// +/// Note that this is only filled in for logs pertaining to a specific payment, and will be +/// `None` for logs which are not directly related to a payment. +#[no_mangle] +pub extern "C" fn Record_set_payment_hash(this_ptr: &mut Record, mut val: crate::c_types::derived::COption_ThirtyTwoBytesZ) { + let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::lightning::ln::types::PaymentHash({ val_opt.take() }.data) }})} }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_hash = local_val; +} /// Constructs a new Record given each field /// /// Note that peer_id_arg (or a relevant inner pointer) may be NULL or all-0s to represent None /// Note that channel_id_arg (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn Record_new(mut level_arg: crate::lightning::util::logger::Level, mut peer_id_arg: crate::c_types::PublicKey, mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut args_arg: crate::c_types::Str, mut module_path_arg: crate::c_types::Str, mut file_arg: crate::c_types::Str, mut line_arg: u32) -> Record { +pub extern "C" fn Record_new(mut level_arg: crate::lightning::util::logger::Level, mut peer_id_arg: crate::c_types::PublicKey, mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut args_arg: crate::c_types::Str, mut module_path_arg: crate::c_types::Str, mut file_arg: crate::c_types::Str, mut line_arg: u32, mut payment_hash_arg: crate::c_types::derived::COption_ThirtyTwoBytesZ) -> Record { let mut local_peer_id_arg = if peer_id_arg.is_null() { None } else { Some( { peer_id_arg.into_rust() }) }; let mut local_channel_id_arg = if channel_id_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(channel_id_arg.take_inner()) } }) }; + let mut local_payment_hash_arg = { /*payment_hash_arg*/ let payment_hash_arg_opt = payment_hash_arg; if payment_hash_arg_opt.is_none() { None } else { Some({ { ::lightning::ln::types::PaymentHash({ payment_hash_arg_opt.take() }.data) }})} }; Record { inner: ObjOps::heap_alloc(nativeRecord { level: level_arg.into_native(), peer_id: local_peer_id_arg, @@ -328,6 +357,7 @@ pub extern "C" fn Record_new(mut level_arg: crate::lightning::util::logger::Leve module_path: module_path_arg.into_str(), file: file_arg.into_str(), line: line_arg, + payment_hash: local_payment_hash_arg, }), is_owned: true } } impl Clone for Record { @@ -382,17 +412,24 @@ impl rustLogger for Logger { } } +pub struct LoggerRef(Logger); +impl rustLogger for LoggerRef { + fn log(&self, mut record: lightning::util::logger::Record) { + (self.0.log)(self.0.this_arg, crate::lightning::util::logger::Record { inner: ObjOps::heap_alloc(record), is_owned: true }) + } +} + // 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 Logger { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = LoggerRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const LoggerRef) } } } impl core::ops::DerefMut for Logger { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut LoggerRef { + unsafe { &mut *(self as *mut _ as *mut LoggerRef) } } } /// Calls the free function if one is set diff --git a/lightning-c-bindings/src/lightning/util/message_signing.rs b/lightning-c-bindings/src/lightning/util/message_signing.rs index 8e4dfc6..b07ca03 100644 --- a/lightning-c-bindings/src/lightning/util/message_signing.rs +++ b/lightning-c-bindings/src/lightning/util/message_signing.rs @@ -35,10 +35,9 @@ use alloc::{vec::Vec, boxed::Box}; /// 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. #[no_mangle] -pub extern "C" fn sign(mut msg: crate::c_types::u8slice, sk: *const [u8; 32]) -> crate::c_types::derived::CResult_StrSecp256k1ErrorZ { +pub extern "C" fn sign(mut msg: crate::c_types::u8slice, sk: *const [u8; 32]) -> crate::c_types::Str { let mut ret = lightning::util::message_signing::sign(msg.to_slice(), &::bitcoin::secp256k1::SecretKey::from_slice(&unsafe { *sk}[..]).unwrap()); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { o.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::Secp256k1Error::from_rust(e) }).into() }; - local_ret + ret.into() } /// Recovers the PublicKey of the signer of the message given the message and the signature. diff --git a/lightning-c-bindings/src/lightning/util/mod.rs b/lightning-c-bindings/src/lightning/util/mod.rs index b995b05..4fedbfb 100644 --- a/lightning-c-bindings/src/lightning/util/mod.rs +++ b/lightning-c-bindings/src/lightning/util/mod.rs @@ -21,16 +21,15 @@ pub mod ser_macros; pub mod errors; pub mod ser; pub mod message_signing; -pub mod invoice; pub mod persist; pub mod scid_utils; -pub mod string; pub mod sweep; pub mod wakers; pub mod hash_tables; pub mod indexed_map; pub mod logger; pub mod config; +pub mod string; mod fuzz_wrappers { use alloc::str::FromStr; @@ -66,6 +65,18 @@ use crate::c_types::*; #[cfg(feature="no-std")] use alloc::{vec::Vec, boxed::Box}; +} +mod async_poll { + +use alloc::str::FromStr; +use alloc::string::String; +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}; + } mod byte_utils { diff --git a/lightning-c-bindings/src/lightning/util/persist.rs b/lightning-c-bindings/src/lightning/util/persist.rs index 80ffb89..4d62d06 100644 --- a/lightning-c-bindings/src/lightning/util/persist.rs +++ b/lightning-c-bindings/src/lightning/util/persist.rs @@ -129,17 +129,42 @@ impl rustKVStore for KVStore { } } +pub struct KVStoreRef(KVStore); +impl rustKVStore for KVStoreRef { + fn read(&self, mut primary_namespace: &str, mut secondary_namespace: &str, mut key: &str) -> Result, lightning::io::Error> { + let mut ret = (self.0.read)(self.0.this_arg, primary_namespace.into(), secondary_namespace.into(), key.into()); + 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( { item }); }; local_ret_0 }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).to_rust() })}; + local_ret + } + fn write(&self, mut primary_namespace: &str, mut secondary_namespace: &str, mut key: &str, mut buf: &[u8]) -> Result<(), lightning::io::Error> { + let mut local_buf = crate::c_types::u8slice::from_slice(buf); + let mut ret = (self.0.write)(self.0.this_arg, primary_namespace.into(), secondary_namespace.into(), key.into(), local_buf); + 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 + } + fn remove(&self, mut primary_namespace: &str, mut secondary_namespace: &str, mut key: &str, mut lazy: bool) -> Result<(), lightning::io::Error> { + let mut ret = (self.0.remove)(self.0.this_arg, primary_namespace.into(), secondary_namespace.into(), key.into(), lazy); + 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 + } + fn list(&self, mut primary_namespace: &str, mut secondary_namespace: &str) -> Result, lightning::io::Error> { + let mut ret = (self.0.list)(self.0.this_arg, primary_namespace.into(), secondary_namespace.into()); + 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( { item.into_string() }); }; local_ret_0 }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).to_rust() })}; + 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 KVStore { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = KVStoreRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const KVStoreRef) } } } impl core::ops::DerefMut for KVStore { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut KVStoreRef { + unsafe { &mut *(self as *mut _ as *mut KVStoreRef) } } } /// Calls the free function if one is set @@ -186,9 +211,9 @@ pub(crate) 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::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 }); +impl<'a> rustPersister<'a, crate::lightning::ln::channelmanager::ChannelManager, crate::lightning::util::logger::Logger, crate::lightning::routing::scoring::WriteableScore, > for Persister { + fn persist_manager(&self, mut channel_manager: &crate::lightning::ln::channelmanager::ChannelManager) -> Result<(), lightning::io::Error> { + let mut ret = (self.persist_manager)(self.this_arg, &channel_manager.as_ref_to()); 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 } @@ -204,17 +229,36 @@ impl<'a> rustPersister<'a, crate::lightning::chain::Watch, crate::lightning::cha } } +pub struct PersisterRef(Persister); +impl<'a> rustPersister<'a, crate::lightning::ln::channelmanager::ChannelManager, crate::lightning::util::logger::Logger, crate::lightning::routing::scoring::WriteableScore, > for PersisterRef { + fn persist_manager(&self, mut channel_manager: &crate::lightning::ln::channelmanager::ChannelManager) -> Result<(), lightning::io::Error> { + let mut ret = (self.0.persist_manager)(self.0.this_arg, &channel_manager.as_ref_to()); + 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 + } + fn persist_graph(&self, mut network_graph: &lightning::routing::gossip::NetworkGraph) -> Result<(), lightning::io::Error> { + let mut ret = (self.0.persist_graph)(self.0.this_arg, &crate::lightning::routing::gossip::NetworkGraph { inner: unsafe { ObjOps::nonnull_ptr_to_inner((network_graph as *const lightning::routing::gossip::NetworkGraph<_, >) 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 + } + fn persist_scorer(&self, mut scorer: &crate::lightning::routing::scoring::WriteableScore) -> Result<(), lightning::io::Error> { + let mut ret = (self.0.persist_scorer)(self.0.this_arg, scorer); + 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 + } +} + // 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 Persister { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = PersisterRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const PersisterRef) } } } impl core::ops::DerefMut for Persister { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut PersisterRef { + unsafe { &mut *(self as *mut _ as *mut PersisterRef) } } } /// Calls the free function if one is set @@ -231,13 +275,13 @@ impl Drop for Persister { #[no_mangle] pub extern "C" fn read_channel_monitors(mut kv_store: crate::lightning::util::persist::KVStore, mut entropy_source: crate::lightning::sign::EntropySource, mut signer_provider: crate::lightning::sign::SignerProvider) -> crate::c_types::derived::CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ { let mut ret = lightning::util::persist::read_channel_monitors::(kv_store, 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.as_ref() }, 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() }; + 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.as_ref() }, 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_bitcoin(e) }).into() }; local_ret } use lightning::util::persist::MonitorUpdatingPersister as nativeMonitorUpdatingPersisterImport; -pub(crate) type nativeMonitorUpdatingPersister = nativeMonitorUpdatingPersisterImport; +pub(crate) type nativeMonitorUpdatingPersister = nativeMonitorUpdatingPersisterImport; /// Implements [`Persist`] in a way that writes and reads both [`ChannelMonitor`]s and /// [`ChannelMonitorUpdate`]s. @@ -337,6 +381,12 @@ pub struct MonitorUpdatingPersister { pub is_owned: bool, } +impl core::ops::Deref for MonitorUpdatingPersister { + type Target = nativeMonitorUpdatingPersister; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for MonitorUpdatingPersister { } +unsafe impl core::marker::Sync for MonitorUpdatingPersister { } impl Drop for MonitorUpdatingPersister { fn drop(&mut self) { if self.is_owned && !<*mut nativeMonitorUpdatingPersister>::is_null(self.inner) { @@ -367,6 +417,9 @@ impl MonitorUpdatingPersister { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Constructs a new [`MonitorUpdatingPersister`]. /// @@ -386,8 +439,8 @@ impl MonitorUpdatingPersister { /// [`MonitorUpdatingPersister::cleanup_stale_updates`]. #[must_use] #[no_mangle] -pub extern "C" fn MonitorUpdatingPersister_new(mut kv_store: crate::lightning::util::persist::KVStore, mut logger: crate::lightning::util::logger::Logger, mut maximum_pending_updates: u64, mut entropy_source: crate::lightning::sign::EntropySource, mut signer_provider: crate::lightning::sign::SignerProvider) -> crate::lightning::util::persist::MonitorUpdatingPersister { - let mut ret = lightning::util::persist::MonitorUpdatingPersister::new(kv_store, logger, maximum_pending_updates, entropy_source, signer_provider); +pub extern "C" fn MonitorUpdatingPersister_new(mut kv_store: crate::lightning::util::persist::KVStore, mut logger: crate::lightning::util::logger::Logger, mut maximum_pending_updates: u64, mut entropy_source: crate::lightning::sign::EntropySource, mut signer_provider: crate::lightning::sign::SignerProvider, mut broadcaster: crate::lightning::chain::chaininterface::BroadcasterInterface, mut fee_estimator: crate::lightning::chain::chaininterface::FeeEstimator) -> crate::lightning::util::persist::MonitorUpdatingPersister { + let mut ret = lightning::util::persist::MonitorUpdatingPersister::new(kv_store, logger, maximum_pending_updates, entropy_source, signer_provider, broadcaster, fee_estimator); crate::lightning::util::persist::MonitorUpdatingPersister { inner: ObjOps::heap_alloc(ret), is_owned: true } } @@ -398,9 +451,9 @@ pub extern "C" fn MonitorUpdatingPersister_new(mut kv_store: crate::lightning::u /// documentation for [`MonitorUpdatingPersister`]. #[must_use] #[no_mangle] -pub extern "C" fn MonitorUpdatingPersister_read_all_channel_monitors_with_updates(this_arg: &crate::lightning::util::persist::MonitorUpdatingPersister, broadcaster: &crate::lightning::chain::chaininterface::BroadcasterInterface, fee_estimator: &crate::lightning::chain::chaininterface::FeeEstimator) -> crate::c_types::derived::CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.read_all_channel_monitors_with_updates(broadcaster, fee_estimator); - 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.as_ref() }, 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() }; +pub extern "C" fn MonitorUpdatingPersister_read_all_channel_monitors_with_updates(this_arg: &crate::lightning::util::persist::MonitorUpdatingPersister) -> crate::c_types::derived::CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.read_all_channel_monitors_with_updates(); + 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.as_ref() }, 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_bitcoin(e) }).into() }; local_ret } @@ -423,9 +476,9 @@ pub extern "C" fn MonitorUpdatingPersister_read_all_channel_monitors_with_update /// function to accomplish this. Take care to limit the number of parallel readers. #[must_use] #[no_mangle] -pub extern "C" fn MonitorUpdatingPersister_read_channel_monitor_with_updates(this_arg: &crate::lightning::util::persist::MonitorUpdatingPersister, broadcaster: &crate::lightning::chain::chaininterface::BroadcasterInterface, fee_estimator: &crate::lightning::chain::chaininterface::FeeEstimator, mut monitor_key: crate::c_types::Str) -> crate::c_types::derived::CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.read_channel_monitor_with_updates(broadcaster, fee_estimator, monitor_key.into_string()); - 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.as_ref() }, crate::lightning::chain::channelmonitor::ChannelMonitor { inner: ObjOps::heap_alloc(orig_ret_0_1), is_owned: true }).into(); local_ret_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::IOError::from_rust(e) }).into() }; +pub extern "C" fn MonitorUpdatingPersister_read_channel_monitor_with_updates(this_arg: &crate::lightning::util::persist::MonitorUpdatingPersister, mut monitor_key: crate::c_types::Str) -> crate::c_types::derived::CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.read_channel_monitor_with_updates(monitor_key.into_string()); + 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.as_ref() }, crate::lightning::chain::channelmonitor::ChannelMonitor { inner: ObjOps::heap_alloc(orig_ret_0_1), is_owned: true }).into(); local_ret_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::IOError::from_bitcoin(e) }).into() }; local_ret } @@ -439,7 +492,7 @@ pub extern "C" fn MonitorUpdatingPersister_read_channel_monitor_with_updates(thi #[no_mangle] pub extern "C" fn MonitorUpdatingPersister_cleanup_stale_updates(this_arg: &crate::lightning::util::persist::MonitorUpdatingPersister, mut lazy: bool) -> crate::c_types::derived::CResult_NoneIOErrorZ { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.cleanup_stale_updates(lazy); - 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::c_types::IOError::from_rust(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::c_types::IOError::from_bitcoin(e) }).into() }; local_ret } @@ -467,17 +520,17 @@ pub extern "C" fn MonitorUpdatingPersister_as_Persist(this_arg: &MonitorUpdating } #[must_use] -extern "C" fn MonitorUpdatingPersister_Persist_persist_new_channel(this_arg: *const c_void, mut channel_funding_outpoint: crate::lightning::chain::transaction::OutPoint, data: &crate::lightning::chain::channelmonitor::ChannelMonitor, mut update_id: crate::lightning::chain::chainmonitor::MonitorUpdateId) -> crate::lightning::chain::ChannelMonitorUpdateStatus { - let mut ret = >::persist_new_channel(unsafe { &mut *(this_arg as *mut nativeMonitorUpdatingPersister) }, *unsafe { Box::from_raw(channel_funding_outpoint.take_inner()) }, data.get_native_ref(), *unsafe { Box::from_raw(update_id.take_inner()) }); +extern "C" fn MonitorUpdatingPersister_Persist_persist_new_channel(this_arg: *const c_void, mut channel_funding_outpoint: crate::lightning::chain::transaction::OutPoint, monitor: &crate::lightning::chain::channelmonitor::ChannelMonitor) -> crate::lightning::chain::ChannelMonitorUpdateStatus { + let mut ret = >::persist_new_channel(unsafe { &mut *(this_arg as *mut nativeMonitorUpdatingPersister) }, *unsafe { Box::from_raw(channel_funding_outpoint.take_inner()) }, monitor.get_native_ref()); crate::lightning::chain::ChannelMonitorUpdateStatus::native_into(ret) } #[must_use] -extern "C" fn MonitorUpdatingPersister_Persist_update_persisted_channel(this_arg: *const c_void, mut channel_funding_outpoint: crate::lightning::chain::transaction::OutPoint, mut update: crate::lightning::chain::channelmonitor::ChannelMonitorUpdate, data: &crate::lightning::chain::channelmonitor::ChannelMonitor, mut update_id: crate::lightning::chain::chainmonitor::MonitorUpdateId) -> crate::lightning::chain::ChannelMonitorUpdateStatus { - let mut local_update = if update.inner.is_null() { None } else { Some( { update.get_native_ref() }) }; - let mut ret = >::update_persisted_channel(unsafe { &mut *(this_arg as *mut nativeMonitorUpdatingPersister) }, *unsafe { Box::from_raw(channel_funding_outpoint.take_inner()) }, local_update, data.get_native_ref(), *unsafe { Box::from_raw(update_id.take_inner()) }); +extern "C" fn MonitorUpdatingPersister_Persist_update_persisted_channel(this_arg: *const c_void, mut channel_funding_outpoint: crate::lightning::chain::transaction::OutPoint, mut monitor_update: crate::lightning::chain::channelmonitor::ChannelMonitorUpdate, monitor: &crate::lightning::chain::channelmonitor::ChannelMonitor) -> crate::lightning::chain::ChannelMonitorUpdateStatus { + let mut local_monitor_update = if monitor_update.inner.is_null() { None } else { Some( { monitor_update.get_native_ref() }) }; + let mut ret = >::update_persisted_channel(unsafe { &mut *(this_arg as *mut nativeMonitorUpdatingPersister) }, *unsafe { Box::from_raw(channel_funding_outpoint.take_inner()) }, local_monitor_update, monitor.get_native_ref()); crate::lightning::chain::ChannelMonitorUpdateStatus::native_into(ret) } extern "C" fn MonitorUpdatingPersister_Persist_archive_persisted_channel(this_arg: *const c_void, mut channel_funding_outpoint: crate::lightning::chain::transaction::OutPoint) { - >::archive_persisted_channel(unsafe { &mut *(this_arg as *mut nativeMonitorUpdatingPersister) }, *unsafe { Box::from_raw(channel_funding_outpoint.take_inner()) }) + >::archive_persisted_channel(unsafe { &mut *(this_arg as *mut nativeMonitorUpdatingPersister) }, *unsafe { Box::from_raw(channel_funding_outpoint.take_inner()) }) } diff --git a/lightning-c-bindings/src/lightning/util/ser.rs b/lightning-c-bindings/src/lightning/util/ser.rs index 1235f5c..a792229 100644 --- a/lightning-c-bindings/src/lightning/util/ser.rs +++ b/lightning-c-bindings/src/lightning/util/ser.rs @@ -51,6 +51,12 @@ pub struct BigSize { pub is_owned: bool, } +impl core::ops::Deref for BigSize { + type Target = nativeBigSize; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for BigSize { } +unsafe impl core::marker::Sync for BigSize { } impl Drop for BigSize { fn drop(&mut self) { if self.is_owned && !<*mut nativeBigSize>::is_null(self.inner) { @@ -81,6 +87,9 @@ impl BigSize { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } #[no_mangle] pub extern "C" fn BigSize_get_a(this_ptr: &BigSize) -> u64 { @@ -147,7 +156,7 @@ pub extern "C" fn BigSize_write(obj: &crate::lightning::util::ser::BigSize) -> c } #[allow(unused)] 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) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::util::ser::nativeBigSize) }) } #[no_mangle] /// Read a BigSize from a byte array, created by BigSize_write @@ -156,6 +165,22 @@ pub extern "C" fn BigSize_read(ser: crate::c_types::u8slice) -> crate::c_types:: 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 } +#[no_mangle] +/// Serialize the UntrustedString object into a byte array which can be read by UntrustedString_read +pub extern "C" fn UntrustedString_write(obj: &crate::lightning_types::string::UntrustedString) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[allow(unused)] +pub(crate) extern "C" fn UntrustedString_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning_types::string::nativeUntrustedString) }) +} +#[no_mangle] +/// Read a UntrustedString from a byte array, created by UntrustedString_write +pub extern "C" fn UntrustedString_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UntrustedStringDecodeErrorZ { + 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_types::string::UntrustedString { 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; @@ -182,6 +207,12 @@ pub struct Hostname { pub is_owned: bool, } +impl core::ops::Deref for Hostname { + type Target = nativeHostname; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for Hostname { } +unsafe impl core::marker::Sync for Hostname { } impl Drop for Hostname { fn drop(&mut self) { if self.is_owned && !<*mut nativeHostname>::is_null(self.inner) { @@ -212,6 +243,9 @@ impl Hostname { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } impl Clone for Hostname { fn clone(&self) -> Self { @@ -274,7 +308,7 @@ pub extern "C" fn Hostname_write(obj: &crate::lightning::util::ser::Hostname) -> } #[allow(unused)] 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) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::util::ser::nativeHostname) }) } #[no_mangle] /// Read a Hostname from a byte array, created by Hostname_write @@ -306,6 +340,12 @@ pub struct TransactionU16LenLimited { pub is_owned: bool, } +impl core::ops::Deref for TransactionU16LenLimited { + type Target = nativeTransactionU16LenLimited; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for TransactionU16LenLimited { } +unsafe impl core::marker::Sync for TransactionU16LenLimited { } impl Drop for TransactionU16LenLimited { fn drop(&mut self) { if self.is_owned && !<*mut nativeTransactionU16LenLimited>::is_null(self.inner) { @@ -336,6 +376,9 @@ impl TransactionU16LenLimited { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } impl Clone for TransactionU16LenLimited { fn clone(&self) -> Self { @@ -411,7 +454,7 @@ pub extern "C" fn TransactionU16LenLimited_write(obj: &crate::lightning::util::s } #[allow(unused)] 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) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::util::ser::nativeTransactionU16LenLimited) }) } #[no_mangle] /// Read a TransactionU16LenLimited from a byte array, created by TransactionU16LenLimited_write diff --git a/lightning-c-bindings/src/lightning/util/string.rs b/lightning-c-bindings/src/lightning/util/string.rs index c858a07..04f9777 100644 --- a/lightning-c-bindings/src/lightning/util/string.rs +++ b/lightning-c-bindings/src/lightning/util/string.rs @@ -6,7 +6,7 @@ // license as that which applies to the original source files from which this // source was automatically generated. -//! Utilities for strings. +//! Utilities to wrap untrusted strings and handle them (more) safely use alloc::str::FromStr; use alloc::string::String; @@ -17,210 +17,3 @@ use crate::c_types::*; #[cfg(feature="no-std")] use alloc::{vec::Vec, boxed::Box}; - -use lightning::util::string::UntrustedString as nativeUntrustedStringImport; -pub(crate) type nativeUntrustedString = nativeUntrustedStringImport; - -/// Struct to `Display` fields in a safe way using `PrintableString` -#[must_use] -#[repr(C)] -pub struct UntrustedString { - /// A pointer to the opaque Rust object. - - /// Nearly everywhere, 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 nativeUntrustedString, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust 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 UntrustedString { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeUntrustedString>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; - } - } -} -/// Frees any resources used by the UntrustedString, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn UntrustedString_free(this_obj: UntrustedString) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn UntrustedString_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUntrustedString) }; -} -#[allow(unused)] -impl UntrustedString { - pub(crate) fn get_native_ref(&self) -> &'static nativeUntrustedString { - unsafe { &*ObjOps::untweak_ptr(self.inner) } - } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUntrustedString { - 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 nativeUntrustedString { - assert!(self.is_owned); - let ret = ObjOps::untweak_ptr(self.inner); - self.inner = core::ptr::null_mut(); - ret - } -} -#[no_mangle] -pub extern "C" fn UntrustedString_get_a(this_ptr: &UntrustedString) -> crate::c_types::Str { - let mut inner_val = &mut this_ptr.get_native_mut_ref().0; - inner_val.as_str().into() -} -#[no_mangle] -pub extern "C" fn UntrustedString_set_a(this_ptr: &mut UntrustedString, mut val: crate::c_types::Str) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.0 = val.into_string(); -} -/// Constructs a new UntrustedString given each field -#[must_use] -#[no_mangle] -pub extern "C" fn UntrustedString_new(mut a_arg: crate::c_types::Str) -> UntrustedString { - UntrustedString { inner: ObjOps::heap_alloc(lightning::util::string::UntrustedString ( - a_arg.into_string(), - )), is_owned: true } -} -impl Clone for UntrustedString { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeUntrustedString>::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 UntrustedString_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUntrustedString)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the UntrustedString -pub extern "C" fn UntrustedString_clone(orig: &UntrustedString) -> UntrustedString { - orig.clone() -} -/// Get a string which allows debug introspection of a UntrustedString object -pub extern "C" fn UntrustedString_debug_str_void(o: *const c_void) -> Str { - alloc::format!("{:?}", unsafe { o as *const crate::lightning::util::string::UntrustedString }).into()} -/// 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. -#[no_mangle] -pub extern "C" fn UntrustedString_eq(a: &UntrustedString, b: &UntrustedString) -> 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 } -} -/// Generates a non-cryptographic 64-bit hash of the UntrustedString. -#[no_mangle] -pub extern "C" fn UntrustedString_hash(o: &UntrustedString) -> 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) -} -#[no_mangle] -/// Serialize the UntrustedString object into a byte array which can be read by UntrustedString_read -pub extern "C" fn UntrustedString_write(obj: &crate::lightning::util::string::UntrustedString) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) -} -#[allow(unused)] -pub(crate) extern "C" fn UntrustedString_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUntrustedString) }) -} -#[no_mangle] -/// Read a UntrustedString from a byte array, created by UntrustedString_write -pub extern "C" fn UntrustedString_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UntrustedStringDecodeErrorZ { - 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::string::UntrustedString { 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] -/// Get the string representation of a UntrustedString object -pub extern "C" fn UntrustedString_to_str(o: &crate::lightning::util::string::UntrustedString) -> Str { - alloc::format!("{}", o.get_native_ref()).into() -} - -use lightning::util::string::PrintableString as nativePrintableStringImport; -pub(crate) type nativePrintableString = nativePrintableStringImport<'static, >; - -/// A string that displays only printable characters, replacing control characters with -/// [`core::char::REPLACEMENT_CHARACTER`]. -#[must_use] -#[repr(C)] -pub struct PrintableString { - /// A pointer to the opaque Rust object. - - /// Nearly everywhere, 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 nativePrintableString, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust 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 PrintableString { - fn drop(&mut self) { - if self.is_owned && !<*mut nativePrintableString>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; - } - } -} -/// Frees any resources used by the PrintableString, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn PrintableString_free(this_obj: PrintableString) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn PrintableString_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativePrintableString) }; -} -#[allow(unused)] -impl PrintableString { - pub(crate) fn get_native_ref(&self) -> &'static nativePrintableString { - unsafe { &*ObjOps::untweak_ptr(self.inner) } - } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePrintableString { - 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 nativePrintableString { - assert!(self.is_owned); - let ret = ObjOps::untweak_ptr(self.inner); - self.inner = core::ptr::null_mut(); - ret - } -} -#[no_mangle] -pub extern "C" fn PrintableString_get_a(this_ptr: &PrintableString) -> crate::c_types::Str { - let mut inner_val = &mut this_ptr.get_native_mut_ref().0; - inner_val.into() -} -#[no_mangle] -pub extern "C" fn PrintableString_set_a(this_ptr: &mut PrintableString, mut val: crate::c_types::Str) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.0 = val.into_str(); -} -/// Constructs a new PrintableString given each field -#[must_use] -#[no_mangle] -pub extern "C" fn PrintableString_new(mut a_arg: crate::c_types::Str) -> PrintableString { - PrintableString { inner: ObjOps::heap_alloc(lightning::util::string::PrintableString ( - a_arg.into_str(), - )), is_owned: true } -} -/// Get a string which allows debug introspection of a PrintableString object -pub extern "C" fn PrintableString_debug_str_void(o: *const c_void) -> Str { - alloc::format!("{:?}", unsafe { o as *const crate::lightning::util::string::PrintableString }).into()} -#[no_mangle] -/// Get the string representation of a PrintableString object -pub extern "C" fn PrintableString_to_str(o: &crate::lightning::util::string::PrintableString) -> Str { - alloc::format!("{}", o.get_native_ref()).into() -} diff --git a/lightning-c-bindings/src/lightning/util/sweep.rs b/lightning-c-bindings/src/lightning/util/sweep.rs index e9abb7b..d2dc424 100644 --- a/lightning-c-bindings/src/lightning/util/sweep.rs +++ b/lightning-c-bindings/src/lightning/util/sweep.rs @@ -39,6 +39,12 @@ pub struct TrackedSpendableOutput { pub is_owned: bool, } +impl core::ops::Deref for TrackedSpendableOutput { + type Target = nativeTrackedSpendableOutput; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for TrackedSpendableOutput { } +unsafe impl core::marker::Sync for TrackedSpendableOutput { } impl Drop for TrackedSpendableOutput { fn drop(&mut self) { if self.is_owned && !<*mut nativeTrackedSpendableOutput>::is_null(self.inner) { @@ -69,6 +75,9 @@ impl TrackedSpendableOutput { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The tracked output descriptor. #[no_mangle] @@ -172,7 +181,7 @@ pub extern "C" fn TrackedSpendableOutput_write(obj: &crate::lightning::util::swe } #[allow(unused)] pub(crate) extern "C" fn TrackedSpendableOutput_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTrackedSpendableOutput) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::util::sweep::nativeTrackedSpendableOutput) }) } #[no_mangle] /// Read a TrackedSpendableOutput from a byte array, created by TrackedSpendableOutput_write @@ -451,6 +460,12 @@ pub struct OutputSweeper { pub is_owned: bool, } +impl core::ops::Deref for OutputSweeper { + type Target = nativeOutputSweeper; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for OutputSweeper { } +unsafe impl core::marker::Sync for OutputSweeper { } impl Drop for OutputSweeper { fn drop(&mut self) { if self.is_owned && !<*mut nativeOutputSweeper>::is_null(self.inner) { @@ -481,6 +496,9 @@ impl OutputSweeper { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Constructs a new [`OutputSweeper`]. /// diff --git a/lightning-c-bindings/src/lightning/util/wakers.rs b/lightning-c-bindings/src/lightning/util/wakers.rs index fcd69bd..1376de5 100644 --- a/lightning-c-bindings/src/lightning/util/wakers.rs +++ b/lightning-c-bindings/src/lightning/util/wakers.rs @@ -58,17 +58,24 @@ impl rustFutureCallback for FutureCallback { } } +pub struct FutureCallbackRef(FutureCallback); +impl rustFutureCallback for FutureCallbackRef { + fn call(&self) { + (self.0.call)(self.0.this_arg) + } +} + // 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 FutureCallback { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = FutureCallbackRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const FutureCallbackRef) } } } impl core::ops::DerefMut for FutureCallback { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut FutureCallbackRef { + unsafe { &mut *(self as *mut _ as *mut FutureCallbackRef) } } } /// Calls the free function if one is set @@ -101,6 +108,12 @@ pub struct Future { pub is_owned: bool, } +impl core::ops::Deref for Future { + type Target = nativeFuture; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for Future { } +unsafe impl core::marker::Sync for Future { } impl Drop for Future { fn drop(&mut self) { if self.is_owned && !<*mut nativeFuture>::is_null(self.inner) { @@ -131,6 +144,9 @@ impl Future { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Registers a callback to be called upon completion of this future. If the future has already /// completed, the callback will be called immediately. @@ -176,6 +192,12 @@ pub struct Sleeper { pub is_owned: bool, } +impl core::ops::Deref for Sleeper { + type Target = nativeSleeper; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for Sleeper { } +unsafe impl core::marker::Sync for Sleeper { } impl Drop for Sleeper { fn drop(&mut self) { if self.is_owned && !<*mut nativeSleeper>::is_null(self.inner) { @@ -206,6 +228,9 @@ impl Sleeper { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Constructs a new sleeper from one future, allowing blocking on it. #[must_use] @@ -223,6 +248,15 @@ pub extern "C" fn Sleeper_from_two_futures(fut_a: &crate::lightning::util::waker crate::lightning::util::wakers::Sleeper { inner: ObjOps::heap_alloc(ret), is_owned: true } } +/// Constructs a new sleeper from three futures, allowing blocking on all three at once. +/// +#[must_use] +#[no_mangle] +pub extern "C" fn Sleeper_from_three_futures(fut_a: &crate::lightning::util::wakers::Future, fut_b: &crate::lightning::util::wakers::Future, fut_c: &crate::lightning::util::wakers::Future) -> crate::lightning::util::wakers::Sleeper { + let mut ret = lightning::util::wakers::Sleeper::from_three_futures(fut_a.get_native_ref(), fut_b.get_native_ref(), fut_c.get_native_ref()); + crate::lightning::util::wakers::Sleeper { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + /// Constructs a new sleeper on many futures, allowing blocking on all at once. #[must_use] #[no_mangle] diff --git a/lightning-c-bindings/src/lightning_background_processor.rs b/lightning-c-bindings/src/lightning_background_processor.rs index 3bfa047..259996a 100644 --- a/lightning-c-bindings/src/lightning_background_processor.rs +++ b/lightning-c-bindings/src/lightning_background_processor.rs @@ -67,6 +67,12 @@ pub struct BackgroundProcessor { pub is_owned: bool, } +impl core::ops::Deref for BackgroundProcessor { + type Target = nativeBackgroundProcessor; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for BackgroundProcessor { } +unsafe impl core::marker::Sync for BackgroundProcessor { } impl Drop for BackgroundProcessor { fn drop(&mut self) { if self.is_owned && !<*mut nativeBackgroundProcessor>::is_null(self.inner) { @@ -97,6 +103,9 @@ impl BackgroundProcessor { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Either [`P2PGossipSync`] or [`RapidGossipSync`]. #[must_use] @@ -218,9 +227,9 @@ pub extern "C" fn GossipSync_none() -> GossipSync { /// [`NetworkGraph::write`]: lightning::routing::gossip::NetworkGraph#impl-Writeable #[must_use] #[no_mangle] -pub extern "C" fn BackgroundProcessor_start(mut persister: crate::lightning::util::persist::Persister, mut event_handler: crate::lightning::events::EventHandler, chain_monitor: &crate::lightning::chain::chainmonitor::ChainMonitor, channel_manager: &crate::lightning::ln::channelmanager::ChannelManager, mut gossip_sync: crate::lightning_background_processor::GossipSync, peer_manager: &crate::lightning::ln::peer_handler::PeerManager, mut logger: crate::lightning::util::logger::Logger, mut scorer: crate::c_types::derived::COption_WriteableScoreZ) -> crate::lightning_background_processor::BackgroundProcessor { +pub extern "C" fn BackgroundProcessor_start(mut persister: crate::lightning::util::persist::Persister, mut event_handler: crate::lightning::events::EventHandler, chain_monitor: &crate::lightning::chain::chainmonitor::ChainMonitor, channel_manager: &crate::lightning::ln::channelmanager::ChannelManager, onion_messenger: &crate::lightning::onion_message::messenger::OnionMessenger, mut gossip_sync: crate::lightning_background_processor::GossipSync, peer_manager: &crate::lightning::ln::peer_handler::PeerManager, mut logger: crate::lightning::util::logger::Logger, mut scorer: crate::c_types::derived::COption_WriteableScoreZ) -> crate::lightning_background_processor::BackgroundProcessor { let mut local_scorer = { /*scorer*/ let scorer_opt = scorer; if scorer_opt.is_none() { None } else { Some({ { { scorer_opt.take() } }})} }; - let mut ret = lightning_background_processor::BackgroundProcessor::start(persister, event_handler, chain_monitor.get_native_ref(), channel_manager.get_native_ref(), gossip_sync.into_native(), peer_manager.get_native_ref(), logger, local_scorer); + let mut ret = lightning_background_processor::BackgroundProcessor::start(persister, event_handler, chain_monitor.get_native_ref(), channel_manager.as_ref_to(), onion_messenger.as_ref_to(), gossip_sync.into_native(), peer_manager.as_ref_to(), logger, local_scorer); crate::lightning_background_processor::BackgroundProcessor { inner: ObjOps::heap_alloc(ret), is_owned: true } } diff --git a/lightning-c-bindings/src/lightning_invoice/mod.rs b/lightning-c-bindings/src/lightning_invoice/mod.rs index 2a4da12..25f6a63 100644 --- a/lightning-c-bindings/src/lightning_invoice/mod.rs +++ b/lightning-c-bindings/src/lightning_invoice/mod.rs @@ -26,8 +26,6 @@ use crate::c_types::*; #[cfg(feature="no-std")] use alloc::{vec::Vec, boxed::Box}; -pub mod payment; -pub mod utils; pub mod constants; mod de { @@ -626,11 +624,9 @@ pub static MAX_TIMESTAMP: u64 = lightning_invoice::MAX_TIMESTAMP; pub static DEFAULT_EXPIRY_TIME: u64 = lightning_invoice::DEFAULT_EXPIRY_TIME; /// Default minimum final CLTV expiry as defined by [BOLT 11]. /// -/// Note that this is *not* the same value as rust-lightning's minimum CLTV expiry, which is -/// provided in [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. +/// Note that this is *not* the same value as rust-lightning's minimum CLTV expiry. /// /// [BOLT 11]: https://github.com/lightning/bolts/blob/master/11-payment-encoding.md -/// [`MIN_FINAL_CLTV_EXPIRY_DELTA`]: lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA #[no_mangle] pub static DEFAULT_MIN_FINAL_CLTV_EXPIRY_DELTA: u64 = lightning_invoice::DEFAULT_MIN_FINAL_CLTV_EXPIRY_DELTA; @@ -661,6 +657,12 @@ pub struct Bolt11Invoice { pub is_owned: bool, } +impl core::ops::Deref for Bolt11Invoice { + type Target = nativeBolt11Invoice; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for Bolt11Invoice { } +unsafe impl core::marker::Sync for Bolt11Invoice { } impl Drop for Bolt11Invoice { fn drop(&mut self) { if self.is_owned && !<*mut nativeBolt11Invoice>::is_null(self.inner) { @@ -691,6 +693,9 @@ impl Bolt11Invoice { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Checks if two Bolt11Invoices contain equal inner contents. /// This ignores pointers and is_owned flags and looks at the values in fields. @@ -757,6 +762,12 @@ pub struct SignedRawBolt11Invoice { pub is_owned: bool, } +impl core::ops::Deref for SignedRawBolt11Invoice { + type Target = nativeSignedRawBolt11Invoice; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for SignedRawBolt11Invoice { } +unsafe impl core::marker::Sync for SignedRawBolt11Invoice { } impl Drop for SignedRawBolt11Invoice { fn drop(&mut self) { if self.is_owned && !<*mut nativeSignedRawBolt11Invoice>::is_null(self.inner) { @@ -787,6 +798,9 @@ impl SignedRawBolt11Invoice { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Checks if two SignedRawBolt11Invoices contain equal inner contents. /// This ignores pointers and is_owned flags and looks at the values in fields. @@ -853,6 +867,12 @@ pub struct RawBolt11Invoice { pub is_owned: bool, } +impl core::ops::Deref for RawBolt11Invoice { + type Target = nativeRawBolt11Invoice; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for RawBolt11Invoice { } +unsafe impl core::marker::Sync for RawBolt11Invoice { } impl Drop for RawBolt11Invoice { fn drop(&mut self) { if self.is_owned && !<*mut nativeRawBolt11Invoice>::is_null(self.inner) { @@ -883,6 +903,9 @@ impl RawBolt11Invoice { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// data part #[no_mangle] @@ -956,6 +979,12 @@ pub struct RawDataPart { pub is_owned: bool, } +impl core::ops::Deref for RawDataPart { + type Target = nativeRawDataPart; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for RawDataPart { } +unsafe impl core::marker::Sync for RawDataPart { } impl Drop for RawDataPart { fn drop(&mut self) { if self.is_owned && !<*mut nativeRawDataPart>::is_null(self.inner) { @@ -986,6 +1015,9 @@ impl RawDataPart { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// generation time of the invoice #[no_mangle] @@ -1064,6 +1096,12 @@ pub struct PositiveTimestamp { pub is_owned: bool, } +impl core::ops::Deref for PositiveTimestamp { + type Target = nativePositiveTimestamp; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for PositiveTimestamp { } +unsafe impl core::marker::Sync for PositiveTimestamp { } impl Drop for PositiveTimestamp { fn drop(&mut self) { if self.is_owned && !<*mut nativePositiveTimestamp>::is_null(self.inner) { @@ -1094,6 +1132,9 @@ impl PositiveTimestamp { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Checks if two PositiveTimestamps contain equal inner contents. /// This ignores pointers and is_owned flags and looks at the values in fields. @@ -1385,6 +1426,12 @@ pub struct Sha256 { pub is_owned: bool, } +impl core::ops::Deref for Sha256 { + type Target = nativeSha256; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for Sha256 { } +unsafe impl core::marker::Sync for Sha256 { } impl Drop for Sha256 { fn drop(&mut self) { if self.is_owned && !<*mut nativeSha256>::is_null(self.inner) { @@ -1415,6 +1462,9 @@ impl Sha256 { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } impl Clone for Sha256 { fn clone(&self) -> Self { @@ -1489,6 +1539,12 @@ pub struct Description { pub is_owned: bool, } +impl core::ops::Deref for Description { + type Target = nativeDescription; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for Description { } +unsafe impl core::marker::Sync for Description { } impl Drop for Description { fn drop(&mut self) { if self.is_owned && !<*mut nativeDescription>::is_null(self.inner) { @@ -1519,6 +1575,9 @@ impl Description { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } impl Clone for Description { fn clone(&self) -> Self { @@ -1581,6 +1640,12 @@ pub struct PayeePubKey { pub is_owned: bool, } +impl core::ops::Deref for PayeePubKey { + type Target = nativePayeePubKey; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for PayeePubKey { } +unsafe impl core::marker::Sync for PayeePubKey { } impl Drop for PayeePubKey { fn drop(&mut self) { if self.is_owned && !<*mut nativePayeePubKey>::is_null(self.inner) { @@ -1611,6 +1676,9 @@ impl PayeePubKey { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } #[no_mangle] pub extern "C" fn PayeePubKey_get_a(this_ptr: &PayeePubKey) -> crate::c_types::PublicKey { @@ -1691,6 +1759,12 @@ pub struct ExpiryTime { pub is_owned: bool, } +impl core::ops::Deref for ExpiryTime { + type Target = nativeExpiryTime; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ExpiryTime { } +unsafe impl core::marker::Sync for ExpiryTime { } impl Drop for ExpiryTime { fn drop(&mut self) { if self.is_owned && !<*mut nativeExpiryTime>::is_null(self.inner) { @@ -1721,6 +1795,9 @@ impl ExpiryTime { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } impl Clone for ExpiryTime { fn clone(&self) -> Self { @@ -1783,6 +1860,12 @@ pub struct MinFinalCltvExpiryDelta { pub is_owned: bool, } +impl core::ops::Deref for MinFinalCltvExpiryDelta { + type Target = nativeMinFinalCltvExpiryDelta; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for MinFinalCltvExpiryDelta { } +unsafe impl core::marker::Sync for MinFinalCltvExpiryDelta { } impl Drop for MinFinalCltvExpiryDelta { fn drop(&mut self) { if self.is_owned && !<*mut nativeMinFinalCltvExpiryDelta>::is_null(self.inner) { @@ -1813,6 +1896,9 @@ impl MinFinalCltvExpiryDelta { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } #[no_mangle] pub extern "C" fn MinFinalCltvExpiryDelta_get_a(this_ptr: &MinFinalCltvExpiryDelta) -> u64 { @@ -1905,13 +1991,13 @@ impl Fallback { Fallback::PubKeyHash (ref a, ) => { let mut a_nonref = Clone::clone(a); nativeFallback::PubKeyHash ( - bitcoin::hash_types::PubkeyHash::from_raw_hash(bitcoin::hashes::Hash::from_byte_array(a_nonref.data)), + bitcoin::PubkeyHash::from_raw_hash(bitcoin::hashes::Hash::from_byte_array(a_nonref.data)), ) }, Fallback::ScriptHash (ref a, ) => { let mut a_nonref = Clone::clone(a); nativeFallback::ScriptHash ( - bitcoin::hash_types::ScriptHash::from_raw_hash(bitcoin::hashes::Hash::from_byte_array(a_nonref.data)), + bitcoin::ScriptHash::from_raw_hash(bitcoin::hashes::Hash::from_byte_array(a_nonref.data)), ) }, } @@ -1928,12 +2014,12 @@ impl Fallback { }, Fallback::PubKeyHash (mut a, ) => { nativeFallback::PubKeyHash ( - bitcoin::hash_types::PubkeyHash::from_raw_hash(bitcoin::hashes::Hash::from_byte_array(a.data)), + bitcoin::PubkeyHash::from_raw_hash(bitcoin::hashes::Hash::from_byte_array(a.data)), ) }, Fallback::ScriptHash (mut a, ) => { nativeFallback::ScriptHash ( - bitcoin::hash_types::ScriptHash::from_raw_hash(bitcoin::hashes::Hash::from_byte_array(a.data)), + bitcoin::ScriptHash::from_raw_hash(bitcoin::hashes::Hash::from_byte_array(a.data)), ) }, } @@ -2062,6 +2148,12 @@ pub struct Bolt11InvoiceSignature { pub is_owned: bool, } +impl core::ops::Deref for Bolt11InvoiceSignature { + type Target = nativeBolt11InvoiceSignature; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for Bolt11InvoiceSignature { } +unsafe impl core::marker::Sync for Bolt11InvoiceSignature { } impl Drop for Bolt11InvoiceSignature { fn drop(&mut self) { if self.is_owned && !<*mut nativeBolt11InvoiceSignature>::is_null(self.inner) { @@ -2092,6 +2184,26 @@ impl Bolt11InvoiceSignature { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +#[no_mangle] +pub extern "C" fn Bolt11InvoiceSignature_get_a(this_ptr: &Bolt11InvoiceSignature) -> crate::c_types::RecoverableSignature { + let mut inner_val = &mut this_ptr.get_native_mut_ref().0; + crate::c_types::RecoverableSignature::from_rust(&inner_val) +} +#[no_mangle] +pub extern "C" fn Bolt11InvoiceSignature_set_a(this_ptr: &mut Bolt11InvoiceSignature, mut val: crate::c_types::RecoverableSignature) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.0 = val.into_rust(); +} +/// Constructs a new Bolt11InvoiceSignature given each field +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt11InvoiceSignature_new(mut a_arg: crate::c_types::RecoverableSignature) -> Bolt11InvoiceSignature { + Bolt11InvoiceSignature { inner: ObjOps::heap_alloc(lightning_invoice::Bolt11InvoiceSignature ( + a_arg.into_rust(), + )), is_owned: true } } impl Clone for Bolt11InvoiceSignature { fn clone(&self) -> Self { @@ -2158,6 +2270,12 @@ pub struct PrivateRoute { pub is_owned: bool, } +impl core::ops::Deref for PrivateRoute { + type Target = nativePrivateRoute; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for PrivateRoute { } +unsafe impl core::marker::Sync for PrivateRoute { } impl Drop for PrivateRoute { fn drop(&mut self) { if self.is_owned && !<*mut nativePrivateRoute>::is_null(self.inner) { @@ -2188,6 +2306,9 @@ impl PrivateRoute { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } impl Clone for PrivateRoute { fn clone(&self) -> Self { @@ -2372,9 +2493,9 @@ pub extern "C" fn RawBolt11Invoice_payment_metadata(this_arg: &crate::lightning_ /// 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 RawBolt11Invoice_features(this_arg: &crate::lightning_invoice::RawBolt11Invoice) -> crate::lightning::ln::features::Bolt11InvoiceFeatures { +pub extern "C" fn RawBolt11Invoice_features(this_arg: &crate::lightning_invoice::RawBolt11Invoice) -> crate::lightning_types::features::Bolt11InvoiceFeatures { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.features(); - 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 }; + let mut local_ret = crate::lightning_types::features::Bolt11InvoiceFeatures { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning_types::features::Bolt11InvoiceFeatures<>) as *mut _ }, is_owned: false }; local_ret } @@ -2575,9 +2696,9 @@ pub extern "C" fn Bolt11Invoice_payment_metadata(this_arg: &crate::lightning_inv /// 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 Bolt11Invoice_features(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> crate::lightning::ln::features::Bolt11InvoiceFeatures { +pub extern "C" fn Bolt11Invoice_features(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> crate::lightning_types::features::Bolt11InvoiceFeatures { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.features(); - 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 }; + let mut local_ret = crate::lightning_types::features::Bolt11InvoiceFeatures { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning_types::features::Bolt11InvoiceFeatures<>) as *mut _ }, is_owned: false }; local_ret } @@ -2682,7 +2803,7 @@ pub extern "C" fn Bolt11Invoice_private_routes(this_arg: &crate::lightning_invoi #[no_mangle] 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 } }); }; + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning_types::routing::RouteHint { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; local_ret.into() } @@ -2703,8 +2824,8 @@ pub extern "C" fn Bolt11Invoice_amount_milli_satoshis(this_arg: &crate::lightnin local_ret } -/// Creates a new `Description` if `description` is at most 1023 __bytes__ long, -/// returns [`CreationError::DescriptionTooLong`] otherwise +/// Creates a new `Description` if `description` is at most 1023 * 5 bits (i.e., 639 bytes) +/// long, and returns [`CreationError::DescriptionTooLong`] otherwise. /// /// Please note that single characters may use more than one byte due to UTF8 encoding. #[must_use] @@ -2718,9 +2839,17 @@ pub extern "C" fn Description_new(mut description: crate::c_types::Str) -> crate /// Returns the underlying description [`UntrustedString`] #[must_use] #[no_mangle] -pub extern "C" fn Description_into_inner(mut this_arg: crate::lightning_invoice::Description) -> crate::lightning::util::string::UntrustedString { +pub extern "C" fn Description_into_inner(mut this_arg: crate::lightning_invoice::Description) -> crate::lightning_types::string::UntrustedString { let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).into_inner(); - crate::lightning::util::string::UntrustedString { inner: ObjOps::heap_alloc(ret), is_owned: true } + crate::lightning_types::string::UntrustedString { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Get a reference to the underlying description [`UntrustedString`] +#[must_use] +#[no_mangle] +pub extern "C" fn Description_as_inner(this_arg: &crate::lightning_invoice::Description) -> crate::lightning_types::string::UntrustedString { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.as_inner(); + crate::lightning_types::string::UntrustedString { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning_types::string::UntrustedString<>) as *mut _) }, is_owned: false } } #[no_mangle] @@ -2763,7 +2892,7 @@ pub extern "C" fn ExpiryTime_as_duration(this_arg: &crate::lightning_invoice::Ex /// Creates a new (partial) route from a list of hops #[must_use] #[no_mangle] -pub extern "C" fn PrivateRoute_new(mut hops: crate::lightning::routing::router::RouteHint) -> crate::c_types::derived::CResult_PrivateRouteCreationErrorZ { +pub extern "C" fn PrivateRoute_new(mut hops: crate::lightning_types::routing::RouteHint) -> crate::c_types::derived::CResult_PrivateRouteCreationErrorZ { let mut ret = lightning_invoice::PrivateRoute::new(*unsafe { Box::from_raw(hops.take_inner()) }); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::PrivateRoute { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::CreationError::native_into(e) }).into() }; local_ret @@ -2772,9 +2901,9 @@ pub extern "C" fn PrivateRoute_new(mut hops: crate::lightning::routing::router:: /// Returns the underlying list of hops #[must_use] #[no_mangle] -pub extern "C" fn PrivateRoute_into_inner(mut this_arg: crate::lightning_invoice::PrivateRoute) -> crate::lightning::routing::router::RouteHint { +pub extern "C" fn PrivateRoute_into_inner(mut this_arg: crate::lightning_invoice::PrivateRoute) -> crate::lightning_types::routing::RouteHint { let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).into_inner(); - crate::lightning::routing::router::RouteHint { inner: ObjOps::heap_alloc(ret), is_owned: true } + crate::lightning_types::routing::RouteHint { inner: ObjOps::heap_alloc(ret), is_owned: true } } /// Errors that may occur when constructing a new [`RawBolt11Invoice`] or [`Bolt11Invoice`] @@ -2790,14 +2919,9 @@ pub enum CreationError { TimestampOutOfBounds, /// The supplied millisatoshi amount was greater than the total bitcoin supply. InvalidAmount, - /// Route hints were required for this invoice and were missing. Applies to - /// [phantom invoices]. - /// - /// [phantom invoices]: crate::utils::create_phantom_invoice + /// Route hints were required for this invoice and were missing. MissingRouteHints, - /// The provided `min_final_cltv_expiry_delta` was less than [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. - /// - /// [`MIN_FINAL_CLTV_EXPIRY_DELTA`]: lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA + /// The provided `min_final_cltv_expiry_delta` was less than rust-lightning's minimum. MinFinalCltvExpiryDeltaTooShort, } use lightning_invoice::CreationError as CreationErrorImport; diff --git a/lightning-c-bindings/src/lightning_invoice/payment.rs b/lightning-c-bindings/src/lightning_invoice/payment.rs deleted file mode 100644 index de0ea57..0000000 --- a/lightning-c-bindings/src/lightning_invoice/payment.rs +++ /dev/null @@ -1,56 +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. - -//! Convenient utilities for paying Lightning invoices. - -use alloc::str::FromStr; -use alloc::string::String; -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}; - -/// Builds the necessary parameters to pay or pre-flight probe the given zero-amount -/// [`Bolt11Invoice`] using [`ChannelManager::send_payment`] or -/// [`ChannelManager::send_preflight_probes`]. -/// -/// Prior to paying, you must ensure that the [`Bolt11Invoice::payment_hash`] is unique and the -/// same [`PaymentHash`] has never been paid before. -/// -/// Will always succeed unless the invoice has an amount specified, in which case -/// [`payment_parameters_from_invoice`] should be used. -/// -/// [`ChannelManager::send_payment`]: lightning::ln::channelmanager::ChannelManager::send_payment -/// [`ChannelManager::send_preflight_probes`]: lightning::ln::channelmanager::ChannelManager::send_preflight_probes -#[no_mangle] -pub extern "C" fn payment_parameters_from_zero_amount_invoice(invoice: &crate::lightning_invoice::Bolt11Invoice, mut amount_msat: u64) -> crate::c_types::derived::CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ { - let mut ret = lightning_invoice::payment::payment_parameters_from_zero_amount_invoice(invoice.get_native_ref(), amount_msat); - 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, mut orig_ret_0_2) = o; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0.0 }, crate::lightning::ln::outbound_payment::RecipientOnionFields { inner: ObjOps::heap_alloc(orig_ret_0_1), is_owned: true }, crate::lightning::routing::router::RouteParameters { inner: ObjOps::heap_alloc(orig_ret_0_2), is_owned: true }).into(); local_ret_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} - -/// Builds the necessary parameters to pay or pre-flight probe the given [`Bolt11Invoice`] using -/// [`ChannelManager::send_payment`] or [`ChannelManager::send_preflight_probes`]. -/// -/// Prior to paying, you must ensure that the [`Bolt11Invoice::payment_hash`] is unique and the -/// same [`PaymentHash`] has never been paid before. -/// -/// Will always succeed unless the invoice has no amount specified, in which case -/// [`payment_parameters_from_zero_amount_invoice`] should be used. -/// -/// [`ChannelManager::send_payment`]: lightning::ln::channelmanager::ChannelManager::send_payment -/// [`ChannelManager::send_preflight_probes`]: lightning::ln::channelmanager::ChannelManager::send_preflight_probes -#[no_mangle] -pub extern "C" fn payment_parameters_from_invoice(invoice: &crate::lightning_invoice::Bolt11Invoice) -> crate::c_types::derived::CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ { - let mut ret = lightning_invoice::payment::payment_parameters_from_invoice(invoice.get_native_ref()); - 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, mut orig_ret_0_2) = o; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0.0 }, crate::lightning::ln::outbound_payment::RecipientOnionFields { inner: ObjOps::heap_alloc(orig_ret_0_1), is_owned: true }, crate::lightning::routing::router::RouteParameters { inner: ObjOps::heap_alloc(orig_ret_0_2), is_owned: true }).into(); local_ret_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} - diff --git a/lightning-c-bindings/src/lightning_invoice/utils.rs b/lightning-c-bindings/src/lightning_invoice/utils.rs deleted file mode 100644 index 3c6a098..0000000 --- a/lightning-c-bindings/src/lightning_invoice/utils.rs +++ /dev/null @@ -1,205 +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. - -//! Convenient utilities to create an invoice. - -use alloc::str::FromStr; -use alloc::string::String; -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}; - -/// 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. -/// -/// `phantom_route_hints` parameter: -/// * Contains channel info for all nodes participating in the phantom invoice -/// * Entries are retrieved from a call to [`ChannelManager::get_phantom_route_hints`] on each -/// 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 -/// -/// `payment_hash` can be specified if you have a specific need for a custom payment hash (see the difference -/// between [`ChannelManager::create_inbound_payment`] and [`ChannelManager::create_inbound_payment_for_hash`]). -/// If `None` is provided for `payment_hash`, then one will be created. -/// -/// `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for -/// in excess of the current time. -/// -/// `duration_since_epoch` is the current time since epoch in seconds. -/// -/// You can specify a custom `min_final_cltv_expiry_delta`, or let LDK default it to -/// [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. The provided expiry must be at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`] - 3. -/// Note that LDK will add a buffer of 3 blocks to the delta to allow for up to a few new block -/// confirmations during routing. -/// -/// Note that the provided `keys_manager`'s `NodeSigner` implementation must support phantom -/// invoices in its `sign_invoice` implementation ([`PhantomKeysManager`] satisfies this -/// requirement). -/// -/// [`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 -/// [`PhantomRouteHints::channels`]: lightning::ln::channelmanager::PhantomRouteHints::channels -/// [`MIN_FINAL_CLTV_EXPIRY_DETLA`]: lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA -/// -/// 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. -#[no_mangle] -pub extern "C" fn create_phantom_invoice(mut amt_msat: crate::c_types::derived::COption_u64Z, mut payment_hash: crate::c_types::derived::COption_ThirtyTwoBytesZ, 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 = { /*payment_hash*/ let payment_hash_opt = payment_hash; if payment_hash_opt.is_none() { None } else { Some({ { ::lightning::ln::types::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::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 -} - -/// 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. -/// -/// `phantom_route_hints` parameter: -/// * Contains channel info for all nodes participating in the phantom invoice -/// * Entries are retrieved from a call to [`ChannelManager::get_phantom_route_hints`] on each -/// 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 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 -/// -/// `payment_hash` can be specified if you have a specific need for a custom payment hash (see the difference -/// between [`ChannelManager::create_inbound_payment`] and [`ChannelManager::create_inbound_payment_for_hash`]). -/// If `None` is provided for `payment_hash`, then one will be created. -/// -/// `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for -/// in excess of the current time. -/// -/// `duration_since_epoch` is the current time since epoch in seconds. -/// -/// Note that the provided `keys_manager`'s `NodeSigner` implementation must support phantom -/// invoices in its `sign_invoice` implementation ([`PhantomKeysManager`] satisfies this -/// requirement). -/// -/// [`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 -/// [`PhantomRouteHints::channels`]: lightning::ln::channelmanager::PhantomRouteHints::channels -/// -/// 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. -#[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::derived::COption_ThirtyTwoBytesZ, 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 = { /*payment_hash*/ let payment_hash_opt = payment_hash; if payment_hash_opt.is_none() { None } else { Some({ { ::lightning::ln::types::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::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 -} - -/// Utility to construct an invoice. Generally, unless you want to do something like a custom -/// cltv_expiry, this is what you should be using to create an invoice. The reason being, this -/// method stores the invoice's payment secret and preimage in `ChannelManager`, so (a) the user -/// doesn't have to store preimage/payment secret information and (b) `ChannelManager` can verify -/// that the payment secret is valid when the invoice is paid. -/// -/// `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for -/// in excess of the current time. -/// -/// You can specify a custom `min_final_cltv_expiry_delta`, or let LDK default it to -/// [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. The provided expiry must be at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. -/// Note that LDK will add a buffer of 3 blocks to the delta to allow for up to a few new block -/// confirmations during routing. -/// -/// [`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::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::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 -} - -/// Utility to construct an invoice. Generally, unless you want to do something like a custom -/// cltv_expiry, this is what you should be using to create an invoice. The reason being, this -/// method stores the invoice's payment secret and preimage in `ChannelManager`, so (a) the user -/// doesn't have to store preimage/payment secret information and (b) `ChannelManager` can verify -/// that the payment secret is valid when the invoice is paid. -/// Use this variant if you want to pass the `description_hash` to the invoice. -/// -/// `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for -/// in excess of the current time. -/// -/// You can specify a custom `min_final_cltv_expiry_delta`, or let LDK default it to -/// [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. The provided expiry must be at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. -/// Note that LDK will add a buffer of 3 blocks to the delta to allow for up to a few new block -/// confirmations during routing. -/// -/// [`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::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::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 -} - -/// 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. -#[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::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::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 -} - -/// 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. -#[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::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::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 -} - -/// See [`create_invoice_from_channelmanager_and_duration_since_epoch`] -/// This version allows for providing a custom [`PaymentHash`] for the invoice. -/// 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::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::types::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/fs_store.rs b/lightning-c-bindings/src/lightning_persister/fs_store.rs index dce100b..46c355d 100644 --- a/lightning-c-bindings/src/lightning_persister/fs_store.rs +++ b/lightning-c-bindings/src/lightning_persister/fs_store.rs @@ -37,6 +37,12 @@ pub struct FilesystemStore { pub is_owned: bool, } +impl core::ops::Deref for FilesystemStore { + type Target = nativeFilesystemStore; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for FilesystemStore { } +unsafe impl core::marker::Sync for FilesystemStore { } impl Drop for FilesystemStore { fn drop(&mut self) { if self.is_owned && !<*mut nativeFilesystemStore>::is_null(self.inner) { @@ -67,6 +73,9 @@ impl FilesystemStore { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Constructs a new [`FilesystemStore`]. #[must_use] @@ -111,25 +120,25 @@ pub extern "C" fn FilesystemStore_as_KVStore(this_arg: &FilesystemStore) -> crat #[must_use] extern "C" fn FilesystemStore_KVStore_read(this_arg: *const c_void, mut primary_namespace: crate::c_types::Str, mut secondary_namespace: crate::c_types::Str, mut key: crate::c_types::Str) -> crate::c_types::derived::CResult_CVec_u8ZIOErrorZ { let mut ret = ::read(unsafe { &mut *(this_arg as *mut nativeFilesystemStore) }, primary_namespace.into_str(), secondary_namespace.into_str(), key.into_str()); - 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( { item }); }; local_ret_0.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::IOError::from_rust(e) }).into() }; + 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( { item }); }; local_ret_0.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::IOError::from_bitcoin(e) }).into() }; local_ret } #[must_use] extern "C" fn FilesystemStore_KVStore_write(this_arg: *const c_void, mut primary_namespace: crate::c_types::Str, mut secondary_namespace: crate::c_types::Str, mut key: crate::c_types::Str, mut buf: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NoneIOErrorZ { let mut ret = ::write(unsafe { &mut *(this_arg as *mut nativeFilesystemStore) }, primary_namespace.into_str(), secondary_namespace.into_str(), key.into_str(), buf.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::c_types::IOError::from_rust(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::c_types::IOError::from_bitcoin(e) }).into() }; local_ret } #[must_use] extern "C" fn FilesystemStore_KVStore_remove(this_arg: *const c_void, mut primary_namespace: crate::c_types::Str, mut secondary_namespace: crate::c_types::Str, mut key: crate::c_types::Str, mut lazy: bool) -> crate::c_types::derived::CResult_NoneIOErrorZ { let mut ret = ::remove(unsafe { &mut *(this_arg as *mut nativeFilesystemStore) }, primary_namespace.into_str(), secondary_namespace.into_str(), key.into_str(), lazy); - 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::c_types::IOError::from_rust(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::c_types::IOError::from_bitcoin(e) }).into() }; local_ret } #[must_use] extern "C" fn FilesystemStore_KVStore_list(this_arg: *const c_void, mut primary_namespace: crate::c_types::Str, mut secondary_namespace: crate::c_types::Str) -> crate::c_types::derived::CResult_CVec_StrZIOErrorZ { let mut ret = ::list(unsafe { &mut *(this_arg as *mut nativeFilesystemStore) }, primary_namespace.into_str(), secondary_namespace.into_str()); - 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( { item.into() }); }; local_ret_0.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::IOError::from_rust(e) }).into() }; + 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( { item.into() }); }; local_ret_0.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::IOError::from_bitcoin(e) }).into() }; local_ret } diff --git a/lightning-c-bindings/src/lightning_rapid_gossip_sync.rs b/lightning-c-bindings/src/lightning_rapid_gossip_sync.rs index 3654334..4286473 100644 --- a/lightning-c-bindings/src/lightning_rapid_gossip_sync.rs +++ b/lightning-c-bindings/src/lightning_rapid_gossip_sync.rs @@ -37,7 +37,7 @@ //! from disk, which we do by calling [`RapidGossipSync::update_network_graph`]: //! //! ``` -//! use bitcoin::blockdata::constants::genesis_block; +//! use bitcoin::constants::genesis_block; //! use bitcoin::Network; //! use lightning::routing::gossip::NetworkGraph; //! use lightning_rapid_gossip_sync::RapidGossipSync; @@ -218,6 +218,12 @@ pub struct RapidGossipSync { pub is_owned: bool, } +impl core::ops::Deref for RapidGossipSync { + type Target = nativeRapidGossipSync; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for RapidGossipSync { } +unsafe impl core::marker::Sync for RapidGossipSync { } impl Drop for RapidGossipSync { fn drop(&mut self) { if self.is_owned && !<*mut nativeRapidGossipSync>::is_null(self.inner) { @@ -248,6 +254,9 @@ impl RapidGossipSync { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Instantiate a new [`RapidGossipSync`] instance. #[must_use] diff --git a/lightning-c-bindings/src/lightning_types/features.rs b/lightning-c-bindings/src/lightning_types/features.rs new file mode 100644 index 0000000..a7cfa21 --- /dev/null +++ b/lightning-c-bindings/src/lightning_types/features.rs @@ -0,0 +1,3614 @@ +// 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. + +//! Feature flag definitions for the Lightning protocol according to [BOLT #9]. +//! +//! Lightning nodes advertise a supported set of operation through feature flags. Features are +//! applicable for a specific context. [`Features`] encapsulates behavior for specifying and +//! checking feature flags for a particular context. Each feature is defined internally by a trait +//! specifying the corresponding flags (i.e., even and odd bits). +//! +//! Whether a feature is considered \"known\" or \"unknown\" is relative to the implementation, whereas +//! the term \"supports\" is used in reference to a particular set of [`Features`]. That is, a node +//! supports a feature if it advertises the feature (as either required or optional) to its peers. +//! And the implementation can interpret a feature if the feature is known to it. +//! +//! The following features are currently required in the LDK: +//! - `VariableLengthOnion` - requires/supports variable-length routing onion payloads +//! (see [BOLT-4](https://github.com/lightning/bolts/blob/master/04-onion-routing.md) for more information). +//! - `StaticRemoteKey` - requires/supports static key for remote output +//! (see [BOLT-3](https://github.com/lightning/bolts/blob/master/03-transactions.md) for more information). +//! +//! The following features are currently supported in the LDK: +//! - `DataLossProtect` - requires/supports that a node which has somehow fallen behind, e.g., has been restored from an old backup, +//! can detect that it has fallen behind +//! (see [BOLT-2](https://github.com/lightning/bolts/blob/master/02-peer-protocol.md) for more information). +//! - `InitialRoutingSync` - requires/supports that the sending node needs a complete routing information dump +//! (see [BOLT-7](https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#initial-sync) for more information). +//! - `UpfrontShutdownScript` - commits to a shutdown scriptpubkey when opening a channel +//! (see [BOLT-2](https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-open_channel-message) for more information). +//! - `GossipQueries` - requires/supports more sophisticated gossip control +//! (see [BOLT-7](https://github.com/lightning/bolts/blob/master/07-routing-gossip.md) for more information). +//! - `PaymentSecret` - requires/supports that a node supports payment_secret field +//! (see [BOLT-4](https://github.com/lightning/bolts/blob/master/04-onion-routing.md) for more information). +//! - `BasicMPP` - requires/supports that a node can receive basic multi-part payments +//! (see [BOLT-4](https://github.com/lightning/bolts/blob/master/04-onion-routing.md#basic-multi-part-payments) for more information). +//! - `Wumbo` - requires/supports that a node create large channels. Called `option_support_large_channel` in the spec. +//! (see [BOLT-2](https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-open_channel-message) for more information). +//! - `AnchorsZeroFeeHtlcTx` - requires/supports that commitment transactions include anchor outputs +//! and HTLC transactions are pre-signed with zero fee (see +//! [BOLT-3](https://github.com/lightning/bolts/blob/master/03-transactions.md) for more +//! information). +//! - `RouteBlinding` - requires/supports that a node can relay payments over blinded paths +//! (see [BOLT-4](https://github.com/lightning/bolts/blob/master/04-onion-routing.md#route-blinding) for more information). +//! - `ShutdownAnySegwit` - requires/supports that future segwit versions are allowed in `shutdown` +//! (see [BOLT-2](https://github.com/lightning/bolts/blob/master/02-peer-protocol.md) for more information). +//! - `OnionMessages` - requires/supports forwarding onion messages +//! (see [BOLT-7](https://github.com/lightning/bolts/pull/759/files) for more information). +//! - `ChannelType` - node supports the channel_type field in open/accept +//! (see [BOLT-2](https://github.com/lightning/bolts/blob/master/02-peer-protocol.md) for more information). +//! - `SCIDPrivacy` - supply channel aliases for routing +//! (see [BOLT-2](https://github.com/lightning/bolts/blob/master/02-peer-protocol.md) for more information). +//! - `PaymentMetadata` - include additional data in invoices which is passed to recipients in the +//! onion. +//! (see [BOLT-11](https://github.com/lightning/bolts/blob/master/11-payment-encoding.md) for +//! more). +//! - `ZeroConf` - supports accepting HTLCs and using channels prior to funding confirmation +//! (see +//! [BOLT-2](https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-channel_ready-message) +//! for more info). +//! - `Keysend` - send funds to a node without an invoice +//! (see the [`Keysend` feature assignment proposal](https://github.com/lightning/bolts/issues/605#issuecomment-606679798) for more information). +//! - `Trampoline` - supports receiving and forwarding Trampoline payments +//! (see the [`Trampoline` feature proposal](https://github.com/lightning/bolts/pull/836) 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 + +use alloc::str::FromStr; +use alloc::string::String; +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}; + +mod sealed { + +use alloc::str::FromStr; +use alloc::string::String; +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}; + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn InitFeatures_set_data_loss_protect_optional(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_data_loss_protect_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn InitFeatures_set_data_loss_protect_required(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_data_loss_protect_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_supports_data_loss_protect(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_data_loss_protect(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_data_loss_protect_optional(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_data_loss_protect_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_data_loss_protect_required(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_data_loss_protect_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_supports_data_loss_protect(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_data_loss_protect(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_requires_data_loss_protect(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_data_loss_protect(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_requires_data_loss_protect(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_data_loss_protect(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn InitFeatures_set_initial_routing_sync_optional(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_initial_routing_sync_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn InitFeatures_set_initial_routing_sync_required(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_initial_routing_sync_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_initial_routing_sync(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.initial_routing_sync(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn InitFeatures_set_upfront_shutdown_script_optional(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_upfront_shutdown_script_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn InitFeatures_set_upfront_shutdown_script_required(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_upfront_shutdown_script_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_supports_upfront_shutdown_script(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_upfront_shutdown_script(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_upfront_shutdown_script_optional(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_upfront_shutdown_script_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_upfront_shutdown_script_required(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_upfront_shutdown_script_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_supports_upfront_shutdown_script(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_upfront_shutdown_script(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_requires_upfront_shutdown_script(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_upfront_shutdown_script(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_requires_upfront_shutdown_script(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_upfront_shutdown_script(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn InitFeatures_set_gossip_queries_optional(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_gossip_queries_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn InitFeatures_set_gossip_queries_required(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_gossip_queries_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_supports_gossip_queries(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_gossip_queries(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_gossip_queries_optional(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_gossip_queries_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_gossip_queries_required(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_gossip_queries_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_supports_gossip_queries(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_gossip_queries(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_requires_gossip_queries(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_gossip_queries(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_requires_gossip_queries(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_gossip_queries(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn InitFeatures_set_variable_length_onion_optional(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_variable_length_onion_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn InitFeatures_set_variable_length_onion_required(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_variable_length_onion_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_supports_variable_length_onion(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_variable_length_onion(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_variable_length_onion_optional(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_variable_length_onion_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_variable_length_onion_required(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_variable_length_onion_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_supports_variable_length_onion(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_variable_length_onion(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_set_variable_length_onion_optional(this_arg: &mut crate::lightning_types::features::Bolt11InvoiceFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeBolt11InvoiceFeatures)) }.set_variable_length_onion_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_set_variable_length_onion_required(this_arg: &mut crate::lightning_types::features::Bolt11InvoiceFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeBolt11InvoiceFeatures)) }.set_variable_length_onion_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_supports_variable_length_onion(this_arg: &crate::lightning_types::features::Bolt11InvoiceFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_variable_length_onion(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_requires_variable_length_onion(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_variable_length_onion(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_requires_variable_length_onion(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_variable_length_onion(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_requires_variable_length_onion(this_arg: &crate::lightning_types::features::Bolt11InvoiceFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_variable_length_onion(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn InitFeatures_set_static_remote_key_optional(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_static_remote_key_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn InitFeatures_set_static_remote_key_required(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_static_remote_key_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_supports_static_remote_key(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_static_remote_key(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_static_remote_key_optional(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_static_remote_key_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_static_remote_key_required(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_static_remote_key_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_supports_static_remote_key(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_static_remote_key(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_set_static_remote_key_optional(this_arg: &mut crate::lightning_types::features::ChannelTypeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeChannelTypeFeatures)) }.set_static_remote_key_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_set_static_remote_key_required(this_arg: &mut crate::lightning_types::features::ChannelTypeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeChannelTypeFeatures)) }.set_static_remote_key_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_supports_static_remote_key(this_arg: &crate::lightning_types::features::ChannelTypeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_static_remote_key(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_requires_static_remote_key(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_static_remote_key(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_requires_static_remote_key(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_static_remote_key(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_requires_static_remote_key(this_arg: &crate::lightning_types::features::ChannelTypeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_static_remote_key(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn InitFeatures_set_payment_secret_optional(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_payment_secret_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn InitFeatures_set_payment_secret_required(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_payment_secret_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_supports_payment_secret(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_payment_secret(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_payment_secret_optional(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_payment_secret_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_payment_secret_required(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_payment_secret_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_supports_payment_secret(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_payment_secret(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_set_payment_secret_optional(this_arg: &mut crate::lightning_types::features::Bolt11InvoiceFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeBolt11InvoiceFeatures)) }.set_payment_secret_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_set_payment_secret_required(this_arg: &mut crate::lightning_types::features::Bolt11InvoiceFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeBolt11InvoiceFeatures)) }.set_payment_secret_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_supports_payment_secret(this_arg: &crate::lightning_types::features::Bolt11InvoiceFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_payment_secret(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_requires_payment_secret(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_payment_secret(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_requires_payment_secret(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_payment_secret(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_requires_payment_secret(this_arg: &crate::lightning_types::features::Bolt11InvoiceFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_payment_secret(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn InitFeatures_set_basic_mpp_optional(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_basic_mpp_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn InitFeatures_set_basic_mpp_required(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_basic_mpp_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_supports_basic_mpp(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_basic_mpp(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_basic_mpp_optional(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_basic_mpp_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_basic_mpp_required(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_basic_mpp_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_supports_basic_mpp(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_basic_mpp(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_set_basic_mpp_optional(this_arg: &mut crate::lightning_types::features::Bolt11InvoiceFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeBolt11InvoiceFeatures)) }.set_basic_mpp_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_set_basic_mpp_required(this_arg: &mut crate::lightning_types::features::Bolt11InvoiceFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeBolt11InvoiceFeatures)) }.set_basic_mpp_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_supports_basic_mpp(this_arg: &crate::lightning_types::features::Bolt11InvoiceFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_basic_mpp(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn Bolt12InvoiceFeatures_set_basic_mpp_optional(this_arg: &mut crate::lightning_types::features::Bolt12InvoiceFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeBolt12InvoiceFeatures)) }.set_basic_mpp_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn Bolt12InvoiceFeatures_set_basic_mpp_required(this_arg: &mut crate::lightning_types::features::Bolt12InvoiceFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeBolt12InvoiceFeatures)) }.set_basic_mpp_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt12InvoiceFeatures_supports_basic_mpp(this_arg: &crate::lightning_types::features::Bolt12InvoiceFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_basic_mpp(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_requires_basic_mpp(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_basic_mpp(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_requires_basic_mpp(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_basic_mpp(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_requires_basic_mpp(this_arg: &crate::lightning_types::features::Bolt11InvoiceFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_basic_mpp(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt12InvoiceFeatures_requires_basic_mpp(this_arg: &crate::lightning_types::features::Bolt12InvoiceFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_basic_mpp(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn InitFeatures_set_wumbo_optional(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_wumbo_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn InitFeatures_set_wumbo_required(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_wumbo_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_supports_wumbo(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_wumbo(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_wumbo_optional(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_wumbo_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_wumbo_required(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_wumbo_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_supports_wumbo(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_wumbo(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_requires_wumbo(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_wumbo(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_requires_wumbo(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_wumbo(); + 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_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::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_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::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_types::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_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::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_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::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_types::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_types::features::ChannelTypeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::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_types::features::ChannelTypeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::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_types::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_types::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_types::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_types::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_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_anchors_zero_fee_htlc_tx_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn InitFeatures_set_anchors_zero_fee_htlc_tx_required(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_anchors_zero_fee_htlc_tx_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_supports_anchors_zero_fee_htlc_tx(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_anchors_zero_fee_htlc_tx(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_anchors_zero_fee_htlc_tx_optional(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_anchors_zero_fee_htlc_tx_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_anchors_zero_fee_htlc_tx_required(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_anchors_zero_fee_htlc_tx_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_supports_anchors_zero_fee_htlc_tx(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_anchors_zero_fee_htlc_tx(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_set_anchors_zero_fee_htlc_tx_optional(this_arg: &mut crate::lightning_types::features::ChannelTypeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeChannelTypeFeatures)) }.set_anchors_zero_fee_htlc_tx_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_set_anchors_zero_fee_htlc_tx_required(this_arg: &mut crate::lightning_types::features::ChannelTypeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeChannelTypeFeatures)) }.set_anchors_zero_fee_htlc_tx_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_supports_anchors_zero_fee_htlc_tx(this_arg: &crate::lightning_types::features::ChannelTypeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_anchors_zero_fee_htlc_tx(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_requires_anchors_zero_fee_htlc_tx(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_anchors_zero_fee_htlc_tx(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_requires_anchors_zero_fee_htlc_tx(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_anchors_zero_fee_htlc_tx(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_requires_anchors_zero_fee_htlc_tx(this_arg: &crate::lightning_types::features::ChannelTypeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_anchors_zero_fee_htlc_tx(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn InitFeatures_set_route_blinding_optional(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_route_blinding_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn InitFeatures_set_route_blinding_required(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_route_blinding_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_supports_route_blinding(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_route_blinding(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_route_blinding_optional(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_route_blinding_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_route_blinding_required(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_route_blinding_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_supports_route_blinding(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_route_blinding(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_requires_route_blinding(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_route_blinding(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_requires_route_blinding(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_route_blinding(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn InitFeatures_set_shutdown_any_segwit_optional(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_shutdown_any_segwit_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn InitFeatures_set_shutdown_any_segwit_required(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_shutdown_any_segwit_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_supports_shutdown_anysegwit(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_shutdown_anysegwit(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_shutdown_any_segwit_optional(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_shutdown_any_segwit_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_shutdown_any_segwit_required(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_shutdown_any_segwit_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_supports_shutdown_anysegwit(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_shutdown_anysegwit(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_requires_shutdown_anysegwit(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_shutdown_anysegwit(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_requires_shutdown_anysegwit(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_shutdown_anysegwit(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn InitFeatures_set_taproot_optional(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_taproot_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn InitFeatures_set_taproot_required(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_taproot_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_supports_taproot(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_taproot(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_taproot_optional(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_taproot_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_taproot_required(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_taproot_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_supports_taproot(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_taproot(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_set_taproot_optional(this_arg: &mut crate::lightning_types::features::ChannelTypeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeChannelTypeFeatures)) }.set_taproot_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_set_taproot_required(this_arg: &mut crate::lightning_types::features::ChannelTypeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeChannelTypeFeatures)) }.set_taproot_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_supports_taproot(this_arg: &crate::lightning_types::features::ChannelTypeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_taproot(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_requires_taproot(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_taproot(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_requires_taproot(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_taproot(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_requires_taproot(this_arg: &crate::lightning_types::features::ChannelTypeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_taproot(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn InitFeatures_set_onion_messages_optional(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_onion_messages_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn InitFeatures_set_onion_messages_required(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_onion_messages_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_supports_onion_messages(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_onion_messages(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_onion_messages_optional(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_onion_messages_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_onion_messages_required(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_onion_messages_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_supports_onion_messages(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_onion_messages(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_requires_onion_messages(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_onion_messages(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_requires_onion_messages(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_onion_messages(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn InitFeatures_set_channel_type_optional(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_channel_type_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn InitFeatures_set_channel_type_required(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_channel_type_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_supports_channel_type(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_channel_type(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_channel_type_optional(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_channel_type_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_channel_type_required(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_channel_type_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_supports_channel_type(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_channel_type(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_requires_channel_type(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_channel_type(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_requires_channel_type(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_channel_type(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn InitFeatures_set_scid_privacy_optional(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_scid_privacy_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn InitFeatures_set_scid_privacy_required(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_scid_privacy_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_supports_scid_privacy(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_scid_privacy(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_scid_privacy_optional(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_scid_privacy_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_scid_privacy_required(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_scid_privacy_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_supports_scid_privacy(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_scid_privacy(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_set_scid_privacy_optional(this_arg: &mut crate::lightning_types::features::ChannelTypeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeChannelTypeFeatures)) }.set_scid_privacy_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_set_scid_privacy_required(this_arg: &mut crate::lightning_types::features::ChannelTypeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeChannelTypeFeatures)) }.set_scid_privacy_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_supports_scid_privacy(this_arg: &crate::lightning_types::features::ChannelTypeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_scid_privacy(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_requires_scid_privacy(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_scid_privacy(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_requires_scid_privacy(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_scid_privacy(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_requires_scid_privacy(this_arg: &crate::lightning_types::features::ChannelTypeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_scid_privacy(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_set_payment_metadata_optional(this_arg: &mut crate::lightning_types::features::Bolt11InvoiceFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeBolt11InvoiceFeatures)) }.set_payment_metadata_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_set_payment_metadata_required(this_arg: &mut crate::lightning_types::features::Bolt11InvoiceFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeBolt11InvoiceFeatures)) }.set_payment_metadata_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_supports_payment_metadata(this_arg: &crate::lightning_types::features::Bolt11InvoiceFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_payment_metadata(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_requires_payment_metadata(this_arg: &crate::lightning_types::features::Bolt11InvoiceFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_payment_metadata(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn InitFeatures_set_zero_conf_optional(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_zero_conf_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn InitFeatures_set_zero_conf_required(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_zero_conf_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_supports_zero_conf(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_zero_conf(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_zero_conf_optional(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_zero_conf_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_zero_conf_required(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_zero_conf_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_supports_zero_conf(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_zero_conf(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_set_zero_conf_optional(this_arg: &mut crate::lightning_types::features::ChannelTypeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeChannelTypeFeatures)) }.set_zero_conf_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_set_zero_conf_required(this_arg: &mut crate::lightning_types::features::ChannelTypeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeChannelTypeFeatures)) }.set_zero_conf_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_supports_zero_conf(this_arg: &crate::lightning_types::features::ChannelTypeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_zero_conf(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_requires_zero_conf(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_zero_conf(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_requires_zero_conf(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_zero_conf(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_requires_zero_conf(this_arg: &crate::lightning_types::features::ChannelTypeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_zero_conf(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_keysend_optional(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_keysend_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_keysend_required(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_keysend_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_supports_keysend(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_keysend(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_requires_keysend(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_keysend(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn InitFeatures_set_trampoline_routing_optional(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_trampoline_routing_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn InitFeatures_set_trampoline_routing_required(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_trampoline_routing_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_supports_trampoline_routing(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_trampoline_routing(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_trampoline_routing_optional(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_trampoline_routing_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_trampoline_routing_required(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_trampoline_routing_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_supports_trampoline_routing(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_trampoline_routing(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_set_trampoline_routing_optional(this_arg: &mut crate::lightning_types::features::Bolt11InvoiceFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeBolt11InvoiceFeatures)) }.set_trampoline_routing_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_set_trampoline_routing_required(this_arg: &mut crate::lightning_types::features::Bolt11InvoiceFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeBolt11InvoiceFeatures)) }.set_trampoline_routing_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_supports_trampoline_routing(this_arg: &crate::lightning_types::features::Bolt11InvoiceFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_trampoline_routing(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_requires_trampoline_routing(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_trampoline_routing(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_requires_trampoline_routing(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_trampoline_routing(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_requires_trampoline_routing(this_arg: &crate::lightning_types::features::Bolt11InvoiceFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_trampoline_routing(); + ret +} + +} +/// 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. +#[no_mangle] +pub extern "C" fn InitFeatures_eq(a: &InitFeatures, b: &InitFeatures) -> 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 } +} +/// 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. +#[no_mangle] +pub extern "C" fn NodeFeatures_eq(a: &NodeFeatures, b: &NodeFeatures) -> 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 } +} +/// 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. +#[no_mangle] +pub extern "C" fn ChannelFeatures_eq(a: &ChannelFeatures, b: &ChannelFeatures) -> 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 } +} +/// 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 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 } +} +/// 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. +#[no_mangle] +pub extern "C" fn OfferFeatures_eq(a: &OfferFeatures, b: &OfferFeatures) -> 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 } +} +/// 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. +#[no_mangle] +pub extern "C" fn InvoiceRequestFeatures_eq(a: &InvoiceRequestFeatures, b: &InvoiceRequestFeatures) -> 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 } +} +/// 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. +#[no_mangle] +pub extern "C" fn Bolt12InvoiceFeatures_eq(a: &Bolt12InvoiceFeatures, b: &Bolt12InvoiceFeatures) -> 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 } +} +/// 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. +#[no_mangle] +pub extern "C" fn BlindedHopFeatures_eq(a: &BlindedHopFeatures, b: &BlindedHopFeatures) -> 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 } +} +/// 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. +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_eq(a: &ChannelTypeFeatures, b: &ChannelTypeFeatures) -> 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 InitFeatures { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeInitFeatures>::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 InitFeatures_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeInitFeatures)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the InitFeatures +pub extern "C" fn InitFeatures_clone(orig: &InitFeatures) -> InitFeatures { + orig.clone() +} +impl Clone for NodeFeatures { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeNodeFeatures>::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 NodeFeatures_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeNodeFeatures)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the NodeFeatures +pub extern "C" fn NodeFeatures_clone(orig: &NodeFeatures) -> NodeFeatures { + orig.clone() +} +impl Clone for ChannelFeatures { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeChannelFeatures>::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 ChannelFeatures_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeChannelFeatures)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the ChannelFeatures +pub extern "C" fn ChannelFeatures_clone(orig: &ChannelFeatures) -> ChannelFeatures { + orig.clone() +} +impl Clone for Bolt11InvoiceFeatures { + fn clone(&self) -> Self { + Self { + 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, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +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 *const nativeBolt11InvoiceFeatures)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the Bolt11InvoiceFeatures +pub extern "C" fn Bolt11InvoiceFeatures_clone(orig: &Bolt11InvoiceFeatures) -> Bolt11InvoiceFeatures { + orig.clone() +} +impl Clone for OfferFeatures { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeOfferFeatures>::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 OfferFeatures_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeOfferFeatures)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the OfferFeatures +pub extern "C" fn OfferFeatures_clone(orig: &OfferFeatures) -> OfferFeatures { + orig.clone() +} +impl Clone for InvoiceRequestFeatures { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeInvoiceRequestFeatures>::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 InvoiceRequestFeatures_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeInvoiceRequestFeatures)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the InvoiceRequestFeatures +pub extern "C" fn InvoiceRequestFeatures_clone(orig: &InvoiceRequestFeatures) -> InvoiceRequestFeatures { + orig.clone() +} +impl Clone for Bolt12InvoiceFeatures { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeBolt12InvoiceFeatures>::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 Bolt12InvoiceFeatures_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeBolt12InvoiceFeatures)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the Bolt12InvoiceFeatures +pub extern "C" fn Bolt12InvoiceFeatures_clone(orig: &Bolt12InvoiceFeatures) -> Bolt12InvoiceFeatures { + orig.clone() +} +impl Clone for BlindedHopFeatures { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeBlindedHopFeatures>::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 BlindedHopFeatures_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeBlindedHopFeatures)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the BlindedHopFeatures +pub extern "C" fn BlindedHopFeatures_clone(orig: &BlindedHopFeatures) -> BlindedHopFeatures { + orig.clone() +} +impl Clone for ChannelTypeFeatures { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeChannelTypeFeatures>::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 ChannelTypeFeatures_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeChannelTypeFeatures)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the ChannelTypeFeatures +pub extern "C" fn ChannelTypeFeatures_clone(orig: &ChannelTypeFeatures) -> ChannelTypeFeatures { + orig.clone() +} +/// Generates a non-cryptographic 64-bit hash of the InitFeatures. +#[no_mangle] +pub extern "C" fn InitFeatures_hash(o: &InitFeatures) -> 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) +} +/// Generates a non-cryptographic 64-bit hash of the NodeFeatures. +#[no_mangle] +pub extern "C" fn NodeFeatures_hash(o: &NodeFeatures) -> 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) +} +/// Generates a non-cryptographic 64-bit hash of the ChannelFeatures. +#[no_mangle] +pub extern "C" fn ChannelFeatures_hash(o: &ChannelFeatures) -> 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) +} +/// Generates a non-cryptographic 64-bit hash of the Bolt11InvoiceFeatures. +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_hash(o: &Bolt11InvoiceFeatures) -> 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) +} +/// Generates a non-cryptographic 64-bit hash of the OfferFeatures. +#[no_mangle] +pub extern "C" fn OfferFeatures_hash(o: &OfferFeatures) -> 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) +} +/// Generates a non-cryptographic 64-bit hash of the InvoiceRequestFeatures. +#[no_mangle] +pub extern "C" fn InvoiceRequestFeatures_hash(o: &InvoiceRequestFeatures) -> 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) +} +/// Generates a non-cryptographic 64-bit hash of the Bolt12InvoiceFeatures. +#[no_mangle] +pub extern "C" fn Bolt12InvoiceFeatures_hash(o: &Bolt12InvoiceFeatures) -> 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) +} +/// Generates a non-cryptographic 64-bit hash of the BlindedHopFeatures. +#[no_mangle] +pub extern "C" fn BlindedHopFeatures_hash(o: &BlindedHopFeatures) -> 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) +} +/// Generates a non-cryptographic 64-bit hash of the ChannelTypeFeatures. +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_hash(o: &ChannelTypeFeatures) -> 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) +} +/// Get a string which allows debug introspection of a InitFeatures object +pub extern "C" fn InitFeatures_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_types::features::InitFeatures }).into()} +/// Get a string which allows debug introspection of a NodeFeatures object +pub extern "C" fn NodeFeatures_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_types::features::NodeFeatures }).into()} +/// Get a string which allows debug introspection of a ChannelFeatures object +pub extern "C" fn ChannelFeatures_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_types::features::ChannelFeatures }).into()} +/// Get a string which allows debug introspection of a Bolt11InvoiceFeatures object +pub extern "C" fn Bolt11InvoiceFeatures_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_types::features::Bolt11InvoiceFeatures }).into()} +/// Get a string which allows debug introspection of a OfferFeatures object +pub extern "C" fn OfferFeatures_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_types::features::OfferFeatures }).into()} +/// Get a string which allows debug introspection of a InvoiceRequestFeatures object +pub extern "C" fn InvoiceRequestFeatures_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_types::features::InvoiceRequestFeatures }).into()} +/// Get a string which allows debug introspection of a Bolt12InvoiceFeatures object +pub extern "C" fn Bolt12InvoiceFeatures_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_types::features::Bolt12InvoiceFeatures }).into()} +/// Get a string which allows debug introspection of a BlindedHopFeatures object +pub extern "C" fn BlindedHopFeatures_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_types::features::BlindedHopFeatures }).into()} +/// Get a string which allows debug introspection of a ChannelTypeFeatures object +pub extern "C" fn ChannelTypeFeatures_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_types::features::ChannelTypeFeatures }).into()} + +use lightning_types::features::InitFeatures as nativeInitFeaturesImport; +pub(crate) type nativeInitFeatures = nativeInitFeaturesImport; + +/// Features used within an `init` message. +#[must_use] +#[repr(C)] +pub struct InitFeatures { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, 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 nativeInitFeatures, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust 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 core::ops::Deref for InitFeatures { + type Target = nativeInitFeatures; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for InitFeatures { } +unsafe impl core::marker::Sync for InitFeatures { } +impl Drop for InitFeatures { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeInitFeatures>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the InitFeatures, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn InitFeatures_free(this_obj: InitFeatures) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn InitFeatures_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeInitFeatures) }; +} +#[allow(unused)] +impl InitFeatures { + pub(crate) fn get_native_ref(&self) -> &'static nativeInitFeatures { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInitFeatures { + 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 nativeInitFeatures { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} + +use lightning_types::features::NodeFeatures as nativeNodeFeaturesImport; +pub(crate) type nativeNodeFeatures = nativeNodeFeaturesImport; + +/// Features used within a `node_announcement` message. +#[must_use] +#[repr(C)] +pub struct NodeFeatures { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, 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 nativeNodeFeatures, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust 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 core::ops::Deref for NodeFeatures { + type Target = nativeNodeFeatures; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for NodeFeatures { } +unsafe impl core::marker::Sync for NodeFeatures { } +impl Drop for NodeFeatures { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeNodeFeatures>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the NodeFeatures, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn NodeFeatures_free(this_obj: NodeFeatures) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn NodeFeatures_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeNodeFeatures) }; +} +#[allow(unused)] +impl NodeFeatures { + pub(crate) fn get_native_ref(&self) -> &'static nativeNodeFeatures { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeNodeFeatures { + 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 nativeNodeFeatures { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} + +use lightning_types::features::ChannelFeatures as nativeChannelFeaturesImport; +pub(crate) type nativeChannelFeatures = nativeChannelFeaturesImport; + +/// Features used within a `channel_announcement` message. +#[must_use] +#[repr(C)] +pub struct ChannelFeatures { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, 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 nativeChannelFeatures, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust 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 core::ops::Deref for ChannelFeatures { + type Target = nativeChannelFeatures; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ChannelFeatures { } +unsafe impl core::marker::Sync for ChannelFeatures { } +impl Drop for ChannelFeatures { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeChannelFeatures>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the ChannelFeatures, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn ChannelFeatures_free(this_obj: ChannelFeatures) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn ChannelFeatures_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelFeatures) }; +} +#[allow(unused)] +impl ChannelFeatures { + pub(crate) fn get_native_ref(&self) -> &'static nativeChannelFeatures { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelFeatures { + 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 nativeChannelFeatures { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} + +use lightning_types::features::Bolt11InvoiceFeatures as nativeBolt11InvoiceFeaturesImport; +pub(crate) type nativeBolt11InvoiceFeatures = nativeBolt11InvoiceFeaturesImport; + +/// Features used within an invoice. +#[must_use] +#[repr(C)] +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 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 + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for Bolt11InvoiceFeatures { + type Target = nativeBolt11InvoiceFeatures; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for Bolt11InvoiceFeatures { } +unsafe impl core::marker::Sync for Bolt11InvoiceFeatures { } +impl Drop for Bolt11InvoiceFeatures { + fn drop(&mut self) { + 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 Bolt11InvoiceFeatures, if is_owned is set and inner is non-NULL. +#[no_mangle] +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 Bolt11InvoiceFeatures_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeBolt11InvoiceFeatures) }; +} +#[allow(unused)] +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 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 nativeBolt11InvoiceFeatures { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} + +use lightning_types::features::OfferFeatures as nativeOfferFeaturesImport; +pub(crate) type nativeOfferFeatures = nativeOfferFeaturesImport; + +/// Features used within an `offer`. +#[must_use] +#[repr(C)] +pub struct OfferFeatures { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, 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 nativeOfferFeatures, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust 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 core::ops::Deref for OfferFeatures { + type Target = nativeOfferFeatures; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for OfferFeatures { } +unsafe impl core::marker::Sync for OfferFeatures { } +impl Drop for OfferFeatures { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeOfferFeatures>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the OfferFeatures, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn OfferFeatures_free(this_obj: OfferFeatures) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn OfferFeatures_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeOfferFeatures) }; +} +#[allow(unused)] +impl OfferFeatures { + pub(crate) fn get_native_ref(&self) -> &'static nativeOfferFeatures { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOfferFeatures { + 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 nativeOfferFeatures { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} + +use lightning_types::features::InvoiceRequestFeatures as nativeInvoiceRequestFeaturesImport; +pub(crate) type nativeInvoiceRequestFeatures = nativeInvoiceRequestFeaturesImport; + +/// Features used within an `invoice_request`. +#[must_use] +#[repr(C)] +pub struct InvoiceRequestFeatures { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, 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 nativeInvoiceRequestFeatures, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust 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 core::ops::Deref for InvoiceRequestFeatures { + type Target = nativeInvoiceRequestFeatures; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for InvoiceRequestFeatures { } +unsafe impl core::marker::Sync for InvoiceRequestFeatures { } +impl Drop for InvoiceRequestFeatures { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeInvoiceRequestFeatures>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the InvoiceRequestFeatures, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn InvoiceRequestFeatures_free(this_obj: InvoiceRequestFeatures) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn InvoiceRequestFeatures_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeInvoiceRequestFeatures) }; +} +#[allow(unused)] +impl InvoiceRequestFeatures { + pub(crate) fn get_native_ref(&self) -> &'static nativeInvoiceRequestFeatures { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInvoiceRequestFeatures { + 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 nativeInvoiceRequestFeatures { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} + +use lightning_types::features::Bolt12InvoiceFeatures as nativeBolt12InvoiceFeaturesImport; +pub(crate) type nativeBolt12InvoiceFeatures = nativeBolt12InvoiceFeaturesImport; + +/// Features used within an `invoice`. +#[must_use] +#[repr(C)] +pub struct Bolt12InvoiceFeatures { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, 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 nativeBolt12InvoiceFeatures, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust 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 core::ops::Deref for Bolt12InvoiceFeatures { + type Target = nativeBolt12InvoiceFeatures; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for Bolt12InvoiceFeatures { } +unsafe impl core::marker::Sync for Bolt12InvoiceFeatures { } +impl Drop for Bolt12InvoiceFeatures { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeBolt12InvoiceFeatures>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the Bolt12InvoiceFeatures, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn Bolt12InvoiceFeatures_free(this_obj: Bolt12InvoiceFeatures) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn Bolt12InvoiceFeatures_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeBolt12InvoiceFeatures) }; +} +#[allow(unused)] +impl Bolt12InvoiceFeatures { + pub(crate) fn get_native_ref(&self) -> &'static nativeBolt12InvoiceFeatures { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeBolt12InvoiceFeatures { + 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 nativeBolt12InvoiceFeatures { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} + +use lightning_types::features::BlindedHopFeatures as nativeBlindedHopFeaturesImport; +pub(crate) type nativeBlindedHopFeatures = nativeBlindedHopFeaturesImport; + +/// Features used within BOLT 4 encrypted_data_tlv and BOLT 12 blinded_payinfo +#[must_use] +#[repr(C)] +pub struct BlindedHopFeatures { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, 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 nativeBlindedHopFeatures, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust 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 core::ops::Deref for BlindedHopFeatures { + type Target = nativeBlindedHopFeatures; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for BlindedHopFeatures { } +unsafe impl core::marker::Sync for BlindedHopFeatures { } +impl Drop for BlindedHopFeatures { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeBlindedHopFeatures>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the BlindedHopFeatures, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn BlindedHopFeatures_free(this_obj: BlindedHopFeatures) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn BlindedHopFeatures_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeBlindedHopFeatures) }; +} +#[allow(unused)] +impl BlindedHopFeatures { + pub(crate) fn get_native_ref(&self) -> &'static nativeBlindedHopFeatures { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeBlindedHopFeatures { + 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 nativeBlindedHopFeatures { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} + +use lightning_types::features::ChannelTypeFeatures as nativeChannelTypeFeaturesImport; +pub(crate) type nativeChannelTypeFeatures = nativeChannelTypeFeaturesImport; + +/// Features used within the channel_type field in an OpenChannel message. +/// +/// A channel is always of some known \"type\", describing the transaction formats used and the exact +/// semantics of our interaction with our peer. +/// +/// Note that because a channel is a specific type which is proposed by the opener and accepted by +/// the counterparty, only required features are allowed here. +/// +/// This is serialized differently from other feature types - it is not prefixed by a length, and +/// thus must only appear inside a TLV where its length is known in advance. +#[must_use] +#[repr(C)] +pub struct ChannelTypeFeatures { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, 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 nativeChannelTypeFeatures, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust 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 core::ops::Deref for ChannelTypeFeatures { + type Target = nativeChannelTypeFeatures; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ChannelTypeFeatures { } +unsafe impl core::marker::Sync for ChannelTypeFeatures { } +impl Drop for ChannelTypeFeatures { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeChannelTypeFeatures>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the ChannelTypeFeatures, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_free(this_obj: ChannelTypeFeatures) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn ChannelTypeFeatures_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelTypeFeatures) }; +} +#[allow(unused)] +impl ChannelTypeFeatures { + pub(crate) fn get_native_ref(&self) -> &'static nativeChannelTypeFeatures { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelTypeFeatures { + 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 nativeChannelTypeFeatures { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// Getting a route for a keysend payment to a private node requires providing the payee's +/// features (since they were not announced in a node announcement). However, keysend payments +/// don't have an invoice to pull the payee's features from, so this method is provided for use +/// when a [`Bolt11InvoiceFeatures`] is required in a route. +/// +/// MPP keysend is not widely supported yet, so we parameterize support to allow the user to +/// choose whether their router should find multi-part routes. +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_for_keysend(mut allow_mpp: bool) -> crate::lightning_types::features::Bolt11InvoiceFeatures { + let mut ret = lightning_types::features::Bolt11InvoiceFeatures::for_keysend(allow_mpp); + crate::lightning_types::features::Bolt11InvoiceFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Constructs a ChannelTypeFeatures with only static_remotekey set +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_only_static_remote_key() -> crate::lightning_types::features::ChannelTypeFeatures { + let mut ret = lightning_types::features::ChannelTypeFeatures::only_static_remote_key(); + crate::lightning_types::features::ChannelTypeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Constructs a ChannelTypeFeatures with anchors support +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_anchors_zero_htlc_fee_and_dependencies() -> crate::lightning_types::features::ChannelTypeFeatures { + let mut ret = lightning_types::features::ChannelTypeFeatures::anchors_zero_htlc_fee_and_dependencies(); + crate::lightning_types::features::ChannelTypeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Create a blank Features with no features set +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_empty() -> crate::lightning_types::features::InitFeatures { + let mut ret = lightning_types::features::InitFeatures::empty(); + crate::lightning_types::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Returns the feature set as a list of bytes, in little-endian. This is in reverse byte order +/// from most on-the-wire encodings. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_le_flags(this_arg: &crate::lightning_types::features::InitFeatures) -> crate::c_types::u8slice { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.le_flags(); + let mut local_ret = crate::c_types::u8slice::from_slice(ret); + local_ret +} + +/// Returns true if this `Features` has any optional flags set +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_supports_any_optional_bits(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_any_optional_bits(); + ret +} + +/// 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_types::features::InitFeatures, other: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits_from(other.get_native_ref()); + ret +} + +/// Returns the set of required features unknown by `other`, as their bit position. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_required_unknown_bits_from(this_arg: &crate::lightning_types::features::InitFeatures, other: &crate::lightning_types::features::InitFeatures) -> crate::c_types::derived::CVec_u64Z { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.required_unknown_bits_from(other.get_native_ref()); + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { item }); }; + local_ret.into() +} + +/// Returns true if this `Features` object contains unknown feature flags which are set as +/// \"required\". +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_requires_unknown_bits(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits(); + ret +} + +/// Returns true if this `Features` supports any bits which we do not know of +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_supports_unknown_bits(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_unknown_bits(); + ret +} + +/// Sets a required feature bit. Errors if `bit` is outside the feature range as defined +/// by [BOLT 9]. +/// +/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will +/// be set instead (i.e., `bit - 1`). +/// +/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_set_required_feature_bit(this_arg: &mut crate::lightning_types::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_types::features::nativeInitFeatures)) }.set_required_feature_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 feature bit. Errors if `bit` is outside the feature range as defined +/// by [BOLT 9]. +/// +/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be +/// set instead (i.e., `bit + 1`). +/// +/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_set_optional_feature_bit(this_arg: &mut crate::lightning_types::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_types::features::nativeInitFeatures)) }.set_optional_feature_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 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_types::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_types::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_types::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_types::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] +pub extern "C" fn NodeFeatures_empty() -> crate::lightning_types::features::NodeFeatures { + let mut ret = lightning_types::features::NodeFeatures::empty(); + crate::lightning_types::features::NodeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Returns the feature set as a list of bytes, in little-endian. This is in reverse byte order +/// from most on-the-wire encodings. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_le_flags(this_arg: &crate::lightning_types::features::NodeFeatures) -> crate::c_types::u8slice { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.le_flags(); + let mut local_ret = crate::c_types::u8slice::from_slice(ret); + local_ret +} + +/// Returns true if this `Features` has any optional flags set +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_supports_any_optional_bits(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_any_optional_bits(); + ret +} + +/// 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_types::features::NodeFeatures, other: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits_from(other.get_native_ref()); + ret +} + +/// Returns the set of required features unknown by `other`, as their bit position. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_required_unknown_bits_from(this_arg: &crate::lightning_types::features::NodeFeatures, other: &crate::lightning_types::features::NodeFeatures) -> crate::c_types::derived::CVec_u64Z { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.required_unknown_bits_from(other.get_native_ref()); + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { item }); }; + local_ret.into() +} + +/// Returns true if this `Features` object contains unknown feature flags which are set as +/// \"required\". +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_requires_unknown_bits(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits(); + ret +} + +/// Returns true if this `Features` supports any bits which we do not know of +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_supports_unknown_bits(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_unknown_bits(); + ret +} + +/// Sets a required feature bit. Errors if `bit` is outside the feature range as defined +/// by [BOLT 9]. +/// +/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will +/// be set instead (i.e., `bit - 1`). +/// +/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_set_required_feature_bit(this_arg: &mut crate::lightning_types::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_types::features::nativeNodeFeatures)) }.set_required_feature_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 feature bit. Errors if `bit` is outside the feature range as defined +/// by [BOLT 9]. +/// +/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be +/// set instead (i.e., `bit + 1`). +/// +/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_set_optional_feature_bit(this_arg: &mut crate::lightning_types::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_types::features::nativeNodeFeatures)) }.set_optional_feature_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 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_types::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_types::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_types::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_types::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] +pub extern "C" fn ChannelFeatures_empty() -> crate::lightning_types::features::ChannelFeatures { + let mut ret = lightning_types::features::ChannelFeatures::empty(); + crate::lightning_types::features::ChannelFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Returns the feature set as a list of bytes, in little-endian. This is in reverse byte order +/// from most on-the-wire encodings. +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelFeatures_le_flags(this_arg: &crate::lightning_types::features::ChannelFeatures) -> crate::c_types::u8slice { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.le_flags(); + let mut local_ret = crate::c_types::u8slice::from_slice(ret); + local_ret +} + +/// Returns true if this `Features` has any optional flags set +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelFeatures_supports_any_optional_bits(this_arg: &crate::lightning_types::features::ChannelFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_any_optional_bits(); + ret +} + +/// 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_types::features::ChannelFeatures, other: &crate::lightning_types::features::ChannelFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits_from(other.get_native_ref()); + ret +} + +/// Returns the set of required features unknown by `other`, as their bit position. +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelFeatures_required_unknown_bits_from(this_arg: &crate::lightning_types::features::ChannelFeatures, other: &crate::lightning_types::features::ChannelFeatures) -> crate::c_types::derived::CVec_u64Z { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.required_unknown_bits_from(other.get_native_ref()); + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { item }); }; + local_ret.into() +} + +/// Returns true if this `Features` object contains unknown feature flags which are set as +/// \"required\". +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelFeatures_requires_unknown_bits(this_arg: &crate::lightning_types::features::ChannelFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits(); + ret +} + +/// Returns true if this `Features` supports any bits which we do not know of +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelFeatures_supports_unknown_bits(this_arg: &crate::lightning_types::features::ChannelFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_unknown_bits(); + ret +} + +/// Sets a required feature bit. Errors if `bit` is outside the feature range as defined +/// by [BOLT 9]. +/// +/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will +/// be set instead (i.e., `bit - 1`). +/// +/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelFeatures_set_required_feature_bit(this_arg: &mut crate::lightning_types::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_types::features::nativeChannelFeatures)) }.set_required_feature_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 feature bit. Errors if `bit` is outside the feature range as defined +/// by [BOLT 9]. +/// +/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be +/// set instead (i.e., `bit + 1`). +/// +/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelFeatures_set_optional_feature_bit(this_arg: &mut crate::lightning_types::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_types::features::nativeChannelFeatures)) }.set_optional_feature_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 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_types::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_types::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_types::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_types::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 Bolt11InvoiceFeatures_empty() -> crate::lightning_types::features::Bolt11InvoiceFeatures { + let mut ret = lightning_types::features::Bolt11InvoiceFeatures::empty(); + crate::lightning_types::features::Bolt11InvoiceFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Returns the feature set as a list of bytes, in little-endian. This is in reverse byte order +/// from most on-the-wire encodings. +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_le_flags(this_arg: &crate::lightning_types::features::Bolt11InvoiceFeatures) -> crate::c_types::u8slice { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.le_flags(); + let mut local_ret = crate::c_types::u8slice::from_slice(ret); + local_ret +} + +/// Returns true if this `Features` has any optional flags set +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_supports_any_optional_bits(this_arg: &crate::lightning_types::features::Bolt11InvoiceFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_any_optional_bits(); + ret +} + +/// 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_types::features::Bolt11InvoiceFeatures, other: &crate::lightning_types::features::Bolt11InvoiceFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits_from(other.get_native_ref()); + ret +} + +/// Returns the set of required features unknown by `other`, as their bit position. +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_required_unknown_bits_from(this_arg: &crate::lightning_types::features::Bolt11InvoiceFeatures, other: &crate::lightning_types::features::Bolt11InvoiceFeatures) -> crate::c_types::derived::CVec_u64Z { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.required_unknown_bits_from(other.get_native_ref()); + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { item }); }; + local_ret.into() +} + +/// Returns true if this `Features` object contains unknown feature flags which are set as +/// \"required\". +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_requires_unknown_bits(this_arg: &crate::lightning_types::features::Bolt11InvoiceFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits(); + ret +} + +/// Returns true if this `Features` supports any bits which we do not know of +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_supports_unknown_bits(this_arg: &crate::lightning_types::features::Bolt11InvoiceFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_unknown_bits(); + ret +} + +/// Sets a required feature bit. Errors if `bit` is outside the feature range as defined +/// by [BOLT 9]. +/// +/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will +/// be set instead (i.e., `bit - 1`). +/// +/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_set_required_feature_bit(this_arg: &mut crate::lightning_types::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_types::features::nativeBolt11InvoiceFeatures)) }.set_required_feature_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 feature bit. Errors if `bit` is outside the feature range as defined +/// by [BOLT 9]. +/// +/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be +/// set instead (i.e., `bit + 1`). +/// +/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_set_optional_feature_bit(this_arg: &mut crate::lightning_types::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_types::features::nativeBolt11InvoiceFeatures)) }.set_optional_feature_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 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_types::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_types::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_types::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_types::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] +pub extern "C" fn OfferFeatures_empty() -> crate::lightning_types::features::OfferFeatures { + let mut ret = lightning_types::features::OfferFeatures::empty(); + crate::lightning_types::features::OfferFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Returns the feature set as a list of bytes, in little-endian. This is in reverse byte order +/// from most on-the-wire encodings. +#[must_use] +#[no_mangle] +pub extern "C" fn OfferFeatures_le_flags(this_arg: &crate::lightning_types::features::OfferFeatures) -> crate::c_types::u8slice { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.le_flags(); + let mut local_ret = crate::c_types::u8slice::from_slice(ret); + local_ret +} + +/// Returns true if this `Features` has any optional flags set +#[must_use] +#[no_mangle] +pub extern "C" fn OfferFeatures_supports_any_optional_bits(this_arg: &crate::lightning_types::features::OfferFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_any_optional_bits(); + ret +} + +/// 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_types::features::OfferFeatures, other: &crate::lightning_types::features::OfferFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits_from(other.get_native_ref()); + ret +} + +/// Returns the set of required features unknown by `other`, as their bit position. +#[must_use] +#[no_mangle] +pub extern "C" fn OfferFeatures_required_unknown_bits_from(this_arg: &crate::lightning_types::features::OfferFeatures, other: &crate::lightning_types::features::OfferFeatures) -> crate::c_types::derived::CVec_u64Z { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.required_unknown_bits_from(other.get_native_ref()); + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { item }); }; + local_ret.into() +} + +/// Returns true if this `Features` object contains unknown feature flags which are set as +/// \"required\". +#[must_use] +#[no_mangle] +pub extern "C" fn OfferFeatures_requires_unknown_bits(this_arg: &crate::lightning_types::features::OfferFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits(); + ret +} + +/// Returns true if this `Features` supports any bits which we do not know of +#[must_use] +#[no_mangle] +pub extern "C" fn OfferFeatures_supports_unknown_bits(this_arg: &crate::lightning_types::features::OfferFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_unknown_bits(); + ret +} + +/// Sets a required feature bit. Errors if `bit` is outside the feature range as defined +/// by [BOLT 9]. +/// +/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will +/// be set instead (i.e., `bit - 1`). +/// +/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md +#[must_use] +#[no_mangle] +pub extern "C" fn OfferFeatures_set_required_feature_bit(this_arg: &mut crate::lightning_types::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_types::features::nativeOfferFeatures)) }.set_required_feature_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 feature bit. Errors if `bit` is outside the feature range as defined +/// by [BOLT 9]. +/// +/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be +/// set instead (i.e., `bit + 1`). +/// +/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md +#[must_use] +#[no_mangle] +pub extern "C" fn OfferFeatures_set_optional_feature_bit(this_arg: &mut crate::lightning_types::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_types::features::nativeOfferFeatures)) }.set_optional_feature_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 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_types::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_types::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_types::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_types::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] +pub extern "C" fn InvoiceRequestFeatures_empty() -> crate::lightning_types::features::InvoiceRequestFeatures { + let mut ret = lightning_types::features::InvoiceRequestFeatures::empty(); + crate::lightning_types::features::InvoiceRequestFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Returns the feature set as a list of bytes, in little-endian. This is in reverse byte order +/// from most on-the-wire encodings. +#[must_use] +#[no_mangle] +pub extern "C" fn InvoiceRequestFeatures_le_flags(this_arg: &crate::lightning_types::features::InvoiceRequestFeatures) -> crate::c_types::u8slice { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.le_flags(); + let mut local_ret = crate::c_types::u8slice::from_slice(ret); + local_ret +} + +/// Returns true if this `Features` has any optional flags set +#[must_use] +#[no_mangle] +pub extern "C" fn InvoiceRequestFeatures_supports_any_optional_bits(this_arg: &crate::lightning_types::features::InvoiceRequestFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_any_optional_bits(); + ret +} + +/// 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_types::features::InvoiceRequestFeatures, other: &crate::lightning_types::features::InvoiceRequestFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits_from(other.get_native_ref()); + ret +} + +/// Returns the set of required features unknown by `other`, as their bit position. +#[must_use] +#[no_mangle] +pub extern "C" fn InvoiceRequestFeatures_required_unknown_bits_from(this_arg: &crate::lightning_types::features::InvoiceRequestFeatures, other: &crate::lightning_types::features::InvoiceRequestFeatures) -> crate::c_types::derived::CVec_u64Z { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.required_unknown_bits_from(other.get_native_ref()); + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { item }); }; + local_ret.into() +} + +/// Returns true if this `Features` object contains unknown feature flags which are set as +/// \"required\". +#[must_use] +#[no_mangle] +pub extern "C" fn InvoiceRequestFeatures_requires_unknown_bits(this_arg: &crate::lightning_types::features::InvoiceRequestFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits(); + ret +} + +/// Returns true if this `Features` supports any bits which we do not know of +#[must_use] +#[no_mangle] +pub extern "C" fn InvoiceRequestFeatures_supports_unknown_bits(this_arg: &crate::lightning_types::features::InvoiceRequestFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_unknown_bits(); + ret +} + +/// Sets a required feature bit. Errors if `bit` is outside the feature range as defined +/// by [BOLT 9]. +/// +/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will +/// be set instead (i.e., `bit - 1`). +/// +/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md +#[must_use] +#[no_mangle] +pub extern "C" fn InvoiceRequestFeatures_set_required_feature_bit(this_arg: &mut crate::lightning_types::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_types::features::nativeInvoiceRequestFeatures)) }.set_required_feature_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 feature bit. Errors if `bit` is outside the feature range as defined +/// by [BOLT 9]. +/// +/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be +/// set instead (i.e., `bit + 1`). +/// +/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md +#[must_use] +#[no_mangle] +pub extern "C" fn InvoiceRequestFeatures_set_optional_feature_bit(this_arg: &mut crate::lightning_types::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_types::features::nativeInvoiceRequestFeatures)) }.set_optional_feature_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 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_types::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_types::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_types::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_types::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] +pub extern "C" fn Bolt12InvoiceFeatures_empty() -> crate::lightning_types::features::Bolt12InvoiceFeatures { + let mut ret = lightning_types::features::Bolt12InvoiceFeatures::empty(); + crate::lightning_types::features::Bolt12InvoiceFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Returns the feature set as a list of bytes, in little-endian. This is in reverse byte order +/// from most on-the-wire encodings. +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt12InvoiceFeatures_le_flags(this_arg: &crate::lightning_types::features::Bolt12InvoiceFeatures) -> crate::c_types::u8slice { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.le_flags(); + let mut local_ret = crate::c_types::u8slice::from_slice(ret); + local_ret +} + +/// Returns true if this `Features` has any optional flags set +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt12InvoiceFeatures_supports_any_optional_bits(this_arg: &crate::lightning_types::features::Bolt12InvoiceFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_any_optional_bits(); + ret +} + +/// 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_types::features::Bolt12InvoiceFeatures, other: &crate::lightning_types::features::Bolt12InvoiceFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits_from(other.get_native_ref()); + ret +} + +/// Returns the set of required features unknown by `other`, as their bit position. +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt12InvoiceFeatures_required_unknown_bits_from(this_arg: &crate::lightning_types::features::Bolt12InvoiceFeatures, other: &crate::lightning_types::features::Bolt12InvoiceFeatures) -> crate::c_types::derived::CVec_u64Z { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.required_unknown_bits_from(other.get_native_ref()); + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { item }); }; + local_ret.into() +} + +/// Returns true if this `Features` object contains unknown feature flags which are set as +/// \"required\". +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt12InvoiceFeatures_requires_unknown_bits(this_arg: &crate::lightning_types::features::Bolt12InvoiceFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits(); + ret +} + +/// Returns true if this `Features` supports any bits which we do not know of +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt12InvoiceFeatures_supports_unknown_bits(this_arg: &crate::lightning_types::features::Bolt12InvoiceFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_unknown_bits(); + ret +} + +/// Sets a required feature bit. Errors if `bit` is outside the feature range as defined +/// by [BOLT 9]. +/// +/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will +/// be set instead (i.e., `bit - 1`). +/// +/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt12InvoiceFeatures_set_required_feature_bit(this_arg: &mut crate::lightning_types::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_types::features::nativeBolt12InvoiceFeatures)) }.set_required_feature_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 feature bit. Errors if `bit` is outside the feature range as defined +/// by [BOLT 9]. +/// +/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be +/// set instead (i.e., `bit + 1`). +/// +/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt12InvoiceFeatures_set_optional_feature_bit(this_arg: &mut crate::lightning_types::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_types::features::nativeBolt12InvoiceFeatures)) }.set_optional_feature_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 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_types::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_types::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_types::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_types::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] +pub extern "C" fn BlindedHopFeatures_empty() -> crate::lightning_types::features::BlindedHopFeatures { + let mut ret = lightning_types::features::BlindedHopFeatures::empty(); + crate::lightning_types::features::BlindedHopFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Returns the feature set as a list of bytes, in little-endian. This is in reverse byte order +/// from most on-the-wire encodings. +#[must_use] +#[no_mangle] +pub extern "C" fn BlindedHopFeatures_le_flags(this_arg: &crate::lightning_types::features::BlindedHopFeatures) -> crate::c_types::u8slice { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.le_flags(); + let mut local_ret = crate::c_types::u8slice::from_slice(ret); + local_ret +} + +/// Returns true if this `Features` has any optional flags set +#[must_use] +#[no_mangle] +pub extern "C" fn BlindedHopFeatures_supports_any_optional_bits(this_arg: &crate::lightning_types::features::BlindedHopFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_any_optional_bits(); + ret +} + +/// 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_types::features::BlindedHopFeatures, other: &crate::lightning_types::features::BlindedHopFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits_from(other.get_native_ref()); + ret +} + +/// Returns the set of required features unknown by `other`, as their bit position. +#[must_use] +#[no_mangle] +pub extern "C" fn BlindedHopFeatures_required_unknown_bits_from(this_arg: &crate::lightning_types::features::BlindedHopFeatures, other: &crate::lightning_types::features::BlindedHopFeatures) -> crate::c_types::derived::CVec_u64Z { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.required_unknown_bits_from(other.get_native_ref()); + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { item }); }; + local_ret.into() +} + +/// Returns true if this `Features` object contains unknown feature flags which are set as +/// \"required\". +#[must_use] +#[no_mangle] +pub extern "C" fn BlindedHopFeatures_requires_unknown_bits(this_arg: &crate::lightning_types::features::BlindedHopFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits(); + ret +} + +/// Returns true if this `Features` supports any bits which we do not know of +#[must_use] +#[no_mangle] +pub extern "C" fn BlindedHopFeatures_supports_unknown_bits(this_arg: &crate::lightning_types::features::BlindedHopFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_unknown_bits(); + ret +} + +/// Sets a required feature bit. Errors if `bit` is outside the feature range as defined +/// by [BOLT 9]. +/// +/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will +/// be set instead (i.e., `bit - 1`). +/// +/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md +#[must_use] +#[no_mangle] +pub extern "C" fn BlindedHopFeatures_set_required_feature_bit(this_arg: &mut crate::lightning_types::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_types::features::nativeBlindedHopFeatures)) }.set_required_feature_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 feature bit. Errors if `bit` is outside the feature range as defined +/// by [BOLT 9]. +/// +/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be +/// set instead (i.e., `bit + 1`). +/// +/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md +#[must_use] +#[no_mangle] +pub extern "C" fn BlindedHopFeatures_set_optional_feature_bit(this_arg: &mut crate::lightning_types::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_types::features::nativeBlindedHopFeatures)) }.set_optional_feature_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 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_types::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_types::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_types::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_types::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] +pub extern "C" fn ChannelTypeFeatures_empty() -> crate::lightning_types::features::ChannelTypeFeatures { + let mut ret = lightning_types::features::ChannelTypeFeatures::empty(); + crate::lightning_types::features::ChannelTypeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Returns the feature set as a list of bytes, in little-endian. This is in reverse byte order +/// from most on-the-wire encodings. +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_le_flags(this_arg: &crate::lightning_types::features::ChannelTypeFeatures) -> crate::c_types::u8slice { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.le_flags(); + let mut local_ret = crate::c_types::u8slice::from_slice(ret); + local_ret +} + +/// Returns true if this `Features` has any optional flags set +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_supports_any_optional_bits(this_arg: &crate::lightning_types::features::ChannelTypeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_any_optional_bits(); + ret +} + +/// 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_types::features::ChannelTypeFeatures, other: &crate::lightning_types::features::ChannelTypeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits_from(other.get_native_ref()); + ret +} + +/// Returns the set of required features unknown by `other`, as their bit position. +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_required_unknown_bits_from(this_arg: &crate::lightning_types::features::ChannelTypeFeatures, other: &crate::lightning_types::features::ChannelTypeFeatures) -> crate::c_types::derived::CVec_u64Z { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.required_unknown_bits_from(other.get_native_ref()); + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { item }); }; + local_ret.into() +} + +/// Returns true if this `Features` object contains unknown feature flags which are set as +/// \"required\". +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_requires_unknown_bits(this_arg: &crate::lightning_types::features::ChannelTypeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits(); + ret +} + +/// Returns true if this `Features` supports any bits which we do not know of +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_supports_unknown_bits(this_arg: &crate::lightning_types::features::ChannelTypeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_unknown_bits(); + ret +} + +/// Sets a required feature bit. Errors if `bit` is outside the feature range as defined +/// by [BOLT 9]. +/// +/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will +/// be set instead (i.e., `bit - 1`). +/// +/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_set_required_feature_bit(this_arg: &mut crate::lightning_types::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_types::features::nativeChannelTypeFeatures)) }.set_required_feature_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 feature bit. Errors if `bit` is outside the feature range as defined +/// by [BOLT 9]. +/// +/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be +/// set instead (i.e., `bit + 1`). +/// +/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_set_optional_feature_bit(this_arg: &mut crate::lightning_types::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_types::features::nativeChannelTypeFeatures)) }.set_optional_feature_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 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_types::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_types::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_types::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_types::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 +} + +/// Unsets the `upfront_shutdown_script` feature +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_clear_upfront_shutdown_script(mut this_arg: crate::lightning_types::features::InitFeatures) -> crate::lightning_types::features::InitFeatures { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).clear_upfront_shutdown_script(); + crate::lightning_types::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Unsets the `upfront_shutdown_script` feature +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_clear_upfront_shutdown_script(mut this_arg: crate::lightning_types::features::NodeFeatures) -> crate::lightning_types::features::NodeFeatures { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).clear_upfront_shutdown_script(); + crate::lightning_types::features::NodeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Unsets the `shutdown_anysegwit` feature +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_clear_shutdown_anysegwit(mut this_arg: crate::lightning_types::features::InitFeatures) -> crate::lightning_types::features::InitFeatures { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).clear_shutdown_anysegwit(); + crate::lightning_types::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Unsets the `shutdown_anysegwit` feature +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_clear_shutdown_anysegwit(mut this_arg: crate::lightning_types::features::NodeFeatures) -> crate::lightning_types::features::NodeFeatures { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).clear_shutdown_anysegwit(); + crate::lightning_types::features::NodeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Unsets the `wumbo` feature +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_clear_wumbo(mut this_arg: crate::lightning_types::features::InitFeatures) -> crate::lightning_types::features::InitFeatures { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).clear_wumbo(); + crate::lightning_types::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Unsets the `wumbo` feature +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_clear_wumbo(mut this_arg: crate::lightning_types::features::NodeFeatures) -> crate::lightning_types::features::NodeFeatures { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).clear_wumbo(); + crate::lightning_types::features::NodeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Unsets the `scid_privacy` feature +#[no_mangle] +pub extern "C" fn InitFeatures_clear_scid_privacy(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.clear_scid_privacy() +} + +/// Unsets the `scid_privacy` feature +#[no_mangle] +pub extern "C" fn NodeFeatures_clear_scid_privacy(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.clear_scid_privacy() +} + +/// Unsets the `scid_privacy` feature +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_clear_scid_privacy(this_arg: &mut crate::lightning_types::features::ChannelTypeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeChannelTypeFeatures)) }.clear_scid_privacy() +} + +/// Unsets the `anchors_zero_fee_htlc_tx` feature +#[no_mangle] +pub extern "C" fn InitFeatures_clear_anchors_zero_fee_htlc_tx(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.clear_anchors_zero_fee_htlc_tx() +} + +/// Unsets the `anchors_zero_fee_htlc_tx` feature +#[no_mangle] +pub extern "C" fn NodeFeatures_clear_anchors_zero_fee_htlc_tx(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.clear_anchors_zero_fee_htlc_tx() +} + +/// Unsets the `anchors_zero_fee_htlc_tx` feature +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_clear_anchors_zero_fee_htlc_tx(this_arg: &mut crate::lightning_types::features::ChannelTypeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeChannelTypeFeatures)) }.clear_anchors_zero_fee_htlc_tx() +} + +/// Unsets the `route_blinding` feature +#[no_mangle] +pub extern "C" fn InitFeatures_clear_route_blinding(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.clear_route_blinding() +} + +/// Unsets the `route_blinding` feature +#[no_mangle] +pub extern "C" fn NodeFeatures_clear_route_blinding(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.clear_route_blinding() +} + diff --git a/lightning-c-bindings/src/lightning_types/mod.rs b/lightning-c-bindings/src/lightning_types/mod.rs new file mode 100644 index 0000000..a815433 --- /dev/null +++ b/lightning-c-bindings/src/lightning_types/mod.rs @@ -0,0 +1,26 @@ +// 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. + +//!lightning_types +//! Various types which are used in the lightning network. +//! +//! See the `lightning` crate for usage of these. + +use alloc::str::FromStr; +use alloc::string::String; +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 features; +pub mod payment; +pub mod routing; +pub mod string; diff --git a/lightning-c-bindings/src/lightning_types/payment.rs b/lightning-c-bindings/src/lightning_types/payment.rs new file mode 100644 index 0000000..06d78e5 --- /dev/null +++ b/lightning-c-bindings/src/lightning_types/payment.rs @@ -0,0 +1,19 @@ +// 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. + +//! Types which describe payments in lightning. + +use alloc::str::FromStr; +use alloc::string::String; +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}; + diff --git a/lightning-c-bindings/src/lightning_types/routing.rs b/lightning-c-bindings/src/lightning_types/routing.rs new file mode 100644 index 0000000..a9d86b2 --- /dev/null +++ b/lightning-c-bindings/src/lightning_types/routing.rs @@ -0,0 +1,465 @@ +// 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. + +//! Various types which describe routes or information about partial routes within the lightning +//! network. + +use alloc::str::FromStr; +use alloc::string::String; +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_types::routing::RoutingFees as nativeRoutingFeesImport; +pub(crate) type nativeRoutingFees = nativeRoutingFeesImport; + +/// Fees for routing via a given channel or a node +#[must_use] +#[repr(C)] +pub struct RoutingFees { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, 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 nativeRoutingFees, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust 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 core::ops::Deref for RoutingFees { + type Target = nativeRoutingFees; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for RoutingFees { } +unsafe impl core::marker::Sync for RoutingFees { } +impl Drop for RoutingFees { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeRoutingFees>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the RoutingFees, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn RoutingFees_free(this_obj: RoutingFees) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn RoutingFees_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeRoutingFees) }; +} +#[allow(unused)] +impl RoutingFees { + pub(crate) fn get_native_ref(&self) -> &'static nativeRoutingFees { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeRoutingFees { + 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 nativeRoutingFees { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// Flat routing fee in millisatoshis. +#[no_mangle] +pub extern "C" fn RoutingFees_get_base_msat(this_ptr: &RoutingFees) -> u32 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().base_msat; + *inner_val +} +/// Flat routing fee in millisatoshis. +#[no_mangle] +pub extern "C" fn RoutingFees_set_base_msat(this_ptr: &mut RoutingFees, mut val: u32) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.base_msat = val; +} +/// Liquidity-based routing fee in millionths of a routed amount. +/// In other words, 10000 is 1%. +#[no_mangle] +pub extern "C" fn RoutingFees_get_proportional_millionths(this_ptr: &RoutingFees) -> u32 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().proportional_millionths; + *inner_val +} +/// Liquidity-based routing fee in millionths of a routed amount. +/// In other words, 10000 is 1%. +#[no_mangle] +pub extern "C" fn RoutingFees_set_proportional_millionths(this_ptr: &mut RoutingFees, mut val: u32) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.proportional_millionths = val; +} +/// Constructs a new RoutingFees given each field +#[must_use] +#[no_mangle] +pub extern "C" fn RoutingFees_new(mut base_msat_arg: u32, mut proportional_millionths_arg: u32) -> RoutingFees { + RoutingFees { inner: ObjOps::heap_alloc(nativeRoutingFees { + base_msat: base_msat_arg, + proportional_millionths: proportional_millionths_arg, + }), is_owned: true } +} +/// 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. +#[no_mangle] +pub extern "C" fn RoutingFees_eq(a: &RoutingFees, b: &RoutingFees) -> 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 RoutingFees { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeRoutingFees>::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 RoutingFees_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeRoutingFees)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the RoutingFees +pub extern "C" fn RoutingFees_clone(orig: &RoutingFees) -> RoutingFees { + orig.clone() +} +/// Get a string which allows debug introspection of a RoutingFees object +pub extern "C" fn RoutingFees_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_types::routing::RoutingFees }).into()} +/// Generates a non-cryptographic 64-bit hash of the RoutingFees. +#[no_mangle] +pub extern "C" fn RoutingFees_hash(o: &RoutingFees) -> 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) +} + +use lightning_types::routing::RouteHint as nativeRouteHintImport; +pub(crate) type nativeRouteHint = nativeRouteHintImport; + +/// A list of hops along a payment path terminating with a channel to the recipient. +#[must_use] +#[repr(C)] +pub struct RouteHint { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, 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 nativeRouteHint, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust 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 core::ops::Deref for RouteHint { + type Target = nativeRouteHint; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for RouteHint { } +unsafe impl core::marker::Sync for RouteHint { } +impl Drop for RouteHint { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeRouteHint>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the RouteHint, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn RouteHint_free(this_obj: RouteHint) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn RouteHint_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeRouteHint) }; +} +#[allow(unused)] +impl RouteHint { + pub(crate) fn get_native_ref(&self) -> &'static nativeRouteHint { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeRouteHint { + 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 nativeRouteHint { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +#[no_mangle] +pub extern "C" fn RouteHint_get_a(this_ptr: &RouteHint) -> crate::c_types::derived::CVec_RouteHintHopZ { + let mut inner_val = &mut this_ptr.get_native_mut_ref().0; + let mut local_inner_val = Vec::new(); for item in inner_val.iter() { local_inner_val.push( { crate::lightning_types::routing::RouteHintHop { inner: unsafe { ObjOps::nonnull_ptr_to_inner((item as *const lightning_types::routing::RouteHintHop<>) as *mut _) }, is_owned: false } }); }; + local_inner_val.into() +} +#[no_mangle] +pub extern "C" fn RouteHint_set_a(this_ptr: &mut RouteHint, mut val: crate::c_types::derived::CVec_RouteHintHopZ) { + 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) }.0 = local_val; +} +/// Constructs a new RouteHint given each field +#[must_use] +#[no_mangle] +pub extern "C" fn RouteHint_new(mut a_arg: crate::c_types::derived::CVec_RouteHintHopZ) -> RouteHint { + let mut local_a_arg = Vec::new(); for mut item in a_arg.into_rust().drain(..) { local_a_arg.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; + RouteHint { inner: ObjOps::heap_alloc(lightning_types::routing::RouteHint ( + local_a_arg, + )), is_owned: true } +} +impl Clone for RouteHint { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeRouteHint>::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 RouteHint_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeRouteHint)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the RouteHint +pub extern "C" fn RouteHint_clone(orig: &RouteHint) -> RouteHint { + orig.clone() +} +/// Get a string which allows debug introspection of a RouteHint object +pub extern "C" fn RouteHint_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_types::routing::RouteHint }).into()} +/// Generates a non-cryptographic 64-bit hash of the RouteHint. +#[no_mangle] +pub extern "C" fn RouteHint_hash(o: &RouteHint) -> 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 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. +#[no_mangle] +pub extern "C" fn RouteHint_eq(a: &RouteHint, b: &RouteHint) -> 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_types::routing::RouteHintHop as nativeRouteHintHopImport; +pub(crate) type nativeRouteHintHop = nativeRouteHintHopImport; + +/// A channel descriptor for a hop along a payment path. +/// +/// While this generally comes from BOLT 11's `r` field, this struct includes more fields than are +/// available in BOLT 11. Thus, encoding and decoding this via `lightning-invoice` is lossy, as +/// fields not supported in BOLT 11 will be stripped. +#[must_use] +#[repr(C)] +pub struct RouteHintHop { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, 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 nativeRouteHintHop, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust 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 core::ops::Deref for RouteHintHop { + type Target = nativeRouteHintHop; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for RouteHintHop { } +unsafe impl core::marker::Sync for RouteHintHop { } +impl Drop for RouteHintHop { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeRouteHintHop>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the RouteHintHop, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn RouteHintHop_free(this_obj: RouteHintHop) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn RouteHintHop_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeRouteHintHop) }; +} +#[allow(unused)] +impl RouteHintHop { + pub(crate) fn get_native_ref(&self) -> &'static nativeRouteHintHop { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeRouteHintHop { + 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 nativeRouteHintHop { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// The node_id of the non-target end of the route +#[no_mangle] +pub extern "C" fn RouteHintHop_get_src_node_id(this_ptr: &RouteHintHop) -> crate::c_types::PublicKey { + let mut inner_val = &mut this_ptr.get_native_mut_ref().src_node_id; + crate::c_types::PublicKey::from_rust(&inner_val) +} +/// The node_id of the non-target end of the route +#[no_mangle] +pub extern "C" fn RouteHintHop_set_src_node_id(this_ptr: &mut RouteHintHop, mut val: crate::c_types::PublicKey) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.src_node_id = val.into_rust(); +} +/// The short_channel_id of this channel +#[no_mangle] +pub extern "C" fn RouteHintHop_get_short_channel_id(this_ptr: &RouteHintHop) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id; + *inner_val +} +/// The short_channel_id of this channel +#[no_mangle] +pub extern "C" fn RouteHintHop_set_short_channel_id(this_ptr: &mut RouteHintHop, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val; +} +/// The fees which must be paid to use this channel +#[no_mangle] +pub extern "C" fn RouteHintHop_get_fees(this_ptr: &RouteHintHop) -> crate::lightning_types::routing::RoutingFees { + let mut inner_val = &mut this_ptr.get_native_mut_ref().fees; + crate::lightning_types::routing::RoutingFees { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning_types::routing::RoutingFees<>) as *mut _) }, is_owned: false } +} +/// The fees which must be paid to use this channel +#[no_mangle] +pub extern "C" fn RouteHintHop_set_fees(this_ptr: &mut RouteHintHop, mut val: crate::lightning_types::routing::RoutingFees) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fees = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// The difference in CLTV values between this node and the next node. +#[no_mangle] +pub extern "C" fn RouteHintHop_get_cltv_expiry_delta(this_ptr: &RouteHintHop) -> u16 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta; + *inner_val +} +/// The difference in CLTV values between this node and the next node. +#[no_mangle] +pub extern "C" fn RouteHintHop_set_cltv_expiry_delta(this_ptr: &mut RouteHintHop, mut val: u16) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val; +} +/// The minimum value, in msat, which must be relayed to the next hop. +#[no_mangle] +pub extern "C" fn RouteHintHop_get_htlc_minimum_msat(this_ptr: &RouteHintHop) -> crate::c_types::derived::COption_u64Z { + let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_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 minimum value, in msat, which must be relayed to the next hop. +#[no_mangle] +pub extern "C" fn RouteHintHop_set_htlc_minimum_msat(this_ptr: &mut RouteHintHop, 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) }.htlc_minimum_msat = local_val; +} +/// The maximum value in msat available for routing with a single HTLC. +#[no_mangle] +pub extern "C" fn RouteHintHop_get_htlc_maximum_msat(this_ptr: &RouteHintHop) -> crate::c_types::derived::COption_u64Z { + let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_maximum_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 maximum value in msat available for routing with a single HTLC. +#[no_mangle] +pub extern "C" fn RouteHintHop_set_htlc_maximum_msat(this_ptr: &mut RouteHintHop, 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) }.htlc_maximum_msat = local_val; +} +/// Constructs a new RouteHintHop given each field +#[must_use] +#[no_mangle] +pub extern "C" fn RouteHintHop_new(mut src_node_id_arg: crate::c_types::PublicKey, mut short_channel_id_arg: u64, mut fees_arg: crate::lightning_types::routing::RoutingFees, mut cltv_expiry_delta_arg: u16, mut htlc_minimum_msat_arg: crate::c_types::derived::COption_u64Z, mut htlc_maximum_msat_arg: crate::c_types::derived::COption_u64Z) -> RouteHintHop { + let mut local_htlc_minimum_msat_arg = if htlc_minimum_msat_arg.is_some() { Some( { htlc_minimum_msat_arg.take() }) } else { None }; + let mut local_htlc_maximum_msat_arg = if htlc_maximum_msat_arg.is_some() { Some( { htlc_maximum_msat_arg.take() }) } else { None }; + RouteHintHop { inner: ObjOps::heap_alloc(nativeRouteHintHop { + src_node_id: src_node_id_arg.into_rust(), + short_channel_id: short_channel_id_arg, + fees: *unsafe { Box::from_raw(fees_arg.take_inner()) }, + cltv_expiry_delta: cltv_expiry_delta_arg, + htlc_minimum_msat: local_htlc_minimum_msat_arg, + htlc_maximum_msat: local_htlc_maximum_msat_arg, + }), is_owned: true } +} +impl Clone for RouteHintHop { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeRouteHintHop>::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 RouteHintHop_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeRouteHintHop)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the RouteHintHop +pub extern "C" fn RouteHintHop_clone(orig: &RouteHintHop) -> RouteHintHop { + orig.clone() +} +/// Get a string which allows debug introspection of a RouteHintHop object +pub extern "C" fn RouteHintHop_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_types::routing::RouteHintHop }).into()} +/// Generates a non-cryptographic 64-bit hash of the RouteHintHop. +#[no_mangle] +pub extern "C" fn RouteHintHop_hash(o: &RouteHintHop) -> 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 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. +#[no_mangle] +pub extern "C" fn RouteHintHop_eq(a: &RouteHintHop, b: &RouteHintHop) -> 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 } +} diff --git a/lightning-c-bindings/src/lightning_types/string.rs b/lightning-c-bindings/src/lightning_types/string.rs new file mode 100644 index 0000000..db3a5fd --- /dev/null +++ b/lightning-c-bindings/src/lightning_types/string.rs @@ -0,0 +1,228 @@ +// 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 strings. + +use alloc::str::FromStr; +use alloc::string::String; +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_types::string::UntrustedString as nativeUntrustedStringImport; +pub(crate) type nativeUntrustedString = nativeUntrustedStringImport; + +/// Struct to `Display` fields in a safe way using `PrintableString` +#[must_use] +#[repr(C)] +pub struct UntrustedString { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, 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 nativeUntrustedString, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust 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 core::ops::Deref for UntrustedString { + type Target = nativeUntrustedString; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for UntrustedString { } +unsafe impl core::marker::Sync for UntrustedString { } +impl Drop for UntrustedString { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeUntrustedString>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the UntrustedString, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn UntrustedString_free(this_obj: UntrustedString) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn UntrustedString_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUntrustedString) }; +} +#[allow(unused)] +impl UntrustedString { + pub(crate) fn get_native_ref(&self) -> &'static nativeUntrustedString { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUntrustedString { + 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 nativeUntrustedString { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +#[no_mangle] +pub extern "C" fn UntrustedString_get_a(this_ptr: &UntrustedString) -> crate::c_types::Str { + let mut inner_val = &mut this_ptr.get_native_mut_ref().0; + inner_val.as_str().into() +} +#[no_mangle] +pub extern "C" fn UntrustedString_set_a(this_ptr: &mut UntrustedString, mut val: crate::c_types::Str) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.0 = val.into_string(); +} +/// Constructs a new UntrustedString given each field +#[must_use] +#[no_mangle] +pub extern "C" fn UntrustedString_new(mut a_arg: crate::c_types::Str) -> UntrustedString { + UntrustedString { inner: ObjOps::heap_alloc(lightning_types::string::UntrustedString ( + a_arg.into_string(), + )), is_owned: true } +} +impl Clone for UntrustedString { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeUntrustedString>::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 UntrustedString_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUntrustedString)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the UntrustedString +pub extern "C" fn UntrustedString_clone(orig: &UntrustedString) -> UntrustedString { + orig.clone() +} +/// Get a string which allows debug introspection of a UntrustedString object +pub extern "C" fn UntrustedString_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_types::string::UntrustedString }).into()} +/// 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. +#[no_mangle] +pub extern "C" fn UntrustedString_eq(a: &UntrustedString, b: &UntrustedString) -> 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 } +} +/// Generates a non-cryptographic 64-bit hash of the UntrustedString. +#[no_mangle] +pub extern "C" fn UntrustedString_hash(o: &UntrustedString) -> 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) +} +#[no_mangle] +/// Get the string representation of a UntrustedString object +pub extern "C" fn UntrustedString_to_str(o: &crate::lightning_types::string::UntrustedString) -> Str { + alloc::format!("{}", o.get_native_ref()).into() +} + +use lightning_types::string::PrintableString as nativePrintableStringImport; +pub(crate) type nativePrintableString = nativePrintableStringImport<'static, >; + +/// A string that displays only printable characters, replacing control characters with +/// [`core::char::REPLACEMENT_CHARACTER`]. +#[must_use] +#[repr(C)] +pub struct PrintableString { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, 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 nativePrintableString, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust 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 core::ops::Deref for PrintableString { + type Target = nativePrintableString; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for PrintableString { } +unsafe impl core::marker::Sync for PrintableString { } +impl Drop for PrintableString { + fn drop(&mut self) { + if self.is_owned && !<*mut nativePrintableString>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the PrintableString, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn PrintableString_free(this_obj: PrintableString) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn PrintableString_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativePrintableString) }; +} +#[allow(unused)] +impl PrintableString { + pub(crate) fn get_native_ref(&self) -> &'static nativePrintableString { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePrintableString { + 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 nativePrintableString { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +#[no_mangle] +pub extern "C" fn PrintableString_get_a(this_ptr: &PrintableString) -> crate::c_types::Str { + let mut inner_val = &mut this_ptr.get_native_mut_ref().0; + inner_val.into() +} +#[no_mangle] +pub extern "C" fn PrintableString_set_a(this_ptr: &mut PrintableString, mut val: crate::c_types::Str) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.0 = val.into_str(); +} +/// Constructs a new PrintableString given each field +#[must_use] +#[no_mangle] +pub extern "C" fn PrintableString_new(mut a_arg: crate::c_types::Str) -> PrintableString { + PrintableString { inner: ObjOps::heap_alloc(lightning_types::string::PrintableString ( + a_arg.into_str(), + )), is_owned: true } +} +/// Get a string which allows debug introspection of a PrintableString object +pub extern "C" fn PrintableString_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_types::string::PrintableString }).into()} +#[no_mangle] +/// Get the string representation of a PrintableString object +pub extern "C" fn PrintableString_to_str(o: &crate::lightning_types::string::PrintableString) -> Str { + alloc::format!("{}", o.get_native_ref()).into() +}