From 82601052fe2cac04a6249f5930495e987923303b Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Wed, 26 Apr 2023 01:03:19 +0000 Subject: [PATCH] Update auto-generated bindings for LDK 0.0.115 --- lightning-c-bindings/include/ldk_rust_types.h | 38 +- lightning-c-bindings/include/lightning.h | 10136 ++++++++++------ lightning-c-bindings/include/lightningpp.hpp | 1361 ++- lightning-c-bindings/src/c_types/derived.rs | 4751 +++++--- .../{onion_message => }/blinded_path.rs | 79 +- .../src/lightning/chain/chaininterface.rs | 2 +- .../src/lightning/chain/chainmonitor.rs | 46 +- .../src/lightning/chain/channelmonitor.rs | 58 +- .../src/lightning/chain/keysinterface.rs | 44 +- .../src/lightning/chain/mod.rs | 2 +- .../src/lightning/chain/transaction.rs | 2 +- .../src/lightning/{util => }/events.rs | 552 +- .../src/lightning/ln/chan_utils.rs | 41 +- .../src/lightning/ln/channelmanager.rs | 239 +- .../src/lightning/ln/features.rs | 43 +- lightning-c-bindings/src/lightning/ln/mod.rs | 14 +- lightning-c-bindings/src/lightning/ln/msgs.rs | 36 +- .../src/lightning/ln/outbound_payment.rs | 247 +- .../src/lightning/ln/peer_handler.rs | 65 +- lightning-c-bindings/src/lightning/ln/wire.rs | 2 +- lightning-c-bindings/src/lightning/mod.rs | 102 +- .../src/lightning/offers/invoice.rs | 353 + .../src/lightning/offers/invoice_request.rs | 266 + .../src/lightning/offers/mod.rs | 59 + .../src/lightning/offers/offer.rs | 439 + .../src/lightning/offers/parse.rs | 29 + .../src/lightning/offers/refund.rs | 285 + .../src/lightning/onion_message/messenger.rs | 26 +- .../src/lightning/onion_message/mod.rs | 14 +- .../src/lightning/routing/gossip.rs | 78 +- .../src/lightning/routing/router.rs | 578 +- .../src/lightning/routing/scoring.rs | 88 +- .../src/lightning/util/config.rs | 42 +- .../src/lightning/util/logger.rs | 2 +- .../src/lightning/util/mod.rs | 1 - .../src/lightning/util/string.rs | 112 + .../src/lightning/util/wakers.rs | 130 + .../src/lightning_background_processor.rs | 10 +- .../src/lightning_invoice/constants.rs | 3 + .../src/lightning_invoice/mod.rs | 172 +- .../src/lightning_invoice/utils.rs | 8 +- .../src/lightning_rapid_gossip_sync/mod.rs | 19 +- 42 files changed, 13410 insertions(+), 7164 deletions(-) rename lightning-c-bindings/src/lightning/{onion_message => }/blinded_path.rs (64%) rename lightning-c-bindings/src/lightning/{util => }/events.rs (84%) create mode 100644 lightning-c-bindings/src/lightning/offers/invoice.rs create mode 100644 lightning-c-bindings/src/lightning/offers/invoice_request.rs create mode 100644 lightning-c-bindings/src/lightning/offers/mod.rs create mode 100644 lightning-c-bindings/src/lightning/offers/offer.rs create mode 100644 lightning-c-bindings/src/lightning/offers/parse.rs create mode 100644 lightning-c-bindings/src/lightning/offers/refund.rs diff --git a/lightning-c-bindings/include/ldk_rust_types.h b/lightning-c-bindings/include/ldk_rust_types.h index 5f546fe..dd6a43c 100644 --- a/lightning-c-bindings/include/ldk_rust_types.h +++ b/lightning-c-bindings/include/ldk_rust_types.h @@ -10,6 +10,10 @@ #else #define NONNULL_PTR #endif +struct nativeRefundOpaque; +typedef struct nativeRefundOpaque LDKnativeRefund; +struct nativeRecipientOnionFieldsOpaque; +typedef struct nativeRecipientOnionFieldsOpaque LDKnativeRecipientOnionFields; struct nativeCounterpartyCommitmentSecretsOpaque; typedef struct nativeCounterpartyCommitmentSecretsOpaque LDKnativeCounterpartyCommitmentSecrets; struct nativeTxCreationKeysOpaque; @@ -40,10 +44,10 @@ struct nativeShutdownScriptOpaque; typedef struct nativeShutdownScriptOpaque LDKnativeShutdownScript; struct nativeInvalidShutdownScriptOpaque; typedef struct nativeInvalidShutdownScriptOpaque LDKnativeInvalidShutdownScript; -struct nativeBlindedPathOpaque; -typedef struct nativeBlindedPathOpaque LDKnativeBlindedPath; -struct nativeBlindedHopOpaque; -typedef struct nativeBlindedHopOpaque LDKnativeBlindedHop; +struct nativeUnsignedInvoiceOpaque; +typedef struct nativeUnsignedInvoiceOpaque LDKnativeUnsignedInvoice; +struct nativeBlindedPayInfoOpaque; +typedef struct nativeBlindedPayInfoOpaque LDKnativeBlindedPayInfo; struct nativeBackgroundProcessorOpaque; typedef struct nativeBackgroundProcessorOpaque LDKnativeBackgroundProcessor; struct nativeDefaultRouterOpaque; @@ -54,6 +58,10 @@ struct nativeInFlightHtlcsOpaque; typedef struct nativeInFlightHtlcsOpaque LDKnativeInFlightHtlcs; struct nativeRouteHopOpaque; typedef struct nativeRouteHopOpaque LDKnativeRouteHop; +struct nativeBlindedTailOpaque; +typedef struct nativeBlindedTailOpaque LDKnativeBlindedTail; +struct nativePathOpaque; +typedef struct nativePathOpaque LDKnativePath; struct nativeRouteOpaque; typedef struct nativeRouteOpaque LDKnativeRoute; struct nativeRouteParametersOpaque; @@ -98,6 +106,12 @@ struct nativeBlindedHopFeaturesOpaque; typedef struct nativeBlindedHopFeaturesOpaque LDKnativeBlindedHopFeatures; struct nativeChannelTypeFeaturesOpaque; typedef struct nativeChannelTypeFeaturesOpaque LDKnativeChannelTypeFeatures; +struct nativeOfferOpaque; +typedef struct nativeOfferOpaque LDKnativeOffer; +struct nativeAmountOpaque; +typedef struct nativeAmountOpaque LDKnativeAmount; +struct nativeQuantityOpaque; +typedef struct nativeQuantityOpaque LDKnativeQuantity; struct nativeNodeIdOpaque; typedef struct nativeNodeIdOpaque LDKnativeNodeId; struct nativeNetworkGraphOpaque; @@ -159,6 +173,8 @@ struct nativeBigSizeOpaque; typedef struct nativeBigSizeOpaque LDKnativeBigSize; struct nativeHostnameOpaque; typedef struct nativeHostnameOpaque LDKnativeHostname; +struct nativeUntrustedStringOpaque; +typedef struct nativeUntrustedStringOpaque LDKnativeUntrustedString; struct nativePrintableStringOpaque; typedef struct nativePrintableStringOpaque LDKnativePrintableString; struct nativeOutPointOpaque; @@ -185,6 +201,10 @@ struct nativeUtxoFutureOpaque; typedef struct nativeUtxoFutureOpaque LDKnativeUtxoFuture; struct nativeOnionMessengerOpaque; typedef struct nativeOnionMessengerOpaque LDKnativeOnionMessenger; +struct nativeBlindedPathOpaque; +typedef struct nativeBlindedPathOpaque LDKnativeBlindedPath; +struct nativeBlindedHopOpaque; +typedef struct nativeBlindedHopOpaque LDKnativeBlindedHop; struct nativeInvoiceOpaque; typedef struct nativeInvoiceOpaque LDKnativeInvoice; struct nativeSignedRawInvoiceOpaque; @@ -209,8 +229,6 @@ struct nativeInvoiceSignatureOpaque; typedef struct nativeInvoiceSignatureOpaque LDKnativeInvoiceSignature; struct nativePrivateRouteOpaque; typedef struct nativePrivateRouteOpaque LDKnativePrivateRoute; -struct nativeRapidGossipSyncOpaque; -typedef struct nativeRapidGossipSyncOpaque LDKnativeRapidGossipSync; struct nativeInitOpaque; typedef struct nativeInitOpaque LDKnativeInit; struct nativeErrorMessageOpaque; @@ -285,13 +303,21 @@ struct nativeLightningErrorOpaque; typedef struct nativeLightningErrorOpaque LDKnativeLightningError; struct nativeCommitmentUpdateOpaque; typedef struct nativeCommitmentUpdateOpaque LDKnativeCommitmentUpdate; +struct nativeUnsignedInvoiceRequestOpaque; +typedef struct nativeUnsignedInvoiceRequestOpaque LDKnativeUnsignedInvoiceRequest; +struct nativeInvoiceRequestOpaque; +typedef struct nativeInvoiceRequestOpaque LDKnativeInvoiceRequest; struct nativeRecordOpaque; typedef struct nativeRecordOpaque LDKnativeRecord; struct nativeFutureOpaque; typedef struct nativeFutureOpaque LDKnativeFuture; +struct nativeSleeperOpaque; +typedef struct nativeSleeperOpaque LDKnativeSleeper; struct nativeMonitorUpdateIdOpaque; typedef struct nativeMonitorUpdateIdOpaque LDKnativeMonitorUpdateId; struct nativeLockedChannelMonitorOpaque; typedef struct nativeLockedChannelMonitorOpaque LDKnativeLockedChannelMonitor; struct nativeChainMonitorOpaque; typedef struct nativeChainMonitorOpaque LDKnativeChainMonitor; +struct nativeRapidGossipSyncOpaque; +typedef struct nativeRapidGossipSyncOpaque LDKnativeRapidGossipSync; diff --git a/lightning-c-bindings/include/lightning.h b/lightning-c-bindings/include/lightning.h index 401ba8d..8afabdc 100644 --- a/lightning-c-bindings/include/lightning.h +++ b/lightning-c-bindings/include/lightning.h @@ -141,11 +141,11 @@ typedef enum LDKConfirmationTarget { } LDKConfirmationTarget; /** - * Errors that may occur when constructing a new `RawInvoice` or `Invoice` + * Errors that may occur when constructing a new [`RawInvoice`] or [`Invoice`] */ typedef enum LDKCreationError { /** - * The supplied description string was longer than 639 __bytes__ (see [`Description::new(…)`](./struct.Description.html#method.new)) + * The supplied description string was longer than 639 __bytes__ (see [`Description::new`]) */ LDKCreationError_DescriptionTooLong, /** @@ -357,6 +357,51 @@ typedef enum LDKNetwork { LDKNetwork_Sentinel, } LDKNetwork; +/** + * The reason the payment failed. Used in [`Event::PaymentFailed`]. + */ +typedef enum LDKPaymentFailureReason { + /** + * The intended recipient rejected our payment. + */ + LDKPaymentFailureReason_RecipientRejected, + /** + * The user chose to abandon this payment by calling [`ChannelManager::abandon_payment`]. + * + * [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment + */ + LDKPaymentFailureReason_UserAbandoned, + /** + * We exhausted all of our retry attempts while trying to send the payment, or we + * exhausted the [`Retry::Timeout`] if the user set one. If at any point a retry + * attempt failed while being forwarded along the path, an [`Event::PaymentPathFailed`] will + * have come before this. + * + * [`Retry::Timeout`]: crate::ln::channelmanager::Retry::Timeout + */ + LDKPaymentFailureReason_RetriesExhausted, + /** + * The payment expired while retrying, based on the provided + * [`PaymentParameters::expiry_time`]. + * + * [`PaymentParameters::expiry_time`]: crate::routing::router::PaymentParameters::expiry_time + */ + LDKPaymentFailureReason_PaymentExpired, + /** + * We failed to find a route while retrying the payment. + */ + LDKPaymentFailureReason_RouteNotFound, + /** + * This error should generally never happen. This likely means that there is a problem with + * your router. + */ + LDKPaymentFailureReason_UnexpectedError, + /** + * Must be last for serialization purposes + */ + LDKPaymentFailureReason_Sentinel, +} LDKPaymentFailureReason; + /** * Specifies the recipient of an invoice. * @@ -382,12 +427,12 @@ typedef enum LDKRecipient { } LDKRecipient; /** - * Indicates an immediate error on [`ChannelManager::send_payment_with_retry`]. Further errors - * may be surfaced later via [`Event::PaymentPathFailed`] and [`Event::PaymentFailed`]. + * Indicates an immediate error on [`ChannelManager::send_payment`]. Further errors may be + * surfaced later via [`Event::PaymentPathFailed`] and [`Event::PaymentFailed`]. * - * [`ChannelManager::send_payment_with_retry`]: crate::ln::channelmanager::ChannelManager::send_payment_with_retry - * [`Event::PaymentPathFailed`]: crate::util::events::Event::PaymentPathFailed - * [`Event::PaymentFailed`]: crate::util::events::Event::PaymentFailed + * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment + * [`Event::PaymentPathFailed`]: crate::events::Event::PaymentPathFailed + * [`Event::PaymentFailed`]: crate::events::Event::PaymentFailed */ typedef enum LDKRetryableSendFailure { /** @@ -406,8 +451,8 @@ typedef enum LDKRetryableSendFailure { * yet completed (i.e. generated an [`Event::PaymentSent`] or [`Event::PaymentFailed`]). * * [`PaymentId`]: crate::ln::channelmanager::PaymentId - * [`Event::PaymentSent`]: crate::util::events::Event::PaymentSent - * [`Event::PaymentFailed`]: crate::util::events::Event::PaymentFailed + * [`Event::PaymentSent`]: crate::events::Event::PaymentSent + * [`Event::PaymentFailed`]: crate::events::Event::PaymentFailed */ LDKRetryableSendFailure_DuplicatePayment, /** @@ -471,7 +516,7 @@ typedef enum LDKSecp256k1Error { } LDKSecp256k1Error; /** - * Errors that may occur when converting a `RawInvoice` to an `Invoice`. They relate to the + * Errors that may occur when converting a [`RawInvoice`] to an [`Invoice`]. They relate to the * requirements sections in BOLT #11 */ typedef enum LDKSemanticError { @@ -762,6 +807,97 @@ typedef struct LDKTxOut { uint64_t value; } LDKTxOut; +/** + * An enum which can either contain a u64 or not + */ +typedef enum LDKCOption_DurationZ_Tag { + /** + * When we're in this state, this COption_DurationZ contains a u64 + */ + LDKCOption_DurationZ_Some, + /** + * When we're in this state, this COption_DurationZ contains nothing + */ + LDKCOption_DurationZ_None, + /** + * Must be last for serialization purposes + */ + LDKCOption_DurationZ_Sentinel, +} LDKCOption_DurationZ_Tag; + +typedef struct LDKCOption_DurationZ { + LDKCOption_DurationZ_Tag tag; + union { + struct { + uint64_t some; + }; + }; +} LDKCOption_DurationZ; + + + +/** + * Onion messages and payments can be sent and received to blinded paths, which serve to hide the + * identity of the recipient. + */ +typedef struct MUST_USE_STRUCT LDKBlindedPath { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, 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; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust 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; + +/** + * A dynamically-allocated array of crate::lightning::blinded_path::BlindedPaths of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_BlindedPathZ { + /** + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + */ + struct LDKBlindedPath *data; + /** + * The number of elements pointed to by `data`. + */ + uintptr_t datalen; +} LDKCVec_BlindedPathZ; + +/** + * An enum which can either contain a u64 or not + */ +typedef enum LDKCOption_u64Z_Tag { + /** + * When we're in this state, this COption_u64Z contains a u64 + */ + LDKCOption_u64Z_Some, + /** + * When we're in this state, this COption_u64Z contains nothing + */ + LDKCOption_u64Z_None, + /** + * Must be last for serialization purposes + */ + LDKCOption_u64Z_Sentinel, +} LDKCOption_u64Z_Tag; + +typedef struct LDKCOption_u64Z { + LDKCOption_u64Z_Tag tag; + union { + struct { + uint64_t some; + }; + }; +} LDKCOption_u64Z; + /** @@ -954,86 +1090,54 @@ typedef struct LDKCVec_APIErrorZ { } LDKCVec_APIErrorZ; /** - * An enum which can either contain a crate::lightning::ln::chan_utils::HTLCClaim or not + * An enum which can either contain a crate::c_types::derived::CVec_u8Z or not */ -typedef enum LDKCOption_HTLCClaimZ_Tag { +typedef enum LDKCOption_CVec_u8ZZ_Tag { /** - * When we're in this state, this COption_HTLCClaimZ contains a crate::lightning::ln::chan_utils::HTLCClaim + * When we're in this state, this COption_CVec_u8ZZ contains a crate::c_types::derived::CVec_u8Z */ - LDKCOption_HTLCClaimZ_Some, + LDKCOption_CVec_u8ZZ_Some, /** - * When we're in this state, this COption_HTLCClaimZ contains nothing + * When we're in this state, this COption_CVec_u8ZZ contains nothing */ - LDKCOption_HTLCClaimZ_None, + LDKCOption_CVec_u8ZZ_None, /** * Must be last for serialization purposes */ - LDKCOption_HTLCClaimZ_Sentinel, -} LDKCOption_HTLCClaimZ_Tag; + LDKCOption_CVec_u8ZZ_Sentinel, +} LDKCOption_CVec_u8ZZ_Tag; -typedef struct LDKCOption_HTLCClaimZ { - LDKCOption_HTLCClaimZ_Tag tag; +typedef struct LDKCOption_CVec_u8ZZ { + LDKCOption_CVec_u8ZZ_Tag tag; union { struct { - enum LDKHTLCClaim some; + struct LDKCVec_u8Z some; }; }; -} LDKCOption_HTLCClaimZ; - -/** - * 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; +} LDKCOption_CVec_u8ZZ; /** - * Implements the per-commitment secret storage scheme from - * [BOLT 3](https://github.com/lightning/bolts/blob/dcbf8583976df087c79c3ce0b535311212e6812d/03-transactions.md#efficient-per-commitment-secret-storage). + * Information which is provided, encrypted, to the payment recipient when sending HTLCs. * - * Allows us to keep track of all of the revocation secrets of our counterparty in just 50*32 bytes - * or so. + * This should generally be constructed with data communicated to us from the recipient (via a + * BOLT11 or BOLT12 invoice). */ -typedef struct MUST_USE_STRUCT LDKCounterpartyCommitmentSecrets { +typedef struct MUST_USE_STRUCT LDKRecipientOnionFields { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeCounterpartyCommitmentSecrets *inner; + LDKnativeRecipientOnionFields *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKCounterpartyCommitmentSecrets; +} LDKRecipientOnionFields; /** * An error in decoding a message or struct. @@ -1088,6 +1192,121 @@ typedef struct MUST_USE_STRUCT LDKDecodeError { }; } LDKDecodeError; +/** + * The contents of CResult_RecipientOnionFieldsDecodeErrorZ + */ +typedef union LDKCResult_RecipientOnionFieldsDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKRecipientOnionFields *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_RecipientOnionFieldsDecodeErrorZPtr; + +/** + * A CResult_RecipientOnionFieldsDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::outbound_payment::RecipientOnionFields 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_RecipientOnionFieldsDecodeErrorZ { + /** + * The contents of this CResult_RecipientOnionFieldsDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_RecipientOnionFieldsDecodeErrorZPtr contents; + /** + * Whether this CResult_RecipientOnionFieldsDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_RecipientOnionFieldsDecodeErrorZ; + +/** + * An enum which can either contain a crate::lightning::ln::chan_utils::HTLCClaim or not + */ +typedef enum LDKCOption_HTLCClaimZ_Tag { + /** + * When we're in this state, this COption_HTLCClaimZ contains a crate::lightning::ln::chan_utils::HTLCClaim + */ + LDKCOption_HTLCClaimZ_Some, + /** + * When we're in this state, this COption_HTLCClaimZ contains nothing + */ + LDKCOption_HTLCClaimZ_None, + /** + * Must be last for serialization purposes + */ + LDKCOption_HTLCClaimZ_Sentinel, +} LDKCOption_HTLCClaimZ_Tag; + +typedef struct LDKCOption_HTLCClaimZ { + LDKCOption_HTLCClaimZ_Tag tag; + union { + struct { + enum LDKHTLCClaim some; + }; + }; +} LDKCOption_HTLCClaimZ; + +/** + * 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; + + + +/** + * Implements the per-commitment secret storage scheme from + * [BOLT 3](https://github.com/lightning/bolts/blob/dcbf8583976df087c79c3ce0b535311212e6812d/03-transactions.md#efficient-per-commitment-secret-storage). + * + * Allows us to keep track of all of the revocation secrets of our counterparty in just 50*32 bytes + * or so. + */ +typedef struct MUST_USE_STRUCT LDKCounterpartyCommitmentSecrets { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeCounterpartyCommitmentSecrets *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKCounterpartyCommitmentSecrets; + /** * The contents of CResult_CounterpartyCommitmentSecretsDecodeErrorZ */ @@ -1851,171 +2070,58 @@ typedef struct LDKCResult_ShutdownScriptInvalidShutdownScriptZ { bool result_ok; } LDKCResult_ShutdownScriptInvalidShutdownScriptZ; -/** - * Represents a valid secp256k1 public key serialized in "compressed form" as a 33 byte array. - */ -typedef struct LDKPublicKey { - /** - * The bytes of the public key - */ - uint8_t compressed_form[33]; -} LDKPublicKey; - -/** - * A dynamically-allocated array of crate::c_types::PublicKeys of arbitrary size. - * This corresponds to std::vector in C++ - */ -typedef struct LDKCVec_PublicKeyZ { - /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - */ - struct LDKPublicKey *data; - /** - * The number of elements pointed to by `data`. - */ - uintptr_t datalen; -} LDKCVec_PublicKeyZ; - - - -/** - * Onion messages can be sent and received to blinded paths, which serve to hide the identity of - * the recipient. - */ -typedef struct MUST_USE_STRUCT LDKBlindedPath { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, 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; - /** - * Indicates that this is the only struct which contains the same pointer. - * Rust 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; - -/** - * The contents of CResult_BlindedPathNoneZ - */ -typedef union LDKCResult_BlindedPathNoneZPtr { - /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. - */ - struct LDKBlindedPath *result; - /** - * Note that this value is always NULL, as there are no contents in the Err variant - */ - void *err; -} LDKCResult_BlindedPathNoneZPtr; - -/** - * A CResult_BlindedPathNoneZ represents the result of a fallible operation, - * containing a crate::lightning::onion_message::blinded_path::BlindedPath on success and a () on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_BlindedPathNoneZ { - /** - * The contents of this CResult_BlindedPathNoneZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. - */ - union LDKCResult_BlindedPathNoneZPtr contents; - /** - * Whether this CResult_BlindedPathNoneZ represents a success state. - */ - bool result_ok; -} LDKCResult_BlindedPathNoneZ; - -/** - * The contents of CResult_BlindedPathDecodeErrorZ - */ -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; - /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. - */ - struct LDKDecodeError *err; -} LDKCResult_BlindedPathDecodeErrorZPtr; - -/** - * A CResult_BlindedPathDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::onion_message::blinded_path::BlindedPath on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_BlindedPathDecodeErrorZ { - /** - * The contents of this CResult_BlindedPathDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. - */ - union LDKCResult_BlindedPathDecodeErrorZPtr contents; - /** - * Whether this CResult_BlindedPathDecodeErrorZ represents a success state. - */ - bool result_ok; -} LDKCResult_BlindedPathDecodeErrorZ; - /** - * Used to construct the blinded hops portion of a blinded path. These hops cannot be identified - * by outside observers and thus can be used to hide the identity of the recipient. + * Information needed to route a payment across a [`BlindedPath`]. */ -typedef struct MUST_USE_STRUCT LDKBlindedHop { +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. */ - LDKnativeBlindedHop *inner; + 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; -} LDKBlindedHop; +} LDKBlindedPayInfo; /** - * The contents of CResult_BlindedHopDecodeErrorZ + * The contents of CResult_BlindedPayInfoDecodeErrorZ */ -typedef union LDKCResult_BlindedHopDecodeErrorZPtr { +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 LDKBlindedHop *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_BlindedHopDecodeErrorZPtr; +} LDKCResult_BlindedPayInfoDecodeErrorZPtr; /** - * A CResult_BlindedHopDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::onion_message::blinded_path::BlindedHop 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::offers::invoice::BlindedPayInfo on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_BlindedHopDecodeErrorZ { +typedef struct LDKCResult_BlindedPayInfoDecodeErrorZ { /** - * The contents of this CResult_BlindedHopDecodeErrorZ, accessible via either + * The contents of this CResult_BlindedPayInfoDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_BlindedHopDecodeErrorZPtr contents; + union LDKCResult_BlindedPayInfoDecodeErrorZPtr contents; /** - * Whether this CResult_BlindedHopDecodeErrorZ represents a success state. + * Whether this CResult_BlindedPayInfoDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_BlindedHopDecodeErrorZ; +} LDKCResult_BlindedPayInfoDecodeErrorZ; @@ -2060,38 +2166,23 @@ typedef struct MUST_USE_STRUCT LDKChannelUsage { /** - * A hop in a route + * A path in a [`Route`] to the payment recipient. Must always be at least length one. + * If no [`Path::blinded_tail`] is present, then [`Path::hops`] length may be up to 19. */ -typedef struct MUST_USE_STRUCT LDKRouteHop { +typedef struct MUST_USE_STRUCT LDKPath { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeRouteHop *inner; + LDKnativePath *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; -} LDKRouteHop; - -/** - * A dynamically-allocated array of crate::lightning::routing::router::RouteHops of arbitrary size. - * This corresponds to std::vector in C++ - */ -typedef struct LDKCVec_RouteHopZ { - /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - */ - struct LDKRouteHop *data; - /** - * The number of elements pointed to by `data`. - */ - uintptr_t datalen; -} LDKCVec_RouteHopZ; +} LDKPath; /** * An interface used to score payment channels for path finding. @@ -2118,19 +2209,19 @@ typedef struct LDKScore { /** * Handles updating channel penalties after failing to route through a channel. */ - void (*payment_path_failed)(void *this_arg, struct LDKCVec_RouteHopZ path, uint64_t short_channel_id); + void (*payment_path_failed)(void *this_arg, const struct LDKPath *NONNULL_PTR path, uint64_t short_channel_id); /** * Handles updating channel penalties after successfully routing along a path. */ - void (*payment_path_successful)(void *this_arg, struct LDKCVec_RouteHopZ path); + void (*payment_path_successful)(void *this_arg, const struct LDKPath *NONNULL_PTR path); /** * Handles updating channel penalties after a probe over the given path failed. */ - void (*probe_failed)(void *this_arg, struct LDKCVec_RouteHopZ path, uint64_t short_channel_id); + void (*probe_failed)(void *this_arg, const struct LDKPath *NONNULL_PTR path, uint64_t short_channel_id); /** * Handles updating channel penalties after a probe over the given path succeeded. */ - void (*probe_successful)(void *this_arg, struct LDKCVec_RouteHopZ path); + void (*probe_successful)(void *this_arg, const struct LDKPath *NONNULL_PTR path); /** * Serialize the object into a byte array */ @@ -2258,7 +2349,7 @@ typedef struct LDKCResult_NoneErrorZ { /** - * Details of a channel, as returned by ChannelManager::list_channels and ChannelManager::list_usable_channels + * Details of a channel, as returned by [`ChannelManager::list_channels`] and [`ChannelManager::list_usable_channels`] */ typedef struct MUST_USE_STRUCT LDKChannelDetails { /** @@ -2365,33 +2456,6 @@ typedef struct LDKCResult_RouteLightningErrorZ { bool result_ok; } LDKCResult_RouteLightningErrorZ; -/** - * An enum which can either contain a u64 or not - */ -typedef enum LDKCOption_u64Z_Tag { - /** - * When we're in this state, this COption_u64Z contains a u64 - */ - LDKCOption_u64Z_Some, - /** - * When we're in this state, this COption_u64Z contains nothing - */ - LDKCOption_u64Z_None, - /** - * Must be last for serialization purposes - */ - LDKCOption_u64Z_Sentinel, -} LDKCOption_u64Z_Tag; - -typedef struct LDKCOption_u64Z { - LDKCOption_u64Z_Tag tag; - union { - struct { - uint64_t some; - }; - }; -} LDKCOption_u64Z; - /** @@ -2446,6 +2510,27 @@ typedef struct LDKCResult_InFlightHtlcsDecodeErrorZ { bool result_ok; } LDKCResult_InFlightHtlcsDecodeErrorZ; + + +/** + * A hop in a route, and additional metadata about it. \"Hop\" is defined as a node and the channel + * that leads to it. + */ +typedef struct MUST_USE_STRUCT LDKRouteHop { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeRouteHop *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; +} LDKRouteHop; + /** * The contents of CResult_RouteHopDecodeErrorZ */ @@ -2479,21 +2564,130 @@ typedef struct LDKCResult_RouteHopDecodeErrorZ { bool result_ok; } LDKCResult_RouteHopDecodeErrorZ; + + +/** + * Used to construct the blinded hops portion of a blinded path. These hops cannot be identified + * by outside observers and thus can be used to hide the identity of the recipient. + */ +typedef struct MUST_USE_STRUCT LDKBlindedHop { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeBlindedHop *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; +} LDKBlindedHop; + +/** + * A dynamically-allocated array of crate::lightning::blinded_path::BlindedHops of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_BlindedHopZ { + /** + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + */ + struct LDKBlindedHop *data; + /** + * The number of elements pointed to by `data`. + */ + uintptr_t datalen; +} LDKCVec_BlindedHopZ; + + + +/** + * The blinded portion of a [`Path`], if we're routing to a recipient who provided blinded paths in + * their BOLT12 [`Invoice`]. + * + * [`Invoice`]: crate::offers::invoice::Invoice + */ +typedef struct MUST_USE_STRUCT LDKBlindedTail { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeBlindedTail *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; +} LDKBlindedTail; + +/** + * The contents of CResult_BlindedTailDecodeErrorZ + */ +typedef union LDKCResult_BlindedTailDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKBlindedTail *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_BlindedTailDecodeErrorZPtr; + +/** + * A CResult_BlindedTailDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::routing::router::BlindedTail on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_BlindedTailDecodeErrorZ { + /** + * The contents of this CResult_BlindedTailDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_BlindedTailDecodeErrorZPtr contents; + /** + * Whether this CResult_BlindedTailDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_BlindedTailDecodeErrorZ; + +/** + * A dynamically-allocated array of crate::lightning::routing::router::RouteHops of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_RouteHopZ { + /** + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + */ + struct LDKRouteHop *data; + /** + * The number of elements pointed to by `data`. + */ + uintptr_t datalen; +} LDKCVec_RouteHopZ; + /** - * A dynamically-allocated array of crate::c_types::derived::CVec_RouteHopZs of arbitrary size. + * A dynamically-allocated array of crate::lightning::routing::router::Paths of arbitrary size. * This corresponds to std::vector in C++ */ -typedef struct LDKCVec_CVec_RouteHopZZ { +typedef struct LDKCVec_PathZ { /** * The elements in the array. * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - struct LDKCVec_RouteHopZ *data; + struct LDKPath *data; /** * The number of elements pointed to by `data`. */ uintptr_t datalen; -} LDKCVec_CVec_RouteHopZZ; +} LDKCVec_PathZ; /** * The contents of CResult_RouteDecodeErrorZ @@ -2536,7 +2730,7 @@ typedef struct LDKCResult_RouteDecodeErrorZ { * Passed to [`find_route`] and [`build_route_from_hops`], but also provided in * [`Event::PaymentPathFailed`]. * - * [`Event::PaymentPathFailed`]: crate::util::events::Event::PaymentPathFailed + * [`Event::PaymentPathFailed`]: crate::events::Event::PaymentPathFailed */ typedef struct MUST_USE_STRUCT LDKRouteParameters { /** @@ -2586,42 +2780,6 @@ typedef struct LDKCResult_RouteParametersDecodeErrorZ { bool result_ok; } LDKCResult_RouteParametersDecodeErrorZ; - - -/** - * A list of hops along a payment path terminating with a channel to the recipient. - */ -typedef struct MUST_USE_STRUCT LDKRouteHint { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeRouteHint *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; -} LDKRouteHint; - -/** - * A dynamically-allocated array of crate::lightning::routing::router::RouteHints of arbitrary size. - * This corresponds to std::vector in C++ - */ -typedef struct LDKCVec_RouteHintZ { - /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - */ - struct LDKRouteHint *data; - /** - * The number of elements pointed to by `data`. - */ - uintptr_t datalen; -} LDKCVec_RouteHintZ; - /** * A dynamically-allocated array of u64s of arbitrary size. * This corresponds to std::vector in C++ @@ -2691,6 +2849,72 @@ typedef struct LDKCResult_PaymentParametersDecodeErrorZ { bool result_ok; } LDKCResult_PaymentParametersDecodeErrorZ; +/** + * A tuple of 2 elements. See the individual fields for the types contained. + */ +typedef struct LDKC2Tuple_BlindedPayInfoBlindedPathZ { + /** + * The element at position 0 + */ + struct LDKBlindedPayInfo a; + /** + * The element at position 1 + */ + struct LDKBlindedPath b; +} LDKC2Tuple_BlindedPayInfoBlindedPathZ; + +/** + * A dynamically-allocated array of crate::c_types::derived::C2Tuple_BlindedPayInfoBlindedPathZs of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ { + /** + * 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; + /** + * The number of elements pointed to by `data`. + */ + uintptr_t datalen; +} LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ; + + + +/** + * A list of hops along a payment path terminating with a channel to the recipient. + */ +typedef struct MUST_USE_STRUCT LDKRouteHint { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeRouteHint *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; +} LDKRouteHint; + +/** + * A dynamically-allocated array of crate::lightning::routing::router::RouteHints of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_RouteHintZ { + /** + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + */ + struct LDKRouteHint *data; + /** + * The number of elements pointed to by `data`. + */ + uintptr_t datalen; +} LDKCVec_RouteHintZ; + /** @@ -2794,3337 +3018,3562 @@ typedef struct LDKCResult_RouteHintHopDecodeErrorZ { } LDKCResult_RouteHintHopDecodeErrorZ; /** - * 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. + * Represents a valid secp256k1 public key serialized in "compressed form" as a 33 byte array. */ -typedef enum LDKPaymentPurpose_Tag { +typedef struct LDKPublicKey { /** - * Information for receiving a payment that we generated an invoice for. + * The bytes of the public key */ - LDKPaymentPurpose_InvoicePayment, + uint8_t compressed_form[33]; +} LDKPublicKey; + +/** + * A dynamically-allocated array of crate::c_types::PublicKeys of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_PublicKeyZ { /** - * Because this is a spontaneous payment, the payer generated their own preimage rather than us - * (the payee) providing a preimage. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - LDKPaymentPurpose_SpontaneousPayment, + struct LDKPublicKey *data; /** - * Must be last for serialization purposes + * The number of elements pointed to by `data`. */ - LDKPaymentPurpose_Sentinel, -} LDKPaymentPurpose_Tag; + uintptr_t datalen; +} LDKCVec_PublicKeyZ; -typedef struct LDKPaymentPurpose_LDKInvoicePayment_Body { +/** + * A tuple of 2 elements. See the individual fields for the types contained. + */ +typedef struct LDKC2Tuple_usizeTransactionZ { /** - * The preimage to the payment_hash, if the payment hash (and secret) were fetched via - * [`ChannelManager::create_inbound_payment`]. If provided, this can be handed directly to - * [`ChannelManager::claim_funds`]. - * - * [`ChannelManager::create_inbound_payment`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment - * [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds - * - * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + * The element at position 0 */ - struct LDKThirtyTwoBytes payment_preimage; + uintptr_t a; /** - * The \"payment secret\". This authenticates the sender to the recipient, preventing a - * number of deanonymization attacks during the routing process. - * It is provided here for your reference, however its accuracy is enforced directly by - * [`ChannelManager`] using the values you previously provided to - * [`ChannelManager::create_inbound_payment`] or - * [`ChannelManager::create_inbound_payment_for_hash`]. - * - * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager - * [`ChannelManager::create_inbound_payment`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment - * [`ChannelManager::create_inbound_payment_for_hash`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash + * The element at position 1 */ - struct LDKThirtyTwoBytes payment_secret; -} LDKPaymentPurpose_LDKInvoicePayment_Body; + struct LDKTransaction b; +} LDKC2Tuple_usizeTransactionZ; -typedef struct MUST_USE_STRUCT LDKPaymentPurpose { - LDKPaymentPurpose_Tag tag; - union { - LDKPaymentPurpose_LDKInvoicePayment_Body invoice_payment; - struct { - struct LDKThirtyTwoBytes spontaneous_payment; - }; - }; -} LDKPaymentPurpose; +/** + * A dynamically-allocated array of crate::c_types::derived::C2Tuple_usizeTransactionZs of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_C2Tuple_usizeTransactionZZ { + /** + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + */ + struct LDKC2Tuple_usizeTransactionZ *data; + /** + * The number of elements pointed to by `data`. + */ + uintptr_t datalen; +} LDKCVec_C2Tuple_usizeTransactionZZ; /** - * The contents of CResult_PaymentPurposeDecodeErrorZ + * A tuple of 2 elements. See the individual fields for the types contained. */ -typedef union LDKCResult_PaymentPurposeDecodeErrorZPtr { +typedef struct LDKC2Tuple_TxidBlockHashZ { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * The element at position 0 */ - struct LDKPaymentPurpose *result; + struct LDKThirtyTwoBytes a; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * The element at position 1 */ - struct LDKDecodeError *err; -} LDKCResult_PaymentPurposeDecodeErrorZPtr; + struct LDKThirtyTwoBytes b; +} LDKC2Tuple_TxidBlockHashZ; /** - * A CResult_PaymentPurposeDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::util::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`. + * A dynamically-allocated array of crate::c_types::derived::C2Tuple_TxidBlockHashZs of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef struct LDKCResult_PaymentPurposeDecodeErrorZ { +typedef struct LDKCVec_C2Tuple_TxidBlockHashZZ { /** - * The contents of this CResult_PaymentPurposeDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - union LDKCResult_PaymentPurposeDecodeErrorZPtr contents; + struct LDKC2Tuple_TxidBlockHashZ *data; /** - * Whether this CResult_PaymentPurposeDecodeErrorZ represents a success state. + * The number of elements pointed to by `data`. */ - bool result_ok; -} LDKCResult_PaymentPurposeDecodeErrorZ; + uintptr_t datalen; +} LDKCVec_C2Tuple_TxidBlockHashZZ; /** - * 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 + * Simple structure sent back by `chain::Watch` when an HTLC from a forward channel is detected on + * chain. Used to update the corresponding HTLC in the backward channel. Failing to pass the + * preimage claim backward will lead to loss of funds. */ -typedef struct MUST_USE_STRUCT LDKChannelUpdate { +typedef struct MUST_USE_STRUCT LDKHTLCUpdate { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeChannelUpdate *inner; + LDKnativeHTLCUpdate *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKChannelUpdate; +} LDKHTLCUpdate; + + /** - * 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. + * A reference to a transaction output. * - * [BOLT #4]: https://github.com/lightning/bolts/blob/master/04-onion-routing.md + * Differs from bitcoin::blockdata::transaction::OutPoint as the index is a u16 instead of u32 + * due to LN's restrictions on index values. Should reduce (possibly) unsafe conversions this way. */ -typedef enum LDKNetworkUpdate_Tag { +typedef struct MUST_USE_STRUCT LDKOutPoint { /** - * An error indicating a `channel_update` messages should be applied via - * [`NetworkGraph::update_channel`]. + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKNetworkUpdate_ChannelUpdateMessage, + LDKnativeOutPoint *inner; /** - * An error indicating that a channel failed to route a payment, which should be applied via - * [`NetworkGraph::channel_failed`]. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - LDKNetworkUpdate_ChannelFailure, + bool is_owned; +} LDKOutPoint; + +/** + * An event to be processed by the ChannelManager. + */ +typedef enum LDKMonitorEvent_Tag { /** - * An error indicating that a node failed to route a payment, which should be applied via - * [`NetworkGraph::node_failed_permanent`] if permanent. + * A monitor event containing an HTLCUpdate. */ - LDKNetworkUpdate_NodeFailure, + LDKMonitorEvent_HTLCEvent, /** - * Must be last for serialization purposes + * A monitor event that the Channel's commitment transaction was confirmed. */ - LDKNetworkUpdate_Sentinel, -} LDKNetworkUpdate_Tag; - -typedef struct LDKNetworkUpdate_LDKChannelUpdateMessage_Body { + LDKMonitorEvent_CommitmentTxConfirmed, /** - * The update to apply via [`NetworkGraph::update_channel`]. + * Indicates a [`ChannelMonitor`] update has completed. See + * [`ChannelMonitorUpdateStatus::InProgress`] for more information on how this is used. + * + * [`ChannelMonitorUpdateStatus::InProgress`]: super::ChannelMonitorUpdateStatus::InProgress */ - struct LDKChannelUpdate msg; -} LDKNetworkUpdate_LDKChannelUpdateMessage_Body; - -typedef struct LDKNetworkUpdate_LDKChannelFailure_Body { + LDKMonitorEvent_Completed, /** - * The short channel id of the closed channel. + * Indicates a [`ChannelMonitor`] update has failed. See + * [`ChannelMonitorUpdateStatus::PermanentFailure`] for more information on how this is used. + * + * [`ChannelMonitorUpdateStatus::PermanentFailure`]: super::ChannelMonitorUpdateStatus::PermanentFailure */ - uint64_t short_channel_id; + LDKMonitorEvent_UpdateFailed, /** - * Whether the channel should be permanently removed or temporarily disabled until a new - * `channel_update` message is received. + * Must be last for serialization purposes */ - bool is_permanent; -} LDKNetworkUpdate_LDKChannelFailure_Body; + LDKMonitorEvent_Sentinel, +} LDKMonitorEvent_Tag; -typedef struct LDKNetworkUpdate_LDKNodeFailure_Body { +typedef struct LDKMonitorEvent_LDKCompleted_Body { /** - * The node id of the failed node. + * The funding outpoint of the [`ChannelMonitor`] that was updated */ - struct LDKPublicKey node_id; + struct LDKOutPoint funding_txo; /** - * Whether the node should be permanently removed from consideration or can be restored - * when a new `channel_update` message is received. + * The Update ID from [`ChannelMonitorUpdate::update_id`] which was applied or + * [`ChannelMonitor::get_latest_update_id`]. + * + * Note that this should only be set to a given update's ID if all previous updates for the + * same [`ChannelMonitor`] have been applied and persisted. */ - bool is_permanent; -} LDKNetworkUpdate_LDKNodeFailure_Body; + uint64_t monitor_update_id; +} LDKMonitorEvent_LDKCompleted_Body; -typedef struct MUST_USE_STRUCT LDKNetworkUpdate { - LDKNetworkUpdate_Tag tag; +typedef struct MUST_USE_STRUCT LDKMonitorEvent { + LDKMonitorEvent_Tag tag; union { - LDKNetworkUpdate_LDKChannelUpdateMessage_Body channel_update_message; - LDKNetworkUpdate_LDKChannelFailure_Body channel_failure; - LDKNetworkUpdate_LDKNodeFailure_Body node_failure; + struct { + struct LDKHTLCUpdate htlc_event; + }; + struct { + struct LDKOutPoint commitment_tx_confirmed; + }; + LDKMonitorEvent_LDKCompleted_Body completed; + struct { + struct LDKOutPoint update_failed; + }; }; -} LDKNetworkUpdate; +} LDKMonitorEvent; /** - * An enum which can either contain a crate::lightning::routing::gossip::NetworkUpdate or not + * A dynamically-allocated array of crate::lightning::chain::channelmonitor::MonitorEvents of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef enum LDKCOption_NetworkUpdateZ_Tag { - /** - * When we're in this state, this COption_NetworkUpdateZ contains a crate::lightning::routing::gossip::NetworkUpdate - */ - LDKCOption_NetworkUpdateZ_Some, +typedef struct LDKCVec_MonitorEventZ { /** - * When we're in this state, this COption_NetworkUpdateZ contains nothing + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - LDKCOption_NetworkUpdateZ_None, + struct LDKMonitorEvent *data; /** - * Must be last for serialization purposes + * The number of elements pointed to by `data`. */ - LDKCOption_NetworkUpdateZ_Sentinel, -} LDKCOption_NetworkUpdateZ_Tag; - -typedef struct LDKCOption_NetworkUpdateZ { - LDKCOption_NetworkUpdateZ_Tag tag; - union { - struct { - struct LDKNetworkUpdate some; - }; - }; -} LDKCOption_NetworkUpdateZ; + uintptr_t datalen; +} LDKCVec_MonitorEventZ; /** - * When the payment path failure took place and extra details about it. [`PathFailure::OnPath`] may - * contain a [`NetworkUpdate`] that needs to be applied to the [`NetworkGraph`]. - * - * [`NetworkUpdate`]: crate::routing::gossip::NetworkUpdate - * [`NetworkGraph`]: crate::routing::gossip::NetworkGraph + * A tuple of 3 elements. See the individual fields for the types contained. */ -typedef enum LDKPathFailure_Tag { +typedef struct LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ { /** - * We failed to initially send the payment and no HTLC was committed to. Contains the relevant - * error. + * The element at position 0 */ - LDKPathFailure_InitialSend, + struct LDKOutPoint a; /** - * A hop on the path failed to forward our payment. + * The element at position 1 */ - LDKPathFailure_OnPath, + struct LDKCVec_MonitorEventZ b; /** - * Must be last for serialization purposes + * The element at position 2 */ - LDKPathFailure_Sentinel, -} LDKPathFailure_Tag; + struct LDKPublicKey c; +} LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ; -typedef struct LDKPathFailure_LDKInitialSend_Body { +/** + * A dynamically-allocated array of crate::c_types::derived::C3Tuple_OutPointCVec_MonitorEventZPublicKeyZs of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ { /** - * The error surfaced from initial send. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - struct LDKAPIError err; -} LDKPathFailure_LDKInitialSend_Body; - -typedef struct LDKPathFailure_LDKOnPath_Body { + struct LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *data; /** - * If present, this [`NetworkUpdate`] should be applied to the [`NetworkGraph`] so that routing - * decisions can take into account the update. - * - * [`NetworkUpdate`]: crate::routing::gossip::NetworkUpdate - * [`NetworkGraph`]: crate::routing::gossip::NetworkGraph + * The number of elements pointed to by `data`. */ - struct LDKCOption_NetworkUpdateZ network_update; -} LDKPathFailure_LDKOnPath_Body; + uintptr_t datalen; +} LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ; + -typedef struct MUST_USE_STRUCT LDKPathFailure { - LDKPathFailure_Tag tag; - union { - LDKPathFailure_LDKInitialSend_Body initial_send; - LDKPathFailure_LDKOnPath_Body on_path; - }; -} LDKPathFailure; /** - * An enum which can either contain a crate::lightning::util::events::PathFailure or not + * [`Score`] implementation that uses a fixed penalty. */ -typedef enum LDKCOption_PathFailureZ_Tag { - /** - * When we're in this state, this COption_PathFailureZ contains a crate::lightning::util::events::PathFailure - */ - LDKCOption_PathFailureZ_Some, +typedef struct MUST_USE_STRUCT LDKFixedPenaltyScorer { /** - * When we're in this state, this COption_PathFailureZ contains nothing + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKCOption_PathFailureZ_None, + LDKnativeFixedPenaltyScorer *inner; /** - * Must be last for serialization purposes + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - LDKCOption_PathFailureZ_Sentinel, -} LDKCOption_PathFailureZ_Tag; - -typedef struct LDKCOption_PathFailureZ { - LDKCOption_PathFailureZ_Tag tag; - union { - struct { - struct LDKPathFailure some; - }; - }; -} LDKCOption_PathFailureZ; + bool is_owned; +} LDKFixedPenaltyScorer; /** - * The contents of CResult_COption_PathFailureZDecodeErrorZ + * The contents of CResult_FixedPenaltyScorerDecodeErrorZ */ -typedef union LDKCResult_COption_PathFailureZDecodeErrorZPtr { +typedef union LDKCResult_FixedPenaltyScorerDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKCOption_PathFailureZ *result; + struct LDKFixedPenaltyScorer *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_COption_PathFailureZDecodeErrorZPtr; +} LDKCResult_FixedPenaltyScorerDecodeErrorZPtr; /** - * 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_FixedPenaltyScorerDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::routing::scoring::FixedPenaltyScorer on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_COption_PathFailureZDecodeErrorZ { +typedef struct LDKCResult_FixedPenaltyScorerDecodeErrorZ { /** - * The contents of this CResult_COption_PathFailureZDecodeErrorZ, accessible via either + * The contents of this CResult_FixedPenaltyScorerDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_COption_PathFailureZDecodeErrorZPtr contents; + union LDKCResult_FixedPenaltyScorerDecodeErrorZPtr contents; /** - * Whether this CResult_COption_PathFailureZDecodeErrorZ represents a success state. + * Whether this CResult_FixedPenaltyScorerDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_COption_PathFailureZDecodeErrorZ; +} LDKCResult_FixedPenaltyScorerDecodeErrorZ; /** - * The reason the channel was closed. See individual variants more details. + * A tuple of 2 elements. See the individual fields for the types contained. */ -typedef enum LDKClosureReason_Tag { - /** - * Closure generated from receiving a peer error message. - * - * Our counterparty may have broadcasted their latest commitment state, and we have - * as well. - */ - LDKClosureReason_CounterpartyForceClosed, - /** - * Closure generated from [`ChannelManager::force_close_channel`], called by the user. - * - * [`ChannelManager::force_close_channel`]: crate::ln::channelmanager::ChannelManager::force_close_channel. - */ - LDKClosureReason_HolderForceClosed, - /** - * The channel was closed after negotiating a cooperative close and we've now broadcasted - * the cooperative close transaction. Note the shutdown may have been initiated by us. - */ - LDKClosureReason_CooperativeClosure, - /** - * A commitment transaction was confirmed on chain, closing the channel. Most likely this - * commitment transaction came from our counterparty, but it may also have come from - * a copy of our own `ChannelMonitor`. - */ - LDKClosureReason_CommitmentTxConfirmed, - /** - * The funding transaction failed to confirm in a timely manner on an inbound channel. - */ - LDKClosureReason_FundingTimedOut, - /** - * Closure generated from processing an event, likely a HTLC forward/relay/reception. - */ - LDKClosureReason_ProcessingError, - /** - * The peer disconnected prior to funding completing. In this case the spec mandates that we - * forget the channel entirely - we can attempt again if the peer reconnects. - * - * This includes cases where we restarted prior to funding completion, including prior to the - * initial [`ChannelMonitor`] persistence completing. - * - * In LDK versions prior to 0.0.107 this could also occur if we were unable to connect to the - * peer because of mutual incompatibility between us and our channel counterparty. - * - * [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor - */ - LDKClosureReason_DisconnectedPeer, - /** - * Closure generated from `ChannelManager::read` if the [`ChannelMonitor`] is newer than - * the [`ChannelManager`] deserialized. - * - * [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor - * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager - */ - LDKClosureReason_OutdatedChannelManager, - /** - * Must be last for serialization purposes - */ - LDKClosureReason_Sentinel, -} LDKClosureReason_Tag; - -typedef struct LDKClosureReason_LDKCounterpartyForceClosed_Body { +typedef struct LDKC2Tuple_u64u64Z { /** - * The error which the peer sent us. - * - * The string should be sanitized before it is used (e.g emitted to logs - * or printed to stdout). Otherwise, a well crafted error message may exploit - * a security vulnerability in the terminal emulator or the logging subsystem. + * The element at position 0 */ - struct LDKStr peer_msg; -} LDKClosureReason_LDKCounterpartyForceClosed_Body; - -typedef struct LDKClosureReason_LDKProcessingError_Body { + uint64_t a; /** - * A developer-readable error message which we generated. + * The element at position 1 */ - struct LDKStr err; -} LDKClosureReason_LDKProcessingError_Body; - -typedef struct MUST_USE_STRUCT LDKClosureReason { - LDKClosureReason_Tag tag; - union { - LDKClosureReason_LDKCounterpartyForceClosed_Body counterparty_force_closed; - LDKClosureReason_LDKProcessingError_Body processing_error; - }; -} LDKClosureReason; + uint64_t b; +} LDKC2Tuple_u64u64Z; /** - * An enum which can either contain a crate::lightning::util::events::ClosureReason or not + * An enum which can either contain a crate::c_types::derived::C2Tuple_u64u64Z or not */ -typedef enum LDKCOption_ClosureReasonZ_Tag { +typedef enum LDKCOption_C2Tuple_u64u64ZZ_Tag { /** - * When we're in this state, this COption_ClosureReasonZ contains a crate::lightning::util::events::ClosureReason + * When we're in this state, this COption_C2Tuple_u64u64ZZ contains a crate::c_types::derived::C2Tuple_u64u64Z */ - LDKCOption_ClosureReasonZ_Some, + LDKCOption_C2Tuple_u64u64ZZ_Some, /** - * When we're in this state, this COption_ClosureReasonZ contains nothing + * When we're in this state, this COption_C2Tuple_u64u64ZZ contains nothing */ - LDKCOption_ClosureReasonZ_None, + LDKCOption_C2Tuple_u64u64ZZ_None, /** * Must be last for serialization purposes */ - LDKCOption_ClosureReasonZ_Sentinel, -} LDKCOption_ClosureReasonZ_Tag; + LDKCOption_C2Tuple_u64u64ZZ_Sentinel, +} LDKCOption_C2Tuple_u64u64ZZ_Tag; -typedef struct LDKCOption_ClosureReasonZ { - LDKCOption_ClosureReasonZ_Tag tag; +typedef struct LDKCOption_C2Tuple_u64u64ZZ { + LDKCOption_C2Tuple_u64u64ZZ_Tag tag; union { struct { - struct LDKClosureReason some; + struct LDKC2Tuple_u64u64Z some; }; }; -} LDKCOption_ClosureReasonZ; +} LDKCOption_C2Tuple_u64u64ZZ; /** - * The contents of CResult_COption_ClosureReasonZDecodeErrorZ + * 8 u16s */ -typedef union LDKCResult_COption_ClosureReasonZDecodeErrorZPtr { - /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. - */ - struct LDKCOption_ClosureReasonZ *result; +typedef struct LDKEightU16s { /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * The eight 16-bit integers */ - struct LDKDecodeError *err; -} LDKCResult_COption_ClosureReasonZDecodeErrorZPtr; + uint16_t data[8]; +} LDKEightU16s; /** - * 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`. + * A tuple of 2 elements. See the individual fields for the types contained. */ -typedef struct LDKCResult_COption_ClosureReasonZDecodeErrorZ { +typedef struct LDKC2Tuple_Z { /** - * The contents of this CResult_COption_ClosureReasonZDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * The element at position 0 */ - union LDKCResult_COption_ClosureReasonZDecodeErrorZPtr contents; + struct LDKEightU16s a; /** - * Whether this CResult_COption_ClosureReasonZDecodeErrorZ represents a success state. + * The element at position 1 */ - bool result_ok; -} LDKCResult_COption_ClosureReasonZDecodeErrorZ; + struct LDKEightU16s b; +} LDKC2Tuple_Z; /** - * Intended destination of a failed HTLC as indicated in [`Event::HTLCHandlingFailed`]. + * A tuple of 2 elements. See the individual fields for the types contained. */ -typedef enum LDKHTLCDestination_Tag { - /** - * We tried forwarding to a channel but failed to do so. An example of such an instance is when - * there is insufficient capacity in our outbound channel. - */ - LDKHTLCDestination_NextHopChannel, - /** - * Scenario where we are unsure of the next node to forward the HTLC to. - */ - LDKHTLCDestination_UnknownNextHop, - /** - * We couldn't forward to the outgoing scid. An example would be attempting to send a duplicate - * intercept HTLC. - */ - LDKHTLCDestination_InvalidForward, - /** - * Failure scenario where an HTLC may have been forwarded to be intended for us, - * but is invalid for some reason, so we reject it. - * - * Some of the reasons may include: - * * HTLC Timeouts - * * Expected MPP amount to claim does not equal HTLC total - * * Claimable amount does not match expected amount - */ - LDKHTLCDestination_FailedPayment, - /** - * Must be last for serialization purposes - */ - LDKHTLCDestination_Sentinel, -} LDKHTLCDestination_Tag; - -typedef struct LDKHTLCDestination_LDKNextHopChannel_Body { - /** - * The `node_id` of the next node. For backwards compatibility, this field is - * marked as optional, versions prior to 0.0.110 may not always be able to provide - * counterparty node information. - * - * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None - */ - struct LDKPublicKey node_id; - /** - * The outgoing `channel_id` between us and the next node. - */ - struct LDKThirtyTwoBytes channel_id; -} LDKHTLCDestination_LDKNextHopChannel_Body; - -typedef struct LDKHTLCDestination_LDKUnknownNextHop_Body { - /** - * Short channel id we are requesting to forward an HTLC to. - */ - uint64_t requested_forward_scid; -} LDKHTLCDestination_LDKUnknownNextHop_Body; - -typedef struct LDKHTLCDestination_LDKInvalidForward_Body { +typedef struct LDKC2Tuple__u168_u168Z { /** - * Short channel id we are requesting to forward an HTLC to. + * The element at position 0 */ - uint64_t requested_forward_scid; -} LDKHTLCDestination_LDKInvalidForward_Body; - -typedef struct LDKHTLCDestination_LDKFailedPayment_Body { + struct LDKEightU16s a; /** - * The payment hash of the payment we attempted to process. + * The element at position 1 */ - struct LDKThirtyTwoBytes payment_hash; -} LDKHTLCDestination_LDKFailedPayment_Body; - -typedef struct MUST_USE_STRUCT LDKHTLCDestination { - LDKHTLCDestination_Tag tag; - union { - LDKHTLCDestination_LDKNextHopChannel_Body next_hop_channel; - LDKHTLCDestination_LDKUnknownNextHop_Body unknown_next_hop; - LDKHTLCDestination_LDKInvalidForward_Body invalid_forward; - LDKHTLCDestination_LDKFailedPayment_Body failed_payment; - }; -} LDKHTLCDestination; + struct LDKEightU16s b; +} LDKC2Tuple__u168_u168Z; /** - * An enum which can either contain a crate::lightning::util::events::HTLCDestination or not + * An enum which can either contain a crate::c_types::derived::C2Tuple__u168_u168Z or not */ -typedef enum LDKCOption_HTLCDestinationZ_Tag { +typedef enum LDKCOption_C2Tuple_EightU16sEightU16sZZ_Tag { /** - * When we're in this state, this COption_HTLCDestinationZ contains a crate::lightning::util::events::HTLCDestination + * When we're in this state, this COption_C2Tuple_EightU16sEightU16sZZ contains a crate::c_types::derived::C2Tuple__u168_u168Z */ - LDKCOption_HTLCDestinationZ_Some, + LDKCOption_C2Tuple_EightU16sEightU16sZZ_Some, /** - * When we're in this state, this COption_HTLCDestinationZ contains nothing + * When we're in this state, this COption_C2Tuple_EightU16sEightU16sZZ contains nothing */ - LDKCOption_HTLCDestinationZ_None, + LDKCOption_C2Tuple_EightU16sEightU16sZZ_None, /** * Must be last for serialization purposes */ - LDKCOption_HTLCDestinationZ_Sentinel, -} LDKCOption_HTLCDestinationZ_Tag; + LDKCOption_C2Tuple_EightU16sEightU16sZZ_Sentinel, +} LDKCOption_C2Tuple_EightU16sEightU16sZZ_Tag; -typedef struct LDKCOption_HTLCDestinationZ { - LDKCOption_HTLCDestinationZ_Tag tag; +typedef struct LDKCOption_C2Tuple_EightU16sEightU16sZZ { + LDKCOption_C2Tuple_EightU16sEightU16sZZ_Tag tag; union { struct { - struct LDKHTLCDestination some; + struct LDKC2Tuple__u168_u168Z some; }; }; -} LDKCOption_HTLCDestinationZ; +} LDKCOption_C2Tuple_EightU16sEightU16sZZ; /** - * The contents of CResult_COption_HTLCDestinationZDecodeErrorZ + * A dynamically-allocated array of crate::lightning::routing::gossip::NodeIds of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef union LDKCResult_COption_HTLCDestinationZDecodeErrorZPtr { +typedef struct LDKCVec_NodeIdZ { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - struct LDKCOption_HTLCDestinationZ *result; + struct LDKNodeId *data; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * The number of elements pointed to by `data`. */ - struct LDKDecodeError *err; -} LDKCResult_COption_HTLCDestinationZDecodeErrorZPtr; + uintptr_t datalen; +} LDKCVec_NodeIdZ; + + /** - * 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`. + * A Record, unit of logging output with Metadata to enable filtering + * Module_path, file, line to inform on log's source */ -typedef struct LDKCResult_COption_HTLCDestinationZDecodeErrorZ { +typedef struct MUST_USE_STRUCT LDKRecord { /** - * The contents of this CResult_COption_HTLCDestinationZDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - union LDKCResult_COption_HTLCDestinationZDecodeErrorZPtr contents; + LDKnativeRecord *inner; /** - * Whether this CResult_COption_HTLCDestinationZDecodeErrorZ represents a success state. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - bool result_ok; -} LDKCResult_COption_HTLCDestinationZDecodeErrorZ; + bool is_owned; +} LDKRecord; /** - * An enum which can either contain a crate::c_types::U128 or not + * A trait encapsulating the operations required of a logger */ -typedef enum LDKCOption_u128Z_Tag { +typedef struct LDKLogger { /** - * When we're in this state, this COption_u128Z contains a crate::c_types::U128 + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. */ - LDKCOption_u128Z_Some, + void *this_arg; /** - * When we're in this state, this COption_u128Z contains nothing + * Logs the `Record` */ - LDKCOption_u128Z_None, + void (*log)(const void *this_arg, const struct LDKRecord *NONNULL_PTR record); /** - * Must be last for serialization purposes + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. */ - LDKCOption_u128Z_Sentinel, -} LDKCOption_u128Z_Tag; - -typedef struct LDKCOption_u128Z { - LDKCOption_u128Z_Tag tag; - union { - struct { - struct LDKU128 some; - }; - }; -} LDKCOption_u128Z; + void (*free)(void *this_arg); +} LDKLogger; /** - * A reference to a transaction output. - * - * Differs from bitcoin::blockdata::transaction::OutPoint as the index is a u16 instead of u32 - * due to LN's restrictions on index values. Should reduce (possibly) unsafe conversions this way. + * Represents the network as nodes and channels between them */ -typedef struct MUST_USE_STRUCT LDKOutPoint { +typedef struct MUST_USE_STRUCT LDKNetworkGraph { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeOutPoint *inner; + LDKnativeNetworkGraph *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKOutPoint; +} LDKNetworkGraph; /** - * Information about a spendable output to a P2WSH script. + * [`Score`] implementation using channel success probability distributions. * - * See [`SpendableOutputDescriptor::DelayedPaymentOutput`] for more details on how to spend this. + * Channels are tracked with upper and lower liquidity bounds - when an HTLC fails at a channel, + * we learn that the upper-bound on the available liquidity is lower than the amount of the HTLC. + * When a payment is forwarded through a channel (but fails later in the route), we learn the + * lower-bound on the channel's available liquidity must be at least the value of the HTLC. + * + * These bounds are then used to determine a success probability using the formula from + * *Optimally Reliable & Cheap Payment Flows on the Lightning Network* by Rene Pickhardt + * and Stefan Richter [[1]] (i.e. `(upper_bound - payment_amount) / (upper_bound - lower_bound)`). + * + * This probability is combined with the [`liquidity_penalty_multiplier_msat`] and + * [`liquidity_penalty_amount_multiplier_msat`] parameters to calculate a concrete penalty in + * milli-satoshis. The penalties, when added across all hops, have the property of being linear in + * terms of the entire path's success probability. This allows the router to directly compare + * penalties for different paths. See the documentation of those parameters for the exact formulas. + * + * The liquidity bounds are decayed by halving them every [`liquidity_offset_half_life`]. + * + * Further, we track the history of our upper and lower liquidity bounds for each channel, + * allowing us to assign a second penalty (using [`historical_liquidity_penalty_multiplier_msat`] + * and [`historical_liquidity_penalty_amount_multiplier_msat`]) based on the same probability + * formula, but using the history of a channel rather than our latest estimates for the liquidity + * bounds. + * + * # Note + * + * Mixing the `no-std` feature between serialization and deserialization results in undefined + * behavior. + * + * [1]: https://arxiv.org/abs/2107.05322 + * [`liquidity_penalty_multiplier_msat`]: ProbabilisticScoringParameters::liquidity_penalty_multiplier_msat + * [`liquidity_penalty_amount_multiplier_msat`]: ProbabilisticScoringParameters::liquidity_penalty_amount_multiplier_msat + * [`liquidity_offset_half_life`]: ProbabilisticScoringParameters::liquidity_offset_half_life + * [`historical_liquidity_penalty_multiplier_msat`]: ProbabilisticScoringParameters::historical_liquidity_penalty_multiplier_msat + * [`historical_liquidity_penalty_amount_multiplier_msat`]: ProbabilisticScoringParameters::historical_liquidity_penalty_amount_multiplier_msat */ -typedef struct MUST_USE_STRUCT LDKDelayedPaymentOutputDescriptor { +typedef struct MUST_USE_STRUCT LDKProbabilisticScorer { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeDelayedPaymentOutputDescriptor *inner; + LDKnativeProbabilisticScorer *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKDelayedPaymentOutputDescriptor; +} LDKProbabilisticScorer; + +/** + * The contents of CResult_ProbabilisticScorerDecodeErrorZ + */ +typedef union LDKCResult_ProbabilisticScorerDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKProbabilisticScorer *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_ProbabilisticScorerDecodeErrorZPtr; + +/** + * A CResult_ProbabilisticScorerDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::routing::scoring::ProbabilisticScorer on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_ProbabilisticScorerDecodeErrorZ { + /** + * The contents of this CResult_ProbabilisticScorerDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_ProbabilisticScorerDecodeErrorZPtr contents; + /** + * Whether this CResult_ProbabilisticScorerDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_ProbabilisticScorerDecodeErrorZ; /** - * Information about a spendable output to our \"payment key\". - * - * See [`SpendableOutputDescriptor::StaticPaymentOutput`] for more details on how to spend this. + * Features used within an `init` message. */ -typedef struct MUST_USE_STRUCT LDKStaticPaymentOutputDescriptor { +typedef struct MUST_USE_STRUCT LDKInitFeatures { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeStaticPaymentOutputDescriptor *inner; + LDKnativeInitFeatures *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKStaticPaymentOutputDescriptor; +} LDKInitFeatures; /** - * Describes the necessary information to spend a spendable output. - * - * When on-chain outputs are created by LDK (which our counterparty is not able to claim at any - * point in the future) a [`SpendableOutputs`] event is generated which you must track and be able - * to spend on-chain. The information needed to do this is provided in this enum, including the - * outpoint describing which `txid` and output `index` is available, the full output which exists - * at that `txid`/`index`, and any keys or other information required to sign. - * - * [`SpendableOutputs`]: crate::util::events::Event::SpendableOutputs + * The contents of CResult_InitFeaturesDecodeErrorZ */ -typedef enum LDKSpendableOutputDescriptor_Tag { - /** - * An output to a script which was provided via [`SignerProvider`] directly, either from - * [`get_destination_script`] or [`get_shutdown_scriptpubkey`], thus you should already - * know how to spend it. No secret keys are provided as LDK was never given any key. - * These may include outputs from a transaction punishing our counterparty or claiming an HTLC - * on-chain using the payment preimage or after it has timed out. - * - * [`get_shutdown_scriptpubkey`]: SignerProvider::get_shutdown_scriptpubkey - * [`get_destination_script`]: SignerProvider::get_shutdown_scriptpubkey - */ - LDKSpendableOutputDescriptor_StaticOutput, - /** - * An output to a P2WSH script which can be spent with a single signature after an `OP_CSV` - * delay. - * - * The witness in the spending input should be: - * ```bitcoin - * (MINIMALIF standard rule) - * ``` - * - * Note that the `nSequence` field in the spending input must be set to - * [`DelayedPaymentOutputDescriptor::to_self_delay`] (which means the transaction is not - * broadcastable until at least [`DelayedPaymentOutputDescriptor::to_self_delay`] blocks after - * the outpoint confirms, see [BIP - * 68](https://github.com/bitcoin/bips/blob/master/bip-0068.mediawiki)). Also note that LDK - * won't generate a [`SpendableOutputDescriptor`] until the corresponding block height - * is reached. - * - * These are generally the result of a \"revocable\" output to us, spendable only by us unless - * it is an output from an old state which we broadcast (which should never happen). - * - * To derive the delayed payment key which is used to sign this input, you must pass the - * holder [`InMemorySigner::delayed_payment_base_key`] (i.e., the private key which corresponds to the - * [`ChannelPublicKeys::delayed_payment_basepoint`] in [`ChannelSigner::pubkeys`]) and the provided - * [`DelayedPaymentOutputDescriptor::per_commitment_point`] to [`chan_utils::derive_private_key`]. The public key can be - * generated without the secret key using [`chan_utils::derive_public_key`] and only the - * [`ChannelPublicKeys::delayed_payment_basepoint`] which appears in [`ChannelSigner::pubkeys`]. - * - * To derive the [`DelayedPaymentOutputDescriptor::revocation_pubkey`] provided here (which is - * used in the witness script generation), you must pass the counterparty - * [`ChannelPublicKeys::revocation_basepoint`] (which appears in the call to - * [`ChannelSigner::provide_channel_parameters`]) and the provided - * [`DelayedPaymentOutputDescriptor::per_commitment_point`] to - * [`chan_utils::derive_public_revocation_key`]. - * - * The witness script which is hashed and included in the output `script_pubkey` may be - * regenerated by passing the [`DelayedPaymentOutputDescriptor::revocation_pubkey`] (derived - * as explained above), our delayed payment pubkey (derived as explained above), and the - * [`DelayedPaymentOutputDescriptor::to_self_delay`] contained here to - * [`chan_utils::get_revokeable_redeemscript`]. - */ - LDKSpendableOutputDescriptor_DelayedPaymentOutput, - /** - * An output to a P2WPKH, spendable exclusively by our payment key (i.e., the private key - * which corresponds to the `payment_point` in [`ChannelSigner::pubkeys`]). The witness - * in the spending input is, thus, simply: - * ```bitcoin - * - * ``` - * - * These are generally the result of our counterparty having broadcast the current state, - * allowing us to claim the non-HTLC-encumbered outputs immediately. - */ - LDKSpendableOutputDescriptor_StaticPaymentOutput, - /** - * Must be last for serialization purposes - */ - LDKSpendableOutputDescriptor_Sentinel, -} LDKSpendableOutputDescriptor_Tag; - -typedef struct LDKSpendableOutputDescriptor_LDKStaticOutput_Body { +typedef union LDKCResult_InitFeaturesDecodeErrorZPtr { /** - * The outpoint which is spendable. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKOutPoint outpoint; + struct LDKInitFeatures *result; /** - * The output which is referenced by the given outpoint. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKTxOut output; -} LDKSpendableOutputDescriptor_LDKStaticOutput_Body; - -typedef struct MUST_USE_STRUCT LDKSpendableOutputDescriptor { - LDKSpendableOutputDescriptor_Tag tag; - union { - LDKSpendableOutputDescriptor_LDKStaticOutput_Body static_output; - struct { - struct LDKDelayedPaymentOutputDescriptor delayed_payment_output; - }; - struct { - struct LDKStaticPaymentOutputDescriptor static_payment_output; - }; - }; -} LDKSpendableOutputDescriptor; + struct LDKDecodeError *err; +} LDKCResult_InitFeaturesDecodeErrorZPtr; /** - * A dynamically-allocated array of crate::lightning::chain::keysinterface::SpendableOutputDescriptors of arbitrary size. - * This corresponds to std::vector in C++ + * A CResult_InitFeaturesDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::features::InitFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCVec_SpendableOutputDescriptorZ { +typedef struct LDKCResult_InitFeaturesDecodeErrorZ { /** - * 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_InitFeaturesDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKSpendableOutputDescriptor *data; + union LDKCResult_InitFeaturesDecodeErrorZPtr contents; /** - * The number of elements pointed to by `data`. + * Whether this CResult_InitFeaturesDecodeErrorZ represents a success state. */ - uintptr_t datalen; -} LDKCVec_SpendableOutputDescriptorZ; + bool result_ok; +} LDKCResult_InitFeaturesDecodeErrorZ; /** - * 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. + * Features used within a `channel_announcement` message. */ -typedef struct MUST_USE_STRUCT LDKChannelTypeFeatures { +typedef struct MUST_USE_STRUCT LDKChannelFeatures { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeChannelTypeFeatures *inner; + LDKnativeChannelFeatures *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; -} LDKChannelTypeFeatures; +} LDKChannelFeatures; /** - * An Event which you should probably take some action in response to. - * - * Note that while Writeable and Readable are implemented for Event, you probably shouldn't use - * them directly as they don't round-trip exactly (for example FundingGenerationReady is never - * written as it makes no sense to respond to it after reconnecting to peers). + * The contents of CResult_ChannelFeaturesDecodeErrorZ */ -typedef enum LDKEvent_Tag { - /** - * Used to indicate that the client should generate a funding transaction with the given - * parameters and then call [`ChannelManager::funding_transaction_generated`]. - * Generated in [`ChannelManager`] message handling. - * Note that *all inputs* in the funding transaction must spend SegWit outputs or your - * counterparty can steal your funds! - * - * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager - * [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated - */ - LDKEvent_FundingGenerationReady, +typedef union LDKCResult_ChannelFeaturesDecodeErrorZPtr { /** - * Indicates that we've been offered a payment and it needs to be claimed via calling - * [`ChannelManager::claim_funds`] with the preimage given in [`PaymentPurpose`]. - * - * Note that if the preimage is not known, you should call - * [`ChannelManager::fail_htlc_backwards`] or [`ChannelManager::fail_htlc_backwards_with_reason`] - * to free up resources for this HTLC and avoid network congestion. - * If you fail to call either [`ChannelManager::claim_funds`], [`ChannelManager::fail_htlc_backwards`], - * or [`ChannelManager::fail_htlc_backwards_with_reason`] within the HTLC's timeout, the HTLC will be - * automatically failed. - * - * # Note - * LDK will not stop an inbound payment from being paid multiple times, so multiple - * `PaymentClaimable` events may be generated for the same payment. - * - * # Note - * This event used to be called `PaymentReceived` in LDK versions 0.0.112 and earlier. - * - * [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds - * [`ChannelManager::fail_htlc_backwards`]: crate::ln::channelmanager::ChannelManager::fail_htlc_backwards - * [`ChannelManager::fail_htlc_backwards_with_reason`]: crate::ln::channelmanager::ChannelManager::fail_htlc_backwards_with_reason + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - LDKEvent_PaymentClaimable, + struct LDKChannelFeatures *result; /** - * Indicates a payment has been claimed and we've received money! - * - * This most likely occurs when [`ChannelManager::claim_funds`] has been called in response - * to an [`Event::PaymentClaimable`]. However, if we previously crashed during a - * [`ChannelManager::claim_funds`] call you may see this event without a corresponding - * [`Event::PaymentClaimable`] event. - * - * # Note - * LDK will not stop an inbound payment from being paid multiple times, so multiple - * `PaymentClaimable` events may be generated for the same payment. If you then call - * [`ChannelManager::claim_funds`] twice for the same [`Event::PaymentClaimable`] you may get - * multiple `PaymentClaimed` events. - * - * [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - LDKEvent_PaymentClaimed, + struct LDKDecodeError *err; +} 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. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_ChannelFeaturesDecodeErrorZ { /** - * 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. + * The contents of this CResult_ChannelFeaturesDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKEvent_PaymentSent, + union LDKCResult_ChannelFeaturesDecodeErrorZPtr contents; /** - * Indicates an outbound payment failed. Individual [`Event::PaymentPathFailed`] events - * provide failure information for each path attempt in the payment, including retries. - * - * This event is provided once there are no further pending HTLCs for the payment and the - * payment is no longer retryable, due either to the [`Retry`] provided or - * [`ChannelManager::abandon_payment`] having been called for the corresponding payment. - * - * [`Retry`]: crate::ln::channelmanager::Retry - * [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment + * Whether this CResult_ChannelFeaturesDecodeErrorZ represents a success state. */ - LDKEvent_PaymentFailed, + bool result_ok; +} LDKCResult_ChannelFeaturesDecodeErrorZ; + + + +/** + * Features used within a `node_announcement` message. + */ +typedef struct MUST_USE_STRUCT LDKNodeFeatures { /** - * 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. + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKEvent_PaymentPathSuccessful, + LDKnativeNodeFeatures *inner; /** - * Indicates an outbound HTLC we sent failed, likely due to an intermediary node being unable to - * handle the HTLC. - * - * Note that this does *not* indicate that all paths for an MPP payment have failed, see - * [`Event::PaymentFailed`]. - * - * See [`ChannelManager::abandon_payment`] for giving up on this payment before its retries have - * been exhausted. - * - * [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - LDKEvent_PaymentPathFailed, + bool is_owned; +} LDKNodeFeatures; + +/** + * The contents of CResult_NodeFeaturesDecodeErrorZ + */ +typedef union LDKCResult_NodeFeaturesDecodeErrorZPtr { /** - * Indicates that a probe payment we sent returned successful, i.e., only failed at the destination. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - LDKEvent_ProbeSuccessful, + struct LDKNodeFeatures *result; /** - * Indicates that a probe payment we sent failed at an intermediary node on the path. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - LDKEvent_ProbeFailed, + struct LDKDecodeError *err; +} 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. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_NodeFeaturesDecodeErrorZ { /** - * Used to indicate that [`ChannelManager::process_pending_htlc_forwards`] should be called at - * a time in the future. - * - * [`ChannelManager::process_pending_htlc_forwards`]: crate::ln::channelmanager::ChannelManager::process_pending_htlc_forwards + * The contents of this CResult_NodeFeaturesDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKEvent_PendingHTLCsForwardable, + union LDKCResult_NodeFeaturesDecodeErrorZPtr contents; /** - * Used to indicate that we've intercepted an HTLC forward. This event will only be generated if - * you've encoded an intercept scid in the receiver's invoice route hints using - * [`ChannelManager::get_intercept_scid`] and have set [`UserConfig::accept_intercept_htlcs`]. - * - * [`ChannelManager::forward_intercepted_htlc`] or - * [`ChannelManager::fail_intercepted_htlc`] MUST be called in response to this event. See - * their docs for more information. - * - * [`ChannelManager::get_intercept_scid`]: crate::ln::channelmanager::ChannelManager::get_intercept_scid - * [`UserConfig::accept_intercept_htlcs`]: crate::util::config::UserConfig::accept_intercept_htlcs - * [`ChannelManager::forward_intercepted_htlc`]: crate::ln::channelmanager::ChannelManager::forward_intercepted_htlc - * [`ChannelManager::fail_intercepted_htlc`]: crate::ln::channelmanager::ChannelManager::fail_intercepted_htlc + * Whether this CResult_NodeFeaturesDecodeErrorZ represents a success state. */ - LDKEvent_HTLCIntercepted, + bool result_ok; +} LDKCResult_NodeFeaturesDecodeErrorZ; + + + +/** + * Features used within an invoice. + */ +typedef struct MUST_USE_STRUCT LDKInvoiceFeatures { /** - * Used to indicate that an output which you should know how to spend was confirmed on chain - * and is now spendable. - * Such an output will *not* ever be spent by rust-lightning, and are not at risk of your - * counterparty spending them due to some kind of timeout. Thus, you need to store them - * somewhere and spend them when you create on-chain transactions. + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKEvent_SpendableOutputs, + LDKnativeInvoiceFeatures *inner; /** - * This event is generated when a payment has been successfully forwarded through us and a - * forwarding fee earned. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - LDKEvent_PaymentForwarded, + bool is_owned; +} LDKInvoiceFeatures; + +/** + * The contents of CResult_InvoiceFeaturesDecodeErrorZ + */ +typedef union LDKCResult_InvoiceFeaturesDecodeErrorZPtr { /** - * Used to indicate that a channel with the given `channel_id` is ready to - * be used. This event is emitted either when the funding transaction has been confirmed - * on-chain, or, in case of a 0conf channel, when both parties have confirmed the channel - * establishment. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - LDKEvent_ChannelReady, + struct LDKInvoiceFeatures *result; /** - * Used to indicate that a previously opened channel with the given `channel_id` is in the - * process of closure. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - LDKEvent_ChannelClosed, + struct LDKDecodeError *err; +} LDKCResult_InvoiceFeaturesDecodeErrorZPtr; + +/** + * A CResult_InvoiceFeaturesDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::features::InvoiceFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_InvoiceFeaturesDecodeErrorZ { /** - * Used to indicate to the user that they can abandon the funding transaction and recycle the - * inputs for another purpose. + * The contents of this CResult_InvoiceFeaturesDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKEvent_DiscardFunding, + union LDKCResult_InvoiceFeaturesDecodeErrorZPtr contents; /** - * Indicates a request to open a new channel by a peer. - * - * To accept the request, call [`ChannelManager::accept_inbound_channel`]. To reject the - * request, call [`ChannelManager::force_close_without_broadcasting_txn`]. - * - * The event is only triggered when a new open channel request is received and the - * [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. - * - * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel - * [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn - * [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels + * Whether this CResult_InvoiceFeaturesDecodeErrorZ represents a success state. */ - LDKEvent_OpenChannelRequest, + bool result_ok; +} LDKCResult_InvoiceFeaturesDecodeErrorZ; + + + +/** + * Features used within BOLT 4 encrypted_data_tlv and BOLT 12 blinded_payinfo + */ +typedef struct MUST_USE_STRUCT LDKBlindedHopFeatures { /** - * Indicates that the HTLC was accepted, but could not be processed when or after attempting to - * forward it. - * - * Some scenarios where this event may be sent include: - * * Insufficient capacity in the outbound channel - * * While waiting to forward the HTLC, the channel it is meant to be forwarded through closes - * * When an unknown SCID is requested for forwarding a payment. - * * Claiming an amount for an MPP payment that exceeds the HTLC total - * * The HTLC has timed out - * - * This event, however, does not get generated if an HTLC fails to meet the forwarding - * requirements (i.e. insufficient fees paid, or a CLTV that is too soon). + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKEvent_HTLCHandlingFailed, + LDKnativeBlindedHopFeatures *inner; /** - * Must be last for serialization purposes + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - LDKEvent_Sentinel, -} LDKEvent_Tag; + bool is_owned; +} LDKBlindedHopFeatures; -typedef struct LDKEvent_LDKFundingGenerationReady_Body { - /** - * The random channel_id we picked which you'll need to pass into - * [`ChannelManager::funding_transaction_generated`]. - * - * [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated - */ - struct LDKThirtyTwoBytes temporary_channel_id; +/** + * The contents of CResult_BlindedHopFeaturesDecodeErrorZ + */ +typedef union LDKCResult_BlindedHopFeaturesDecodeErrorZPtr { /** - * The counterparty's node_id, which you'll need to pass back into - * [`ChannelManager::funding_transaction_generated`]. - * - * [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKPublicKey counterparty_node_id; + struct LDKBlindedHopFeatures *result; /** - * The value, in satoshis, that the output should have. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - uint64_t channel_value_satoshis; + struct LDKDecodeError *err; +} 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. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_BlindedHopFeaturesDecodeErrorZ { /** - * The script which should be used in the transaction output. + * The contents of this CResult_BlindedHopFeaturesDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKCVec_u8Z output_script; + union LDKCResult_BlindedHopFeaturesDecodeErrorZPtr contents; /** - * The `user_channel_id` value passed in to [`ChannelManager::create_channel`], or a - * random value for an inbound channel. This may be zero for objects serialized with LDK - * versions prior to 0.0.113. - * - * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel + * Whether this CResult_BlindedHopFeaturesDecodeErrorZ represents a success state. */ - struct LDKU128 user_channel_id; -} LDKEvent_LDKFundingGenerationReady_Body; + bool result_ok; +} LDKCResult_BlindedHopFeaturesDecodeErrorZ; -typedef struct LDKEvent_LDKPaymentClaimable_Body { + + +/** + * 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. + */ +typedef struct MUST_USE_STRUCT LDKChannelTypeFeatures { /** - * The node that will receive the payment after it has been claimed. - * This is useful to identify payments received via [phantom nodes]. - * This field will always be filled in when the event was generated by LDK versions - * 0.0.113 and above. - * - * [phantom nodes]: crate::chain::keysinterface::PhantomKeysManager - * - * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - struct LDKPublicKey receiver_node_id; + LDKnativeChannelTypeFeatures *inner; /** - * The hash for which the preimage should be handed to the ChannelManager. Note that LDK will - * not stop you from registering duplicate payment hashes for inbound payments. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - struct LDKThirtyTwoBytes payment_hash; + bool is_owned; +} LDKChannelTypeFeatures; + +/** + * The contents of CResult_ChannelTypeFeaturesDecodeErrorZ + */ +typedef union LDKCResult_ChannelTypeFeaturesDecodeErrorZPtr { /** - * The value, in thousandths of a satoshi, that this payment is for. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - uint64_t amount_msat; + struct LDKChannelTypeFeatures *result; /** - * Information for claiming this received payment, based on whether the purpose of the - * payment is to pay an invoice or to send a spontaneous payment. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKPaymentPurpose purpose; + struct LDKDecodeError *err; +} 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. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_ChannelTypeFeaturesDecodeErrorZ { /** - * The `channel_id` indicating over which channel we received the payment. - * - * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + * The contents of this CResult_ChannelTypeFeaturesDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKThirtyTwoBytes via_channel_id; + union LDKCResult_ChannelTypeFeaturesDecodeErrorZPtr contents; /** - * The `user_channel_id` indicating over which channel we received the payment. + * Whether this CResult_ChannelTypeFeaturesDecodeErrorZ represents a success state. */ - struct LDKCOption_u128Z via_user_channel_id; -} LDKEvent_LDKPaymentClaimable_Body; + bool result_ok; +} LDKCResult_ChannelTypeFeaturesDecodeErrorZ; -typedef struct LDKEvent_LDKPaymentClaimed_Body { - /** - * The node that received the payment. - * This is useful to identify payments which were received via [phantom nodes]. - * This field will always be filled in when the event was generated by LDK versions - * 0.0.113 and above. - * - * [phantom nodes]: crate::chain::keysinterface::PhantomKeysManager - * - * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None - */ - struct LDKPublicKey receiver_node_id; +/** + * Some information provided on receipt of payment depends on whether the payment received is a + * spontaneous payment or a \"conventional\" lightning payment that's paying an invoice. + */ +typedef enum LDKPaymentPurpose_Tag { /** - * The payment hash of the claimed payment. Note that LDK will not stop you from - * registering duplicate payment hashes for inbound payments. + * Information for receiving a payment that we generated an invoice for. */ - struct LDKThirtyTwoBytes payment_hash; + LDKPaymentPurpose_InvoicePayment, /** - * The value, in thousandths of a satoshi, that this payment is for. + * Because this is a spontaneous payment, the payer generated their own preimage rather than us + * (the payee) providing a preimage. */ - uint64_t amount_msat; + LDKPaymentPurpose_SpontaneousPayment, /** - * The purpose of the claimed payment, i.e. whether the payment was for an invoice or a - * spontaneous payment. + * Must be last for serialization purposes */ - struct LDKPaymentPurpose purpose; -} LDKEvent_LDKPaymentClaimed_Body; + LDKPaymentPurpose_Sentinel, +} LDKPaymentPurpose_Tag; -typedef struct LDKEvent_LDKPaymentSent_Body { +typedef struct LDKPaymentPurpose_LDKInvoicePayment_Body { /** - * The id returned by [`ChannelManager::send_payment`]. + * The preimage to the payment_hash, if the payment hash (and secret) were fetched via + * [`ChannelManager::create_inbound_payment`]. If provided, this can be handed directly to + * [`ChannelManager::claim_funds`]. * - * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment + * [`ChannelManager::create_inbound_payment`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment + * [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds * * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None */ - struct LDKThirtyTwoBytes payment_id; - /** - * The preimage to the hash given to ChannelManager::send_payment. - * Note that this serves as a payment receipt, if you wish to have such a thing, you must - * store it somehow! - */ struct LDKThirtyTwoBytes payment_preimage; /** - * The hash that was given to [`ChannelManager::send_payment`]. - * - * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment - */ - struct LDKThirtyTwoBytes payment_hash; - /** - * The total fee which was spent at intermediate hops in this payment, across all paths. - * - * Note that, like [`Route::get_total_fees`] this does *not* include any potential - * overpayment to the recipient node. - * - * If the recipient or an intermediate node misbehaves and gives us free money, this may - * overstate the amount paid, though this is unlikely. + * The \"payment secret\". This authenticates the sender to the recipient, preventing a + * number of deanonymization attacks during the routing process. + * It is provided here for your reference, however its accuracy is enforced directly by + * [`ChannelManager`] using the values you previously provided to + * [`ChannelManager::create_inbound_payment`] or + * [`ChannelManager::create_inbound_payment_for_hash`]. * - * [`Route::get_total_fees`]: crate::routing::router::Route::get_total_fees + * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager + * [`ChannelManager::create_inbound_payment`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment + * [`ChannelManager::create_inbound_payment_for_hash`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash */ - struct LDKCOption_u64Z fee_paid_msat; -} LDKEvent_LDKPaymentSent_Body; + struct LDKThirtyTwoBytes payment_secret; +} LDKPaymentPurpose_LDKInvoicePayment_Body; -typedef struct LDKEvent_LDKPaymentFailed_Body { +typedef struct MUST_USE_STRUCT LDKPaymentPurpose { + LDKPaymentPurpose_Tag tag; + union { + LDKPaymentPurpose_LDKInvoicePayment_Body invoice_payment; + struct { + struct LDKThirtyTwoBytes spontaneous_payment; + }; + }; +} LDKPaymentPurpose; + +/** + * The contents of CResult_PaymentPurposeDecodeErrorZ + */ +typedef union LDKCResult_PaymentPurposeDecodeErrorZPtr { /** - * The id returned by [`ChannelManager::send_payment`] and used with - * [`ChannelManager::abandon_payment`]. - * - * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment - * [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKThirtyTwoBytes payment_id; + struct LDKPaymentPurpose *result; /** - * The hash that was given to [`ChannelManager::send_payment`]. - * - * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKThirtyTwoBytes payment_hash; -} LDKEvent_LDKPaymentFailed_Body; + struct LDKDecodeError *err; +} LDKCResult_PaymentPurposeDecodeErrorZPtr; -typedef struct LDKEvent_LDKPaymentPathSuccessful_Body { - /** - * The id returned by [`ChannelManager::send_payment`]. - * - * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment - */ - struct LDKThirtyTwoBytes payment_id; +/** + * A CResult_PaymentPurposeDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::events::PaymentPurpose on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_PaymentPurposeDecodeErrorZ { /** - * The hash that was given to [`ChannelManager::send_payment`]. - * - * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment - * - * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + * The contents of this CResult_PaymentPurposeDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKThirtyTwoBytes payment_hash; + union LDKCResult_PaymentPurposeDecodeErrorZPtr contents; /** - * The payment path that was successful. - * - * May contain a closed channel if the HTLC sent along the path was fulfilled on chain. + * Whether this CResult_PaymentPurposeDecodeErrorZ represents a success state. */ - struct LDKCVec_RouteHopZ path; -} LDKEvent_LDKPaymentPathSuccessful_Body; + bool result_ok; +} LDKCResult_PaymentPurposeDecodeErrorZ; -typedef struct LDKEvent_LDKPaymentPathFailed_Body { + + +/** + * 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 { /** - * The id returned by [`ChannelManager::send_payment`] and used with - * [`ChannelManager::abandon_payment`]. - * - * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment - * [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment - * - * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - struct LDKThirtyTwoBytes payment_id; + LDKnativeChannelUpdate *inner; /** - * The hash that was given to [`ChannelManager::send_payment`]. - * - * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - struct LDKThirtyTwoBytes payment_hash; + bool is_owned; +} 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. + * + * [BOLT #4]: https://github.com/lightning/bolts/blob/master/04-onion-routing.md + */ +typedef enum LDKNetworkUpdate_Tag { /** - * Indicates the payment was rejected for some reason by the recipient. This implies that - * the payment has failed, not just the route in question. If this is not set, the payment may - * be retried via a different route. + * An error indicating a `channel_update` messages should be applied via + * [`NetworkGraph::update_channel`]. */ - bool payment_failed_permanently; + LDKNetworkUpdate_ChannelUpdateMessage, /** - * Extra error details based on the failure type. May contain an update that needs to be - * applied to the [`NetworkGraph`]. - * - * [`NetworkGraph`]: crate::routing::gossip::NetworkGraph + * An error indicating that a channel failed to route a payment, which should be applied via + * [`NetworkGraph::channel_failed_permanent`] if permanent. */ - struct LDKPathFailure failure; + LDKNetworkUpdate_ChannelFailure, /** - * The payment path that failed. + * An error indicating that a node failed to route a payment, which should be applied via + * [`NetworkGraph::node_failed_permanent`] if permanent. */ - struct LDKCVec_RouteHopZ path; + LDKNetworkUpdate_NodeFailure, /** - * The channel responsible for the failed payment path. - * - * Note that for route hints or for the first hop in a path this may be an SCID alias and - * may not refer to a channel in the public network graph. These aliases may also collide - * with channels in the public network graph. - * - * If this is `Some`, then the corresponding channel should be avoided when the payment is - * retried. May be `None` for older [`Event`] serializations. + * Must be last for serialization purposes */ - struct LDKCOption_u64Z short_channel_id; + LDKNetworkUpdate_Sentinel, +} LDKNetworkUpdate_Tag; + +typedef struct LDKNetworkUpdate_LDKChannelUpdateMessage_Body { /** - * Parameters used by LDK to compute a new [`Route`] when retrying the failed payment path. - * - * [`Route`]: crate::routing::router::Route - * - * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + * The update to apply via [`NetworkGraph::update_channel`]. */ - struct LDKRouteParameters retry; -} LDKEvent_LDKPaymentPathFailed_Body; + struct LDKChannelUpdate msg; +} LDKNetworkUpdate_LDKChannelUpdateMessage_Body; -typedef struct LDKEvent_LDKProbeSuccessful_Body { +typedef struct LDKNetworkUpdate_LDKChannelFailure_Body { /** - * The id returned by [`ChannelManager::send_probe`]. - * - * [`ChannelManager::send_probe`]: crate::ln::channelmanager::ChannelManager::send_probe + * The short channel id of the closed channel. */ - struct LDKThirtyTwoBytes payment_id; + uint64_t short_channel_id; /** - * The hash generated by [`ChannelManager::send_probe`]. - * - * [`ChannelManager::send_probe`]: crate::ln::channelmanager::ChannelManager::send_probe + * Whether the channel should be permanently removed or temporarily disabled until a new + * `channel_update` message is received. */ - struct LDKThirtyTwoBytes payment_hash; + bool is_permanent; +} LDKNetworkUpdate_LDKChannelFailure_Body; + +typedef struct LDKNetworkUpdate_LDKNodeFailure_Body { /** - * The payment path that was successful. + * The node id of the failed node. */ - struct LDKCVec_RouteHopZ path; -} LDKEvent_LDKProbeSuccessful_Body; - -typedef struct LDKEvent_LDKProbeFailed_Body { + struct LDKPublicKey node_id; /** - * The id returned by [`ChannelManager::send_probe`]. - * - * [`ChannelManager::send_probe`]: crate::ln::channelmanager::ChannelManager::send_probe + * Whether the node should be permanently removed from consideration or can be restored + * when a new `channel_update` message is received. */ - struct LDKThirtyTwoBytes payment_id; + bool is_permanent; +} 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; + }; +} LDKNetworkUpdate; + +/** + * An enum which can either contain a crate::lightning::routing::gossip::NetworkUpdate or not + */ +typedef enum LDKCOption_NetworkUpdateZ_Tag { /** - * The hash generated by [`ChannelManager::send_probe`]. - * - * [`ChannelManager::send_probe`]: crate::ln::channelmanager::ChannelManager::send_probe + * When we're in this state, this COption_NetworkUpdateZ contains a crate::lightning::routing::gossip::NetworkUpdate */ - struct LDKThirtyTwoBytes payment_hash; + LDKCOption_NetworkUpdateZ_Some, /** - * The payment path that failed. + * When we're in this state, this COption_NetworkUpdateZ contains nothing */ - struct LDKCVec_RouteHopZ path; + LDKCOption_NetworkUpdateZ_None, /** - * The channel responsible for the failed probe. - * - * Note that for route hints or for the first hop in a path this may be an SCID alias and - * may not refer to a channel in the public network graph. These aliases may also collide - * with channels in the public network graph. + * Must be last for serialization purposes */ - struct LDKCOption_u64Z short_channel_id; -} LDKEvent_LDKProbeFailed_Body; + LDKCOption_NetworkUpdateZ_Sentinel, +} LDKCOption_NetworkUpdateZ_Tag; -typedef struct LDKEvent_LDKPendingHTLCsForwardable_Body { - /** - * The minimum amount of time that should be waited prior to calling - * process_pending_htlc_forwards. To increase the effort required to correlate payments, - * you should wait a random amount of time in roughly the range (now + time_forwardable, - * now + 5*time_forwardable). - */ - uint64_t time_forwardable; -} LDKEvent_LDKPendingHTLCsForwardable_Body; +typedef struct LDKCOption_NetworkUpdateZ { + LDKCOption_NetworkUpdateZ_Tag tag; + union { + struct { + struct LDKNetworkUpdate some; + }; + }; +} LDKCOption_NetworkUpdateZ; -typedef struct LDKEvent_LDKHTLCIntercepted_Body { +/** + * When the payment path failure took place and extra details about it. [`PathFailure::OnPath`] may + * contain a [`NetworkUpdate`] that needs to be applied to the [`NetworkGraph`]. + * + * [`NetworkUpdate`]: crate::routing::gossip::NetworkUpdate + * [`NetworkGraph`]: crate::routing::gossip::NetworkGraph + */ +typedef enum LDKPathFailure_Tag { /** - * An id to help LDK identify which HTLC is being forwarded or failed. + * We failed to initially send the payment and no HTLC was committed to. Contains the relevant + * error. */ - struct LDKThirtyTwoBytes intercept_id; + LDKPathFailure_InitialSend, /** - * The fake scid that was programmed as the next hop's scid, generated using - * [`ChannelManager::get_intercept_scid`]. - * - * [`ChannelManager::get_intercept_scid`]: crate::ln::channelmanager::ChannelManager::get_intercept_scid + * A hop on the path failed to forward our payment. */ - uint64_t requested_next_hop_scid; + LDKPathFailure_OnPath, /** - * The payment hash used for this HTLC. + * Must be last for serialization purposes */ - struct LDKThirtyTwoBytes payment_hash; + LDKPathFailure_Sentinel, +} LDKPathFailure_Tag; + +typedef struct LDKPathFailure_LDKInitialSend_Body { /** - * How many msats were received on the inbound edge of this HTLC. + * The error surfaced from initial send. */ - uint64_t inbound_amount_msat; + struct LDKAPIError err; +} LDKPathFailure_LDKInitialSend_Body; + +typedef struct LDKPathFailure_LDKOnPath_Body { /** - * How many msats the payer intended to route to the next node. Depending on the reason you are - * intercepting this payment, you might take a fee by forwarding less than this amount. + * If present, this [`NetworkUpdate`] should be applied to the [`NetworkGraph`] so that routing + * decisions can take into account the update. * - * Note that LDK will NOT check that expected fees were factored into this value. You MUST - * check that whatever fee you want has been included here or subtract it as required. Further, - * LDK will not stop you from forwarding more than you received. + * [`NetworkUpdate`]: crate::routing::gossip::NetworkUpdate + * [`NetworkGraph`]: crate::routing::gossip::NetworkGraph */ - uint64_t expected_outbound_amount_msat; -} LDKEvent_LDKHTLCIntercepted_Body; + struct LDKCOption_NetworkUpdateZ network_update; +} LDKPathFailure_LDKOnPath_Body; -typedef struct LDKEvent_LDKSpendableOutputs_Body { +typedef struct MUST_USE_STRUCT LDKPathFailure { + LDKPathFailure_Tag tag; + union { + LDKPathFailure_LDKInitialSend_Body initial_send; + LDKPathFailure_LDKOnPath_Body on_path; + }; +} LDKPathFailure; + +/** + * An enum which can either contain a crate::lightning::events::PathFailure or not + */ +typedef enum LDKCOption_PathFailureZ_Tag { /** - * The outputs which you should store as spendable by you. + * When we're in this state, this COption_PathFailureZ contains a crate::lightning::events::PathFailure */ - struct LDKCVec_SpendableOutputDescriptorZ outputs; -} LDKEvent_LDKSpendableOutputs_Body; - -typedef struct LDKEvent_LDKPaymentForwarded_Body { + LDKCOption_PathFailureZ_Some, /** - * The incoming channel between the previous node and us. This is only `None` for events - * generated or serialized by versions prior to 0.0.107. - * - * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + * When we're in this state, this COption_PathFailureZ contains nothing */ - struct LDKThirtyTwoBytes prev_channel_id; + LDKCOption_PathFailureZ_None, /** - * The outgoing channel between the next node and us. This is only `None` for events - * generated or serialized by versions prior to 0.0.107. - * - * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + * Must be last for serialization purposes */ - struct LDKThirtyTwoBytes next_channel_id; + LDKCOption_PathFailureZ_Sentinel, +} LDKCOption_PathFailureZ_Tag; + +typedef struct LDKCOption_PathFailureZ { + LDKCOption_PathFailureZ_Tag tag; + union { + struct { + struct LDKPathFailure some; + }; + }; +} LDKCOption_PathFailureZ; + +/** + * The contents of CResult_COption_PathFailureZDecodeErrorZ + */ +typedef union LDKCResult_COption_PathFailureZDecodeErrorZPtr { /** - * The fee, in milli-satoshis, which was earned as a result of the payment. - * - * Note that if we force-closed the channel over which we forwarded an HTLC while the HTLC - * was pending, the amount the next hop claimed will have been rounded down to the nearest - * whole satoshi. Thus, the fee calculated here may be higher than expected as we still - * claimed the full value in millisatoshis from the source. In this case, - * `claim_from_onchain_tx` will be set. - * - * If the channel which sent us the payment has been force-closed, we will claim the funds - * via an on-chain transaction. In that case we do not yet know the on-chain transaction - * fees which we will spend and will instead set this to `None`. It is possible duplicate - * `PaymentForwarded` events are generated for the same payment iff `fee_earned_msat` is - * `None`. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKCOption_u64Z fee_earned_msat; + struct LDKCOption_PathFailureZ *result; /** - * If this is `true`, the forwarded HTLC was claimed by our counterparty via an on-chain - * transaction. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - bool claim_from_onchain_tx; -} LDKEvent_LDKPaymentForwarded_Body; + struct LDKDecodeError *err; +} LDKCResult_COption_PathFailureZDecodeErrorZPtr; -typedef struct LDKEvent_LDKChannelReady_Body { +/** + * A CResult_COption_PathFailureZDecodeErrorZ represents the result of a fallible operation, + * containing a crate::c_types::derived::COption_PathFailureZ on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_COption_PathFailureZDecodeErrorZ { /** - * The channel_id of the channel that is ready. + * The contents of this CResult_COption_PathFailureZDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKThirtyTwoBytes channel_id; + union LDKCResult_COption_PathFailureZDecodeErrorZPtr contents; /** - * The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound - * channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if - * [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise - * `user_channel_id` will be randomized for an inbound channel. - * - * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel - * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel - * [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels + * Whether this CResult_COption_PathFailureZDecodeErrorZ represents a success state. */ - struct LDKU128 user_channel_id; + bool result_ok; +} LDKCResult_COption_PathFailureZDecodeErrorZ; + + + +/** + * Struct to `Display` fields in a safe way using `PrintableString` + */ +typedef struct MUST_USE_STRUCT LDKUntrustedString { /** - * The node_id of the channel counterparty. + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - struct LDKPublicKey counterparty_node_id; + LDKnativeUntrustedString *inner; /** - * The features that this channel will operate with. + * Indicates that this is the only struct which contains the same pointer. + * Rust 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 LDKChannelTypeFeatures channel_type; -} LDKEvent_LDKChannelReady_Body; + bool is_owned; +} LDKUntrustedString; -typedef struct LDKEvent_LDKChannelClosed_Body { +/** + * The reason the channel was closed. See individual variants more details. + */ +typedef enum LDKClosureReason_Tag { /** - * The channel_id of the channel which has been closed. Note that on-chain transactions - * resolving the channel are likely still awaiting confirmation. + * Closure generated from receiving a peer error message. + * + * Our counterparty may have broadcasted their latest commitment state, and we have + * as well. */ - struct LDKThirtyTwoBytes channel_id; + LDKClosureReason_CounterpartyForceClosed, /** - * The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound - * channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if - * [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise - * `user_channel_id` will be randomized for inbound channels. - * This may be zero for inbound channels serialized prior to 0.0.113 and will always be - * zero for objects serialized with LDK versions prior to 0.0.102. + * Closure generated from [`ChannelManager::force_close_channel`], called by the user. * - * [`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 + * [`ChannelManager::force_close_channel`]: crate::ln::channelmanager::ChannelManager::force_close_channel. */ - struct LDKU128 user_channel_id; + LDKClosureReason_HolderForceClosed, /** - * The reason the channel was closed. + * 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. */ - struct LDKClosureReason reason; -} LDKEvent_LDKChannelClosed_Body; - -typedef struct LDKEvent_LDKDiscardFunding_Body { + LDKClosureReason_CooperativeClosure, /** - * The channel_id of the channel which has been closed. + * A commitment transaction was confirmed on chain, closing the channel. Most likely this + * commitment transaction came from our counterparty, but it may also have come from + * a copy of our own `ChannelMonitor`. */ - struct LDKThirtyTwoBytes channel_id; + LDKClosureReason_CommitmentTxConfirmed, /** - * The full transaction received from the user + * The funding transaction failed to confirm in a timely manner on an inbound channel. */ - struct LDKTransaction transaction; -} LDKEvent_LDKDiscardFunding_Body; - -typedef struct LDKEvent_LDKOpenChannelRequest_Body { + LDKClosureReason_FundingTimedOut, /** - * The temporary channel ID of the channel requested to be opened. - * - * When responding to the request, the `temporary_channel_id` should be passed - * back to the ChannelManager through [`ChannelManager::accept_inbound_channel`] to accept, - * or through [`ChannelManager::force_close_without_broadcasting_txn`] to reject. - * - * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel - * [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn + * Closure generated from processing an event, likely a HTLC forward/relay/reception. */ - struct LDKThirtyTwoBytes temporary_channel_id; + LDKClosureReason_ProcessingError, /** - * The node_id of the counterparty requesting to open the channel. + * The peer disconnected prior to funding completing. In this case the spec mandates that we + * forget the channel entirely - we can attempt again if the peer reconnects. * - * When responding to the request, the `counterparty_node_id` should be passed - * back to the `ChannelManager` through [`ChannelManager::accept_inbound_channel`] to - * accept the request, or through [`ChannelManager::force_close_without_broadcasting_txn`] to reject the - * request. + * This includes cases where we restarted prior to funding completion, including prior to the + * initial [`ChannelMonitor`] persistence completing. * - * [`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 + * In LDK versions prior to 0.0.107 this could also occur if we were unable to connect to the + * peer because of mutual incompatibility between us and our channel counterparty. + * + * [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor */ - struct LDKPublicKey counterparty_node_id; + LDKClosureReason_DisconnectedPeer, /** - * The channel value of the requested channel. + * Closure generated from `ChannelManager::read` if the [`ChannelMonitor`] is newer than + * the [`ChannelManager`] deserialized. + * + * [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor + * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager */ - uint64_t funding_satoshis; + LDKClosureReason_OutdatedChannelManager, /** - * Our starting balance in the channel if the request is accepted, in milli-satoshi. + * Must be last for serialization purposes */ - uint64_t push_msat; + LDKClosureReason_Sentinel, +} LDKClosureReason_Tag; + +typedef struct LDKClosureReason_LDKCounterpartyForceClosed_Body { /** - * The features that this channel will operate with. If you reject the channel, a - * well-behaved counterparty may automatically re-attempt the channel with a new set of - * feature flags. - * - * Note that if [`ChannelTypeFeatures::supports_scid_privacy`] returns true on this type, - * the resulting [`ChannelManager`] will not be readable by versions of LDK prior to - * 0.0.106. + * The error which the peer sent us. * - * Furthermore, note that if [`ChannelTypeFeatures::supports_zero_conf`] returns true on this type, - * the resulting [`ChannelManager`] will not be readable by versions of LDK prior to - * 0.0.107. Channels setting this type also need to get manually accepted via - * [`crate::ln::channelmanager::ChannelManager::accept_inbound_channel_from_trusted_peer_0conf`], - * or will be rejected otherwise. + * Be careful about printing the peer_msg, a well-crafted message could exploit + * a security vulnerability in the terminal emulator or the logging subsystem. + * To be safe, use `Display` on `UntrustedString` * - * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager + * [`UntrustedString`]: crate::util::string::UntrustedString */ - struct LDKChannelTypeFeatures channel_type; -} LDKEvent_LDKOpenChannelRequest_Body; + struct LDKUntrustedString peer_msg; +} LDKClosureReason_LDKCounterpartyForceClosed_Body; -typedef struct LDKEvent_LDKHTLCHandlingFailed_Body { - /** - * The channel over which the HTLC was received. - */ - struct LDKThirtyTwoBytes prev_channel_id; +typedef struct LDKClosureReason_LDKProcessingError_Body { /** - * Destination of the HTLC that failed to be processed. + * A developer-readable error message which we generated. */ - struct LDKHTLCDestination failed_next_destination; -} LDKEvent_LDKHTLCHandlingFailed_Body; + struct LDKStr err; +} LDKClosureReason_LDKProcessingError_Body; -typedef struct MUST_USE_STRUCT LDKEvent { - LDKEvent_Tag tag; +typedef struct MUST_USE_STRUCT LDKClosureReason { + LDKClosureReason_Tag tag; union { - LDKEvent_LDKFundingGenerationReady_Body funding_generation_ready; - LDKEvent_LDKPaymentClaimable_Body payment_claimable; - LDKEvent_LDKPaymentClaimed_Body payment_claimed; - LDKEvent_LDKPaymentSent_Body payment_sent; - LDKEvent_LDKPaymentFailed_Body payment_failed; - LDKEvent_LDKPaymentPathSuccessful_Body payment_path_successful; - LDKEvent_LDKPaymentPathFailed_Body payment_path_failed; - LDKEvent_LDKProbeSuccessful_Body probe_successful; - LDKEvent_LDKProbeFailed_Body probe_failed; - LDKEvent_LDKPendingHTLCsForwardable_Body pending_htl_cs_forwardable; - LDKEvent_LDKHTLCIntercepted_Body htlc_intercepted; - LDKEvent_LDKSpendableOutputs_Body spendable_outputs; - LDKEvent_LDKPaymentForwarded_Body payment_forwarded; - LDKEvent_LDKChannelReady_Body channel_ready; - LDKEvent_LDKChannelClosed_Body channel_closed; - LDKEvent_LDKDiscardFunding_Body discard_funding; - LDKEvent_LDKOpenChannelRequest_Body open_channel_request; - LDKEvent_LDKHTLCHandlingFailed_Body htlc_handling_failed; + LDKClosureReason_LDKCounterpartyForceClosed_Body counterparty_force_closed; + LDKClosureReason_LDKProcessingError_Body processing_error; }; -} LDKEvent; +} LDKClosureReason; /** - * An enum which can either contain a crate::lightning::util::events::Event or not + * An enum which can either contain a crate::lightning::events::ClosureReason or not */ -typedef enum LDKCOption_EventZ_Tag { +typedef enum LDKCOption_ClosureReasonZ_Tag { /** - * When we're in this state, this COption_EventZ contains a crate::lightning::util::events::Event + * When we're in this state, this COption_ClosureReasonZ contains a crate::lightning::events::ClosureReason */ - LDKCOption_EventZ_Some, + LDKCOption_ClosureReasonZ_Some, /** - * When we're in this state, this COption_EventZ contains nothing + * When we're in this state, this COption_ClosureReasonZ contains nothing */ - LDKCOption_EventZ_None, + LDKCOption_ClosureReasonZ_None, /** * Must be last for serialization purposes */ - LDKCOption_EventZ_Sentinel, -} LDKCOption_EventZ_Tag; + LDKCOption_ClosureReasonZ_Sentinel, +} LDKCOption_ClosureReasonZ_Tag; -typedef struct LDKCOption_EventZ { - LDKCOption_EventZ_Tag tag; +typedef struct LDKCOption_ClosureReasonZ { + LDKCOption_ClosureReasonZ_Tag tag; union { struct { - struct LDKEvent some; + struct LDKClosureReason some; }; }; -} LDKCOption_EventZ; +} LDKCOption_ClosureReasonZ; /** - * The contents of CResult_COption_EventZDecodeErrorZ + * The contents of CResult_COption_ClosureReasonZDecodeErrorZ */ -typedef union LDKCResult_COption_EventZDecodeErrorZPtr { +typedef union LDKCResult_COption_ClosureReasonZDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKCOption_EventZ *result; + struct LDKCOption_ClosureReasonZ *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_COption_EventZDecodeErrorZPtr; +} LDKCResult_COption_ClosureReasonZDecodeErrorZPtr; /** - * 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`. */ -typedef struct LDKCResult_COption_EventZDecodeErrorZ { +typedef struct LDKCResult_COption_ClosureReasonZDecodeErrorZ { /** - * The contents of this CResult_COption_EventZDecodeErrorZ, accessible via either + * The contents of this CResult_COption_ClosureReasonZDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_COption_EventZDecodeErrorZPtr contents; + union LDKCResult_COption_ClosureReasonZDecodeErrorZPtr contents; /** - * Whether this CResult_COption_EventZDecodeErrorZ represents a success state. + * Whether this CResult_COption_ClosureReasonZDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_COption_EventZDecodeErrorZ; - - +} LDKCResult_COption_ClosureReasonZDecodeErrorZ; /** - * An [`accept_channel`] message to be sent to or received from a peer. - * - * [`accept_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-accept_channel-message + * Intended destination of a failed HTLC as indicated in [`Event::HTLCHandlingFailed`]. */ -typedef struct MUST_USE_STRUCT LDKAcceptChannel { +typedef enum LDKHTLCDestination_Tag { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * We tried forwarding to a channel but failed to do so. An example of such an instance is when + * there is insufficient capacity in our outbound channel. */ - LDKnativeAcceptChannel *inner; + LDKHTLCDestination_NextHopChannel, /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * Scenario where we are unsure of the next node to forward the HTLC to. */ - bool is_owned; -} LDKAcceptChannel; - - - -/** - * An [`open_channel`] message to be sent to or received from a peer. - * - * [`open_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-open_channel-message - */ -typedef struct MUST_USE_STRUCT LDKOpenChannel { + LDKHTLCDestination_UnknownNextHop, /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * We couldn't forward to the outgoing scid. An example would be attempting to send a duplicate + * intercept HTLC. */ - LDKnativeOpenChannel *inner; + LDKHTLCDestination_InvalidForward, /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * Failure scenario where an HTLC may have been forwarded to be intended for us, + * but is invalid for some reason, so we reject it. + * + * Some of the reasons may include: + * * HTLC Timeouts + * * Excess HTLCs for a payment that we have already fully received, over-paying for the + * payment, + * * The counterparty node modified the HTLC in transit, + * * A probing attack where an intermediary node is trying to detect if we are the ultimate + * recipient for a payment. */ - bool is_owned; -} LDKOpenChannel; - + LDKHTLCDestination_FailedPayment, + /** + * Must be last for serialization purposes + */ + LDKHTLCDestination_Sentinel, +} LDKHTLCDestination_Tag; +typedef struct LDKHTLCDestination_LDKNextHopChannel_Body { + /** + * The `node_id` of the next node. For backwards compatibility, this field is + * marked as optional, versions prior to 0.0.110 may not always be able to provide + * counterparty node information. + * + * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + */ + struct LDKPublicKey node_id; + /** + * The outgoing `channel_id` between us and the next node. + */ + struct LDKThirtyTwoBytes channel_id; +} LDKHTLCDestination_LDKNextHopChannel_Body; -/** - * A [`funding_created`] message to be sent to or received from a peer. - * - * [`funding_created`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-funding_created-message - */ -typedef struct MUST_USE_STRUCT LDKFundingCreated { +typedef struct LDKHTLCDestination_LDKUnknownNextHop_Body { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * Short channel id we are requesting to forward an HTLC to. */ - LDKnativeFundingCreated *inner; + uint64_t requested_forward_scid; +} LDKHTLCDestination_LDKUnknownNextHop_Body; + +typedef struct LDKHTLCDestination_LDKInvalidForward_Body { /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * Short channel id we are requesting to forward an HTLC to. */ - bool is_owned; -} LDKFundingCreated; + uint64_t requested_forward_scid; +} LDKHTLCDestination_LDKInvalidForward_Body; +typedef struct LDKHTLCDestination_LDKFailedPayment_Body { + /** + * The payment hash of the payment we attempted to process. + */ + struct LDKThirtyTwoBytes payment_hash; +} LDKHTLCDestination_LDKFailedPayment_Body; +typedef struct MUST_USE_STRUCT LDKHTLCDestination { + LDKHTLCDestination_Tag tag; + union { + LDKHTLCDestination_LDKNextHopChannel_Body next_hop_channel; + LDKHTLCDestination_LDKUnknownNextHop_Body unknown_next_hop; + LDKHTLCDestination_LDKInvalidForward_Body invalid_forward; + LDKHTLCDestination_LDKFailedPayment_Body failed_payment; + }; +} LDKHTLCDestination; /** - * A [`funding_signed`] message to be sent to or received from a peer. - * - * [`funding_signed`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-funding_signed-message + * An enum which can either contain a crate::lightning::events::HTLCDestination or not */ -typedef struct MUST_USE_STRUCT LDKFundingSigned { +typedef enum LDKCOption_HTLCDestinationZ_Tag { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * When we're in this state, this COption_HTLCDestinationZ contains a crate::lightning::events::HTLCDestination */ - LDKnativeFundingSigned *inner; + LDKCOption_HTLCDestinationZ_Some, /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * When we're in this state, this COption_HTLCDestinationZ contains nothing */ - bool is_owned; -} LDKFundingSigned; - + LDKCOption_HTLCDestinationZ_None, + /** + * Must be last for serialization purposes + */ + LDKCOption_HTLCDestinationZ_Sentinel, +} LDKCOption_HTLCDestinationZ_Tag; +typedef struct LDKCOption_HTLCDestinationZ { + LDKCOption_HTLCDestinationZ_Tag tag; + union { + struct { + struct LDKHTLCDestination some; + }; + }; +} LDKCOption_HTLCDestinationZ; /** - * A [`channel_ready`] message to be sent to or received from a peer. - * - * [`channel_ready`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-channel_ready-message + * The contents of CResult_COption_HTLCDestinationZDecodeErrorZ */ -typedef struct MUST_USE_STRUCT LDKChannelReady { +typedef union LDKCResult_COption_HTLCDestinationZDecodeErrorZPtr { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - LDKnativeChannelReady *inner; + struct LDKCOption_HTLCDestinationZ *result; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - bool is_owned; -} LDKChannelReady; - - + struct LDKDecodeError *err; +} LDKCResult_COption_HTLCDestinationZDecodeErrorZPtr; /** - * An [`announcement_signatures`] message to be sent to or received from a peer. - * - * [`announcement_signatures`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-announcement_signatures-message + * A CResult_COption_HTLCDestinationZDecodeErrorZ represents the result of a fallible operation, + * containing a crate::c_types::derived::COption_HTLCDestinationZ on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct MUST_USE_STRUCT LDKAnnouncementSignatures { +typedef struct LDKCResult_COption_HTLCDestinationZDecodeErrorZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The contents of this CResult_COption_HTLCDestinationZDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKnativeAnnouncementSignatures *inner; + union LDKCResult_COption_HTLCDestinationZDecodeErrorZPtr contents; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * Whether this CResult_COption_HTLCDestinationZDecodeErrorZ represents a success state. */ - bool is_owned; -} LDKAnnouncementSignatures; - - + bool result_ok; +} LDKCResult_COption_HTLCDestinationZDecodeErrorZ; /** - * Struct used to return values from [`RevokeAndACK`] messages, containing a bunch of commitment - * transaction updates if they were pending. + * The contents of CResult_PaymentFailureReasonDecodeErrorZ */ -typedef struct MUST_USE_STRUCT LDKCommitmentUpdate { +typedef union LDKCResult_PaymentFailureReasonDecodeErrorZPtr { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - LDKnativeCommitmentUpdate *inner; + enum LDKPaymentFailureReason *result; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - bool is_owned; -} LDKCommitmentUpdate; - - + struct LDKDecodeError *err; +} LDKCResult_PaymentFailureReasonDecodeErrorZPtr; /** - * A [`revoke_and_ack`] message to be sent to or received from a peer. - * - * [`revoke_and_ack`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#completing-the-transition-to-the-updated-state-revoke_and_ack + * A CResult_PaymentFailureReasonDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::events::PaymentFailureReason on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct MUST_USE_STRUCT LDKRevokeAndACK { +typedef struct LDKCResult_PaymentFailureReasonDecodeErrorZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The contents of this CResult_PaymentFailureReasonDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKnativeRevokeAndACK *inner; + union LDKCResult_PaymentFailureReasonDecodeErrorZPtr contents; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * Whether this CResult_PaymentFailureReasonDecodeErrorZ represents a success state. */ - bool is_owned; -} LDKRevokeAndACK; - - + bool result_ok; +} LDKCResult_PaymentFailureReasonDecodeErrorZ; /** - * A [`closing_signed`] message to be sent to or received from a peer. - * - * [`closing_signed`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#closing-negotiation-closing_signed + * An enum which can either contain a crate::c_types::U128 or not */ -typedef struct MUST_USE_STRUCT LDKClosingSigned { +typedef enum LDKCOption_u128Z_Tag { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * When we're in this state, this COption_u128Z contains a crate::c_types::U128 */ - LDKnativeClosingSigned *inner; + LDKCOption_u128Z_Some, /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * When we're in this state, this COption_u128Z contains nothing */ - bool is_owned; -} LDKClosingSigned; - + LDKCOption_u128Z_None, + /** + * Must be last for serialization purposes + */ + LDKCOption_u128Z_Sentinel, +} LDKCOption_u128Z_Tag; +typedef struct LDKCOption_u128Z { + LDKCOption_u128Z_Tag tag; + union { + struct { + struct LDKU128 some; + }; + }; +} LDKCOption_u128Z; /** - * A [`shutdown`] message to be sent to or received from a peer. - * - * [`shutdown`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#closing-initiation-shutdown + * An enum which can either contain a crate::lightning::events::PaymentFailureReason or not */ -typedef struct MUST_USE_STRUCT LDKShutdown { +typedef enum LDKCOption_PaymentFailureReasonZ_Tag { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * When we're in this state, this COption_PaymentFailureReasonZ contains a crate::lightning::events::PaymentFailureReason */ - LDKnativeShutdown *inner; + LDKCOption_PaymentFailureReasonZ_Some, /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * When we're in this state, this COption_PaymentFailureReasonZ contains nothing */ - bool is_owned; -} LDKShutdown; + 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; /** - * A [`channel_reestablish`] message to be sent to or received from a peer. + * Information about a spendable output to a P2WSH script. * - * [`channel_reestablish`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#message-retransmission + * See [`SpendableOutputDescriptor::DelayedPaymentOutput`] for more details on how to spend this. */ -typedef struct MUST_USE_STRUCT LDKChannelReestablish { +typedef struct MUST_USE_STRUCT LDKDelayedPaymentOutputDescriptor { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeChannelReestablish *inner; + LDKnativeDelayedPaymentOutputDescriptor *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKChannelReestablish; +} LDKDelayedPaymentOutputDescriptor; /** - * A [`channel_announcement`] message to be sent to or received from a peer. + * Information about a spendable output to our \"payment key\". * - * [`channel_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_announcement-message + * See [`SpendableOutputDescriptor::StaticPaymentOutput`] for more details on how to spend this. */ -typedef struct MUST_USE_STRUCT LDKChannelAnnouncement { +typedef struct MUST_USE_STRUCT LDKStaticPaymentOutputDescriptor { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeChannelAnnouncement *inner; + LDKnativeStaticPaymentOutputDescriptor *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKChannelAnnouncement; - - +} LDKStaticPaymentOutputDescriptor; /** - * A [`node_announcement`] message to be sent to or received from a peer. + * Describes the necessary information to spend a spendable output. * - * [`node_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-node_announcement-message + * When on-chain outputs are created by LDK (which our counterparty is not able to claim at any + * point in the future) a [`SpendableOutputs`] event is generated which you must track and be able + * to spend on-chain. The information needed to do this is provided in this enum, including the + * outpoint describing which `txid` and output `index` is available, the full output which exists + * at that `txid`/`index`, and any keys or other information required to sign. + * + * [`SpendableOutputs`]: crate::events::Event::SpendableOutputs */ -typedef struct MUST_USE_STRUCT LDKNodeAnnouncement { +typedef enum LDKSpendableOutputDescriptor_Tag { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * An output to a script which was provided via [`SignerProvider`] directly, either from + * [`get_destination_script`] or [`get_shutdown_scriptpubkey`], thus you should already + * know how to spend it. No secret keys are provided as LDK was never given any key. + * These may include outputs from a transaction punishing our counterparty or claiming an HTLC + * on-chain using the payment preimage or after it has timed out. + * + * [`get_shutdown_scriptpubkey`]: SignerProvider::get_shutdown_scriptpubkey + * [`get_destination_script`]: SignerProvider::get_shutdown_scriptpubkey */ - LDKnativeNodeAnnouncement *inner; + LDKSpendableOutputDescriptor_StaticOutput, /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * An output to a P2WSH script which can be spent with a single signature after an `OP_CSV` + * delay. + * + * The witness in the spending input should be: + * ```bitcoin + * (MINIMALIF standard rule) + * ``` + * + * Note that the `nSequence` field in the spending input must be set to + * [`DelayedPaymentOutputDescriptor::to_self_delay`] (which means the transaction is not + * broadcastable until at least [`DelayedPaymentOutputDescriptor::to_self_delay`] blocks after + * the outpoint confirms, see [BIP + * 68](https://github.com/bitcoin/bips/blob/master/bip-0068.mediawiki)). Also note that LDK + * won't generate a [`SpendableOutputDescriptor`] until the corresponding block height + * is reached. + * + * These are generally the result of a \"revocable\" output to us, spendable only by us unless + * it is an output from an old state which we broadcast (which should never happen). + * + * To derive the delayed payment key which is used to sign this input, you must pass the + * holder [`InMemorySigner::delayed_payment_base_key`] (i.e., the private key which corresponds to the + * [`ChannelPublicKeys::delayed_payment_basepoint`] in [`ChannelSigner::pubkeys`]) and the provided + * [`DelayedPaymentOutputDescriptor::per_commitment_point`] to [`chan_utils::derive_private_key`]. The public key can be + * generated without the secret key using [`chan_utils::derive_public_key`] and only the + * [`ChannelPublicKeys::delayed_payment_basepoint`] which appears in [`ChannelSigner::pubkeys`]. + * + * To derive the [`DelayedPaymentOutputDescriptor::revocation_pubkey`] provided here (which is + * used in the witness script generation), you must pass the counterparty + * [`ChannelPublicKeys::revocation_basepoint`] (which appears in the call to + * [`ChannelSigner::provide_channel_parameters`]) and the provided + * [`DelayedPaymentOutputDescriptor::per_commitment_point`] to + * [`chan_utils::derive_public_revocation_key`]. + * + * The witness script which is hashed and included in the output `script_pubkey` may be + * regenerated by passing the [`DelayedPaymentOutputDescriptor::revocation_pubkey`] (derived + * as explained above), our delayed payment pubkey (derived as explained above), and the + * [`DelayedPaymentOutputDescriptor::to_self_delay`] contained here to + * [`chan_utils::get_revokeable_redeemscript`]. */ - bool is_owned; -} LDKNodeAnnouncement; + LDKSpendableOutputDescriptor_DelayedPaymentOutput, + /** + * An output to a P2WPKH, spendable exclusively by our payment key (i.e., the private key + * which corresponds to the `payment_point` in [`ChannelSigner::pubkeys`]). The witness + * in the spending input is, thus, simply: + * ```bitcoin + * + * ``` + * + * These are generally the result of our counterparty having broadcast the current state, + * allowing us to claim the non-HTLC-encumbered outputs immediately. + */ + LDKSpendableOutputDescriptor_StaticPaymentOutput, + /** + * Must be last for serialization purposes + */ + LDKSpendableOutputDescriptor_Sentinel, +} LDKSpendableOutputDescriptor_Tag; +typedef struct LDKSpendableOutputDescriptor_LDKStaticOutput_Body { + /** + * The outpoint which is spendable. + */ + struct LDKOutPoint outpoint; + /** + * The output which is referenced by the given outpoint. + */ + struct LDKTxOut output; +} LDKSpendableOutputDescriptor_LDKStaticOutput_Body; +typedef struct MUST_USE_STRUCT LDKSpendableOutputDescriptor { + LDKSpendableOutputDescriptor_Tag tag; + union { + LDKSpendableOutputDescriptor_LDKStaticOutput_Body static_output; + struct { + struct LDKDelayedPaymentOutputDescriptor delayed_payment_output; + }; + struct { + struct LDKStaticPaymentOutputDescriptor static_payment_output; + }; + }; +} LDKSpendableOutputDescriptor; /** - * An [`error`] message to be sent to or received from a peer. - * - * [`error`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-error-and-warning-messages + * A dynamically-allocated array of crate::lightning::chain::keysinterface::SpendableOutputDescriptors of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef struct MUST_USE_STRUCT LDKErrorMessage { +typedef struct LDKCVec_SpendableOutputDescriptorZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - LDKnativeErrorMessage *inner; + struct LDKSpendableOutputDescriptor *data; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The number of elements pointed to by `data`. */ - bool is_owned; -} LDKErrorMessage; - - + uintptr_t datalen; +} LDKCVec_SpendableOutputDescriptorZ; /** - * A [`warning`] message to be sent to or received from a peer. + * An Event which you should probably take some action in response to. * - * [`warning`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-error-and-warning-messages + * Note that while Writeable and Readable are implemented for Event, you probably shouldn't use + * them directly as they don't round-trip exactly (for example FundingGenerationReady is never + * written as it makes no sense to respond to it after reconnecting to peers). */ -typedef struct MUST_USE_STRUCT LDKWarningMessage { +typedef enum LDKEvent_Tag { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * Used to indicate that the client should generate a funding transaction with the given + * parameters and then call [`ChannelManager::funding_transaction_generated`]. + * Generated in [`ChannelManager`] message handling. + * Note that *all inputs* in the funding transaction must spend SegWit outputs or your + * counterparty can steal your funds! + * + * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager + * [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated */ - LDKnativeWarningMessage *inner; + LDKEvent_FundingGenerationReady, /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * Indicates that we've been offered a payment and it needs to be claimed via calling + * [`ChannelManager::claim_funds`] with the preimage given in [`PaymentPurpose`]. + * + * Note that if the preimage is not known, you should call + * [`ChannelManager::fail_htlc_backwards`] or [`ChannelManager::fail_htlc_backwards_with_reason`] + * to free up resources for this HTLC and avoid network congestion. + * If you fail to call either [`ChannelManager::claim_funds`], [`ChannelManager::fail_htlc_backwards`], + * or [`ChannelManager::fail_htlc_backwards_with_reason`] within the HTLC's timeout, the HTLC will be + * automatically failed. + * + * # Note + * LDK will not stop an inbound payment from being paid multiple times, so multiple + * `PaymentClaimable` events may be generated for the same payment. In such a case it is + * polite (and required in the lightning specification) to fail the payment the second time + * and give the sender their money back rather than accepting double payment. + * + * # Note + * This event used to be called `PaymentReceived` in LDK versions 0.0.112 and earlier. + * + * [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds + * [`ChannelManager::fail_htlc_backwards`]: crate::ln::channelmanager::ChannelManager::fail_htlc_backwards + * [`ChannelManager::fail_htlc_backwards_with_reason`]: crate::ln::channelmanager::ChannelManager::fail_htlc_backwards_with_reason */ - bool is_owned; -} LDKWarningMessage; - -/** - * Used to put an error message in a [`LightningError`]. - */ -typedef enum LDKErrorAction_Tag { + LDKEvent_PaymentClaimable, /** - * The peer took some action which made us think they were useless. Disconnect them. + * Indicates a payment has been claimed and we've received money! + * + * This most likely occurs when [`ChannelManager::claim_funds`] has been called in response + * to an [`Event::PaymentClaimable`]. However, if we previously crashed during a + * [`ChannelManager::claim_funds`] call you may see this event without a corresponding + * [`Event::PaymentClaimable`] event. + * + * # Note + * LDK will not stop an inbound payment from being paid multiple times, so multiple + * `PaymentClaimable` events may be generated for the same payment. If you then call + * [`ChannelManager::claim_funds`] twice for the same [`Event::PaymentClaimable`] you may get + * multiple `PaymentClaimed` events. + * + * [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds */ - LDKErrorAction_DisconnectPeer, + LDKEvent_PaymentClaimed, /** - * The peer did something harmless that we weren't able to process, just log and ignore + * 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. */ - LDKErrorAction_IgnoreError, + LDKEvent_PaymentSent, /** - * The peer did something harmless that we weren't able to meaningfully process. - * If the error is logged, log it at the given level. + * Indicates an outbound payment failed. Individual [`Event::PaymentPathFailed`] events + * provide failure information for each path attempt in the payment, including retries. + * + * This event is provided once there are no further pending HTLCs for the payment and the + * payment is no longer retryable, due either to the [`Retry`] provided or + * [`ChannelManager::abandon_payment`] having been called for the corresponding payment. + * + * [`Retry`]: crate::ln::channelmanager::Retry + * [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment */ - LDKErrorAction_IgnoreAndLog, + LDKEvent_PaymentFailed, /** - * The peer provided us with a gossip message which we'd already seen. In most cases this - * should be ignored, but it may result in the message being forwarded if it is a duplicate of - * our own channel announcements. + * 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. */ - LDKErrorAction_IgnoreDuplicateGossip, + LDKEvent_PaymentPathSuccessful, /** - * The peer did something incorrect. Tell them. + * Indicates an outbound HTLC we sent failed, likely due to an intermediary node being unable to + * handle the HTLC. + * + * Note that this does *not* indicate that all paths for an MPP payment have failed, see + * [`Event::PaymentFailed`]. + * + * See [`ChannelManager::abandon_payment`] for giving up on this payment before its retries have + * been exhausted. + * + * [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment */ - LDKErrorAction_SendErrorMessage, + LDKEvent_PaymentPathFailed, /** - * The peer did something incorrect. Tell them without closing any channels. + * Indicates that a probe payment we sent returned successful, i.e., only failed at the destination. */ - LDKErrorAction_SendWarningMessage, + LDKEvent_ProbeSuccessful, + /** + * Indicates that a probe payment we sent failed at an intermediary node on the path. + */ + LDKEvent_ProbeFailed, + /** + * Used to indicate that [`ChannelManager::process_pending_htlc_forwards`] should be called at + * a time in the future. + * + * [`ChannelManager::process_pending_htlc_forwards`]: crate::ln::channelmanager::ChannelManager::process_pending_htlc_forwards + */ + LDKEvent_PendingHTLCsForwardable, + /** + * Used to indicate that we've intercepted an HTLC forward. This event will only be generated if + * you've encoded an intercept scid in the receiver's invoice route hints using + * [`ChannelManager::get_intercept_scid`] and have set [`UserConfig::accept_intercept_htlcs`]. + * + * [`ChannelManager::forward_intercepted_htlc`] or + * [`ChannelManager::fail_intercepted_htlc`] MUST be called in response to this event. See + * their docs for more information. + * + * [`ChannelManager::get_intercept_scid`]: crate::ln::channelmanager::ChannelManager::get_intercept_scid + * [`UserConfig::accept_intercept_htlcs`]: crate::util::config::UserConfig::accept_intercept_htlcs + * [`ChannelManager::forward_intercepted_htlc`]: crate::ln::channelmanager::ChannelManager::forward_intercepted_htlc + * [`ChannelManager::fail_intercepted_htlc`]: crate::ln::channelmanager::ChannelManager::fail_intercepted_htlc + */ + LDKEvent_HTLCIntercepted, + /** + * Used to indicate that an output which you should know how to spend was confirmed on chain + * and is now spendable. + * Such an output will *not* ever be spent by rust-lightning, and are not at risk of your + * counterparty spending them due to some kind of timeout. Thus, you need to store them + * somewhere and spend them when you create on-chain transactions. + */ + LDKEvent_SpendableOutputs, + /** + * This event is generated when a payment has been successfully forwarded through us and a + * forwarding fee earned. + */ + LDKEvent_PaymentForwarded, + /** + * Used to indicate that a channel with the given `channel_id` is being opened and pending + * confirmation on-chain. + * + * This event is emitted when the funding transaction has been signed and is broadcast to the + * network. For 0conf channels it will be immediately followed by the corresponding + * [`Event::ChannelReady`] event. + */ + LDKEvent_ChannelPending, + /** + * 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. + */ + LDKEvent_ChannelReady, + /** + * Used to indicate that a previously opened channel with the given `channel_id` is in the + * process of closure. + */ + LDKEvent_ChannelClosed, + /** + * Used to indicate to the user that they can abandon the funding transaction and recycle the + * inputs for another purpose. + */ + LDKEvent_DiscardFunding, + /** + * Indicates a request to open a new channel by a peer. + * + * To accept the request, call [`ChannelManager::accept_inbound_channel`]. To reject the + * request, call [`ChannelManager::force_close_without_broadcasting_txn`]. + * + * The event is only triggered when a new open channel request is received and the + * [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. + * + * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel + * [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn + * [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels + */ + LDKEvent_OpenChannelRequest, + /** + * Indicates that the HTLC was accepted, but could not be processed when or after attempting to + * forward it. + * + * Some scenarios where this event may be sent include: + * * Insufficient capacity in the outbound channel + * * While waiting to forward the HTLC, the channel it is meant to be forwarded through closes + * * When an unknown SCID is requested for forwarding a payment. + * * Expected MPP amount has already been reached + * * The HTLC has timed out + * + * This event, however, does not get generated if an HTLC fails to meet the forwarding + * requirements (i.e. insufficient fees paid, or a CLTV that is too soon). + */ + LDKEvent_HTLCHandlingFailed, /** * Must be last for serialization purposes */ - LDKErrorAction_Sentinel, -} LDKErrorAction_Tag; + LDKEvent_Sentinel, +} LDKEvent_Tag; -typedef struct LDKErrorAction_LDKDisconnectPeer_Body { +typedef struct LDKEvent_LDKFundingGenerationReady_Body { /** - * An error message which we should make an effort to send before we disconnect. + * The random channel_id we picked which you'll need to pass into + * [`ChannelManager::funding_transaction_generated`]. + * + * [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated + */ + struct LDKThirtyTwoBytes temporary_channel_id; + /** + * The counterparty's node_id, which you'll need to pass back into + * [`ChannelManager::funding_transaction_generated`]. * - * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + * [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated */ - struct LDKErrorMessage msg; -} LDKErrorAction_LDKDisconnectPeer_Body; - -typedef struct LDKErrorAction_LDKSendErrorMessage_Body { + struct LDKPublicKey counterparty_node_id; /** - * The message to send. + * The value, in satoshis, that the output should have. */ - struct LDKErrorMessage msg; -} LDKErrorAction_LDKSendErrorMessage_Body; - -typedef struct LDKErrorAction_LDKSendWarningMessage_Body { + uint64_t channel_value_satoshis; /** - * The message to send. + * The script which should be used in the transaction output. */ - struct LDKWarningMessage msg; + struct LDKCVec_u8Z output_script; /** - * The peer may have done something harmless that we weren't able to meaningfully process, - * though we should still tell them about it. - * If this event is logged, log it at the given level. + * The `user_channel_id` value passed in to [`ChannelManager::create_channel`], or a + * random value for an inbound channel. This may be zero for objects serialized with LDK + * versions prior to 0.0.113. + * + * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel */ - enum LDKLevel log_level; -} LDKErrorAction_LDKSendWarningMessage_Body; - -typedef struct MUST_USE_STRUCT LDKErrorAction { - LDKErrorAction_Tag tag; - union { - LDKErrorAction_LDKDisconnectPeer_Body disconnect_peer; - struct { - enum LDKLevel ignore_and_log; - }; - LDKErrorAction_LDKSendErrorMessage_Body send_error_message; - LDKErrorAction_LDKSendWarningMessage_Body send_warning_message; - }; -} LDKErrorAction; - - + struct LDKU128 user_channel_id; +} LDKEvent_LDKFundingGenerationReady_Body; -/** - * A [`query_channel_range`] message is used to query a peer for channel - * UTXOs in a range of blocks. The recipient of a query makes a best - * effort to reply to the query using one or more [`ReplyChannelRange`] - * messages. - * - * [`query_channel_range`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-query_channel_range-and-reply_channel_range-messages - */ -typedef struct MUST_USE_STRUCT LDKQueryChannelRange { +typedef struct LDKEvent_LDKPaymentClaimable_Body { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The node that will receive the payment after it has been claimed. + * This is useful to identify payments received via [phantom nodes]. + * This field will always be filled in when the event was generated by LDK versions + * 0.0.113 and above. + * + * [phantom nodes]: crate::chain::keysinterface::PhantomKeysManager + * + * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None */ - LDKnativeQueryChannelRange *inner; + struct LDKPublicKey receiver_node_id; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The hash for which the preimage should be handed to the ChannelManager. Note that LDK will + * not stop you from registering duplicate payment hashes for inbound payments. */ - bool is_owned; -} LDKQueryChannelRange; - - - -/** - * A [`query_short_channel_ids`] message is used to query a peer for - * routing gossip messages related to one or more `short_channel_id`s. - * - * The query recipient will reply with the latest, if available, - * [`ChannelAnnouncement`], [`ChannelUpdate`] and [`NodeAnnouncement`] messages - * it maintains for the requested `short_channel_id`s followed by a - * [`ReplyShortChannelIdsEnd`] message. The `short_channel_id`s sent in - * this query are encoded. We only support `encoding_type=0` uncompressed - * serialization and do not support `encoding_type=1` zlib serialization. - * - * [`query_short_channel_ids`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-query_short_channel_idsreply_short_channel_ids_end-messages - */ -typedef struct MUST_USE_STRUCT LDKQueryShortChannelIds { + struct LDKThirtyTwoBytes payment_hash; /** - * A pointer to the opaque Rust object. - * Nearly everywhere, 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 fields in the onion which were received with each HTLC. Only fields which were + * identical in each HTLC involved in the payment will be included here. + * + * Payments received on LDK versions prior to 0.0.115 will have this field unset. + * + * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None */ - LDKnativeQueryShortChannelIds *inner; + struct LDKRecipientOnionFields onion_fields; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust 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 value, in thousandths of a satoshi, that this payment is for. */ - bool is_owned; -} LDKQueryShortChannelIds; - - - -/** - * A [`reply_channel_range`] message is a reply to a [`QueryChannelRange`] - * message. - * - * Multiple `reply_channel_range` messages can be sent in reply - * to a single [`QueryChannelRange`] message. The query recipient makes a - * best effort to respond based on their local network view which may - * not be a perfect view of the network. The `short_channel_id`s in the - * reply are encoded. We only support `encoding_type=0` uncompressed - * serialization and do not support `encoding_type=1` zlib serialization. - * - * [`reply_channel_range`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-query_channel_range-and-reply_channel_range-messages - */ -typedef struct MUST_USE_STRUCT LDKReplyChannelRange { + uint64_t amount_msat; /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * Information for claiming this received payment, based on whether the purpose of the + * payment is to pay an invoice or to send a spontaneous payment. */ - LDKnativeReplyChannelRange *inner; + struct LDKPaymentPurpose purpose; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The `channel_id` indicating over which channel we received the payment. + * + * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None */ - bool is_owned; -} LDKReplyChannelRange; - - - -/** - * A [`gossip_timestamp_filter`] message is used by a node to request - * gossip relay for messages in the requested time range when the - * `gossip_queries` feature has been negotiated. - * - * [`gossip_timestamp_filter`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-gossip_timestamp_filter-message - */ -typedef struct MUST_USE_STRUCT LDKGossipTimestampFilter { + struct LDKThirtyTwoBytes via_channel_id; /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The `user_channel_id` indicating over which channel we received the payment. */ - LDKnativeGossipTimestampFilter *inner; + struct LDKCOption_u128Z via_user_channel_id; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The block height at which this payment will be failed back and will no longer be + * eligible for claiming. + * + * Prior to this height, a call to [`ChannelManager::claim_funds`] is guaranteed to + * succeed, however you should wait for [`Event::PaymentClaimed`] to be sure. + * + * [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds */ - bool is_owned; -} LDKGossipTimestampFilter; + struct LDKCOption_u32Z claim_deadline; +} LDKEvent_LDKPaymentClaimable_Body; -/** - * An event generated by ChannelManager which indicates a message should be sent to a peer (or - * broadcast to most peers). - * These events are handled by PeerManager::process_events if you are using a PeerManager. - */ -typedef enum LDKMessageSendEvent_Tag { +typedef struct LDKEvent_LDKPaymentClaimed_Body { /** - * Used to indicate that we've accepted a channel open and should send the accept_channel - * message provided to the given peer. + * The node that received the payment. + * This is useful to identify payments which were received via [phantom nodes]. + * This field will always be filled in when the event was generated by LDK versions + * 0.0.113 and above. + * + * [phantom nodes]: crate::chain::keysinterface::PhantomKeysManager + * + * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None */ - LDKMessageSendEvent_SendAcceptChannel, + struct LDKPublicKey receiver_node_id; /** - * Used to indicate that we've initiated a channel open and should send the open_channel - * message provided to the given peer. + * The payment hash of the claimed payment. Note that LDK will not stop you from + * registering duplicate payment hashes for inbound payments. */ - LDKMessageSendEvent_SendOpenChannel, + struct LDKThirtyTwoBytes payment_hash; /** - * Used to indicate that a funding_created message should be sent to the peer with the given node_id. + * The value, in thousandths of a satoshi, that this payment is for. */ - LDKMessageSendEvent_SendFundingCreated, + uint64_t amount_msat; /** - * Used to indicate that a funding_signed message should be sent to the peer with the given node_id. + * The purpose of the claimed payment, i.e. whether the payment was for an invoice or a + * spontaneous payment. */ - LDKMessageSendEvent_SendFundingSigned, + struct LDKPaymentPurpose purpose; +} LDKEvent_LDKPaymentClaimed_Body; + +typedef struct LDKEvent_LDKPaymentSent_Body { /** - * Used to indicate that a channel_ready message should be sent to the peer with the given node_id. + * The `payment_id` passed to [`ChannelManager::send_payment`]. + * + * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment + * + * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None */ - LDKMessageSendEvent_SendChannelReady, + struct LDKThirtyTwoBytes payment_id; /** - * Used to indicate that an announcement_signatures message should be sent to the peer with the given node_id. + * The preimage to the hash given to ChannelManager::send_payment. + * Note that this serves as a payment receipt, if you wish to have such a thing, you must + * store it somehow! */ - LDKMessageSendEvent_SendAnnouncementSignatures, + struct LDKThirtyTwoBytes payment_preimage; /** - * Used to indicate that a series of HTLC update messages, as well as a commitment_signed - * message should be sent to the peer with the given node_id. + * The hash that was given to [`ChannelManager::send_payment`]. + * + * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment */ - LDKMessageSendEvent_UpdateHTLCs, + struct LDKThirtyTwoBytes payment_hash; /** - * Used to indicate that a revoke_and_ack message should be sent to the peer with the given node_id. + * The total fee which was spent at intermediate hops in this payment, across all paths. + * + * Note that, like [`Route::get_total_fees`] this does *not* include any potential + * overpayment to the recipient node. + * + * If the recipient or an intermediate node misbehaves and gives us free money, this may + * overstate the amount paid, though this is unlikely. + * + * [`Route::get_total_fees`]: crate::routing::router::Route::get_total_fees */ - LDKMessageSendEvent_SendRevokeAndACK, + struct LDKCOption_u64Z fee_paid_msat; +} LDKEvent_LDKPaymentSent_Body; + +typedef struct LDKEvent_LDKPaymentFailed_Body { /** - * Used to indicate that a closing_signed message should be sent to the peer with the given node_id. + * The `payment_id` passed to [`ChannelManager::send_payment`]. + * + * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment */ - LDKMessageSendEvent_SendClosingSigned, + struct LDKThirtyTwoBytes payment_id; /** - * Used to indicate that a shutdown message should be sent to the peer with the given node_id. + * The hash that was given to [`ChannelManager::send_payment`]. + * + * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment */ - LDKMessageSendEvent_SendShutdown, + struct LDKThirtyTwoBytes payment_hash; /** - * Used to indicate that a channel_reestablish message should be sent to the peer with the given node_id. + * The reason the payment failed. This is only `None` for events generated or serialized + * by versions prior to 0.0.115. */ - LDKMessageSendEvent_SendChannelReestablish, + struct LDKCOption_PaymentFailureReasonZ reason; +} LDKEvent_LDKPaymentFailed_Body; + +typedef struct LDKEvent_LDKPaymentPathSuccessful_Body { /** - * Used to send a channel_announcement and channel_update to a specific peer, likely on - * initial connection to ensure our peers know about our channels. + * The `payment_id` passed to [`ChannelManager::send_payment`]. + * + * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment */ - LDKMessageSendEvent_SendChannelAnnouncement, + struct LDKThirtyTwoBytes payment_id; /** - * Used to indicate that a channel_announcement and channel_update should be broadcast to all - * peers (except the peer with node_id either msg.contents.node_id_1 or msg.contents.node_id_2). + * The hash that was given to [`ChannelManager::send_payment`]. * - * Note that after doing so, you very likely (unless you did so very recently) want to - * broadcast a node_announcement (e.g. via [`PeerManager::broadcast_node_announcement`]). This - * ensures that any nodes which see our channel_announcement also have a relevant - * node_announcement, including relevant feature flags which may be important for routing - * through or to us. + * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment * - * [`PeerManager::broadcast_node_announcement`]: crate::ln::peer_handler::PeerManager::broadcast_node_announcement - */ - LDKMessageSendEvent_BroadcastChannelAnnouncement, - /** - * Used to indicate that a channel_update should be broadcast to all peers. - */ - LDKMessageSendEvent_BroadcastChannelUpdate, - /** - * Used to indicate that a node_announcement should be broadcast to all peers. + * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None */ - LDKMessageSendEvent_BroadcastNodeAnnouncement, + struct LDKThirtyTwoBytes payment_hash; /** - * Used to indicate that a channel_update should be sent to a single peer. - * In contrast to [`Self::BroadcastChannelUpdate`], this is used when the channel is a - * private channel and we shouldn't be informing all of our peers of channel parameters. + * The payment path that was successful. + * + * May contain a closed channel if the HTLC sent along the path was fulfilled on chain. */ - LDKMessageSendEvent_SendChannelUpdate, + struct LDKPath path; +} LDKEvent_LDKPaymentPathSuccessful_Body; + +typedef struct LDKEvent_LDKPaymentPathFailed_Body { /** - * Broadcast an error downstream to be handled + * The `payment_id` passed to [`ChannelManager::send_payment`]. + * + * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment + * [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment + * + * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None */ - LDKMessageSendEvent_HandleError, + struct LDKThirtyTwoBytes payment_id; /** - * Query a peer for channels with funding transaction UTXOs in a block range. + * The hash that was given to [`ChannelManager::send_payment`]. + * + * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment */ - LDKMessageSendEvent_SendChannelRangeQuery, + struct LDKThirtyTwoBytes payment_hash; /** - * Request routing gossip messages from a peer for a list of channels identified by - * their short_channel_ids. + * Indicates the payment was rejected for some reason by the recipient. This implies that + * the payment has failed, not just the route in question. If this is not set, the payment may + * be retried via a different route. */ - LDKMessageSendEvent_SendShortIdsQuery, + bool payment_failed_permanently; /** - * Sends a reply to a channel range query. This may be one of several SendReplyChannelRange events - * emitted during processing of the query. + * Extra error details based on the failure type. May contain an update that needs to be + * applied to the [`NetworkGraph`]. + * + * [`NetworkGraph`]: crate::routing::gossip::NetworkGraph */ - LDKMessageSendEvent_SendReplyChannelRange, + struct LDKPathFailure failure; /** - * Sends a timestamp filter for inbound gossip. This should be sent on each new connection to - * enable receiving gossip messages from the peer. + * The payment path that failed. */ - LDKMessageSendEvent_SendGossipTimestampFilter, + struct LDKPath path; /** - * Must be last for serialization purposes + * The channel responsible for the failed payment path. + * + * Note that for route hints or for the first hop in a path this may be an SCID alias and + * may not refer to a channel in the public network graph. These aliases may also collide + * with channels in the public network graph. + * + * If this is `Some`, then the corresponding channel should be avoided when the payment is + * retried. May be `None` for older [`Event`] serializations. */ - LDKMessageSendEvent_Sentinel, -} LDKMessageSendEvent_Tag; + struct LDKCOption_u64Z short_channel_id; +} LDKEvent_LDKPaymentPathFailed_Body; -typedef struct LDKMessageSendEvent_LDKSendAcceptChannel_Body { - /** - * The node_id of the node which should receive this message - */ - struct LDKPublicKey node_id; +typedef struct LDKEvent_LDKProbeSuccessful_Body { /** - * The message which should be sent. + * The id returned by [`ChannelManager::send_probe`]. + * + * [`ChannelManager::send_probe`]: crate::ln::channelmanager::ChannelManager::send_probe */ - struct LDKAcceptChannel msg; -} LDKMessageSendEvent_LDKSendAcceptChannel_Body; - -typedef struct LDKMessageSendEvent_LDKSendOpenChannel_Body { + struct LDKThirtyTwoBytes payment_id; /** - * The node_id of the node which should receive this message + * The hash generated by [`ChannelManager::send_probe`]. + * + * [`ChannelManager::send_probe`]: crate::ln::channelmanager::ChannelManager::send_probe */ - struct LDKPublicKey node_id; + struct LDKThirtyTwoBytes payment_hash; /** - * The message which should be sent. + * The payment path that was successful. */ - struct LDKOpenChannel msg; -} LDKMessageSendEvent_LDKSendOpenChannel_Body; + struct LDKPath path; +} LDKEvent_LDKProbeSuccessful_Body; -typedef struct LDKMessageSendEvent_LDKSendFundingCreated_Body { +typedef struct LDKEvent_LDKProbeFailed_Body { /** - * The node_id of the node which should receive this message + * The id returned by [`ChannelManager::send_probe`]. + * + * [`ChannelManager::send_probe`]: crate::ln::channelmanager::ChannelManager::send_probe */ - struct LDKPublicKey node_id; + struct LDKThirtyTwoBytes payment_id; /** - * The message which should be sent. + * The hash generated by [`ChannelManager::send_probe`]. + * + * [`ChannelManager::send_probe`]: crate::ln::channelmanager::ChannelManager::send_probe */ - struct LDKFundingCreated msg; -} LDKMessageSendEvent_LDKSendFundingCreated_Body; - -typedef struct LDKMessageSendEvent_LDKSendFundingSigned_Body { + struct LDKThirtyTwoBytes payment_hash; /** - * The node_id of the node which should receive this message + * The payment path that failed. */ - struct LDKPublicKey node_id; + struct LDKPath path; /** - * The message which should be sent. + * The channel responsible for the failed probe. + * + * Note that for route hints or for the first hop in a path this may be an SCID alias and + * may not refer to a channel in the public network graph. These aliases may also collide + * with channels in the public network graph. */ - struct LDKFundingSigned msg; -} LDKMessageSendEvent_LDKSendFundingSigned_Body; + struct LDKCOption_u64Z short_channel_id; +} LDKEvent_LDKProbeFailed_Body; -typedef struct LDKMessageSendEvent_LDKSendChannelReady_Body { +typedef struct LDKEvent_LDKPendingHTLCsForwardable_Body { /** - * The node_id of the node which should receive these message(s) + * The minimum amount of time that should be waited prior to calling + * process_pending_htlc_forwards. To increase the effort required to correlate payments, + * you should wait a random amount of time in roughly the range (now + time_forwardable, + * now + 5*time_forwardable). */ - struct LDKPublicKey node_id; + uint64_t time_forwardable; +} LDKEvent_LDKPendingHTLCsForwardable_Body; + +typedef struct LDKEvent_LDKHTLCIntercepted_Body { /** - * The channel_ready message which should be sent. + * An id to help LDK identify which HTLC is being forwarded or failed. */ - struct LDKChannelReady msg; -} LDKMessageSendEvent_LDKSendChannelReady_Body; - -typedef struct LDKMessageSendEvent_LDKSendAnnouncementSignatures_Body { + struct LDKThirtyTwoBytes intercept_id; /** - * The node_id of the node which should receive these message(s) + * The fake scid that was programmed as the next hop's scid, generated using + * [`ChannelManager::get_intercept_scid`]. + * + * [`ChannelManager::get_intercept_scid`]: crate::ln::channelmanager::ChannelManager::get_intercept_scid */ - struct LDKPublicKey node_id; + uint64_t requested_next_hop_scid; /** - * The announcement_signatures message which should be sent. + * The payment hash used for this HTLC. */ - struct LDKAnnouncementSignatures msg; -} LDKMessageSendEvent_LDKSendAnnouncementSignatures_Body; - -typedef struct LDKMessageSendEvent_LDKUpdateHTLCs_Body { + struct LDKThirtyTwoBytes payment_hash; /** - * The node_id of the node which should receive these message(s) + * How many msats were received on the inbound edge of this HTLC. */ - struct LDKPublicKey node_id; + uint64_t inbound_amount_msat; /** - * The update messages which should be sent. ALL messages in the struct should be sent! + * How many msats the payer intended to route to the next node. Depending on the reason you are + * intercepting this payment, you might take a fee by forwarding less than this amount. + * + * Note that LDK will NOT check that expected fees were factored into this value. You MUST + * check that whatever fee you want has been included here or subtract it as required. Further, + * LDK will not stop you from forwarding more than you received. */ - struct LDKCommitmentUpdate updates; -} LDKMessageSendEvent_LDKUpdateHTLCs_Body; + uint64_t expected_outbound_amount_msat; +} LDKEvent_LDKHTLCIntercepted_Body; -typedef struct LDKMessageSendEvent_LDKSendRevokeAndACK_Body { +typedef struct LDKEvent_LDKSpendableOutputs_Body { /** - * The node_id of the node which should receive this message + * The outputs which you should store as spendable by you. */ - struct LDKPublicKey node_id; + struct LDKCVec_SpendableOutputDescriptorZ outputs; +} LDKEvent_LDKSpendableOutputs_Body; + +typedef struct LDKEvent_LDKPaymentForwarded_Body { /** - * The message which should be sent. + * The incoming channel between the previous node and us. This is only `None` for events + * generated or serialized by versions prior to 0.0.107. + * + * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None */ - struct LDKRevokeAndACK msg; -} LDKMessageSendEvent_LDKSendRevokeAndACK_Body; - -typedef struct LDKMessageSendEvent_LDKSendClosingSigned_Body { + struct LDKThirtyTwoBytes prev_channel_id; /** - * The node_id of the node which should receive this message + * The outgoing channel between the next node and us. This is only `None` for events + * generated or serialized by versions prior to 0.0.107. + * + * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None */ - struct LDKPublicKey node_id; + struct LDKThirtyTwoBytes next_channel_id; /** - * The message which should be sent. + * The fee, in milli-satoshis, which was earned as a result of the payment. + * + * Note that if we force-closed the channel over which we forwarded an HTLC while the HTLC + * was pending, the amount the next hop claimed will have been rounded down to the nearest + * whole satoshi. Thus, the fee calculated here may be higher than expected as we still + * claimed the full value in millisatoshis from the source. In this case, + * `claim_from_onchain_tx` will be set. + * + * If the channel which sent us the payment has been force-closed, we will claim the funds + * via an on-chain transaction. In that case we do not yet know the on-chain transaction + * fees which we will spend and will instead set this to `None`. It is possible duplicate + * `PaymentForwarded` events are generated for the same payment iff `fee_earned_msat` is + * `None`. */ - struct LDKClosingSigned msg; -} LDKMessageSendEvent_LDKSendClosingSigned_Body; - -typedef struct LDKMessageSendEvent_LDKSendShutdown_Body { + struct LDKCOption_u64Z fee_earned_msat; /** - * The node_id of the node which should receive this message + * If this is `true`, the forwarded HTLC was claimed by our counterparty via an on-chain + * transaction. */ - struct LDKPublicKey node_id; + bool claim_from_onchain_tx; /** - * The message which should be sent. + * The final amount forwarded, in milli-satoshis, after the fee is deducted. + * + * The caveat described above the `fee_earned_msat` field applies here as well. */ - struct LDKShutdown msg; -} LDKMessageSendEvent_LDKSendShutdown_Body; + struct LDKCOption_u64Z outbound_amount_forwarded_msat; +} LDKEvent_LDKPaymentForwarded_Body; -typedef struct LDKMessageSendEvent_LDKSendChannelReestablish_Body { +typedef struct LDKEvent_LDKChannelPending_Body { /** - * The node_id of the node which should receive this message + * The `channel_id` of the channel that is pending confirmation. */ - struct LDKPublicKey node_id; + struct LDKThirtyTwoBytes channel_id; /** - * The message which should be sent. - */ - struct LDKChannelReestablish msg; -} LDKMessageSendEvent_LDKSendChannelReestablish_Body; - -typedef struct LDKMessageSendEvent_LDKSendChannelAnnouncement_Body { + * The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound + * channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if + * [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise + * `user_channel_id` will be randomized for an inbound channel. + * + * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel + * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel + * [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels + */ + struct LDKU128 user_channel_id; /** - * The node_id of the node which should receive this message + * The `temporary_channel_id` this channel used to be known by during channel establishment. + * + * Will be `None` for channels created prior to LDK version 0.0.115. + * + * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None */ - struct LDKPublicKey node_id; + struct LDKThirtyTwoBytes former_temporary_channel_id; /** - * The channel_announcement which should be sent. + * The `node_id` of the channel counterparty. */ - struct LDKChannelAnnouncement msg; + struct LDKPublicKey counterparty_node_id; /** - * The followup channel_update which should be sent. + * The outpoint of the channel's funding transaction. */ - struct LDKChannelUpdate update_msg; -} LDKMessageSendEvent_LDKSendChannelAnnouncement_Body; + struct LDKOutPoint funding_txo; +} LDKEvent_LDKChannelPending_Body; -typedef struct LDKMessageSendEvent_LDKBroadcastChannelAnnouncement_Body { +typedef struct LDKEvent_LDKChannelReady_Body { /** - * The channel_announcement which should be sent. + * The `channel_id` of the channel that is ready. */ - struct LDKChannelAnnouncement msg; + struct LDKThirtyTwoBytes channel_id; /** - * The followup channel_update which should be sent. + * The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound + * channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if + * [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise + * `user_channel_id` will be randomized for an inbound channel. * - * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel + * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel + * [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels */ - struct LDKChannelUpdate update_msg; -} LDKMessageSendEvent_LDKBroadcastChannelAnnouncement_Body; - -typedef struct LDKMessageSendEvent_LDKBroadcastChannelUpdate_Body { + struct LDKU128 user_channel_id; /** - * The channel_update which should be sent. + * The `node_id` of the channel counterparty. */ - struct LDKChannelUpdate msg; -} LDKMessageSendEvent_LDKBroadcastChannelUpdate_Body; - -typedef struct LDKMessageSendEvent_LDKBroadcastNodeAnnouncement_Body { + struct LDKPublicKey counterparty_node_id; /** - * The node_announcement which should be sent. + * The features that this channel will operate with. */ - struct LDKNodeAnnouncement msg; -} LDKMessageSendEvent_LDKBroadcastNodeAnnouncement_Body; + struct LDKChannelTypeFeatures channel_type; +} LDKEvent_LDKChannelReady_Body; -typedef struct LDKMessageSendEvent_LDKSendChannelUpdate_Body { +typedef struct LDKEvent_LDKChannelClosed_Body { /** - * The node_id of the node which should receive this message + * The `channel_id` of the channel which has been closed. Note that on-chain transactions + * resolving the channel are likely still awaiting confirmation. */ - struct LDKPublicKey node_id; + struct LDKThirtyTwoBytes channel_id; /** - * The channel_update which should be sent. + * The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound + * channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if + * [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise + * `user_channel_id` will be randomized for inbound channels. + * This may be zero for inbound channels serialized prior to 0.0.113 and will always be + * zero for objects serialized with LDK versions prior to 0.0.102. + * + * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel + * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel + * [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels */ - struct LDKChannelUpdate msg; -} LDKMessageSendEvent_LDKSendChannelUpdate_Body; + struct LDKU128 user_channel_id; + /** + * The reason the channel was closed. + */ + struct LDKClosureReason reason; +} LDKEvent_LDKChannelClosed_Body; -typedef struct LDKMessageSendEvent_LDKHandleError_Body { +typedef struct LDKEvent_LDKDiscardFunding_Body { /** - * The node_id of the node which should receive this message + * The channel_id of the channel which has been closed. */ - struct LDKPublicKey node_id; + struct LDKThirtyTwoBytes channel_id; /** - * The action which should be taken. + * The full transaction received from the user */ - struct LDKErrorAction action; -} LDKMessageSendEvent_LDKHandleError_Body; + struct LDKTransaction transaction; +} LDKEvent_LDKDiscardFunding_Body; -typedef struct LDKMessageSendEvent_LDKSendChannelRangeQuery_Body { +typedef struct LDKEvent_LDKOpenChannelRequest_Body { /** - * The node_id of this message recipient + * The temporary channel ID of the channel requested to be opened. + * + * When responding to the request, the `temporary_channel_id` should be passed + * back to the ChannelManager through [`ChannelManager::accept_inbound_channel`] to accept, + * or through [`ChannelManager::force_close_without_broadcasting_txn`] to reject. + * + * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel + * [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn */ - struct LDKPublicKey node_id; + struct LDKThirtyTwoBytes temporary_channel_id; /** - * The query_channel_range which should be sent. + * The node_id of the counterparty requesting to open the channel. + * + * When responding to the request, the `counterparty_node_id` should be passed + * back to the `ChannelManager` through [`ChannelManager::accept_inbound_channel`] to + * accept the request, or through [`ChannelManager::force_close_without_broadcasting_txn`] to reject the + * request. + * + * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel + * [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn */ - struct LDKQueryChannelRange msg; -} LDKMessageSendEvent_LDKSendChannelRangeQuery_Body; - -typedef struct LDKMessageSendEvent_LDKSendShortIdsQuery_Body { + struct LDKPublicKey counterparty_node_id; /** - * The node_id of this message recipient + * The channel value of the requested channel. */ - struct LDKPublicKey node_id; + uint64_t funding_satoshis; /** - * The query_short_channel_ids which should be sent. + * Our starting balance in the channel if the request is accepted, in milli-satoshi. */ - struct LDKQueryShortChannelIds msg; -} LDKMessageSendEvent_LDKSendShortIdsQuery_Body; + uint64_t push_msat; + /** + * The features that this channel will operate with. If you reject the channel, a + * well-behaved counterparty may automatically re-attempt the channel with a new set of + * feature flags. + * + * Note that if [`ChannelTypeFeatures::supports_scid_privacy`] returns true on this type, + * the resulting [`ChannelManager`] will not be readable by versions of LDK prior to + * 0.0.106. + * + * Furthermore, note that if [`ChannelTypeFeatures::supports_zero_conf`] returns true on this type, + * the resulting [`ChannelManager`] will not be readable by versions of LDK prior to + * 0.0.107. Channels setting this type also need to get manually accepted via + * [`crate::ln::channelmanager::ChannelManager::accept_inbound_channel_from_trusted_peer_0conf`], + * or will be rejected otherwise. + * + * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager + */ + struct LDKChannelTypeFeatures channel_type; +} LDKEvent_LDKOpenChannelRequest_Body; -typedef struct LDKMessageSendEvent_LDKSendReplyChannelRange_Body { +typedef struct LDKEvent_LDKHTLCHandlingFailed_Body { /** - * The node_id of this message recipient + * The channel over which the HTLC was received. */ - struct LDKPublicKey node_id; + struct LDKThirtyTwoBytes prev_channel_id; /** - * The reply_channel_range which should be sent. + * Destination of the HTLC that failed to be processed. */ - struct LDKReplyChannelRange msg; -} LDKMessageSendEvent_LDKSendReplyChannelRange_Body; + struct LDKHTLCDestination failed_next_destination; +} LDKEvent_LDKHTLCHandlingFailed_Body; -typedef struct LDKMessageSendEvent_LDKSendGossipTimestampFilter_Body { +typedef struct MUST_USE_STRUCT LDKEvent { + LDKEvent_Tag tag; + union { + LDKEvent_LDKFundingGenerationReady_Body funding_generation_ready; + LDKEvent_LDKPaymentClaimable_Body payment_claimable; + LDKEvent_LDKPaymentClaimed_Body payment_claimed; + LDKEvent_LDKPaymentSent_Body payment_sent; + LDKEvent_LDKPaymentFailed_Body payment_failed; + LDKEvent_LDKPaymentPathSuccessful_Body payment_path_successful; + LDKEvent_LDKPaymentPathFailed_Body payment_path_failed; + LDKEvent_LDKProbeSuccessful_Body probe_successful; + LDKEvent_LDKProbeFailed_Body probe_failed; + LDKEvent_LDKPendingHTLCsForwardable_Body pending_htl_cs_forwardable; + LDKEvent_LDKHTLCIntercepted_Body htlc_intercepted; + LDKEvent_LDKSpendableOutputs_Body spendable_outputs; + LDKEvent_LDKPaymentForwarded_Body payment_forwarded; + LDKEvent_LDKChannelPending_Body channel_pending; + LDKEvent_LDKChannelReady_Body channel_ready; + LDKEvent_LDKChannelClosed_Body channel_closed; + LDKEvent_LDKDiscardFunding_Body discard_funding; + LDKEvent_LDKOpenChannelRequest_Body open_channel_request; + LDKEvent_LDKHTLCHandlingFailed_Body htlc_handling_failed; + }; +} LDKEvent; + +/** + * An enum which can either contain a crate::lightning::events::Event or not + */ +typedef enum LDKCOption_EventZ_Tag { /** - * The node_id of this message recipient + * When we're in this state, this COption_EventZ contains a crate::lightning::events::Event */ - struct LDKPublicKey node_id; + LDKCOption_EventZ_Some, /** - * The gossip_timestamp_filter which should be sent. + * When we're in this state, this COption_EventZ contains nothing */ - struct LDKGossipTimestampFilter msg; -} LDKMessageSendEvent_LDKSendGossipTimestampFilter_Body; + LDKCOption_EventZ_None, + /** + * Must be last for serialization purposes + */ + LDKCOption_EventZ_Sentinel, +} LDKCOption_EventZ_Tag; -typedef struct MUST_USE_STRUCT LDKMessageSendEvent { - LDKMessageSendEvent_Tag tag; +typedef struct LDKCOption_EventZ { + LDKCOption_EventZ_Tag tag; union { - LDKMessageSendEvent_LDKSendAcceptChannel_Body send_accept_channel; - LDKMessageSendEvent_LDKSendOpenChannel_Body send_open_channel; - LDKMessageSendEvent_LDKSendFundingCreated_Body send_funding_created; - LDKMessageSendEvent_LDKSendFundingSigned_Body send_funding_signed; - LDKMessageSendEvent_LDKSendChannelReady_Body send_channel_ready; - LDKMessageSendEvent_LDKSendAnnouncementSignatures_Body send_announcement_signatures; - LDKMessageSendEvent_LDKUpdateHTLCs_Body update_htl_cs; - LDKMessageSendEvent_LDKSendRevokeAndACK_Body send_revoke_and_ack; - LDKMessageSendEvent_LDKSendClosingSigned_Body send_closing_signed; - LDKMessageSendEvent_LDKSendShutdown_Body send_shutdown; - LDKMessageSendEvent_LDKSendChannelReestablish_Body send_channel_reestablish; - LDKMessageSendEvent_LDKSendChannelAnnouncement_Body send_channel_announcement; - LDKMessageSendEvent_LDKBroadcastChannelAnnouncement_Body broadcast_channel_announcement; - LDKMessageSendEvent_LDKBroadcastChannelUpdate_Body broadcast_channel_update; - LDKMessageSendEvent_LDKBroadcastNodeAnnouncement_Body broadcast_node_announcement; - LDKMessageSendEvent_LDKSendChannelUpdate_Body send_channel_update; - LDKMessageSendEvent_LDKHandleError_Body handle_error; - LDKMessageSendEvent_LDKSendChannelRangeQuery_Body send_channel_range_query; - LDKMessageSendEvent_LDKSendShortIdsQuery_Body send_short_ids_query; - LDKMessageSendEvent_LDKSendReplyChannelRange_Body send_reply_channel_range; - LDKMessageSendEvent_LDKSendGossipTimestampFilter_Body send_gossip_timestamp_filter; + struct { + struct LDKEvent some; + }; }; -} LDKMessageSendEvent; +} LDKCOption_EventZ; /** - * A dynamically-allocated array of crate::lightning::util::events::MessageSendEvents of arbitrary size. - * This corresponds to std::vector in C++ + * The contents of CResult_COption_EventZDecodeErrorZ */ -typedef struct LDKCVec_MessageSendEventZ { +typedef union LDKCResult_COption_EventZDecodeErrorZPtr { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKMessageSendEvent *data; + struct LDKCOption_EventZ *result; /** - * The number of elements pointed to by `data`. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - uintptr_t datalen; -} LDKCVec_MessageSendEventZ; + struct LDKDecodeError *err; +} LDKCResult_COption_EventZDecodeErrorZPtr; /** - * A tuple of 2 elements. See the individual fields for the types contained. + * A CResult_COption_EventZDecodeErrorZ represents the result of a fallible operation, + * containing a crate::c_types::derived::COption_EventZ on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKC2Tuple_usizeTransactionZ { +typedef struct LDKCResult_COption_EventZDecodeErrorZ { /** - * The element at position 0 + * The contents of this CResult_COption_EventZDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - uintptr_t a; + union LDKCResult_COption_EventZDecodeErrorZPtr contents; /** - * The element at position 1 + * Whether this CResult_COption_EventZDecodeErrorZ represents a success state. */ - struct LDKTransaction b; -} LDKC2Tuple_usizeTransactionZ; + bool result_ok; +} LDKCResult_COption_EventZDecodeErrorZ; + + /** - * A dynamically-allocated array of crate::c_types::derived::C2Tuple_usizeTransactionZs of arbitrary size. - * This corresponds to std::vector in C++ + * An [`accept_channel`] message to be sent to or received from a peer. + * + * [`accept_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-accept_channel-message */ -typedef struct LDKCVec_C2Tuple_usizeTransactionZZ { +typedef struct MUST_USE_STRUCT LDKAcceptChannel { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - struct LDKC2Tuple_usizeTransactionZ *data; + LDKnativeAcceptChannel *inner; /** - * The number of elements pointed to by `data`. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - uintptr_t datalen; -} LDKCVec_C2Tuple_usizeTransactionZZ; + bool is_owned; +} LDKAcceptChannel; + + /** - * A tuple of 2 elements. See the individual fields for the types contained. + * An [`open_channel`] message to be sent to or received from a peer. + * + * [`open_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-open_channel-message */ -typedef struct LDKC2Tuple_TxidBlockHashZ { +typedef struct MUST_USE_STRUCT LDKOpenChannel { /** - * The element at position 0 + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - struct LDKThirtyTwoBytes a; + LDKnativeOpenChannel *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 LDKThirtyTwoBytes b; -} LDKC2Tuple_TxidBlockHashZ; + bool is_owned; +} LDKOpenChannel; + + /** - * A dynamically-allocated array of crate::c_types::derived::C2Tuple_TxidBlockHashZs of arbitrary size. - * This corresponds to std::vector in C++ + * A [`funding_created`] message to be sent to or received from a peer. + * + * [`funding_created`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-funding_created-message */ -typedef struct LDKCVec_C2Tuple_TxidBlockHashZZ { +typedef struct MUST_USE_STRUCT LDKFundingCreated { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - struct LDKC2Tuple_TxidBlockHashZ *data; + LDKnativeFundingCreated *inner; /** - * The number of elements pointed to by `data`. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - uintptr_t datalen; -} LDKCVec_C2Tuple_TxidBlockHashZZ; + bool is_owned; +} LDKFundingCreated; /** - * Simple structure sent back by `chain::Watch` when an HTLC from a forward channel is detected on - * chain. Used to update the corresponding HTLC in the backward channel. Failing to pass the - * preimage claim backward will lead to loss of funds. + * A [`funding_signed`] message to be sent to or received from a peer. + * + * [`funding_signed`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-funding_signed-message */ -typedef struct MUST_USE_STRUCT LDKHTLCUpdate { +typedef struct MUST_USE_STRUCT LDKFundingSigned { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeHTLCUpdate *inner; + LDKnativeFundingSigned *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKHTLCUpdate; +} LDKFundingSigned; + + /** - * An event to be processed by the ChannelManager. + * A [`channel_ready`] message to be sent to or received from a peer. + * + * [`channel_ready`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-channel_ready-message */ -typedef enum LDKMonitorEvent_Tag { - /** - * A monitor event containing an HTLCUpdate. - */ - LDKMonitorEvent_HTLCEvent, +typedef struct MUST_USE_STRUCT LDKChannelReady { /** - * A monitor event that the Channel's commitment transaction was confirmed. + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKMonitorEvent_CommitmentTxConfirmed, + LDKnativeChannelReady *inner; /** - * Indicates a [`ChannelMonitor`] update has completed. See - * [`ChannelMonitorUpdateStatus::InProgress`] for more information on how this is used. - * - * [`ChannelMonitorUpdateStatus::InProgress`]: super::ChannelMonitorUpdateStatus::InProgress + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - LDKMonitorEvent_Completed, + bool is_owned; +} LDKChannelReady; + + + +/** + * An [`announcement_signatures`] message to be sent to or received from a peer. + * + * [`announcement_signatures`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-announcement_signatures-message + */ +typedef struct MUST_USE_STRUCT LDKAnnouncementSignatures { /** - * Indicates a [`ChannelMonitor`] update has failed. See - * [`ChannelMonitorUpdateStatus::PermanentFailure`] for more information on how this is used. - * - * [`ChannelMonitorUpdateStatus::PermanentFailure`]: super::ChannelMonitorUpdateStatus::PermanentFailure + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKMonitorEvent_UpdateFailed, + LDKnativeAnnouncementSignatures *inner; /** - * Must be last for serialization purposes + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - LDKMonitorEvent_Sentinel, -} LDKMonitorEvent_Tag; + bool is_owned; +} LDKAnnouncementSignatures; -typedef struct LDKMonitorEvent_LDKCompleted_Body { + + +/** + * Struct used to return values from [`RevokeAndACK`] messages, containing a bunch of commitment + * transaction updates if they were pending. + */ +typedef struct MUST_USE_STRUCT LDKCommitmentUpdate { /** - * The funding outpoint of the [`ChannelMonitor`] that was updated + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - struct LDKOutPoint funding_txo; + LDKnativeCommitmentUpdate *inner; /** - * The Update ID from [`ChannelMonitorUpdate::update_id`] which was applied or - * [`ChannelMonitor::get_latest_update_id`]. - * - * Note that this should only be set to a given update's ID if all previous updates for the - * same [`ChannelMonitor`] have been applied and persisted. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - uint64_t monitor_update_id; -} LDKMonitorEvent_LDKCompleted_Body; + bool is_owned; +} LDKCommitmentUpdate; + -typedef struct MUST_USE_STRUCT LDKMonitorEvent { - LDKMonitorEvent_Tag tag; - union { - struct { - struct LDKHTLCUpdate htlc_event; - }; - struct { - struct LDKOutPoint commitment_tx_confirmed; - }; - LDKMonitorEvent_LDKCompleted_Body completed; - struct { - struct LDKOutPoint update_failed; - }; - }; -} LDKMonitorEvent; /** - * A dynamically-allocated array of crate::lightning::chain::channelmonitor::MonitorEvents of arbitrary size. - * This corresponds to std::vector in C++ + * A [`revoke_and_ack`] message to be sent to or received from a peer. + * + * [`revoke_and_ack`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#completing-the-transition-to-the-updated-state-revoke_and_ack */ -typedef struct LDKCVec_MonitorEventZ { +typedef struct MUST_USE_STRUCT LDKRevokeAndACK { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - struct LDKMonitorEvent *data; + LDKnativeRevokeAndACK *inner; /** - * The number of elements pointed to by `data`. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - uintptr_t datalen; -} LDKCVec_MonitorEventZ; + bool is_owned; +} LDKRevokeAndACK; + + /** - * A tuple of 3 elements. See the individual fields for the types contained. + * A [`closing_signed`] message to be sent to or received from a peer. + * + * [`closing_signed`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#closing-negotiation-closing_signed */ -typedef struct LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ { +typedef struct MUST_USE_STRUCT LDKClosingSigned { /** - * 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 LDKOutPoint a; + LDKnativeClosingSigned *inner; /** - * The element at position 1 + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - struct LDKCVec_MonitorEventZ b; + bool is_owned; +} LDKClosingSigned; + + + +/** + * A [`shutdown`] message to be sent to or received from a peer. + * + * [`shutdown`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#closing-initiation-shutdown + */ +typedef struct MUST_USE_STRUCT LDKShutdown { /** - * The element at position 2 + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - struct LDKPublicKey c; -} LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ; + LDKnativeShutdown *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKShutdown; + + /** - * A dynamically-allocated array of crate::c_types::derived::C3Tuple_OutPointCVec_MonitorEventZPublicKeyZs of arbitrary size. - * This corresponds to std::vector in C++ + * A [`channel_reestablish`] message to be sent to or received from a peer. + * + * [`channel_reestablish`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#message-retransmission */ -typedef struct LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ { +typedef struct MUST_USE_STRUCT LDKChannelReestablish { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - struct LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *data; + LDKnativeChannelReestablish *inner; /** - * The number of elements pointed to by `data`. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - uintptr_t datalen; -} LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ; + bool is_owned; +} LDKChannelReestablish; /** - * [`Score`] implementation that uses a fixed penalty. + * A [`channel_announcement`] message to be sent to or received from a peer. + * + * [`channel_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_announcement-message */ -typedef struct MUST_USE_STRUCT LDKFixedPenaltyScorer { +typedef struct MUST_USE_STRUCT LDKChannelAnnouncement { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeFixedPenaltyScorer *inner; + LDKnativeChannelAnnouncement *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; -} LDKFixedPenaltyScorer; +} LDKChannelAnnouncement; + + /** - * The contents of CResult_FixedPenaltyScorerDecodeErrorZ + * A [`node_announcement`] message to be sent to or received from a peer. + * + * [`node_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-node_announcement-message */ -typedef union LDKCResult_FixedPenaltyScorerDecodeErrorZPtr { +typedef struct MUST_USE_STRUCT LDKNodeAnnouncement { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - struct LDKFixedPenaltyScorer *result; + LDKnativeNodeAnnouncement *inner; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - struct LDKDecodeError *err; -} LDKCResult_FixedPenaltyScorerDecodeErrorZPtr; + bool is_owned; +} LDKNodeAnnouncement; + + /** - * A CResult_FixedPenaltyScorerDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::routing::scoring::FixedPenaltyScorer on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * An [`error`] message to be sent to or received from a peer. + * + * [`error`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-error-and-warning-messages */ -typedef struct LDKCResult_FixedPenaltyScorerDecodeErrorZ { +typedef struct MUST_USE_STRUCT LDKErrorMessage { /** - * The contents of this CResult_FixedPenaltyScorerDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - union LDKCResult_FixedPenaltyScorerDecodeErrorZPtr contents; + LDKnativeErrorMessage *inner; /** - * Whether this CResult_FixedPenaltyScorerDecodeErrorZ represents a success state. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - bool result_ok; -} LDKCResult_FixedPenaltyScorerDecodeErrorZ; + bool is_owned; +} LDKErrorMessage; + + /** - * A tuple of 2 elements. See the individual fields for the types contained. + * A [`warning`] message to be sent to or received from a peer. + * + * [`warning`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-error-and-warning-messages */ -typedef struct LDKC2Tuple_u64u64Z { +typedef struct MUST_USE_STRUCT LDKWarningMessage { /** - * 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. */ - uint64_t a; + LDKnativeWarningMessage *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. */ - uint64_t b; -} LDKC2Tuple_u64u64Z; + bool is_owned; +} LDKWarningMessage; /** - * An enum which can either contain a crate::c_types::derived::C2Tuple_u64u64Z or not + * Used to put an error message in a [`LightningError`]. */ -typedef enum LDKCOption_C2Tuple_u64u64ZZ_Tag { +typedef enum LDKErrorAction_Tag { /** - * When we're in this state, this COption_C2Tuple_u64u64ZZ contains a crate::c_types::derived::C2Tuple_u64u64Z + * The peer took some action which made us think they were useless. Disconnect them. */ - LDKCOption_C2Tuple_u64u64ZZ_Some, + LDKErrorAction_DisconnectPeer, /** - * When we're in this state, this COption_C2Tuple_u64u64ZZ contains nothing + * The peer did something harmless that we weren't able to process, just log and ignore */ - LDKCOption_C2Tuple_u64u64ZZ_None, + LDKErrorAction_IgnoreError, /** - * Must be last for serialization purposes + * The peer did something harmless that we weren't able to meaningfully process. + * If the error is logged, log it at the given level. */ - LDKCOption_C2Tuple_u64u64ZZ_Sentinel, -} LDKCOption_C2Tuple_u64u64ZZ_Tag; - -typedef struct LDKCOption_C2Tuple_u64u64ZZ { - LDKCOption_C2Tuple_u64u64ZZ_Tag tag; - union { - struct { - struct LDKC2Tuple_u64u64Z some; - }; - }; -} LDKCOption_C2Tuple_u64u64ZZ; - -/** - * 8 u16s - */ -typedef struct LDKEightU16s { + LDKErrorAction_IgnoreAndLog, /** - * The eight 16-bit integers + * The peer provided us with a gossip message which we'd already seen. In most cases this + * should be ignored, but it may result in the message being forwarded if it is a duplicate of + * our own channel announcements. */ - uint16_t data[8]; -} LDKEightU16s; - -/** - * A tuple of 2 elements. See the individual fields for the types contained. - */ -typedef struct LDKC2Tuple_Z { + LDKErrorAction_IgnoreDuplicateGossip, /** - * The element at position 0 + * The peer did something incorrect. Tell them. */ - struct LDKEightU16s a; + LDKErrorAction_SendErrorMessage, /** - * The element at position 1 + * The peer did something incorrect. Tell them without closing any channels. */ - struct LDKEightU16s b; -} LDKC2Tuple_Z; - -/** - * A tuple of 2 elements. See the individual fields for the types contained. - */ -typedef struct LDKC2Tuple__u168_u168Z { + LDKErrorAction_SendWarningMessage, /** - * The element at position 0 + * Must be last for serialization purposes */ - struct LDKEightU16s a; + LDKErrorAction_Sentinel, +} LDKErrorAction_Tag; + +typedef struct LDKErrorAction_LDKDisconnectPeer_Body { /** - * The element at position 1 + * An error message which we should make an effort to send before we disconnect. + * + * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None */ - struct LDKEightU16s b; -} LDKC2Tuple__u168_u168Z; + struct LDKErrorMessage msg; +} LDKErrorAction_LDKDisconnectPeer_Body; -/** - * An enum which can either contain a crate::c_types::derived::C2Tuple__u168_u168Z or not - */ -typedef enum LDKCOption_C2Tuple_EightU16sEightU16sZZ_Tag { +typedef struct LDKErrorAction_LDKSendErrorMessage_Body { /** - * When we're in this state, this COption_C2Tuple_EightU16sEightU16sZZ contains a crate::c_types::derived::C2Tuple__u168_u168Z + * The message to send. */ - LDKCOption_C2Tuple_EightU16sEightU16sZZ_Some, + struct LDKErrorMessage msg; +} LDKErrorAction_LDKSendErrorMessage_Body; + +typedef struct LDKErrorAction_LDKSendWarningMessage_Body { /** - * When we're in this state, this COption_C2Tuple_EightU16sEightU16sZZ contains nothing + * The message to send. */ - LDKCOption_C2Tuple_EightU16sEightU16sZZ_None, + struct LDKWarningMessage msg; /** - * Must be last for serialization purposes + * The peer may have done something harmless that we weren't able to meaningfully process, + * though we should still tell them about it. + * If this event is logged, log it at the given level. */ - LDKCOption_C2Tuple_EightU16sEightU16sZZ_Sentinel, -} LDKCOption_C2Tuple_EightU16sEightU16sZZ_Tag; + enum LDKLevel log_level; +} LDKErrorAction_LDKSendWarningMessage_Body; -typedef struct LDKCOption_C2Tuple_EightU16sEightU16sZZ { - LDKCOption_C2Tuple_EightU16sEightU16sZZ_Tag tag; +typedef struct MUST_USE_STRUCT LDKErrorAction { + LDKErrorAction_Tag tag; union { + LDKErrorAction_LDKDisconnectPeer_Body disconnect_peer; struct { - struct LDKC2Tuple__u168_u168Z some; + enum LDKLevel ignore_and_log; }; + LDKErrorAction_LDKSendErrorMessage_Body send_error_message; + LDKErrorAction_LDKSendWarningMessage_Body send_warning_message; }; -} LDKCOption_C2Tuple_EightU16sEightU16sZZ; - -/** - * A dynamically-allocated array of crate::lightning::routing::gossip::NodeIds of arbitrary size. - * This corresponds to std::vector in C++ - */ -typedef struct LDKCVec_NodeIdZ { - /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - */ - struct LDKNodeId *data; - /** - * The number of elements pointed to by `data`. - */ - uintptr_t datalen; -} LDKCVec_NodeIdZ; +} LDKErrorAction; /** - * A Record, unit of logging output with Metadata to enable filtering - * Module_path, file, line to inform on log's source + * A [`query_channel_range`] message is used to query a peer for channel + * UTXOs in a range of blocks. The recipient of a query makes a best + * effort to reply to the query using one or more [`ReplyChannelRange`] + * messages. + * + * [`query_channel_range`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-query_channel_range-and-reply_channel_range-messages */ -typedef struct MUST_USE_STRUCT LDKRecord { +typedef struct MUST_USE_STRUCT LDKQueryChannelRange { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeRecord *inner; + LDKnativeQueryChannelRange *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; -} LDKRecord; +} LDKQueryChannelRange; + + /** - * A trait encapsulating the operations required of a logger + * A [`query_short_channel_ids`] message is used to query a peer for + * routing gossip messages related to one or more `short_channel_id`s. + * + * The query recipient will reply with the latest, if available, + * [`ChannelAnnouncement`], [`ChannelUpdate`] and [`NodeAnnouncement`] messages + * it maintains for the requested `short_channel_id`s followed by a + * [`ReplyShortChannelIdsEnd`] message. The `short_channel_id`s sent in + * this query are encoded. We only support `encoding_type=0` uncompressed + * serialization and do not support `encoding_type=1` zlib serialization. + * + * [`query_short_channel_ids`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-query_short_channel_idsreply_short_channel_ids_end-messages */ -typedef struct LDKLogger { - /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. - */ - void *this_arg; +typedef struct MUST_USE_STRUCT LDKQueryShortChannelIds { /** - * Logs the `Record` + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - void (*log)(const void *this_arg, const struct LDKRecord *NONNULL_PTR record); + LDKnativeQueryShortChannelIds *inner; /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - void (*free)(void *this_arg); -} LDKLogger; + bool is_owned; +} LDKQueryShortChannelIds; /** - * Represents the network as nodes and channels between them + * A [`reply_channel_range`] message is a reply to a [`QueryChannelRange`] + * message. + * + * Multiple `reply_channel_range` messages can be sent in reply + * to a single [`QueryChannelRange`] message. The query recipient makes a + * best effort to respond based on their local network view which may + * not be a perfect view of the network. The `short_channel_id`s in the + * reply are encoded. We only support `encoding_type=0` uncompressed + * serialization and do not support `encoding_type=1` zlib serialization. + * + * [`reply_channel_range`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-query_channel_range-and-reply_channel_range-messages */ -typedef struct MUST_USE_STRUCT LDKNetworkGraph { +typedef struct MUST_USE_STRUCT LDKReplyChannelRange { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeNetworkGraph *inner; + LDKnativeReplyChannelRange *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; -} LDKNetworkGraph; +} LDKReplyChannelRange; /** - * [`Score`] implementation using channel success probability distributions. - * - * Channels are tracked with upper and lower liquidity bounds - when an HTLC fails at a channel, - * we learn that the upper-bound on the available liquidity is lower than the amount of the HTLC. - * When a payment is forwarded through a channel (but fails later in the route), we learn the - * lower-bound on the channel's available liquidity must be at least the value of the HTLC. - * - * These bounds are then used to determine a success probability using the formula from - * *Optimally Reliable & Cheap Payment Flows on the Lightning Network* by Rene Pickhardt - * and Stefan Richter [[1]] (i.e. `(upper_bound - payment_amount) / (upper_bound - lower_bound)`). - * - * This probability is combined with the [`liquidity_penalty_multiplier_msat`] and - * [`liquidity_penalty_amount_multiplier_msat`] parameters to calculate a concrete penalty in - * milli-satoshis. The penalties, when added across all hops, have the property of being linear in - * terms of the entire path's success probability. This allows the router to directly compare - * penalties for different paths. See the documentation of those parameters for the exact formulas. - * - * The liquidity bounds are decayed by halving them every [`liquidity_offset_half_life`]. - * - * Further, we track the history of our upper and lower liquidity bounds for each channel, - * allowing us to assign a second penalty (using [`historical_liquidity_penalty_multiplier_msat`] - * and [`historical_liquidity_penalty_amount_multiplier_msat`]) based on the same probability - * formula, but using the history of a channel rather than our latest estimates for the liquidity - * bounds. - * - * # Note - * - * Mixing the `no-std` feature between serialization and deserialization results in undefined - * behavior. + * A [`gossip_timestamp_filter`] message is used by a node to request + * gossip relay for messages in the requested time range when the + * `gossip_queries` feature has been negotiated. * - * [1]: https://arxiv.org/abs/2107.05322 - * [`liquidity_penalty_multiplier_msat`]: ProbabilisticScoringParameters::liquidity_penalty_multiplier_msat - * [`liquidity_penalty_amount_multiplier_msat`]: ProbabilisticScoringParameters::liquidity_penalty_amount_multiplier_msat - * [`liquidity_offset_half_life`]: ProbabilisticScoringParameters::liquidity_offset_half_life - * [`historical_liquidity_penalty_multiplier_msat`]: ProbabilisticScoringParameters::historical_liquidity_penalty_multiplier_msat - * [`historical_liquidity_penalty_amount_multiplier_msat`]: ProbabilisticScoringParameters::historical_liquidity_penalty_amount_multiplier_msat + * [`gossip_timestamp_filter`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-gossip_timestamp_filter-message */ -typedef struct MUST_USE_STRUCT LDKProbabilisticScorer { +typedef struct MUST_USE_STRUCT LDKGossipTimestampFilter { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeProbabilisticScorer *inner; + LDKnativeGossipTimestampFilter *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; -} LDKProbabilisticScorer; +} LDKGossipTimestampFilter; /** - * The contents of CResult_ProbabilisticScorerDecodeErrorZ + * An event generated by ChannelManager which indicates a message should be sent to a peer (or + * broadcast to most peers). + * These events are handled by PeerManager::process_events if you are using a PeerManager. */ -typedef union LDKCResult_ProbabilisticScorerDecodeErrorZPtr { +typedef enum LDKMessageSendEvent_Tag { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * Used to indicate that we've accepted a channel open and should send the accept_channel + * message provided to the given peer. */ - struct LDKProbabilisticScorer *result; + LDKMessageSendEvent_SendAcceptChannel, /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * Used to indicate that we've initiated a channel open and should send the open_channel + * message provided to the given peer. */ - struct LDKDecodeError *err; -} LDKCResult_ProbabilisticScorerDecodeErrorZPtr; + LDKMessageSendEvent_SendOpenChannel, + /** + * Used to indicate that a funding_created message should be sent to the peer with the given node_id. + */ + LDKMessageSendEvent_SendFundingCreated, + /** + * Used to indicate that a funding_signed message should be sent to the peer with the given node_id. + */ + LDKMessageSendEvent_SendFundingSigned, + /** + * Used to indicate that a channel_ready message should be sent to the peer with the given node_id. + */ + LDKMessageSendEvent_SendChannelReady, + /** + * Used to indicate that an announcement_signatures message should be sent to the peer with the given node_id. + */ + LDKMessageSendEvent_SendAnnouncementSignatures, + /** + * Used to indicate that a series of HTLC update messages, as well as a commitment_signed + * message should be sent to the peer with the given node_id. + */ + LDKMessageSendEvent_UpdateHTLCs, + /** + * Used to indicate that a revoke_and_ack message should be sent to the peer with the given node_id. + */ + LDKMessageSendEvent_SendRevokeAndACK, + /** + * Used to indicate that a closing_signed message should be sent to the peer with the given node_id. + */ + LDKMessageSendEvent_SendClosingSigned, + /** + * Used to indicate that a shutdown message should be sent to the peer with the given node_id. + */ + LDKMessageSendEvent_SendShutdown, + /** + * Used to indicate that a channel_reestablish message should be sent to the peer with the given node_id. + */ + LDKMessageSendEvent_SendChannelReestablish, + /** + * Used to send a channel_announcement and channel_update to a specific peer, likely on + * initial connection to ensure our peers know about our channels. + */ + LDKMessageSendEvent_SendChannelAnnouncement, + /** + * Used to indicate that a channel_announcement and channel_update should be broadcast to all + * peers (except the peer with node_id either msg.contents.node_id_1 or msg.contents.node_id_2). + * + * Note that after doing so, you very likely (unless you did so very recently) want to + * broadcast a node_announcement (e.g. via [`PeerManager::broadcast_node_announcement`]). This + * ensures that any nodes which see our channel_announcement also have a relevant + * node_announcement, including relevant feature flags which may be important for routing + * through or to us. + * + * [`PeerManager::broadcast_node_announcement`]: crate::ln::peer_handler::PeerManager::broadcast_node_announcement + */ + LDKMessageSendEvent_BroadcastChannelAnnouncement, + /** + * Used to indicate that a channel_update should be broadcast to all peers. + */ + LDKMessageSendEvent_BroadcastChannelUpdate, + /** + * Used to indicate that a node_announcement should be broadcast to all peers. + */ + LDKMessageSendEvent_BroadcastNodeAnnouncement, + /** + * Used to indicate that a channel_update should be sent to a single peer. + * In contrast to [`Self::BroadcastChannelUpdate`], this is used when the channel is a + * private channel and we shouldn't be informing all of our peers of channel parameters. + */ + LDKMessageSendEvent_SendChannelUpdate, + /** + * Broadcast an error downstream to be handled + */ + LDKMessageSendEvent_HandleError, + /** + * Query a peer for channels with funding transaction UTXOs in a block range. + */ + LDKMessageSendEvent_SendChannelRangeQuery, + /** + * Request routing gossip messages from a peer for a list of channels identified by + * their short_channel_ids. + */ + LDKMessageSendEvent_SendShortIdsQuery, + /** + * Sends a reply to a channel range query. This may be one of several SendReplyChannelRange events + * emitted during processing of the query. + */ + LDKMessageSendEvent_SendReplyChannelRange, + /** + * Sends a timestamp filter for inbound gossip. This should be sent on each new connection to + * enable receiving gossip messages from the peer. + */ + LDKMessageSendEvent_SendGossipTimestampFilter, + /** + * Must be last for serialization purposes + */ + LDKMessageSendEvent_Sentinel, +} LDKMessageSendEvent_Tag; + +typedef struct LDKMessageSendEvent_LDKSendAcceptChannel_Body { + /** + * The node_id of the node which should receive this message + */ + struct LDKPublicKey node_id; + /** + * The message which should be sent. + */ + struct LDKAcceptChannel msg; +} LDKMessageSendEvent_LDKSendAcceptChannel_Body; + +typedef struct LDKMessageSendEvent_LDKSendOpenChannel_Body { + /** + * The node_id of the node which should receive this message + */ + struct LDKPublicKey node_id; + /** + * The message which should be sent. + */ + struct LDKOpenChannel msg; +} LDKMessageSendEvent_LDKSendOpenChannel_Body; + +typedef struct LDKMessageSendEvent_LDKSendFundingCreated_Body { + /** + * The node_id of the node which should receive this message + */ + struct LDKPublicKey node_id; + /** + * The message which should be sent. + */ + struct LDKFundingCreated msg; +} LDKMessageSendEvent_LDKSendFundingCreated_Body; + +typedef struct LDKMessageSendEvent_LDKSendFundingSigned_Body { + /** + * The node_id of the node which should receive this message + */ + struct LDKPublicKey node_id; + /** + * The message which should be sent. + */ + struct LDKFundingSigned msg; +} LDKMessageSendEvent_LDKSendFundingSigned_Body; + +typedef struct LDKMessageSendEvent_LDKSendChannelReady_Body { + /** + * The node_id of the node which should receive these message(s) + */ + struct LDKPublicKey node_id; + /** + * The channel_ready message which should be sent. + */ + struct LDKChannelReady msg; +} LDKMessageSendEvent_LDKSendChannelReady_Body; + +typedef struct LDKMessageSendEvent_LDKSendAnnouncementSignatures_Body { + /** + * The node_id of the node which should receive these message(s) + */ + struct LDKPublicKey node_id; + /** + * The announcement_signatures message which should be sent. + */ + struct LDKAnnouncementSignatures msg; +} LDKMessageSendEvent_LDKSendAnnouncementSignatures_Body; -/** - * A CResult_ProbabilisticScorerDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::routing::scoring::ProbabilisticScorer on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_ProbabilisticScorerDecodeErrorZ { +typedef struct LDKMessageSendEvent_LDKUpdateHTLCs_Body { /** - * The contents of this CResult_ProbabilisticScorerDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * The node_id of the node which should receive these message(s) */ - union LDKCResult_ProbabilisticScorerDecodeErrorZPtr contents; + struct LDKPublicKey node_id; /** - * Whether this CResult_ProbabilisticScorerDecodeErrorZ represents a success state. + * The update messages which should be sent. ALL messages in the struct should be sent! */ - bool result_ok; -} LDKCResult_ProbabilisticScorerDecodeErrorZ; - - + struct LDKCommitmentUpdate updates; +} LDKMessageSendEvent_LDKUpdateHTLCs_Body; -/** - * Features used within an `init` message. - */ -typedef struct MUST_USE_STRUCT LDKInitFeatures { +typedef struct LDKMessageSendEvent_LDKSendRevokeAndACK_Body { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The node_id of the node which should receive this message */ - LDKnativeInitFeatures *inner; + struct LDKPublicKey node_id; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The message which should be sent. */ - bool is_owned; -} LDKInitFeatures; + struct LDKRevokeAndACK msg; +} LDKMessageSendEvent_LDKSendRevokeAndACK_Body; -/** - * The contents of CResult_InitFeaturesDecodeErrorZ - */ -typedef union LDKCResult_InitFeaturesDecodeErrorZPtr { +typedef struct LDKMessageSendEvent_LDKSendClosingSigned_Body { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * The node_id of the node which should receive this message */ - struct LDKInitFeatures *result; + struct LDKPublicKey node_id; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * The message which should be sent. */ - struct LDKDecodeError *err; -} LDKCResult_InitFeaturesDecodeErrorZPtr; + struct LDKClosingSigned msg; +} LDKMessageSendEvent_LDKSendClosingSigned_Body; -/** - * A CResult_InitFeaturesDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::features::InitFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_InitFeaturesDecodeErrorZ { +typedef struct LDKMessageSendEvent_LDKSendShutdown_Body { /** - * The contents of this CResult_InitFeaturesDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * The node_id of the node which should receive this message */ - union LDKCResult_InitFeaturesDecodeErrorZPtr contents; + struct LDKPublicKey node_id; /** - * Whether this CResult_InitFeaturesDecodeErrorZ represents a success state. + * The message which should be sent. */ - bool result_ok; -} LDKCResult_InitFeaturesDecodeErrorZ; - - + struct LDKShutdown msg; +} LDKMessageSendEvent_LDKSendShutdown_Body; -/** - * Features used within a `channel_announcement` message. - */ -typedef struct MUST_USE_STRUCT LDKChannelFeatures { +typedef struct LDKMessageSendEvent_LDKSendChannelReestablish_Body { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The node_id of the node which should receive this message */ - LDKnativeChannelFeatures *inner; + struct LDKPublicKey node_id; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The message which should be sent. */ - bool is_owned; -} LDKChannelFeatures; + struct LDKChannelReestablish msg; +} LDKMessageSendEvent_LDKSendChannelReestablish_Body; -/** - * The contents of CResult_ChannelFeaturesDecodeErrorZ - */ -typedef union LDKCResult_ChannelFeaturesDecodeErrorZPtr { +typedef struct LDKMessageSendEvent_LDKSendChannelAnnouncement_Body { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * The node_id of the node which should receive this message */ - struct LDKChannelFeatures *result; + struct LDKPublicKey node_id; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * The channel_announcement which should be sent. */ - struct LDKDecodeError *err; -} LDKCResult_ChannelFeaturesDecodeErrorZPtr; + struct LDKChannelAnnouncement msg; + /** + * The followup channel_update which should be sent. + */ + struct LDKChannelUpdate update_msg; +} LDKMessageSendEvent_LDKSendChannelAnnouncement_Body; -/** - * A CResult_ChannelFeaturesDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::features::ChannelFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_ChannelFeaturesDecodeErrorZ { +typedef struct LDKMessageSendEvent_LDKBroadcastChannelAnnouncement_Body { /** - * The contents of this CResult_ChannelFeaturesDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * The channel_announcement which should be sent. */ - union LDKCResult_ChannelFeaturesDecodeErrorZPtr contents; + struct LDKChannelAnnouncement msg; /** - * Whether this CResult_ChannelFeaturesDecodeErrorZ represents a success state. + * The followup channel_update which should be sent. + * + * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None */ - bool result_ok; -} LDKCResult_ChannelFeaturesDecodeErrorZ; - - + struct LDKChannelUpdate update_msg; +} LDKMessageSendEvent_LDKBroadcastChannelAnnouncement_Body; -/** - * Features used within a `node_announcement` message. - */ -typedef struct MUST_USE_STRUCT LDKNodeFeatures { +typedef struct LDKMessageSendEvent_LDKBroadcastChannelUpdate_Body { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The channel_update which should be sent. */ - LDKnativeNodeFeatures *inner; + struct LDKChannelUpdate msg; +} LDKMessageSendEvent_LDKBroadcastChannelUpdate_Body; + +typedef struct LDKMessageSendEvent_LDKBroadcastNodeAnnouncement_Body { /** - * Indicates that this is the only struct which contains the same pointer. - * Rust 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 node_announcement which should be sent. */ - bool is_owned; -} LDKNodeFeatures; + struct LDKNodeAnnouncement msg; +} LDKMessageSendEvent_LDKBroadcastNodeAnnouncement_Body; -/** - * The contents of CResult_NodeFeaturesDecodeErrorZ - */ -typedef union LDKCResult_NodeFeaturesDecodeErrorZPtr { +typedef struct LDKMessageSendEvent_LDKSendChannelUpdate_Body { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * The node_id of the node which should receive this message */ - struct LDKNodeFeatures *result; + struct LDKPublicKey node_id; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * The channel_update which should be sent. */ - struct LDKDecodeError *err; -} LDKCResult_NodeFeaturesDecodeErrorZPtr; + struct LDKChannelUpdate msg; +} LDKMessageSendEvent_LDKSendChannelUpdate_Body; -/** - * A CResult_NodeFeaturesDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::features::NodeFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_NodeFeaturesDecodeErrorZ { +typedef struct LDKMessageSendEvent_LDKHandleError_Body { /** - * The contents of this CResult_NodeFeaturesDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * The node_id of the node which should receive this message */ - union LDKCResult_NodeFeaturesDecodeErrorZPtr contents; + struct LDKPublicKey node_id; /** - * Whether this CResult_NodeFeaturesDecodeErrorZ represents a success state. + * The action which should be taken. */ - bool result_ok; -} LDKCResult_NodeFeaturesDecodeErrorZ; - - + struct LDKErrorAction action; +} LDKMessageSendEvent_LDKHandleError_Body; -/** - * Features used within an invoice. - */ -typedef struct MUST_USE_STRUCT LDKInvoiceFeatures { +typedef struct LDKMessageSendEvent_LDKSendChannelRangeQuery_Body { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The node_id of this message recipient */ - LDKnativeInvoiceFeatures *inner; + struct LDKPublicKey node_id; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The query_channel_range which should be sent. */ - bool is_owned; -} LDKInvoiceFeatures; + struct LDKQueryChannelRange msg; +} LDKMessageSendEvent_LDKSendChannelRangeQuery_Body; -/** - * The contents of CResult_InvoiceFeaturesDecodeErrorZ - */ -typedef union LDKCResult_InvoiceFeaturesDecodeErrorZPtr { +typedef struct LDKMessageSendEvent_LDKSendShortIdsQuery_Body { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * The node_id of this message recipient */ - struct LDKInvoiceFeatures *result; + struct LDKPublicKey node_id; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * The query_short_channel_ids which should be sent. */ - struct LDKDecodeError *err; -} LDKCResult_InvoiceFeaturesDecodeErrorZPtr; + struct LDKQueryShortChannelIds msg; +} LDKMessageSendEvent_LDKSendShortIdsQuery_Body; -/** - * A CResult_InvoiceFeaturesDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::features::InvoiceFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_InvoiceFeaturesDecodeErrorZ { +typedef struct LDKMessageSendEvent_LDKSendReplyChannelRange_Body { /** - * The contents of this CResult_InvoiceFeaturesDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * The node_id of this message recipient */ - union LDKCResult_InvoiceFeaturesDecodeErrorZPtr contents; + struct LDKPublicKey node_id; /** - * Whether this CResult_InvoiceFeaturesDecodeErrorZ represents a success state. + * The reply_channel_range which should be sent. */ - bool result_ok; -} LDKCResult_InvoiceFeaturesDecodeErrorZ; - - + struct LDKReplyChannelRange msg; +} LDKMessageSendEvent_LDKSendReplyChannelRange_Body; -/** - * Features used within BOLT 4 encrypted_data_tlv and BOLT 12 blinded_payinfo - */ -typedef struct MUST_USE_STRUCT LDKBlindedHopFeatures { +typedef struct LDKMessageSendEvent_LDKSendGossipTimestampFilter_Body { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The node_id of this message recipient */ - LDKnativeBlindedHopFeatures *inner; + struct LDKPublicKey node_id; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The gossip_timestamp_filter which should be sent. */ - bool is_owned; -} LDKBlindedHopFeatures; + struct LDKGossipTimestampFilter msg; +} LDKMessageSendEvent_LDKSendGossipTimestampFilter_Body; + +typedef struct MUST_USE_STRUCT LDKMessageSendEvent { + LDKMessageSendEvent_Tag tag; + union { + LDKMessageSendEvent_LDKSendAcceptChannel_Body send_accept_channel; + LDKMessageSendEvent_LDKSendOpenChannel_Body send_open_channel; + LDKMessageSendEvent_LDKSendFundingCreated_Body send_funding_created; + LDKMessageSendEvent_LDKSendFundingSigned_Body send_funding_signed; + LDKMessageSendEvent_LDKSendChannelReady_Body send_channel_ready; + LDKMessageSendEvent_LDKSendAnnouncementSignatures_Body send_announcement_signatures; + LDKMessageSendEvent_LDKUpdateHTLCs_Body update_htl_cs; + LDKMessageSendEvent_LDKSendRevokeAndACK_Body send_revoke_and_ack; + LDKMessageSendEvent_LDKSendClosingSigned_Body send_closing_signed; + LDKMessageSendEvent_LDKSendShutdown_Body send_shutdown; + LDKMessageSendEvent_LDKSendChannelReestablish_Body send_channel_reestablish; + LDKMessageSendEvent_LDKSendChannelAnnouncement_Body send_channel_announcement; + LDKMessageSendEvent_LDKBroadcastChannelAnnouncement_Body broadcast_channel_announcement; + LDKMessageSendEvent_LDKBroadcastChannelUpdate_Body broadcast_channel_update; + LDKMessageSendEvent_LDKBroadcastNodeAnnouncement_Body broadcast_node_announcement; + LDKMessageSendEvent_LDKSendChannelUpdate_Body send_channel_update; + LDKMessageSendEvent_LDKHandleError_Body handle_error; + LDKMessageSendEvent_LDKSendChannelRangeQuery_Body send_channel_range_query; + LDKMessageSendEvent_LDKSendShortIdsQuery_Body send_short_ids_query; + LDKMessageSendEvent_LDKSendReplyChannelRange_Body send_reply_channel_range; + LDKMessageSendEvent_LDKSendGossipTimestampFilter_Body send_gossip_timestamp_filter; + }; +} LDKMessageSendEvent; /** - * The contents of CResult_BlindedHopFeaturesDecodeErrorZ + * A dynamically-allocated array of crate::lightning::events::MessageSendEvents of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef union LDKCResult_BlindedHopFeaturesDecodeErrorZPtr { +typedef struct LDKCVec_MessageSendEventZ { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - struct LDKBlindedHopFeatures *result; + struct LDKMessageSendEvent *data; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * The number of elements pointed to by `data`. */ - struct LDKDecodeError *err; -} LDKCResult_BlindedHopFeaturesDecodeErrorZPtr; + uintptr_t datalen; +} LDKCVec_MessageSendEventZ; /** - * A CResult_BlindedHopFeaturesDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::features::BlindedHopFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * A dynamically-allocated array of crate::c_types::ThirtyTwoBytess of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef struct LDKCResult_BlindedHopFeaturesDecodeErrorZ { +typedef struct LDKCVec_ChainHashZ { /** - * The contents of this CResult_BlindedHopFeaturesDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - union LDKCResult_BlindedHopFeaturesDecodeErrorZPtr contents; + struct LDKThirtyTwoBytes *data; /** - * Whether this CResult_BlindedHopFeaturesDecodeErrorZ represents a success state. + * The number of elements pointed to by `data`. */ - bool result_ok; -} LDKCResult_BlindedHopFeaturesDecodeErrorZ; + uintptr_t datalen; +} LDKCVec_ChainHashZ; /** - * The contents of CResult_ChannelTypeFeaturesDecodeErrorZ + * The contents of CResult_PublicKeyErrorZ */ -typedef union LDKCResult_ChannelTypeFeaturesDecodeErrorZPtr { +typedef union LDKCResult_PublicKeyErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKChannelTypeFeatures *result; + struct LDKPublicKey *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_ChannelTypeFeaturesDecodeErrorZPtr; + enum LDKSecp256k1Error *err; +} LDKCResult_PublicKeyErrorZPtr; /** - * A CResult_ChannelTypeFeaturesDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::features::ChannelTypeFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_PublicKeyErrorZ represents the result of a fallible operation, + * containing a crate::c_types::PublicKey on success and a crate::c_types::Secp256k1Error on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_ChannelTypeFeaturesDecodeErrorZ { +typedef struct LDKCResult_PublicKeyErrorZ { /** - * The contents of this CResult_ChannelTypeFeaturesDecodeErrorZ, accessible via either + * The contents of this CResult_PublicKeyErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_ChannelTypeFeaturesDecodeErrorZPtr contents; + union LDKCResult_PublicKeyErrorZPtr contents; /** - * Whether this CResult_ChannelTypeFeaturesDecodeErrorZ represents a success state. + * Whether this CResult_PublicKeyErrorZ represents a success state. */ bool result_ok; -} LDKCResult_ChannelTypeFeaturesDecodeErrorZ; +} LDKCResult_PublicKeyErrorZ; /** * The contents of CResult_NodeIdDecodeErrorZ @@ -8072,11 +8521,11 @@ typedef struct LDKCVec_RecentPaymentDetailsZ { } LDKCVec_RecentPaymentDetailsZ; /** - * If a payment fails to send with [`ChannelManager::send_payment`], it can be in one of several - * states. This enum is returned as the Err() type describing which state the payment is in, see - * the description of individual enum states for more. + * If a payment fails to send with [`ChannelManager::send_payment_with_route`], it can be in one + * of several states. This enum is returned as the Err() type describing which state the payment + * is in, see the description of individual enum states for more. * - * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment + * [`ChannelManager::send_payment_with_route`]: crate::ln::channelmanager::ChannelManager::send_payment_with_route */ typedef enum LDKPaymentSendFailure_Tag { /** @@ -8088,8 +8537,8 @@ typedef enum LDKPaymentSendFailure_Tag { * Because the payment failed outright, no payment tracking is done and no * [`Event::PaymentPathFailed`] or [`Event::PaymentFailed`] events will be generated. * - * [`Event::PaymentPathFailed`]: crate::util::events::Event::PaymentPathFailed - * [`Event::PaymentFailed`]: crate::util::events::Event::PaymentFailed + * [`Event::PaymentPathFailed`]: crate::events::Event::PaymentPathFailed + * [`Event::PaymentFailed`]: crate::events::Event::PaymentFailed */ LDKPaymentSendFailure_ParameterError, /** @@ -8104,8 +8553,8 @@ typedef enum LDKPaymentSendFailure_Tag { * The results here are ordered the same as the paths in the route object which was passed to * send_payment. * - * [`Event::PaymentPathFailed`]: crate::util::events::Event::PaymentPathFailed - * [`Event::PaymentFailed`]: crate::util::events::Event::PaymentFailed + * [`Event::PaymentPathFailed`]: crate::events::Event::PaymentPathFailed + * [`Event::PaymentFailed`]: crate::events::Event::PaymentFailed */ LDKPaymentSendFailure_PathParameterError, /** @@ -8116,8 +8565,8 @@ typedef enum LDKPaymentSendFailure_Tag { * Because the payment failed outright, no payment tracking is done and no * [`Event::PaymentPathFailed`] or [`Event::PaymentFailed`] events will be generated. * - * [`Event::PaymentPathFailed`]: crate::util::events::Event::PaymentPathFailed - * [`Event::PaymentFailed`]: crate::util::events::Event::PaymentFailed + * [`Event::PaymentPathFailed`]: crate::events::Event::PaymentPathFailed + * [`Event::PaymentFailed`]: crate::events::Event::PaymentFailed */ LDKPaymentSendFailure_AllFailedResendSafe, /** @@ -8125,8 +8574,8 @@ typedef enum LDKPaymentSendFailure_Tag { * yet completed (i.e. generated an [`Event::PaymentSent`] or [`Event::PaymentFailed`]). * * [`PaymentId`]: crate::ln::channelmanager::PaymentId - * [`Event::PaymentSent`]: crate::util::events::Event::PaymentSent - * [`Event::PaymentFailed`]: crate::util::events::Event::PaymentFailed + * [`Event::PaymentSent`]: crate::events::Event::PaymentSent + * [`Event::PaymentFailed`]: crate::events::Event::PaymentFailed */ LDKPaymentSendFailure_DuplicatePayment, /** @@ -9197,35 +9646,33 @@ typedef struct LDKRouter { * Manager which keeps track of a number of channels and sends messages to the appropriate * channel, also tracking HTLC preimages and forwarding onion packets appropriately. * - * Implements ChannelMessageHandler, handling the multi-channel parts and passing things through + * Implements [`ChannelMessageHandler`], handling the multi-channel parts and passing things through * to individual Channels. * - * Implements Writeable to write out all channel state to disk. Implies peer_disconnected() for + * Implements [`Writeable`] to write out all channel state to disk. Implies [`peer_disconnected`] for * all peers during write/read (though does not modify this instance, only the instance being - * serialized). This will result in any channels which have not yet exchanged funding_created (ie - * called funding_transaction_generated for outbound channels). + * serialized). This will result in any channels which have not yet exchanged [`funding_created`] (i.e., + * called [`funding_transaction_generated`] for outbound channels) being closed. * - * Note that you can be a bit lazier about writing out ChannelManager than you can be with - * ChannelMonitors. With ChannelMonitors you MUST write each monitor update out to disk before - * returning from chain::Watch::watch_/update_channel, with ChannelManagers, writing updates - * happens out-of-band (and will prevent any other ChannelManager operations from occurring during + * Note that you can be a bit lazier about writing out `ChannelManager` than you can be with + * [`ChannelMonitor`]. With [`ChannelMonitor`] you MUST write each monitor update out to disk before + * returning from [`chain::Watch::watch_channel`]/[`update_channel`], with ChannelManagers, writing updates + * happens out-of-band (and will prevent any other `ChannelManager` operations from occurring during * the serialization process). If the deserialized version is out-of-date compared to the - * ChannelMonitors passed by reference to read(), those channels will be force-closed based on the - * ChannelMonitor state and no funds will be lost (mod on-chain transaction fees). + * [`ChannelMonitor`] passed by reference to [`read`], those channels will be force-closed based on the + * `ChannelMonitor` state and no funds will be lost (mod on-chain transaction fees). * - * Note that the deserializer is only implemented for (BlockHash, ChannelManager), which - * tells you the last block hash which was block_connect()ed. You MUST rescan any blocks along - * the \"reorg path\" (ie call block_disconnected() until you get to a common block and then call - * block_connected() to step towards your best block) upon deserialization before using the - * object! + * Note that the deserializer is only implemented for `(`[`BlockHash`]`, `[`ChannelManager`]`)`, which + * tells you the last block hash which was connected. You should get the best block tip before using the manager. + * See [`chain::Listen`] and [`chain::Confirm`] for more details. * - * Note that ChannelManager is responsible for tracking liveness of its channels and generating - * ChannelUpdate messages informing peers that the channel is temporarily disabled. To avoid + * Note that `ChannelManager` is responsible for tracking liveness of its channels and generating + * [`ChannelUpdate`] messages informing peers that the channel is temporarily disabled. To avoid * spam due to quick disconnection/reconnection, updates are not sent until the channel has been * offline for a full minute. In order to track this, you must call - * timer_tick_occurred roughly once per minute, though it doesn't have to be perfect. + * [`timer_tick_occurred`] roughly once per minute, though it doesn't have to be perfect. * - * To avoid trivial DoS issues, ChannelManager limits the number of inbound connections and + * To avoid trivial DoS issues, `ChannelManager` limits the number of inbound connections and * inbound channels without confirmed funding transactions. This may result in nodes which we do * not have a channel with being unable to connect to us or open new channels with us if we have * many peers with unfunded channels. @@ -9234,11 +9681,20 @@ typedef struct LDKRouter { * exempted from the count of unfunded channels. Similarly, outbound channels and connections are * never limited. Please ensure you limit the count of such channels yourself. * - * Rather than using a plain ChannelManager, it is preferable to use either a SimpleArcChannelManager - * a SimpleRefChannelManager, for conciseness. See their documentation for more details, but - * essentially you should default to using a SimpleRefChannelManager, and use a - * SimpleArcChannelManager when you require a ChannelManager with a static lifetime, such as when + * Rather than using a plain `ChannelManager`, it is preferable to use either a [`SimpleArcChannelManager`] + * a [`SimpleRefChannelManager`], for conciseness. See their documentation for more details, but + * essentially you should default to using a [`SimpleRefChannelManager`], and use a + * [`SimpleArcChannelManager`] when you require a `ChannelManager` with a static lifetime, such as when * you're using lightning-net-tokio. + * + * [`peer_disconnected`]: msgs::ChannelMessageHandler::peer_disconnected + * [`funding_created`]: msgs::FundingCreated + * [`funding_transaction_generated`]: Self::funding_transaction_generated + * [`BlockHash`]: bitcoin::hash_types::BlockHash + * [`update_channel`]: chain::Watch::update_channel + * [`ChannelUpdate`]: msgs::ChannelUpdate + * [`timer_tick_occurred`]: Self::timer_tick_occurred + * [`read`]: ReadableArgs::read */ typedef struct MUST_USE_STRUCT LDKChannelManager { /** @@ -9416,6 +9872,39 @@ typedef struct LDKCResult_COption_APIErrorZDecodeErrorZ { bool result_ok; } LDKCResult_COption_APIErrorZDecodeErrorZ; +/** + * 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::util::string::UntrustedString on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_UntrustedStringDecodeErrorZ { + /** + * 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_OutPointDecodeErrorZ */ @@ -9667,39 +10156,6 @@ typedef struct LDKCResult_StringErrorZ { bool result_ok; } LDKCResult_StringErrorZ; -/** - * The contents of CResult_PublicKeyErrorZ - */ -typedef union LDKCResult_PublicKeyErrorZPtr { - /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. - */ - struct LDKPublicKey *result; - /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. - */ - enum LDKSecp256k1Error *err; -} LDKCResult_PublicKeyErrorZPtr; - -/** - * A CResult_PublicKeyErrorZ represents the result of a fallible operation, - * containing a crate::c_types::PublicKey on success and a crate::c_types::Secp256k1Error on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_PublicKeyErrorZ { - /** - * The contents of this CResult_PublicKeyErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. - */ - union LDKCResult_PublicKeyErrorZPtr contents; - /** - * Whether this CResult_PublicKeyErrorZ represents a success state. - */ - bool result_ok; -} LDKCResult_PublicKeyErrorZ; - /** * The contents of CResult_ChannelMonitorUpdateDecodeErrorZ */ @@ -9901,7 +10357,7 @@ typedef struct LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ { } LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ; /** - * A dynamically-allocated array of crate::lightning::util::events::Events of arbitrary size. + * A dynamically-allocated array of crate::lightning::events::Events of arbitrary size. * This corresponds to std::vector in C++ */ typedef struct LDKCVec_EventZ { @@ -10560,6 +11016,104 @@ typedef struct LDKCResult_NoneSendErrorZ { bool result_ok; } LDKCResult_NoneSendErrorZ; +/** + * The contents of CResult_BlindedPathNoneZ + */ +typedef union LDKCResult_BlindedPathNoneZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKBlindedPath *result; + /** + * Note that this value is always NULL, as there are no contents in the Err variant + */ + void *err; +} LDKCResult_BlindedPathNoneZPtr; + +/** + * A CResult_BlindedPathNoneZ represents the result of a fallible operation, + * containing a crate::lightning::blinded_path::BlindedPath on success and a () on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_BlindedPathNoneZ { + /** + * The contents of this CResult_BlindedPathNoneZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_BlindedPathNoneZPtr contents; + /** + * Whether this CResult_BlindedPathNoneZ represents a success state. + */ + bool result_ok; +} LDKCResult_BlindedPathNoneZ; + +/** + * The contents of CResult_BlindedPathDecodeErrorZ + */ +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; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + 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 { + /** + * The contents of this CResult_BlindedPathDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_BlindedPathDecodeErrorZPtr contents; + /** + * Whether this CResult_BlindedPathDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_BlindedPathDecodeErrorZ; + +/** + * The contents of CResult_BlindedHopDecodeErrorZ + */ +typedef union LDKCResult_BlindedHopDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKBlindedHop *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + struct LDKDecodeError *err; +} LDKCResult_BlindedHopDecodeErrorZPtr; + +/** + * A CResult_BlindedHopDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::blinded_path::BlindedHop on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_BlindedHopDecodeErrorZ { + /** + * The contents of this CResult_BlindedHopDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_BlindedHopDecodeErrorZPtr contents; + /** + * Whether this CResult_BlindedHopDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_BlindedHopDecodeErrorZ; + /** * Sub-errors which don't have specific information in them use this type. */ @@ -10663,9 +11217,11 @@ typedef struct LDKCResult_SiPrefixParseErrorZ { * Represents a syntactically and semantically correct lightning BOLT11 invoice. * * There are three ways to construct an `Invoice`: - * 1. using `InvoiceBuilder` - * 2. using `Invoice::from_signed(SignedRawInvoice)` - * 3. using `str::parse::(&str)` + * 1. using [`InvoiceBuilder`] + * 2. using [`Invoice::from_signed`] + * 3. using `str::parse::(&str)` (see [`Invoice::from_str`]) + * + * [`Invoice::from_str`]: crate::Invoice#impl-FromStr */ typedef struct MUST_USE_STRUCT LDKInvoice { /** @@ -10750,11 +11306,11 @@ typedef struct LDKCResult_InvoiceParseOrSemanticErrorZ { /** - * Represents a signed `RawInvoice` with cached hash. The signature is not checked and may be + * Represents a signed [`RawInvoice`] with cached hash. The signature is not checked and may be * invalid. * * # Invariants - * The hash has to be either from the deserialized invoice or from the serialized `raw_invoice`. + * The hash has to be either from the deserialized invoice or from the serialized [`RawInvoice`]. */ typedef struct MUST_USE_STRUCT LDKSignedRawInvoice { /** @@ -10807,11 +11363,11 @@ typedef struct LDKCResult_SignedRawInvoiceParseErrorZ { /** - * Represents an syntactically correct Invoice for a payment on the lightning network, + * Represents an syntactically correct [`Invoice`] for a payment on the lightning network, * but without the signature information. - * De- and encoding should not lead to information loss but may lead to different hashes. + * Decoding and encoding should not lead to information loss but may lead to different hashes. * - * For methods without docs see the corresponding methods in `Invoice`. + * For methods without docs see the corresponding methods in [`Invoice`]. */ typedef struct MUST_USE_STRUCT LDKRawInvoice { /** @@ -11082,6 +11638,22 @@ typedef struct LDKCResult_InvoiceSemanticErrorZ { bool result_ok; } LDKCResult_InvoiceSemanticErrorZ; +/** + * A dynamically-allocated array of crate::c_types::Strs of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_AddressZ { + /** + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + */ + struct LDKStr *data; + /** + * The number of elements pointed to by `data`. + */ + uintptr_t datalen; +} LDKCVec_AddressZ; + /** @@ -11171,71 +11743,6 @@ typedef struct LDKCResult_PrivateRouteCreationErrorZ { bool result_ok; } LDKCResult_PrivateRouteCreationErrorZ; -/** - * All-encompassing standard error type that processing can return - */ -typedef enum LDKGraphSyncError_Tag { - /** - * Error trying to read the update data, typically due to an erroneous data length indication - * that is greater than the actual amount of data provided - */ - LDKGraphSyncError_DecodeError, - /** - * Error applying the patch to the network graph, usually the result of updates that are too - * old or missing prerequisite data to the application of updates out of order - */ - LDKGraphSyncError_LightningError, - /** - * Must be last for serialization purposes - */ - LDKGraphSyncError_Sentinel, -} LDKGraphSyncError_Tag; - -typedef struct MUST_USE_STRUCT LDKGraphSyncError { - LDKGraphSyncError_Tag tag; - union { - struct { - struct LDKDecodeError decode_error; - }; - struct { - struct LDKLightningError lightning_error; - }; - }; -} LDKGraphSyncError; - -/** - * The contents of CResult_u32GraphSyncErrorZ - */ -typedef union LDKCResult_u32GraphSyncErrorZPtr { - /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. - */ - uint32_t *result; - /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. - */ - struct LDKGraphSyncError *err; -} LDKCResult_u32GraphSyncErrorZPtr; - -/** - * A CResult_u32GraphSyncErrorZ represents the result of a fallible operation, - * containing a u32 on success and a crate::lightning_rapid_gossip_sync::error::GraphSyncError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_u32GraphSyncErrorZ { - /** - * The contents of this CResult_u32GraphSyncErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. - */ - union LDKCResult_u32GraphSyncErrorZPtr contents; - /** - * Whether this CResult_u32GraphSyncErrorZ represents a success state. - */ - bool result_ok; -} LDKCResult_u32GraphSyncErrorZ; - /** * The contents of CResult_NetAddressDecodeErrorZ */ @@ -12739,7 +13246,7 @@ typedef struct LDKCVec_PhantomRouteHintsZ { } LDKCVec_PhantomRouteHintsZ; /** - * When signing using a fallible method either an user-supplied `SignError` or a `CreationError` + * When signing using a fallible method either an user-supplied `SignError` or a [`CreationError`] * may occur. */ typedef enum LDKSignOrCreationError_Tag { @@ -12801,6 +13308,44 @@ typedef struct LDKCResult_InvoiceSignOrCreationErrorZ { +/** + * A simple future which can complete once, and calls some callback(s) when it does so. + * + * Clones can be made and all futures cloned from the same source will complete at the same time. + */ +typedef struct MUST_USE_STRUCT LDKFuture { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeFuture *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKFuture; + +/** + * A dynamically-allocated array of crate::lightning::util::wakers::Futures of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_FutureZ { + /** + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + */ + struct LDKFuture *data; + /** + * The number of elements pointed to by `data`. + */ + uintptr_t datalen; +} LDKCVec_FutureZ; + + + /** * A transaction output watched by a [`ChannelMonitor`] for spends on-chain. * @@ -13043,130 +13588,69 @@ typedef struct LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ { } LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ; /** - * A trait indicating an object may generate message send events + * All-encompassing standard error type that processing can return */ -typedef struct LDKMessageSendEventsProvider { +typedef enum LDKGraphSyncError_Tag { /** - * 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. + * Error trying to read the update data, typically due to an erroneous data length indication + * that is greater than the actual amount of data provided */ - void *this_arg; + LDKGraphSyncError_DecodeError, /** - * Gets the list of pending events which were generated by previous actions, clearing the list - * in the process. + * Error applying the patch to the network graph, usually the result of updates that are too + * old or missing prerequisite data to the application of updates out of order */ - struct LDKCVec_MessageSendEventZ (*get_and_clear_pending_msg_events)(const void *this_arg); + LDKGraphSyncError_LightningError, /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + * Must be last for serialization purposes */ - void (*free)(void *this_arg); -} LDKMessageSendEventsProvider; + LDKGraphSyncError_Sentinel, +} LDKGraphSyncError_Tag; -/** - * A trait indicating an object may generate onion messages to send - */ -typedef struct LDKOnionMessageProvider { - /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. - */ - void *this_arg; - /** - * Gets the next pending onion message for the peer with the given node id. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None - */ - struct LDKOnionMessage (*next_onion_message_for_peer)(const void *this_arg, struct LDKPublicKey peer_node_id); - /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. - */ - void (*free)(void *this_arg); -} LDKOnionMessageProvider; +typedef struct MUST_USE_STRUCT LDKGraphSyncError { + LDKGraphSyncError_Tag tag; + union { + struct { + struct LDKDecodeError decode_error; + }; + struct { + struct LDKLightningError lightning_error; + }; + }; +} LDKGraphSyncError; /** - * A trait implemented for objects handling events from [`EventsProvider`]. - * - * An async variation also exists for implementations of [`EventsProvider`] that support async - * event handling. The async event handler should satisfy the generic bounds: `F: - * core::future::Future, H: Fn(Event) -> F`. + * The contents of CResult_u32GraphSyncErrorZ */ -typedef struct LDKEventHandler { - /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. - */ - void *this_arg; +typedef union LDKCResult_u32GraphSyncErrorZPtr { /** - * Handles the given [`Event`]. - * - * See [`EventsProvider`] for details that must be considered when implementing this method. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - void (*handle_event)(const void *this_arg, struct LDKEvent event); + uint32_t *result; /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - void (*free)(void *this_arg); -} LDKEventHandler; + struct LDKGraphSyncError *err; +} LDKCResult_u32GraphSyncErrorZPtr; /** - * A trait indicating an object may generate events. - * - * Events are processed by passing an [`EventHandler`] to [`process_pending_events`]. - * - * Implementations of this trait may also feature an async version of event handling, as shown with - * [`ChannelManager::process_pending_events_async`] and - * [`ChainMonitor::process_pending_events_async`]. - * - * # Requirements - * - * When using this trait, [`process_pending_events`] will call [`handle_event`] for each pending - * event since the last invocation. - * - * In order to ensure no [`Event`]s are lost, implementors of this trait will persist [`Event`]s - * and replay any unhandled events on startup. An [`Event`] is considered handled when - * [`process_pending_events`] returns, thus handlers MUST fully handle [`Event`]s and persist any - * relevant changes to disk *before* returning. - * - * Further, because an application may crash between an [`Event`] being handled and the - * implementor of this trait being re-serialized, [`Event`] handling must be idempotent - in - * effect, [`Event`]s may be replayed. - * - * Note, handlers may call back into the provider and thus deadlocking must be avoided. Be sure to - * consult the provider's documentation on the implication of processing events and how a handler - * may safely use the provider (e.g., see [`ChannelManager::process_pending_events`] and - * [`ChainMonitor::process_pending_events`]). - * - * (C-not implementable) As there is likely no reason for a user to implement this trait on their - * own type(s). - * - * [`process_pending_events`]: Self::process_pending_events - * [`handle_event`]: EventHandler::handle_event - * [`ChannelManager::process_pending_events`]: crate::ln::channelmanager::ChannelManager#method.process_pending_events - * [`ChainMonitor::process_pending_events`]: crate::chain::chainmonitor::ChainMonitor#method.process_pending_events - * [`ChannelManager::process_pending_events_async`]: crate::ln::channelmanager::ChannelManager::process_pending_events_async - * [`ChainMonitor::process_pending_events_async`]: crate::chain::chainmonitor::ChainMonitor::process_pending_events_async + * A CResult_u32GraphSyncErrorZ represents the result of a fallible operation, + * containing a u32 on success and a crate::lightning_rapid_gossip_sync::error::GraphSyncError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKEventsProvider { - /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. - */ - void *this_arg; +typedef struct LDKCResult_u32GraphSyncErrorZ { /** - * Processes any events generated since the last call using the given event handler. - * - * See the trait-level documentation for requirements. + * The contents of this CResult_u32GraphSyncErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - void (*process_pending_events)(const void *this_arg, struct LDKEventHandler handler); + union LDKCResult_u32GraphSyncErrorZPtr contents; /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + * Whether this CResult_u32GraphSyncErrorZ represents a success state. */ - void (*free)(void *this_arg); -} LDKEventsProvider; + bool result_ok; +} LDKCResult_u32GraphSyncErrorZ; @@ -13273,22 +13757,23 @@ typedef struct LDKFutureCallback { /** - * A simple future which can complete once, and calls some callback(s) when it does so. + * A struct which can be used to select across many [`Future`]s at once without relying on a full + * async context. */ -typedef struct MUST_USE_STRUCT LDKFuture { +typedef struct MUST_USE_STRUCT LDKSleeper { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeFuture *inner; + LDKnativeSleeper *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKFuture; +} LDKSleeper; @@ -13635,8 +14120,15 @@ typedef struct LDKPersist { * or used independently to monitor channels remotely. See the [module-level documentation] for * details. * + * Note that `ChainMonitor` should regularly trigger rebroadcasts/fee bumps of pending claims from + * a force-closed channel. This is crucial in preventing certain classes of pinning attacks, + * detecting substantial mempool feerate changes between blocks, and ensuring reliability if + * broadcasting fails. We recommend invoking this every 30 seconds, or lower if running in an + * environment with spotty connections, like on mobile. + * * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager * [module-level documentation]: crate::chain::chainmonitor + * [`rebroadcast_pending_claims`]: Self::rebroadcast_pending_claims */ typedef struct MUST_USE_STRUCT LDKChainMonitor { /** @@ -13653,6 +14145,89 @@ typedef struct MUST_USE_STRUCT LDKChainMonitor { bool is_owned; } LDKChainMonitor; +/** + * A trait implemented for objects handling events from [`EventsProvider`]. + * + * An async variation also exists for implementations of [`EventsProvider`] that support async + * event handling. The async event handler should satisfy the generic bounds: `F: + * core::future::Future, H: Fn(Event) -> F`. + */ +typedef struct LDKEventHandler { + /** + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. + */ + void *this_arg; + /** + * Handles the given [`Event`]. + * + * See [`EventsProvider`] for details that must be considered when implementing this method. + */ + void (*handle_event)(const void *this_arg, struct LDKEvent event); + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKEventHandler; + +/** + * A trait indicating an object may generate events. + * + * Events are processed by passing an [`EventHandler`] to [`process_pending_events`]. + * + * Implementations of this trait may also feature an async version of event handling, as shown with + * [`ChannelManager::process_pending_events_async`] and + * [`ChainMonitor::process_pending_events_async`]. + * + * # Requirements + * + * When using this trait, [`process_pending_events`] will call [`handle_event`] for each pending + * event since the last invocation. + * + * In order to ensure no [`Event`]s are lost, implementors of this trait will persist [`Event`]s + * and replay any unhandled events on startup. An [`Event`] is considered handled when + * [`process_pending_events`] returns, thus handlers MUST fully handle [`Event`]s and persist any + * relevant changes to disk *before* returning. + * + * Further, because an application may crash between an [`Event`] being handled and the + * implementor of this trait being re-serialized, [`Event`] handling must be idempotent - in + * effect, [`Event`]s may be replayed. + * + * Note, handlers may call back into the provider and thus deadlocking must be avoided. Be sure to + * consult the provider's documentation on the implication of processing events and how a handler + * may safely use the provider (e.g., see [`ChannelManager::process_pending_events`] and + * [`ChainMonitor::process_pending_events`]). + * + * (C-not implementable) As there is likely no reason for a user to implement this trait on their + * own type(s). + * + * [`process_pending_events`]: Self::process_pending_events + * [`handle_event`]: EventHandler::handle_event + * [`ChannelManager::process_pending_events`]: crate::ln::channelmanager::ChannelManager#method.process_pending_events + * [`ChainMonitor::process_pending_events`]: crate::chain::chainmonitor::ChainMonitor#method.process_pending_events + * [`ChannelManager::process_pending_events_async`]: crate::ln::channelmanager::ChannelManager::process_pending_events_async + * [`ChainMonitor::process_pending_events_async`]: crate::chain::chainmonitor::ChainMonitor::process_pending_events_async + */ +typedef struct LDKEventsProvider { + /** + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. + */ + void *this_arg; + /** + * Processes any events generated since the last call using the given event handler. + * + * See the trait-level documentation for requirements. + */ + void (*process_pending_events)(const void *this_arg, struct LDKEventHandler handler); + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKEventsProvider; + /** * Represents a valid secp256k1 secret key serialized as a 32 byte array. */ @@ -13762,7 +14337,7 @@ typedef enum LDKRetry_Tag { * * Each attempt may be multiple HTLCs along multiple paths if the router decides to split up a * retry, and may retry multiple failed HTLCs at once if they failed around the same time and - * were retried along a route from a single call to [`Router::find_route`]. + * were retried along a route from a single call to [`Router::find_route_with_id`]. */ LDKRetry_Attempts, /** @@ -13790,6 +14365,27 @@ typedef struct MUST_USE_STRUCT LDKRetry { }; } LDKRetry; +/** + * A trait indicating an object may generate message send events + */ +typedef struct LDKMessageSendEventsProvider { + /** + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. + */ + void *this_arg; + /** + * Gets the list of pending events which were generated by previous actions, clearing the list + * in the process. + */ + struct LDKCVec_MessageSendEventZ (*get_and_clear_pending_msg_events)(const void *this_arg); + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKMessageSendEventsProvider; + /** * A trait to describe an object which can receive channel messages. * @@ -14130,6 +14726,28 @@ typedef struct LDKRoutingMessageHandler { void (*free)(void *this_arg); } LDKRoutingMessageHandler; +/** + * A trait indicating an object may generate onion messages to send + */ +typedef struct LDKOnionMessageProvider { + /** + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. + */ + void *this_arg; + /** + * Gets the next pending onion message for the peer with the given node id. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + */ + struct LDKOnionMessage (*next_onion_message_for_peer)(const void *this_arg, struct LDKPublicKey peer_node_id); + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKOnionMessageProvider; + /** * A trait to describe an object that can receive onion messages. */ @@ -14346,7 +14964,7 @@ typedef struct MUST_USE_STRUCT LDKMessageHandler { * to a remote host. You will need to be able to generate multiple of these which meet Eq and * implement Hash to meet the PeerManager API. * - * For efficiency, Clone should be relatively cheap for this type. + * For efficiency, [`Clone`] should be relatively cheap for this type. * * Two descriptors may compare equal (by [`cmp::Eq`] and [`hash::Hash`]) as long as the original * has been disconnected, the [`PeerManager`] has been informed of the disconnection (either by it @@ -14425,10 +15043,10 @@ typedef struct LDKSocketDescriptor { * [`PeerManager`] functions related to the same connection must occur only in serial, making new * calls only after previous ones have returned. * - * Rather than using a plain PeerManager, it is preferable to use either a SimpleArcPeerManager - * a SimpleRefPeerManager, for conciseness. See their documentation for more details, but - * essentially you should default to using a SimpleRefPeerManager, and use a - * SimpleArcPeerManager when you require a PeerManager with a static lifetime, such as when + * Rather than using a plain [`PeerManager`], it is preferable to use either a [`SimpleArcPeerManager`] + * a [`SimpleRefPeerManager`], for conciseness. See their documentation for more details, but + * essentially you should default to using a [`SimpleRefPeerManager`], and use a + * [`SimpleArcPeerManager`] when you require a `PeerManager` with a static lifetime, such as when * you're using lightning-net-tokio. * * [`read_event`]: PeerManager::read_event @@ -14541,6 +15159,172 @@ typedef struct LDKWitnessVersion { +/** + * A semantically valid [`Invoice`] that hasn't been signed. + */ +typedef struct MUST_USE_STRUCT LDKUnsignedInvoice { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeUnsignedInvoice *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; +} LDKUnsignedInvoice; + + + +/** + * A semantically valid [`InvoiceRequest`] that hasn't been signed. + */ +typedef struct MUST_USE_STRUCT LDKUnsignedInvoiceRequest { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeUnsignedInvoiceRequest *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKUnsignedInvoiceRequest; + + + +/** + * An `InvoiceRequest` is a request for an [`Invoice`] formulated from an [`Offer`]. + * + * An offer may provide choices such as quantity, amount, chain, features, etc. An invoice request + * specifies these such that its recipient can send an invoice for payment. + * + * [`Invoice`]: crate::offers::invoice::Invoice + * [`Offer`]: crate::offers::offer::Offer + */ +typedef struct MUST_USE_STRUCT LDKInvoiceRequest { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeInvoiceRequest *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKInvoiceRequest; + + + +/** + * An `Offer` is a potentially long-lived proposal for payment of a good or service. + * + * An offer is a precursor to an [`InvoiceRequest`]. A merchant publishes an offer from which a + * customer may request an [`Invoice`] for a specific quantity and using an amount sufficient to + * cover that quantity (i.e., at least `quantity * amount`). See [`Offer::amount`]. + * + * Offers may be denominated in currency other than bitcoin but are ultimately paid using the + * latter. + * + * Through the use of [`BlindedPath`]s, offers provide recipient privacy. + * + * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest + * [`Invoice`]: crate::offers::invoice::Invoice + */ +typedef struct MUST_USE_STRUCT LDKOffer { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeOffer *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKOffer; + + + +/** + * The minimum amount required for an item in an [`Offer`], denominated in either bitcoin or + * another currency. + */ +typedef struct MUST_USE_STRUCT LDKAmount { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeAmount *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKAmount; + + + +/** + * Quantity of items supported by an [`Offer`]. + */ +typedef struct MUST_USE_STRUCT LDKQuantity { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeQuantity *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKQuantity; + + + +/** + * A `Refund` is a request to send an [`Invoice`] without a preceding [`Offer`]. + * + * Typically, after an invoice is paid, the recipient may publish a refund allowing the sender to + * recoup their funds. A refund may be used more generally as an \"offer for money\", such as with a + * bitcoin ATM. + * + * [`Invoice`]: crate::offers::invoice::Invoice + * [`Offer`]: crate::offers::offer::Offer + */ +typedef struct MUST_USE_STRUCT LDKRefund { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeRefund *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKRefund; + + + /** * Receives and validates network updates from peers, * stores authentic and relevant data as a network graph. @@ -14720,6 +15504,37 @@ typedef struct MUST_USE_STRUCT LDKScorerAccountingForInFlightHtlcs { bool is_owned; } LDKScorerAccountingForInFlightHtlcs; +/** + * Routing hints for the tail of the route. + */ +typedef enum LDKHints_Tag { + /** + * The recipient provided blinded paths and payinfo to reach them. The blinded paths themselves + * will be included in the final [`Route`]. + */ + LDKHints_Blinded, + /** + * The recipient included these route hints in their BOLT11 invoice. + */ + LDKHints_Clear, + /** + * Must be last for serialization purposes + */ + LDKHints_Sentinel, +} LDKHints_Tag; + +typedef struct MUST_USE_STRUCT LDKHints { + LDKHints_Tag tag; + union { + struct { + struct LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ blinded; + }; + struct { + struct LDKCVec_RouteHintZ clear; + }; + }; +} LDKHints; + /** @@ -14799,9 +15614,9 @@ typedef struct MUST_USE_STRUCT LDKProbabilisticScoringParameters { * # extern crate bitcoin; * # use bitcoin::hashes::_export::_core::time::Duration; * # use bitcoin::secp256k1::{PublicKey, Secp256k1, SecretKey}; + * # use lightning::blinded_path::BlindedPath; * # use lightning::chain::keysinterface::KeysManager; * # use lightning::ln::peer_handler::IgnoringMessageHandler; - * # use lightning::onion_message::blinded_path::BlindedPath; * # use lightning::onion_message::messenger::{Destination, OnionMessenger}; * # use lightning::onion_message::packet::{CustomOnionMessageContents, OnionMessageContents}; * # use lightning::util::logger::{Logger, Record}; @@ -14849,7 +15664,7 @@ typedef struct MUST_USE_STRUCT LDKProbabilisticScoringParameters { * // 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(&hops, &keys_manager, &secp_ctx).unwrap(); + * let blinded_path = BlindedPath::new_for_message(&hops, &keys_manager, &secp_ctx).unwrap(); * * // Send a custom onion message to a blinded path. * # let intermediate_hops = [hop_node_id1, hop_node_id2]; @@ -14972,8 +15787,8 @@ typedef struct MUST_USE_STRUCT LDKFilesystemPersister { * * Monitoring whether the [`ChannelManager`] needs to be re-persisted to disk, and if so, * writing it to disk/backups by invoking the callback given to it at startup. * [`ChannelManager`] persistence should be done in the background. - * * Calling [`ChannelManager::timer_tick_occurred`] and [`PeerManager::timer_tick_occurred`] - * at the appropriate intervals. + * * Calling [`ChannelManager::timer_tick_occurred`], [`ChainMonitor::rebroadcast_pending_claims`] + * and [`PeerManager::timer_tick_occurred`] at the appropriate intervals. * * Calling [`NetworkGraph::remove_stale_channels_and_tracking`] (if a [`GossipSync`] with a * [`NetworkGraph`] is provided to [`BackgroundProcessor::start`]). * @@ -14988,7 +15803,7 @@ typedef struct MUST_USE_STRUCT LDKFilesystemPersister { * unilateral chain closure fees are at risk. * * [`ChannelMonitor`]: lightning::chain::channelmonitor::ChannelMonitor - * [`Event`]: lightning::util::events::Event + * [`Event`]: lightning::events::Event *BackgroundProcessor will immediately stop on drop. It should be stored until shutdown. */ typedef struct MUST_USE_STRUCT LDKBackgroundProcessor { @@ -15073,7 +15888,7 @@ typedef struct MUST_USE_STRUCT LDKGossipSync { /** - * Data of the `RawInvoice` that is encoded in the data part + * Data of the [`RawInvoice`] that is encoded in the data part */ typedef struct MUST_USE_STRUCT LDKRawDataPart { /** @@ -15175,7 +15990,7 @@ typedef enum LDKFallback_Tag { } LDKFallback_Tag; typedef struct LDKFallback_LDKSegWitProgram_Body { - struct LDKU5 version; + struct LDKWitnessVersion version; struct LDKCVec_u8Z program; } LDKFallback_LDKSegWitProgram_Body; @@ -15248,6 +16063,8 @@ extern const uint8_t TAG_PRIVATE_ROUTE; extern const uint8_t TAG_PAYMENT_SECRET; +extern const uint8_t TAG_PAYMENT_METADATA; + extern const uint8_t TAG_FEATURES; struct LDKStr _ldk_get_compiled_version(void); @@ -15317,6 +16134,53 @@ void Str_free(struct LDKStr _res); const void *__unmangle_inner_ptr(const void *ptr); #endif +/** + * Constructs a new COption_DurationZ containing a u64 + */ +struct LDKCOption_DurationZ COption_DurationZ_some(uint64_t o); + +/** + * Constructs a new COption_DurationZ containing nothing + */ +struct LDKCOption_DurationZ COption_DurationZ_none(void); + +/** + * Frees any resources associated with the u64, if we are in the Some state + */ +void COption_DurationZ_free(struct LDKCOption_DurationZ _res); + +/** + * Creates a new COption_DurationZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCOption_DurationZ COption_DurationZ_clone(const struct LDKCOption_DurationZ *NONNULL_PTR orig); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_BlindedPathZ_free(struct LDKCVec_BlindedPathZ _res); + +/** + * Constructs a new COption_u64Z containing a u64 + */ +struct LDKCOption_u64Z COption_u64Z_some(uint64_t o); + +/** + * Constructs a new COption_u64Z containing nothing + */ +struct LDKCOption_u64Z COption_u64Z_none(void); + +/** + * Frees any resources associated with the u64, if we are in the Some state + */ +void COption_u64Z_free(struct LDKCOption_u64Z _res); + +/** + * Creates a new COption_u64Z which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCOption_u64Z COption_u64Z_clone(const struct LDKCOption_u64Z *NONNULL_PTR orig); + /** * Creates a new CResult_NoneAPIErrorZ in the success state. */ @@ -15353,6 +16217,58 @@ void CVec_CResult_NoneAPIErrorZZ_free(struct LDKCVec_CResult_NoneAPIErrorZZ _res */ void CVec_APIErrorZ_free(struct LDKCVec_APIErrorZ _res); +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_u8Z_free(struct LDKCVec_u8Z _res); + +/** + * Constructs a new COption_CVec_u8ZZ containing a crate::c_types::derived::CVec_u8Z + */ +struct LDKCOption_CVec_u8ZZ COption_CVec_u8ZZ_some(struct LDKCVec_u8Z o); + +/** + * Constructs a new COption_CVec_u8ZZ containing nothing + */ +struct LDKCOption_CVec_u8ZZ COption_CVec_u8ZZ_none(void); + +/** + * Frees any resources associated with the crate::c_types::derived::CVec_u8Z, if we are in the Some state + */ +void COption_CVec_u8ZZ_free(struct LDKCOption_CVec_u8ZZ _res); + +/** + * Creates a new COption_CVec_u8ZZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCOption_CVec_u8ZZ COption_CVec_u8ZZ_clone(const struct LDKCOption_CVec_u8ZZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_RecipientOnionFieldsDecodeErrorZ in the success state. + */ +struct LDKCResult_RecipientOnionFieldsDecodeErrorZ CResult_RecipientOnionFieldsDecodeErrorZ_ok(struct LDKRecipientOnionFields o); + +/** + * Creates a new CResult_RecipientOnionFieldsDecodeErrorZ in the error state. + */ +struct LDKCResult_RecipientOnionFieldsDecodeErrorZ CResult_RecipientOnionFieldsDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_RecipientOnionFieldsDecodeErrorZ_is_ok(const struct LDKCResult_RecipientOnionFieldsDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_RecipientOnionFieldsDecodeErrorZ. + */ +void CResult_RecipientOnionFieldsDecodeErrorZ_free(struct LDKCResult_RecipientOnionFieldsDecodeErrorZ _res); + +/** + * Creates a new CResult_RecipientOnionFieldsDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_RecipientOnionFieldsDecodeErrorZ CResult_RecipientOnionFieldsDecodeErrorZ_clone(const struct LDKCResult_RecipientOnionFieldsDecodeErrorZ *NONNULL_PTR orig); + /** * Constructs a new COption_HTLCClaimZ containing a crate::lightning::ln::chan_utils::HTLCClaim */ @@ -15788,87 +16704,30 @@ void CResult_ShutdownScriptInvalidShutdownScriptZ_free(struct LDKCResult_Shutdow struct LDKCResult_ShutdownScriptInvalidShutdownScriptZ CResult_ShutdownScriptInvalidShutdownScriptZ_clone(const struct LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR orig); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. - */ -void CVec_PublicKeyZ_free(struct LDKCVec_PublicKeyZ _res); - -/** - * Creates a new CResult_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_BlindedPathDecodeErrorZ in the success state. - */ -struct LDKCResult_BlindedPathDecodeErrorZ CResult_BlindedPathDecodeErrorZ_ok(struct LDKBlindedPath o); - -/** - * Creates a new CResult_BlindedPathDecodeErrorZ in the error state. - */ -struct LDKCResult_BlindedPathDecodeErrorZ CResult_BlindedPathDecodeErrorZ_err(struct LDKDecodeError e); - -/** - * Checks if the given object is currently in the success state - */ -bool CResult_BlindedPathDecodeErrorZ_is_ok(const struct LDKCResult_BlindedPathDecodeErrorZ *NONNULL_PTR o); - -/** - * Frees any resources used by the CResult_BlindedPathDecodeErrorZ. + * Creates a new CResult_BlindedPayInfoDecodeErrorZ in the success state. */ -void CResult_BlindedPathDecodeErrorZ_free(struct LDKCResult_BlindedPathDecodeErrorZ _res); - -/** - * Creates a new CResult_BlindedPathDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKCResult_BlindedPathDecodeErrorZ CResult_BlindedPathDecodeErrorZ_clone(const struct LDKCResult_BlindedPathDecodeErrorZ *NONNULL_PTR orig); - -/** - * Creates a new CResult_BlindedHopDecodeErrorZ in the success state. - */ -struct LDKCResult_BlindedHopDecodeErrorZ CResult_BlindedHopDecodeErrorZ_ok(struct LDKBlindedHop o); +struct LDKCResult_BlindedPayInfoDecodeErrorZ CResult_BlindedPayInfoDecodeErrorZ_ok(struct LDKBlindedPayInfo o); /** - * Creates a new CResult_BlindedHopDecodeErrorZ in the error state. + * Creates a new CResult_BlindedPayInfoDecodeErrorZ in the error state. */ -struct LDKCResult_BlindedHopDecodeErrorZ CResult_BlindedHopDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_BlindedPayInfoDecodeErrorZ CResult_BlindedPayInfoDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_BlindedHopDecodeErrorZ_is_ok(const struct LDKCResult_BlindedHopDecodeErrorZ *NONNULL_PTR o); +bool CResult_BlindedPayInfoDecodeErrorZ_is_ok(const struct LDKCResult_BlindedPayInfoDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_BlindedHopDecodeErrorZ. + * Frees any resources used by the CResult_BlindedPayInfoDecodeErrorZ. */ -void CResult_BlindedHopDecodeErrorZ_free(struct LDKCResult_BlindedHopDecodeErrorZ _res); +void CResult_BlindedPayInfoDecodeErrorZ_free(struct LDKCResult_BlindedPayInfoDecodeErrorZ _res); /** - * Creates a new CResult_BlindedHopDecodeErrorZ 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_BlindedHopDecodeErrorZ CResult_BlindedHopDecodeErrorZ_clone(const struct LDKCResult_BlindedHopDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_BlindedPayInfoDecodeErrorZ CResult_BlindedPayInfoDecodeErrorZ_clone(const struct LDKCResult_BlindedPayInfoDecodeErrorZ *NONNULL_PTR orig); /** * Constructs a new COption_WriteableScoreZ containing a crate::lightning::routing::scoring::WriteableScore @@ -15942,32 +16801,6 @@ void CResult_RouteLightningErrorZ_free(struct LDKCResult_RouteLightningErrorZ _r */ struct LDKCResult_RouteLightningErrorZ CResult_RouteLightningErrorZ_clone(const struct LDKCResult_RouteLightningErrorZ *NONNULL_PTR orig); -/** - * Frees the buffer pointed to by `data` if `datalen` is non-0. - */ -void CVec_RouteHopZ_free(struct LDKCVec_RouteHopZ _res); - -/** - * Constructs a new COption_u64Z containing a u64 - */ -struct LDKCOption_u64Z COption_u64Z_some(uint64_t o); - -/** - * Constructs a new COption_u64Z containing nothing - */ -struct LDKCOption_u64Z COption_u64Z_none(void); - -/** - * Frees any resources associated with the u64, if we are in the Some state - */ -void COption_u64Z_free(struct LDKCOption_u64Z _res); - -/** - * Creates a new COption_u64Z which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKCOption_u64Z COption_u64Z_clone(const struct LDKCOption_u64Z *NONNULL_PTR orig); - /** * Creates a new CResult_InFlightHtlcsDecodeErrorZ in the success state. */ @@ -16023,7 +16856,43 @@ struct LDKCResult_RouteHopDecodeErrorZ CResult_RouteHopDecodeErrorZ_clone(const /** * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -void CVec_CVec_RouteHopZZ_free(struct LDKCVec_CVec_RouteHopZZ _res); +void CVec_BlindedHopZ_free(struct LDKCVec_BlindedHopZ _res); + +/** + * Creates a new CResult_BlindedTailDecodeErrorZ in the success state. + */ +struct LDKCResult_BlindedTailDecodeErrorZ CResult_BlindedTailDecodeErrorZ_ok(struct LDKBlindedTail o); + +/** + * Creates a new CResult_BlindedTailDecodeErrorZ in the error state. + */ +struct LDKCResult_BlindedTailDecodeErrorZ CResult_BlindedTailDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_BlindedTailDecodeErrorZ_is_ok(const struct LDKCResult_BlindedTailDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_BlindedTailDecodeErrorZ. + */ +void CResult_BlindedTailDecodeErrorZ_free(struct LDKCResult_BlindedTailDecodeErrorZ _res); + +/** + * Creates a new CResult_BlindedTailDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_BlindedTailDecodeErrorZ CResult_BlindedTailDecodeErrorZ_clone(const struct LDKCResult_BlindedTailDecodeErrorZ *NONNULL_PTR orig); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_RouteHopZ_free(struct LDKCVec_RouteHopZ _res); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_PathZ_free(struct LDKCVec_PathZ _res); /** * Creates a new CResult_RouteDecodeErrorZ in the success state. @@ -16077,11 +16946,6 @@ void CResult_RouteParametersDecodeErrorZ_free(struct LDKCResult_RouteParametersD */ struct LDKCResult_RouteParametersDecodeErrorZ CResult_RouteParametersDecodeErrorZ_clone(const struct LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR orig); -/** - * Frees the buffer pointed to by `data` if `datalen` is non-0. - */ -void CVec_RouteHintZ_free(struct LDKCVec_RouteHintZ _res); - /** * Frees the buffer pointed to by `data` if `datalen` is non-0. */ @@ -16113,6 +16977,32 @@ void CResult_PaymentParametersDecodeErrorZ_free(struct LDKCResult_PaymentParamet */ struct LDKCResult_PaymentParametersDecodeErrorZ CResult_PaymentParametersDecodeErrorZ_clone(const struct LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR orig); +/** + * Creates a new tuple which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKC2Tuple_BlindedPayInfoBlindedPathZ C2Tuple_BlindedPayInfoBlindedPathZ_clone(const struct LDKC2Tuple_BlindedPayInfoBlindedPathZ *NONNULL_PTR orig); + +/** + * Creates a new C2Tuple_BlindedPayInfoBlindedPathZ from the contained elements. + */ +struct LDKC2Tuple_BlindedPayInfoBlindedPathZ C2Tuple_BlindedPayInfoBlindedPathZ_new(struct LDKBlindedPayInfo a, struct LDKBlindedPath b); + +/** + * Frees any resources used by the C2Tuple_BlindedPayInfoBlindedPathZ. + */ +void C2Tuple_BlindedPayInfoBlindedPathZ_free(struct LDKC2Tuple_BlindedPayInfoBlindedPathZ _res); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_C2Tuple_BlindedPayInfoBlindedPathZZ_free(struct LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ _res); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_RouteHintZ_free(struct LDKCVec_RouteHintZ _res); + /** * Frees the buffer pointed to by `data` if `datalen` is non-0. */ @@ -16170,271 +17060,10 @@ void CResult_RouteHintHopDecodeErrorZ_free(struct LDKCResult_RouteHintHopDecodeE */ struct LDKCResult_RouteHintHopDecodeErrorZ CResult_RouteHintHopDecodeErrorZ_clone(const struct LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR orig); -/** - * Creates a new CResult_PaymentPurposeDecodeErrorZ in the success state. - */ -struct LDKCResult_PaymentPurposeDecodeErrorZ CResult_PaymentPurposeDecodeErrorZ_ok(struct LDKPaymentPurpose o); - -/** - * Creates a new CResult_PaymentPurposeDecodeErrorZ in the error state. - */ -struct LDKCResult_PaymentPurposeDecodeErrorZ CResult_PaymentPurposeDecodeErrorZ_err(struct LDKDecodeError e); - -/** - * Checks if the given object is currently in the success state - */ -bool CResult_PaymentPurposeDecodeErrorZ_is_ok(const struct LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR o); - -/** - * Frees any resources used by the CResult_PaymentPurposeDecodeErrorZ. - */ -void CResult_PaymentPurposeDecodeErrorZ_free(struct LDKCResult_PaymentPurposeDecodeErrorZ _res); - -/** - * Creates a new CResult_PaymentPurposeDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKCResult_PaymentPurposeDecodeErrorZ CResult_PaymentPurposeDecodeErrorZ_clone(const struct LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR orig); - -/** - * Constructs a new COption_NetworkUpdateZ containing a crate::lightning::routing::gossip::NetworkUpdate - */ -struct LDKCOption_NetworkUpdateZ COption_NetworkUpdateZ_some(struct LDKNetworkUpdate o); - -/** - * Constructs a new COption_NetworkUpdateZ containing nothing - */ -struct LDKCOption_NetworkUpdateZ COption_NetworkUpdateZ_none(void); - -/** - * Frees any resources associated with the crate::lightning::routing::gossip::NetworkUpdate, if we are in the Some state - */ -void COption_NetworkUpdateZ_free(struct LDKCOption_NetworkUpdateZ _res); - -/** - * Creates a new COption_NetworkUpdateZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKCOption_NetworkUpdateZ COption_NetworkUpdateZ_clone(const struct LDKCOption_NetworkUpdateZ *NONNULL_PTR orig); - -/** - * Constructs a new COption_PathFailureZ containing a crate::lightning::util::events::PathFailure - */ -struct LDKCOption_PathFailureZ COption_PathFailureZ_some(struct LDKPathFailure o); - -/** - * Constructs a new COption_PathFailureZ containing nothing - */ -struct LDKCOption_PathFailureZ COption_PathFailureZ_none(void); - -/** - * Frees any resources associated with the crate::lightning::util::events::PathFailure, if we are in the Some state - */ -void COption_PathFailureZ_free(struct LDKCOption_PathFailureZ _res); - -/** - * Creates a new COption_PathFailureZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKCOption_PathFailureZ COption_PathFailureZ_clone(const struct LDKCOption_PathFailureZ *NONNULL_PTR orig); - -/** - * Creates a new CResult_COption_PathFailureZDecodeErrorZ in the success state. - */ -struct LDKCResult_COption_PathFailureZDecodeErrorZ CResult_COption_PathFailureZDecodeErrorZ_ok(struct LDKCOption_PathFailureZ o); - -/** - * Creates a new CResult_COption_PathFailureZDecodeErrorZ in the error state. - */ -struct LDKCResult_COption_PathFailureZDecodeErrorZ CResult_COption_PathFailureZDecodeErrorZ_err(struct LDKDecodeError e); - -/** - * Checks if the given object is currently in the success state - */ -bool CResult_COption_PathFailureZDecodeErrorZ_is_ok(const struct LDKCResult_COption_PathFailureZDecodeErrorZ *NONNULL_PTR o); - -/** - * Frees any resources used by the CResult_COption_PathFailureZDecodeErrorZ. - */ -void CResult_COption_PathFailureZDecodeErrorZ_free(struct LDKCResult_COption_PathFailureZDecodeErrorZ _res); - -/** - * Creates a new CResult_COption_PathFailureZDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKCResult_COption_PathFailureZDecodeErrorZ CResult_COption_PathFailureZDecodeErrorZ_clone(const struct LDKCResult_COption_PathFailureZDecodeErrorZ *NONNULL_PTR orig); - -/** - * Constructs a new COption_ClosureReasonZ containing a crate::lightning::util::events::ClosureReason - */ -struct LDKCOption_ClosureReasonZ COption_ClosureReasonZ_some(struct LDKClosureReason o); - -/** - * Constructs a new COption_ClosureReasonZ containing nothing - */ -struct LDKCOption_ClosureReasonZ COption_ClosureReasonZ_none(void); - -/** - * Frees any resources associated with the crate::lightning::util::events::ClosureReason, if we are in the Some state - */ -void COption_ClosureReasonZ_free(struct LDKCOption_ClosureReasonZ _res); - -/** - * Creates a new COption_ClosureReasonZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKCOption_ClosureReasonZ COption_ClosureReasonZ_clone(const struct LDKCOption_ClosureReasonZ *NONNULL_PTR orig); - -/** - * Creates a new CResult_COption_ClosureReasonZDecodeErrorZ in the success state. - */ -struct LDKCResult_COption_ClosureReasonZDecodeErrorZ CResult_COption_ClosureReasonZDecodeErrorZ_ok(struct LDKCOption_ClosureReasonZ o); - -/** - * Creates a new CResult_COption_ClosureReasonZDecodeErrorZ in the error state. - */ -struct LDKCResult_COption_ClosureReasonZDecodeErrorZ CResult_COption_ClosureReasonZDecodeErrorZ_err(struct LDKDecodeError e); - -/** - * Checks if the given object is currently in the success state - */ -bool CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(const struct LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR o); - -/** - * Frees any resources used by the CResult_COption_ClosureReasonZDecodeErrorZ. - */ -void CResult_COption_ClosureReasonZDecodeErrorZ_free(struct LDKCResult_COption_ClosureReasonZDecodeErrorZ _res); - -/** - * Creates a new CResult_COption_ClosureReasonZDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKCResult_COption_ClosureReasonZDecodeErrorZ CResult_COption_ClosureReasonZDecodeErrorZ_clone(const struct LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR orig); - -/** - * Constructs a new COption_HTLCDestinationZ containing a crate::lightning::util::events::HTLCDestination - */ -struct LDKCOption_HTLCDestinationZ COption_HTLCDestinationZ_some(struct LDKHTLCDestination o); - -/** - * Constructs a new COption_HTLCDestinationZ containing nothing - */ -struct LDKCOption_HTLCDestinationZ COption_HTLCDestinationZ_none(void); - -/** - * Frees any resources associated with the crate::lightning::util::events::HTLCDestination, if we are in the Some state - */ -void COption_HTLCDestinationZ_free(struct LDKCOption_HTLCDestinationZ _res); - -/** - * Creates a new COption_HTLCDestinationZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKCOption_HTLCDestinationZ COption_HTLCDestinationZ_clone(const struct LDKCOption_HTLCDestinationZ *NONNULL_PTR orig); - -/** - * Creates a new CResult_COption_HTLCDestinationZDecodeErrorZ in the success state. - */ -struct LDKCResult_COption_HTLCDestinationZDecodeErrorZ CResult_COption_HTLCDestinationZDecodeErrorZ_ok(struct LDKCOption_HTLCDestinationZ o); - -/** - * Creates a new CResult_COption_HTLCDestinationZDecodeErrorZ in the error state. - */ -struct LDKCResult_COption_HTLCDestinationZDecodeErrorZ CResult_COption_HTLCDestinationZDecodeErrorZ_err(struct LDKDecodeError e); - -/** - * Checks if the given object is currently in the success state - */ -bool CResult_COption_HTLCDestinationZDecodeErrorZ_is_ok(const struct LDKCResult_COption_HTLCDestinationZDecodeErrorZ *NONNULL_PTR o); - -/** - * Frees any resources used by the CResult_COption_HTLCDestinationZDecodeErrorZ. - */ -void CResult_COption_HTLCDestinationZDecodeErrorZ_free(struct LDKCResult_COption_HTLCDestinationZDecodeErrorZ _res); - -/** - * Creates a new CResult_COption_HTLCDestinationZDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKCResult_COption_HTLCDestinationZDecodeErrorZ CResult_COption_HTLCDestinationZDecodeErrorZ_clone(const struct LDKCResult_COption_HTLCDestinationZDecodeErrorZ *NONNULL_PTR orig); - -/** - * Constructs a new COption_u128Z containing a crate::c_types::U128 - */ -struct LDKCOption_u128Z COption_u128Z_some(struct LDKU128 o); - -/** - * Constructs a new COption_u128Z containing nothing - */ -struct LDKCOption_u128Z COption_u128Z_none(void); - -/** - * Frees any resources associated with the crate::c_types::U128, if we are in the Some state - */ -void COption_u128Z_free(struct LDKCOption_u128Z _res); - -/** - * Creates a new COption_u128Z 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); - /** * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -void CVec_SpendableOutputDescriptorZ_free(struct LDKCVec_SpendableOutputDescriptorZ _res); - -/** - * Constructs a new COption_EventZ containing a crate::lightning::util::events::Event - */ -struct LDKCOption_EventZ COption_EventZ_some(struct LDKEvent o); - -/** - * Constructs a new COption_EventZ containing nothing - */ -struct LDKCOption_EventZ COption_EventZ_none(void); - -/** - * Frees any resources associated with the crate::lightning::util::events::Event, if we are in the Some state - */ -void COption_EventZ_free(struct LDKCOption_EventZ _res); - -/** - * Creates a new COption_EventZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKCOption_EventZ COption_EventZ_clone(const struct LDKCOption_EventZ *NONNULL_PTR orig); - -/** - * Creates a new CResult_COption_EventZDecodeErrorZ in the success state. - */ -struct LDKCResult_COption_EventZDecodeErrorZ CResult_COption_EventZDecodeErrorZ_ok(struct LDKCOption_EventZ o); - -/** - * Creates a new CResult_COption_EventZDecodeErrorZ in the error state. - */ -struct LDKCResult_COption_EventZDecodeErrorZ CResult_COption_EventZDecodeErrorZ_err(struct LDKDecodeError e); - -/** - * Checks if the given object is currently in the success state - */ -bool CResult_COption_EventZDecodeErrorZ_is_ok(const struct LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR o); - -/** - * Frees any resources used by the CResult_COption_EventZDecodeErrorZ. - */ -void CResult_COption_EventZDecodeErrorZ_free(struct LDKCResult_COption_EventZDecodeErrorZ _res); - -/** - * Creates a new CResult_COption_EventZDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKCResult_COption_EventZDecodeErrorZ CResult_COption_EventZDecodeErrorZ_clone(const struct LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR orig); - -/** - * Frees the buffer pointed to by `data` if `datalen` is non-0. - */ -void CVec_MessageSendEventZ_free(struct LDKCVec_MessageSendEventZ _res); +void CVec_PublicKeyZ_free(struct LDKCVec_PublicKeyZ _res); /** * Creates a new tuple which has the same data as `orig` @@ -16801,6 +17430,350 @@ void CResult_ChannelTypeFeaturesDecodeErrorZ_free(struct LDKCResult_ChannelTypeF */ struct LDKCResult_ChannelTypeFeaturesDecodeErrorZ CResult_ChannelTypeFeaturesDecodeErrorZ_clone(const struct LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR orig); +/** + * Creates a new CResult_PaymentPurposeDecodeErrorZ in the success state. + */ +struct LDKCResult_PaymentPurposeDecodeErrorZ CResult_PaymentPurposeDecodeErrorZ_ok(struct LDKPaymentPurpose o); + +/** + * Creates a new CResult_PaymentPurposeDecodeErrorZ in the error state. + */ +struct LDKCResult_PaymentPurposeDecodeErrorZ CResult_PaymentPurposeDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_PaymentPurposeDecodeErrorZ_is_ok(const struct LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_PaymentPurposeDecodeErrorZ. + */ +void CResult_PaymentPurposeDecodeErrorZ_free(struct LDKCResult_PaymentPurposeDecodeErrorZ _res); + +/** + * Creates a new CResult_PaymentPurposeDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_PaymentPurposeDecodeErrorZ CResult_PaymentPurposeDecodeErrorZ_clone(const struct LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR orig); + +/** + * Constructs a new COption_NetworkUpdateZ containing a crate::lightning::routing::gossip::NetworkUpdate + */ +struct LDKCOption_NetworkUpdateZ COption_NetworkUpdateZ_some(struct LDKNetworkUpdate o); + +/** + * Constructs a new COption_NetworkUpdateZ containing nothing + */ +struct LDKCOption_NetworkUpdateZ COption_NetworkUpdateZ_none(void); + +/** + * Frees any resources associated with the crate::lightning::routing::gossip::NetworkUpdate, if we are in the Some state + */ +void COption_NetworkUpdateZ_free(struct LDKCOption_NetworkUpdateZ _res); + +/** + * Creates a new COption_NetworkUpdateZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCOption_NetworkUpdateZ COption_NetworkUpdateZ_clone(const struct LDKCOption_NetworkUpdateZ *NONNULL_PTR orig); + +/** + * Constructs a new COption_PathFailureZ containing a crate::lightning::events::PathFailure + */ +struct LDKCOption_PathFailureZ COption_PathFailureZ_some(struct LDKPathFailure o); + +/** + * Constructs a new COption_PathFailureZ containing nothing + */ +struct LDKCOption_PathFailureZ COption_PathFailureZ_none(void); + +/** + * Frees any resources associated with the crate::lightning::events::PathFailure, if we are in the Some state + */ +void COption_PathFailureZ_free(struct LDKCOption_PathFailureZ _res); + +/** + * Creates a new COption_PathFailureZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCOption_PathFailureZ COption_PathFailureZ_clone(const struct LDKCOption_PathFailureZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_COption_PathFailureZDecodeErrorZ in the success state. + */ +struct LDKCResult_COption_PathFailureZDecodeErrorZ CResult_COption_PathFailureZDecodeErrorZ_ok(struct LDKCOption_PathFailureZ o); + +/** + * Creates a new CResult_COption_PathFailureZDecodeErrorZ in the error state. + */ +struct LDKCResult_COption_PathFailureZDecodeErrorZ CResult_COption_PathFailureZDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_COption_PathFailureZDecodeErrorZ_is_ok(const struct LDKCResult_COption_PathFailureZDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_COption_PathFailureZDecodeErrorZ. + */ +void CResult_COption_PathFailureZDecodeErrorZ_free(struct LDKCResult_COption_PathFailureZDecodeErrorZ _res); + +/** + * Creates a new CResult_COption_PathFailureZDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_COption_PathFailureZDecodeErrorZ CResult_COption_PathFailureZDecodeErrorZ_clone(const struct LDKCResult_COption_PathFailureZDecodeErrorZ *NONNULL_PTR orig); + +/** + * Constructs a new COption_ClosureReasonZ containing a crate::lightning::events::ClosureReason + */ +struct LDKCOption_ClosureReasonZ COption_ClosureReasonZ_some(struct LDKClosureReason o); + +/** + * Constructs a new COption_ClosureReasonZ containing nothing + */ +struct LDKCOption_ClosureReasonZ COption_ClosureReasonZ_none(void); + +/** + * Frees any resources associated with the crate::lightning::events::ClosureReason, if we are in the Some state + */ +void COption_ClosureReasonZ_free(struct LDKCOption_ClosureReasonZ _res); + +/** + * Creates a new COption_ClosureReasonZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCOption_ClosureReasonZ COption_ClosureReasonZ_clone(const struct LDKCOption_ClosureReasonZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_COption_ClosureReasonZDecodeErrorZ in the success state. + */ +struct LDKCResult_COption_ClosureReasonZDecodeErrorZ CResult_COption_ClosureReasonZDecodeErrorZ_ok(struct LDKCOption_ClosureReasonZ o); + +/** + * Creates a new CResult_COption_ClosureReasonZDecodeErrorZ in the error state. + */ +struct LDKCResult_COption_ClosureReasonZDecodeErrorZ CResult_COption_ClosureReasonZDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(const struct LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_COption_ClosureReasonZDecodeErrorZ. + */ +void CResult_COption_ClosureReasonZDecodeErrorZ_free(struct LDKCResult_COption_ClosureReasonZDecodeErrorZ _res); + +/** + * Creates a new CResult_COption_ClosureReasonZDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_COption_ClosureReasonZDecodeErrorZ CResult_COption_ClosureReasonZDecodeErrorZ_clone(const struct LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR orig); + +/** + * Constructs a new COption_HTLCDestinationZ containing a crate::lightning::events::HTLCDestination + */ +struct LDKCOption_HTLCDestinationZ COption_HTLCDestinationZ_some(struct LDKHTLCDestination o); + +/** + * Constructs a new COption_HTLCDestinationZ containing nothing + */ +struct LDKCOption_HTLCDestinationZ COption_HTLCDestinationZ_none(void); + +/** + * Frees any resources associated with the crate::lightning::events::HTLCDestination, if we are in the Some state + */ +void COption_HTLCDestinationZ_free(struct LDKCOption_HTLCDestinationZ _res); + +/** + * Creates a new COption_HTLCDestinationZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCOption_HTLCDestinationZ COption_HTLCDestinationZ_clone(const struct LDKCOption_HTLCDestinationZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_COption_HTLCDestinationZDecodeErrorZ in the success state. + */ +struct LDKCResult_COption_HTLCDestinationZDecodeErrorZ CResult_COption_HTLCDestinationZDecodeErrorZ_ok(struct LDKCOption_HTLCDestinationZ o); + +/** + * Creates a new CResult_COption_HTLCDestinationZDecodeErrorZ in the error state. + */ +struct LDKCResult_COption_HTLCDestinationZDecodeErrorZ CResult_COption_HTLCDestinationZDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_COption_HTLCDestinationZDecodeErrorZ_is_ok(const struct LDKCResult_COption_HTLCDestinationZDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_COption_HTLCDestinationZDecodeErrorZ. + */ +void CResult_COption_HTLCDestinationZDecodeErrorZ_free(struct LDKCResult_COption_HTLCDestinationZDecodeErrorZ _res); + +/** + * Creates a new CResult_COption_HTLCDestinationZDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_COption_HTLCDestinationZDecodeErrorZ CResult_COption_HTLCDestinationZDecodeErrorZ_clone(const struct LDKCResult_COption_HTLCDestinationZDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_PaymentFailureReasonDecodeErrorZ in the success state. + */ +struct LDKCResult_PaymentFailureReasonDecodeErrorZ CResult_PaymentFailureReasonDecodeErrorZ_ok(enum LDKPaymentFailureReason o); + +/** + * Creates a new CResult_PaymentFailureReasonDecodeErrorZ in the error state. + */ +struct LDKCResult_PaymentFailureReasonDecodeErrorZ CResult_PaymentFailureReasonDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_PaymentFailureReasonDecodeErrorZ_is_ok(const struct LDKCResult_PaymentFailureReasonDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_PaymentFailureReasonDecodeErrorZ. + */ +void CResult_PaymentFailureReasonDecodeErrorZ_free(struct LDKCResult_PaymentFailureReasonDecodeErrorZ _res); + +/** + * Creates a new CResult_PaymentFailureReasonDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_PaymentFailureReasonDecodeErrorZ CResult_PaymentFailureReasonDecodeErrorZ_clone(const struct LDKCResult_PaymentFailureReasonDecodeErrorZ *NONNULL_PTR orig); + +/** + * Constructs a new COption_u128Z containing a crate::c_types::U128 + */ +struct LDKCOption_u128Z COption_u128Z_some(struct LDKU128 o); + +/** + * Constructs a new COption_u128Z containing nothing + */ +struct LDKCOption_u128Z COption_u128Z_none(void); + +/** + * Frees any resources associated with the crate::c_types::U128, if we are in the Some state + */ +void COption_u128Z_free(struct LDKCOption_u128Z _res); + +/** + * Creates a new COption_u128Z 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); + +/** + * Constructs a new COption_PaymentFailureReasonZ containing a crate::lightning::events::PaymentFailureReason + */ +struct LDKCOption_PaymentFailureReasonZ COption_PaymentFailureReasonZ_some(enum LDKPaymentFailureReason o); + +/** + * Constructs a new COption_PaymentFailureReasonZ containing nothing + */ +struct LDKCOption_PaymentFailureReasonZ COption_PaymentFailureReasonZ_none(void); + +/** + * Frees any resources associated with the crate::lightning::events::PaymentFailureReason, if we are in the Some state + */ +void COption_PaymentFailureReasonZ_free(struct LDKCOption_PaymentFailureReasonZ _res); + +/** + * Creates a new COption_PaymentFailureReasonZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCOption_PaymentFailureReasonZ COption_PaymentFailureReasonZ_clone(const struct LDKCOption_PaymentFailureReasonZ *NONNULL_PTR orig); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_SpendableOutputDescriptorZ_free(struct LDKCVec_SpendableOutputDescriptorZ _res); + +/** + * Constructs a new COption_EventZ containing a crate::lightning::events::Event + */ +struct LDKCOption_EventZ COption_EventZ_some(struct LDKEvent o); + +/** + * Constructs a new COption_EventZ containing nothing + */ +struct LDKCOption_EventZ COption_EventZ_none(void); + +/** + * Frees any resources associated with the crate::lightning::events::Event, if we are in the Some state + */ +void COption_EventZ_free(struct LDKCOption_EventZ _res); + +/** + * Creates a new COption_EventZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCOption_EventZ COption_EventZ_clone(const struct LDKCOption_EventZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_COption_EventZDecodeErrorZ in the success state. + */ +struct LDKCResult_COption_EventZDecodeErrorZ CResult_COption_EventZDecodeErrorZ_ok(struct LDKCOption_EventZ o); + +/** + * Creates a new CResult_COption_EventZDecodeErrorZ in the error state. + */ +struct LDKCResult_COption_EventZDecodeErrorZ CResult_COption_EventZDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_COption_EventZDecodeErrorZ_is_ok(const struct LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_COption_EventZDecodeErrorZ. + */ +void CResult_COption_EventZDecodeErrorZ_free(struct LDKCResult_COption_EventZDecodeErrorZ _res); + +/** + * Creates a new CResult_COption_EventZDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_COption_EventZDecodeErrorZ CResult_COption_EventZDecodeErrorZ_clone(const struct LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR orig); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_MessageSendEventZ_free(struct LDKCVec_MessageSendEventZ _res); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_ChainHashZ_free(struct LDKCVec_ChainHashZ _res); + +/** + * Creates a new CResult_PublicKeyErrorZ in the success state. + */ +struct LDKCResult_PublicKeyErrorZ CResult_PublicKeyErrorZ_ok(struct LDKPublicKey o); + +/** + * Creates a new CResult_PublicKeyErrorZ in the error state. + */ +struct LDKCResult_PublicKeyErrorZ CResult_PublicKeyErrorZ_err(enum LDKSecp256k1Error e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_PublicKeyErrorZ_is_ok(const struct LDKCResult_PublicKeyErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_PublicKeyErrorZ. + */ +void CResult_PublicKeyErrorZ_free(struct LDKCResult_PublicKeyErrorZ _res); + +/** + * Creates a new CResult_PublicKeyErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_PublicKeyErrorZ CResult_PublicKeyErrorZ_clone(const struct LDKCResult_PublicKeyErrorZ *NONNULL_PTR orig); + /** * Creates a new CResult_NodeIdDecodeErrorZ in the success state. */ @@ -17428,11 +18401,6 @@ bool CResult_WriteableEcdsaChannelSignerDecodeErrorZ_is_ok(const struct LDKCResu */ void CResult_WriteableEcdsaChannelSignerDecodeErrorZ_free(struct LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ _res); -/** - * Frees the buffer pointed to by `data` if `datalen` is non-0. - */ -void CVec_u8Z_free(struct LDKCVec_u8Z _res); - /** * Frees the buffer pointed to by `data` if `datalen` is non-0. */ @@ -18117,6 +19085,32 @@ void CResult_COption_APIErrorZDecodeErrorZ_free(struct LDKCResult_COption_APIErr */ struct LDKCResult_COption_APIErrorZDecodeErrorZ CResult_COption_APIErrorZDecodeErrorZ_clone(const struct LDKCResult_COption_APIErrorZDecodeErrorZ *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_OutPointDecodeErrorZ in the success state. */ @@ -18256,32 +19250,6 @@ void CResult_StringErrorZ_free(struct LDKCResult_StringErrorZ _res); */ struct LDKCResult_StringErrorZ CResult_StringErrorZ_clone(const struct LDKCResult_StringErrorZ *NONNULL_PTR orig); -/** - * Creates a new CResult_PublicKeyErrorZ in the success state. - */ -struct LDKCResult_PublicKeyErrorZ CResult_PublicKeyErrorZ_ok(struct LDKPublicKey o); - -/** - * Creates a new CResult_PublicKeyErrorZ in the error state. - */ -struct LDKCResult_PublicKeyErrorZ CResult_PublicKeyErrorZ_err(enum LDKSecp256k1Error e); - -/** - * Checks if the given object is currently in the success state - */ -bool CResult_PublicKeyErrorZ_is_ok(const struct LDKCResult_PublicKeyErrorZ *NONNULL_PTR o); - -/** - * Frees any resources used by the CResult_PublicKeyErrorZ. - */ -void CResult_PublicKeyErrorZ_free(struct LDKCResult_PublicKeyErrorZ _res); - -/** - * Creates a new CResult_PublicKeyErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKCResult_PublicKeyErrorZ CResult_PublicKeyErrorZ_clone(const struct LDKCResult_PublicKeyErrorZ *NONNULL_PTR orig); - /** * Creates a new CResult_ChannelMonitorUpdateDecodeErrorZ in the success state. */ @@ -18647,90 +19615,168 @@ struct LDKCResult_NonePeerHandleErrorZ CResult_NonePeerHandleErrorZ_err(struct L /** * Checks if the given object is currently in the success state */ -bool CResult_NonePeerHandleErrorZ_is_ok(const struct LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR o); +bool CResult_NonePeerHandleErrorZ_is_ok(const struct LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_NonePeerHandleErrorZ. + */ +void CResult_NonePeerHandleErrorZ_free(struct LDKCResult_NonePeerHandleErrorZ _res); + +/** + * Creates a new CResult_NonePeerHandleErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_NonePeerHandleErrorZ CResult_NonePeerHandleErrorZ_clone(const struct LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_boolPeerHandleErrorZ in the success state. + */ +struct LDKCResult_boolPeerHandleErrorZ CResult_boolPeerHandleErrorZ_ok(bool o); + +/** + * Creates a new CResult_boolPeerHandleErrorZ in the error state. + */ +struct LDKCResult_boolPeerHandleErrorZ CResult_boolPeerHandleErrorZ_err(struct LDKPeerHandleError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_boolPeerHandleErrorZ_is_ok(const struct LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_boolPeerHandleErrorZ. + */ +void CResult_boolPeerHandleErrorZ_free(struct LDKCResult_boolPeerHandleErrorZ _res); + +/** + * Creates a new CResult_boolPeerHandleErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_boolPeerHandleErrorZ CResult_boolPeerHandleErrorZ_clone(const struct LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_TxOutUtxoLookupErrorZ in the success state. + */ +struct LDKCResult_TxOutUtxoLookupErrorZ CResult_TxOutUtxoLookupErrorZ_ok(struct LDKTxOut o); + +/** + * Creates a new CResult_TxOutUtxoLookupErrorZ in the error state. + */ +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); + +/** + * Frees any resources used by the CResult_TxOutUtxoLookupErrorZ. + */ +void CResult_TxOutUtxoLookupErrorZ_free(struct LDKCResult_TxOutUtxoLookupErrorZ _res); + +/** + * Creates a new CResult_TxOutUtxoLookupErrorZ 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); + +/** + * Creates a new CResult_NoneSendErrorZ in the success state. + */ +struct LDKCResult_NoneSendErrorZ CResult_NoneSendErrorZ_ok(void); + +/** + * Creates a new CResult_NoneSendErrorZ in the error state. + */ +struct LDKCResult_NoneSendErrorZ CResult_NoneSendErrorZ_err(struct LDKSendError e); /** - * Frees any resources used by the CResult_NonePeerHandleErrorZ. + * Checks if the given object is currently in the success state */ -void CResult_NonePeerHandleErrorZ_free(struct LDKCResult_NonePeerHandleErrorZ _res); +bool CResult_NoneSendErrorZ_is_ok(const struct LDKCResult_NoneSendErrorZ *NONNULL_PTR o); /** - * Creates a new CResult_NonePeerHandleErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Frees any resources used by the CResult_NoneSendErrorZ. */ -struct LDKCResult_NonePeerHandleErrorZ CResult_NonePeerHandleErrorZ_clone(const struct LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR orig); +void CResult_NoneSendErrorZ_free(struct LDKCResult_NoneSendErrorZ _res); /** - * Creates a new CResult_boolPeerHandleErrorZ in the success state. + * Creates a new CResult_BlindedPathNoneZ in the success state. */ -struct LDKCResult_boolPeerHandleErrorZ CResult_boolPeerHandleErrorZ_ok(bool o); +struct LDKCResult_BlindedPathNoneZ CResult_BlindedPathNoneZ_ok(struct LDKBlindedPath o); /** - * Creates a new CResult_boolPeerHandleErrorZ in the error state. + * Creates a new CResult_BlindedPathNoneZ in the error state. */ -struct LDKCResult_boolPeerHandleErrorZ CResult_boolPeerHandleErrorZ_err(struct LDKPeerHandleError e); +struct LDKCResult_BlindedPathNoneZ CResult_BlindedPathNoneZ_err(void); /** * Checks if the given object is currently in the success state */ -bool CResult_boolPeerHandleErrorZ_is_ok(const struct LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR o); +bool CResult_BlindedPathNoneZ_is_ok(const struct LDKCResult_BlindedPathNoneZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_boolPeerHandleErrorZ. + * Frees any resources used by the CResult_BlindedPathNoneZ. */ -void CResult_boolPeerHandleErrorZ_free(struct LDKCResult_boolPeerHandleErrorZ _res); +void CResult_BlindedPathNoneZ_free(struct LDKCResult_BlindedPathNoneZ _res); /** - * Creates a new CResult_boolPeerHandleErrorZ which has the same data as `orig` + * Creates a new CResult_BlindedPathNoneZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_boolPeerHandleErrorZ CResult_boolPeerHandleErrorZ_clone(const struct LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR orig); +struct LDKCResult_BlindedPathNoneZ CResult_BlindedPathNoneZ_clone(const struct LDKCResult_BlindedPathNoneZ *NONNULL_PTR orig); /** - * Creates a new CResult_TxOutUtxoLookupErrorZ in the success state. + * Creates a new CResult_BlindedPathDecodeErrorZ in the success state. */ -struct LDKCResult_TxOutUtxoLookupErrorZ CResult_TxOutUtxoLookupErrorZ_ok(struct LDKTxOut o); +struct LDKCResult_BlindedPathDecodeErrorZ CResult_BlindedPathDecodeErrorZ_ok(struct LDKBlindedPath o); /** - * Creates a new CResult_TxOutUtxoLookupErrorZ in the error state. + * Creates a new CResult_BlindedPathDecodeErrorZ in the error state. */ -struct LDKCResult_TxOutUtxoLookupErrorZ CResult_TxOutUtxoLookupErrorZ_err(enum LDKUtxoLookupError e); +struct LDKCResult_BlindedPathDecodeErrorZ CResult_BlindedPathDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_TxOutUtxoLookupErrorZ_is_ok(const struct LDKCResult_TxOutUtxoLookupErrorZ *NONNULL_PTR o); +bool CResult_BlindedPathDecodeErrorZ_is_ok(const struct LDKCResult_BlindedPathDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_TxOutUtxoLookupErrorZ. + * Frees any resources used by the CResult_BlindedPathDecodeErrorZ. */ -void CResult_TxOutUtxoLookupErrorZ_free(struct LDKCResult_TxOutUtxoLookupErrorZ _res); +void CResult_BlindedPathDecodeErrorZ_free(struct LDKCResult_BlindedPathDecodeErrorZ _res); /** - * Creates a new CResult_TxOutUtxoLookupErrorZ which has the same data as `orig` + * Creates a new CResult_BlindedPathDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_TxOutUtxoLookupErrorZ CResult_TxOutUtxoLookupErrorZ_clone(const struct LDKCResult_TxOutUtxoLookupErrorZ *NONNULL_PTR orig); +struct LDKCResult_BlindedPathDecodeErrorZ CResult_BlindedPathDecodeErrorZ_clone(const struct LDKCResult_BlindedPathDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_NoneSendErrorZ in the success state. + * Creates a new CResult_BlindedHopDecodeErrorZ in the success state. */ -struct LDKCResult_NoneSendErrorZ CResult_NoneSendErrorZ_ok(void); +struct LDKCResult_BlindedHopDecodeErrorZ CResult_BlindedHopDecodeErrorZ_ok(struct LDKBlindedHop o); /** - * Creates a new CResult_NoneSendErrorZ in the error state. + * Creates a new CResult_BlindedHopDecodeErrorZ in the error state. */ -struct LDKCResult_NoneSendErrorZ CResult_NoneSendErrorZ_err(struct LDKSendError e); +struct LDKCResult_BlindedHopDecodeErrorZ CResult_BlindedHopDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_NoneSendErrorZ_is_ok(const struct LDKCResult_NoneSendErrorZ *NONNULL_PTR o); +bool CResult_BlindedHopDecodeErrorZ_is_ok(const struct LDKCResult_BlindedHopDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_NoneSendErrorZ. + * Frees any resources used by the CResult_BlindedHopDecodeErrorZ. */ -void CResult_NoneSendErrorZ_free(struct LDKCResult_NoneSendErrorZ _res); +void CResult_BlindedHopDecodeErrorZ_free(struct LDKCResult_BlindedHopDecodeErrorZ _res); + +/** + * Creates a new CResult_BlindedHopDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_BlindedHopDecodeErrorZ CResult_BlindedHopDecodeErrorZ_clone(const struct LDKCResult_BlindedHopDecodeErrorZ *NONNULL_PTR orig); /** * Creates a new CResult_SiPrefixParseErrorZ in the success state. @@ -18935,6 +19981,11 @@ void CResult_InvoiceSemanticErrorZ_free(struct LDKCResult_InvoiceSemanticErrorZ */ struct LDKCResult_InvoiceSemanticErrorZ CResult_InvoiceSemanticErrorZ_clone(const struct LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR orig); +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_AddressZ_free(struct LDKCVec_AddressZ _res); + /** * Creates a new CResult_DescriptionCreationErrorZ in the success state. */ @@ -18987,26 +20038,6 @@ void CResult_PrivateRouteCreationErrorZ_free(struct LDKCResult_PrivateRouteCreat */ struct LDKCResult_PrivateRouteCreationErrorZ CResult_PrivateRouteCreationErrorZ_clone(const struct LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR orig); -/** - * Creates a new CResult_u32GraphSyncErrorZ in the success state. - */ -struct LDKCResult_u32GraphSyncErrorZ CResult_u32GraphSyncErrorZ_ok(uint32_t o); - -/** - * Creates a new CResult_u32GraphSyncErrorZ in the error state. - */ -struct LDKCResult_u32GraphSyncErrorZ CResult_u32GraphSyncErrorZ_err(struct LDKGraphSyncError e); - -/** - * Checks if the given object is currently in the success state - */ -bool CResult_u32GraphSyncErrorZ_is_ok(const struct LDKCResult_u32GraphSyncErrorZ *NONNULL_PTR o); - -/** - * Frees any resources used by the CResult_u32GraphSyncErrorZ. - */ -void CResult_u32GraphSyncErrorZ_free(struct LDKCResult_u32GraphSyncErrorZ _res); - /** * Creates a new CResult_NetAddressDecodeErrorZ in the success state. */ @@ -19607,867 +20638,457 @@ struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ CResult_UnsignedChanne /** * Creates a new CResult_UnsignedChannelAnnouncementDecodeErrorZ in the error state. */ -struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(struct LDKDecodeError e); - -/** - * Checks if the given object is currently in the success state - */ -bool CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(const struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR o); - -/** - * Frees any resources used by the CResult_UnsignedChannelAnnouncementDecodeErrorZ. - */ -void CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res); - -/** - * Creates a new CResult_UnsignedChannelAnnouncementDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(const struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR orig); - -/** - * Creates a new CResult_ChannelAnnouncementDecodeErrorZ in the success state. - */ -struct LDKCResult_ChannelAnnouncementDecodeErrorZ CResult_ChannelAnnouncementDecodeErrorZ_ok(struct LDKChannelAnnouncement o); - -/** - * Creates a new CResult_ChannelAnnouncementDecodeErrorZ in the error state. - */ -struct LDKCResult_ChannelAnnouncementDecodeErrorZ CResult_ChannelAnnouncementDecodeErrorZ_err(struct LDKDecodeError e); - -/** - * Checks if the given object is currently in the success state - */ -bool CResult_ChannelAnnouncementDecodeErrorZ_is_ok(const struct LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR o); - -/** - * Frees any resources used by the CResult_ChannelAnnouncementDecodeErrorZ. - */ -void CResult_ChannelAnnouncementDecodeErrorZ_free(struct LDKCResult_ChannelAnnouncementDecodeErrorZ _res); - -/** - * Creates a new CResult_ChannelAnnouncementDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKCResult_ChannelAnnouncementDecodeErrorZ CResult_ChannelAnnouncementDecodeErrorZ_clone(const struct LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR orig); - -/** - * Creates a new CResult_UnsignedChannelUpdateDecodeErrorZ in the success state. - */ -struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ CResult_UnsignedChannelUpdateDecodeErrorZ_ok(struct LDKUnsignedChannelUpdate o); - -/** - * Creates a new CResult_UnsignedChannelUpdateDecodeErrorZ in the error state. - */ -struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ CResult_UnsignedChannelUpdateDecodeErrorZ_err(struct LDKDecodeError e); - -/** - * Checks if the given object is currently in the success state - */ -bool CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(const struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR o); - -/** - * Frees any resources used by the CResult_UnsignedChannelUpdateDecodeErrorZ. - */ -void CResult_UnsignedChannelUpdateDecodeErrorZ_free(struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res); - -/** - * Creates a new CResult_UnsignedChannelUpdateDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ CResult_UnsignedChannelUpdateDecodeErrorZ_clone(const struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR orig); - -/** - * Creates a new CResult_ChannelUpdateDecodeErrorZ in the success state. - */ -struct LDKCResult_ChannelUpdateDecodeErrorZ CResult_ChannelUpdateDecodeErrorZ_ok(struct LDKChannelUpdate o); - -/** - * Creates a new CResult_ChannelUpdateDecodeErrorZ in the error state. - */ -struct LDKCResult_ChannelUpdateDecodeErrorZ CResult_ChannelUpdateDecodeErrorZ_err(struct LDKDecodeError e); - -/** - * Checks if the given object is currently in the success state - */ -bool CResult_ChannelUpdateDecodeErrorZ_is_ok(const struct LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR o); - -/** - * Frees any resources used by the CResult_ChannelUpdateDecodeErrorZ. - */ -void CResult_ChannelUpdateDecodeErrorZ_free(struct LDKCResult_ChannelUpdateDecodeErrorZ _res); - -/** - * Creates a new CResult_ChannelUpdateDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKCResult_ChannelUpdateDecodeErrorZ CResult_ChannelUpdateDecodeErrorZ_clone(const struct LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR orig); - -/** - * Creates a new CResult_ErrorMessageDecodeErrorZ in the success state. - */ -struct LDKCResult_ErrorMessageDecodeErrorZ CResult_ErrorMessageDecodeErrorZ_ok(struct LDKErrorMessage o); - -/** - * Creates a new CResult_ErrorMessageDecodeErrorZ in the error state. - */ -struct LDKCResult_ErrorMessageDecodeErrorZ CResult_ErrorMessageDecodeErrorZ_err(struct LDKDecodeError e); - -/** - * Checks if the given object is currently in the success state - */ -bool CResult_ErrorMessageDecodeErrorZ_is_ok(const struct LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR o); - -/** - * Frees any resources used by the CResult_ErrorMessageDecodeErrorZ. - */ -void CResult_ErrorMessageDecodeErrorZ_free(struct LDKCResult_ErrorMessageDecodeErrorZ _res); - -/** - * Creates a new CResult_ErrorMessageDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKCResult_ErrorMessageDecodeErrorZ CResult_ErrorMessageDecodeErrorZ_clone(const struct LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR orig); - -/** - * Creates a new CResult_WarningMessageDecodeErrorZ in the success state. - */ -struct LDKCResult_WarningMessageDecodeErrorZ CResult_WarningMessageDecodeErrorZ_ok(struct LDKWarningMessage o); - -/** - * Creates a new CResult_WarningMessageDecodeErrorZ in the error state. - */ -struct LDKCResult_WarningMessageDecodeErrorZ CResult_WarningMessageDecodeErrorZ_err(struct LDKDecodeError e); - -/** - * Checks if the given object is currently in the success state - */ -bool CResult_WarningMessageDecodeErrorZ_is_ok(const struct LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR o); - -/** - * Frees any resources used by the CResult_WarningMessageDecodeErrorZ. - */ -void CResult_WarningMessageDecodeErrorZ_free(struct LDKCResult_WarningMessageDecodeErrorZ _res); - -/** - * Creates a new CResult_WarningMessageDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKCResult_WarningMessageDecodeErrorZ CResult_WarningMessageDecodeErrorZ_clone(const struct LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR orig); - -/** - * Creates a new CResult_UnsignedNodeAnnouncementDecodeErrorZ in the success state. - */ -struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(struct LDKUnsignedNodeAnnouncement o); - -/** - * Creates a new CResult_UnsignedNodeAnnouncementDecodeErrorZ in the error state. - */ -struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(struct LDKDecodeError e); - -/** - * Checks if the given object is currently in the success state - */ -bool CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(const struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR o); - -/** - * Frees any resources used by the CResult_UnsignedNodeAnnouncementDecodeErrorZ. - */ -void CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res); - -/** - * Creates a new CResult_UnsignedNodeAnnouncementDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(const struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR orig); - -/** - * Creates a new CResult_NodeAnnouncementDecodeErrorZ in the success state. - */ -struct LDKCResult_NodeAnnouncementDecodeErrorZ CResult_NodeAnnouncementDecodeErrorZ_ok(struct LDKNodeAnnouncement o); - -/** - * Creates a new CResult_NodeAnnouncementDecodeErrorZ in the error state. - */ -struct LDKCResult_NodeAnnouncementDecodeErrorZ CResult_NodeAnnouncementDecodeErrorZ_err(struct LDKDecodeError e); - -/** - * Checks if the given object is currently in the success state - */ -bool CResult_NodeAnnouncementDecodeErrorZ_is_ok(const struct LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR o); - -/** - * Frees any resources used by the CResult_NodeAnnouncementDecodeErrorZ. - */ -void CResult_NodeAnnouncementDecodeErrorZ_free(struct LDKCResult_NodeAnnouncementDecodeErrorZ _res); - -/** - * Creates a new CResult_NodeAnnouncementDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKCResult_NodeAnnouncementDecodeErrorZ CResult_NodeAnnouncementDecodeErrorZ_clone(const struct LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR orig); - -/** - * Creates a new CResult_QueryShortChannelIdsDecodeErrorZ in the success state. - */ -struct LDKCResult_QueryShortChannelIdsDecodeErrorZ CResult_QueryShortChannelIdsDecodeErrorZ_ok(struct LDKQueryShortChannelIds o); - -/** - * Creates a new CResult_QueryShortChannelIdsDecodeErrorZ in the error state. - */ -struct LDKCResult_QueryShortChannelIdsDecodeErrorZ CResult_QueryShortChannelIdsDecodeErrorZ_err(struct LDKDecodeError e); - -/** - * Checks if the given object is currently in the success state - */ -bool CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(const struct LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR o); - -/** - * Frees any resources used by the CResult_QueryShortChannelIdsDecodeErrorZ. - */ -void CResult_QueryShortChannelIdsDecodeErrorZ_free(struct LDKCResult_QueryShortChannelIdsDecodeErrorZ _res); - -/** - * Creates a new CResult_QueryShortChannelIdsDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKCResult_QueryShortChannelIdsDecodeErrorZ CResult_QueryShortChannelIdsDecodeErrorZ_clone(const struct LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR orig); - -/** - * Creates a new CResult_ReplyShortChannelIdsEndDecodeErrorZ in the success state. - */ -struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(struct LDKReplyShortChannelIdsEnd o); - -/** - * Creates a new CResult_ReplyShortChannelIdsEndDecodeErrorZ in the error state. - */ -struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(struct LDKDecodeError e); - -/** - * Checks if the given object is currently in the success state - */ -bool CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(const struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR o); - -/** - * Frees any resources used by the CResult_ReplyShortChannelIdsEndDecodeErrorZ. - */ -void CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res); - -/** - * Creates a new CResult_ReplyShortChannelIdsEndDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(const struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR orig); - -/** - * Creates a new CResult_QueryChannelRangeDecodeErrorZ in the success state. - */ -struct LDKCResult_QueryChannelRangeDecodeErrorZ CResult_QueryChannelRangeDecodeErrorZ_ok(struct LDKQueryChannelRange o); - -/** - * Creates a new CResult_QueryChannelRangeDecodeErrorZ in the error state. - */ -struct LDKCResult_QueryChannelRangeDecodeErrorZ CResult_QueryChannelRangeDecodeErrorZ_err(struct LDKDecodeError e); - -/** - * Checks if the given object is currently in the success state - */ -bool CResult_QueryChannelRangeDecodeErrorZ_is_ok(const struct LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR o); - -/** - * Frees any resources used by the CResult_QueryChannelRangeDecodeErrorZ. - */ -void CResult_QueryChannelRangeDecodeErrorZ_free(struct LDKCResult_QueryChannelRangeDecodeErrorZ _res); - -/** - * Creates a new CResult_QueryChannelRangeDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKCResult_QueryChannelRangeDecodeErrorZ CResult_QueryChannelRangeDecodeErrorZ_clone(const struct LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR orig); - -/** - * Creates a new CResult_ReplyChannelRangeDecodeErrorZ in the success state. - */ -struct LDKCResult_ReplyChannelRangeDecodeErrorZ CResult_ReplyChannelRangeDecodeErrorZ_ok(struct LDKReplyChannelRange o); - -/** - * Creates a new CResult_ReplyChannelRangeDecodeErrorZ in the error state. - */ -struct LDKCResult_ReplyChannelRangeDecodeErrorZ CResult_ReplyChannelRangeDecodeErrorZ_err(struct LDKDecodeError e); - -/** - * Checks if the given object is currently in the success state - */ -bool CResult_ReplyChannelRangeDecodeErrorZ_is_ok(const struct LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR o); - -/** - * Frees any resources used by the CResult_ReplyChannelRangeDecodeErrorZ. - */ -void CResult_ReplyChannelRangeDecodeErrorZ_free(struct LDKCResult_ReplyChannelRangeDecodeErrorZ _res); - -/** - * Creates a new CResult_ReplyChannelRangeDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKCResult_ReplyChannelRangeDecodeErrorZ CResult_ReplyChannelRangeDecodeErrorZ_clone(const struct LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR orig); - -/** - * Creates a new CResult_GossipTimestampFilterDecodeErrorZ in the success state. - */ -struct LDKCResult_GossipTimestampFilterDecodeErrorZ CResult_GossipTimestampFilterDecodeErrorZ_ok(struct LDKGossipTimestampFilter o); - -/** - * Creates a new CResult_GossipTimestampFilterDecodeErrorZ in the error state. - */ -struct LDKCResult_GossipTimestampFilterDecodeErrorZ CResult_GossipTimestampFilterDecodeErrorZ_err(struct LDKDecodeError e); - -/** - * Checks if the given object is currently in the success state - */ -bool CResult_GossipTimestampFilterDecodeErrorZ_is_ok(const struct LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR o); - -/** - * Frees any resources used by the CResult_GossipTimestampFilterDecodeErrorZ. - */ -void CResult_GossipTimestampFilterDecodeErrorZ_free(struct LDKCResult_GossipTimestampFilterDecodeErrorZ _res); - -/** - * Creates a new CResult_GossipTimestampFilterDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -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_InvoiceSignOrCreationErrorZ in the success state. - */ -struct LDKCResult_InvoiceSignOrCreationErrorZ CResult_InvoiceSignOrCreationErrorZ_ok(struct LDKInvoice o); - -/** - * Creates a new CResult_InvoiceSignOrCreationErrorZ in the error state. - */ -struct LDKCResult_InvoiceSignOrCreationErrorZ CResult_InvoiceSignOrCreationErrorZ_err(struct LDKSignOrCreationError e); - -/** - * Checks if the given object is currently in the success state - */ -bool CResult_InvoiceSignOrCreationErrorZ_is_ok(const struct LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR o); - -/** - * Frees any resources used by the CResult_InvoiceSignOrCreationErrorZ. - */ -void CResult_InvoiceSignOrCreationErrorZ_free(struct LDKCResult_InvoiceSignOrCreationErrorZ _res); - -/** - * Creates a new CResult_InvoiceSignOrCreationErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKCResult_InvoiceSignOrCreationErrorZ CResult_InvoiceSignOrCreationErrorZ_clone(const struct LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR orig); - -/** - * Constructs a new COption_FilterZ containing a crate::lightning::chain::Filter - */ -struct LDKCOption_FilterZ COption_FilterZ_some(struct LDKFilter o); - -/** - * Constructs a new COption_FilterZ containing nothing - */ -struct LDKCOption_FilterZ COption_FilterZ_none(void); - -/** - * Frees any resources associated with the crate::lightning::chain::Filter, if we are in the Some state - */ -void COption_FilterZ_free(struct LDKCOption_FilterZ _res); - -/** - * Creates a new CResult_LockedChannelMonitorNoneZ in the success state. - */ -struct LDKCResult_LockedChannelMonitorNoneZ CResult_LockedChannelMonitorNoneZ_ok(struct LDKLockedChannelMonitor o); - -/** - * Creates a new CResult_LockedChannelMonitorNoneZ in the error state. - */ -struct LDKCResult_LockedChannelMonitorNoneZ CResult_LockedChannelMonitorNoneZ_err(void); - -/** - * Checks if the given object is currently in the success state - */ -bool CResult_LockedChannelMonitorNoneZ_is_ok(const struct LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR o); - -/** - * Frees any resources used by the CResult_LockedChannelMonitorNoneZ. - */ -void CResult_LockedChannelMonitorNoneZ_free(struct LDKCResult_LockedChannelMonitorNoneZ _res); - -/** - * Frees the buffer pointed to by `data` if `datalen` is non-0. - */ -void CVec_OutPointZ_free(struct LDKCVec_OutPointZ _res); - -/** - * Frees the buffer pointed to by `data` if `datalen` is non-0. - */ -void CVec_MonitorUpdateIdZ_free(struct LDKCVec_MonitorUpdateIdZ _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_MonitorUpdateIdZZ C2Tuple_OutPointCVec_MonitorUpdateIdZZ_clone(const struct LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ *NONNULL_PTR orig); - -/** - * Creates a new C2Tuple_OutPointCVec_MonitorUpdateIdZZ from the contained elements. - */ -struct LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ C2Tuple_OutPointCVec_MonitorUpdateIdZZ_new(struct LDKOutPoint a, struct LDKCVec_MonitorUpdateIdZ b); - -/** - * Frees any resources used by the C2Tuple_OutPointCVec_MonitorUpdateIdZZ. - */ -void C2Tuple_OutPointCVec_MonitorUpdateIdZZ_free(struct LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ _res); +struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Checks if the given object is currently in the success state */ -void CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ_free(struct LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ _res); +bool CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(const struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the PaymentPurpose + * Frees any resources used by the CResult_UnsignedChannelAnnouncementDecodeErrorZ. */ -void PaymentPurpose_free(struct LDKPaymentPurpose this_ptr); +void CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res); /** - * Creates a copy of the PaymentPurpose + * Creates a new CResult_UnsignedChannelAnnouncementDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKPaymentPurpose PaymentPurpose_clone(const struct LDKPaymentPurpose *NONNULL_PTR orig); +struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(const struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR orig); /** - * Utility method to constructs a new InvoicePayment-variant PaymentPurpose + * Creates a new CResult_ChannelAnnouncementDecodeErrorZ in the success state. */ -struct LDKPaymentPurpose PaymentPurpose_invoice_payment(struct LDKThirtyTwoBytes payment_preimage, struct LDKThirtyTwoBytes payment_secret); +struct LDKCResult_ChannelAnnouncementDecodeErrorZ CResult_ChannelAnnouncementDecodeErrorZ_ok(struct LDKChannelAnnouncement o); /** - * Utility method to constructs a new SpontaneousPayment-variant PaymentPurpose + * Creates a new CResult_ChannelAnnouncementDecodeErrorZ in the error state. */ -struct LDKPaymentPurpose PaymentPurpose_spontaneous_payment(struct LDKThirtyTwoBytes a); +struct LDKCResult_ChannelAnnouncementDecodeErrorZ CResult_ChannelAnnouncementDecodeErrorZ_err(struct LDKDecodeError e); /** - * Checks if two PaymentPurposes contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Checks if the given object is currently in the success state */ -bool PaymentPurpose_eq(const struct LDKPaymentPurpose *NONNULL_PTR a, const struct LDKPaymentPurpose *NONNULL_PTR b); +bool CResult_ChannelAnnouncementDecodeErrorZ_is_ok(const struct LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR o); /** - * Serialize the PaymentPurpose object into a byte array which can be read by PaymentPurpose_read + * Frees any resources used by the CResult_ChannelAnnouncementDecodeErrorZ. */ -struct LDKCVec_u8Z PaymentPurpose_write(const struct LDKPaymentPurpose *NONNULL_PTR obj); +void CResult_ChannelAnnouncementDecodeErrorZ_free(struct LDKCResult_ChannelAnnouncementDecodeErrorZ _res); /** - * Read a PaymentPurpose from a byte array, created by PaymentPurpose_write + * Creates a new CResult_ChannelAnnouncementDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_PaymentPurposeDecodeErrorZ PaymentPurpose_read(struct LDKu8slice ser); +struct LDKCResult_ChannelAnnouncementDecodeErrorZ CResult_ChannelAnnouncementDecodeErrorZ_clone(const struct LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR orig); /** - * Frees any resources used by the PathFailure + * Creates a new CResult_UnsignedChannelUpdateDecodeErrorZ in the success state. */ -void PathFailure_free(struct LDKPathFailure this_ptr); +struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ CResult_UnsignedChannelUpdateDecodeErrorZ_ok(struct LDKUnsignedChannelUpdate o); /** - * Creates a copy of the PathFailure + * Creates a new CResult_UnsignedChannelUpdateDecodeErrorZ in the error state. */ -struct LDKPathFailure PathFailure_clone(const struct LDKPathFailure *NONNULL_PTR orig); +struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ CResult_UnsignedChannelUpdateDecodeErrorZ_err(struct LDKDecodeError e); /** - * Utility method to constructs a new InitialSend-variant PathFailure + * Checks if the given object is currently in the success state */ -struct LDKPathFailure PathFailure_initial_send(struct LDKAPIError err); +bool CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(const struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR o); /** - * Utility method to constructs a new OnPath-variant PathFailure + * Frees any resources used by the CResult_UnsignedChannelUpdateDecodeErrorZ. */ -struct LDKPathFailure PathFailure_on_path(struct LDKCOption_NetworkUpdateZ network_update); +void CResult_UnsignedChannelUpdateDecodeErrorZ_free(struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res); /** - * Checks if two PathFailures contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Creates a new CResult_UnsignedChannelUpdateDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -bool PathFailure_eq(const struct LDKPathFailure *NONNULL_PTR a, const struct LDKPathFailure *NONNULL_PTR b); +struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ CResult_UnsignedChannelUpdateDecodeErrorZ_clone(const struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR orig); /** - * Serialize the PathFailure object into a byte array which can be read by PathFailure_read + * Creates a new CResult_ChannelUpdateDecodeErrorZ in the success state. */ -struct LDKCVec_u8Z PathFailure_write(const struct LDKPathFailure *NONNULL_PTR obj); +struct LDKCResult_ChannelUpdateDecodeErrorZ CResult_ChannelUpdateDecodeErrorZ_ok(struct LDKChannelUpdate o); /** - * Read a PathFailure from a byte array, created by PathFailure_write + * Creates a new CResult_ChannelUpdateDecodeErrorZ in the error state. */ -struct LDKCResult_COption_PathFailureZDecodeErrorZ PathFailure_read(struct LDKu8slice ser); +struct LDKCResult_ChannelUpdateDecodeErrorZ CResult_ChannelUpdateDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees any resources used by the ClosureReason + * Checks if the given object is currently in the success state */ -void ClosureReason_free(struct LDKClosureReason this_ptr); +bool CResult_ChannelUpdateDecodeErrorZ_is_ok(const struct LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR o); /** - * Creates a copy of the ClosureReason + * Frees any resources used by the CResult_ChannelUpdateDecodeErrorZ. */ -struct LDKClosureReason ClosureReason_clone(const struct LDKClosureReason *NONNULL_PTR orig); +void CResult_ChannelUpdateDecodeErrorZ_free(struct LDKCResult_ChannelUpdateDecodeErrorZ _res); /** - * Utility method to constructs a new CounterpartyForceClosed-variant ClosureReason + * Creates a new CResult_ChannelUpdateDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKClosureReason ClosureReason_counterparty_force_closed(struct LDKStr peer_msg); +struct LDKCResult_ChannelUpdateDecodeErrorZ CResult_ChannelUpdateDecodeErrorZ_clone(const struct LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR orig); /** - * Utility method to constructs a new HolderForceClosed-variant ClosureReason + * Creates a new CResult_ErrorMessageDecodeErrorZ in the success state. */ -struct LDKClosureReason ClosureReason_holder_force_closed(void); +struct LDKCResult_ErrorMessageDecodeErrorZ CResult_ErrorMessageDecodeErrorZ_ok(struct LDKErrorMessage o); /** - * Utility method to constructs a new CooperativeClosure-variant ClosureReason + * Creates a new CResult_ErrorMessageDecodeErrorZ in the error state. */ -struct LDKClosureReason ClosureReason_cooperative_closure(void); +struct LDKCResult_ErrorMessageDecodeErrorZ CResult_ErrorMessageDecodeErrorZ_err(struct LDKDecodeError e); /** - * Utility method to constructs a new CommitmentTxConfirmed-variant ClosureReason + * Checks if the given object is currently in the success state */ -struct LDKClosureReason ClosureReason_commitment_tx_confirmed(void); +bool CResult_ErrorMessageDecodeErrorZ_is_ok(const struct LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR o); /** - * Utility method to constructs a new FundingTimedOut-variant ClosureReason + * Frees any resources used by the CResult_ErrorMessageDecodeErrorZ. */ -struct LDKClosureReason ClosureReason_funding_timed_out(void); +void CResult_ErrorMessageDecodeErrorZ_free(struct LDKCResult_ErrorMessageDecodeErrorZ _res); /** - * Utility method to constructs a new ProcessingError-variant ClosureReason + * Creates a new CResult_ErrorMessageDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKClosureReason ClosureReason_processing_error(struct LDKStr err); +struct LDKCResult_ErrorMessageDecodeErrorZ CResult_ErrorMessageDecodeErrorZ_clone(const struct LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR orig); /** - * Utility method to constructs a new DisconnectedPeer-variant ClosureReason + * Creates a new CResult_WarningMessageDecodeErrorZ in the success state. */ -struct LDKClosureReason ClosureReason_disconnected_peer(void); +struct LDKCResult_WarningMessageDecodeErrorZ CResult_WarningMessageDecodeErrorZ_ok(struct LDKWarningMessage o); /** - * Utility method to constructs a new OutdatedChannelManager-variant ClosureReason + * Creates a new CResult_WarningMessageDecodeErrorZ in the error state. */ -struct LDKClosureReason ClosureReason_outdated_channel_manager(void); +struct LDKCResult_WarningMessageDecodeErrorZ CResult_WarningMessageDecodeErrorZ_err(struct LDKDecodeError e); /** - * Checks if two ClosureReasons contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Checks if the given object is currently in the success state */ -bool ClosureReason_eq(const struct LDKClosureReason *NONNULL_PTR a, const struct LDKClosureReason *NONNULL_PTR b); +bool CResult_WarningMessageDecodeErrorZ_is_ok(const struct LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR o); /** - * Serialize the ClosureReason object into a byte array which can be read by ClosureReason_read + * Frees any resources used by the CResult_WarningMessageDecodeErrorZ. */ -struct LDKCVec_u8Z ClosureReason_write(const struct LDKClosureReason *NONNULL_PTR obj); +void CResult_WarningMessageDecodeErrorZ_free(struct LDKCResult_WarningMessageDecodeErrorZ _res); /** - * Read a ClosureReason from a byte array, created by ClosureReason_write + * Creates a new CResult_WarningMessageDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_COption_ClosureReasonZDecodeErrorZ ClosureReason_read(struct LDKu8slice ser); +struct LDKCResult_WarningMessageDecodeErrorZ CResult_WarningMessageDecodeErrorZ_clone(const struct LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR orig); /** - * Frees any resources used by the HTLCDestination + * Creates a new CResult_UnsignedNodeAnnouncementDecodeErrorZ in the success state. */ -void HTLCDestination_free(struct LDKHTLCDestination this_ptr); +struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(struct LDKUnsignedNodeAnnouncement o); /** - * Creates a copy of the HTLCDestination + * Creates a new CResult_UnsignedNodeAnnouncementDecodeErrorZ in the error state. */ -struct LDKHTLCDestination HTLCDestination_clone(const struct LDKHTLCDestination *NONNULL_PTR orig); +struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(struct LDKDecodeError e); /** - * Utility method to constructs a new NextHopChannel-variant HTLCDestination + * Checks if the given object is currently in the success state */ -struct LDKHTLCDestination HTLCDestination_next_hop_channel(struct LDKPublicKey node_id, struct LDKThirtyTwoBytes channel_id); +bool CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(const struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR o); /** - * Utility method to constructs a new UnknownNextHop-variant HTLCDestination + * Frees any resources used by the CResult_UnsignedNodeAnnouncementDecodeErrorZ. */ -struct LDKHTLCDestination HTLCDestination_unknown_next_hop(uint64_t requested_forward_scid); +void CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res); /** - * Utility method to constructs a new InvalidForward-variant HTLCDestination + * Creates a new CResult_UnsignedNodeAnnouncementDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKHTLCDestination HTLCDestination_invalid_forward(uint64_t requested_forward_scid); +struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(const struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR orig); /** - * Utility method to constructs a new FailedPayment-variant HTLCDestination + * Creates a new CResult_NodeAnnouncementDecodeErrorZ in the success state. */ -struct LDKHTLCDestination HTLCDestination_failed_payment(struct LDKThirtyTwoBytes payment_hash); +struct LDKCResult_NodeAnnouncementDecodeErrorZ CResult_NodeAnnouncementDecodeErrorZ_ok(struct LDKNodeAnnouncement o); /** - * Checks if two HTLCDestinations contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Creates a new CResult_NodeAnnouncementDecodeErrorZ in the error state. */ -bool HTLCDestination_eq(const struct LDKHTLCDestination *NONNULL_PTR a, const struct LDKHTLCDestination *NONNULL_PTR b); +struct LDKCResult_NodeAnnouncementDecodeErrorZ CResult_NodeAnnouncementDecodeErrorZ_err(struct LDKDecodeError e); /** - * Serialize the HTLCDestination object into a byte array which can be read by HTLCDestination_read + * Checks if the given object is currently in the success state */ -struct LDKCVec_u8Z HTLCDestination_write(const struct LDKHTLCDestination *NONNULL_PTR obj); +bool CResult_NodeAnnouncementDecodeErrorZ_is_ok(const struct LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR o); /** - * Read a HTLCDestination from a byte array, created by HTLCDestination_write + * Frees any resources used by the CResult_NodeAnnouncementDecodeErrorZ. */ -struct LDKCResult_COption_HTLCDestinationZDecodeErrorZ HTLCDestination_read(struct LDKu8slice ser); +void CResult_NodeAnnouncementDecodeErrorZ_free(struct LDKCResult_NodeAnnouncementDecodeErrorZ _res); /** - * Frees any resources used by the Event + * Creates a new CResult_NodeAnnouncementDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -void Event_free(struct LDKEvent this_ptr); +struct LDKCResult_NodeAnnouncementDecodeErrorZ CResult_NodeAnnouncementDecodeErrorZ_clone(const struct LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a copy of the Event + * Creates a new CResult_QueryShortChannelIdsDecodeErrorZ in the success state. */ -struct LDKEvent Event_clone(const struct LDKEvent *NONNULL_PTR orig); +struct LDKCResult_QueryShortChannelIdsDecodeErrorZ CResult_QueryShortChannelIdsDecodeErrorZ_ok(struct LDKQueryShortChannelIds o); /** - * Utility method to constructs a new FundingGenerationReady-variant Event + * Creates a new CResult_QueryShortChannelIdsDecodeErrorZ in the error state. */ -struct LDKEvent Event_funding_generation_ready(struct LDKThirtyTwoBytes temporary_channel_id, struct LDKPublicKey counterparty_node_id, uint64_t channel_value_satoshis, struct LDKCVec_u8Z output_script, struct LDKU128 user_channel_id); +struct LDKCResult_QueryShortChannelIdsDecodeErrorZ CResult_QueryShortChannelIdsDecodeErrorZ_err(struct LDKDecodeError e); /** - * Utility method to constructs a new PaymentClaimable-variant Event + * Checks if the given object is currently in the success state */ -struct LDKEvent Event_payment_claimable(struct LDKPublicKey receiver_node_id, struct LDKThirtyTwoBytes payment_hash, uint64_t amount_msat, struct LDKPaymentPurpose purpose, struct LDKThirtyTwoBytes via_channel_id, struct LDKCOption_u128Z via_user_channel_id); +bool CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(const struct LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR o); /** - * Utility method to constructs a new PaymentClaimed-variant Event + * Frees any resources used by the CResult_QueryShortChannelIdsDecodeErrorZ. */ -struct LDKEvent Event_payment_claimed(struct LDKPublicKey receiver_node_id, struct LDKThirtyTwoBytes payment_hash, uint64_t amount_msat, struct LDKPaymentPurpose purpose); +void CResult_QueryShortChannelIdsDecodeErrorZ_free(struct LDKCResult_QueryShortChannelIdsDecodeErrorZ _res); /** - * Utility method to constructs a new PaymentSent-variant Event + * Creates a new CResult_QueryShortChannelIdsDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKEvent Event_payment_sent(struct LDKThirtyTwoBytes payment_id, struct LDKThirtyTwoBytes payment_preimage, struct LDKThirtyTwoBytes payment_hash, struct LDKCOption_u64Z fee_paid_msat); +struct LDKCResult_QueryShortChannelIdsDecodeErrorZ CResult_QueryShortChannelIdsDecodeErrorZ_clone(const struct LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR orig); /** - * Utility method to constructs a new PaymentFailed-variant Event + * Creates a new CResult_ReplyShortChannelIdsEndDecodeErrorZ in the success state. */ -struct LDKEvent Event_payment_failed(struct LDKThirtyTwoBytes payment_id, struct LDKThirtyTwoBytes payment_hash); +struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(struct LDKReplyShortChannelIdsEnd o); /** - * Utility method to constructs a new PaymentPathSuccessful-variant Event + * Creates a new CResult_ReplyShortChannelIdsEndDecodeErrorZ in the error state. */ -struct LDKEvent Event_payment_path_successful(struct LDKThirtyTwoBytes payment_id, struct LDKThirtyTwoBytes payment_hash, struct LDKCVec_RouteHopZ path); +struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(struct LDKDecodeError e); /** - * Utility method to constructs a new PaymentPathFailed-variant Event + * Checks if the given object is currently in the success state */ -struct LDKEvent Event_payment_path_failed(struct LDKThirtyTwoBytes payment_id, struct LDKThirtyTwoBytes payment_hash, bool payment_failed_permanently, struct LDKPathFailure failure, struct LDKCVec_RouteHopZ path, struct LDKCOption_u64Z short_channel_id, struct LDKRouteParameters retry); +bool CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(const struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR o); /** - * Utility method to constructs a new ProbeSuccessful-variant Event + * Frees any resources used by the CResult_ReplyShortChannelIdsEndDecodeErrorZ. */ -struct LDKEvent Event_probe_successful(struct LDKThirtyTwoBytes payment_id, struct LDKThirtyTwoBytes payment_hash, struct LDKCVec_RouteHopZ path); +void CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res); /** - * Utility method to constructs a new ProbeFailed-variant Event + * Creates a new CResult_ReplyShortChannelIdsEndDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKEvent Event_probe_failed(struct LDKThirtyTwoBytes payment_id, struct LDKThirtyTwoBytes payment_hash, struct LDKCVec_RouteHopZ path, struct LDKCOption_u64Z short_channel_id); +struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(const struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR orig); /** - * Utility method to constructs a new PendingHTLCsForwardable-variant Event + * Creates a new CResult_QueryChannelRangeDecodeErrorZ in the success state. */ -struct LDKEvent Event_pending_htlcs_forwardable(uint64_t time_forwardable); +struct LDKCResult_QueryChannelRangeDecodeErrorZ CResult_QueryChannelRangeDecodeErrorZ_ok(struct LDKQueryChannelRange o); /** - * Utility method to constructs a new HTLCIntercepted-variant Event + * Creates a new CResult_QueryChannelRangeDecodeErrorZ in the error state. */ -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); +struct LDKCResult_QueryChannelRangeDecodeErrorZ CResult_QueryChannelRangeDecodeErrorZ_err(struct LDKDecodeError e); /** - * Utility method to constructs a new SpendableOutputs-variant Event + * Checks if the given object is currently in the success state */ -struct LDKEvent Event_spendable_outputs(struct LDKCVec_SpendableOutputDescriptorZ outputs); +bool CResult_QueryChannelRangeDecodeErrorZ_is_ok(const struct LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR o); /** - * Utility method to constructs a new PaymentForwarded-variant Event + * Frees any resources used by the CResult_QueryChannelRangeDecodeErrorZ. */ -struct LDKEvent Event_payment_forwarded(struct LDKThirtyTwoBytes prev_channel_id, struct LDKThirtyTwoBytes next_channel_id, struct LDKCOption_u64Z fee_earned_msat, bool claim_from_onchain_tx); +void CResult_QueryChannelRangeDecodeErrorZ_free(struct LDKCResult_QueryChannelRangeDecodeErrorZ _res); /** - * Utility method to constructs a new ChannelReady-variant Event + * Creates a new CResult_QueryChannelRangeDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKEvent Event_channel_ready(struct LDKThirtyTwoBytes channel_id, struct LDKU128 user_channel_id, struct LDKPublicKey counterparty_node_id, struct LDKChannelTypeFeatures channel_type); +struct LDKCResult_QueryChannelRangeDecodeErrorZ CResult_QueryChannelRangeDecodeErrorZ_clone(const struct LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR orig); /** - * Utility method to constructs a new ChannelClosed-variant Event + * Creates a new CResult_ReplyChannelRangeDecodeErrorZ in the success state. */ -struct LDKEvent Event_channel_closed(struct LDKThirtyTwoBytes channel_id, struct LDKU128 user_channel_id, struct LDKClosureReason reason); +struct LDKCResult_ReplyChannelRangeDecodeErrorZ CResult_ReplyChannelRangeDecodeErrorZ_ok(struct LDKReplyChannelRange o); /** - * Utility method to constructs a new DiscardFunding-variant Event + * Creates a new CResult_ReplyChannelRangeDecodeErrorZ in the error state. */ -struct LDKEvent Event_discard_funding(struct LDKThirtyTwoBytes channel_id, struct LDKTransaction transaction); +struct LDKCResult_ReplyChannelRangeDecodeErrorZ CResult_ReplyChannelRangeDecodeErrorZ_err(struct LDKDecodeError e); /** - * Utility method to constructs a new OpenChannelRequest-variant Event + * Checks if the given object is currently in the success state */ -struct LDKEvent Event_open_channel_request(struct LDKThirtyTwoBytes temporary_channel_id, struct LDKPublicKey counterparty_node_id, uint64_t funding_satoshis, uint64_t push_msat, struct LDKChannelTypeFeatures channel_type); +bool CResult_ReplyChannelRangeDecodeErrorZ_is_ok(const struct LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR o); /** - * Utility method to constructs a new HTLCHandlingFailed-variant Event + * Frees any resources used by the CResult_ReplyChannelRangeDecodeErrorZ. */ -struct LDKEvent Event_htlchandling_failed(struct LDKThirtyTwoBytes prev_channel_id, struct LDKHTLCDestination failed_next_destination); +void CResult_ReplyChannelRangeDecodeErrorZ_free(struct LDKCResult_ReplyChannelRangeDecodeErrorZ _res); /** - * Checks if two Events contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Creates a new CResult_ReplyChannelRangeDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -bool Event_eq(const struct LDKEvent *NONNULL_PTR a, const struct LDKEvent *NONNULL_PTR b); +struct LDKCResult_ReplyChannelRangeDecodeErrorZ CResult_ReplyChannelRangeDecodeErrorZ_clone(const struct LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR orig); /** - * Serialize the Event object into a byte array which can be read by Event_read + * Creates a new CResult_GossipTimestampFilterDecodeErrorZ in the success state. */ -struct LDKCVec_u8Z Event_write(const struct LDKEvent *NONNULL_PTR obj); +struct LDKCResult_GossipTimestampFilterDecodeErrorZ CResult_GossipTimestampFilterDecodeErrorZ_ok(struct LDKGossipTimestampFilter o); /** - * Read a Event from a byte array, created by Event_write + * Creates a new CResult_GossipTimestampFilterDecodeErrorZ in the error state. */ -struct LDKCResult_COption_EventZDecodeErrorZ Event_read(struct LDKu8slice ser); +struct LDKCResult_GossipTimestampFilterDecodeErrorZ CResult_GossipTimestampFilterDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees any resources used by the MessageSendEvent + * Checks if the given object is currently in the success state */ -void MessageSendEvent_free(struct LDKMessageSendEvent this_ptr); +bool CResult_GossipTimestampFilterDecodeErrorZ_is_ok(const struct LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR o); /** - * Creates a copy of the MessageSendEvent + * Frees any resources used by the CResult_GossipTimestampFilterDecodeErrorZ. */ -struct LDKMessageSendEvent MessageSendEvent_clone(const struct LDKMessageSendEvent *NONNULL_PTR orig); +void CResult_GossipTimestampFilterDecodeErrorZ_free(struct LDKCResult_GossipTimestampFilterDecodeErrorZ _res); /** - * Utility method to constructs a new SendAcceptChannel-variant MessageSendEvent + * Creates a new CResult_GossipTimestampFilterDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKMessageSendEvent MessageSendEvent_send_accept_channel(struct LDKPublicKey node_id, struct LDKAcceptChannel msg); +struct LDKCResult_GossipTimestampFilterDecodeErrorZ CResult_GossipTimestampFilterDecodeErrorZ_clone(const struct LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR orig); /** - * Utility method to constructs a new SendOpenChannel-variant MessageSendEvent + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -struct LDKMessageSendEvent MessageSendEvent_send_open_channel(struct LDKPublicKey node_id, struct LDKOpenChannel msg); +void CVec_PhantomRouteHintsZ_free(struct LDKCVec_PhantomRouteHintsZ _res); /** - * Utility method to constructs a new SendFundingCreated-variant MessageSendEvent + * Creates a new CResult_InvoiceSignOrCreationErrorZ in the success state. */ -struct LDKMessageSendEvent MessageSendEvent_send_funding_created(struct LDKPublicKey node_id, struct LDKFundingCreated msg); +struct LDKCResult_InvoiceSignOrCreationErrorZ CResult_InvoiceSignOrCreationErrorZ_ok(struct LDKInvoice o); /** - * Utility method to constructs a new SendFundingSigned-variant MessageSendEvent + * Creates a new CResult_InvoiceSignOrCreationErrorZ in the error state. */ -struct LDKMessageSendEvent MessageSendEvent_send_funding_signed(struct LDKPublicKey node_id, struct LDKFundingSigned msg); +struct LDKCResult_InvoiceSignOrCreationErrorZ CResult_InvoiceSignOrCreationErrorZ_err(struct LDKSignOrCreationError e); /** - * Utility method to constructs a new SendChannelReady-variant MessageSendEvent + * Checks if the given object is currently in the success state */ -struct LDKMessageSendEvent MessageSendEvent_send_channel_ready(struct LDKPublicKey node_id, struct LDKChannelReady msg); +bool CResult_InvoiceSignOrCreationErrorZ_is_ok(const struct LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR o); /** - * Utility method to constructs a new SendAnnouncementSignatures-variant MessageSendEvent + * Frees any resources used by the CResult_InvoiceSignOrCreationErrorZ. */ -struct LDKMessageSendEvent MessageSendEvent_send_announcement_signatures(struct LDKPublicKey node_id, struct LDKAnnouncementSignatures msg); +void CResult_InvoiceSignOrCreationErrorZ_free(struct LDKCResult_InvoiceSignOrCreationErrorZ _res); /** - * Utility method to constructs a new UpdateHTLCs-variant MessageSendEvent + * Creates a new CResult_InvoiceSignOrCreationErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKMessageSendEvent MessageSendEvent_update_htlcs(struct LDKPublicKey node_id, struct LDKCommitmentUpdate updates); +struct LDKCResult_InvoiceSignOrCreationErrorZ CResult_InvoiceSignOrCreationErrorZ_clone(const struct LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR orig); /** - * Utility method to constructs a new SendRevokeAndACK-variant MessageSendEvent + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -struct LDKMessageSendEvent MessageSendEvent_send_revoke_and_ack(struct LDKPublicKey node_id, struct LDKRevokeAndACK msg); +void CVec_FutureZ_free(struct LDKCVec_FutureZ _res); /** - * Utility method to constructs a new SendClosingSigned-variant MessageSendEvent + * Constructs a new COption_FilterZ containing a crate::lightning::chain::Filter */ -struct LDKMessageSendEvent MessageSendEvent_send_closing_signed(struct LDKPublicKey node_id, struct LDKClosingSigned msg); +struct LDKCOption_FilterZ COption_FilterZ_some(struct LDKFilter o); /** - * Utility method to constructs a new SendShutdown-variant MessageSendEvent + * Constructs a new COption_FilterZ containing nothing */ -struct LDKMessageSendEvent MessageSendEvent_send_shutdown(struct LDKPublicKey node_id, struct LDKShutdown msg); +struct LDKCOption_FilterZ COption_FilterZ_none(void); /** - * Utility method to constructs a new SendChannelReestablish-variant MessageSendEvent + * Frees any resources associated with the crate::lightning::chain::Filter, if we are in the Some state */ -struct LDKMessageSendEvent MessageSendEvent_send_channel_reestablish(struct LDKPublicKey node_id, struct LDKChannelReestablish msg); +void COption_FilterZ_free(struct LDKCOption_FilterZ _res); /** - * Utility method to constructs a new SendChannelAnnouncement-variant MessageSendEvent + * Creates a new CResult_LockedChannelMonitorNoneZ in the success state. */ -struct LDKMessageSendEvent MessageSendEvent_send_channel_announcement(struct LDKPublicKey node_id, struct LDKChannelAnnouncement msg, struct LDKChannelUpdate update_msg); +struct LDKCResult_LockedChannelMonitorNoneZ CResult_LockedChannelMonitorNoneZ_ok(struct LDKLockedChannelMonitor o); /** - * Utility method to constructs a new BroadcastChannelAnnouncement-variant MessageSendEvent + * Creates a new CResult_LockedChannelMonitorNoneZ in the error state. */ -struct LDKMessageSendEvent MessageSendEvent_broadcast_channel_announcement(struct LDKChannelAnnouncement msg, struct LDKChannelUpdate update_msg); +struct LDKCResult_LockedChannelMonitorNoneZ CResult_LockedChannelMonitorNoneZ_err(void); /** - * Utility method to constructs a new BroadcastChannelUpdate-variant MessageSendEvent + * Checks if the given object is currently in the success state */ -struct LDKMessageSendEvent MessageSendEvent_broadcast_channel_update(struct LDKChannelUpdate msg); +bool CResult_LockedChannelMonitorNoneZ_is_ok(const struct LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR o); /** - * Utility method to constructs a new BroadcastNodeAnnouncement-variant MessageSendEvent + * Frees any resources used by the CResult_LockedChannelMonitorNoneZ. */ -struct LDKMessageSendEvent MessageSendEvent_broadcast_node_announcement(struct LDKNodeAnnouncement msg); +void CResult_LockedChannelMonitorNoneZ_free(struct LDKCResult_LockedChannelMonitorNoneZ _res); /** - * Utility method to constructs a new SendChannelUpdate-variant MessageSendEvent + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -struct LDKMessageSendEvent MessageSendEvent_send_channel_update(struct LDKPublicKey node_id, struct LDKChannelUpdate msg); +void CVec_OutPointZ_free(struct LDKCVec_OutPointZ _res); /** - * Utility method to constructs a new HandleError-variant MessageSendEvent + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -struct LDKMessageSendEvent MessageSendEvent_handle_error(struct LDKPublicKey node_id, struct LDKErrorAction action); +void CVec_MonitorUpdateIdZ_free(struct LDKCVec_MonitorUpdateIdZ _res); /** - * Utility method to constructs a new SendChannelRangeQuery-variant MessageSendEvent + * Creates a new tuple which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKMessageSendEvent MessageSendEvent_send_channel_range_query(struct LDKPublicKey node_id, struct LDKQueryChannelRange msg); +struct LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ C2Tuple_OutPointCVec_MonitorUpdateIdZZ_clone(const struct LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ *NONNULL_PTR orig); /** - * Utility method to constructs a new SendShortIdsQuery-variant MessageSendEvent + * Creates a new C2Tuple_OutPointCVec_MonitorUpdateIdZZ from the contained elements. */ -struct LDKMessageSendEvent MessageSendEvent_send_short_ids_query(struct LDKPublicKey node_id, struct LDKQueryShortChannelIds msg); +struct LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ C2Tuple_OutPointCVec_MonitorUpdateIdZZ_new(struct LDKOutPoint a, struct LDKCVec_MonitorUpdateIdZ b); /** - * Utility method to constructs a new SendReplyChannelRange-variant MessageSendEvent + * Frees any resources used by the C2Tuple_OutPointCVec_MonitorUpdateIdZZ. */ -struct LDKMessageSendEvent MessageSendEvent_send_reply_channel_range(struct LDKPublicKey node_id, struct LDKReplyChannelRange msg); +void C2Tuple_OutPointCVec_MonitorUpdateIdZZ_free(struct LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ _res); /** - * Utility method to constructs a new SendGossipTimestampFilter-variant MessageSendEvent + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -struct LDKMessageSendEvent MessageSendEvent_send_gossip_timestamp_filter(struct LDKPublicKey node_id, struct LDKGossipTimestampFilter msg); +void CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ_free(struct LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ _res); /** - * Calls the free function if one is set + * Creates a new CResult_u32GraphSyncErrorZ in the success state. */ -void MessageSendEventsProvider_free(struct LDKMessageSendEventsProvider this_ptr); +struct LDKCResult_u32GraphSyncErrorZ CResult_u32GraphSyncErrorZ_ok(uint32_t o); /** - * Calls the free function if one is set + * Creates a new CResult_u32GraphSyncErrorZ in the error state. */ -void OnionMessageProvider_free(struct LDKOnionMessageProvider this_ptr); +struct LDKCResult_u32GraphSyncErrorZ CResult_u32GraphSyncErrorZ_err(struct LDKGraphSyncError e); /** - * Calls the free function if one is set + * Checks if the given object is currently in the success state */ -void EventsProvider_free(struct LDKEventsProvider this_ptr); +bool CResult_u32GraphSyncErrorZ_is_ok(const struct LDKCResult_u32GraphSyncErrorZ *NONNULL_PTR o); /** - * Calls the free function if one is set + * Frees any resources used by the CResult_u32GraphSyncErrorZ. */ -void EventHandler_free(struct LDKEventHandler this_ptr); +void CResult_u32GraphSyncErrorZ_free(struct LDKCResult_u32GraphSyncErrorZ _res); /** * Frees any resources used by the APIError @@ -20589,6 +21210,42 @@ struct LDKCVec_u8Z construct_invoice_preimage(struct LDKu8slice hrp_bytes, struc */ void Persister_free(struct LDKPersister this_ptr); +/** + * 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); + +/** + * 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 PrintableString, if is_owned is set and inner is non-NULL. */ @@ -20613,12 +21270,61 @@ void FutureCallback_free(struct LDKFutureCallback this_ptr); */ void Future_free(struct LDKFuture this_obj); +/** + * Creates a copy of the Future + */ +struct LDKFuture Future_clone(const struct LDKFuture *NONNULL_PTR orig); + /** * Registers a callback to be called upon completion of this future. If the future has already * completed, the callback will be called immediately. */ void Future_register_callback_fn(const struct LDKFuture *NONNULL_PTR this_arg, struct LDKFutureCallback callback); +/** + * Waits until this [`Future`] completes. + */ +void Future_wait(struct LDKFuture this_arg); + +/** + * Waits until this [`Future`] completes or the given amount of time has elapsed. + * + * Returns true if the [`Future`] completed, false if the time elapsed. + */ +MUST_USE_RES bool Future_wait_timeout(struct LDKFuture this_arg, uint64_t max_wait); + +/** + * Frees any resources used by the Sleeper, if is_owned is set and inner is non-NULL. + */ +void Sleeper_free(struct LDKSleeper this_obj); + +/** + * Constructs a new sleeper from one future, allowing blocking on it. + */ +MUST_USE_RES struct LDKSleeper Sleeper_from_single_future(struct LDKFuture future); + +/** + * Constructs a new sleeper from two futures, allowing blocking on both at once. + */ +MUST_USE_RES struct LDKSleeper Sleeper_from_two_futures(struct LDKFuture fut_a, struct LDKFuture fut_b); + +/** + * Constructs a new sleeper on many futures, allowing blocking on all at once. + */ +MUST_USE_RES struct LDKSleeper Sleeper_new(struct LDKCVec_FutureZ futures); + +/** + * Wait until one of the [`Future`]s registered with this [`Sleeper`] has completed. + */ +void Sleeper_wait(const struct LDKSleeper *NONNULL_PTR this_arg); + +/** + * Wait until one of the [`Future`]s registered with this [`Sleeper`] has completed or the + * given amount of time has elapsed. Returns true if a [`Future`] completed, false if the time + * elapsed. + */ +MUST_USE_RES bool Sleeper_wait_timeout(const struct LDKSleeper *NONNULL_PTR this_arg, uint64_t max_wait); + /** * Creates a copy of the Level */ @@ -20661,7 +21367,7 @@ enum LDKLevel Level_error(void); bool Level_eq(const enum LDKLevel *NONNULL_PTR a, const enum LDKLevel *NONNULL_PTR b); /** - * Checks if two Levels contain equal inner contents. + * Generates a non-cryptographic 64-bit hash of the Level. */ uint64_t Level_hash(const enum LDKLevel *NONNULL_PTR o); @@ -21050,10 +21756,40 @@ uint32_t ChannelHandshakeConfig_get_their_channel_reserve_proportional_millionth */ void ChannelHandshakeConfig_set_their_channel_reserve_proportional_millionths(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, uint32_t val); +/** + * The maximum number of HTLCs in-flight from our counterparty towards us at the same time. + * + * Increasing the value can help improve liquidity and stability in + * routing at the cost of higher long term disk / DB usage. + * + * Note: Versions of LDK earlier than v0.0.115 will fail to read channels with a configuration + * other than the default value. + * + * Default value: 50 + * Maximum value: 483, any values larger will be treated as 483. + * This is the BOLT #2 spec limit on `max_accepted_htlcs`. + */ +uint16_t ChannelHandshakeConfig_get_our_max_accepted_htlcs(const struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr); + +/** + * The maximum number of HTLCs in-flight from our counterparty towards us at the same time. + * + * Increasing the value can help improve liquidity and stability in + * routing at the cost of higher long term disk / DB usage. + * + * Note: Versions of LDK earlier than v0.0.115 will fail to read channels with a configuration + * other than the default value. + * + * Default value: 50 + * Maximum value: 483, any values larger will be treated as 483. + * This is the BOLT #2 spec limit on `max_accepted_htlcs`. + */ +void 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); +MUST_USE_RES struct LDKChannelHandshakeConfig ChannelHandshakeConfig_new(uint32_t minimum_depth_arg, uint16_t our_to_self_delay_arg, uint64_t our_htlc_minimum_msat_arg, uint8_t max_inbound_htlc_value_in_flight_percent_of_channel_arg, bool negotiate_scid_privacy_arg, bool announced_channel_arg, bool commit_upfront_shutdown_pubkey_arg, uint32_t their_channel_reserve_proportional_millionths_arg, uint16_t our_max_accepted_htlcs_arg); /** * Creates a copy of the ChannelHandshakeConfig @@ -21626,7 +22362,7 @@ void UserConfig_set_accept_inbound_channels(struct LDKUserConfig *NONNULL_PTR th * * Default value: false. * - * [`Event::OpenChannelRequest`]: crate::util::events::Event::OpenChannelRequest + * [`Event::OpenChannelRequest`]: crate::events::Event::OpenChannelRequest * [`msgs::OpenChannel`]: crate::ln::msgs::OpenChannel * [`msgs::AcceptChannel`]: crate::ln::msgs::AcceptChannel */ @@ -21643,7 +22379,7 @@ bool UserConfig_get_manually_accept_inbound_channels(const struct LDKUserConfig * * Default value: false. * - * [`Event::OpenChannelRequest`]: crate::util::events::Event::OpenChannelRequest + * [`Event::OpenChannelRequest`]: crate::events::Event::OpenChannelRequest * [`msgs::OpenChannel`]: crate::ln::msgs::OpenChannel * [`msgs::AcceptChannel`]: crate::ln::msgs::AcceptChannel */ @@ -21659,7 +22395,7 @@ void UserConfig_set_manually_accept_inbound_channels(struct LDKUserConfig *NONNU * Default value: false. * * [`ChannelManager::get_intercept_scid`]: crate::ln::channelmanager::ChannelManager::get_intercept_scid - * [`Event::HTLCIntercepted`]: crate::util::events::Event::HTLCIntercepted + * [`Event::HTLCIntercepted`]: crate::events::Event::HTLCIntercepted */ bool UserConfig_get_accept_intercept_htlcs(const struct LDKUserConfig *NONNULL_PTR this_ptr); @@ -21673,7 +22409,7 @@ bool UserConfig_get_accept_intercept_htlcs(const struct LDKUserConfig *NONNULL_P * Default value: false. * * [`ChannelManager::get_intercept_scid`]: crate::ln::channelmanager::ChannelManager::get_intercept_scid - * [`Event::HTLCIntercepted`]: crate::util::events::Event::HTLCIntercepted + * [`Event::HTLCIntercepted`]: crate::events::Event::HTLCIntercepted */ void UserConfig_set_accept_intercept_htlcs(struct LDKUserConfig *NONNULL_PTR this_ptr, bool val); @@ -21833,7 +22569,7 @@ struct LDKWatchedOutput WatchedOutput_clone(const struct LDKWatchedOutput *NONNU bool WatchedOutput_eq(const struct LDKWatchedOutput *NONNULL_PTR a, const struct LDKWatchedOutput *NONNULL_PTR b); /** - * Checks if two WatchedOutputs contain equal inner contents. + * Generates a non-cryptographic 64-bit hash of the WatchedOutput. */ uint64_t WatchedOutput_hash(const struct LDKWatchedOutput *NONNULL_PTR o); @@ -21863,7 +22599,7 @@ enum LDKConfirmationTarget ConfirmationTarget_normal(void); enum LDKConfirmationTarget ConfirmationTarget_high_priority(void); /** - * Checks if two ConfirmationTargets contain equal inner contents. + * Generates a non-cryptographic 64-bit hash of the ConfirmationTarget. */ uint64_t ConfirmationTarget_hash(const enum LDKConfirmationTarget *NONNULL_PTR o); @@ -21889,7 +22625,7 @@ void MonitorUpdateId_free(struct LDKMonitorUpdateId this_obj); struct LDKMonitorUpdateId MonitorUpdateId_clone(const struct LDKMonitorUpdateId *NONNULL_PTR orig); /** - * Checks if two MonitorUpdateIds contain equal inner contents. + * Generates a non-cryptographic 64-bit hash of the MonitorUpdateId. */ uint64_t MonitorUpdateId_hash(const struct LDKMonitorUpdateId *NONNULL_PTR o); @@ -21978,6 +22714,27 @@ MUST_USE_RES struct LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ ChainMonitor */ 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); +/** + * Gets a [`Future`] that completes when an event is available either via + * [`chain::Watch::release_pending_monitor_events`] or + * [`EventsProvider::process_pending_events`]. + * + * Note that callbacks registered on the [`Future`] MUST NOT call back into this + * [`ChainMonitor`] and should instead register actions to be taken later. + * + * [`EventsProvider::process_pending_events`]: crate::events::EventsProvider::process_pending_events + */ +MUST_USE_RES struct LDKFuture ChainMonitor_get_update_future(const struct LDKChainMonitor *NONNULL_PTR this_arg); + +/** + * Triggers rebroadcasts/fee-bumps of pending claims from a force-closed channel. This is + * crucial in preventing certain classes of pinning attacks, detecting substantial mempool + * feerate changes between blocks, and ensuring reliability if broadcasting fails. We recommend + * invoking this every 30 seconds, or lower if running in an environment with spotty + * connections, like on mobile. + */ +void ChainMonitor_rebroadcast_pending_claims(const struct LDKChainMonitor *NONNULL_PTR this_arg); + /** * Constructs a new Listen which calls the relevant methods on this_arg. * This copies the `inner` pointer in this_arg and thus the returned Listen must be freed before this_arg is @@ -22010,15 +22767,17 @@ void ChannelMonitorUpdate_free(struct LDKChannelMonitorUpdate this_obj); /** * The sequence number of this update. Updates *must* be replayed in-order according to this * sequence number (and updates may panic if they are not). The update_id values are strictly - * increasing and increase by one for each new update, with one exception specified below. + * increasing and increase by one for each new update, with two exceptions specified below. * * This sequence number is also used to track up to which points updates which returned * [`ChannelMonitorUpdateStatus::InProgress`] have been applied to all copies of a given * ChannelMonitor when ChannelManager::channel_monitor_updated is called. * - * The only instance where update_id values are not strictly increasing is the case where we - * allow post-force-close updates with a special update ID of [`CLOSED_CHANNEL_UPDATE_ID`]. See - * its docs for more details. + * The only instances we allow where update_id values are not strictly increasing have a + * special update ID of [`CLOSED_CHANNEL_UPDATE_ID`]. This update ID is used for updates that + * will force close the channel by broadcasting the latest commitment transaction or + * special post-force-close updates, like providing preimages necessary to claim outputs on the + * broadcast commitment transaction. See its docs for more details. * * [`ChannelMonitorUpdateStatus::InProgress`]: super::ChannelMonitorUpdateStatus::InProgress */ @@ -22027,15 +22786,17 @@ uint64_t ChannelMonitorUpdate_get_update_id(const struct LDKChannelMonitorUpdate /** * The sequence number of this update. Updates *must* be replayed in-order according to this * sequence number (and updates may panic if they are not). The update_id values are strictly - * increasing and increase by one for each new update, with one exception specified below. + * increasing and increase by one for each new update, with two exceptions specified below. * * This sequence number is also used to track up to which points updates which returned * [`ChannelMonitorUpdateStatus::InProgress`] have been applied to all copies of a given * ChannelMonitor when ChannelManager::channel_monitor_updated is called. * - * The only instance where update_id values are not strictly increasing is the case where we - * allow post-force-close updates with a special update ID of [`CLOSED_CHANNEL_UPDATE_ID`]. See - * its docs for more details. + * The only instances we allow where update_id values are not strictly increasing have a + * special update ID of [`CLOSED_CHANNEL_UPDATE_ID`]. This update ID is used for updates that + * will force close the channel by broadcasting the latest commitment transaction or + * special post-force-close updates, like providing preimages necessary to claim outputs on the + * broadcast commitment transaction. See its docs for more details. * * [`ChannelMonitorUpdateStatus::InProgress`]: super::ChannelMonitorUpdateStatus::InProgress */ @@ -22046,6 +22807,13 @@ void ChannelMonitorUpdate_set_update_id(struct LDKChannelMonitorUpdate *NONNULL_ */ struct LDKChannelMonitorUpdate ChannelMonitorUpdate_clone(const struct LDKChannelMonitorUpdate *NONNULL_PTR orig); +/** + * Checks if two ChannelMonitorUpdates contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ +bool ChannelMonitorUpdate_eq(const struct LDKChannelMonitorUpdate *NONNULL_PTR a, const struct LDKChannelMonitorUpdate *NONNULL_PTR b); + /** * Serialize the ChannelMonitorUpdate object into a byte array which can be read by ChannelMonitorUpdate_read */ @@ -22230,7 +22998,7 @@ MUST_USE_RES struct LDKCVec_MonitorEventZ ChannelMonitor_get_and_clear_pending_m * This is called by the [`EventsProvider::process_pending_events`] implementation for * [`ChainMonitor`]. * - * [`EventsProvider::process_pending_events`]: crate::util::events::EventsProvider::process_pending_events + * [`EventsProvider::process_pending_events`]: crate::events::EventsProvider::process_pending_events * [`ChainMonitor`]: crate::chain::chainmonitor::ChainMonitor */ MUST_USE_RES struct LDKCVec_EventZ ChannelMonitor_get_and_clear_pending_events(const struct LDKChannelMonitor *NONNULL_PTR this_arg); @@ -22328,6 +23096,15 @@ MUST_USE_RES struct LDKCVec_C2Tuple_TxidBlockHashZZ ChannelMonitor_get_relevant_ */ MUST_USE_RES struct LDKBestBlock ChannelMonitor_current_best_block(const struct LDKChannelMonitor *NONNULL_PTR this_arg); +/** + * Triggers rebroadcasts/fee-bumps of pending claims from a force-closed channel. This is + * crucial in preventing certain classes of pinning attacks, detecting substantial mempool + * feerate changes between blocks, and ensuring reliability if broadcasting fails. We recommend + * invoking this every 30 seconds, or lower if running in an environment with spotty + * connections, like on mobile. + */ +void ChannelMonitor_rebroadcast_pending_claims(const struct LDKChannelMonitor *NONNULL_PTR this_arg, struct LDKBroadcasterInterface broadcaster, struct LDKFeeEstimator fee_estimator, struct LDKLogger logger); + /** * Gets the balances in this channel which are either claimable by us if we were to * force-close the channel now or which are claimable on-chain (possibly awaiting @@ -22395,7 +23172,7 @@ struct LDKOutPoint OutPoint_clone(const struct LDKOutPoint *NONNULL_PTR orig); bool OutPoint_eq(const struct LDKOutPoint *NONNULL_PTR a, const struct LDKOutPoint *NONNULL_PTR b); /** - * Checks if two OutPoints contain equal inner contents. + * Generates a non-cryptographic 64-bit hash of the OutPoint. */ uint64_t OutPoint_hash(const struct LDKOutPoint *NONNULL_PTR o); @@ -22761,7 +23538,7 @@ struct LDKInMemorySigner InMemorySigner_clone(const struct LDKInMemorySigner *NO /** * Creates a new [`InMemorySigner`]. */ -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); +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); /** * Returns the counterparty's pubkeys. @@ -22843,6 +23620,12 @@ MUST_USE_RES struct LDKCResult_CVec_CVec_u8ZZNoneZ InMemorySigner_sign_counterpa */ MUST_USE_RES struct LDKCResult_CVec_CVec_u8ZZNoneZ InMemorySigner_sign_dynamic_p2wsh_input(const struct LDKInMemorySigner *NONNULL_PTR this_arg, struct LDKTransaction spend_tx, uintptr_t input_idx, const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR descriptor); +/** + * 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 + */ +struct LDKEntropySource InMemorySigner_as_EntropySource(const struct LDKInMemorySigner *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 @@ -22869,7 +23652,7 @@ struct LDKCVec_u8Z InMemorySigner_write(const struct LDKInMemorySigner *NONNULL_ /** * Read a InMemorySigner from a byte array, created by InMemorySigner_write */ -struct LDKCResult_InMemorySignerDecodeErrorZ InMemorySigner_read(struct LDKu8slice ser); +struct LDKCResult_InMemorySignerDecodeErrorZ InMemorySigner_read(struct LDKu8slice ser, struct LDKEntropySource arg); /** * Frees any resources used by the KeysManager, if is_owned is set and inner is non-NULL. @@ -23423,6 +24206,22 @@ struct LDKU128 ChannelDetails_get_user_channel_id(const struct LDKChannelDetails */ void ChannelDetails_set_user_channel_id(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKU128 val); +/** + * The currently negotiated fee rate denominated in satoshi per 1000 weight units, + * which is applied to commitment and HTLC transactions. + * + * This value will be `None` for objects serialized with LDK versions prior to 0.0.115. + */ +struct LDKCOption_u32Z ChannelDetails_get_feerate_sat_per_1000_weight(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + +/** + * The currently negotiated fee rate denominated in satoshi per 1000 weight units, + * which is applied to commitment and HTLC transactions. + * + * This value will be `None` for objects serialized with LDK versions prior to 0.0.115. + */ +void ChannelDetails_set_feerate_sat_per_1000_weight(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u32Z val); + /** * Our total balance. This is the amount we would get if we close the channel. * This value is not exact. Due to various in-flight changes and feerate changes, exactly this @@ -23692,7 +24491,7 @@ void ChannelDetails_set_config(struct LDKChannelDetails *NONNULL_PTR this_ptr, s /** * Constructs a new ChannelDetails given each field */ -MUST_USE_RES struct LDKChannelDetails ChannelDetails_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKChannelCounterparty counterparty_arg, struct LDKOutPoint funding_txo_arg, struct LDKChannelTypeFeatures channel_type_arg, struct LDKCOption_u64Z short_channel_id_arg, struct LDKCOption_u64Z outbound_scid_alias_arg, struct LDKCOption_u64Z inbound_scid_alias_arg, uint64_t channel_value_satoshis_arg, struct LDKCOption_u64Z unspendable_punishment_reserve_arg, struct LDKU128 user_channel_id_arg, uint64_t balance_msat_arg, uint64_t outbound_capacity_msat_arg, uint64_t next_outbound_htlc_limit_msat_arg, uint64_t inbound_capacity_msat_arg, struct LDKCOption_u32Z confirmations_required_arg, struct LDKCOption_u32Z confirmations_arg, struct LDKCOption_u16Z force_close_spend_delay_arg, bool is_outbound_arg, bool is_channel_ready_arg, bool is_usable_arg, bool is_public_arg, struct LDKCOption_u64Z inbound_htlc_minimum_msat_arg, struct LDKCOption_u64Z inbound_htlc_maximum_msat_arg, struct LDKChannelConfig config_arg); +MUST_USE_RES struct LDKChannelDetails ChannelDetails_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKChannelCounterparty counterparty_arg, struct LDKOutPoint funding_txo_arg, struct LDKChannelTypeFeatures channel_type_arg, struct LDKCOption_u64Z short_channel_id_arg, struct LDKCOption_u64Z outbound_scid_alias_arg, struct LDKCOption_u64Z inbound_scid_alias_arg, uint64_t channel_value_satoshis_arg, struct LDKCOption_u64Z unspendable_punishment_reserve_arg, struct LDKU128 user_channel_id_arg, struct LDKCOption_u32Z feerate_sat_per_1000_weight_arg, uint64_t balance_msat_arg, uint64_t outbound_capacity_msat_arg, uint64_t next_outbound_htlc_limit_msat_arg, uint64_t inbound_capacity_msat_arg, struct LDKCOption_u32Z confirmations_required_arg, struct LDKCOption_u32Z confirmations_arg, struct LDKCOption_u16Z force_close_spend_delay_arg, bool is_outbound_arg, bool is_channel_ready_arg, bool is_usable_arg, bool is_public_arg, struct LDKCOption_u64Z inbound_htlc_minimum_msat_arg, struct LDKCOption_u64Z inbound_htlc_maximum_msat_arg, struct LDKChannelConfig config_arg); /** * Creates a copy of the ChannelDetails @@ -23792,16 +24591,21 @@ MUST_USE_RES struct LDKPhantomRouteHints PhantomRouteHints_new(struct LDKCVec_Ch struct LDKPhantomRouteHints PhantomRouteHints_clone(const struct LDKPhantomRouteHints *NONNULL_PTR orig); /** - * Constructs a new ChannelManager to hold several channels and route between them. + * Constructs a new `ChannelManager` to hold several channels and route between them. * * This is the main \"logic hub\" for all channel-related actions, and implements - * ChannelMessageHandler. + * [`ChannelMessageHandler`]. * * Non-proportional fees are fixed according to our risk using the provided fee estimator. * - * Users need to notify the new ChannelManager when a new block is connected or - * disconnected using its `block_connected` and `block_disconnected` methods, starting - * from after `params.latest_hash`. + * Users need to notify the new `ChannelManager` when a new block is connected or + * disconnected using its [`block_connected`] and [`block_disconnected`] methods, starting + * from after [`params.best_block.block_hash`]. See [`chain::Listen`] and [`chain::Confirm`] for + * more details. + * + * [`block_connected`]: chain::Listen::block_connected + * [`block_disconnected`]: chain::Listen::block_disconnected + * [`params.best_block.block_hash`]: chain::BestBlock::block_hash */ MUST_USE_RES struct LDKChannelManager ChannelManager_new(struct LDKFeeEstimator fee_est, struct LDKWatch chain_monitor, struct LDKBroadcasterInterface tx_broadcaster, struct LDKRouter router, struct LDKLogger logger, struct LDKEntropySource entropy_source, struct LDKNodeSigner node_signer, struct LDKSignerProvider signer_provider, struct LDKUserConfig config, struct LDKChainParameters params); @@ -23842,7 +24646,7 @@ MUST_USE_RES struct LDKUserConfig ChannelManager_get_current_default_configurati MUST_USE_RES struct LDKCResult__u832APIErrorZ ChannelManager_create_channel(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKPublicKey their_network_key, uint64_t channel_value_satoshis, uint64_t push_msat, struct LDKU128 user_channel_id, struct LDKUserConfig override_config); /** - * Gets the list of open channels, in random order. See ChannelDetail field documentation for + * Gets the list of open channels, in random order. See [`ChannelDetails`] field documentation for * more information. */ MUST_USE_RES struct LDKCVec_ChannelDetailsZ ChannelManager_list_channels(const struct LDKChannelManager *NONNULL_PTR this_arg); @@ -23857,6 +24661,11 @@ MUST_USE_RES struct LDKCVec_ChannelDetailsZ ChannelManager_list_channels(const s */ MUST_USE_RES struct LDKCVec_ChannelDetailsZ ChannelManager_list_usable_channels(const struct LDKChannelManager *NONNULL_PTR this_arg); +/** + * Gets the list of channels we have with a given counterparty, in random order. + */ +MUST_USE_RES struct LDKCVec_ChannelDetailsZ ChannelManager_list_channels_with_counterparty(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKPublicKey counterparty_node_id); + /** * Returns in an undefined order recent payments that -- if not fulfilled -- have yet to find a * successful path, or have unresolved HTLCs. @@ -23882,11 +24691,12 @@ MUST_USE_RES struct LDKCVec_RecentPaymentDetailsZ ChannelManager_list_recent_pay * would appear on a force-closure transaction, whichever is lower. We will allow our * counterparty to pay as much fee as they'd like, however. * - * May generate a SendShutdown message event on success, which should be relayed. + * May generate a [`SendShutdown`] message event on success, which should be relayed. * * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`]: crate::util::config::ChannelConfig::force_close_avoidance_max_fee_satoshis * [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background * [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal + * [`SendShutdown`]: crate::events::MessageSendEvent::SendShutdown */ MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_close_channel(const struct LDKChannelManager *NONNULL_PTR this_arg, const uint8_t (*channel_id)[32], struct LDKPublicKey counterparty_node_id); @@ -23905,11 +24715,12 @@ MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_close_channel(const * transaction feerate below `target_feerate_sat_per_1000_weight` (or the feerate which * will appear on a force-closure transaction, whichever is lower). * - * May generate a SendShutdown message event on success, which should be relayed. + * May generate a [`SendShutdown`] message event on success, which should be relayed. * * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`]: crate::util::config::ChannelConfig::force_close_avoidance_max_fee_satoshis * [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background * [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal + * [`SendShutdown`]: crate::events::MessageSendEvent::SendShutdown */ MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_close_channel_with_target_feerate(const struct LDKChannelManager *NONNULL_PTR this_arg, const uint8_t (*channel_id)[32], struct LDKPublicKey counterparty_node_id, uint32_t target_feerate_sats_per_1000_weight); @@ -23949,7 +24760,7 @@ void ChannelManager_force_close_all_channels_without_broadcasting_txn(const stru * Value parameters are provided via the last hop in route, see documentation for [`RouteHop`] * fields for more info. * - * May generate SendHTLCs message(s) event on success, which should be relayed (e.g. via + * May generate [`UpdateHTLCs`] message(s) event on success, which should be relayed (e.g. via * [`PeerManager::process_events`]). * * # Avoiding Duplicate Payments @@ -23973,7 +24784,7 @@ void ChannelManager_force_close_all_channels_without_broadcasting_txn(const stru * * # Possible Error States on [`PaymentSendFailure`] * - * Each path may have a different return value, and PaymentSendValue may return a Vec with + * Each path may have a different return value, and [`PaymentSendFailure`] may return a `Vec` with * each entry matching the corresponding-index entry in the route paths, see * [`PaymentSendFailure`] for more info. * @@ -23986,38 +24797,23 @@ void ChannelManager_force_close_all_channels_without_broadcasting_txn(const stru * * [`APIError::MonitorUpdateInProgress`] if a new monitor update failure prevented sending the * relevant updates. * - * Note that depending on the type of the PaymentSendFailure the HTLC may have been + * Note that depending on the type of the [`PaymentSendFailure`] the HTLC may have been * irrevocably committed to on our end. In such a case, do NOT retry the payment with a * different route unless you intend to pay twice! * - * # A caution on `payment_secret` - * - * `payment_secret` is unrelated to `payment_hash` (or [`PaymentPreimage`]) and exists to - * authenticate the sender to the recipient and prevent payment-probing (deanonymization) - * attacks. For newer nodes, it will be provided to you in the invoice. If you do not have one, - * the [`Route`] must not contain multiple paths as multi-path payments require a - * recipient-provided `payment_secret`. - * - * If a `payment_secret` *is* provided, we assume that the invoice had the payment_secret - * feature bit set (either as required or as available). If multiple paths are present in the - * [`Route`], we assume the invoice had the basic_mpp feature set. - * * [`Event::PaymentSent`]: events::Event::PaymentSent * [`Event::PaymentFailed`]: events::Event::PaymentFailed + * [`UpdateHTLCs`]: events::MessageSendEvent::UpdateHTLCs * [`PeerManager::process_events`]: crate::ln::peer_handler::PeerManager::process_events * [`ChannelMonitorUpdateStatus::InProgress`]: crate::chain::ChannelMonitorUpdateStatus::InProgress - * - * Note that payment_secret (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKCResult_NonePaymentSendFailureZ ChannelManager_send_payment(const struct LDKChannelManager *NONNULL_PTR this_arg, const struct LDKRoute *NONNULL_PTR route, struct LDKThirtyTwoBytes payment_hash, struct LDKThirtyTwoBytes payment_secret, struct LDKThirtyTwoBytes payment_id); +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); /** * Similar to [`ChannelManager::send_payment`], but will automatically find a route based on * `route_params` and retry failed payment paths based on `retry_strategy`. - * - * Note that payment_secret (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKCResult_NoneRetryableSendFailureZ ChannelManager_send_payment_with_retry(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes payment_hash, struct LDKThirtyTwoBytes payment_secret, struct LDKThirtyTwoBytes payment_id, struct LDKRouteParameters route_params, struct LDKRetry retry_strategy); +MUST_USE_RES struct LDKCResult_NoneRetryableSendFailureZ ChannelManager_send_payment(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes payment_hash, struct LDKRecipientOnionFields recipient_onion, struct LDKThirtyTwoBytes payment_id, struct LDKRouteParameters route_params, struct LDKRetry retry_strategy); /** * Signals that no further retries for the given payment should occur. Useful if you have a @@ -24058,7 +24854,7 @@ void ChannelManager_abandon_payment(const struct LDKChannelManager *NONNULL_PTR * * Note that payment_preimage (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKCResult_PaymentHashPaymentSendFailureZ ChannelManager_send_spontaneous_payment(const struct LDKChannelManager *NONNULL_PTR this_arg, const struct LDKRoute *NONNULL_PTR route, struct LDKThirtyTwoBytes payment_preimage, struct LDKThirtyTwoBytes payment_id); +MUST_USE_RES struct LDKCResult_PaymentHashPaymentSendFailureZ ChannelManager_send_spontaneous_payment(const struct LDKChannelManager *NONNULL_PTR this_arg, const struct LDKRoute *NONNULL_PTR route, struct LDKThirtyTwoBytes payment_preimage, struct LDKRecipientOnionFields recipient_onion, struct LDKThirtyTwoBytes payment_id); /** * Similar to [`ChannelManager::send_spontaneous_payment`], but will automatically find a route @@ -24071,14 +24867,14 @@ MUST_USE_RES struct LDKCResult_PaymentHashPaymentSendFailureZ ChannelManager_sen * * Note that payment_preimage (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKCResult_PaymentHashRetryableSendFailureZ ChannelManager_send_spontaneous_payment_with_retry(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes payment_preimage, struct LDKThirtyTwoBytes payment_id, struct LDKRouteParameters route_params, struct LDKRetry retry_strategy); +MUST_USE_RES struct LDKCResult_PaymentHashRetryableSendFailureZ ChannelManager_send_spontaneous_payment_with_retry(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes payment_preimage, struct LDKRecipientOnionFields recipient_onion, struct LDKThirtyTwoBytes payment_id, struct LDKRouteParameters route_params, struct LDKRetry retry_strategy); /** * Send a payment that is probing the given route for liquidity. We calculate the * [`PaymentHash`] of probes based on a static secret and a random [`PaymentId`], which allows * us to easily discern them from real payments. */ -MUST_USE_RES struct LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ ChannelManager_send_probe(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKCVec_RouteHopZ hops); +MUST_USE_RES struct LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ ChannelManager_send_probe(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKPath path); /** * Call this upon creation of a funding transaction for the given channel. @@ -24109,8 +24905,8 @@ MUST_USE_RES struct LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ * implemented by Bitcoin Core wallet. See * for more details. * - * [`Event::FundingGenerationReady`]: crate::util::events::Event::FundingGenerationReady - * [`Event::ChannelClosed`]: crate::util::events::Event::ChannelClosed + * [`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 uint8_t (*temporary_channel_id)[32], struct LDKPublicKey counterparty_node_id, struct LDKTransaction funding_transaction); @@ -24188,15 +24984,18 @@ void ChannelManager_process_pending_htlc_forwards(const struct LDKChannelManager * * This currently includes: * * Increasing or decreasing the on-chain feerate estimates for our outbound channels, - * * Broadcasting `ChannelUpdate` messages if we've been disconnected from our peer for more + * * Broadcasting [`ChannelUpdate`] messages if we've been disconnected from our peer for more * than a minute, informing the network that they should no longer attempt to route over * the channel. - * * Expiring a channel's previous `ChannelConfig` if necessary to only allow forwarding HTLCs - * with the current `ChannelConfig`. + * * Expiring a channel's previous [`ChannelConfig`] if necessary to only allow forwarding HTLCs + * with the current [`ChannelConfig`]. * * Removing peers which have disconnected but and no longer have any channels. * - * Note that this may cause reentrancy through `chain::Watch::update_channel` calls or feerate + * Note that this may cause reentrancy through [`chain::Watch::update_channel`] calls or feerate * estimate fetches. + * + * [`ChannelUpdate`]: msgs::ChannelUpdate + * [`ChannelConfig`]: crate::util::config::ChannelConfig */ void ChannelManager_timer_tick_occurred(const struct LDKChannelManager *NONNULL_PTR this_arg); @@ -24229,17 +25028,19 @@ void ChannelManager_fail_htlc_backwards_with_reason(const struct LDKChannelManag * Provides a payment preimage in response to [`Event::PaymentClaimable`], generating any * [`MessageSendEvent`]s needed to claim the payment. * - * Note that calling this method does *not* guarantee that the payment has been claimed. You - * *must* wait for an [`Event::PaymentClaimed`] event which upon a successful claim will be - * provided to your [`EventHandler`] when [`process_pending_events`] is next called. + * This method is guaranteed to ensure the payment has been claimed but only if the current + * height is strictly below [`Event::PaymentClaimable::claim_deadline`]. To avoid race + * conditions, you should wait for an [`Event::PaymentClaimed`] before considering the payment + * successful. It will generally be available in the next [`process_pending_events`] call. * * Note that if you did not set an `amount_msat` when calling [`create_inbound_payment`] or * [`create_inbound_payment_for_hash`] you must check that the amount in the `PaymentClaimable` * event matches your expectation. If you fail to do so and call this method, you may provide * the sender \"proof-of-payment\" when they did not fulfill the full expected payment. * - * [`Event::PaymentClaimable`]: crate::util::events::Event::PaymentClaimable - * [`Event::PaymentClaimed`]: crate::util::events::Event::PaymentClaimed + * [`Event::PaymentClaimable`]: crate::events::Event::PaymentClaimable + * [`Event::PaymentClaimable::claim_deadline`]: crate::events::Event::PaymentClaimable::claim_deadline + * [`Event::PaymentClaimed`]: crate::events::Event::PaymentClaimed * [`process_pending_events`]: EventsProvider::process_pending_events * [`create_inbound_payment`]: Self::create_inbound_payment * [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash @@ -24469,33 +25270,11 @@ struct LDKListen ChannelManager_as_Listen(const struct LDKChannelManager *NONNUL struct LDKConfirm ChannelManager_as_Confirm(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * Blocks until ChannelManager needs to be persisted or a timeout is reached. It returns a bool - * indicating whether persistence is necessary. Only one listener on - * [`await_persistable_update`], [`await_persistable_update_timeout`], or a future returned by - * [`get_persistable_update_future`] is guaranteed to be woken up. - * - * Note that this method is not available with the `no-std` feature. + * Gets a [`Future`] that completes when this [`ChannelManager`] needs to be persisted. * - * [`await_persistable_update`]: Self::await_persistable_update - * [`await_persistable_update_timeout`]: Self::await_persistable_update_timeout - * [`get_persistable_update_future`]: Self::get_persistable_update_future - */ -MUST_USE_RES bool ChannelManager_await_persistable_update_timeout(const struct LDKChannelManager *NONNULL_PTR this_arg, uint64_t max_wait); - -/** - * Blocks until ChannelManager needs to be persisted. Only one listener on - * [`await_persistable_update`], `await_persistable_update_timeout`, or a future returned by - * [`get_persistable_update_future`] is guaranteed to be woken up. + * Note that callbacks registered on the [`Future`] MUST NOT call back into this + * [`ChannelManager`] and should instead register actions to be taken later. * - * [`await_persistable_update`]: Self::await_persistable_update - * [`get_persistable_update_future`]: Self::get_persistable_update_future - */ -void ChannelManager_await_persistable_update(const struct LDKChannelManager *NONNULL_PTR this_arg); - -/** - * Gets a [`Future`] that completes when a persistable update is available. Note that - * callbacks registered on the [`Future`] MUST NOT call back into this [`ChannelManager`] and - * should instead register actions to be taken later. */ MUST_USE_RES struct LDKFuture ChannelManager_get_persistable_update_future(const struct LDKChannelManager *NONNULL_PTR this_arg); @@ -26449,14 +27228,14 @@ void UnsignedNodeAnnouncement_set_rgb(struct LDKUnsignedNodeAnnouncement *NONNUL * * This should be sanitized before use. There is no guarantee of uniqueness. */ -const uint8_t (*UnsignedNodeAnnouncement_get_alias(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr))[32]; +struct LDKNodeAlias UnsignedNodeAnnouncement_get_alias(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr); /** * An alias, for UI purposes. * * This should be sanitized before use. There is no guarantee of uniqueness. */ -void UnsignedNodeAnnouncement_set_alias(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void UnsignedNodeAnnouncement_set_alias(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKNodeAlias val); /** * List of addresses on which this node is reachable @@ -27826,8 +28605,9 @@ struct LDKPeerHandleError PeerHandleError_clone(const struct LDKPeerHandleError void PeerManager_free(struct LDKPeerManager this_obj); /** - * Constructs a new PeerManager with the given message handlers and node_id secret key - * ephemeral_random_data is used to derive per-connection ephemeral keys and must be + * Constructs a new `PeerManager` with the given message handlers. + * + * `ephemeral_random_data` is used to derive per-connection ephemeral keys and must be * cryptographically secure random bytes. * * `current_time` is used as an always-increasing counter that survives across restarts and is @@ -27864,9 +28644,9 @@ MUST_USE_RES struct LDKCVec_C2Tuple_PublicKeyCOption_NetAddressZZZ PeerManager_g * Returns a small number of bytes to send to the remote node (currently always 50). * * Panics if descriptor is duplicative with some other descriptor which has not yet been - * [`socket_disconnected()`]. + * [`socket_disconnected`]. * - * [`socket_disconnected()`]: PeerManager::socket_disconnected + * [`socket_disconnected`]: PeerManager::socket_disconnected */ MUST_USE_RES struct LDKCResult_CVec_u8ZPeerHandleErrorZ PeerManager_new_outbound_connection(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKPublicKey their_node_id, struct LDKSocketDescriptor descriptor, struct LDKCOption_NetAddressZ remote_network_address); @@ -27883,9 +28663,9 @@ MUST_USE_RES struct LDKCResult_CVec_u8ZPeerHandleErrorZ PeerManager_new_outbound * the connection immediately. * * Panics if descriptor is duplicative with some other descriptor which has not yet been - * [`socket_disconnected()`]. + * [`socket_disconnected`]. * - * [`socket_disconnected()`]: PeerManager::socket_disconnected + * [`socket_disconnected`]: PeerManager::socket_disconnected */ MUST_USE_RES struct LDKCResult_NonePeerHandleErrorZ PeerManager_new_inbound_connection(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKSocketDescriptor descriptor, struct LDKCOption_NetAddressZ remote_network_address); @@ -27897,7 +28677,7 @@ MUST_USE_RES struct LDKCResult_NonePeerHandleErrorZ PeerManager_new_inbound_conn * May call [`send_data`] on the descriptor passed in (or an equal descriptor) before * returning. Thus, be very careful with reentrancy issues! The invariants around calling * [`write_buffer_space_avail`] in case a write did not fully complete must still hold - be - * ready to call `[write_buffer_space_avail`] again if a write call generated here isn't + * ready to call [`write_buffer_space_avail`] again if a write call generated here isn't * sufficient! * * [`send_data`]: SocketDescriptor::send_data @@ -28599,6 +29379,13 @@ MUST_USE_RES struct LDKChannelTransactionParameters ChannelTransactionParameters */ struct LDKChannelTransactionParameters ChannelTransactionParameters_clone(const struct LDKChannelTransactionParameters *NONNULL_PTR orig); +/** + * Checks if two ChannelTransactionParameterss contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ +bool ChannelTransactionParameters_eq(const struct LDKChannelTransactionParameters *NONNULL_PTR a, const struct LDKChannelTransactionParameters *NONNULL_PTR b); + /** * Frees any resources used by the CounterpartyChannelTransactionParameters, if is_owned is set and inner is non-NULL. */ @@ -28634,6 +29421,13 @@ MUST_USE_RES struct LDKCounterpartyChannelTransactionParameters CounterpartyChan */ struct LDKCounterpartyChannelTransactionParameters CounterpartyChannelTransactionParameters_clone(const struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR orig); +/** + * Checks if two CounterpartyChannelTransactionParameterss contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ +bool CounterpartyChannelTransactionParameters_eq(const struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR a, const struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR b); + /** * Whether the late bound parameters are populated. */ @@ -28821,10 +29615,14 @@ struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ BuiltCommitmentTransact MUST_USE_RES struct LDKThirtyTwoBytes BuiltCommitmentTransaction_get_sighash_all(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_arg, struct LDKu8slice funding_redeemscript, uint64_t channel_value_satoshis); /** - * Sign a transaction, either because we are counter-signing the counterparty's transaction or - * because we are about to broadcast a holder transaction. + * Signs the counterparty's commitment transaction. + */ +MUST_USE_RES struct LDKSignature BuiltCommitmentTransaction_sign_counterparty_commitment(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_arg, const uint8_t (*funding_key)[32], struct LDKu8slice funding_redeemscript, uint64_t channel_value_satoshis); + +/** + * Signs the holder commitment transaction because we are about to broadcast it. */ -MUST_USE_RES struct LDKSignature BuiltCommitmentTransaction_sign(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_arg, const uint8_t (*funding_key)[32], struct LDKu8slice funding_redeemscript, uint64_t channel_value_satoshis); +MUST_USE_RES struct LDKSignature BuiltCommitmentTransaction_sign_holder_commitment(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_arg, const uint8_t (*funding_key)[32], struct LDKu8slice funding_redeemscript, uint64_t channel_value_satoshis, const struct LDKEntropySource *NONNULL_PTR entropy_source); /** * Frees any resources used by the ClosingTransaction, if is_owned is set and inner is non-NULL. @@ -28837,7 +29635,7 @@ void ClosingTransaction_free(struct LDKClosingTransaction this_obj); struct LDKClosingTransaction ClosingTransaction_clone(const struct LDKClosingTransaction *NONNULL_PTR orig); /** - * Checks if two ClosingTransactions contain equal inner contents. + * Generates a non-cryptographic 64-bit hash of the ClosingTransaction. */ uint64_t ClosingTransaction_hash(const struct LDKClosingTransaction *NONNULL_PTR o); @@ -29009,7 +29807,7 @@ MUST_USE_RES bool TrustedCommitmentTransaction_opt_anchors(const struct LDKTrust * * This function is only valid in the holder commitment context, it always uses EcdsaSighashType::All. */ -MUST_USE_RES struct LDKCResult_CVec_SignatureZNoneZ TrustedCommitmentTransaction_get_htlc_sigs(const struct LDKTrustedCommitmentTransaction *NONNULL_PTR this_arg, const uint8_t (*htlc_base_key)[32], const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR channel_parameters); +MUST_USE_RES struct LDKCResult_CVec_SignatureZNoneZ TrustedCommitmentTransaction_get_htlc_sigs(const struct LDKTrustedCommitmentTransaction *NONNULL_PTR this_arg, const uint8_t (*htlc_base_key)[32], const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR channel_parameters, const struct LDKEntropySource *NONNULL_PTR entropy_source); /** * Commitment transaction numbers which appear in the transactions themselves are XOR'd with a @@ -30008,6 +30806,26 @@ MUST_USE_RES bool NodeFeatures_requires_scid_privacy(const struct LDKNodeFeature */ MUST_USE_RES bool ChannelTypeFeatures_requires_scid_privacy(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +/** + * Set this feature as optional. + */ +void InvoiceFeatures_set_payment_metadata_optional(struct LDKInvoiceFeatures *NONNULL_PTR this_arg); + +/** + * Set this feature as required. + */ +void InvoiceFeatures_set_payment_metadata_required(struct LDKInvoiceFeatures *NONNULL_PTR this_arg); + +/** + * Checks if this feature is supported. + */ +MUST_USE_RES bool InvoiceFeatures_supports_payment_metadata(const struct LDKInvoiceFeatures *NONNULL_PTR this_arg); + +/** + * Checks if this feature is required. + */ +MUST_USE_RES bool InvoiceFeatures_requires_payment_metadata(const struct LDKInvoiceFeatures *NONNULL_PTR this_arg); + /** * Set this feature as optional. */ @@ -30212,7 +31030,7 @@ struct LDKRetry Retry_timeout(uint64_t a); bool Retry_eq(const struct LDKRetry *NONNULL_PTR a, const struct LDKRetry *NONNULL_PTR b); /** - * Checks if two Retrys contain equal inner contents. + * Generates a non-cryptographic 64-bit hash of the Retry. */ uint64_t Retry_hash(const struct LDKRetry *NONNULL_PTR o); @@ -30271,6 +31089,122 @@ struct LDKPaymentSendFailure PaymentSendFailure_duplicate_payment(void); */ struct LDKPaymentSendFailure PaymentSendFailure_partial_failure(struct LDKCVec_CResult_NoneAPIErrorZZ results, struct LDKRouteParameters failed_paths_retry, struct LDKThirtyTwoBytes payment_id); +/** + * 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. + * + * If you do not have one, the [`Route`] you pay over must not contain multiple paths as + * multi-path payments require a recipient-provided secret. + * + * Note that for spontaneous payments most lightning nodes do not currently support MPP + * receives, thus you should generally never be providing a secret here for spontaneous + * payments. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +struct LDKThirtyTwoBytes RecipientOnionFields_get_payment_secret(const struct LDKRecipientOnionFields *NONNULL_PTR this_ptr); + +/** + * The [`PaymentSecret`] is an arbitrary 32 bytes provided by the recipient for us to repeat + * in the onion. It is unrelated to `payment_hash` (or [`PaymentPreimage`]) and exists to + * authenticate the sender to the recipient and prevent payment-probing (deanonymization) + * attacks. + * + * If you do not have one, the [`Route`] you pay over must not contain multiple paths as + * multi-path payments require a recipient-provided secret. + * + * Note that for spontaneous payments most lightning nodes do not currently support MPP + * receives, thus you should generally never be providing a secret here for spontaneous + * payments. + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +void RecipientOnionFields_set_payment_secret(struct LDKRecipientOnionFields *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); + +/** + * 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. + */ +struct LDKCOption_CVec_u8ZZ RecipientOnionFields_get_payment_metadata(const struct LDKRecipientOnionFields *NONNULL_PTR this_ptr); + +/** + * 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. + */ +void RecipientOnionFields_set_payment_metadata(struct LDKRecipientOnionFields *NONNULL_PTR this_ptr, struct LDKCOption_CVec_u8ZZ val); + +/** + * Constructs a new RecipientOnionFields given each field + */ +MUST_USE_RES struct LDKRecipientOnionFields RecipientOnionFields_new(struct LDKThirtyTwoBytes payment_secret_arg, struct LDKCOption_CVec_u8ZZ payment_metadata_arg); + +/** + * Creates a copy of the RecipientOnionFields + */ +struct LDKRecipientOnionFields RecipientOnionFields_clone(const struct LDKRecipientOnionFields *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. + */ +bool RecipientOnionFields_eq(const struct LDKRecipientOnionFields *NONNULL_PTR a, const struct LDKRecipientOnionFields *NONNULL_PTR b); + +/** + * Serialize the RecipientOnionFields object into a byte array which can be read by RecipientOnionFields_read + */ +struct LDKCVec_u8Z RecipientOnionFields_write(const struct LDKRecipientOnionFields *NONNULL_PTR obj); + +/** + * Read a RecipientOnionFields from a byte array, created by RecipientOnionFields_write + */ +struct LDKCResult_RecipientOnionFieldsDecodeErrorZ RecipientOnionFields_read(struct LDKu8slice ser); + +/** + * 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. + */ +MUST_USE_RES struct LDKRecipientOnionFields RecipientOnionFields_secret_only(struct LDKThirtyTwoBytes payment_secret); + +/** + * Creates a new [`RecipientOnionFields`] with no fields. This generally does not create + * payable HTLCs except for spontaneous payments, i.e. this should generally only be used for + * calls to [`ChannelManager::send_spontaneous_payment`]. + * + * [`ChannelManager::send_spontaneous_payment`]: super::channelmanager::ChannelManager::send_spontaneous_payment + */ +MUST_USE_RES struct LDKRecipientOnionFields RecipientOnionFields_spontaneous_empty(void); + /** * Calls the free function if one is set */ @@ -30281,6 +31215,402 @@ void CustomMessageReader_free(struct LDKCustomMessageReader this_ptr); */ void Type_free(struct LDKType this_ptr); +/** + * Frees any resources used by the UnsignedInvoice, if is_owned is set and inner is non-NULL. + */ +void UnsignedInvoice_free(struct LDKUnsignedInvoice this_obj); + +/** + * The public key corresponding to the key needed to sign the invoice. + */ +MUST_USE_RES struct LDKPublicKey UnsignedInvoice_signing_pubkey(const struct LDKUnsignedInvoice *NONNULL_PTR this_arg); + +/** + * Frees any resources used by the BlindedPayInfo, if is_owned is set and inner is non-NULL. + */ +void BlindedPayInfo_free(struct LDKBlindedPayInfo this_obj); + +/** + * Base fee charged (in millisatoshi) for the entire blinded path. + */ +uint32_t BlindedPayInfo_get_fee_base_msat(const struct LDKBlindedPayInfo *NONNULL_PTR this_ptr); + +/** + * Base fee charged (in millisatoshi) for the entire blinded path. + */ +void BlindedPayInfo_set_fee_base_msat(struct LDKBlindedPayInfo *NONNULL_PTR this_ptr, uint32_t val); + +/** + * Liquidity fee charged (in millionths of the amount transferred) for the entire blinded path + * (i.e., 10,000 is 1%). + */ +uint32_t BlindedPayInfo_get_fee_proportional_millionths(const struct LDKBlindedPayInfo *NONNULL_PTR this_ptr); + +/** + * Liquidity fee charged (in millionths of the amount transferred) for the entire blinded path + * (i.e., 10,000 is 1%). + */ +void BlindedPayInfo_set_fee_proportional_millionths(struct LDKBlindedPayInfo *NONNULL_PTR this_ptr, uint32_t val); + +/** + * Number of blocks subtracted from an incoming HTLC's `cltv_expiry` for the entire blinded + * path. + */ +uint16_t BlindedPayInfo_get_cltv_expiry_delta(const struct LDKBlindedPayInfo *NONNULL_PTR this_ptr); + +/** + * Number of blocks subtracted from an incoming HTLC's `cltv_expiry` for the entire blinded + * path. + */ +void BlindedPayInfo_set_cltv_expiry_delta(struct LDKBlindedPayInfo *NONNULL_PTR this_ptr, uint16_t 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. + */ +uint64_t BlindedPayInfo_get_htlc_minimum_msat(const struct LDKBlindedPayInfo *NONNULL_PTR this_ptr); + +/** + * The minimum HTLC value (in millisatoshi) that is acceptable to all channel peers on the + * blinded path from the introduction node to the recipient, accounting for any fees, i.e., as + * seen by the recipient. + */ +void BlindedPayInfo_set_htlc_minimum_msat(struct LDKBlindedPayInfo *NONNULL_PTR this_ptr, uint64_t 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. + */ +uint64_t BlindedPayInfo_get_htlc_maximum_msat(const struct LDKBlindedPayInfo *NONNULL_PTR this_ptr); + +/** + * The maximum HTLC value (in millisatoshi) that is acceptable to all channel peers on the + * blinded path from the introduction node to the recipient, accounting for any fees, i.e., as + * seen by the recipient. + */ +void BlindedPayInfo_set_htlc_maximum_msat(struct LDKBlindedPayInfo *NONNULL_PTR this_ptr, uint64_t val); + +/** + * Features set in `encrypted_data_tlv` for the `encrypted_recipient_data` TLV record in an + * onion payload. + */ +struct LDKBlindedHopFeatures BlindedPayInfo_get_features(const struct LDKBlindedPayInfo *NONNULL_PTR this_ptr); + +/** + * Features set in `encrypted_data_tlv` for the `encrypted_recipient_data` TLV record in an + * onion payload. + */ +void BlindedPayInfo_set_features(struct LDKBlindedPayInfo *NONNULL_PTR this_ptr, struct LDKBlindedHopFeatures val); + +/** + * Constructs a new BlindedPayInfo given each field + */ +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); + +/** + * Creates a copy of the BlindedPayInfo + */ +struct LDKBlindedPayInfo BlindedPayInfo_clone(const struct LDKBlindedPayInfo *NONNULL_PTR orig); + +/** + * Generates a non-cryptographic 64-bit hash of the BlindedPayInfo. + */ +uint64_t BlindedPayInfo_hash(const struct LDKBlindedPayInfo *NONNULL_PTR o); + +/** + * 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. + */ +bool BlindedPayInfo_eq(const struct LDKBlindedPayInfo *NONNULL_PTR a, const struct LDKBlindedPayInfo *NONNULL_PTR b); + +/** + * Serialize the BlindedPayInfo object into a byte array which can be read by BlindedPayInfo_read + */ +struct LDKCVec_u8Z BlindedPayInfo_write(const struct LDKBlindedPayInfo *NONNULL_PTR obj); + +/** + * Read a BlindedPayInfo from a byte array, created by BlindedPayInfo_write + */ +struct LDKCResult_BlindedPayInfoDecodeErrorZ BlindedPayInfo_read(struct LDKu8slice ser); + +/** + * Frees any resources used by the UnsignedInvoiceRequest, if is_owned is set and inner is non-NULL. + */ +void UnsignedInvoiceRequest_free(struct LDKUnsignedInvoiceRequest this_obj); + +/** + * Frees any resources used by the InvoiceRequest, if is_owned is set and inner is non-NULL. + */ +void InvoiceRequest_free(struct LDKInvoiceRequest this_obj); + +/** + * Creates a copy of the InvoiceRequest + */ +struct LDKInvoiceRequest InvoiceRequest_clone(const struct LDKInvoiceRequest *NONNULL_PTR orig); + +/** + * An unpredictable series of bytes, typically containing information about the derivation of + * [`payer_id`]. + * + * [`payer_id`]: Self::payer_id + */ +MUST_USE_RES struct LDKu8slice InvoiceRequest_metadata(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); + +/** + * A chain from [`Offer::chains`] that the offer is valid for. + */ +MUST_USE_RES struct LDKThirtyTwoBytes InvoiceRequest_chain(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); + +/** + * 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 LDKCOption_u64Z InvoiceRequest_amount_msats(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); + +/** + * Features pertaining to requesting an invoice. + */ +MUST_USE_RES struct LDKInvoiceRequestFeatures InvoiceRequest_features(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); + +/** + * The quantity of the offer's item conforming to [`Offer::is_valid_quantity`]. + */ +MUST_USE_RES struct LDKCOption_u64Z InvoiceRequest_quantity(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); + +/** + * A possibly transient pubkey used to sign the invoice request. + */ +MUST_USE_RES struct LDKPublicKey InvoiceRequest_payer_id(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); + +/** + * 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 LDKPrintableString InvoiceRequest_payer_note(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); + +/** + * Serialize the InvoiceRequest object into a byte array which can be read by InvoiceRequest_read + */ +struct LDKCVec_u8Z InvoiceRequest_write(const struct LDKInvoiceRequest *NONNULL_PTR obj); + +/** + * Frees any resources used by the Offer, if is_owned is set and inner is non-NULL. + */ +void Offer_free(struct LDKOffer this_obj); + +/** + * Creates a copy of the Offer + */ +struct LDKOffer Offer_clone(const struct LDKOffer *NONNULL_PTR orig); + +/** + * 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 struct LDKCVec_ChainHashZ Offer_chains(const struct LDKOffer *NONNULL_PTR this_arg); + +/** + * Returns whether the given chain is supported by the offer. + */ +MUST_USE_RES bool Offer_supports_chain(const struct LDKOffer *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes chain); + +/** + * 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`. + */ +MUST_USE_RES struct LDKCOption_CVec_u8ZZ Offer_metadata(const struct LDKOffer *NONNULL_PTR this_arg); + +/** + * The minimum amount required for a successful payment of a single item. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +MUST_USE_RES struct LDKAmount Offer_amount(const struct LDKOffer *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. + */ +MUST_USE_RES struct LDKPrintableString Offer_description(const struct LDKOffer *NONNULL_PTR this_arg); + +/** + * Features pertaining to the offer. + */ +MUST_USE_RES struct LDKOfferFeatures Offer_features(const struct LDKOffer *NONNULL_PTR this_arg); + +/** + * Duration since the Unix epoch when an invoice should no longer be requested. + * + * If `None`, the offer does not expire. + */ +MUST_USE_RES struct LDKCOption_DurationZ Offer_absolute_expiry(const struct LDKOffer *NONNULL_PTR this_arg); + +/** + * Whether the offer has expired. + */ +MUST_USE_RES bool Offer_is_expired(const struct LDKOffer *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. + * + * 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); + +/** + * The quantity of items supported. + */ +MUST_USE_RES struct LDKQuantity Offer_supported_quantity(const struct LDKOffer *NONNULL_PTR this_arg); + +/** + * Returns whether the given quantity is valid for the offer. + */ +MUST_USE_RES bool Offer_is_valid_quantity(const struct LDKOffer *NONNULL_PTR this_arg, uint64_t quantity); + +/** + * Returns whether a quantity is expected in an [`InvoiceRequest`] for the offer. + * + * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest + */ +MUST_USE_RES bool Offer_expects_quantity(const struct LDKOffer *NONNULL_PTR this_arg); + +/** + * The public key used by the recipient to sign invoices. + */ +MUST_USE_RES struct LDKPublicKey Offer_signing_pubkey(const struct LDKOffer *NONNULL_PTR this_arg); + +/** + * Serialize the Offer object into a byte array which can be read by Offer_read + */ +struct LDKCVec_u8Z Offer_write(const struct LDKOffer *NONNULL_PTR obj); + +/** + * Frees any resources used by the Amount, if is_owned is set and inner is non-NULL. + */ +void Amount_free(struct LDKAmount this_obj); + +/** + * Creates a copy of the Amount + */ +struct LDKAmount Amount_clone(const struct LDKAmount *NONNULL_PTR orig); + +/** + * Frees any resources used by the Quantity, if is_owned is set and inner is non-NULL. + */ +void Quantity_free(struct LDKQuantity this_obj); + +/** + * Creates a copy of the Quantity + */ +struct LDKQuantity Quantity_clone(const struct LDKQuantity *NONNULL_PTR orig); + +/** + * Frees any resources used by the Refund, if is_owned is set and inner is non-NULL. + */ +void Refund_free(struct LDKRefund this_obj); + +/** + * Creates a copy of the Refund + */ +struct LDKRefund Refund_clone(const struct LDKRefund *NONNULL_PTR orig); + +/** + * 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 LDKPrintableString Refund_description(const struct LDKRefund *NONNULL_PTR this_arg); + +/** + * Duration since the Unix epoch when an invoice should no longer be sent. + * + * If `None`, the refund does not expire. + */ +MUST_USE_RES struct LDKCOption_DurationZ Refund_absolute_expiry(const struct LDKRefund *NONNULL_PTR this_arg); + +/** + * Whether the refund has expired. + */ +MUST_USE_RES bool Refund_is_expired(const struct LDKRefund *NONNULL_PTR this_arg); + +/** + * 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 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. + */ +MUST_USE_RES struct LDKCVec_BlindedPathZ Refund_paths(const struct LDKRefund *NONNULL_PTR this_arg); + +/** + * An unpredictable series of bytes, typically containing information about the derivation of + * [`payer_id`]. + * + * [`payer_id`]: Self::payer_id + */ +MUST_USE_RES struct LDKu8slice Refund_metadata(const struct LDKRefund *NONNULL_PTR this_arg); + +/** + * A chain that the refund is valid for. + */ +MUST_USE_RES struct LDKThirtyTwoBytes Refund_chain(const struct LDKRefund *NONNULL_PTR this_arg); + +/** + * The amount to refund in msats (i.e., the minimum lightning-payable unit for [`chain`]). + * + * [`chain`]: Self::chain + */ +MUST_USE_RES uint64_t Refund_amount_msats(const struct LDKRefund *NONNULL_PTR this_arg); + +/** + * Features pertaining to requesting an invoice. + */ +MUST_USE_RES struct LDKInvoiceRequestFeatures Refund_features(const struct LDKRefund *NONNULL_PTR this_arg); + +/** + * The quantity of an item that refund is for. + */ +MUST_USE_RES struct LDKCOption_u64Z Refund_quantity(const struct LDKRefund *NONNULL_PTR this_arg); + +/** + * A public node id to send to in the case where there are no [`paths`]. Otherwise, a possibly + * transient pubkey. + * + * [`paths`]: Self::paths + */ +MUST_USE_RES struct LDKPublicKey Refund_payer_id(const struct LDKRefund *NONNULL_PTR this_arg); + +/** + * Payer provided note to include in the invoice. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +MUST_USE_RES struct LDKPrintableString Refund_payer_note(const struct LDKRefund *NONNULL_PTR this_arg); + +/** + * Serialize the Refund object into a byte array which can be read by Refund_read + */ +struct LDKCVec_u8Z Refund_write(const struct LDKRefund *NONNULL_PTR obj); + /** * Creates a copy of the UtxoLookupError */ @@ -30387,7 +31717,12 @@ MUST_USE_RES struct LDKNodeId NodeId_from_pubkey(struct LDKPublicKey pubkey); MUST_USE_RES struct LDKu8slice NodeId_as_slice(const struct LDKNodeId *NONNULL_PTR this_arg); /** - * Checks if two NodeIds contain equal inner contents. + * Get the public key from this NodeId + */ +MUST_USE_RES struct LDKCResult_PublicKeyErrorZ NodeId_as_pubkey(const struct LDKNodeId *NONNULL_PTR this_arg); + +/** + * Generates a non-cryptographic 64-bit hash of the NodeId. */ uint64_t NodeId_hash(const struct LDKNodeId *NONNULL_PTR o); @@ -30459,7 +31794,7 @@ void P2PGossipSync_free(struct LDKP2PGossipSync this_obj); /** * Creates a new tracker of the actual state of the network of channels and nodes, - * assuming an existing Network Graph. + * 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. */ @@ -30475,7 +31810,7 @@ void P2PGossipSync_add_utxo_lookup(struct LDKP2PGossipSync *NONNULL_PTR this_arg /** * Handles any network updates originating from [`Event`]s. * - * [`Event`]: crate::util::events::Event + * [`Event`]: crate::events::Event */ void NetworkGraph_handle_network_update(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKNetworkUpdate *NONNULL_PTR network_update); @@ -30841,7 +32176,7 @@ bool RoutingFees_eq(const struct LDKRoutingFees *NONNULL_PTR a, const struct LDK struct LDKRoutingFees RoutingFees_clone(const struct LDKRoutingFees *NONNULL_PTR orig); /** - * Checks if two RoutingFeess contain equal inner contents. + * Generates a non-cryptographic 64-bit hash of the RoutingFees. */ uint64_t RoutingFees_hash(const struct LDKRoutingFees *NONNULL_PTR o); @@ -30906,18 +32241,6 @@ struct LDKNodeAlias NodeAnnouncementInfo_get_alias(const struct LDKNodeAnnouncem */ void NodeAnnouncementInfo_set_alias(struct LDKNodeAnnouncementInfo *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 LDKCVec_NetAddressZ NodeAnnouncementInfo_get_addresses(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr); - -/** - * Internet-level addresses via which one can connect to the node - */ -void NodeAnnouncementInfo_set_addresses(struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr, struct LDKCVec_NetAddressZ val); - /** * An initial announcement of the node * Mostly redundant with the data we store in fields explicitly. @@ -30941,7 +32264,7 @@ void NodeAnnouncementInfo_set_announcement_message(struct LDKNodeAnnouncementInf /** * Constructs a new NodeAnnouncementInfo 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 LDKCVec_NetAddressZ addresses_arg, struct LDKNodeAnnouncement announcement_message_arg); +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); /** * Creates a copy of the NodeAnnouncementInfo @@ -30955,6 +32278,11 @@ struct LDKNodeAnnouncementInfo NodeAnnouncementInfo_clone(const struct LDKNodeAn */ bool NodeAnnouncementInfo_eq(const struct LDKNodeAnnouncementInfo *NONNULL_PTR a, const struct LDKNodeAnnouncementInfo *NONNULL_PTR b); +/** + * Internet-level addresses via which one can connect to the node + */ +MUST_USE_RES struct LDKCVec_NetAddressZ NodeAnnouncementInfo_addresses(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_arg); + /** * Serialize the NodeAnnouncementInfo object into a byte array which can be read by NodeAnnouncementInfo_read */ @@ -31146,12 +32474,11 @@ MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_f 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); /** - * Marks a channel in the graph as failed if a corresponding HTLC fail was sent. - * If permanent, removes a channel from the local storage. - * May cause the removal of nodes too, if this was their last channel. - * If not permanent, makes channels unavailable for routing. + * 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. */ -void NetworkGraph_channel_failed(const struct LDKNetworkGraph *NONNULL_PTR this_arg, uint64_t short_channel_id, bool is_permanent); +void NetworkGraph_channel_failed_permanent(const struct LDKNetworkGraph *NONNULL_PTR this_arg, uint64_t short_channel_id); /** * Marks a node in the graph as permanently failed, effectively removing it and its channels @@ -31307,6 +32634,11 @@ struct LDKInFlightHtlcs InFlightHtlcs_clone(const struct LDKInFlightHtlcs *NONNU */ 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); + /** * Returns liquidity in msat given the public key of the HTLC source, target, and short channel * id. @@ -31374,27 +32706,41 @@ void RouteHop_set_channel_features(struct LDKRouteHop *NONNULL_PTR this_ptr, str /** * The fee taken on this hop (for paying for the use of the *next* channel in the path). - * For the last hop, this should be the full value of the payment (might be more than - * requested if we had to match htlc_minimum_msat). + * 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 */ 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). - * For the last hop, this should be the full value of the payment (might be more than - * requested if we had to match htlc_minimum_msat). + * 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 */ void RouteHop_set_fee_msat(struct LDKRouteHop *NONNULL_PTR this_ptr, uint64_t val); /** - * The CLTV delta added for this hop. For the last hop, this should be the full CLTV value - * expected at the destination, in excess of the current block height. + * 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 */ uint32_t RouteHop_get_cltv_expiry_delta(const struct LDKRouteHop *NONNULL_PTR this_ptr); /** - * The CLTV delta added for this hop. For the last hop, this should be the full CLTV value - * expected at the destination, in excess of the current block height. + * The CLTV delta added for this hop. + * If this is the last hop in [`Path::hops`]: + * * if we're sending to a [`BlindedPath`], this is the CLTV delta for the entire blinded path + * * otherwise, this is the CLTV delta expected at the destination + * + * [`BlindedPath`]: crate::blinded_path::BlindedPath */ void RouteHop_set_cltv_expiry_delta(struct LDKRouteHop *NONNULL_PTR this_ptr, uint32_t val); @@ -31409,7 +32755,7 @@ MUST_USE_RES struct LDKRouteHop RouteHop_new(struct LDKPublicKey pubkey_arg, str struct LDKRouteHop RouteHop_clone(const struct LDKRouteHop *NONNULL_PTR orig); /** - * Checks if two RouteHops contain equal inner contents. + * Generates a non-cryptographic 64-bit hash of the RouteHop. */ uint64_t RouteHop_hash(const struct LDKRouteHop *NONNULL_PTR o); @@ -31430,35 +32776,184 @@ struct LDKCVec_u8Z RouteHop_write(const struct LDKRouteHop *NONNULL_PTR obj); */ 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 [`BlindedPath`] provided by the recipient. + * + * [`BlindedPath`]: crate::blinded_path::BlindedPath + */ +struct LDKCVec_BlindedHopZ BlindedTail_get_hops(const struct LDKBlindedTail *NONNULL_PTR this_ptr); + +/** + * The hops of the [`BlindedPath`] provided by the recipient. + * + * [`BlindedPath`]: crate::blinded_path::BlindedPath + */ +void BlindedTail_set_hops(struct LDKBlindedTail *NONNULL_PTR this_ptr, struct LDKCVec_BlindedHopZ val); + +/** + * The blinding point of the [`BlindedPath`] provided by the recipient. + * + * [`BlindedPath`]: crate::blinded_path::BlindedPath + */ +struct LDKPublicKey BlindedTail_get_blinding_point(const struct LDKBlindedTail *NONNULL_PTR this_ptr); + +/** + * The blinding point of the [`BlindedPath`] provided by the recipient. + * + * [`BlindedPath`]: crate::blinded_path::BlindedPath + */ +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 + */ +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 routes taken for a single (potentially-)multi-part payment. The pubkey of the - * last RouteHop in each path must be the same. Each entry represents a list of hops, NOT - * INCLUDING our own, where the last hop is the destination. Thus, this must always be at - * least length one. While the maximum length of any given path is variable, keeping the length - * of any path less or equal to 19 should currently ensure it is viable. + * 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_CVec_RouteHopZZ Route_get_paths(const struct LDKRoute *NONNULL_PTR this_ptr); +struct LDKCVec_PathZ Route_get_paths(const struct LDKRoute *NONNULL_PTR this_ptr); /** - * The list of routes taken for a single (potentially-)multi-part payment. The pubkey of the - * last RouteHop in each path must be the same. Each entry represents a list of hops, NOT - * INCLUDING our own, where the last hop is the destination. Thus, this must always be at - * least length one. While the maximum length of any given path is variable, keeping the length - * of any path less or equal to 19 should currently ensure it is viable. + * 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_CVec_RouteHopZZ val); +void Route_set_paths(struct LDKRoute *NONNULL_PTR this_ptr, struct LDKCVec_PathZ val); /** * The `payment_params` parameter passed to [`find_route`]. * This is used by `ChannelManager` to track information which may be required for retries, * provided back to you via [`Event::PaymentPathFailed`]. * - * [`Event::PaymentPathFailed`]: crate::util::events::Event::PaymentPathFailed + * [`Event::PaymentPathFailed`]: crate::events::Event::PaymentPathFailed * * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ @@ -31469,7 +32964,7 @@ struct LDKPaymentParameters Route_get_payment_params(const struct LDKRoute *NONN * This is used by `ChannelManager` to track information which may be required for retries, * provided back to you via [`Event::PaymentPathFailed`]. * - * [`Event::PaymentPathFailed`]: crate::util::events::Event::PaymentPathFailed + * [`Event::PaymentPathFailed`]: crate::events::Event::PaymentPathFailed * * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ @@ -31478,7 +32973,7 @@ void Route_set_payment_params(struct LDKRoute *NONNULL_PTR this_ptr, struct LDKP /** * Constructs a new Route given each field */ -MUST_USE_RES struct LDKRoute Route_new(struct LDKCVec_CVec_RouteHopZZ paths_arg, struct LDKPaymentParameters payment_params_arg); +MUST_USE_RES struct LDKRoute Route_new(struct LDKCVec_PathZ paths_arg, struct LDKPaymentParameters payment_params_arg); /** * Creates a copy of the Route @@ -31486,7 +32981,7 @@ MUST_USE_RES struct LDKRoute Route_new(struct LDKCVec_CVec_RouteHopZZ paths_arg, struct LDKRoute Route_clone(const struct LDKRoute *NONNULL_PTR orig); /** - * Checks if two Routes contain equal inner contents. + * Generates a non-cryptographic 64-bit hash of the Route. */ uint64_t Route_hash(const struct LDKRoute *NONNULL_PTR o); @@ -31506,7 +33001,8 @@ bool Route_eq(const struct LDKRoute *NONNULL_PTR a, const struct LDKRoute *NONNU 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. + * Returns the total amount paid on this [`Route`], excluding the fees. Might be more than + * requested if we had to reach htlc_minimum_msat. */ MUST_USE_RES uint64_t Route_get_total_amount(const struct LDKRoute *NONNULL_PTR this_arg); @@ -31614,12 +33110,12 @@ void PaymentParameters_set_features(struct LDKPaymentParameters *NONNULL_PTR thi /** * Hints for routing to the payee, containing channels connecting the payee to public nodes. */ -struct LDKCVec_RouteHintZ PaymentParameters_get_route_hints(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); +struct LDKHints PaymentParameters_get_route_hints(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); /** * Hints for routing to the payee, containing channels connecting the payee to public nodes. */ -void PaymentParameters_set_route_hints(struct LDKPaymentParameters *NONNULL_PTR this_ptr, struct LDKCVec_RouteHintZ val); +void PaymentParameters_set_route_hints(struct LDKPaymentParameters *NONNULL_PTR this_ptr, struct LDKHints val); /** * Expiration of a payment to the payee, in seconds relative to the UNIX epoch. @@ -31718,7 +33214,7 @@ void PaymentParameters_set_final_cltv_expiry_delta(struct LDKPaymentParameters * /** * Constructs a new PaymentParameters given each field */ -MUST_USE_RES struct LDKPaymentParameters PaymentParameters_new(struct LDKPublicKey payee_pubkey_arg, struct LDKInvoiceFeatures features_arg, struct LDKCVec_RouteHintZ route_hints_arg, struct LDKCOption_u64Z expiry_time_arg, uint32_t max_total_cltv_expiry_delta_arg, uint8_t max_path_count_arg, uint8_t max_channel_saturation_power_of_half_arg, struct LDKCVec_u64Z previously_failed_channels_arg, uint32_t final_cltv_expiry_delta_arg); +MUST_USE_RES struct LDKPaymentParameters PaymentParameters_new(struct LDKPublicKey payee_pubkey_arg, struct LDKInvoiceFeatures features_arg, struct LDKHints route_hints_arg, struct LDKCOption_u64Z expiry_time_arg, uint32_t max_total_cltv_expiry_delta_arg, uint8_t max_path_count_arg, uint8_t max_channel_saturation_power_of_half_arg, struct LDKCVec_u64Z previously_failed_channels_arg, uint32_t final_cltv_expiry_delta_arg); /** * Creates a copy of the PaymentParameters @@ -31726,7 +33222,7 @@ MUST_USE_RES struct LDKPaymentParameters PaymentParameters_new(struct LDKPublicK struct LDKPaymentParameters PaymentParameters_clone(const struct LDKPaymentParameters *NONNULL_PTR orig); /** - * Checks if two PaymentParameterss contain equal inner contents. + * Generates a non-cryptographic 64-bit hash of the PaymentParameters. */ uint64_t PaymentParameters_hash(const struct LDKPaymentParameters *NONNULL_PTR o); @@ -31763,6 +33259,37 @@ MUST_USE_RES struct LDKPaymentParameters PaymentParameters_from_node_id(struct L */ MUST_USE_RES struct LDKPaymentParameters PaymentParameters_for_keysend(struct LDKPublicKey payee_pubkey, uint32_t final_cltv_expiry_delta); +/** + * Frees any resources used by the Hints + */ +void Hints_free(struct LDKHints this_ptr); + +/** + * Creates a copy of the Hints + */ +struct LDKHints Hints_clone(const struct LDKHints *NONNULL_PTR orig); + +/** + * Utility method to constructs a new Blinded-variant Hints + */ +struct LDKHints Hints_blinded(struct LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ a); + +/** + * Utility method to constructs a new Clear-variant Hints + */ +struct LDKHints Hints_clear(struct LDKCVec_RouteHintZ a); + +/** + * Generates a non-cryptographic 64-bit hash of the Hints. + */ +uint64_t Hints_hash(const struct LDKHints *NONNULL_PTR o); + +/** + * Checks if two Hintss contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + */ +bool Hints_eq(const struct LDKHints *NONNULL_PTR a, const struct LDKHints *NONNULL_PTR b); + /** * Frees any resources used by the RouteHint, if is_owned is set and inner is non-NULL. */ @@ -31783,7 +33310,7 @@ MUST_USE_RES struct LDKRouteHint RouteHint_new(struct LDKCVec_RouteHintHopZ a_ar struct LDKRouteHint RouteHint_clone(const struct LDKRouteHint *NONNULL_PTR orig); /** - * Checks if two RouteHints contain equal inner contents. + * Generates a non-cryptographic 64-bit hash of the RouteHint. */ uint64_t RouteHint_hash(const struct LDKRouteHint *NONNULL_PTR o); @@ -31880,7 +33407,7 @@ MUST_USE_RES struct LDKRouteHintHop RouteHintHop_new(struct LDKPublicKey src_nod struct LDKRouteHintHop RouteHintHop_clone(const struct LDKRouteHintHop *NONNULL_PTR orig); /** - * Checks if two RouteHintHops contain equal inner contents. + * Generates a non-cryptographic 64-bit hash of the RouteHintHop. */ uint64_t RouteHintHop_hash(const struct LDKRouteHintHop *NONNULL_PTR o); @@ -31929,7 +33456,7 @@ struct LDKCResult_RouteHintHopDecodeErrorZ RouteHintHop_read(struct LDKu8slice s * [`ChannelManager::list_usable_channels`] will never include such channels. * * [`ChannelManager::list_usable_channels`]: crate::ln::channelmanager::ChannelManager::list_usable_channels - * [`Event::PaymentPathFailed`]: crate::util::events::Event::PaymentPathFailed + * [`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 @@ -32535,6 +34062,133 @@ struct LDKCVec_u8Z ProbabilisticScorer_write(const struct LDKProbabilisticScorer */ struct LDKCResult_ProbabilisticScorerDecodeErrorZ ProbabilisticScorer_read(struct LDKu8slice ser, struct LDKProbabilisticScoringParameters arg_a, const struct LDKNetworkGraph *NONNULL_PTR arg_b, struct LDKLogger arg_c); +/** + * Frees any resources used by the OnionMessenger, if is_owned is set and inner is non-NULL. + */ +void OnionMessenger_free(struct LDKOnionMessenger this_obj); + +/** + * Frees any resources used by the Destination + */ +void Destination_free(struct LDKDestination this_ptr); + +/** + * Creates a copy of the Destination + */ +struct LDKDestination Destination_clone(const struct LDKDestination *NONNULL_PTR orig); + +/** + * Utility method to constructs a new Node-variant Destination + */ +struct LDKDestination Destination_node(struct LDKPublicKey a); + +/** + * Utility method to constructs a new BlindedPath-variant Destination + */ +struct LDKDestination Destination_blinded_path(struct LDKBlindedPath a); + +/** + * Frees any resources used by the SendError + */ +void SendError_free(struct LDKSendError this_ptr); + +/** + * Creates a copy of the SendError + */ +struct LDKSendError SendError_clone(const struct LDKSendError *NONNULL_PTR orig); + +/** + * Utility method to constructs a new Secp256k1-variant SendError + */ +struct LDKSendError SendError_secp256k1(enum LDKSecp256k1Error a); + +/** + * Utility method to constructs a new TooBigPacket-variant SendError + */ +struct LDKSendError SendError_too_big_packet(void); + +/** + * Utility method to constructs a new TooFewBlindedHops-variant SendError + */ +struct LDKSendError SendError_too_few_blinded_hops(void); + +/** + * Utility method to constructs a new InvalidFirstHop-variant SendError + */ +struct LDKSendError SendError_invalid_first_hop(void); + +/** + * Utility method to constructs a new InvalidMessage-variant SendError + */ +struct LDKSendError SendError_invalid_message(void); + +/** + * Utility method to constructs a new BufferFull-variant SendError + */ +struct LDKSendError SendError_buffer_full(void); + +/** + * Utility method to constructs a new GetNodeIdFailed-variant SendError + */ +struct LDKSendError SendError_get_node_id_failed(void); + +/** + * Utility method to constructs a new BlindedPathAdvanceFailed-variant SendError + */ +struct LDKSendError SendError_blinded_path_advance_failed(void); + +/** + * Checks if two SendErrors contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + */ +bool SendError_eq(const struct LDKSendError *NONNULL_PTR a, const struct LDKSendError *NONNULL_PTR b); + +/** + * Calls the free function if one is set + */ +void CustomOnionMessageHandler_free(struct LDKCustomOnionMessageHandler this_ptr); + +/** + * Constructs a new `OnionMessenger` to send, forward, and delegate received onion messages to + * their respective handlers. + */ +MUST_USE_RES struct LDKOnionMessenger OnionMessenger_new(struct LDKEntropySource entropy_source, struct LDKNodeSigner node_signer, struct LDKLogger logger, struct LDKCustomOnionMessageHandler custom_handler); + +/** + * Send an onion message with contents `message` to `destination`, routing it through `intermediate_nodes`. + * See [`OnionMessenger`] for example usage. + * + * Note that reply_path (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +MUST_USE_RES struct LDKCResult_NoneSendErrorZ OnionMessenger_send_onion_message(const struct LDKOnionMessenger *NONNULL_PTR this_arg, struct LDKCVec_PublicKeyZ intermediate_nodes, struct LDKDestination destination, struct LDKOnionMessageContents message, struct LDKBlindedPath reply_path); + +/** + * 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 + */ +struct LDKOnionMessageHandler OnionMessenger_as_OnionMessageHandler(const struct LDKOnionMessenger *NONNULL_PTR this_arg); + +/** + * Constructs a new OnionMessageProvider which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned OnionMessageProvider must be freed before this_arg is + */ +struct LDKOnionMessageProvider OnionMessenger_as_OnionMessageProvider(const struct LDKOnionMessenger *NONNULL_PTR this_arg); + +/** + * Frees any resources used by the OnionMessageContents + */ +void OnionMessageContents_free(struct LDKOnionMessageContents this_ptr); + +/** + * Utility method to constructs a new Custom-variant OnionMessageContents + */ +struct LDKOnionMessageContents OnionMessageContents_custom(struct LDKCustomOnionMessageContents a); + +/** + * Calls the free function if one is set + */ +void CustomOnionMessageContents_free(struct LDKCustomOnionMessageContents this_ptr); + /** * Frees any resources used by the BlindedPath, if is_owned is set and inner is non-NULL. */ @@ -32545,6 +34199,18 @@ void BlindedPath_free(struct LDKBlindedPath this_obj); */ struct LDKBlindedPath BlindedPath_clone(const struct LDKBlindedPath *NONNULL_PTR orig); +/** + * Generates a non-cryptographic 64-bit hash of the BlindedPath. + */ +uint64_t BlindedPath_hash(const struct LDKBlindedPath *NONNULL_PTR o); + +/** + * 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. + */ +bool BlindedPath_eq(const struct LDKBlindedPath *NONNULL_PTR a, const struct LDKBlindedPath *NONNULL_PTR b); + /** * Frees any resources used by the BlindedHop, if is_owned is set and inner is non-NULL. */ @@ -32556,12 +34222,24 @@ void BlindedHop_free(struct LDKBlindedHop this_obj); struct LDKBlindedHop BlindedHop_clone(const struct LDKBlindedHop *NONNULL_PTR orig); /** - * Create a blinded path to be forwarded along `node_pks`. The last node pubkey in `node_pks` - * will be the destination node. + * Generates a non-cryptographic 64-bit hash of the BlindedHop. + */ +uint64_t BlindedHop_hash(const struct LDKBlindedHop *NONNULL_PTR o); + +/** + * 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. + */ +bool BlindedHop_eq(const struct LDKBlindedHop *NONNULL_PTR a, const struct LDKBlindedHop *NONNULL_PTR b); + +/** + * 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 less than two hops are provided or if `node_pk`(s) are invalid. */ -MUST_USE_RES struct LDKCResult_BlindedPathNoneZ BlindedPath_new(struct LDKCVec_PublicKeyZ node_pks, const struct LDKEntropySource *NONNULL_PTR entropy_source); +MUST_USE_RES struct LDKCResult_BlindedPathNoneZ BlindedPath_new_for_message(struct LDKCVec_PublicKeyZ node_pks, const struct LDKEntropySource *NONNULL_PTR entropy_source); /** * Serialize the BlindedPath object into a byte array which can be read by BlindedPath_read @@ -32584,131 +34262,495 @@ struct LDKCVec_u8Z BlindedHop_write(const struct LDKBlindedHop *NONNULL_PTR obj) struct LDKCResult_BlindedHopDecodeErrorZ BlindedHop_read(struct LDKu8slice ser); /** - * Frees any resources used by the OnionMessenger, if is_owned is set and inner is non-NULL. + * Frees any resources used by the PaymentPurpose */ -void OnionMessenger_free(struct LDKOnionMessenger this_obj); +void PaymentPurpose_free(struct LDKPaymentPurpose this_ptr); /** - * Frees any resources used by the Destination + * Creates a copy of the PaymentPurpose */ -void Destination_free(struct LDKDestination this_ptr); +struct LDKPaymentPurpose PaymentPurpose_clone(const struct LDKPaymentPurpose *NONNULL_PTR orig); /** - * Creates a copy of the Destination + * Utility method to constructs a new InvoicePayment-variant PaymentPurpose */ -struct LDKDestination Destination_clone(const struct LDKDestination *NONNULL_PTR orig); +struct LDKPaymentPurpose PaymentPurpose_invoice_payment(struct LDKThirtyTwoBytes payment_preimage, struct LDKThirtyTwoBytes payment_secret); /** - * Utility method to constructs a new Node-variant Destination + * Utility method to constructs a new SpontaneousPayment-variant PaymentPurpose */ -struct LDKDestination Destination_node(struct LDKPublicKey a); +struct LDKPaymentPurpose PaymentPurpose_spontaneous_payment(struct LDKThirtyTwoBytes a); /** - * Utility method to constructs a new BlindedPath-variant Destination + * Checks if two PaymentPurposes contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -struct LDKDestination Destination_blinded_path(struct LDKBlindedPath a); +bool PaymentPurpose_eq(const struct LDKPaymentPurpose *NONNULL_PTR a, const struct LDKPaymentPurpose *NONNULL_PTR b); /** - * Frees any resources used by the SendError + * Serialize the PaymentPurpose object into a byte array which can be read by PaymentPurpose_read */ -void SendError_free(struct LDKSendError this_ptr); +struct LDKCVec_u8Z PaymentPurpose_write(const struct LDKPaymentPurpose *NONNULL_PTR obj); /** - * Creates a copy of the SendError + * Read a PaymentPurpose from a byte array, created by PaymentPurpose_write */ -struct LDKSendError SendError_clone(const struct LDKSendError *NONNULL_PTR orig); +struct LDKCResult_PaymentPurposeDecodeErrorZ PaymentPurpose_read(struct LDKu8slice ser); /** - * Utility method to constructs a new Secp256k1-variant SendError + * Frees any resources used by the PathFailure */ -struct LDKSendError SendError_secp256k1(enum LDKSecp256k1Error a); +void PathFailure_free(struct LDKPathFailure this_ptr); /** - * Utility method to constructs a new TooBigPacket-variant SendError + * Creates a copy of the PathFailure */ -struct LDKSendError SendError_too_big_packet(void); +struct LDKPathFailure PathFailure_clone(const struct LDKPathFailure *NONNULL_PTR orig); /** - * Utility method to constructs a new TooFewBlindedHops-variant SendError + * Utility method to constructs a new InitialSend-variant PathFailure */ -struct LDKSendError SendError_too_few_blinded_hops(void); +struct LDKPathFailure PathFailure_initial_send(struct LDKAPIError err); /** - * Utility method to constructs a new InvalidFirstHop-variant SendError + * Utility method to constructs a new OnPath-variant PathFailure */ -struct LDKSendError SendError_invalid_first_hop(void); +struct LDKPathFailure PathFailure_on_path(struct LDKCOption_NetworkUpdateZ network_update); /** - * Utility method to constructs a new InvalidMessage-variant SendError + * Checks if two PathFailures contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -struct LDKSendError SendError_invalid_message(void); +bool PathFailure_eq(const struct LDKPathFailure *NONNULL_PTR a, const struct LDKPathFailure *NONNULL_PTR b); /** - * Utility method to constructs a new BufferFull-variant SendError + * Serialize the PathFailure object into a byte array which can be read by PathFailure_read */ -struct LDKSendError SendError_buffer_full(void); +struct LDKCVec_u8Z PathFailure_write(const struct LDKPathFailure *NONNULL_PTR obj); /** - * Utility method to constructs a new GetNodeIdFailed-variant SendError + * Read a PathFailure from a byte array, created by PathFailure_write */ -struct LDKSendError SendError_get_node_id_failed(void); +struct LDKCResult_COption_PathFailureZDecodeErrorZ PathFailure_read(struct LDKu8slice ser); /** - * Utility method to constructs a new BlindedPathAdvanceFailed-variant SendError + * Frees any resources used by the ClosureReason */ -struct LDKSendError SendError_blinded_path_advance_failed(void); +void ClosureReason_free(struct LDKClosureReason this_ptr); /** - * Checks if two SendErrors contain equal inner contents. + * Creates a copy of the ClosureReason + */ +struct LDKClosureReason ClosureReason_clone(const struct LDKClosureReason *NONNULL_PTR orig); + +/** + * Utility method to constructs a new CounterpartyForceClosed-variant ClosureReason + */ +struct LDKClosureReason ClosureReason_counterparty_force_closed(struct LDKUntrustedString peer_msg); + +/** + * Utility method to constructs a new HolderForceClosed-variant ClosureReason + */ +struct LDKClosureReason ClosureReason_holder_force_closed(void); + +/** + * Utility method to constructs a new CooperativeClosure-variant ClosureReason + */ +struct LDKClosureReason ClosureReason_cooperative_closure(void); + +/** + * Utility method to constructs a new CommitmentTxConfirmed-variant ClosureReason + */ +struct LDKClosureReason ClosureReason_commitment_tx_confirmed(void); + +/** + * Utility method to constructs a new FundingTimedOut-variant ClosureReason + */ +struct LDKClosureReason ClosureReason_funding_timed_out(void); + +/** + * Utility method to constructs a new ProcessingError-variant ClosureReason + */ +struct LDKClosureReason ClosureReason_processing_error(struct LDKStr err); + +/** + * Utility method to constructs a new DisconnectedPeer-variant ClosureReason + */ +struct LDKClosureReason ClosureReason_disconnected_peer(void); + +/** + * Utility method to constructs a new OutdatedChannelManager-variant ClosureReason + */ +struct LDKClosureReason ClosureReason_outdated_channel_manager(void); + +/** + * Checks if two ClosureReasons contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. */ -bool SendError_eq(const struct LDKSendError *NONNULL_PTR a, const struct LDKSendError *NONNULL_PTR b); +bool ClosureReason_eq(const struct LDKClosureReason *NONNULL_PTR a, const struct LDKClosureReason *NONNULL_PTR b); /** - * Calls the free function if one is set + * Serialize the ClosureReason object into a byte array which can be read by ClosureReason_read */ -void CustomOnionMessageHandler_free(struct LDKCustomOnionMessageHandler this_ptr); +struct LDKCVec_u8Z ClosureReason_write(const struct LDKClosureReason *NONNULL_PTR obj); /** - * Constructs a new `OnionMessenger` to send, forward, and delegate received onion messages to - * their respective handlers. + * Read a ClosureReason from a byte array, created by ClosureReason_write */ -MUST_USE_RES struct LDKOnionMessenger OnionMessenger_new(struct LDKEntropySource entropy_source, struct LDKNodeSigner node_signer, struct LDKLogger logger, struct LDKCustomOnionMessageHandler custom_handler); +struct LDKCResult_COption_ClosureReasonZDecodeErrorZ ClosureReason_read(struct LDKu8slice ser); /** - * Send an onion message with contents `message` to `destination`, routing it through `intermediate_nodes`. - * 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 HTLCDestination */ -MUST_USE_RES struct LDKCResult_NoneSendErrorZ OnionMessenger_send_onion_message(const struct LDKOnionMessenger *NONNULL_PTR this_arg, struct LDKCVec_PublicKeyZ intermediate_nodes, struct LDKDestination destination, struct LDKOnionMessageContents message, struct LDKBlindedPath reply_path); +void HTLCDestination_free(struct LDKHTLCDestination this_ptr); /** - * 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 + * Creates a copy of the HTLCDestination */ -struct LDKOnionMessageHandler OnionMessenger_as_OnionMessageHandler(const struct LDKOnionMessenger *NONNULL_PTR this_arg); +struct LDKHTLCDestination HTLCDestination_clone(const struct LDKHTLCDestination *NONNULL_PTR orig); /** - * Constructs a new OnionMessageProvider which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned OnionMessageProvider must be freed before this_arg is + * Utility method to constructs a new NextHopChannel-variant HTLCDestination */ -struct LDKOnionMessageProvider OnionMessenger_as_OnionMessageProvider(const struct LDKOnionMessenger *NONNULL_PTR this_arg); +struct LDKHTLCDestination HTLCDestination_next_hop_channel(struct LDKPublicKey node_id, struct LDKThirtyTwoBytes channel_id); /** - * Frees any resources used by the OnionMessageContents + * Utility method to constructs a new UnknownNextHop-variant HTLCDestination */ -void OnionMessageContents_free(struct LDKOnionMessageContents this_ptr); +struct LDKHTLCDestination HTLCDestination_unknown_next_hop(uint64_t requested_forward_scid); /** - * Utility method to constructs a new Custom-variant OnionMessageContents + * Utility method to constructs a new InvalidForward-variant HTLCDestination */ -struct LDKOnionMessageContents OnionMessageContents_custom(struct LDKCustomOnionMessageContents a); +struct LDKHTLCDestination HTLCDestination_invalid_forward(uint64_t requested_forward_scid); + +/** + * Utility method to constructs a new FailedPayment-variant HTLCDestination + */ +struct LDKHTLCDestination HTLCDestination_failed_payment(struct LDKThirtyTwoBytes payment_hash); + +/** + * Checks if two HTLCDestinations contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + */ +bool HTLCDestination_eq(const struct LDKHTLCDestination *NONNULL_PTR a, const struct LDKHTLCDestination *NONNULL_PTR b); + +/** + * Serialize the HTLCDestination object into a byte array which can be read by HTLCDestination_read + */ +struct LDKCVec_u8Z HTLCDestination_write(const struct LDKHTLCDestination *NONNULL_PTR obj); + +/** + * Read a HTLCDestination from a byte array, created by HTLCDestination_write + */ +struct LDKCResult_COption_HTLCDestinationZDecodeErrorZ HTLCDestination_read(struct LDKu8slice ser); + +/** + * Creates a copy of the PaymentFailureReason + */ +enum LDKPaymentFailureReason PaymentFailureReason_clone(const enum LDKPaymentFailureReason *NONNULL_PTR orig); + +/** + * Utility method to constructs a new RecipientRejected-variant PaymentFailureReason + */ +enum LDKPaymentFailureReason PaymentFailureReason_recipient_rejected(void); + +/** + * Utility method to constructs a new UserAbandoned-variant PaymentFailureReason + */ +enum LDKPaymentFailureReason PaymentFailureReason_user_abandoned(void); + +/** + * Utility method to constructs a new RetriesExhausted-variant PaymentFailureReason + */ +enum LDKPaymentFailureReason PaymentFailureReason_retries_exhausted(void); + +/** + * Utility method to constructs a new PaymentExpired-variant PaymentFailureReason + */ +enum LDKPaymentFailureReason PaymentFailureReason_payment_expired(void); + +/** + * Utility method to constructs a new RouteNotFound-variant PaymentFailureReason + */ +enum LDKPaymentFailureReason PaymentFailureReason_route_not_found(void); + +/** + * Utility method to constructs a new UnexpectedError-variant PaymentFailureReason + */ +enum LDKPaymentFailureReason PaymentFailureReason_unexpected_error(void); + +/** + * Checks if two PaymentFailureReasons contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + */ +bool PaymentFailureReason_eq(const enum LDKPaymentFailureReason *NONNULL_PTR a, const enum LDKPaymentFailureReason *NONNULL_PTR b); + +/** + * Serialize the PaymentFailureReason object into a byte array which can be read by PaymentFailureReason_read + */ +struct LDKCVec_u8Z PaymentFailureReason_write(const enum LDKPaymentFailureReason *NONNULL_PTR obj); + +/** + * Read a PaymentFailureReason from a byte array, created by PaymentFailureReason_write + */ +struct LDKCResult_PaymentFailureReasonDecodeErrorZ PaymentFailureReason_read(struct LDKu8slice ser); + +/** + * Frees any resources used by the Event + */ +void Event_free(struct LDKEvent this_ptr); + +/** + * Creates a copy of the Event + */ +struct LDKEvent Event_clone(const struct LDKEvent *NONNULL_PTR orig); + +/** + * Utility method to constructs a new FundingGenerationReady-variant Event + */ +struct LDKEvent Event_funding_generation_ready(struct LDKThirtyTwoBytes 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 PaymentClaimable-variant Event + */ +struct LDKEvent Event_payment_claimable(struct LDKPublicKey receiver_node_id, struct LDKThirtyTwoBytes payment_hash, struct LDKRecipientOnionFields onion_fields, uint64_t amount_msat, struct LDKPaymentPurpose purpose, struct LDKThirtyTwoBytes via_channel_id, struct LDKCOption_u128Z via_user_channel_id, struct LDKCOption_u32Z claim_deadline); + +/** + * Utility method to constructs a new PaymentClaimed-variant Event + */ +struct LDKEvent Event_payment_claimed(struct LDKPublicKey receiver_node_id, struct LDKThirtyTwoBytes payment_hash, uint64_t amount_msat, struct LDKPaymentPurpose purpose); + +/** + * Utility method to constructs a new PaymentSent-variant Event + */ +struct LDKEvent Event_payment_sent(struct LDKThirtyTwoBytes payment_id, struct LDKThirtyTwoBytes payment_preimage, struct LDKThirtyTwoBytes payment_hash, struct LDKCOption_u64Z fee_paid_msat); + +/** + * Utility method to constructs a new PaymentFailed-variant Event + */ +struct LDKEvent Event_payment_failed(struct LDKThirtyTwoBytes payment_id, struct LDKThirtyTwoBytes payment_hash, struct LDKCOption_PaymentFailureReasonZ reason); + +/** + * Utility method to constructs a new PaymentPathSuccessful-variant Event + */ +struct LDKEvent Event_payment_path_successful(struct LDKThirtyTwoBytes payment_id, struct LDKThirtyTwoBytes payment_hash, struct LDKPath path); + +/** + * Utility method to constructs a new PaymentPathFailed-variant Event + */ +struct LDKEvent Event_payment_path_failed(struct LDKThirtyTwoBytes payment_id, struct LDKThirtyTwoBytes payment_hash, bool payment_failed_permanently, struct LDKPathFailure failure, struct LDKPath path, struct LDKCOption_u64Z short_channel_id); + +/** + * Utility method to constructs a new ProbeSuccessful-variant Event + */ +struct LDKEvent Event_probe_successful(struct LDKThirtyTwoBytes payment_id, struct LDKThirtyTwoBytes payment_hash, struct LDKPath path); + +/** + * Utility method to constructs a new ProbeFailed-variant Event + */ +struct LDKEvent Event_probe_failed(struct LDKThirtyTwoBytes payment_id, struct LDKThirtyTwoBytes payment_hash, struct LDKPath path, struct LDKCOption_u64Z short_channel_id); + +/** + * Utility method to constructs a new PendingHTLCsForwardable-variant Event + */ +struct LDKEvent Event_pending_htlcs_forwardable(uint64_t time_forwardable); + +/** + * Utility method to constructs a new HTLCIntercepted-variant Event + */ +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); + +/** + * Utility method to constructs a new SpendableOutputs-variant Event + */ +struct LDKEvent Event_spendable_outputs(struct LDKCVec_SpendableOutputDescriptorZ outputs); + +/** + * Utility method to constructs a new PaymentForwarded-variant Event + */ +struct LDKEvent Event_payment_forwarded(struct LDKThirtyTwoBytes prev_channel_id, struct LDKThirtyTwoBytes next_channel_id, struct LDKCOption_u64Z fee_earned_msat, bool claim_from_onchain_tx, struct LDKCOption_u64Z outbound_amount_forwarded_msat); + +/** + * Utility method to constructs a new ChannelPending-variant Event + */ +struct LDKEvent Event_channel_pending(struct LDKThirtyTwoBytes channel_id, struct LDKU128 user_channel_id, struct LDKThirtyTwoBytes former_temporary_channel_id, struct LDKPublicKey counterparty_node_id, struct LDKOutPoint funding_txo); + +/** + * Utility method to constructs a new ChannelReady-variant Event + */ +struct LDKEvent Event_channel_ready(struct LDKThirtyTwoBytes channel_id, struct LDKU128 user_channel_id, struct LDKPublicKey counterparty_node_id, struct LDKChannelTypeFeatures channel_type); + +/** + * Utility method to constructs a new ChannelClosed-variant Event + */ +struct LDKEvent Event_channel_closed(struct LDKThirtyTwoBytes channel_id, struct LDKU128 user_channel_id, struct LDKClosureReason reason); + +/** + * Utility method to constructs a new DiscardFunding-variant Event + */ +struct LDKEvent Event_discard_funding(struct LDKThirtyTwoBytes channel_id, struct LDKTransaction transaction); + +/** + * Utility method to constructs a new OpenChannelRequest-variant Event + */ +struct LDKEvent Event_open_channel_request(struct LDKThirtyTwoBytes temporary_channel_id, struct LDKPublicKey counterparty_node_id, uint64_t funding_satoshis, uint64_t push_msat, struct LDKChannelTypeFeatures channel_type); + +/** + * Utility method to constructs a new HTLCHandlingFailed-variant Event + */ +struct LDKEvent Event_htlchandling_failed(struct LDKThirtyTwoBytes prev_channel_id, struct LDKHTLCDestination failed_next_destination); + +/** + * Checks if two Events contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + */ +bool Event_eq(const struct LDKEvent *NONNULL_PTR a, const struct LDKEvent *NONNULL_PTR b); + +/** + * Serialize the Event object into a byte array which can be read by Event_read + */ +struct LDKCVec_u8Z Event_write(const struct LDKEvent *NONNULL_PTR obj); + +/** + * Read a Event from a byte array, created by Event_write + */ +struct LDKCResult_COption_EventZDecodeErrorZ Event_read(struct LDKu8slice ser); + +/** + * Frees any resources used by the MessageSendEvent + */ +void MessageSendEvent_free(struct LDKMessageSendEvent this_ptr); + +/** + * Creates a copy of the MessageSendEvent + */ +struct LDKMessageSendEvent MessageSendEvent_clone(const struct LDKMessageSendEvent *NONNULL_PTR orig); + +/** + * Utility method to constructs a new SendAcceptChannel-variant MessageSendEvent + */ +struct LDKMessageSendEvent MessageSendEvent_send_accept_channel(struct LDKPublicKey node_id, struct LDKAcceptChannel msg); + +/** + * Utility method to constructs a new SendOpenChannel-variant MessageSendEvent + */ +struct LDKMessageSendEvent MessageSendEvent_send_open_channel(struct LDKPublicKey node_id, struct LDKOpenChannel msg); + +/** + * Utility method to constructs a new SendFundingCreated-variant MessageSendEvent + */ +struct LDKMessageSendEvent MessageSendEvent_send_funding_created(struct LDKPublicKey node_id, struct LDKFundingCreated msg); + +/** + * Utility method to constructs a new SendFundingSigned-variant MessageSendEvent + */ +struct LDKMessageSendEvent MessageSendEvent_send_funding_signed(struct LDKPublicKey node_id, struct LDKFundingSigned msg); + +/** + * Utility method to constructs a new SendChannelReady-variant MessageSendEvent + */ +struct LDKMessageSendEvent MessageSendEvent_send_channel_ready(struct LDKPublicKey node_id, struct LDKChannelReady msg); + +/** + * Utility method to constructs a new SendAnnouncementSignatures-variant MessageSendEvent + */ +struct LDKMessageSendEvent MessageSendEvent_send_announcement_signatures(struct LDKPublicKey node_id, struct LDKAnnouncementSignatures msg); + +/** + * Utility method to constructs a new UpdateHTLCs-variant MessageSendEvent + */ +struct LDKMessageSendEvent MessageSendEvent_update_htlcs(struct LDKPublicKey node_id, struct LDKCommitmentUpdate updates); + +/** + * Utility method to constructs a new SendRevokeAndACK-variant MessageSendEvent + */ +struct LDKMessageSendEvent MessageSendEvent_send_revoke_and_ack(struct LDKPublicKey node_id, struct LDKRevokeAndACK msg); + +/** + * Utility method to constructs a new SendClosingSigned-variant MessageSendEvent + */ +struct LDKMessageSendEvent MessageSendEvent_send_closing_signed(struct LDKPublicKey node_id, struct LDKClosingSigned msg); + +/** + * Utility method to constructs a new SendShutdown-variant MessageSendEvent + */ +struct LDKMessageSendEvent MessageSendEvent_send_shutdown(struct LDKPublicKey node_id, struct LDKShutdown msg); + +/** + * Utility method to constructs a new SendChannelReestablish-variant MessageSendEvent + */ +struct LDKMessageSendEvent MessageSendEvent_send_channel_reestablish(struct LDKPublicKey node_id, struct LDKChannelReestablish msg); + +/** + * Utility method to constructs a new SendChannelAnnouncement-variant MessageSendEvent + */ +struct LDKMessageSendEvent MessageSendEvent_send_channel_announcement(struct LDKPublicKey node_id, struct LDKChannelAnnouncement msg, struct LDKChannelUpdate update_msg); + +/** + * Utility method to constructs a new BroadcastChannelAnnouncement-variant MessageSendEvent + */ +struct LDKMessageSendEvent MessageSendEvent_broadcast_channel_announcement(struct LDKChannelAnnouncement msg, struct LDKChannelUpdate update_msg); + +/** + * Utility method to constructs a new BroadcastChannelUpdate-variant MessageSendEvent + */ +struct LDKMessageSendEvent MessageSendEvent_broadcast_channel_update(struct LDKChannelUpdate msg); + +/** + * Utility method to constructs a new BroadcastNodeAnnouncement-variant MessageSendEvent + */ +struct LDKMessageSendEvent MessageSendEvent_broadcast_node_announcement(struct LDKNodeAnnouncement msg); + +/** + * Utility method to constructs a new SendChannelUpdate-variant MessageSendEvent + */ +struct LDKMessageSendEvent MessageSendEvent_send_channel_update(struct LDKPublicKey node_id, struct LDKChannelUpdate msg); + +/** + * Utility method to constructs a new HandleError-variant MessageSendEvent + */ +struct LDKMessageSendEvent MessageSendEvent_handle_error(struct LDKPublicKey node_id, struct LDKErrorAction action); + +/** + * Utility method to constructs a new SendChannelRangeQuery-variant MessageSendEvent + */ +struct LDKMessageSendEvent MessageSendEvent_send_channel_range_query(struct LDKPublicKey node_id, struct LDKQueryChannelRange msg); + +/** + * Utility method to constructs a new SendShortIdsQuery-variant MessageSendEvent + */ +struct LDKMessageSendEvent MessageSendEvent_send_short_ids_query(struct LDKPublicKey node_id, struct LDKQueryShortChannelIds msg); + +/** + * Utility method to constructs a new SendReplyChannelRange-variant MessageSendEvent + */ +struct LDKMessageSendEvent MessageSendEvent_send_reply_channel_range(struct LDKPublicKey node_id, struct LDKReplyChannelRange msg); + +/** + * Utility method to constructs a new SendGossipTimestampFilter-variant MessageSendEvent + */ +struct LDKMessageSendEvent MessageSendEvent_send_gossip_timestamp_filter(struct LDKPublicKey node_id, struct LDKGossipTimestampFilter msg); /** * Calls the free function if one is set */ -void CustomOnionMessageContents_free(struct LDKCustomOnionMessageContents this_ptr); +void MessageSendEventsProvider_free(struct LDKMessageSendEventsProvider this_ptr); + +/** + * Calls the free function if one is set + */ +void OnionMessageProvider_free(struct LDKOnionMessageProvider this_ptr); + +/** + * Calls the free function if one is set + */ +void EventsProvider_free(struct LDKEventsProvider this_ptr); + +/** + * Calls the free function if one is set + */ +void EventHandler_free(struct LDKEventHandler this_ptr); /** * Frees any resources used by the FilesystemPersister, if is_owned is set and inner is non-NULL. @@ -32980,7 +35022,7 @@ bool Invoice_eq(const struct LDKInvoice *NONNULL_PTR a, const struct LDKInvoice struct LDKInvoice Invoice_clone(const struct LDKInvoice *NONNULL_PTR orig); /** - * Checks if two Invoices contain equal inner contents. + * Generates a non-cryptographic 64-bit hash of the Invoice. */ uint64_t Invoice_hash(const struct LDKInvoice *NONNULL_PTR o); @@ -33002,7 +35044,7 @@ bool SignedRawInvoice_eq(const struct LDKSignedRawInvoice *NONNULL_PTR a, const struct LDKSignedRawInvoice SignedRawInvoice_clone(const struct LDKSignedRawInvoice *NONNULL_PTR orig); /** - * Checks if two SignedRawInvoices contain equal inner contents. + * Generates a non-cryptographic 64-bit hash of the SignedRawInvoice. */ uint64_t SignedRawInvoice_hash(const struct LDKSignedRawInvoice *NONNULL_PTR o); @@ -33034,7 +35076,7 @@ bool RawInvoice_eq(const struct LDKRawInvoice *NONNULL_PTR a, const struct LDKRa struct LDKRawInvoice RawInvoice_clone(const struct LDKRawInvoice *NONNULL_PTR orig); /** - * Checks if two RawInvoices contain equal inner contents. + * Generates a non-cryptographic 64-bit hash of the RawInvoice. */ uint64_t RawInvoice_hash(const struct LDKRawInvoice *NONNULL_PTR o); @@ -33066,7 +35108,7 @@ bool RawDataPart_eq(const struct LDKRawDataPart *NONNULL_PTR a, const struct LDK struct LDKRawDataPart RawDataPart_clone(const struct LDKRawDataPart *NONNULL_PTR orig); /** - * Checks if two RawDataParts contain equal inner contents. + * Generates a non-cryptographic 64-bit hash of the RawDataPart. */ uint64_t RawDataPart_hash(const struct LDKRawDataPart *NONNULL_PTR o); @@ -33088,7 +35130,7 @@ bool PositiveTimestamp_eq(const struct LDKPositiveTimestamp *NONNULL_PTR a, cons struct LDKPositiveTimestamp PositiveTimestamp_clone(const struct LDKPositiveTimestamp *NONNULL_PTR orig); /** - * Checks if two PositiveTimestamps contain equal inner contents. + * Generates a non-cryptographic 64-bit hash of the PositiveTimestamp. */ uint64_t PositiveTimestamp_hash(const struct LDKPositiveTimestamp *NONNULL_PTR o); @@ -33124,7 +35166,7 @@ enum LDKSiPrefix SiPrefix_pico(void); bool SiPrefix_eq(const enum LDKSiPrefix *NONNULL_PTR a, const enum LDKSiPrefix *NONNULL_PTR b); /** - * Checks if two SiPrefixs contain equal inner contents. + * Generates a non-cryptographic 64-bit hash of the SiPrefix. */ uint64_t SiPrefix_hash(const enum LDKSiPrefix *NONNULL_PTR o); @@ -33165,7 +35207,7 @@ enum LDKCurrency Currency_simnet(void); enum LDKCurrency Currency_signet(void); /** - * Checks if two Currencys contain equal inner contents. + * Generates a non-cryptographic 64-bit hash of the Currency. */ uint64_t Currency_hash(const enum LDKCurrency *NONNULL_PTR o); @@ -33186,7 +35228,7 @@ void Sha256_free(struct LDKSha256 this_obj); struct LDKSha256 Sha256_clone(const struct LDKSha256 *NONNULL_PTR orig); /** - * Checks if two Sha256s contain equal inner contents. + * Generates a non-cryptographic 64-bit hash of the Sha256. */ uint64_t Sha256_hash(const struct LDKSha256 *NONNULL_PTR o); @@ -33197,6 +35239,12 @@ uint64_t Sha256_hash(const struct LDKSha256 *NONNULL_PTR o); */ bool Sha256_eq(const struct LDKSha256 *NONNULL_PTR a, const struct LDKSha256 *NONNULL_PTR b); +/** + * Constructs a new [`Sha256`] from the given bytes, which are assumed to be the output of a + * single sha256 hash. + */ +MUST_USE_RES struct LDKSha256 Sha256_from_bytes(const uint8_t (*bytes)[32]); + /** * Frees any resources used by the Description, if is_owned is set and inner is non-NULL. */ @@ -33208,7 +35256,7 @@ void Description_free(struct LDKDescription this_obj); struct LDKDescription Description_clone(const struct LDKDescription *NONNULL_PTR orig); /** - * Checks if two Descriptions contain equal inner contents. + * Generates a non-cryptographic 64-bit hash of the Description. */ uint64_t Description_hash(const struct LDKDescription *NONNULL_PTR o); @@ -33239,7 +35287,7 @@ MUST_USE_RES struct LDKPayeePubKey PayeePubKey_new(struct LDKPublicKey a_arg); struct LDKPayeePubKey PayeePubKey_clone(const struct LDKPayeePubKey *NONNULL_PTR orig); /** - * Checks if two PayeePubKeys contain equal inner contents. + * Generates a non-cryptographic 64-bit hash of the PayeePubKey. */ uint64_t PayeePubKey_hash(const struct LDKPayeePubKey *NONNULL_PTR o); @@ -33261,7 +35309,7 @@ void ExpiryTime_free(struct LDKExpiryTime this_obj); struct LDKExpiryTime ExpiryTime_clone(const struct LDKExpiryTime *NONNULL_PTR orig); /** - * Checks if two ExpiryTimes contain equal inner contents. + * Generates a non-cryptographic 64-bit hash of the ExpiryTime. */ uint64_t ExpiryTime_hash(const struct LDKExpiryTime *NONNULL_PTR o); @@ -33292,7 +35340,7 @@ MUST_USE_RES struct LDKMinFinalCltvExpiryDelta MinFinalCltvExpiryDelta_new(uint6 struct LDKMinFinalCltvExpiryDelta MinFinalCltvExpiryDelta_clone(const struct LDKMinFinalCltvExpiryDelta *NONNULL_PTR orig); /** - * Checks if two MinFinalCltvExpiryDeltas contain equal inner contents. + * Generates a non-cryptographic 64-bit hash of the MinFinalCltvExpiryDelta. */ uint64_t MinFinalCltvExpiryDelta_hash(const struct LDKMinFinalCltvExpiryDelta *NONNULL_PTR o); @@ -33316,7 +35364,7 @@ struct LDKFallback Fallback_clone(const struct LDKFallback *NONNULL_PTR orig); /** * Utility method to constructs a new SegWitProgram-variant Fallback */ -struct LDKFallback Fallback_seg_wit_program(struct LDKU5 version, struct LDKCVec_u8Z program); +struct LDKFallback Fallback_seg_wit_program(struct LDKWitnessVersion version, struct LDKCVec_u8Z program); /** * Utility method to constructs a new PubKeyHash-variant Fallback @@ -33329,7 +35377,7 @@ struct LDKFallback Fallback_pub_key_hash(struct LDKTwentyBytes a); struct LDKFallback Fallback_script_hash(struct LDKTwentyBytes a); /** - * Checks if two Fallbacks contain equal inner contents. + * Generates a non-cryptographic 64-bit hash of the Fallback. */ uint64_t Fallback_hash(const struct LDKFallback *NONNULL_PTR o); @@ -33350,7 +35398,7 @@ void InvoiceSignature_free(struct LDKInvoiceSignature this_obj); struct LDKInvoiceSignature InvoiceSignature_clone(const struct LDKInvoiceSignature *NONNULL_PTR orig); /** - * Checks if two InvoiceSignatures contain equal inner contents. + * Generates a non-cryptographic 64-bit hash of the InvoiceSignature. */ uint64_t InvoiceSignature_hash(const struct LDKInvoiceSignature *NONNULL_PTR o); @@ -33372,7 +35420,7 @@ void PrivateRoute_free(struct LDKPrivateRoute this_obj); struct LDKPrivateRoute PrivateRoute_clone(const struct LDKPrivateRoute *NONNULL_PTR orig); /** - * Checks if two PrivateRoutes contain equal inner contents. + * Generates a non-cryptographic 64-bit hash of the PrivateRoute. */ uint64_t PrivateRoute_hash(const struct LDKPrivateRoute *NONNULL_PTR o); @@ -33392,17 +35440,17 @@ bool PrivateRoute_eq(const struct LDKPrivateRoute *NONNULL_PTR a, const struct L MUST_USE_RES struct LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ SignedRawInvoice_into_parts(struct LDKSignedRawInvoice this_arg); /** - * The `RawInvoice` which was signed. + * The [`RawInvoice`] which was signed. */ MUST_USE_RES struct LDKRawInvoice SignedRawInvoice_raw_invoice(const struct LDKSignedRawInvoice *NONNULL_PTR this_arg); /** - * The hash of the `RawInvoice` that was signed. + * The hash of the [`RawInvoice`] that was signed. */ MUST_USE_RES const uint8_t (*SignedRawInvoice_signable_hash(const struct LDKSignedRawInvoice *NONNULL_PTR this_arg))[32]; /** - * InvoiceSignature for the invoice. + * Signature for the invoice. */ MUST_USE_RES struct LDKInvoiceSignature SignedRawInvoice_signature(const struct LDKSignedRawInvoice *NONNULL_PTR this_arg); @@ -33464,6 +35512,8 @@ MUST_USE_RES struct LDKMinFinalCltvExpiryDelta RawInvoice_min_final_cltv_expiry_ */ MUST_USE_RES struct LDKThirtyTwoBytes RawInvoice_payment_secret(const struct LDKRawInvoice *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCOption_CVec_u8ZZ RawInvoice_payment_metadata(const struct LDKRawInvoice *NONNULL_PTR this_arg); + /** * * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None @@ -33518,6 +35568,11 @@ MUST_USE_RES uint64_t PositiveTimestamp_as_duration_since_epoch(const struct LDK */ MUST_USE_RES uint64_t PositiveTimestamp_as_time(const struct LDKPositiveTimestamp *NONNULL_PTR this_arg); +/** + * The hash of the [`RawInvoice`] that was signed. + */ +MUST_USE_RES struct LDKThirtyTwoBytes Invoice_signable_hash(const struct LDKInvoice *NONNULL_PTR this_arg); + /** * Transform the `Invoice` into it's unchecked version */ @@ -33529,7 +35584,7 @@ MUST_USE_RES struct LDKSignedRawInvoice Invoice_into_signed_raw(struct LDKInvoic MUST_USE_RES struct LDKCResult_NoneSemanticErrorZ Invoice_check_signature(const struct LDKInvoice *NONNULL_PTR this_arg); /** - * Constructs an `Invoice` from a `SignedRawInvoice` by checking all its invariants. + * Constructs an `Invoice` from a [`SignedRawInvoice`] by checking all its invariants. * ``` * use lightning_invoice::*; * @@ -33579,6 +35634,11 @@ MUST_USE_RES struct LDKPublicKey Invoice_payee_pub_key(const struct LDKInvoice * */ MUST_USE_RES const uint8_t (*Invoice_payment_secret(const struct LDKInvoice *NONNULL_PTR this_arg))[32]; +/** + * Get the payment metadata blob if one was included in the invoice + */ +MUST_USE_RES struct LDKCOption_CVec_u8ZZ Invoice_payment_metadata(const struct LDKInvoice *NONNULL_PTR this_arg); + /** * Get the invoice features if they were included in the invoice * @@ -33591,6 +35651,12 @@ MUST_USE_RES struct LDKInvoiceFeatures Invoice_features(const struct LDKInvoice */ MUST_USE_RES struct LDKPublicKey Invoice_recover_payee_pub_key(const struct LDKInvoice *NONNULL_PTR this_arg); +/** + * Returns the Duration since the Unix epoch at which the invoice expires. + * Returning None if overflow occurred. + */ +MUST_USE_RES struct LDKCOption_DurationZ Invoice_expires_at(const struct LDKInvoice *NONNULL_PTR this_arg); + /** * Returns the invoice's expiry time, if present, otherwise [`DEFAULT_EXPIRY_TIME`]. */ @@ -33601,6 +35667,17 @@ MUST_USE_RES uint64_t Invoice_expiry_time(const struct LDKInvoice *NONNULL_PTR t */ MUST_USE_RES bool Invoice_is_expired(const struct LDKInvoice *NONNULL_PTR this_arg); +/** + * Returns the Duration remaining until the invoice expires. + */ +MUST_USE_RES uint64_t Invoice_duration_until_expiry(const struct LDKInvoice *NONNULL_PTR this_arg); + +/** + * Returns the Duration remaining until the invoice expires given the current time. + * `time` is the timestamp as a duration since the Unix epoch. + */ +MUST_USE_RES uint64_t Invoice_expiration_remaining_from_epoch(const struct LDKInvoice *NONNULL_PTR this_arg, uint64_t time); + /** * Returns whether the expiry time would pass at the given point in time. * `at_time` is the timestamp as a duration since the Unix epoch. @@ -33613,6 +35690,11 @@ MUST_USE_RES bool Invoice_would_expire(const struct LDKInvoice *NONNULL_PTR this */ MUST_USE_RES uint64_t Invoice_min_final_cltv_expiry_delta(const struct LDKInvoice *NONNULL_PTR this_arg); +/** + * Returns a list of all fallback addresses as [`Address`]es + */ +MUST_USE_RES struct LDKCVec_AddressZ Invoice_fallback_addresses(const struct LDKInvoice *NONNULL_PTR this_arg); + /** * Returns a list of all routes included in the invoice */ @@ -33635,14 +35717,14 @@ MUST_USE_RES struct LDKCOption_u64Z Invoice_amount_milli_satoshis(const struct L /** * Creates a new `Description` if `description` is at most 1023 __bytes__ long, - * returns `CreationError::DescriptionTooLong` otherwise + * returns [`CreationError::DescriptionTooLong`] otherwise * * Please note that single characters may use more than one byte due to UTF8 encoding. */ MUST_USE_RES struct LDKCResult_DescriptionCreationErrorZ Description_new(struct LDKStr description); /** - * Returns the underlying description `String` + * Returns the underlying description [`String`] */ MUST_USE_RES struct LDKStr Description_into_inner(struct LDKDescription this_arg); @@ -33652,7 +35734,7 @@ MUST_USE_RES struct LDKStr Description_into_inner(struct LDKDescription this_arg MUST_USE_RES struct LDKExpiryTime ExpiryTime_from_seconds(uint64_t seconds); /** - * Construct an `ExpiryTime` from a `Duration`, dropping the sub-second part. + * Construct an `ExpiryTime` from a [`Duration`], dropping the sub-second part. */ MUST_USE_RES struct LDKExpiryTime ExpiryTime_from_duration(uint64_t duration); @@ -33662,7 +35744,7 @@ MUST_USE_RES struct LDKExpiryTime ExpiryTime_from_duration(uint64_t duration); MUST_USE_RES uint64_t ExpiryTime_as_seconds(const struct LDKExpiryTime *NONNULL_PTR this_arg); /** - * Returns a reference to the underlying `Duration` (=expiry time) + * Returns a reference to the underlying [`Duration`] (=expiry time) */ MUST_USE_RES uint64_t ExpiryTime_as_duration(const struct LDKExpiryTime *NONNULL_PTR this_arg); @@ -34095,14 +36177,6 @@ void RapidGossipSync_free(struct LDKRapidGossipSync this_obj); */ MUST_USE_RES struct LDKRapidGossipSync RapidGossipSync_new(const struct LDKNetworkGraph *NONNULL_PTR network_graph, struct LDKLogger logger); -/** - * Update network graph from binary data. - * Returns the last sync timestamp to be used the next time rapid sync data is queried. - * - * `update_data`: `&[u8]` binary stream that comprises the update data - */ -MUST_USE_RES struct LDKCResult_u32GraphSyncErrorZ RapidGossipSync_update_network_graph(const struct LDKRapidGossipSync *NONNULL_PTR this_arg, struct LDKu8slice update_data); - /** * Update network graph from binary data. * Returns the last sync timestamp to be used the next time rapid sync data is queried. diff --git a/lightning-c-bindings/include/lightningpp.hpp b/lightning-c-bindings/include/lightningpp.hpp index c9e30a3..c4ef0ea 100644 --- a/lightning-c-bindings/include/lightningpp.hpp +++ b/lightning-c-bindings/include/lightningpp.hpp @@ -2,9 +2,11 @@ namespace LDK { // Forward declarations class Str; +class Refund; class Retry; class RetryableSendFailure; class PaymentSendFailure; +class RecipientOnionFields; class HTLCClaim; class CounterpartyCommitmentSecrets; class TxCreationKeys; @@ -21,8 +23,8 @@ class CommitmentTransaction; class TrustedCommitmentTransaction; class ShutdownScript; class InvalidShutdownScript; -class BlindedPath; -class BlindedHop; +class UnsignedInvoice; +class BlindedPayInfo; class BackgroundProcessor; class GossipSync; class DefaultRouter; @@ -30,24 +32,17 @@ class Router; class ScorerAccountingForInFlightHtlcs; class InFlightHtlcs; class RouteHop; +class BlindedTail; +class Path; class Route; class RouteParameters; class PaymentParameters; +class Hints; class RouteHint; class RouteHintHop; class BroadcasterInterface; class ConfirmationTarget; class FeeEstimator; -class PaymentPurpose; -class PathFailure; -class ClosureReason; -class HTLCDestination; -class Event; -class MessageSendEvent; -class MessageSendEventsProvider; -class OnionMessageProvider; -class EventsProvider; -class EventHandler; class BestBlock; class Listen; class Confirm; @@ -64,6 +59,8 @@ class ChannelUsage; class FixedPenaltyScorer; class ProbabilisticScorer; class ProbabilisticScoringParameters; +class OnionMessageContents; +class CustomOnionMessageContents; class InitFeatures; class NodeFeatures; class ChannelFeatures; @@ -73,8 +70,20 @@ class InvoiceRequestFeatures; class Bolt12InvoiceFeatures; class BlindedHopFeatures; class ChannelTypeFeatures; -class OnionMessageContents; -class CustomOnionMessageContents; +class PaymentPurpose; +class PathFailure; +class ClosureReason; +class HTLCDestination; +class PaymentFailureReason; +class Event; +class MessageSendEvent; +class MessageSendEventsProvider; +class OnionMessageProvider; +class EventsProvider; +class EventHandler; +class Offer; +class Amount; +class Quantity; class NodeId; class NetworkGraph; class ReadOnlyNetworkGraph; @@ -118,6 +127,7 @@ class UserConfig; class APIError; class BigSize; class Hostname; +class UntrustedString; class PrintableString; class OutPoint; class CustomMessageReader; @@ -144,6 +154,8 @@ class OnionMessenger; class Destination; class SendError; class CustomOnionMessageHandler; +class BlindedPath; +class BlindedHop; class ParseError; class ParseOrSemanticError; class Invoice; @@ -164,7 +176,6 @@ class PrivateRoute; class CreationError; class SemanticError; class SignOrCreationError; -class RapidGossipSync; class Persister; class DecodeError; class Init; @@ -210,17 +221,22 @@ class CommitmentUpdate; class ChannelMessageHandler; class RoutingMessageHandler; class OnionMessageHandler; -class GraphSyncError; +class UnsignedInvoiceRequest; +class InvoiceRequest; class Level; class Record; class Logger; class FutureCallback; class Future; +class Sleeper; class MonitorUpdateId; class Persist; class LockedChannelMonitor; class ChainMonitor; +class GraphSyncError; +class RapidGossipSync; class CResult_LockedChannelMonitorNoneZ; +class CVec_C2Tuple_BlindedPayInfoBlindedPathZZ; class CResult_PhantomRouteHintsDecodeErrorZ; class CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ; class CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ; @@ -245,6 +261,7 @@ class CVec_C2Tuple_TxidBlockHashZZ; class CResult_CommitmentTransactionDecodeErrorZ; class CResult_TransactionNoneZ; class CResult_ClosingSignedFeeRangeDecodeErrorZ; +class COption_DurationZ; class CResult_ErrorMessageDecodeErrorZ; class CResult_OpenChannelDecodeErrorZ; class COption_APIErrorZ; @@ -277,6 +294,7 @@ class CResult_CounterpartyCommitmentSecretsDecodeErrorZ; class CVec_RecentPaymentDetailsZ; class CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ; class CVec_RouteHintHopZ; +class CResult_UntrustedStringDecodeErrorZ; class CResult_PaymentParametersDecodeErrorZ; class CVec_U5Z; class COption_UtxoLookupZ; @@ -297,17 +315,19 @@ class CResult_SiPrefixParseErrorZ; class CResult_BlindedHopDecodeErrorZ; class CResult_TrustedCommitmentTransactionNoneZ; class CResult_FixedPenaltyScorerDecodeErrorZ; +class CVec_BlindedPathZ; class CResult_NoneLightningErrorZ; class CResult_PaymentHashRetryableSendFailureZ; -class C2Tuple_PublicKeyCOption_NetAddressZZ; class CResult_COption_EventZDecodeErrorZ; class CResult_CVec_SignatureZNoneZ; class COption_CVec_NetAddressZZ; -class CResult_NonePeerHandleErrorZ; +class CResult_PaymentFailureReasonDecodeErrorZ; +class C2Tuple_PublicKeyCOption_NetAddressZZ; class CResult__u832APIErrorZ; class CResult_PaymentIdPaymentErrorZ; class CResult_COption_MonitorEventZDecodeErrorZ; class CResult_RoutingFeesDecodeErrorZ; +class CResult_NonePeerHandleErrorZ; class CResult_PayeePubKeyErrorZ; class CResult_DescriptionCreationErrorZ; class CResult_QueryShortChannelIdsDecodeErrorZ; @@ -325,6 +345,7 @@ class CResult_UnsignedChannelUpdateDecodeErrorZ; class CVec_EventZ; class CResult_NoneSemanticErrorZ; class CVec_C2Tuple_u32ScriptZZ; +class CVec_BlindedHopZ; class CResult_COption_ClosureReasonZDecodeErrorZ; class CResult_PaymentHashPaymentSendFailureZ; class C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ; @@ -354,15 +375,16 @@ class COption_WriteableScoreZ; class CResult_PositiveTimestampCreationErrorZ; class C2Tuple__u168_u168Z; class CResult_InvoiceFeaturesDecodeErrorZ; +class C2Tuple_BlindedPayInfoBlindedPathZ; class CResult_ChannelMonitorUpdateDecodeErrorZ; class CResult_ReplyChannelRangeDecodeErrorZ; -class CResult_InvoiceSignOrCreationErrorZ; class CResult_TrustedClosingTransactionNoneZ; class CResult_NetAddressDecodeErrorZ; class C2Tuple_PublicKeyTypeZ; class CResult_ChannelReestablishDecodeErrorZ; class CResult_OnionMessageDecodeErrorZ; class CResult_UnsignedNodeAnnouncementDecodeErrorZ; +class CResult_InvoiceSignOrCreationErrorZ; class CResult_InitFeaturesDecodeErrorZ; class CResult_PublicKeyNoneZ; class CResult_PingDecodeErrorZ; @@ -373,23 +395,25 @@ class CVec_CVec_u8ZZ; class CResult_COption_CustomOnionMessageContentsZDecodeErrorZ; class CResult_ShutdownScriptDecodeErrorZ; class CResult_ProbabilisticScorerDecodeErrorZ; -class CResult_TxCreationKeysDecodeErrorZ; class C2Tuple_usizeTransactionZ; +class CResult_TxCreationKeysDecodeErrorZ; class CResult_NodeAnnouncementDecodeErrorZ; -class CResult_BlindedPathDecodeErrorZ; class CVec_ChannelMonitorZ; +class CResult_BlindedPathDecodeErrorZ; +class CVec_FutureZ; class CResult_RouteHopDecodeErrorZ; class CVec_BalanceZ; class CResult_FundingSignedDecodeErrorZ; class CResult_RecoverableSignatureNoneZ; class C2Tuple_Z; class C3Tuple_RawInvoice_u832InvoiceSignatureZ; +class CVec_PathZ; class CResult_NetworkGraphDecodeErrorZ; class CResult_NodeInfoDecodeErrorZ; class CVec_NodeIdZ; -class CResult_RouteLightningErrorZ; -class CResult_ChannelPublicKeysDecodeErrorZ; class CVec_u8Z; +class CResult_ChannelPublicKeysDecodeErrorZ; +class CResult_RouteLightningErrorZ; class CResult_NonePaymentSendFailureZ; class CResult_HolderCommitmentTransactionDecodeErrorZ; class CResult_WarningMessageDecodeErrorZ; @@ -406,6 +430,7 @@ class COption_NetAddressZ; class C2Tuple_OutPointScriptZ; class CResult_RouteHintHopDecodeErrorZ; class CResult_UpdateFailMalformedHTLCDecodeErrorZ; +class CResult_BlindedPayInfoDecodeErrorZ; class CResult_SharedSecretNoneZ; class CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ; class CResult_CVec_CVec_u8ZZNoneZ; @@ -419,8 +444,10 @@ class CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ; class COption_EventZ; class CResult_ChannelTypeFeaturesDecodeErrorZ; class CVec_RouteHintZ; +class COption_PaymentFailureReasonZ; class COption_u16Z; -class CVec_CVec_RouteHopZZ; +class CVec_ChainHashZ; +class CResult_BlindedTailDecodeErrorZ; class CVec_C2Tuple_PublicKeyTypeZZ; class C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ; class CResult_u32GraphSyncErrorZ; @@ -429,9 +456,10 @@ class CResult_NoneAPIErrorZ; class CResult_CounterpartyChannelTransactionParametersDecodeErrorZ; class CVec_NetAddressZ; class CResult_ChannelDetailsDecodeErrorZ; -class CVec_PublicKeyZ; class CVec_C2Tuple_usizeTransactionZZ; +class CVec_PublicKeyZ; class C2Tuple_u64u64Z; +class CResult_RecipientOnionFieldsDecodeErrorZ; class C2Tuple_u32TxOutZ; class CResult_PaymentSecretNoneZ; class CResult_ChannelConfigDecodeErrorZ; @@ -448,6 +476,7 @@ class COption_ClosureReasonZ; class COption_u128Z; class CVec_APIErrorZ; class CResult_boolPeerHandleErrorZ; +class CVec_AddressZ; class CResult_ChannelUpdateDecodeErrorZ; class CResult_PaymentSecretAPIErrorZ; class CResult_CounterpartyForwardingInfoDecodeErrorZ; @@ -456,6 +485,7 @@ class CResult_SignedRawInvoiceParseErrorZ; class COption_C2Tuple_EightU16sEightU16sZZ; class CResult_RouteDecodeErrorZ; class COption_NoneZ; +class COption_CVec_u8ZZ; class Str { private: @@ -472,6 +502,21 @@ public: const LDKStr* operator &() const { return &self; } const LDKStr* operator ->() const { return &self; } }; +class Refund { +private: + LDKRefund self; +public: + Refund(const Refund&) = delete; + Refund(Refund&& o) : self(o.self) { memset(&o, 0, sizeof(Refund)); } + Refund(LDKRefund&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKRefund)); } + operator LDKRefund() && { LDKRefund res = self; memset(&self, 0, sizeof(LDKRefund)); return res; } + ~Refund() { Refund_free(self); } + Refund& operator=(Refund&& o) { Refund_free(self); self = o.self; memset(&o, 0, sizeof(Refund)); return *this; } + LDKRefund* operator &() { return &self; } + LDKRefund* operator ->() { return &self; } + const LDKRefund* operator &() const { return &self; } + const LDKRefund* operator ->() const { return &self; } +}; class Retry { private: LDKRetry self; @@ -516,6 +561,21 @@ public: const LDKPaymentSendFailure* operator &() const { return &self; } const LDKPaymentSendFailure* operator ->() const { return &self; } }; +class RecipientOnionFields { +private: + LDKRecipientOnionFields self; +public: + RecipientOnionFields(const RecipientOnionFields&) = delete; + RecipientOnionFields(RecipientOnionFields&& o) : self(o.self) { memset(&o, 0, sizeof(RecipientOnionFields)); } + RecipientOnionFields(LDKRecipientOnionFields&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKRecipientOnionFields)); } + operator LDKRecipientOnionFields() && { LDKRecipientOnionFields res = self; memset(&self, 0, sizeof(LDKRecipientOnionFields)); return res; } + ~RecipientOnionFields() { RecipientOnionFields_free(self); } + RecipientOnionFields& operator=(RecipientOnionFields&& o) { RecipientOnionFields_free(self); self = o.self; memset(&o, 0, sizeof(RecipientOnionFields)); return *this; } + LDKRecipientOnionFields* operator &() { return &self; } + LDKRecipientOnionFields* operator ->() { return &self; } + const LDKRecipientOnionFields* operator &() const { return &self; } + const LDKRecipientOnionFields* operator ->() const { return &self; } +}; class HTLCClaim { private: LDKHTLCClaim self; @@ -755,35 +815,35 @@ public: const LDKInvalidShutdownScript* operator &() const { return &self; } const LDKInvalidShutdownScript* operator ->() const { return &self; } }; -class BlindedPath { +class UnsignedInvoice { private: - LDKBlindedPath self; + LDKUnsignedInvoice 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; } + UnsignedInvoice(const UnsignedInvoice&) = delete; + UnsignedInvoice(UnsignedInvoice&& o) : self(o.self) { memset(&o, 0, sizeof(UnsignedInvoice)); } + UnsignedInvoice(LDKUnsignedInvoice&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKUnsignedInvoice)); } + operator LDKUnsignedInvoice() && { LDKUnsignedInvoice res = self; memset(&self, 0, sizeof(LDKUnsignedInvoice)); return res; } + ~UnsignedInvoice() { UnsignedInvoice_free(self); } + UnsignedInvoice& operator=(UnsignedInvoice&& o) { UnsignedInvoice_free(self); self = o.self; memset(&o, 0, sizeof(UnsignedInvoice)); return *this; } + LDKUnsignedInvoice* operator &() { return &self; } + LDKUnsignedInvoice* operator ->() { return &self; } + const LDKUnsignedInvoice* operator &() const { return &self; } + const LDKUnsignedInvoice* operator ->() const { return &self; } }; -class BlindedHop { +class BlindedPayInfo { private: - LDKBlindedHop self; + LDKBlindedPayInfo self; public: - BlindedHop(const BlindedHop&) = delete; - BlindedHop(BlindedHop&& o) : self(o.self) { memset(&o, 0, sizeof(BlindedHop)); } - BlindedHop(LDKBlindedHop&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBlindedHop)); } - operator LDKBlindedHop() && { LDKBlindedHop res = self; memset(&self, 0, sizeof(LDKBlindedHop)); return res; } - ~BlindedHop() { BlindedHop_free(self); } - BlindedHop& operator=(BlindedHop&& o) { BlindedHop_free(self); self = o.self; memset(&o, 0, sizeof(BlindedHop)); return *this; } - LDKBlindedHop* operator &() { return &self; } - LDKBlindedHop* operator ->() { return &self; } - const LDKBlindedHop* operator &() const { return &self; } - const LDKBlindedHop* operator ->() const { return &self; } + 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 BackgroundProcessor { private: @@ -903,6 +963,36 @@ public: const LDKRouteHop* operator &() const { return &self; } const LDKRouteHop* operator ->() const { return &self; } }; +class BlindedTail { +private: + LDKBlindedTail self; +public: + BlindedTail(const BlindedTail&) = delete; + BlindedTail(BlindedTail&& o) : self(o.self) { memset(&o, 0, sizeof(BlindedTail)); } + BlindedTail(LDKBlindedTail&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBlindedTail)); } + operator LDKBlindedTail() && { LDKBlindedTail res = self; memset(&self, 0, sizeof(LDKBlindedTail)); return res; } + ~BlindedTail() { BlindedTail_free(self); } + BlindedTail& operator=(BlindedTail&& o) { BlindedTail_free(self); self = o.self; memset(&o, 0, sizeof(BlindedTail)); return *this; } + LDKBlindedTail* operator &() { return &self; } + LDKBlindedTail* operator ->() { return &self; } + const LDKBlindedTail* operator &() const { return &self; } + const LDKBlindedTail* operator ->() const { return &self; } +}; +class Path { +private: + LDKPath self; +public: + Path(const Path&) = delete; + Path(Path&& o) : self(o.self) { memset(&o, 0, sizeof(Path)); } + Path(LDKPath&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPath)); } + operator LDKPath() && { LDKPath res = self; memset(&self, 0, sizeof(LDKPath)); return res; } + ~Path() { Path_free(self); } + Path& operator=(Path&& o) { Path_free(self); self = o.self; memset(&o, 0, sizeof(Path)); return *this; } + LDKPath* operator &() { return &self; } + LDKPath* operator ->() { return &self; } + const LDKPath* operator &() const { return &self; } + const LDKPath* operator ->() const { return &self; } +}; class Route { private: LDKRoute self; @@ -948,6 +1038,21 @@ public: const LDKPaymentParameters* operator &() const { return &self; } const LDKPaymentParameters* operator ->() const { return &self; } }; +class Hints { +private: + LDKHints self; +public: + Hints(const Hints&) = delete; + Hints(Hints&& o) : self(o.self) { memset(&o, 0, sizeof(Hints)); } + Hints(LDKHints&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKHints)); } + operator LDKHints() && { LDKHints res = self; memset(&self, 0, sizeof(LDKHints)); return res; } + ~Hints() { Hints_free(self); } + Hints& operator=(Hints&& o) { Hints_free(self); self = o.self; memset(&o, 0, sizeof(Hints)); return *this; } + LDKHints* operator &() { return &self; } + LDKHints* operator ->() { return &self; } + const LDKHints* operator &() const { return &self; } + const LDKHints* operator ->() const { return &self; } +}; class RouteHint { private: LDKRouteHint self; @@ -1037,179 +1142,6 @@ public: */ inline uint32_t get_est_sat_per_1000_weight(enum LDKConfirmationTarget confirmation_target); }; -class PaymentPurpose { -private: - LDKPaymentPurpose self; -public: - PaymentPurpose(const PaymentPurpose&) = delete; - PaymentPurpose(PaymentPurpose&& o) : self(o.self) { memset(&o, 0, sizeof(PaymentPurpose)); } - PaymentPurpose(LDKPaymentPurpose&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPaymentPurpose)); } - operator LDKPaymentPurpose() && { LDKPaymentPurpose res = self; memset(&self, 0, sizeof(LDKPaymentPurpose)); return res; } - ~PaymentPurpose() { PaymentPurpose_free(self); } - PaymentPurpose& operator=(PaymentPurpose&& o) { PaymentPurpose_free(self); self = o.self; memset(&o, 0, sizeof(PaymentPurpose)); return *this; } - LDKPaymentPurpose* operator &() { return &self; } - LDKPaymentPurpose* operator ->() { return &self; } - const LDKPaymentPurpose* operator &() const { return &self; } - const LDKPaymentPurpose* operator ->() const { return &self; } -}; -class PathFailure { -private: - LDKPathFailure self; -public: - PathFailure(const PathFailure&) = delete; - PathFailure(PathFailure&& o) : self(o.self) { memset(&o, 0, sizeof(PathFailure)); } - PathFailure(LDKPathFailure&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPathFailure)); } - operator LDKPathFailure() && { LDKPathFailure res = self; memset(&self, 0, sizeof(LDKPathFailure)); return res; } - ~PathFailure() { PathFailure_free(self); } - PathFailure& operator=(PathFailure&& o) { PathFailure_free(self); self = o.self; memset(&o, 0, sizeof(PathFailure)); return *this; } - LDKPathFailure* operator &() { return &self; } - LDKPathFailure* operator ->() { return &self; } - const LDKPathFailure* operator &() const { return &self; } - const LDKPathFailure* operator ->() const { return &self; } -}; -class ClosureReason { -private: - LDKClosureReason self; -public: - ClosureReason(const ClosureReason&) = delete; - ClosureReason(ClosureReason&& o) : self(o.self) { memset(&o, 0, sizeof(ClosureReason)); } - ClosureReason(LDKClosureReason&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKClosureReason)); } - operator LDKClosureReason() && { LDKClosureReason res = self; memset(&self, 0, sizeof(LDKClosureReason)); return res; } - ~ClosureReason() { ClosureReason_free(self); } - ClosureReason& operator=(ClosureReason&& o) { ClosureReason_free(self); self = o.self; memset(&o, 0, sizeof(ClosureReason)); return *this; } - LDKClosureReason* operator &() { return &self; } - LDKClosureReason* operator ->() { return &self; } - const LDKClosureReason* operator &() const { return &self; } - const LDKClosureReason* operator ->() const { return &self; } -}; -class HTLCDestination { -private: - LDKHTLCDestination self; -public: - HTLCDestination(const HTLCDestination&) = delete; - HTLCDestination(HTLCDestination&& o) : self(o.self) { memset(&o, 0, sizeof(HTLCDestination)); } - HTLCDestination(LDKHTLCDestination&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKHTLCDestination)); } - operator LDKHTLCDestination() && { LDKHTLCDestination res = self; memset(&self, 0, sizeof(LDKHTLCDestination)); return res; } - ~HTLCDestination() { HTLCDestination_free(self); } - HTLCDestination& operator=(HTLCDestination&& o) { HTLCDestination_free(self); self = o.self; memset(&o, 0, sizeof(HTLCDestination)); return *this; } - LDKHTLCDestination* operator &() { return &self; } - LDKHTLCDestination* operator ->() { return &self; } - const LDKHTLCDestination* operator &() const { return &self; } - const LDKHTLCDestination* operator ->() const { return &self; } -}; -class Event { -private: - LDKEvent self; -public: - Event(const Event&) = delete; - Event(Event&& o) : self(o.self) { memset(&o, 0, sizeof(Event)); } - Event(LDKEvent&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKEvent)); } - operator LDKEvent() && { LDKEvent res = self; memset(&self, 0, sizeof(LDKEvent)); return res; } - ~Event() { Event_free(self); } - Event& operator=(Event&& o) { Event_free(self); self = o.self; memset(&o, 0, sizeof(Event)); return *this; } - LDKEvent* operator &() { return &self; } - LDKEvent* operator ->() { return &self; } - const LDKEvent* operator &() const { return &self; } - const LDKEvent* operator ->() const { return &self; } -}; -class MessageSendEvent { -private: - LDKMessageSendEvent self; -public: - MessageSendEvent(const MessageSendEvent&) = delete; - MessageSendEvent(MessageSendEvent&& o) : self(o.self) { memset(&o, 0, sizeof(MessageSendEvent)); } - MessageSendEvent(LDKMessageSendEvent&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKMessageSendEvent)); } - operator LDKMessageSendEvent() && { LDKMessageSendEvent res = self; memset(&self, 0, sizeof(LDKMessageSendEvent)); return res; } - ~MessageSendEvent() { MessageSendEvent_free(self); } - MessageSendEvent& operator=(MessageSendEvent&& o) { MessageSendEvent_free(self); self = o.self; memset(&o, 0, sizeof(MessageSendEvent)); return *this; } - LDKMessageSendEvent* operator &() { return &self; } - LDKMessageSendEvent* operator ->() { return &self; } - const LDKMessageSendEvent* operator &() const { return &self; } - const LDKMessageSendEvent* operator ->() const { return &self; } -}; -class MessageSendEventsProvider { -private: - LDKMessageSendEventsProvider self; -public: - MessageSendEventsProvider(const MessageSendEventsProvider&) = delete; - MessageSendEventsProvider(MessageSendEventsProvider&& o) : self(o.self) { memset(&o, 0, sizeof(MessageSendEventsProvider)); } - MessageSendEventsProvider(LDKMessageSendEventsProvider&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKMessageSendEventsProvider)); } - operator LDKMessageSendEventsProvider() && { LDKMessageSendEventsProvider res = self; memset(&self, 0, sizeof(LDKMessageSendEventsProvider)); return res; } - ~MessageSendEventsProvider() { MessageSendEventsProvider_free(self); } - MessageSendEventsProvider& operator=(MessageSendEventsProvider&& o) { MessageSendEventsProvider_free(self); self = o.self; memset(&o, 0, sizeof(MessageSendEventsProvider)); return *this; } - LDKMessageSendEventsProvider* operator &() { return &self; } - LDKMessageSendEventsProvider* operator ->() { return &self; } - const LDKMessageSendEventsProvider* operator &() const { return &self; } - const LDKMessageSendEventsProvider* operator ->() const { return &self; } - /** - * Gets the list of pending events which were generated by previous actions, clearing the list - * in the process. - */ - inline LDK::CVec_MessageSendEventZ get_and_clear_pending_msg_events(); -}; -class OnionMessageProvider { -private: - LDKOnionMessageProvider self; -public: - OnionMessageProvider(const OnionMessageProvider&) = delete; - OnionMessageProvider(OnionMessageProvider&& o) : self(o.self) { memset(&o, 0, sizeof(OnionMessageProvider)); } - OnionMessageProvider(LDKOnionMessageProvider&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKOnionMessageProvider)); } - operator LDKOnionMessageProvider() && { LDKOnionMessageProvider res = self; memset(&self, 0, sizeof(LDKOnionMessageProvider)); return res; } - ~OnionMessageProvider() { OnionMessageProvider_free(self); } - OnionMessageProvider& operator=(OnionMessageProvider&& o) { OnionMessageProvider_free(self); self = o.self; memset(&o, 0, sizeof(OnionMessageProvider)); return *this; } - LDKOnionMessageProvider* operator &() { return &self; } - LDKOnionMessageProvider* operator ->() { return &self; } - const LDKOnionMessageProvider* operator &() const { return &self; } - const LDKOnionMessageProvider* operator ->() const { return &self; } - /** - * Gets the next pending onion message for the peer with the given node id. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None - */ - inline LDK::OnionMessage next_onion_message_for_peer(struct LDKPublicKey peer_node_id); -}; -class EventsProvider { -private: - LDKEventsProvider self; -public: - EventsProvider(const EventsProvider&) = delete; - EventsProvider(EventsProvider&& o) : self(o.self) { memset(&o, 0, sizeof(EventsProvider)); } - EventsProvider(LDKEventsProvider&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKEventsProvider)); } - operator LDKEventsProvider() && { LDKEventsProvider res = self; memset(&self, 0, sizeof(LDKEventsProvider)); return res; } - ~EventsProvider() { EventsProvider_free(self); } - EventsProvider& operator=(EventsProvider&& o) { EventsProvider_free(self); self = o.self; memset(&o, 0, sizeof(EventsProvider)); return *this; } - LDKEventsProvider* operator &() { return &self; } - LDKEventsProvider* operator ->() { return &self; } - const LDKEventsProvider* operator &() const { return &self; } - const LDKEventsProvider* operator ->() const { return &self; } - /** - * Processes any events generated since the last call using the given event handler. - * - * See the trait-level documentation for requirements. - */ - inline void process_pending_events(struct LDKEventHandler handler); -}; -class EventHandler { -private: - LDKEventHandler self; -public: - EventHandler(const EventHandler&) = delete; - EventHandler(EventHandler&& o) : self(o.self) { memset(&o, 0, sizeof(EventHandler)); } - EventHandler(LDKEventHandler&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKEventHandler)); } - operator LDKEventHandler() && { LDKEventHandler res = self; memset(&self, 0, sizeof(LDKEventHandler)); return res; } - ~EventHandler() { EventHandler_free(self); } - EventHandler& operator=(EventHandler&& o) { EventHandler_free(self); self = o.self; memset(&o, 0, sizeof(EventHandler)); return *this; } - LDKEventHandler* operator &() { return &self; } - LDKEventHandler* operator ->() { return &self; } - const LDKEventHandler* operator &() const { return &self; } - const LDKEventHandler* operator ->() const { return &self; } - /** - * Handles the given [`Event`]. - * - * See [`EventsProvider`] for details that must be considered when implementing this method. - */ - inline void handle_event(struct LDKEvent event); -}; class BestBlock { private: LDKBestBlock self; @@ -1464,19 +1396,19 @@ public: /** * Handles updating channel penalties after failing to route through a channel. */ - inline void payment_path_failed(struct LDKCVec_RouteHopZ path, uint64_t short_channel_id); + inline void payment_path_failed(const struct LDKPath *NONNULL_PTR path, uint64_t short_channel_id); /** * Handles updating channel penalties after successfully routing along a path. */ - inline void payment_path_successful(struct LDKCVec_RouteHopZ path); + inline void payment_path_successful(const struct LDKPath *NONNULL_PTR path); /** * Handles updating channel penalties after a probe over the given path failed. */ - inline void probe_failed(struct LDKCVec_RouteHopZ path, uint64_t short_channel_id); + inline void probe_failed(const struct LDKPath *NONNULL_PTR path, uint64_t short_channel_id); /** * Handles updating channel penalties after a probe over the given path succeeded. */ - inline void probe_successful(struct LDKCVec_RouteHopZ path); + inline void probe_successful(const struct LDKPath *NONNULL_PTR path); }; class LockableScore { private: @@ -1602,6 +1534,40 @@ public: const LDKProbabilisticScoringParameters* operator &() const { return &self; } const LDKProbabilisticScoringParameters* operator ->() const { return &self; } }; +class OnionMessageContents { +private: + LDKOnionMessageContents self; +public: + OnionMessageContents(const OnionMessageContents&) = delete; + OnionMessageContents(OnionMessageContents&& o) : self(o.self) { memset(&o, 0, sizeof(OnionMessageContents)); } + OnionMessageContents(LDKOnionMessageContents&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKOnionMessageContents)); } + operator LDKOnionMessageContents() && { LDKOnionMessageContents res = self; memset(&self, 0, sizeof(LDKOnionMessageContents)); return res; } + ~OnionMessageContents() { OnionMessageContents_free(self); } + OnionMessageContents& operator=(OnionMessageContents&& o) { OnionMessageContents_free(self); self = o.self; memset(&o, 0, sizeof(OnionMessageContents)); return *this; } + LDKOnionMessageContents* operator &() { return &self; } + LDKOnionMessageContents* operator ->() { return &self; } + const LDKOnionMessageContents* operator &() const { return &self; } + const LDKOnionMessageContents* operator ->() const { return &self; } +}; +class CustomOnionMessageContents { +private: + LDKCustomOnionMessageContents self; +public: + CustomOnionMessageContents(const CustomOnionMessageContents&) = delete; + CustomOnionMessageContents(CustomOnionMessageContents&& o) : self(o.self) { memset(&o, 0, sizeof(CustomOnionMessageContents)); } + CustomOnionMessageContents(LDKCustomOnionMessageContents&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCustomOnionMessageContents)); } + operator LDKCustomOnionMessageContents() && { LDKCustomOnionMessageContents res = self; memset(&self, 0, sizeof(LDKCustomOnionMessageContents)); return res; } + ~CustomOnionMessageContents() { CustomOnionMessageContents_free(self); } + CustomOnionMessageContents& operator=(CustomOnionMessageContents&& o) { CustomOnionMessageContents_free(self); self = o.self; memset(&o, 0, sizeof(CustomOnionMessageContents)); return *this; } + LDKCustomOnionMessageContents* operator &() { return &self; } + LDKCustomOnionMessageContents* operator ->() { return &self; } + const LDKCustomOnionMessageContents* operator &() const { return &self; } + const LDKCustomOnionMessageContents* operator ->() const { return &self; } + /** + * Returns the TLV type identifying the message contents. MUST be >= 64. + */ + inline uint64_t tlv_type(); +}; class InitFeatures { private: LDKInitFeatures self; @@ -1707,69 +1673,267 @@ public: const LDKBolt12InvoiceFeatures* operator &() const { return &self; } const LDKBolt12InvoiceFeatures* operator ->() const { return &self; } }; -class BlindedHopFeatures { +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 PaymentPurpose { +private: + LDKPaymentPurpose self; +public: + PaymentPurpose(const PaymentPurpose&) = delete; + PaymentPurpose(PaymentPurpose&& o) : self(o.self) { memset(&o, 0, sizeof(PaymentPurpose)); } + PaymentPurpose(LDKPaymentPurpose&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPaymentPurpose)); } + operator LDKPaymentPurpose() && { LDKPaymentPurpose res = self; memset(&self, 0, sizeof(LDKPaymentPurpose)); return res; } + ~PaymentPurpose() { PaymentPurpose_free(self); } + PaymentPurpose& operator=(PaymentPurpose&& o) { PaymentPurpose_free(self); self = o.self; memset(&o, 0, sizeof(PaymentPurpose)); return *this; } + LDKPaymentPurpose* operator &() { return &self; } + LDKPaymentPurpose* operator ->() { return &self; } + const LDKPaymentPurpose* operator &() const { return &self; } + const LDKPaymentPurpose* operator ->() const { return &self; } +}; +class PathFailure { +private: + LDKPathFailure self; +public: + PathFailure(const PathFailure&) = delete; + PathFailure(PathFailure&& o) : self(o.self) { memset(&o, 0, sizeof(PathFailure)); } + PathFailure(LDKPathFailure&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPathFailure)); } + operator LDKPathFailure() && { LDKPathFailure res = self; memset(&self, 0, sizeof(LDKPathFailure)); return res; } + ~PathFailure() { PathFailure_free(self); } + PathFailure& operator=(PathFailure&& o) { PathFailure_free(self); self = o.self; memset(&o, 0, sizeof(PathFailure)); return *this; } + LDKPathFailure* operator &() { return &self; } + LDKPathFailure* operator ->() { return &self; } + const LDKPathFailure* operator &() const { return &self; } + const LDKPathFailure* operator ->() const { return &self; } +}; +class ClosureReason { +private: + LDKClosureReason self; +public: + ClosureReason(const ClosureReason&) = delete; + ClosureReason(ClosureReason&& o) : self(o.self) { memset(&o, 0, sizeof(ClosureReason)); } + ClosureReason(LDKClosureReason&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKClosureReason)); } + operator LDKClosureReason() && { LDKClosureReason res = self; memset(&self, 0, sizeof(LDKClosureReason)); return res; } + ~ClosureReason() { ClosureReason_free(self); } + ClosureReason& operator=(ClosureReason&& o) { ClosureReason_free(self); self = o.self; memset(&o, 0, sizeof(ClosureReason)); return *this; } + LDKClosureReason* operator &() { return &self; } + LDKClosureReason* operator ->() { return &self; } + const LDKClosureReason* operator &() const { return &self; } + const LDKClosureReason* operator ->() const { return &self; } +}; +class HTLCDestination { +private: + LDKHTLCDestination self; +public: + HTLCDestination(const HTLCDestination&) = delete; + HTLCDestination(HTLCDestination&& o) : self(o.self) { memset(&o, 0, sizeof(HTLCDestination)); } + HTLCDestination(LDKHTLCDestination&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKHTLCDestination)); } + operator LDKHTLCDestination() && { LDKHTLCDestination res = self; memset(&self, 0, sizeof(LDKHTLCDestination)); return res; } + ~HTLCDestination() { HTLCDestination_free(self); } + HTLCDestination& operator=(HTLCDestination&& o) { HTLCDestination_free(self); self = o.self; memset(&o, 0, sizeof(HTLCDestination)); return *this; } + LDKHTLCDestination* operator &() { return &self; } + LDKHTLCDestination* operator ->() { return &self; } + const LDKHTLCDestination* operator &() const { return &self; } + const LDKHTLCDestination* operator ->() const { return &self; } +}; +class PaymentFailureReason { +private: + LDKPaymentFailureReason self; +public: + PaymentFailureReason(const PaymentFailureReason&) = delete; + PaymentFailureReason(PaymentFailureReason&& o) : self(o.self) { memset(&o, 0, sizeof(PaymentFailureReason)); } + PaymentFailureReason(LDKPaymentFailureReason&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPaymentFailureReason)); } + operator LDKPaymentFailureReason() && { LDKPaymentFailureReason res = self; memset(&self, 0, sizeof(LDKPaymentFailureReason)); return res; } + PaymentFailureReason& operator=(PaymentFailureReason&& o) { self = o.self; memset(&o, 0, sizeof(PaymentFailureReason)); return *this; } + LDKPaymentFailureReason* operator &() { return &self; } + LDKPaymentFailureReason* operator ->() { return &self; } + const LDKPaymentFailureReason* operator &() const { return &self; } + const LDKPaymentFailureReason* operator ->() const { return &self; } +}; +class Event { +private: + LDKEvent self; +public: + Event(const Event&) = delete; + Event(Event&& o) : self(o.self) { memset(&o, 0, sizeof(Event)); } + Event(LDKEvent&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKEvent)); } + operator LDKEvent() && { LDKEvent res = self; memset(&self, 0, sizeof(LDKEvent)); return res; } + ~Event() { Event_free(self); } + Event& operator=(Event&& o) { Event_free(self); self = o.self; memset(&o, 0, sizeof(Event)); return *this; } + LDKEvent* operator &() { return &self; } + LDKEvent* operator ->() { return &self; } + const LDKEvent* operator &() const { return &self; } + const LDKEvent* operator ->() const { return &self; } +}; +class MessageSendEvent { +private: + LDKMessageSendEvent self; +public: + MessageSendEvent(const MessageSendEvent&) = delete; + MessageSendEvent(MessageSendEvent&& o) : self(o.self) { memset(&o, 0, sizeof(MessageSendEvent)); } + MessageSendEvent(LDKMessageSendEvent&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKMessageSendEvent)); } + operator LDKMessageSendEvent() && { LDKMessageSendEvent res = self; memset(&self, 0, sizeof(LDKMessageSendEvent)); return res; } + ~MessageSendEvent() { MessageSendEvent_free(self); } + MessageSendEvent& operator=(MessageSendEvent&& o) { MessageSendEvent_free(self); self = o.self; memset(&o, 0, sizeof(MessageSendEvent)); return *this; } + LDKMessageSendEvent* operator &() { return &self; } + LDKMessageSendEvent* operator ->() { return &self; } + const LDKMessageSendEvent* operator &() const { return &self; } + const LDKMessageSendEvent* operator ->() const { return &self; } +}; +class MessageSendEventsProvider { private: - LDKBlindedHopFeatures self; + LDKMessageSendEventsProvider 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; } + MessageSendEventsProvider(const MessageSendEventsProvider&) = delete; + MessageSendEventsProvider(MessageSendEventsProvider&& o) : self(o.self) { memset(&o, 0, sizeof(MessageSendEventsProvider)); } + MessageSendEventsProvider(LDKMessageSendEventsProvider&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKMessageSendEventsProvider)); } + operator LDKMessageSendEventsProvider() && { LDKMessageSendEventsProvider res = self; memset(&self, 0, sizeof(LDKMessageSendEventsProvider)); return res; } + ~MessageSendEventsProvider() { MessageSendEventsProvider_free(self); } + MessageSendEventsProvider& operator=(MessageSendEventsProvider&& o) { MessageSendEventsProvider_free(self); self = o.self; memset(&o, 0, sizeof(MessageSendEventsProvider)); return *this; } + LDKMessageSendEventsProvider* operator &() { return &self; } + LDKMessageSendEventsProvider* operator ->() { return &self; } + const LDKMessageSendEventsProvider* operator &() const { return &self; } + const LDKMessageSendEventsProvider* operator ->() const { return &self; } + /** + * Gets the list of pending events which were generated by previous actions, clearing the list + * in the process. + */ + inline LDK::CVec_MessageSendEventZ get_and_clear_pending_msg_events(); }; -class ChannelTypeFeatures { +class OnionMessageProvider { private: - LDKChannelTypeFeatures self; + LDKOnionMessageProvider 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; } + OnionMessageProvider(const OnionMessageProvider&) = delete; + OnionMessageProvider(OnionMessageProvider&& o) : self(o.self) { memset(&o, 0, sizeof(OnionMessageProvider)); } + OnionMessageProvider(LDKOnionMessageProvider&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKOnionMessageProvider)); } + operator LDKOnionMessageProvider() && { LDKOnionMessageProvider res = self; memset(&self, 0, sizeof(LDKOnionMessageProvider)); return res; } + ~OnionMessageProvider() { OnionMessageProvider_free(self); } + OnionMessageProvider& operator=(OnionMessageProvider&& o) { OnionMessageProvider_free(self); self = o.self; memset(&o, 0, sizeof(OnionMessageProvider)); return *this; } + LDKOnionMessageProvider* operator &() { return &self; } + LDKOnionMessageProvider* operator ->() { return &self; } + const LDKOnionMessageProvider* operator &() const { return &self; } + const LDKOnionMessageProvider* operator ->() const { return &self; } + /** + * Gets the next pending onion message for the peer with the given node id. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + */ + inline LDK::OnionMessage next_onion_message_for_peer(struct LDKPublicKey peer_node_id); }; -class OnionMessageContents { +class EventsProvider { private: - LDKOnionMessageContents self; + LDKEventsProvider self; public: - OnionMessageContents(const OnionMessageContents&) = delete; - OnionMessageContents(OnionMessageContents&& o) : self(o.self) { memset(&o, 0, sizeof(OnionMessageContents)); } - OnionMessageContents(LDKOnionMessageContents&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKOnionMessageContents)); } - operator LDKOnionMessageContents() && { LDKOnionMessageContents res = self; memset(&self, 0, sizeof(LDKOnionMessageContents)); return res; } - ~OnionMessageContents() { OnionMessageContents_free(self); } - OnionMessageContents& operator=(OnionMessageContents&& o) { OnionMessageContents_free(self); self = o.self; memset(&o, 0, sizeof(OnionMessageContents)); return *this; } - LDKOnionMessageContents* operator &() { return &self; } - LDKOnionMessageContents* operator ->() { return &self; } - const LDKOnionMessageContents* operator &() const { return &self; } - const LDKOnionMessageContents* operator ->() const { return &self; } + EventsProvider(const EventsProvider&) = delete; + EventsProvider(EventsProvider&& o) : self(o.self) { memset(&o, 0, sizeof(EventsProvider)); } + EventsProvider(LDKEventsProvider&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKEventsProvider)); } + operator LDKEventsProvider() && { LDKEventsProvider res = self; memset(&self, 0, sizeof(LDKEventsProvider)); return res; } + ~EventsProvider() { EventsProvider_free(self); } + EventsProvider& operator=(EventsProvider&& o) { EventsProvider_free(self); self = o.self; memset(&o, 0, sizeof(EventsProvider)); return *this; } + LDKEventsProvider* operator &() { return &self; } + LDKEventsProvider* operator ->() { return &self; } + const LDKEventsProvider* operator &() const { return &self; } + const LDKEventsProvider* operator ->() const { return &self; } + /** + * Processes any events generated since the last call using the given event handler. + * + * See the trait-level documentation for requirements. + */ + inline void process_pending_events(struct LDKEventHandler handler); }; -class CustomOnionMessageContents { +class EventHandler { private: - LDKCustomOnionMessageContents self; + LDKEventHandler self; public: - CustomOnionMessageContents(const CustomOnionMessageContents&) = delete; - CustomOnionMessageContents(CustomOnionMessageContents&& o) : self(o.self) { memset(&o, 0, sizeof(CustomOnionMessageContents)); } - CustomOnionMessageContents(LDKCustomOnionMessageContents&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCustomOnionMessageContents)); } - operator LDKCustomOnionMessageContents() && { LDKCustomOnionMessageContents res = self; memset(&self, 0, sizeof(LDKCustomOnionMessageContents)); return res; } - ~CustomOnionMessageContents() { CustomOnionMessageContents_free(self); } - CustomOnionMessageContents& operator=(CustomOnionMessageContents&& o) { CustomOnionMessageContents_free(self); self = o.self; memset(&o, 0, sizeof(CustomOnionMessageContents)); return *this; } - LDKCustomOnionMessageContents* operator &() { return &self; } - LDKCustomOnionMessageContents* operator ->() { return &self; } - const LDKCustomOnionMessageContents* operator &() const { return &self; } - const LDKCustomOnionMessageContents* operator ->() const { return &self; } + EventHandler(const EventHandler&) = delete; + EventHandler(EventHandler&& o) : self(o.self) { memset(&o, 0, sizeof(EventHandler)); } + EventHandler(LDKEventHandler&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKEventHandler)); } + operator LDKEventHandler() && { LDKEventHandler res = self; memset(&self, 0, sizeof(LDKEventHandler)); return res; } + ~EventHandler() { EventHandler_free(self); } + EventHandler& operator=(EventHandler&& o) { EventHandler_free(self); self = o.self; memset(&o, 0, sizeof(EventHandler)); return *this; } + LDKEventHandler* operator &() { return &self; } + LDKEventHandler* operator ->() { return &self; } + const LDKEventHandler* operator &() const { return &self; } + const LDKEventHandler* operator ->() const { return &self; } /** - * Returns the TLV type identifying the message contents. MUST be >= 64. + * Handles the given [`Event`]. + * + * See [`EventsProvider`] for details that must be considered when implementing this method. */ - inline uint64_t tlv_type(); + inline void handle_event(struct LDKEvent event); +}; +class Offer { +private: + LDKOffer self; +public: + Offer(const Offer&) = delete; + Offer(Offer&& o) : self(o.self) { memset(&o, 0, sizeof(Offer)); } + Offer(LDKOffer&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKOffer)); } + operator LDKOffer() && { LDKOffer res = self; memset(&self, 0, sizeof(LDKOffer)); return res; } + ~Offer() { Offer_free(self); } + Offer& operator=(Offer&& o) { Offer_free(self); self = o.self; memset(&o, 0, sizeof(Offer)); return *this; } + LDKOffer* operator &() { return &self; } + LDKOffer* operator ->() { return &self; } + const LDKOffer* operator &() const { return &self; } + const LDKOffer* operator ->() const { return &self; } +}; +class Amount { +private: + LDKAmount self; +public: + Amount(const Amount&) = delete; + Amount(Amount&& o) : self(o.self) { memset(&o, 0, sizeof(Amount)); } + Amount(LDKAmount&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKAmount)); } + operator LDKAmount() && { LDKAmount res = self; memset(&self, 0, sizeof(LDKAmount)); return res; } + ~Amount() { Amount_free(self); } + Amount& operator=(Amount&& o) { Amount_free(self); self = o.self; memset(&o, 0, sizeof(Amount)); return *this; } + LDKAmount* operator &() { return &self; } + LDKAmount* operator ->() { return &self; } + const LDKAmount* operator &() const { return &self; } + const LDKAmount* operator ->() const { return &self; } +}; +class Quantity { +private: + LDKQuantity self; +public: + Quantity(const Quantity&) = delete; + Quantity(Quantity&& o) : self(o.self) { memset(&o, 0, sizeof(Quantity)); } + Quantity(LDKQuantity&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKQuantity)); } + operator LDKQuantity() && { LDKQuantity res = self; memset(&self, 0, sizeof(LDKQuantity)); return res; } + ~Quantity() { Quantity_free(self); } + Quantity& operator=(Quantity&& o) { Quantity_free(self); self = o.self; memset(&o, 0, sizeof(Quantity)); return *this; } + LDKQuantity* operator &() { return &self; } + LDKQuantity* operator ->() { return &self; } + const LDKQuantity* operator &() const { return &self; } + const LDKQuantity* operator ->() const { return &self; } }; class NodeId { private: @@ -2696,6 +2860,21 @@ public: const LDKHostname* operator &() const { return &self; } const LDKHostname* 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; @@ -3163,6 +3342,36 @@ public: */ inline LDK::CResult_COption_CustomOnionMessageContentsZDecodeErrorZ read_custom_message(uint64_t message_type, struct LDKu8slice buffer); }; +class BlindedPath { +private: + LDKBlindedPath self; +public: + BlindedPath(const BlindedPath&) = delete; + BlindedPath(BlindedPath&& o) : self(o.self) { memset(&o, 0, sizeof(BlindedPath)); } + BlindedPath(LDKBlindedPath&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBlindedPath)); } + operator LDKBlindedPath() && { LDKBlindedPath res = self; memset(&self, 0, sizeof(LDKBlindedPath)); return res; } + ~BlindedPath() { BlindedPath_free(self); } + BlindedPath& operator=(BlindedPath&& o) { BlindedPath_free(self); self = o.self; memset(&o, 0, sizeof(BlindedPath)); return *this; } + LDKBlindedPath* operator &() { return &self; } + LDKBlindedPath* operator ->() { return &self; } + const LDKBlindedPath* operator &() const { return &self; } + const LDKBlindedPath* operator ->() const { return &self; } +}; +class BlindedHop { +private: + LDKBlindedHop self; +public: + BlindedHop(const BlindedHop&) = delete; + BlindedHop(BlindedHop&& o) : self(o.self) { memset(&o, 0, sizeof(BlindedHop)); } + BlindedHop(LDKBlindedHop&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBlindedHop)); } + operator LDKBlindedHop() && { LDKBlindedHop res = self; memset(&self, 0, sizeof(LDKBlindedHop)); return res; } + ~BlindedHop() { BlindedHop_free(self); } + BlindedHop& operator=(BlindedHop&& o) { BlindedHop_free(self); self = o.self; memset(&o, 0, sizeof(BlindedHop)); return *this; } + LDKBlindedHop* operator &() { return &self; } + LDKBlindedHop* operator ->() { return &self; } + const LDKBlindedHop* operator &() const { return &self; } + const LDKBlindedHop* operator ->() const { return &self; } +}; class ParseError { private: LDKParseError self; @@ -3459,21 +3668,6 @@ public: const LDKSignOrCreationError* operator &() const { return &self; } const LDKSignOrCreationError* operator ->() const { return &self; } }; -class RapidGossipSync { -private: - LDKRapidGossipSync self; -public: - RapidGossipSync(const RapidGossipSync&) = delete; - RapidGossipSync(RapidGossipSync&& o) : self(o.self) { memset(&o, 0, sizeof(RapidGossipSync)); } - RapidGossipSync(LDKRapidGossipSync&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKRapidGossipSync)); } - operator LDKRapidGossipSync() && { LDKRapidGossipSync res = self; memset(&self, 0, sizeof(LDKRapidGossipSync)); return res; } - ~RapidGossipSync() { RapidGossipSync_free(self); } - RapidGossipSync& operator=(RapidGossipSync&& o) { RapidGossipSync_free(self); self = o.self; memset(&o, 0, sizeof(RapidGossipSync)); return *this; } - LDKRapidGossipSync* operator &() { return &self; } - LDKRapidGossipSync* operator ->() { return &self; } - const LDKRapidGossipSync* operator &() const { return &self; } - const LDKRapidGossipSync* operator ->() const { return &self; } -}; class Persister { private: LDKPersister self; @@ -4376,20 +4570,35 @@ public: */ inline LDK::InitFeatures provided_init_features(struct LDKPublicKey their_node_id); }; -class GraphSyncError { +class UnsignedInvoiceRequest { private: - LDKGraphSyncError self; + LDKUnsignedInvoiceRequest self; public: - GraphSyncError(const GraphSyncError&) = delete; - GraphSyncError(GraphSyncError&& o) : self(o.self) { memset(&o, 0, sizeof(GraphSyncError)); } - GraphSyncError(LDKGraphSyncError&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKGraphSyncError)); } - operator LDKGraphSyncError() && { LDKGraphSyncError res = self; memset(&self, 0, sizeof(LDKGraphSyncError)); return res; } - ~GraphSyncError() { GraphSyncError_free(self); } - GraphSyncError& operator=(GraphSyncError&& o) { GraphSyncError_free(self); self = o.self; memset(&o, 0, sizeof(GraphSyncError)); return *this; } - LDKGraphSyncError* operator &() { return &self; } - LDKGraphSyncError* operator ->() { return &self; } - const LDKGraphSyncError* operator &() const { return &self; } - const LDKGraphSyncError* operator ->() const { return &self; } + UnsignedInvoiceRequest(const UnsignedInvoiceRequest&) = delete; + UnsignedInvoiceRequest(UnsignedInvoiceRequest&& o) : self(o.self) { memset(&o, 0, sizeof(UnsignedInvoiceRequest)); } + UnsignedInvoiceRequest(LDKUnsignedInvoiceRequest&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKUnsignedInvoiceRequest)); } + operator LDKUnsignedInvoiceRequest() && { LDKUnsignedInvoiceRequest res = self; memset(&self, 0, sizeof(LDKUnsignedInvoiceRequest)); return res; } + ~UnsignedInvoiceRequest() { UnsignedInvoiceRequest_free(self); } + UnsignedInvoiceRequest& operator=(UnsignedInvoiceRequest&& o) { UnsignedInvoiceRequest_free(self); self = o.self; memset(&o, 0, sizeof(UnsignedInvoiceRequest)); return *this; } + LDKUnsignedInvoiceRequest* operator &() { return &self; } + LDKUnsignedInvoiceRequest* operator ->() { return &self; } + const LDKUnsignedInvoiceRequest* operator &() const { return &self; } + const LDKUnsignedInvoiceRequest* operator ->() const { return &self; } +}; +class InvoiceRequest { +private: + LDKInvoiceRequest self; +public: + InvoiceRequest(const InvoiceRequest&) = delete; + InvoiceRequest(InvoiceRequest&& o) : self(o.self) { memset(&o, 0, sizeof(InvoiceRequest)); } + InvoiceRequest(LDKInvoiceRequest&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKInvoiceRequest)); } + operator LDKInvoiceRequest() && { LDKInvoiceRequest res = self; memset(&self, 0, sizeof(LDKInvoiceRequest)); return res; } + ~InvoiceRequest() { InvoiceRequest_free(self); } + InvoiceRequest& operator=(InvoiceRequest&& o) { InvoiceRequest_free(self); self = o.self; memset(&o, 0, sizeof(InvoiceRequest)); return *this; } + LDKInvoiceRequest* operator &() { return &self; } + LDKInvoiceRequest* operator ->() { return &self; } + const LDKInvoiceRequest* operator &() const { return &self; } + const LDKInvoiceRequest* operator ->() const { return &self; } }; class Level { private: @@ -4473,6 +4682,21 @@ public: const LDKFuture* operator &() const { return &self; } const LDKFuture* operator ->() const { return &self; } }; +class Sleeper { +private: + LDKSleeper self; +public: + Sleeper(const Sleeper&) = delete; + Sleeper(Sleeper&& o) : self(o.self) { memset(&o, 0, sizeof(Sleeper)); } + Sleeper(LDKSleeper&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKSleeper)); } + operator LDKSleeper() && { LDKSleeper res = self; memset(&self, 0, sizeof(LDKSleeper)); return res; } + ~Sleeper() { Sleeper_free(self); } + Sleeper& operator=(Sleeper&& o) { Sleeper_free(self); self = o.self; memset(&o, 0, sizeof(Sleeper)); return *this; } + LDKSleeper* operator &() { return &self; } + LDKSleeper* operator ->() { return &self; } + const LDKSleeper* operator &() const { return &self; } + const LDKSleeper* operator ->() const { return &self; } +}; class MonitorUpdateId { private: LDKMonitorUpdateId self; @@ -4589,6 +4813,36 @@ public: const LDKChainMonitor* operator &() const { return &self; } const LDKChainMonitor* operator ->() const { return &self; } }; +class GraphSyncError { +private: + LDKGraphSyncError self; +public: + GraphSyncError(const GraphSyncError&) = delete; + GraphSyncError(GraphSyncError&& o) : self(o.self) { memset(&o, 0, sizeof(GraphSyncError)); } + GraphSyncError(LDKGraphSyncError&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKGraphSyncError)); } + operator LDKGraphSyncError() && { LDKGraphSyncError res = self; memset(&self, 0, sizeof(LDKGraphSyncError)); return res; } + ~GraphSyncError() { GraphSyncError_free(self); } + GraphSyncError& operator=(GraphSyncError&& o) { GraphSyncError_free(self); self = o.self; memset(&o, 0, sizeof(GraphSyncError)); return *this; } + LDKGraphSyncError* operator &() { return &self; } + LDKGraphSyncError* operator ->() { return &self; } + const LDKGraphSyncError* operator &() const { return &self; } + const LDKGraphSyncError* operator ->() const { return &self; } +}; +class RapidGossipSync { +private: + LDKRapidGossipSync self; +public: + RapidGossipSync(const RapidGossipSync&) = delete; + RapidGossipSync(RapidGossipSync&& o) : self(o.self) { memset(&o, 0, sizeof(RapidGossipSync)); } + RapidGossipSync(LDKRapidGossipSync&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKRapidGossipSync)); } + operator LDKRapidGossipSync() && { LDKRapidGossipSync res = self; memset(&self, 0, sizeof(LDKRapidGossipSync)); return res; } + ~RapidGossipSync() { RapidGossipSync_free(self); } + RapidGossipSync& operator=(RapidGossipSync&& o) { RapidGossipSync_free(self); self = o.self; memset(&o, 0, sizeof(RapidGossipSync)); return *this; } + LDKRapidGossipSync* operator &() { return &self; } + LDKRapidGossipSync* operator ->() { return &self; } + const LDKRapidGossipSync* operator &() const { return &self; } + const LDKRapidGossipSync* operator ->() const { return &self; } +}; class CResult_LockedChannelMonitorNoneZ { private: LDKCResult_LockedChannelMonitorNoneZ self; @@ -4604,6 +4858,21 @@ 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; @@ -4964,6 +5233,21 @@ public: const LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* operator &() const { return &self; } const LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* operator ->() const { return &self; } }; +class COption_DurationZ { +private: + LDKCOption_DurationZ self; +public: + COption_DurationZ(const COption_DurationZ&) = delete; + COption_DurationZ(COption_DurationZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_DurationZ)); } + COption_DurationZ(LDKCOption_DurationZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_DurationZ)); } + operator LDKCOption_DurationZ() && { LDKCOption_DurationZ res = self; memset(&self, 0, sizeof(LDKCOption_DurationZ)); return res; } + ~COption_DurationZ() { COption_DurationZ_free(self); } + COption_DurationZ& operator=(COption_DurationZ&& o) { COption_DurationZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_DurationZ)); return *this; } + LDKCOption_DurationZ* operator &() { return &self; } + LDKCOption_DurationZ* operator ->() { return &self; } + const LDKCOption_DurationZ* operator &() const { return &self; } + const LDKCOption_DurationZ* operator ->() const { return &self; } +}; class CResult_ErrorMessageDecodeErrorZ { private: LDKCResult_ErrorMessageDecodeErrorZ self; @@ -5444,6 +5728,21 @@ public: const LDKCVec_RouteHintHopZ* operator &() const { return &self; } const LDKCVec_RouteHintHopZ* operator ->() const { return &self; } }; +class CResult_UntrustedStringDecodeErrorZ { +private: + LDKCResult_UntrustedStringDecodeErrorZ self; +public: + CResult_UntrustedStringDecodeErrorZ(const CResult_UntrustedStringDecodeErrorZ&) = delete; + CResult_UntrustedStringDecodeErrorZ(CResult_UntrustedStringDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_UntrustedStringDecodeErrorZ)); } + CResult_UntrustedStringDecodeErrorZ(LDKCResult_UntrustedStringDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_UntrustedStringDecodeErrorZ)); } + operator LDKCResult_UntrustedStringDecodeErrorZ() && { LDKCResult_UntrustedStringDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_UntrustedStringDecodeErrorZ)); return res; } + ~CResult_UntrustedStringDecodeErrorZ() { CResult_UntrustedStringDecodeErrorZ_free(self); } + CResult_UntrustedStringDecodeErrorZ& operator=(CResult_UntrustedStringDecodeErrorZ&& o) { CResult_UntrustedStringDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_UntrustedStringDecodeErrorZ)); return *this; } + LDKCResult_UntrustedStringDecodeErrorZ* operator &() { return &self; } + LDKCResult_UntrustedStringDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_UntrustedStringDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_UntrustedStringDecodeErrorZ* operator ->() const { return &self; } +}; class CResult_PaymentParametersDecodeErrorZ { private: LDKCResult_PaymentParametersDecodeErrorZ self; @@ -5744,6 +6043,21 @@ 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_NoneLightningErrorZ { private: LDKCResult_NoneLightningErrorZ self; @@ -5774,21 +6088,6 @@ public: const LDKCResult_PaymentHashRetryableSendFailureZ* operator &() const { return &self; } const LDKCResult_PaymentHashRetryableSendFailureZ* operator ->() const { return &self; } }; -class C2Tuple_PublicKeyCOption_NetAddressZZ { -private: - LDKC2Tuple_PublicKeyCOption_NetAddressZZ self; -public: - C2Tuple_PublicKeyCOption_NetAddressZZ(const C2Tuple_PublicKeyCOption_NetAddressZZ&) = delete; - C2Tuple_PublicKeyCOption_NetAddressZZ(C2Tuple_PublicKeyCOption_NetAddressZZ&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_PublicKeyCOption_NetAddressZZ)); } - C2Tuple_PublicKeyCOption_NetAddressZZ(LDKC2Tuple_PublicKeyCOption_NetAddressZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_PublicKeyCOption_NetAddressZZ)); } - operator LDKC2Tuple_PublicKeyCOption_NetAddressZZ() && { LDKC2Tuple_PublicKeyCOption_NetAddressZZ res = self; memset(&self, 0, sizeof(LDKC2Tuple_PublicKeyCOption_NetAddressZZ)); return res; } - ~C2Tuple_PublicKeyCOption_NetAddressZZ() { C2Tuple_PublicKeyCOption_NetAddressZZ_free(self); } - C2Tuple_PublicKeyCOption_NetAddressZZ& operator=(C2Tuple_PublicKeyCOption_NetAddressZZ&& o) { C2Tuple_PublicKeyCOption_NetAddressZZ_free(self); self = o.self; memset(&o, 0, sizeof(C2Tuple_PublicKeyCOption_NetAddressZZ)); return *this; } - LDKC2Tuple_PublicKeyCOption_NetAddressZZ* operator &() { return &self; } - LDKC2Tuple_PublicKeyCOption_NetAddressZZ* operator ->() { return &self; } - const LDKC2Tuple_PublicKeyCOption_NetAddressZZ* operator &() const { return &self; } - const LDKC2Tuple_PublicKeyCOption_NetAddressZZ* operator ->() const { return &self; } -}; class CResult_COption_EventZDecodeErrorZ { private: LDKCResult_COption_EventZDecodeErrorZ self; @@ -5834,20 +6133,35 @@ public: const LDKCOption_CVec_NetAddressZZ* operator &() const { return &self; } const LDKCOption_CVec_NetAddressZZ* operator ->() const { return &self; } }; -class CResult_NonePeerHandleErrorZ { +class CResult_PaymentFailureReasonDecodeErrorZ { private: - LDKCResult_NonePeerHandleErrorZ self; + 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 C2Tuple_PublicKeyCOption_NetAddressZZ { +private: + LDKC2Tuple_PublicKeyCOption_NetAddressZZ self; public: - CResult_NonePeerHandleErrorZ(const CResult_NonePeerHandleErrorZ&) = delete; - CResult_NonePeerHandleErrorZ(CResult_NonePeerHandleErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_NonePeerHandleErrorZ)); } - CResult_NonePeerHandleErrorZ(LDKCResult_NonePeerHandleErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_NonePeerHandleErrorZ)); } - operator LDKCResult_NonePeerHandleErrorZ() && { LDKCResult_NonePeerHandleErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_NonePeerHandleErrorZ)); return res; } - ~CResult_NonePeerHandleErrorZ() { CResult_NonePeerHandleErrorZ_free(self); } - CResult_NonePeerHandleErrorZ& operator=(CResult_NonePeerHandleErrorZ&& o) { CResult_NonePeerHandleErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_NonePeerHandleErrorZ)); return *this; } - LDKCResult_NonePeerHandleErrorZ* operator &() { return &self; } - LDKCResult_NonePeerHandleErrorZ* operator ->() { return &self; } - const LDKCResult_NonePeerHandleErrorZ* operator &() const { return &self; } - const LDKCResult_NonePeerHandleErrorZ* operator ->() const { return &self; } + C2Tuple_PublicKeyCOption_NetAddressZZ(const C2Tuple_PublicKeyCOption_NetAddressZZ&) = delete; + C2Tuple_PublicKeyCOption_NetAddressZZ(C2Tuple_PublicKeyCOption_NetAddressZZ&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_PublicKeyCOption_NetAddressZZ)); } + C2Tuple_PublicKeyCOption_NetAddressZZ(LDKC2Tuple_PublicKeyCOption_NetAddressZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_PublicKeyCOption_NetAddressZZ)); } + operator LDKC2Tuple_PublicKeyCOption_NetAddressZZ() && { LDKC2Tuple_PublicKeyCOption_NetAddressZZ res = self; memset(&self, 0, sizeof(LDKC2Tuple_PublicKeyCOption_NetAddressZZ)); return res; } + ~C2Tuple_PublicKeyCOption_NetAddressZZ() { C2Tuple_PublicKeyCOption_NetAddressZZ_free(self); } + C2Tuple_PublicKeyCOption_NetAddressZZ& operator=(C2Tuple_PublicKeyCOption_NetAddressZZ&& o) { C2Tuple_PublicKeyCOption_NetAddressZZ_free(self); self = o.self; memset(&o, 0, sizeof(C2Tuple_PublicKeyCOption_NetAddressZZ)); return *this; } + LDKC2Tuple_PublicKeyCOption_NetAddressZZ* operator &() { return &self; } + LDKC2Tuple_PublicKeyCOption_NetAddressZZ* operator ->() { return &self; } + const LDKC2Tuple_PublicKeyCOption_NetAddressZZ* operator &() const { return &self; } + const LDKC2Tuple_PublicKeyCOption_NetAddressZZ* operator ->() const { return &self; } }; class CResult__u832APIErrorZ { private: @@ -5909,6 +6223,21 @@ public: const LDKCResult_RoutingFeesDecodeErrorZ* operator &() const { return &self; } const LDKCResult_RoutingFeesDecodeErrorZ* operator ->() const { return &self; } }; +class CResult_NonePeerHandleErrorZ { +private: + LDKCResult_NonePeerHandleErrorZ self; +public: + CResult_NonePeerHandleErrorZ(const CResult_NonePeerHandleErrorZ&) = delete; + CResult_NonePeerHandleErrorZ(CResult_NonePeerHandleErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_NonePeerHandleErrorZ)); } + CResult_NonePeerHandleErrorZ(LDKCResult_NonePeerHandleErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_NonePeerHandleErrorZ)); } + operator LDKCResult_NonePeerHandleErrorZ() && { LDKCResult_NonePeerHandleErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_NonePeerHandleErrorZ)); return res; } + ~CResult_NonePeerHandleErrorZ() { CResult_NonePeerHandleErrorZ_free(self); } + CResult_NonePeerHandleErrorZ& operator=(CResult_NonePeerHandleErrorZ&& o) { CResult_NonePeerHandleErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_NonePeerHandleErrorZ)); return *this; } + LDKCResult_NonePeerHandleErrorZ* operator &() { return &self; } + LDKCResult_NonePeerHandleErrorZ* operator ->() { return &self; } + const LDKCResult_NonePeerHandleErrorZ* operator &() const { return &self; } + const LDKCResult_NonePeerHandleErrorZ* operator ->() const { return &self; } +}; class CResult_PayeePubKeyErrorZ { private: LDKCResult_PayeePubKeyErrorZ self; @@ -6164,6 +6493,21 @@ public: const LDKCVec_C2Tuple_u32ScriptZZ* operator &() const { return &self; } const LDKCVec_C2Tuple_u32ScriptZZ* operator ->() const { return &self; } }; +class CVec_BlindedHopZ { +private: + LDKCVec_BlindedHopZ self; +public: + CVec_BlindedHopZ(const CVec_BlindedHopZ&) = delete; + CVec_BlindedHopZ(CVec_BlindedHopZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_BlindedHopZ)); } + CVec_BlindedHopZ(LDKCVec_BlindedHopZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_BlindedHopZ)); } + operator LDKCVec_BlindedHopZ() && { LDKCVec_BlindedHopZ res = self; memset(&self, 0, sizeof(LDKCVec_BlindedHopZ)); return res; } + ~CVec_BlindedHopZ() { CVec_BlindedHopZ_free(self); } + CVec_BlindedHopZ& operator=(CVec_BlindedHopZ&& o) { CVec_BlindedHopZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_BlindedHopZ)); return *this; } + LDKCVec_BlindedHopZ* operator &() { return &self; } + LDKCVec_BlindedHopZ* operator ->() { return &self; } + const LDKCVec_BlindedHopZ* operator &() const { return &self; } + const LDKCVec_BlindedHopZ* operator ->() const { return &self; } +}; class CResult_COption_ClosureReasonZDecodeErrorZ { private: LDKCResult_COption_ClosureReasonZDecodeErrorZ self; @@ -6599,6 +6943,21 @@ public: const LDKCResult_InvoiceFeaturesDecodeErrorZ* operator &() const { return &self; } const LDKCResult_InvoiceFeaturesDecodeErrorZ* 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_ChannelMonitorUpdateDecodeErrorZ { private: LDKCResult_ChannelMonitorUpdateDecodeErrorZ self; @@ -6629,21 +6988,6 @@ public: const LDKCResult_ReplyChannelRangeDecodeErrorZ* operator &() const { return &self; } const LDKCResult_ReplyChannelRangeDecodeErrorZ* operator ->() const { return &self; } }; -class CResult_InvoiceSignOrCreationErrorZ { -private: - LDKCResult_InvoiceSignOrCreationErrorZ self; -public: - CResult_InvoiceSignOrCreationErrorZ(const CResult_InvoiceSignOrCreationErrorZ&) = delete; - CResult_InvoiceSignOrCreationErrorZ(CResult_InvoiceSignOrCreationErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_InvoiceSignOrCreationErrorZ)); } - CResult_InvoiceSignOrCreationErrorZ(LDKCResult_InvoiceSignOrCreationErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_InvoiceSignOrCreationErrorZ)); } - operator LDKCResult_InvoiceSignOrCreationErrorZ() && { LDKCResult_InvoiceSignOrCreationErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_InvoiceSignOrCreationErrorZ)); return res; } - ~CResult_InvoiceSignOrCreationErrorZ() { CResult_InvoiceSignOrCreationErrorZ_free(self); } - CResult_InvoiceSignOrCreationErrorZ& operator=(CResult_InvoiceSignOrCreationErrorZ&& o) { CResult_InvoiceSignOrCreationErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_InvoiceSignOrCreationErrorZ)); return *this; } - LDKCResult_InvoiceSignOrCreationErrorZ* operator &() { return &self; } - LDKCResult_InvoiceSignOrCreationErrorZ* operator ->() { return &self; } - const LDKCResult_InvoiceSignOrCreationErrorZ* operator &() const { return &self; } - const LDKCResult_InvoiceSignOrCreationErrorZ* operator ->() const { return &self; } -}; class CResult_TrustedClosingTransactionNoneZ { private: LDKCResult_TrustedClosingTransactionNoneZ self; @@ -6734,6 +7078,21 @@ public: const LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* operator &() const { return &self; } const LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* operator ->() const { return &self; } }; +class CResult_InvoiceSignOrCreationErrorZ { +private: + LDKCResult_InvoiceSignOrCreationErrorZ self; +public: + CResult_InvoiceSignOrCreationErrorZ(const CResult_InvoiceSignOrCreationErrorZ&) = delete; + CResult_InvoiceSignOrCreationErrorZ(CResult_InvoiceSignOrCreationErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_InvoiceSignOrCreationErrorZ)); } + CResult_InvoiceSignOrCreationErrorZ(LDKCResult_InvoiceSignOrCreationErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_InvoiceSignOrCreationErrorZ)); } + operator LDKCResult_InvoiceSignOrCreationErrorZ() && { LDKCResult_InvoiceSignOrCreationErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_InvoiceSignOrCreationErrorZ)); return res; } + ~CResult_InvoiceSignOrCreationErrorZ() { CResult_InvoiceSignOrCreationErrorZ_free(self); } + CResult_InvoiceSignOrCreationErrorZ& operator=(CResult_InvoiceSignOrCreationErrorZ&& o) { CResult_InvoiceSignOrCreationErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_InvoiceSignOrCreationErrorZ)); return *this; } + LDKCResult_InvoiceSignOrCreationErrorZ* operator &() { return &self; } + LDKCResult_InvoiceSignOrCreationErrorZ* operator ->() { return &self; } + const LDKCResult_InvoiceSignOrCreationErrorZ* operator &() const { return &self; } + const LDKCResult_InvoiceSignOrCreationErrorZ* operator ->() const { return &self; } +}; class CResult_InitFeaturesDecodeErrorZ { private: LDKCResult_InitFeaturesDecodeErrorZ self; @@ -6884,21 +7243,6 @@ public: const LDKCResult_ProbabilisticScorerDecodeErrorZ* operator &() const { return &self; } const LDKCResult_ProbabilisticScorerDecodeErrorZ* operator ->() const { return &self; } }; -class CResult_TxCreationKeysDecodeErrorZ { -private: - LDKCResult_TxCreationKeysDecodeErrorZ self; -public: - CResult_TxCreationKeysDecodeErrorZ(const CResult_TxCreationKeysDecodeErrorZ&) = delete; - CResult_TxCreationKeysDecodeErrorZ(CResult_TxCreationKeysDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_TxCreationKeysDecodeErrorZ)); } - CResult_TxCreationKeysDecodeErrorZ(LDKCResult_TxCreationKeysDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_TxCreationKeysDecodeErrorZ)); } - operator LDKCResult_TxCreationKeysDecodeErrorZ() && { LDKCResult_TxCreationKeysDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_TxCreationKeysDecodeErrorZ)); return res; } - ~CResult_TxCreationKeysDecodeErrorZ() { CResult_TxCreationKeysDecodeErrorZ_free(self); } - CResult_TxCreationKeysDecodeErrorZ& operator=(CResult_TxCreationKeysDecodeErrorZ&& o) { CResult_TxCreationKeysDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_TxCreationKeysDecodeErrorZ)); return *this; } - LDKCResult_TxCreationKeysDecodeErrorZ* operator &() { return &self; } - LDKCResult_TxCreationKeysDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_TxCreationKeysDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_TxCreationKeysDecodeErrorZ* operator ->() const { return &self; } -}; class C2Tuple_usizeTransactionZ { private: LDKC2Tuple_usizeTransactionZ self; @@ -6914,6 +7258,21 @@ public: const LDKC2Tuple_usizeTransactionZ* operator &() const { return &self; } const LDKC2Tuple_usizeTransactionZ* operator ->() const { return &self; } }; +class CResult_TxCreationKeysDecodeErrorZ { +private: + LDKCResult_TxCreationKeysDecodeErrorZ self; +public: + CResult_TxCreationKeysDecodeErrorZ(const CResult_TxCreationKeysDecodeErrorZ&) = delete; + CResult_TxCreationKeysDecodeErrorZ(CResult_TxCreationKeysDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_TxCreationKeysDecodeErrorZ)); } + CResult_TxCreationKeysDecodeErrorZ(LDKCResult_TxCreationKeysDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_TxCreationKeysDecodeErrorZ)); } + operator LDKCResult_TxCreationKeysDecodeErrorZ() && { LDKCResult_TxCreationKeysDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_TxCreationKeysDecodeErrorZ)); return res; } + ~CResult_TxCreationKeysDecodeErrorZ() { CResult_TxCreationKeysDecodeErrorZ_free(self); } + CResult_TxCreationKeysDecodeErrorZ& operator=(CResult_TxCreationKeysDecodeErrorZ&& o) { CResult_TxCreationKeysDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_TxCreationKeysDecodeErrorZ)); return *this; } + LDKCResult_TxCreationKeysDecodeErrorZ* operator &() { return &self; } + LDKCResult_TxCreationKeysDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_TxCreationKeysDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_TxCreationKeysDecodeErrorZ* operator ->() const { return &self; } +}; class CResult_NodeAnnouncementDecodeErrorZ { private: LDKCResult_NodeAnnouncementDecodeErrorZ self; @@ -6929,6 +7288,21 @@ public: const LDKCResult_NodeAnnouncementDecodeErrorZ* operator &() const { return &self; } const LDKCResult_NodeAnnouncementDecodeErrorZ* operator ->() const { return &self; } }; +class CVec_ChannelMonitorZ { +private: + LDKCVec_ChannelMonitorZ self; +public: + CVec_ChannelMonitorZ(const CVec_ChannelMonitorZ&) = delete; + CVec_ChannelMonitorZ(CVec_ChannelMonitorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_ChannelMonitorZ)); } + CVec_ChannelMonitorZ(LDKCVec_ChannelMonitorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_ChannelMonitorZ)); } + operator LDKCVec_ChannelMonitorZ() && { LDKCVec_ChannelMonitorZ res = self; memset(&self, 0, sizeof(LDKCVec_ChannelMonitorZ)); return res; } + ~CVec_ChannelMonitorZ() { CVec_ChannelMonitorZ_free(self); } + CVec_ChannelMonitorZ& operator=(CVec_ChannelMonitorZ&& o) { CVec_ChannelMonitorZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_ChannelMonitorZ)); return *this; } + LDKCVec_ChannelMonitorZ* operator &() { return &self; } + LDKCVec_ChannelMonitorZ* operator ->() { return &self; } + const LDKCVec_ChannelMonitorZ* operator &() const { return &self; } + const LDKCVec_ChannelMonitorZ* operator ->() const { return &self; } +}; class CResult_BlindedPathDecodeErrorZ { private: LDKCResult_BlindedPathDecodeErrorZ self; @@ -6944,20 +7318,20 @@ public: const LDKCResult_BlindedPathDecodeErrorZ* operator &() const { return &self; } const LDKCResult_BlindedPathDecodeErrorZ* operator ->() const { return &self; } }; -class CVec_ChannelMonitorZ { +class CVec_FutureZ { private: - LDKCVec_ChannelMonitorZ self; + LDKCVec_FutureZ self; public: - CVec_ChannelMonitorZ(const CVec_ChannelMonitorZ&) = delete; - CVec_ChannelMonitorZ(CVec_ChannelMonitorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_ChannelMonitorZ)); } - CVec_ChannelMonitorZ(LDKCVec_ChannelMonitorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_ChannelMonitorZ)); } - operator LDKCVec_ChannelMonitorZ() && { LDKCVec_ChannelMonitorZ res = self; memset(&self, 0, sizeof(LDKCVec_ChannelMonitorZ)); return res; } - ~CVec_ChannelMonitorZ() { CVec_ChannelMonitorZ_free(self); } - CVec_ChannelMonitorZ& operator=(CVec_ChannelMonitorZ&& o) { CVec_ChannelMonitorZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_ChannelMonitorZ)); return *this; } - LDKCVec_ChannelMonitorZ* operator &() { return &self; } - LDKCVec_ChannelMonitorZ* operator ->() { return &self; } - const LDKCVec_ChannelMonitorZ* operator &() const { return &self; } - const LDKCVec_ChannelMonitorZ* operator ->() const { return &self; } + 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_RouteHopDecodeErrorZ { private: @@ -7049,6 +7423,21 @@ public: const LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* operator &() const { return &self; } const LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* operator ->() const { return &self; } }; +class CVec_PathZ { +private: + LDKCVec_PathZ self; +public: + CVec_PathZ(const CVec_PathZ&) = delete; + CVec_PathZ(CVec_PathZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_PathZ)); } + CVec_PathZ(LDKCVec_PathZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_PathZ)); } + operator LDKCVec_PathZ() && { LDKCVec_PathZ res = self; memset(&self, 0, sizeof(LDKCVec_PathZ)); return res; } + ~CVec_PathZ() { CVec_PathZ_free(self); } + CVec_PathZ& operator=(CVec_PathZ&& o) { CVec_PathZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_PathZ)); return *this; } + LDKCVec_PathZ* operator &() { return &self; } + LDKCVec_PathZ* operator ->() { return &self; } + const LDKCVec_PathZ* operator &() const { return &self; } + const LDKCVec_PathZ* operator ->() const { return &self; } +}; class CResult_NetworkGraphDecodeErrorZ { private: LDKCResult_NetworkGraphDecodeErrorZ self; @@ -7094,20 +7483,20 @@ public: const LDKCVec_NodeIdZ* operator &() const { return &self; } const LDKCVec_NodeIdZ* operator ->() const { return &self; } }; -class CResult_RouteLightningErrorZ { +class CVec_u8Z { private: - LDKCResult_RouteLightningErrorZ self; + LDKCVec_u8Z self; public: - CResult_RouteLightningErrorZ(const CResult_RouteLightningErrorZ&) = delete; - CResult_RouteLightningErrorZ(CResult_RouteLightningErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_RouteLightningErrorZ)); } - CResult_RouteLightningErrorZ(LDKCResult_RouteLightningErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_RouteLightningErrorZ)); } - operator LDKCResult_RouteLightningErrorZ() && { LDKCResult_RouteLightningErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_RouteLightningErrorZ)); return res; } - ~CResult_RouteLightningErrorZ() { CResult_RouteLightningErrorZ_free(self); } - CResult_RouteLightningErrorZ& operator=(CResult_RouteLightningErrorZ&& o) { CResult_RouteLightningErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_RouteLightningErrorZ)); return *this; } - LDKCResult_RouteLightningErrorZ* operator &() { return &self; } - LDKCResult_RouteLightningErrorZ* operator ->() { return &self; } - const LDKCResult_RouteLightningErrorZ* operator &() const { return &self; } - const LDKCResult_RouteLightningErrorZ* operator ->() const { return &self; } + CVec_u8Z(const CVec_u8Z&) = delete; + CVec_u8Z(CVec_u8Z&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_u8Z)); } + CVec_u8Z(LDKCVec_u8Z&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_u8Z)); } + operator LDKCVec_u8Z() && { LDKCVec_u8Z res = self; memset(&self, 0, sizeof(LDKCVec_u8Z)); return res; } + ~CVec_u8Z() { CVec_u8Z_free(self); } + CVec_u8Z& operator=(CVec_u8Z&& o) { CVec_u8Z_free(self); self = o.self; memset(&o, 0, sizeof(CVec_u8Z)); return *this; } + LDKCVec_u8Z* operator &() { return &self; } + LDKCVec_u8Z* operator ->() { return &self; } + const LDKCVec_u8Z* operator &() const { return &self; } + const LDKCVec_u8Z* operator ->() const { return &self; } }; class CResult_ChannelPublicKeysDecodeErrorZ { private: @@ -7124,20 +7513,20 @@ public: const LDKCResult_ChannelPublicKeysDecodeErrorZ* operator &() const { return &self; } const LDKCResult_ChannelPublicKeysDecodeErrorZ* operator ->() const { return &self; } }; -class CVec_u8Z { +class CResult_RouteLightningErrorZ { private: - LDKCVec_u8Z self; + LDKCResult_RouteLightningErrorZ self; public: - CVec_u8Z(const CVec_u8Z&) = delete; - CVec_u8Z(CVec_u8Z&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_u8Z)); } - CVec_u8Z(LDKCVec_u8Z&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_u8Z)); } - operator LDKCVec_u8Z() && { LDKCVec_u8Z res = self; memset(&self, 0, sizeof(LDKCVec_u8Z)); return res; } - ~CVec_u8Z() { CVec_u8Z_free(self); } - CVec_u8Z& operator=(CVec_u8Z&& o) { CVec_u8Z_free(self); self = o.self; memset(&o, 0, sizeof(CVec_u8Z)); return *this; } - LDKCVec_u8Z* operator &() { return &self; } - LDKCVec_u8Z* operator ->() { return &self; } - const LDKCVec_u8Z* operator &() const { return &self; } - const LDKCVec_u8Z* operator ->() const { return &self; } + CResult_RouteLightningErrorZ(const CResult_RouteLightningErrorZ&) = delete; + CResult_RouteLightningErrorZ(CResult_RouteLightningErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_RouteLightningErrorZ)); } + CResult_RouteLightningErrorZ(LDKCResult_RouteLightningErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_RouteLightningErrorZ)); } + operator LDKCResult_RouteLightningErrorZ() && { LDKCResult_RouteLightningErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_RouteLightningErrorZ)); return res; } + ~CResult_RouteLightningErrorZ() { CResult_RouteLightningErrorZ_free(self); } + CResult_RouteLightningErrorZ& operator=(CResult_RouteLightningErrorZ&& o) { CResult_RouteLightningErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_RouteLightningErrorZ)); return *this; } + LDKCResult_RouteLightningErrorZ* operator &() { return &self; } + LDKCResult_RouteLightningErrorZ* operator ->() { return &self; } + const LDKCResult_RouteLightningErrorZ* operator &() const { return &self; } + const LDKCResult_RouteLightningErrorZ* operator ->() const { return &self; } }; class CResult_NonePaymentSendFailureZ { private: @@ -7379,6 +7768,21 @@ public: const LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* operator &() const { return &self; } const LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* operator ->() const { return &self; } }; +class CResult_BlindedPayInfoDecodeErrorZ { +private: + LDKCResult_BlindedPayInfoDecodeErrorZ self; +public: + CResult_BlindedPayInfoDecodeErrorZ(const CResult_BlindedPayInfoDecodeErrorZ&) = delete; + CResult_BlindedPayInfoDecodeErrorZ(CResult_BlindedPayInfoDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_BlindedPayInfoDecodeErrorZ)); } + CResult_BlindedPayInfoDecodeErrorZ(LDKCResult_BlindedPayInfoDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_BlindedPayInfoDecodeErrorZ)); } + operator LDKCResult_BlindedPayInfoDecodeErrorZ() && { LDKCResult_BlindedPayInfoDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_BlindedPayInfoDecodeErrorZ)); return res; } + ~CResult_BlindedPayInfoDecodeErrorZ() { CResult_BlindedPayInfoDecodeErrorZ_free(self); } + CResult_BlindedPayInfoDecodeErrorZ& operator=(CResult_BlindedPayInfoDecodeErrorZ&& o) { CResult_BlindedPayInfoDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_BlindedPayInfoDecodeErrorZ)); return *this; } + LDKCResult_BlindedPayInfoDecodeErrorZ* operator &() { return &self; } + LDKCResult_BlindedPayInfoDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_BlindedPayInfoDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_BlindedPayInfoDecodeErrorZ* operator ->() const { return &self; } +}; class CResult_SharedSecretNoneZ { private: LDKCResult_SharedSecretNoneZ self; @@ -7574,6 +7978,21 @@ public: const LDKCVec_RouteHintZ* operator &() const { return &self; } const LDKCVec_RouteHintZ* operator ->() const { return &self; } }; +class COption_PaymentFailureReasonZ { +private: + LDKCOption_PaymentFailureReasonZ self; +public: + COption_PaymentFailureReasonZ(const COption_PaymentFailureReasonZ&) = delete; + COption_PaymentFailureReasonZ(COption_PaymentFailureReasonZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_PaymentFailureReasonZ)); } + COption_PaymentFailureReasonZ(LDKCOption_PaymentFailureReasonZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_PaymentFailureReasonZ)); } + operator LDKCOption_PaymentFailureReasonZ() && { LDKCOption_PaymentFailureReasonZ res = self; memset(&self, 0, sizeof(LDKCOption_PaymentFailureReasonZ)); return res; } + ~COption_PaymentFailureReasonZ() { COption_PaymentFailureReasonZ_free(self); } + COption_PaymentFailureReasonZ& operator=(COption_PaymentFailureReasonZ&& o) { COption_PaymentFailureReasonZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_PaymentFailureReasonZ)); return *this; } + LDKCOption_PaymentFailureReasonZ* operator &() { return &self; } + LDKCOption_PaymentFailureReasonZ* operator ->() { return &self; } + const LDKCOption_PaymentFailureReasonZ* operator &() const { return &self; } + const LDKCOption_PaymentFailureReasonZ* operator ->() const { return &self; } +}; class COption_u16Z { private: LDKCOption_u16Z self; @@ -7589,20 +8008,35 @@ public: const LDKCOption_u16Z* operator &() const { return &self; } const LDKCOption_u16Z* operator ->() const { return &self; } }; -class CVec_CVec_RouteHopZZ { +class CVec_ChainHashZ { +private: + LDKCVec_ChainHashZ self; +public: + CVec_ChainHashZ(const CVec_ChainHashZ&) = delete; + CVec_ChainHashZ(CVec_ChainHashZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_ChainHashZ)); } + CVec_ChainHashZ(LDKCVec_ChainHashZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_ChainHashZ)); } + operator LDKCVec_ChainHashZ() && { LDKCVec_ChainHashZ res = self; memset(&self, 0, sizeof(LDKCVec_ChainHashZ)); return res; } + ~CVec_ChainHashZ() { CVec_ChainHashZ_free(self); } + CVec_ChainHashZ& operator=(CVec_ChainHashZ&& o) { CVec_ChainHashZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_ChainHashZ)); return *this; } + LDKCVec_ChainHashZ* operator &() { return &self; } + LDKCVec_ChainHashZ* operator ->() { return &self; } + const LDKCVec_ChainHashZ* operator &() const { return &self; } + const LDKCVec_ChainHashZ* operator ->() const { return &self; } +}; +class CResult_BlindedTailDecodeErrorZ { private: - LDKCVec_CVec_RouteHopZZ self; + LDKCResult_BlindedTailDecodeErrorZ self; public: - CVec_CVec_RouteHopZZ(const CVec_CVec_RouteHopZZ&) = delete; - CVec_CVec_RouteHopZZ(CVec_CVec_RouteHopZZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_CVec_RouteHopZZ)); } - CVec_CVec_RouteHopZZ(LDKCVec_CVec_RouteHopZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_CVec_RouteHopZZ)); } - operator LDKCVec_CVec_RouteHopZZ() && { LDKCVec_CVec_RouteHopZZ res = self; memset(&self, 0, sizeof(LDKCVec_CVec_RouteHopZZ)); return res; } - ~CVec_CVec_RouteHopZZ() { CVec_CVec_RouteHopZZ_free(self); } - CVec_CVec_RouteHopZZ& operator=(CVec_CVec_RouteHopZZ&& o) { CVec_CVec_RouteHopZZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_CVec_RouteHopZZ)); return *this; } - LDKCVec_CVec_RouteHopZZ* operator &() { return &self; } - LDKCVec_CVec_RouteHopZZ* operator ->() { return &self; } - const LDKCVec_CVec_RouteHopZZ* operator &() const { return &self; } - const LDKCVec_CVec_RouteHopZZ* operator ->() const { return &self; } + CResult_BlindedTailDecodeErrorZ(const CResult_BlindedTailDecodeErrorZ&) = delete; + CResult_BlindedTailDecodeErrorZ(CResult_BlindedTailDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_BlindedTailDecodeErrorZ)); } + CResult_BlindedTailDecodeErrorZ(LDKCResult_BlindedTailDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_BlindedTailDecodeErrorZ)); } + operator LDKCResult_BlindedTailDecodeErrorZ() && { LDKCResult_BlindedTailDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_BlindedTailDecodeErrorZ)); return res; } + ~CResult_BlindedTailDecodeErrorZ() { CResult_BlindedTailDecodeErrorZ_free(self); } + CResult_BlindedTailDecodeErrorZ& operator=(CResult_BlindedTailDecodeErrorZ&& o) { CResult_BlindedTailDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_BlindedTailDecodeErrorZ)); return *this; } + LDKCResult_BlindedTailDecodeErrorZ* operator &() { return &self; } + LDKCResult_BlindedTailDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_BlindedTailDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_BlindedTailDecodeErrorZ* operator ->() const { return &self; } }; class CVec_C2Tuple_PublicKeyTypeZZ { private: @@ -7724,21 +8158,6 @@ public: const LDKCResult_ChannelDetailsDecodeErrorZ* operator &() const { return &self; } const LDKCResult_ChannelDetailsDecodeErrorZ* operator ->() const { return &self; } }; -class CVec_PublicKeyZ { -private: - LDKCVec_PublicKeyZ self; -public: - CVec_PublicKeyZ(const CVec_PublicKeyZ&) = delete; - CVec_PublicKeyZ(CVec_PublicKeyZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_PublicKeyZ)); } - CVec_PublicKeyZ(LDKCVec_PublicKeyZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_PublicKeyZ)); } - operator LDKCVec_PublicKeyZ() && { LDKCVec_PublicKeyZ res = self; memset(&self, 0, sizeof(LDKCVec_PublicKeyZ)); return res; } - ~CVec_PublicKeyZ() { CVec_PublicKeyZ_free(self); } - CVec_PublicKeyZ& operator=(CVec_PublicKeyZ&& o) { CVec_PublicKeyZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_PublicKeyZ)); return *this; } - LDKCVec_PublicKeyZ* operator &() { return &self; } - LDKCVec_PublicKeyZ* operator ->() { return &self; } - const LDKCVec_PublicKeyZ* operator &() const { return &self; } - const LDKCVec_PublicKeyZ* operator ->() const { return &self; } -}; class CVec_C2Tuple_usizeTransactionZZ { private: LDKCVec_C2Tuple_usizeTransactionZZ self; @@ -7754,6 +8173,21 @@ public: const LDKCVec_C2Tuple_usizeTransactionZZ* operator &() const { return &self; } const LDKCVec_C2Tuple_usizeTransactionZZ* operator ->() const { return &self; } }; +class CVec_PublicKeyZ { +private: + LDKCVec_PublicKeyZ self; +public: + CVec_PublicKeyZ(const CVec_PublicKeyZ&) = delete; + CVec_PublicKeyZ(CVec_PublicKeyZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_PublicKeyZ)); } + CVec_PublicKeyZ(LDKCVec_PublicKeyZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_PublicKeyZ)); } + operator LDKCVec_PublicKeyZ() && { LDKCVec_PublicKeyZ res = self; memset(&self, 0, sizeof(LDKCVec_PublicKeyZ)); return res; } + ~CVec_PublicKeyZ() { CVec_PublicKeyZ_free(self); } + CVec_PublicKeyZ& operator=(CVec_PublicKeyZ&& o) { CVec_PublicKeyZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_PublicKeyZ)); return *this; } + LDKCVec_PublicKeyZ* operator &() { return &self; } + LDKCVec_PublicKeyZ* operator ->() { return &self; } + const LDKCVec_PublicKeyZ* operator &() const { return &self; } + const LDKCVec_PublicKeyZ* operator ->() const { return &self; } +}; class C2Tuple_u64u64Z { private: LDKC2Tuple_u64u64Z self; @@ -7769,6 +8203,21 @@ public: const LDKC2Tuple_u64u64Z* operator &() const { return &self; } const LDKC2Tuple_u64u64Z* operator ->() const { return &self; } }; +class CResult_RecipientOnionFieldsDecodeErrorZ { +private: + LDKCResult_RecipientOnionFieldsDecodeErrorZ self; +public: + CResult_RecipientOnionFieldsDecodeErrorZ(const CResult_RecipientOnionFieldsDecodeErrorZ&) = delete; + CResult_RecipientOnionFieldsDecodeErrorZ(CResult_RecipientOnionFieldsDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_RecipientOnionFieldsDecodeErrorZ)); } + CResult_RecipientOnionFieldsDecodeErrorZ(LDKCResult_RecipientOnionFieldsDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_RecipientOnionFieldsDecodeErrorZ)); } + operator LDKCResult_RecipientOnionFieldsDecodeErrorZ() && { LDKCResult_RecipientOnionFieldsDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_RecipientOnionFieldsDecodeErrorZ)); return res; } + ~CResult_RecipientOnionFieldsDecodeErrorZ() { CResult_RecipientOnionFieldsDecodeErrorZ_free(self); } + CResult_RecipientOnionFieldsDecodeErrorZ& operator=(CResult_RecipientOnionFieldsDecodeErrorZ&& o) { CResult_RecipientOnionFieldsDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_RecipientOnionFieldsDecodeErrorZ)); return *this; } + LDKCResult_RecipientOnionFieldsDecodeErrorZ* operator &() { return &self; } + LDKCResult_RecipientOnionFieldsDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_RecipientOnionFieldsDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_RecipientOnionFieldsDecodeErrorZ* operator ->() const { return &self; } +}; class C2Tuple_u32TxOutZ { private: LDKC2Tuple_u32TxOutZ self; @@ -8009,6 +8458,21 @@ public: const LDKCResult_boolPeerHandleErrorZ* operator &() const { return &self; } const LDKCResult_boolPeerHandleErrorZ* operator ->() const { return &self; } }; +class CVec_AddressZ { +private: + LDKCVec_AddressZ self; +public: + CVec_AddressZ(const CVec_AddressZ&) = delete; + CVec_AddressZ(CVec_AddressZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_AddressZ)); } + CVec_AddressZ(LDKCVec_AddressZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_AddressZ)); } + operator LDKCVec_AddressZ() && { LDKCVec_AddressZ res = self; memset(&self, 0, sizeof(LDKCVec_AddressZ)); return res; } + ~CVec_AddressZ() { CVec_AddressZ_free(self); } + CVec_AddressZ& operator=(CVec_AddressZ&& o) { CVec_AddressZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_AddressZ)); return *this; } + LDKCVec_AddressZ* operator &() { return &self; } + LDKCVec_AddressZ* operator ->() { return &self; } + const LDKCVec_AddressZ* operator &() const { return &self; } + const LDKCVec_AddressZ* operator ->() const { return &self; } +}; class CResult_ChannelUpdateDecodeErrorZ { private: LDKCResult_ChannelUpdateDecodeErrorZ self; @@ -8129,6 +8593,21 @@ public: const LDKCOption_NoneZ* operator &() const { return &self; } const LDKCOption_NoneZ* operator ->() const { return &self; } }; +class COption_CVec_u8ZZ { +private: + LDKCOption_CVec_u8ZZ self; +public: + COption_CVec_u8ZZ(const COption_CVec_u8ZZ&) = delete; + COption_CVec_u8ZZ(COption_CVec_u8ZZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_CVec_u8ZZ)); } + COption_CVec_u8ZZ(LDKCOption_CVec_u8ZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_CVec_u8ZZ)); } + operator LDKCOption_CVec_u8ZZ() && { LDKCOption_CVec_u8ZZ res = self; memset(&self, 0, sizeof(LDKCOption_CVec_u8ZZ)); return res; } + ~COption_CVec_u8ZZ() { COption_CVec_u8ZZ_free(self); } + COption_CVec_u8ZZ& operator=(COption_CVec_u8ZZ&& o) { COption_CVec_u8ZZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_CVec_u8ZZ)); return *this; } + LDKCOption_CVec_u8ZZ* operator &() { return &self; } + LDKCOption_CVec_u8ZZ* operator ->() { return &self; } + const LDKCOption_CVec_u8ZZ* operator &() const { return &self; } + const LDKCOption_CVec_u8ZZ* operator ->() const { return &self; } +}; inline LDK::CResult_RouteLightningErrorZ Router::find_route(struct LDKPublicKey payer, const struct LDKRouteParameters *NONNULL_PTR route_params, struct LDKCVec_ChannelDetailsZ *first_hops, const struct LDKInFlightHtlcs *NONNULL_PTR inflight_htlcs) { LDK::CResult_RouteLightningErrorZ ret = (self.find_route)(self.this_arg, payer, route_params, first_hops, inflight_htlcs); @@ -8145,20 +8624,6 @@ inline uint32_t FeeEstimator::get_est_sat_per_1000_weight(enum LDKConfirmationTa uint32_t ret = (self.get_est_sat_per_1000_weight)(self.this_arg, confirmation_target); return ret; } -inline LDK::CVec_MessageSendEventZ MessageSendEventsProvider::get_and_clear_pending_msg_events() { - LDK::CVec_MessageSendEventZ ret = (self.get_and_clear_pending_msg_events)(self.this_arg); - return ret; -} -inline LDK::OnionMessage OnionMessageProvider::next_onion_message_for_peer(struct LDKPublicKey peer_node_id) { - LDK::OnionMessage ret = (self.next_onion_message_for_peer)(self.this_arg, peer_node_id); - return ret; -} -inline void EventsProvider::process_pending_events(struct LDKEventHandler handler) { - (self.process_pending_events)(self.this_arg, handler); -} -inline void EventHandler::handle_event(struct LDKEvent event) { - (self.handle_event)(self.this_arg, event); -} inline void Listen::filtered_block_connected(const uint8_t (*header)[80], struct LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) { (self.filtered_block_connected)(self.this_arg, header, txdata, height); } @@ -8203,16 +8668,16 @@ inline uint64_t Score::channel_penalty_msat(uint64_t short_channel_id, const str uint64_t ret = (self.channel_penalty_msat)(self.this_arg, short_channel_id, source, target, usage); return ret; } -inline void Score::payment_path_failed(struct LDKCVec_RouteHopZ path, uint64_t short_channel_id) { +inline void Score::payment_path_failed(const struct LDKPath *NONNULL_PTR path, uint64_t short_channel_id) { (self.payment_path_failed)(self.this_arg, path, short_channel_id); } -inline void Score::payment_path_successful(struct LDKCVec_RouteHopZ path) { +inline void Score::payment_path_successful(const struct LDKPath *NONNULL_PTR path) { (self.payment_path_successful)(self.this_arg, path); } -inline void Score::probe_failed(struct LDKCVec_RouteHopZ path, uint64_t short_channel_id) { +inline void Score::probe_failed(const struct LDKPath *NONNULL_PTR path, uint64_t short_channel_id) { (self.probe_failed)(self.this_arg, path, short_channel_id); } -inline void Score::probe_successful(struct LDKCVec_RouteHopZ path) { +inline void Score::probe_successful(const struct LDKPath *NONNULL_PTR path) { (self.probe_successful)(self.this_arg, path); } inline LDK::Score LockableScore::lock() { @@ -8223,6 +8688,20 @@ inline uint64_t CustomOnionMessageContents::tlv_type() { uint64_t ret = (self.tlv_type)(self.this_arg); return ret; } +inline LDK::CVec_MessageSendEventZ MessageSendEventsProvider::get_and_clear_pending_msg_events() { + LDK::CVec_MessageSendEventZ ret = (self.get_and_clear_pending_msg_events)(self.this_arg); + return ret; +} +inline LDK::OnionMessage OnionMessageProvider::next_onion_message_for_peer(struct LDKPublicKey peer_node_id) { + LDK::OnionMessage ret = (self.next_onion_message_for_peer)(self.this_arg, peer_node_id); + return ret; +} +inline void EventsProvider::process_pending_events(struct LDKEventHandler handler) { + (self.process_pending_events)(self.this_arg, handler); +} +inline void EventHandler::handle_event(struct LDKEvent event) { + (self.handle_event)(self.this_arg, event); +} inline LDKPublicKey ChannelSigner::get_per_commitment_point(uint64_t idx) { LDKPublicKey ret = (self.get_per_commitment_point)(self.this_arg, idx); return ret; diff --git a/lightning-c-bindings/src/c_types/derived.rs b/lightning-c-bindings/src/c_types/derived.rs index f763965..9b47257 100644 --- a/lightning-c-bindings/src/c_types/derived.rs +++ b/lightning-c-bindings/src/c_types/derived.rs @@ -7,6 +7,126 @@ use crate::c_types::*; #[cfg(feature="no-std")] use alloc::{vec::Vec, boxed::Box}; +#[repr(C)] +#[derive(Clone)] +/// An enum which can either contain a u64 or not +pub enum COption_DurationZ { + /// When we're in this state, this COption_DurationZ contains a u64 + Some(u64), + /// When we're in this state, this COption_DurationZ contains nothing + None +} +impl COption_DurationZ { + #[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) -> u64 { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_DurationZ containing a u64 +pub extern "C" fn COption_DurationZ_some(o: u64) -> COption_DurationZ { + COption_DurationZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_DurationZ containing nothing +pub extern "C" fn COption_DurationZ_none() -> COption_DurationZ { + COption_DurationZ::None +} +#[no_mangle] +/// Frees any resources associated with the u64, if we are in the Some state +pub extern "C" fn COption_DurationZ_free(_res: COption_DurationZ) { } +#[no_mangle] +/// Creates a new COption_DurationZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_DurationZ_clone(orig: &COption_DurationZ) -> COption_DurationZ { Clone::clone(&orig) } +#[repr(C)] +/// A dynamically-allocated array of crate::lightning::blinded_path::BlindedPaths of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_BlindedPathZ { + /// 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, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_BlindedPathZ { + #[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] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_BlindedPathZ { + 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_BlindedPathZ_free(_res: CVec_BlindedPathZ) { } +impl Drop for CVec_BlindedPathZ { + 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 { + 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 u64 or not +pub enum COption_u64Z { + /// When we're in this state, this COption_u64Z contains a u64 + Some(u64), + /// When we're in this state, this COption_u64Z contains nothing + None +} +impl COption_u64Z { + #[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) -> u64 { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_u64Z containing a u64 +pub extern "C" fn COption_u64Z_some(o: u64) -> COption_u64Z { + COption_u64Z::Some(o) +} +#[no_mangle] +/// Constructs a new COption_u64Z containing nothing +pub extern "C" fn COption_u64Z_none() -> COption_u64Z { + COption_u64Z::None +} +#[no_mangle] +/// Frees any resources associated with the u64, if we are in the Some state +pub extern "C" fn COption_u64Z_free(_res: COption_u64Z) { } +#[no_mangle] +/// Creates a new COption_u64Z which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_u64Z_clone(orig: &COption_u64Z) -> COption_u64Z { Clone::clone(&orig) } #[repr(C)] /// The contents of CResult_NoneAPIErrorZ pub union CResult_NoneAPIErrorZPtr { @@ -192,6 +312,185 @@ impl Clone for CVec_APIErrorZ { } } #[repr(C)] +/// A dynamically-allocated array of u8s of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_u8Z { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut u8, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_u8Z { + #[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) -> &[u8] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_u8Z { + 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_u8Z_free(_res: CVec_u8Z) { } +impl Drop for CVec_u8Z { + 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_u8Z { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +#[derive(Clone)] +/// An enum which can either contain a crate::c_types::derived::CVec_u8Z or not +pub enum COption_CVec_u8ZZ { + /// When we're in this state, this COption_CVec_u8ZZ contains a crate::c_types::derived::CVec_u8Z + Some(crate::c_types::derived::CVec_u8Z), + /// When we're in this state, this COption_CVec_u8ZZ contains nothing + None +} +impl COption_CVec_u8ZZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::derived::CVec_u8Z { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_CVec_u8ZZ containing a crate::c_types::derived::CVec_u8Z +pub extern "C" fn COption_CVec_u8ZZ_some(o: crate::c_types::derived::CVec_u8Z) -> COption_CVec_u8ZZ { + COption_CVec_u8ZZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_CVec_u8ZZ containing nothing +pub extern "C" fn COption_CVec_u8ZZ_none() -> COption_CVec_u8ZZ { + COption_CVec_u8ZZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::c_types::derived::CVec_u8Z, if we are in the Some state +pub extern "C" fn COption_CVec_u8ZZ_free(_res: COption_CVec_u8ZZ) { } +#[no_mangle] +/// Creates a new COption_CVec_u8ZZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_CVec_u8ZZ_clone(orig: &COption_CVec_u8ZZ) -> COption_CVec_u8ZZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_RecipientOnionFieldsDecodeErrorZ +pub union CResult_RecipientOnionFieldsDecodeErrorZPtr { + /// A 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::outbound_payment::RecipientOnionFields, + /// A 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_RecipientOnionFieldsDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::outbound_payment::RecipientOnionFields 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_RecipientOnionFieldsDecodeErrorZ { + /// The contents of this CResult_RecipientOnionFieldsDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_RecipientOnionFieldsDecodeErrorZPtr, + /// Whether this CResult_RecipientOnionFieldsDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_RecipientOnionFieldsDecodeErrorZ in the success state. +pub extern "C" fn CResult_RecipientOnionFieldsDecodeErrorZ_ok(o: crate::lightning::ln::outbound_payment::RecipientOnionFields) -> CResult_RecipientOnionFieldsDecodeErrorZ { + CResult_RecipientOnionFieldsDecodeErrorZ { + contents: CResult_RecipientOnionFieldsDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_RecipientOnionFieldsDecodeErrorZ in the error state. +pub extern "C" fn CResult_RecipientOnionFieldsDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_RecipientOnionFieldsDecodeErrorZ { + CResult_RecipientOnionFieldsDecodeErrorZ { + contents: CResult_RecipientOnionFieldsDecodeErrorZPtr { + 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_RecipientOnionFieldsDecodeErrorZ_is_ok(o: &CResult_RecipientOnionFieldsDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_RecipientOnionFieldsDecodeErrorZ. +pub extern "C" fn CResult_RecipientOnionFieldsDecodeErrorZ_free(_res: CResult_RecipientOnionFieldsDecodeErrorZ) { } +impl Drop for CResult_RecipientOnionFieldsDecodeErrorZ { + 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_RecipientOnionFieldsDecodeErrorZ { + fn from(mut o: crate::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_RecipientOnionFieldsDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_RecipientOnionFieldsDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_RecipientOnionFieldsDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_RecipientOnionFieldsDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_RecipientOnionFieldsDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_RecipientOnionFieldsDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_RecipientOnionFieldsDecodeErrorZ_clone(orig: &CResult_RecipientOnionFieldsDecodeErrorZ) -> CResult_RecipientOnionFieldsDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] /// An enum which can either contain a crate::lightning::ln::chan_utils::HTLCClaim or not pub enum COption_HTLCClaimZ { /// When we're in this state, this COption_HTLCClaimZ contains a crate::lightning::ln::chan_utils::HTLCClaim @@ -1722,275 +2021,41 @@ impl Clone for CResult_ShutdownScriptInvalidShutdownScriptZ { /// 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::PublicKeys of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_PublicKeyZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::PublicKey, - /// The number of elements pointed to by `data`. - pub datalen: usize +/// The contents of CResult_BlindedPayInfoDecodeErrorZ +pub union CResult_BlindedPayInfoDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::offers::invoice::BlindedPayInfo, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, } -impl CVec_PublicKeyZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::PublicKey] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_PublicKeyZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_PublicKeyZ_free(_res: CVec_PublicKeyZ) { } -impl Drop for CVec_PublicKeyZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_PublicKeyZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} -#[repr(C)] -/// The contents of CResult_BlindedPathNoneZ -pub union CResult_BlindedPathNoneZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::onion_message::blinded_path::BlindedPath, - /// Note that this value is always NULL, as there are no contents in the Err variant - pub err: *mut core::ffi::c_void, -} -#[repr(C)] -/// A CResult_BlindedPathNoneZ represents the result of a fallible operation, -/// containing a crate::lightning::onion_message::blinded_path::BlindedPath on success and a () on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_BlindedPathNoneZ { - /// The contents of this CResult_BlindedPathNoneZ, 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 result_ok: bool, -} -#[no_mangle] -/// Creates a new CResult_BlindedPathNoneZ in the success state. -pub extern "C" fn CResult_BlindedPathNoneZ_ok(o: crate::lightning::onion_message::blinded_path::BlindedPath) -> CResult_BlindedPathNoneZ { - CResult_BlindedPathNoneZ { - contents: CResult_BlindedPathNoneZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, - } -} -#[no_mangle] -/// Creates a new CResult_BlindedPathNoneZ in the error state. -pub extern "C" fn CResult_BlindedPathNoneZ_err() -> CResult_BlindedPathNoneZ { - CResult_BlindedPathNoneZ { - contents: CResult_BlindedPathNoneZPtr { - err: core::ptr::null_mut(), - }, - result_ok: false, - } -} -/// Checks if the given object is currently in the success state -#[no_mangle] -pub extern "C" fn CResult_BlindedPathNoneZ_is_ok(o: &CResult_BlindedPathNoneZ) -> 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 { - 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_BlindedPathNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { - let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_BlindedPathNoneZPtr { result } - } else { - let _ = unsafe { Box::from_raw(o.contents.err) }; - o.contents.err = core::ptr::null_mut(); - CResult_BlindedPathNoneZPtr { err: core::ptr::null_mut() } - }; - Self { - contents, - result_ok: o.result_ok, - } - } -} -impl Clone for CResult_BlindedPathNoneZ { - fn clone(&self) -> Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_BlindedPathNoneZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_BlindedPathNoneZPtr { - err: core::ptr::null_mut() - } } - } - } -} -#[no_mangle] -/// Creates a new CResult_BlindedPathNoneZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_BlindedPathNoneZ_clone(orig: &CResult_BlindedPathNoneZ) -> CResult_BlindedPathNoneZ { Clone::clone(&orig) } -#[repr(C)] -/// The contents of CResult_BlindedPathDecodeErrorZ -pub union CResult_BlindedPathDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::onion_message::blinded_path::BlindedPath, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, -} -#[repr(C)] -/// A CResult_BlindedPathDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::onion_message::blinded_path::BlindedPath on success and a crate::lightning::ln::msgs::DecodeError on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_BlindedPathDecodeErrorZ { - /// The contents of this CResult_BlindedPathDecodeErrorZ, 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 result_ok: bool, +#[repr(C)] +/// A CResult_BlindedPayInfoDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::offers::invoice::BlindedPayInfo on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_BlindedPayInfoDecodeErrorZ { + /// The contents of this CResult_BlindedPayInfoDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_BlindedPayInfoDecodeErrorZPtr, + /// Whether this CResult_BlindedPayInfoDecodeErrorZ represents a success state. + pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_BlindedPathDecodeErrorZ in the success state. -pub extern "C" fn CResult_BlindedPathDecodeErrorZ_ok(o: crate::lightning::onion_message::blinded_path::BlindedPath) -> CResult_BlindedPathDecodeErrorZ { - CResult_BlindedPathDecodeErrorZ { - contents: CResult_BlindedPathDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, - } -} -#[no_mangle] -/// Creates a new CResult_BlindedPathDecodeErrorZ in the error state. -pub extern "C" fn CResult_BlindedPathDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_BlindedPathDecodeErrorZ { - CResult_BlindedPathDecodeErrorZ { - contents: CResult_BlindedPathDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), - }, - result_ok: false, - } -} -/// 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 { - 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 { - 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_BlindedPathDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { - let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_BlindedPathDecodeErrorZPtr { result } - } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_BlindedPathDecodeErrorZPtr { err } - }; - Self { - contents, - result_ok: o.result_ok, - } - } -} -impl Clone for CResult_BlindedPathDecodeErrorZ { - fn clone(&self) -> 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 }))) - } } - } - } -} -#[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) } -#[repr(C)] -/// The contents of CResult_BlindedHopDecodeErrorZ -pub union CResult_BlindedHopDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::onion_message::blinded_path::BlindedHop, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, -} -#[repr(C)] -/// A CResult_BlindedHopDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::onion_message::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_BlindedHopDecodeErrorZ { - /// The contents of this CResult_BlindedHopDecodeErrorZ, 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 result_ok: bool, -} -#[no_mangle] -/// Creates a new CResult_BlindedHopDecodeErrorZ in the success state. -pub extern "C" fn CResult_BlindedHopDecodeErrorZ_ok(o: crate::lightning::onion_message::blinded_path::BlindedHop) -> CResult_BlindedHopDecodeErrorZ { - CResult_BlindedHopDecodeErrorZ { - contents: CResult_BlindedHopDecodeErrorZPtr { +/// Creates a new CResult_BlindedPayInfoDecodeErrorZ in the success state. +pub extern "C" fn CResult_BlindedPayInfoDecodeErrorZ_ok(o: crate::lightning::offers::invoice::BlindedPayInfo) -> CResult_BlindedPayInfoDecodeErrorZ { + CResult_BlindedPayInfoDecodeErrorZ { + contents: CResult_BlindedPayInfoDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_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_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, @@ -1998,13 +2063,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_BlindedPayInfoDecodeErrorZ_is_ok(o: &CResult_BlindedPayInfoDecodeErrorZ) -> 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_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() } { @@ -2017,16 +2082,16 @@ impl Drop for CResult_BlindedHopDecodeErrorZ { } } } -impl From> for CResult_BlindedHopDecodeErrorZ { - 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_BlindedHopDecodeErrorZPtr { result } + CResult_BlindedPayInfoDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_BlindedHopDecodeErrorZPtr { err } + CResult_BlindedPayInfoDecodeErrorZPtr { err } }; Self { contents, @@ -2034,23 +2099,23 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_BlindedHopDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_BlindedPayInfoDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_BlindedHopDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_BlindedPayInfoDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_BlindedHopDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_BlindedPayInfoDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_BlindedHopDecodeErrorZ_clone(orig: &CResult_BlindedHopDecodeErrorZ) -> CResult_BlindedHopDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_BlindedPayInfoDecodeErrorZ_clone(orig: &CResult_BlindedPayInfoDecodeErrorZ) -> CResult_BlindedPayInfoDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] /// An enum which can either contain a crate::lightning::routing::scoring::WriteableScore or not pub enum COption_WriteableScoreZ { @@ -2318,97 +2383,14 @@ impl Clone for CResult_RouteLightningErrorZ { /// 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::lightning::routing::router::RouteHops of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_RouteHopZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::routing::router::RouteHop, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_RouteHopZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::routing::router::RouteHop] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_RouteHopZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_RouteHopZ_free(_res: CVec_RouteHopZ) { } -impl Drop for CVec_RouteHopZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_RouteHopZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} -#[repr(C)] -#[derive(Clone)] -/// An enum which can either contain a u64 or not -pub enum COption_u64Z { - /// When we're in this state, this COption_u64Z contains a u64 - Some(u64), - /// When we're in this state, this COption_u64Z contains nothing - None -} -impl COption_u64Z { - #[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) -> u64 { - if let Self::Some(v) = self { v } else { unreachable!() } - } -} -#[no_mangle] -/// Constructs a new COption_u64Z containing a u64 -pub extern "C" fn COption_u64Z_some(o: u64) -> COption_u64Z { - COption_u64Z::Some(o) -} -#[no_mangle] -/// Constructs a new COption_u64Z containing nothing -pub extern "C" fn COption_u64Z_none() -> COption_u64Z { - COption_u64Z::None -} -#[no_mangle] -/// Frees any resources associated with the u64, if we are in the Some state -pub extern "C" fn COption_u64Z_free(_res: COption_u64Z) { } -#[no_mangle] -/// Creates a new COption_u64Z which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_u64Z_clone(orig: &COption_u64Z) -> COption_u64Z { Clone::clone(&orig) } -#[repr(C)] -/// The contents of CResult_InFlightHtlcsDecodeErrorZ -pub union CResult_InFlightHtlcsDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::routing::router::InFlightHtlcs, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, +/// The contents of CResult_InFlightHtlcsDecodeErrorZ +pub union CResult_InFlightHtlcsDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::routing::router::InFlightHtlcs, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] /// A CResult_InFlightHtlcsDecodeErrorZ represents the result of a fallible operation, @@ -2593,29 +2575,217 @@ impl Clone for CResult_RouteHopDecodeErrorZ { /// but with all dynamically-allocated buffers duplicated in new buffers. pub extern "C" fn CResult_RouteHopDecodeErrorZ_clone(orig: &CResult_RouteHopDecodeErrorZ) -> CResult_RouteHopDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// A dynamically-allocated array of crate::c_types::derived::CVec_RouteHopZs of arbitrary size. +/// A dynamically-allocated array of crate::lightning::blinded_path::BlindedHops of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_BlindedHopZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::blinded_path::BlindedHop, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_BlindedHopZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::blinded_path::BlindedHop] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_BlindedHopZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_BlindedHopZ_free(_res: CVec_BlindedHopZ) { } +impl Drop for CVec_BlindedHopZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_BlindedHopZ { + 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_BlindedTailDecodeErrorZ +pub union CResult_BlindedTailDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::routing::router::BlindedTail, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_BlindedTailDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::routing::router::BlindedTail on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_BlindedTailDecodeErrorZ { + /// The contents of this CResult_BlindedTailDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_BlindedTailDecodeErrorZPtr, + /// Whether this CResult_BlindedTailDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_BlindedTailDecodeErrorZ in the success state. +pub extern "C" fn CResult_BlindedTailDecodeErrorZ_ok(o: crate::lightning::routing::router::BlindedTail) -> CResult_BlindedTailDecodeErrorZ { + CResult_BlindedTailDecodeErrorZ { + contents: CResult_BlindedTailDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_BlindedTailDecodeErrorZ in the error state. +pub extern "C" fn CResult_BlindedTailDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_BlindedTailDecodeErrorZ { + CResult_BlindedTailDecodeErrorZ { + contents: CResult_BlindedTailDecodeErrorZPtr { + 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_BlindedTailDecodeErrorZ_is_ok(o: &CResult_BlindedTailDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_BlindedTailDecodeErrorZ. +pub extern "C" fn CResult_BlindedTailDecodeErrorZ_free(_res: CResult_BlindedTailDecodeErrorZ) { } +impl Drop for CResult_BlindedTailDecodeErrorZ { + 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_BlindedTailDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_BlindedTailDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_BlindedTailDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_BlindedTailDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_BlindedTailDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_BlindedTailDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_BlindedTailDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_BlindedTailDecodeErrorZ_clone(orig: &CResult_BlindedTailDecodeErrorZ) -> CResult_BlindedTailDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// A dynamically-allocated array of crate::lightning::routing::router::RouteHops of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_RouteHopZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::routing::router::RouteHop, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_RouteHopZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::routing::router::RouteHop] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_RouteHopZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_RouteHopZ_free(_res: CVec_RouteHopZ) { } +impl Drop for CVec_RouteHopZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_RouteHopZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// A dynamically-allocated array of crate::lightning::routing::router::Paths of arbitrary size. /// This corresponds to std::vector in C++ -pub struct CVec_CVec_RouteHopZZ { +pub struct CVec_PathZ { /// The elements in the array. /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::derived::CVec_RouteHopZ, + pub data: *mut crate::lightning::routing::router::Path, /// The number of elements pointed to by `data`. pub datalen: usize } -impl CVec_CVec_RouteHopZZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { +impl CVec_PathZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { if self.datalen == 0 { return Vec::new(); } let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); self.data = core::ptr::null_mut(); self.datalen = 0; ret } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::CVec_RouteHopZ] { + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::routing::router::Path] { unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl From> for CVec_CVec_RouteHopZZ { - fn from(v: Vec) -> Self { +impl From> for CVec_PathZ { + fn from(v: Vec) -> Self { let datalen = v.len(); let data = Box::into_raw(v.into_boxed_slice()); Self { datalen, data: unsafe { (*data).as_mut_ptr() } } @@ -2623,14 +2793,14 @@ impl From> for CVec_CVec_RouteHopZZ } #[no_mangle] /// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_CVec_RouteHopZZ_free(_res: CVec_CVec_RouteHopZZ) { } -impl Drop for CVec_CVec_RouteHopZZ { +pub extern "C" fn CVec_PathZ_free(_res: CVec_PathZ) { } +impl Drop for CVec_PathZ { fn drop(&mut self) { if self.datalen == 0 { return; } let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl Clone for CVec_CVec_RouteHopZZ { +impl Clone for CVec_PathZ { fn clone(&self) -> Self { let mut res = Vec::new(); if self.datalen == 0 { return Self::from(res); } @@ -2831,29 +3001,29 @@ impl Clone for CResult_RouteParametersDecodeErrorZ { /// but with all dynamically-allocated buffers duplicated in new buffers. pub extern "C" fn CResult_RouteParametersDecodeErrorZ_clone(orig: &CResult_RouteParametersDecodeErrorZ) -> CResult_RouteParametersDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// A dynamically-allocated array of crate::lightning::routing::router::RouteHints of arbitrary size. +/// A dynamically-allocated array of u64s of arbitrary size. /// This corresponds to std::vector in C++ -pub struct CVec_RouteHintZ { +pub struct CVec_u64Z { /// The elements in the array. /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::routing::router::RouteHint, + pub data: *mut u64, /// The number of elements pointed to by `data`. pub datalen: usize } -impl CVec_RouteHintZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { +impl CVec_u64Z { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { if self.datalen == 0 { return Vec::new(); } let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); self.data = core::ptr::null_mut(); self.datalen = 0; ret } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::routing::router::RouteHint] { + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[u64] { 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_u64Z { + fn from(v: Vec) -> Self { let datalen = v.len(); let data = Box::into_raw(v.into_boxed_slice()); Self { datalen, data: unsafe { (*data).as_mut_ptr() } } @@ -2861,60 +3031,14 @@ impl From> for CVec_RouteHintZ } #[no_mangle] /// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_RouteHintZ_free(_res: CVec_RouteHintZ) { } -impl Drop for CVec_RouteHintZ { +pub extern "C" fn CVec_u64Z_free(_res: CVec_u64Z) { } +impl Drop for CVec_u64Z { fn drop(&mut self) { if self.datalen == 0 { return; } let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl Clone for CVec_RouteHintZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} -#[repr(C)] -/// A dynamically-allocated array of u64s of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_u64Z { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut u64, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_u64Z { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[u64] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_u64Z { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_u64Z_free(_res: CVec_u64Z) { } -impl Drop for CVec_u64Z { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_u64Z { +impl Clone for CVec_u64Z { fn clone(&self) -> Self { let mut res = Vec::new(); if self.datalen == 0 { return Self::from(res); } @@ -3019,6 +3143,140 @@ 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 tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_BlindedPayInfoBlindedPathZ { + /// The element at position 0 + pub a: crate::lightning::offers::invoice::BlindedPayInfo, + /// The element at position 1 + pub b: crate::lightning::blinded_path::BlindedPath, +} +impl From<(crate::lightning::offers::invoice::BlindedPayInfo, crate::lightning::blinded_path::BlindedPath)> for C2Tuple_BlindedPayInfoBlindedPathZ { + fn from (tup: (crate::lightning::offers::invoice::BlindedPayInfo, crate::lightning::blinded_path::BlindedPath)) -> Self { + Self { + a: tup.0, + b: tup.1, + } + } +} +impl C2Tuple_BlindedPayInfoBlindedPathZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::lightning::offers::invoice::BlindedPayInfo, crate::lightning::blinded_path::BlindedPath) { + (self.a, self.b) + } +} +impl Clone for C2Tuple_BlindedPayInfoBlindedPathZ { + fn clone(&self) -> Self { + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), + } + } +} +#[no_mangle] +/// Creates a new tuple which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn C2Tuple_BlindedPayInfoBlindedPathZ_clone(orig: &C2Tuple_BlindedPayInfoBlindedPathZ) -> C2Tuple_BlindedPayInfoBlindedPathZ { Clone::clone(&orig) } +/// Creates a new C2Tuple_BlindedPayInfoBlindedPathZ from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_BlindedPayInfoBlindedPathZ_new(a: crate::lightning::offers::invoice::BlindedPayInfo, b: crate::lightning::blinded_path::BlindedPath) -> C2Tuple_BlindedPayInfoBlindedPathZ { + C2Tuple_BlindedPayInfoBlindedPathZ { a, b, } +} + +#[no_mangle] +/// Frees any resources used by the C2Tuple_BlindedPayInfoBlindedPathZ. +pub extern "C" fn C2Tuple_BlindedPayInfoBlindedPathZ_free(_res: C2Tuple_BlindedPayInfoBlindedPathZ) { } +#[repr(C)] +/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_BlindedPayInfoBlindedPathZs of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_C2Tuple_BlindedPayInfoBlindedPathZZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::derived::C2Tuple_BlindedPayInfoBlindedPathZ, + /// 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 { + 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] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_C2Tuple_BlindedPayInfoBlindedPathZZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[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 { + 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 { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// A dynamically-allocated array of crate::lightning::routing::router::RouteHints of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_RouteHintZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::routing::router::RouteHint, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_RouteHintZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::routing::router::RouteHint] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +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() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_RouteHintZ_free(_res: CVec_RouteHintZ) { } +impl Drop for CVec_RouteHintZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_RouteHintZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[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 { @@ -3257,344 +3515,401 @@ impl Clone for CResult_RouteHintHopDecodeErrorZ { /// but with all dynamically-allocated buffers duplicated in new buffers. pub extern "C" fn CResult_RouteHintHopDecodeErrorZ_clone(orig: &CResult_RouteHintHopDecodeErrorZ) -> CResult_RouteHintHopDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_PaymentPurposeDecodeErrorZ -pub union CResult_PaymentPurposeDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::util::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_PaymentPurposeDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::util::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_PaymentPurposeDecodeErrorZ { - /// The contents of this CResult_PaymentPurposeDecodeErrorZ, 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 result_ok: bool, +/// A dynamically-allocated array of crate::c_types::PublicKeys of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_PublicKeyZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::PublicKey, + /// The number of elements pointed to by `data`. + pub datalen: usize } -#[no_mangle] -/// Creates a new CResult_PaymentPurposeDecodeErrorZ in the success state. -pub extern "C" fn CResult_PaymentPurposeDecodeErrorZ_ok(o: crate::lightning::util::events::PaymentPurpose) -> CResult_PaymentPurposeDecodeErrorZ { - CResult_PaymentPurposeDecodeErrorZ { - contents: CResult_PaymentPurposeDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, +impl CVec_PublicKeyZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret } -} -#[no_mangle] -/// Creates a new CResult_PaymentPurposeDecodeErrorZ in the error state. -pub extern "C" fn CResult_PaymentPurposeDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_PaymentPurposeDecodeErrorZ { - CResult_PaymentPurposeDecodeErrorZ { - contents: CResult_PaymentPurposeDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), - }, - result_ok: false, + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::PublicKey] { + 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_PaymentPurposeDecodeErrorZ_is_ok(o: &CResult_PaymentPurposeDecodeErrorZ) -> bool { - o.result_ok +impl From> for CVec_PublicKeyZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } } #[no_mangle] -/// Frees any resources used by the CResult_PaymentPurposeDecodeErrorZ. -pub extern "C" fn CResult_PaymentPurposeDecodeErrorZ_free(_res: CResult_PaymentPurposeDecodeErrorZ) { } -impl Drop for CResult_PaymentPurposeDecodeErrorZ { +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_PublicKeyZ_free(_res: CVec_PublicKeyZ) { } +impl Drop for CVec_PublicKeyZ { fn drop(&mut self) { - if self.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 { - let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_PaymentPurposeDecodeErrorZPtr { result } - } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_PaymentPurposeDecodeErrorZPtr { 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_PaymentPurposeDecodeErrorZ { +impl Clone for CVec_PublicKeyZ { fn clone(&self) -> Self { - if self.result_ok { - 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_PaymentPurposeDecodeErrorZPtr { - 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_PaymentPurposeDecodeErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_PaymentPurposeDecodeErrorZ_clone(orig: &CResult_PaymentPurposeDecodeErrorZ) -> CResult_PaymentPurposeDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -#[derive(Clone)] -/// An enum which can either contain a crate::lightning::routing::gossip::NetworkUpdate or not -pub enum COption_NetworkUpdateZ { - /// When we're in this state, this COption_NetworkUpdateZ contains a crate::lightning::routing::gossip::NetworkUpdate - Some(crate::lightning::routing::gossip::NetworkUpdate), - /// When we're in this state, this COption_NetworkUpdateZ contains nothing - None +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_usizeTransactionZ { + /// The element at position 0 + pub a: usize, + /// The element at position 1 + pub b: crate::c_types::Transaction, } -impl COption_NetworkUpdateZ { - #[allow(unused)] pub(crate) fn is_some(&self) -> bool { - if let Self::None = self { false } else { true } +impl From<(usize, crate::c_types::Transaction)> for C2Tuple_usizeTransactionZ { + fn from (tup: (usize, crate::c_types::Transaction)) -> Self { + Self { + a: tup.0, + b: tup.1, + } } - #[allow(unused)] pub(crate) fn is_none(&self) -> bool { - !self.is_some() +} +impl C2Tuple_usizeTransactionZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (usize, crate::c_types::Transaction) { + (self.a, self.b) } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::routing::gossip::NetworkUpdate { - if let Self::Some(v) = self { v } else { unreachable!() } +} +impl Clone for C2Tuple_usizeTransactionZ { + fn clone(&self) -> Self { + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), + } } } #[no_mangle] -/// Constructs a new COption_NetworkUpdateZ containing a crate::lightning::routing::gossip::NetworkUpdate -pub extern "C" fn COption_NetworkUpdateZ_some(o: crate::lightning::routing::gossip::NetworkUpdate) -> COption_NetworkUpdateZ { - COption_NetworkUpdateZ::Some(o) -} +/// Creates a new tuple which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn C2Tuple_usizeTransactionZ_clone(orig: &C2Tuple_usizeTransactionZ) -> C2Tuple_usizeTransactionZ { Clone::clone(&orig) } +/// Creates a new C2Tuple_usizeTransactionZ from the contained elements. #[no_mangle] -/// Constructs a new COption_NetworkUpdateZ containing nothing -pub extern "C" fn COption_NetworkUpdateZ_none() -> COption_NetworkUpdateZ { - COption_NetworkUpdateZ::None +pub extern "C" fn C2Tuple_usizeTransactionZ_new(a: usize, b: crate::c_types::Transaction) -> C2Tuple_usizeTransactionZ { + C2Tuple_usizeTransactionZ { a, b, } } + #[no_mangle] -/// Frees any resources associated with the crate::lightning::routing::gossip::NetworkUpdate, if we are in the Some state -pub extern "C" fn COption_NetworkUpdateZ_free(_res: COption_NetworkUpdateZ) { } -#[no_mangle] -/// Creates a new COption_NetworkUpdateZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_NetworkUpdateZ_clone(orig: &COption_NetworkUpdateZ) -> COption_NetworkUpdateZ { Clone::clone(&orig) } +/// Frees any resources used by the C2Tuple_usizeTransactionZ. +pub extern "C" fn C2Tuple_usizeTransactionZ_free(_res: C2Tuple_usizeTransactionZ) { } #[repr(C)] -#[derive(Clone)] -/// An enum which can either contain a crate::lightning::util::events::PathFailure or not -pub enum COption_PathFailureZ { - /// When we're in this state, this COption_PathFailureZ contains a crate::lightning::util::events::PathFailure - Some(crate::lightning::util::events::PathFailure), - /// When we're in this state, this COption_PathFailureZ contains nothing - None +/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_usizeTransactionZs of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_C2Tuple_usizeTransactionZZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::derived::C2Tuple_usizeTransactionZ, + /// The number of elements pointed to by `data`. + pub datalen: usize } -impl 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() +impl CVec_C2Tuple_usizeTransactionZZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::util::events::PathFailure { - if let Self::Some(v) = self { v } else { unreachable!() } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_usizeTransactionZ] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -#[no_mangle] -/// Constructs a new COption_PathFailureZ containing a crate::lightning::util::events::PathFailure -pub extern "C" fn COption_PathFailureZ_some(o: crate::lightning::util::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::util::events::PathFailure, if we are in the Some state -pub extern "C" fn COption_PathFailureZ_free(_res: COption_PathFailureZ) { } -#[no_mangle] -/// Creates a new COption_PathFailureZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_PathFailureZ_clone(orig: &COption_PathFailureZ) -> COption_PathFailureZ { Clone::clone(&orig) } -#[repr(C)] -/// The contents of CResult_COption_PathFailureZDecodeErrorZ -pub union CResult_COption_PathFailureZDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::COption_PathFailureZ, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, -} -#[repr(C)] -/// A CResult_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, +impl From> for CVec_C2Tuple_usizeTransactionZZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } } #[no_mangle] -/// 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, +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_C2Tuple_usizeTransactionZZ_free(_res: CVec_C2Tuple_usizeTransactionZZ) { } +impl Drop for CVec_C2Tuple_usizeTransactionZZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -#[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, +impl Clone for CVec_C2Tuple_usizeTransactionZZ { + 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) } } -/// 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 +#[repr(C)] +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_TxidBlockHashZ { + /// The element at position 0 + pub a: crate::c_types::ThirtyTwoBytes, + /// The element at position 1 + pub b: crate::c_types::ThirtyTwoBytes, } -#[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) }; - } +impl From<(crate::c_types::ThirtyTwoBytes, crate::c_types::ThirtyTwoBytes)> for C2Tuple_TxidBlockHashZ { + fn from (tup: (crate::c_types::ThirtyTwoBytes, crate::c_types::ThirtyTwoBytes)) -> Self { + Self { + a: tup.0, + b: tup.1, } } } -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, - } +impl C2Tuple_TxidBlockHashZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoBytes, crate::c_types::ThirtyTwoBytes) { + (self.a, self.b) } } -impl Clone for CResult_COption_PathFailureZDecodeErrorZ { +impl Clone for C2Tuple_TxidBlockHashZ { 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 }))) - } } + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), } } } #[no_mangle] -/// Creates a new CResult_COption_PathFailureZDecodeErrorZ 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_COption_PathFailureZDecodeErrorZ_clone(orig: &CResult_COption_PathFailureZDecodeErrorZ) -> CResult_COption_PathFailureZDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn C2Tuple_TxidBlockHashZ_clone(orig: &C2Tuple_TxidBlockHashZ) -> C2Tuple_TxidBlockHashZ { Clone::clone(&orig) } +/// Creates a new C2Tuple_TxidBlockHashZ from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_TxidBlockHashZ_new(a: crate::c_types::ThirtyTwoBytes, b: crate::c_types::ThirtyTwoBytes) -> C2Tuple_TxidBlockHashZ { + C2Tuple_TxidBlockHashZ { a, b, } +} + +#[no_mangle] +/// Frees any resources used by the C2Tuple_TxidBlockHashZ. +pub extern "C" fn C2Tuple_TxidBlockHashZ_free(_res: C2Tuple_TxidBlockHashZ) { } #[repr(C)] -#[derive(Clone)] -/// An enum which can either contain a crate::lightning::util::events::ClosureReason or not -pub enum COption_ClosureReasonZ { - /// When we're in this state, this COption_ClosureReasonZ contains a crate::lightning::util::events::ClosureReason - Some(crate::lightning::util::events::ClosureReason), - /// When we're in this state, this COption_ClosureReasonZ contains nothing - None +/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_TxidBlockHashZs of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_C2Tuple_TxidBlockHashZZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::derived::C2Tuple_TxidBlockHashZ, + /// 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 } - } - #[allow(unused)] pub(crate) fn is_none(&self) -> bool { - !self.is_some() +impl CVec_C2Tuple_TxidBlockHashZZ { + #[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 take(mut self) -> crate::lightning::util::events::ClosureReason { - if let Self::Some(v) = self { v } else { unreachable!() } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_TxidBlockHashZ] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -#[no_mangle] -/// Constructs a new COption_ClosureReasonZ containing a crate::lightning::util::events::ClosureReason -pub extern "C" fn COption_ClosureReasonZ_some(o: crate::lightning::util::events::ClosureReason) -> COption_ClosureReasonZ { - COption_ClosureReasonZ::Some(o) +impl From> for CVec_C2Tuple_TxidBlockHashZZ { + 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 nothing -pub extern "C" fn COption_ClosureReasonZ_none() -> COption_ClosureReasonZ { - COption_ClosureReasonZ::None +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_C2Tuple_TxidBlockHashZZ_free(_res: CVec_C2Tuple_TxidBlockHashZZ) { } +impl Drop for CVec_C2Tuple_TxidBlockHashZZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_C2Tuple_TxidBlockHashZZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// A dynamically-allocated array of crate::lightning::chain::channelmonitor::MonitorEvents of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_MonitorEventZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::chain::channelmonitor::MonitorEvent, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_MonitorEventZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::chain::channelmonitor::MonitorEvent] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_MonitorEventZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } } #[no_mangle] -/// Frees any resources associated with the crate::lightning::util::events::ClosureReason, if we are in the Some state -pub extern "C" fn COption_ClosureReasonZ_free(_res: COption_ClosureReasonZ) { } +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_MonitorEventZ_free(_res: CVec_MonitorEventZ) { } +impl Drop for CVec_MonitorEventZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_MonitorEventZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// A tuple of 3 elements. See the individual fields for the types contained. +pub struct C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ { + /// The element at position 0 + pub a: crate::lightning::chain::transaction::OutPoint, + /// The element at position 1 + pub b: crate::c_types::derived::CVec_MonitorEventZ, + /// The element at position 2 + pub c: crate::c_types::PublicKey, +} +impl From<(crate::lightning::chain::transaction::OutPoint, crate::c_types::derived::CVec_MonitorEventZ, crate::c_types::PublicKey)> for C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ { + fn from (tup: (crate::lightning::chain::transaction::OutPoint, crate::c_types::derived::CVec_MonitorEventZ, crate::c_types::PublicKey)) -> Self { + Self { + a: tup.0, + b: tup.1, + c: tup.2, + } + } +} +impl C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::lightning::chain::transaction::OutPoint, crate::c_types::derived::CVec_MonitorEventZ, crate::c_types::PublicKey) { + (self.a, self.b, self.c) + } +} +impl Clone for C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ { + fn clone(&self) -> Self { + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), + c: Clone::clone(&self.c), + } + } +} #[no_mangle] -/// Creates a new COption_ClosureReasonZ 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 COption_ClosureReasonZ_clone(orig: &COption_ClosureReasonZ) -> COption_ClosureReasonZ { Clone::clone(&orig) } +pub extern "C" fn C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(orig: &C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ) -> C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ { Clone::clone(&orig) } +/// Creates a new C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ from the contained elements. +#[no_mangle] +pub extern "C" fn C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_new(a: crate::lightning::chain::transaction::OutPoint, b: crate::c_types::derived::CVec_MonitorEventZ, c: crate::c_types::PublicKey) -> C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ { + C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ { a, b, c, } +} + +#[no_mangle] +/// Frees any resources used by the C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ. +pub extern "C" fn C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_free(_res: C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ) { } #[repr(C)] -/// The contents of CResult_COption_ClosureReasonZDecodeErrorZ -pub union CResult_COption_ClosureReasonZDecodeErrorZPtr { +/// A dynamically-allocated array of crate::c_types::derived::C3Tuple_OutPointCVec_MonitorEventZPublicKeyZs of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::derived::C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ_free(_res: CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ) { } +impl Drop for CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// The contents of CResult_FixedPenaltyScorerDecodeErrorZ +pub union CResult_FixedPenaltyScorerDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::COption_ClosureReasonZ, + pub result: *mut crate::lightning::routing::scoring::FixedPenaltyScorer, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[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_FixedPenaltyScorerDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::routing::scoring::FixedPenaltyScorer on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_COption_ClosureReasonZDecodeErrorZ { - /// The contents of this CResult_COption_ClosureReasonZDecodeErrorZ, accessible via either +pub struct CResult_FixedPenaltyScorerDecodeErrorZ { + /// The contents of this CResult_FixedPenaltyScorerDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_COption_ClosureReasonZDecodeErrorZPtr, - /// Whether this CResult_COption_ClosureReasonZDecodeErrorZ represents a success state. + pub contents: CResult_FixedPenaltyScorerDecodeErrorZPtr, + /// Whether this CResult_FixedPenaltyScorerDecodeErrorZ 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_FixedPenaltyScorerDecodeErrorZ in the success state. +pub extern "C" fn CResult_FixedPenaltyScorerDecodeErrorZ_ok(o: crate::lightning::routing::scoring::FixedPenaltyScorer) -> CResult_FixedPenaltyScorerDecodeErrorZ { + CResult_FixedPenaltyScorerDecodeErrorZ { + contents: CResult_FixedPenaltyScorerDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// 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_FixedPenaltyScorerDecodeErrorZ in the error state. +pub extern "C" fn CResult_FixedPenaltyScorerDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_FixedPenaltyScorerDecodeErrorZ { + CResult_FixedPenaltyScorerDecodeErrorZ { + contents: CResult_FixedPenaltyScorerDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -3602,13 +3917,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_FixedPenaltyScorerDecodeErrorZ_is_ok(o: &CResult_FixedPenaltyScorerDecodeErrorZ) -> 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_FixedPenaltyScorerDecodeErrorZ. +pub extern "C" fn CResult_FixedPenaltyScorerDecodeErrorZ_free(_res: CResult_FixedPenaltyScorerDecodeErrorZ) { } +impl Drop for CResult_FixedPenaltyScorerDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -3621,16 +3936,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_FixedPenaltyScorerDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_COption_ClosureReasonZDecodeErrorZPtr { result } + CResult_FixedPenaltyScorerDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_COption_ClosureReasonZDecodeErrorZPtr { err } + CResult_FixedPenaltyScorerDecodeErrorZPtr { err } }; Self { contents, @@ -3638,217 +3953,247 @@ 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_FixedPenaltyScorerDecodeErrorZPtr { + 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_FixedPenaltyScorerDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_COption_ClosureReasonZDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_FixedPenaltyScorerDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_COption_ClosureReasonZDecodeErrorZ_clone(orig: &CResult_COption_ClosureReasonZDecodeErrorZ) -> CResult_COption_ClosureReasonZDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_FixedPenaltyScorerDecodeErrorZ_clone(orig: &CResult_FixedPenaltyScorerDecodeErrorZ) -> CResult_FixedPenaltyScorerDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -#[derive(Clone)] -/// An enum which can either contain a crate::lightning::util::events::HTLCDestination or not -pub enum COption_HTLCDestinationZ { - /// When we're in this state, this COption_HTLCDestinationZ contains a crate::lightning::util::events::HTLCDestination - Some(crate::lightning::util::events::HTLCDestination), - /// When we're in this state, this COption_HTLCDestinationZ contains nothing - None +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_u64u64Z { + /// The element at position 0 + pub a: u64, + /// The element at position 1 + pub b: u64, } -impl 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::util::events::HTLCDestination { - if let Self::Some(v) = self { v } else { unreachable!() } +impl From<(u64, u64)> for C2Tuple_u64u64Z { + fn from (tup: (u64, u64)) -> Self { + Self { + a: tup.0, + b: tup.1, + } } } -#[no_mangle] -/// Constructs a new COption_HTLCDestinationZ containing a crate::lightning::util::events::HTLCDestination -pub extern "C" fn COption_HTLCDestinationZ_some(o: crate::lightning::util::events::HTLCDestination) -> COption_HTLCDestinationZ { - COption_HTLCDestinationZ::Some(o) +impl C2Tuple_u64u64Z { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (u64, u64) { + (self.a, self.b) + } } -#[no_mangle] -/// Constructs a new COption_HTLCDestinationZ containing nothing -pub extern "C" fn COption_HTLCDestinationZ_none() -> COption_HTLCDestinationZ { - COption_HTLCDestinationZ::None +impl Clone for C2Tuple_u64u64Z { + fn clone(&self) -> Self { + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), + } + } } #[no_mangle] -/// Frees any resources associated with the crate::lightning::util::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 tuple 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::c_types::derived::COption_HTLCDestinationZ, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, +pub extern "C" fn C2Tuple_u64u64Z_clone(orig: &C2Tuple_u64u64Z) -> C2Tuple_u64u64Z { Clone::clone(&orig) } +/// Creates a new C2Tuple_u64u64Z from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_u64u64Z_new(a: u64, b: u64) -> C2Tuple_u64u64Z { + C2Tuple_u64u64Z { a, b, } } + +#[no_mangle] +/// Frees any resources used by the C2Tuple_u64u64Z. +pub extern "C" fn C2Tuple_u64u64Z_free(_res: C2Tuple_u64u64Z) { } #[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. -/// `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 - /// `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, +#[derive(Clone)] +/// An enum which can either contain a crate::c_types::derived::C2Tuple_u64u64Z or not +pub enum COption_C2Tuple_u64u64ZZ { + /// When we're in this state, this COption_C2Tuple_u64u64ZZ contains a crate::c_types::derived::C2Tuple_u64u64Z + Some(crate::c_types::derived::C2Tuple_u64u64Z), + /// When we're in this state, this COption_C2Tuple_u64u64ZZ contains nothing + None } -#[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, +impl COption_C2Tuple_u64u64ZZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::derived::C2Tuple_u64u64Z { + if let Self::Some(v) = self { v } else { unreachable!() } } } #[no_mangle] -/// Creates a new CResult_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, - } +/// Constructs a new COption_C2Tuple_u64u64ZZ containing a crate::c_types::derived::C2Tuple_u64u64Z +pub extern "C" fn COption_C2Tuple_u64u64ZZ_some(o: crate::c_types::derived::C2Tuple_u64u64Z) -> COption_C2Tuple_u64u64ZZ { + COption_C2Tuple_u64u64ZZ::Some(o) } -/// 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 +/// Constructs a new COption_C2Tuple_u64u64ZZ containing nothing +pub extern "C" fn COption_C2Tuple_u64u64ZZ_none() -> COption_C2Tuple_u64u64ZZ { + COption_C2Tuple_u64u64ZZ::None } #[no_mangle] -/// 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) }; - } +/// Frees any resources associated with the crate::c_types::derived::C2Tuple_u64u64Z, if we are in the Some state +pub extern "C" fn COption_C2Tuple_u64u64ZZ_free(_res: COption_C2Tuple_u64u64ZZ) { } +#[no_mangle] +/// Creates a new COption_C2Tuple_u64u64ZZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_C2Tuple_u64u64ZZ_clone(orig: &COption_C2Tuple_u64u64ZZ) -> COption_C2Tuple_u64u64ZZ { Clone::clone(&orig) } +#[repr(C)] +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_Z { + /// The element at position 0 + pub a: crate::c_types::EightU16s, + /// The element at position 1 + pub b: crate::c_types::EightU16s, +} +impl From<(crate::c_types::EightU16s, crate::c_types::EightU16s)> for C2Tuple_Z { + fn from (tup: (crate::c_types::EightU16s, crate::c_types::EightU16s)) -> Self { + Self { + a: tup.0, + b: tup.1, } } } -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 } - }; +impl C2Tuple_Z { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::EightU16s, crate::c_types::EightU16s) { + (self.a, self.b) + } +} +impl Clone for C2Tuple_Z { + fn clone(&self) -> Self { Self { - contents, - result_ok: o.result_ok, + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), } } } -impl Clone for CResult_COption_HTLCDestinationZDecodeErrorZ { +#[no_mangle] +/// Creates a new tuple which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn C2Tuple_Z_clone(orig: &C2Tuple_Z) -> C2Tuple_Z { Clone::clone(&orig) } +/// Creates a new C2Tuple_Z from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_Z_new(a: crate::c_types::EightU16s, b: crate::c_types::EightU16s) -> C2Tuple_Z { + C2Tuple_Z { a, b, } +} + +#[no_mangle] +/// Frees any resources used by the C2Tuple_Z. +pub extern "C" fn C2Tuple_Z_free(_res: C2Tuple_Z) { } +#[repr(C)] +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple__u168_u168Z { + /// The element at position 0 + pub a: crate::c_types::EightU16s, + /// The element at position 1 + pub b: crate::c_types::EightU16s, +} +impl From<(crate::c_types::EightU16s, crate::c_types::EightU16s)> for C2Tuple__u168_u168Z { + fn from (tup: (crate::c_types::EightU16s, crate::c_types::EightU16s)) -> Self { + Self { + a: tup.0, + b: tup.1, + } + } +} +impl C2Tuple__u168_u168Z { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::EightU16s, crate::c_types::EightU16s) { + (self.a, self.b) + } +} +impl Clone for C2Tuple__u168_u168Z { fn clone(&self) -> Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_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 }))) - } } + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), } } } #[no_mangle] -/// Creates a new CResult_COption_HTLCDestinationZDecodeErrorZ 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_COption_HTLCDestinationZDecodeErrorZ_clone(orig: &CResult_COption_HTLCDestinationZDecodeErrorZ) -> CResult_COption_HTLCDestinationZDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn C2Tuple__u168_u168Z_clone(orig: &C2Tuple__u168_u168Z) -> C2Tuple__u168_u168Z { Clone::clone(&orig) } +/// Creates a new C2Tuple__u168_u168Z from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple__u168_u168Z_new(a: crate::c_types::EightU16s, b: crate::c_types::EightU16s) -> C2Tuple__u168_u168Z { + C2Tuple__u168_u168Z { a, b, } +} + +#[no_mangle] +/// Frees any resources used by the C2Tuple__u168_u168Z. +pub extern "C" fn C2Tuple__u168_u168Z_free(_res: C2Tuple__u168_u168Z) { } #[repr(C)] #[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::c_types::derived::C2Tuple__u168_u168Z or not +pub enum COption_C2Tuple_EightU16sEightU16sZZ { + /// When we're in this state, this COption_C2Tuple_EightU16sEightU16sZZ contains a crate::c_types::derived::C2Tuple__u168_u168Z + Some(crate::c_types::derived::C2Tuple__u168_u168Z), + /// When we're in this state, this COption_C2Tuple_EightU16sEightU16sZZ contains nothing None } -impl COption_u128Z { +impl COption_C2Tuple_EightU16sEightU16sZZ { #[allow(unused)] pub(crate) fn is_some(&self) -> bool { if let Self::None = self { false } else { true } } #[allow(unused)] pub(crate) fn is_none(&self) -> bool { !self.is_some() } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::U128 { + #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::derived::C2Tuple__u168_u168Z { if let Self::Some(v) = self { v } else { unreachable!() } } } #[no_mangle] -/// Constructs a new COption_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_C2Tuple_EightU16sEightU16sZZ containing a crate::c_types::derived::C2Tuple__u168_u168Z +pub extern "C" fn COption_C2Tuple_EightU16sEightU16sZZ_some(o: crate::c_types::derived::C2Tuple__u168_u168Z) -> COption_C2Tuple_EightU16sEightU16sZZ { + COption_C2Tuple_EightU16sEightU16sZZ::Some(o) } #[no_mangle] -/// Constructs a new COption_u128Z containing nothing -pub extern "C" fn COption_u128Z_none() -> COption_u128Z { - COption_u128Z::None +/// Constructs a new COption_C2Tuple_EightU16sEightU16sZZ containing nothing +pub extern "C" fn COption_C2Tuple_EightU16sEightU16sZZ_none() -> COption_C2Tuple_EightU16sEightU16sZZ { + COption_C2Tuple_EightU16sEightU16sZZ::None } #[no_mangle] -/// Frees any resources associated with the crate::c_types::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::c_types::derived::C2Tuple__u168_u168Z, if we are in the Some state +pub extern "C" fn COption_C2Tuple_EightU16sEightU16sZZ_free(_res: COption_C2Tuple_EightU16sEightU16sZZ) { } #[no_mangle] -/// Creates a new COption_u128Z which has the same data as `orig` +/// Creates a new COption_C2Tuple_EightU16sEightU16sZZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_u128Z_clone(orig: &COption_u128Z) -> COption_u128Z { Clone::clone(&orig) } +pub extern "C" fn COption_C2Tuple_EightU16sEightU16sZZ_clone(orig: &COption_C2Tuple_EightU16sEightU16sZZ) -> COption_C2Tuple_EightU16sEightU16sZZ { Clone::clone(&orig) } #[repr(C)] -/// A dynamically-allocated array of crate::lightning::chain::keysinterface::SpendableOutputDescriptors of arbitrary size. +/// A dynamically-allocated array of crate::lightning::routing::gossip::NodeIds of arbitrary size. /// This corresponds to std::vector in C++ -pub struct CVec_SpendableOutputDescriptorZ { +pub struct CVec_NodeIdZ { /// The elements in the array. /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::chain::keysinterface::SpendableOutputDescriptor, + pub data: *mut crate::lightning::routing::gossip::NodeId, /// The number of elements pointed to by `data`. pub datalen: usize } -impl CVec_SpendableOutputDescriptorZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { +impl CVec_NodeIdZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { if self.datalen == 0 { return Vec::new(); } let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); self.data = core::ptr::null_mut(); self.datalen = 0; ret } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::chain::keysinterface::SpendableOutputDescriptor] { + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::routing::gossip::NodeId] { unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl From> for CVec_SpendableOutputDescriptorZ { - fn from(v: Vec) -> Self { +impl From> for CVec_NodeIdZ { + 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() } } @@ -3856,14 +4201,14 @@ impl From } #[no_mangle] /// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_SpendableOutputDescriptorZ_free(_res: CVec_SpendableOutputDescriptorZ) { } -impl Drop for CVec_SpendableOutputDescriptorZ { +pub extern "C" fn CVec_NodeIdZ_free(_res: CVec_NodeIdZ) { } +impl Drop for CVec_NodeIdZ { fn drop(&mut self) { if self.datalen == 0 { return; } let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl Clone for CVec_SpendableOutputDescriptorZ { +impl Clone for CVec_NodeIdZ { fn clone(&self) -> Self { let mut res = Vec::new(); if self.datalen == 0 { return Self::from(res); } @@ -3872,78 +4217,120 @@ impl Clone for CVec_SpendableOutputDescriptorZ { } } #[repr(C)] -#[derive(Clone)] -/// An enum which can either contain a crate::lightning::util::events::Event or not -pub enum COption_EventZ { - /// When we're in this state, this COption_EventZ contains a crate::lightning::util::events::Event - Some(crate::lightning::util::events::Event), - /// When we're in this state, this COption_EventZ contains nothing - None +/// The contents of CResult_ProbabilisticScorerDecodeErrorZ +pub union CResult_ProbabilisticScorerDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::routing::scoring::ProbabilisticScorer, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, } -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::util::events::Event { - if let Self::Some(v) = self { v } else { unreachable!() } - } +#[repr(C)] +/// A CResult_ProbabilisticScorerDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::routing::scoring::ProbabilisticScorer on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_ProbabilisticScorerDecodeErrorZ { + /// The contents of this CResult_ProbabilisticScorerDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_ProbabilisticScorerDecodeErrorZPtr, + /// Whether this CResult_ProbabilisticScorerDecodeErrorZ represents a success state. + pub result_ok: bool, } #[no_mangle] -/// Constructs a new COption_EventZ containing a crate::lightning::util::events::Event -pub extern "C" fn COption_EventZ_some(o: crate::lightning::util::events::Event) -> COption_EventZ { - COption_EventZ::Some(o) +/// Creates a new CResult_ProbabilisticScorerDecodeErrorZ in the success state. +pub extern "C" fn CResult_ProbabilisticScorerDecodeErrorZ_ok(o: crate::lightning::routing::scoring::ProbabilisticScorer) -> CResult_ProbabilisticScorerDecodeErrorZ { + CResult_ProbabilisticScorerDecodeErrorZ { + contents: CResult_ProbabilisticScorerDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } } #[no_mangle] -/// Constructs a new COption_EventZ containing nothing -pub extern "C" fn COption_EventZ_none() -> COption_EventZ { - COption_EventZ::None +/// Creates a new CResult_ProbabilisticScorerDecodeErrorZ in the error state. +pub extern "C" fn CResult_ProbabilisticScorerDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ProbabilisticScorerDecodeErrorZ { + CResult_ProbabilisticScorerDecodeErrorZ { + contents: CResult_ProbabilisticScorerDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } } +/// Checks if the given object is currently in the success state #[no_mangle] -/// Frees any resources associated with the crate::lightning::util::events::Event, if we are in the Some state -pub extern "C" fn COption_EventZ_free(_res: COption_EventZ) { } +pub extern "C" fn CResult_ProbabilisticScorerDecodeErrorZ_is_ok(o: &CResult_ProbabilisticScorerDecodeErrorZ) -> bool { + o.result_ok +} #[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) } +/// Frees any resources used by the CResult_ProbabilisticScorerDecodeErrorZ. +pub extern "C" fn CResult_ProbabilisticScorerDecodeErrorZ_free(_res: CResult_ProbabilisticScorerDecodeErrorZ) { } +impl Drop for CResult_ProbabilisticScorerDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_ProbabilisticScorerDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_ProbabilisticScorerDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_ProbabilisticScorerDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} #[repr(C)] -/// The contents of CResult_COption_EventZDecodeErrorZ -pub union CResult_COption_EventZDecodeErrorZPtr { +/// The contents of CResult_InitFeaturesDecodeErrorZ +pub union CResult_InitFeaturesDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::COption_EventZ, + pub result: *mut crate::lightning::ln::features::InitFeatures, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_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_InitFeaturesDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::features::InitFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_COption_EventZDecodeErrorZ { - /// The contents of this CResult_COption_EventZDecodeErrorZ, accessible via either +pub struct CResult_InitFeaturesDecodeErrorZ { + /// The contents of this CResult_InitFeaturesDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_COption_EventZDecodeErrorZPtr, - /// Whether this CResult_COption_EventZDecodeErrorZ represents a success state. + pub contents: CResult_InitFeaturesDecodeErrorZPtr, + /// Whether this CResult_InitFeaturesDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_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_InitFeaturesDecodeErrorZ in the success state. +pub extern "C" fn CResult_InitFeaturesDecodeErrorZ_ok(o: crate::lightning::ln::features::InitFeatures) -> CResult_InitFeaturesDecodeErrorZ { + CResult_InitFeaturesDecodeErrorZ { + contents: CResult_InitFeaturesDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_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_InitFeaturesDecodeErrorZ in the error state. +pub extern "C" fn CResult_InitFeaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_InitFeaturesDecodeErrorZ { + CResult_InitFeaturesDecodeErrorZ { + contents: CResult_InitFeaturesDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -3951,13 +4338,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_InitFeaturesDecodeErrorZ_is_ok(o: &CResult_InitFeaturesDecodeErrorZ) -> 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_InitFeaturesDecodeErrorZ. +pub extern "C" fn CResult_InitFeaturesDecodeErrorZ_free(_res: CResult_InitFeaturesDecodeErrorZ) { } +impl Drop for CResult_InitFeaturesDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -3970,16 +4357,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_InitFeaturesDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_COption_EventZDecodeErrorZPtr { result } + CResult_InitFeaturesDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_COption_EventZDecodeErrorZPtr { err } + CResult_InitFeaturesDecodeErrorZPtr { err } }; Self { contents, @@ -3987,419 +4374,539 @@ 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_InitFeaturesDecodeErrorZPtr { + 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_InitFeaturesDecodeErrorZPtr { 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_InitFeaturesDecodeErrorZ 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_InitFeaturesDecodeErrorZ_clone(orig: &CResult_InitFeaturesDecodeErrorZ) -> CResult_InitFeaturesDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// A dynamically-allocated array of crate::lightning::util::events::MessageSendEvents of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_MessageSendEventZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::util::events::MessageSendEvent, - /// The number of elements pointed to by `data`. - pub datalen: usize +/// The contents of CResult_ChannelFeaturesDecodeErrorZ +pub union CResult_ChannelFeaturesDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::features::ChannelFeatures, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, } -impl CVec_MessageSendEventZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::util::events::MessageSendEvent] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } +#[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. +/// `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 + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_ChannelFeaturesDecodeErrorZPtr, + /// Whether this CResult_ChannelFeaturesDecodeErrorZ represents a success state. + pub result_ok: bool, } -impl From> for CVec_MessageSendEventZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } +#[no_mangle] +/// Creates a new CResult_ChannelFeaturesDecodeErrorZ in the success state. +pub extern "C" fn CResult_ChannelFeaturesDecodeErrorZ_ok(o: crate::lightning::ln::features::ChannelFeatures) -> CResult_ChannelFeaturesDecodeErrorZ { + CResult_ChannelFeaturesDecodeErrorZ { + contents: CResult_ChannelFeaturesDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, } } #[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_MessageSendEventZ_free(_res: CVec_MessageSendEventZ) { } -impl Drop for CVec_MessageSendEventZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; +/// Creates a new CResult_ChannelFeaturesDecodeErrorZ in the error state. +pub extern "C" fn CResult_ChannelFeaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelFeaturesDecodeErrorZ { + CResult_ChannelFeaturesDecodeErrorZ { + contents: CResult_ChannelFeaturesDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, } } -impl Clone for CVec_MessageSendEventZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_ChannelFeaturesDecodeErrorZ_is_ok(o: &CResult_ChannelFeaturesDecodeErrorZ) -> bool { + o.result_ok } -#[repr(C)] -/// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple_usizeTransactionZ { - /// The element at position 0 - pub a: usize, - /// The element at position 1 - pub b: crate::c_types::Transaction, +#[no_mangle] +/// Frees any resources used by the CResult_ChannelFeaturesDecodeErrorZ. +pub extern "C" fn CResult_ChannelFeaturesDecodeErrorZ_free(_res: CResult_ChannelFeaturesDecodeErrorZ) { } +impl Drop for CResult_ChannelFeaturesDecodeErrorZ { + 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<(usize, crate::c_types::Transaction)> for C2Tuple_usizeTransactionZ { - fn from (tup: (usize, crate::c_types::Transaction)) -> Self { +impl From> for CResult_ChannelFeaturesDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_ChannelFeaturesDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_ChannelFeaturesDecodeErrorZPtr { err } + }; Self { - a: tup.0, - b: tup.1, + contents, + result_ok: o.result_ok, } } } -impl C2Tuple_usizeTransactionZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (usize, crate::c_types::Transaction) { - (self.a, self.b) - } -} -impl Clone for C2Tuple_usizeTransactionZ { +impl Clone for CResult_ChannelFeaturesDecodeErrorZ { 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_ChannelFeaturesDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_ChannelFeaturesDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } } } } #[no_mangle] -/// Creates a new tuple which has the same data as `orig` +/// Creates a new CResult_ChannelFeaturesDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C2Tuple_usizeTransactionZ_clone(orig: &C2Tuple_usizeTransactionZ) -> C2Tuple_usizeTransactionZ { Clone::clone(&orig) } -/// Creates a new C2Tuple_usizeTransactionZ from the contained elements. -#[no_mangle] -pub extern "C" fn C2Tuple_usizeTransactionZ_new(a: usize, b: crate::c_types::Transaction) -> C2Tuple_usizeTransactionZ { - C2Tuple_usizeTransactionZ { a, b, } +pub extern "C" fn CResult_ChannelFeaturesDecodeErrorZ_clone(orig: &CResult_ChannelFeaturesDecodeErrorZ) -> CResult_ChannelFeaturesDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_NodeFeaturesDecodeErrorZ +pub union CResult_NodeFeaturesDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::features::NodeFeatures, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, } - -#[no_mangle] -/// Frees any resources used by the C2Tuple_usizeTransactionZ. -pub extern "C" fn C2Tuple_usizeTransactionZ_free(_res: C2Tuple_usizeTransactionZ) { } #[repr(C)] -/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_usizeTransactionZs of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_C2Tuple_usizeTransactionZZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::derived::C2Tuple_usizeTransactionZ, - /// The number of elements pointed to by `data`. - pub datalen: usize +/// A CResult_NodeFeaturesDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::features::NodeFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_NodeFeaturesDecodeErrorZ { + /// The contents of this CResult_NodeFeaturesDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_NodeFeaturesDecodeErrorZPtr, + /// Whether this CResult_NodeFeaturesDecodeErrorZ represents a success state. + pub result_ok: bool, } -impl CVec_C2Tuple_usizeTransactionZZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_usizeTransactionZ] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } +#[no_mangle] +/// Creates a new CResult_NodeFeaturesDecodeErrorZ in the success state. +pub extern "C" fn CResult_NodeFeaturesDecodeErrorZ_ok(o: crate::lightning::ln::features::NodeFeatures) -> CResult_NodeFeaturesDecodeErrorZ { + CResult_NodeFeaturesDecodeErrorZ { + contents: CResult_NodeFeaturesDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, } } -impl From> for CVec_C2Tuple_usizeTransactionZZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } +#[no_mangle] +/// Creates a new CResult_NodeFeaturesDecodeErrorZ in the error state. +pub extern "C" fn CResult_NodeFeaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_NodeFeaturesDecodeErrorZ { + CResult_NodeFeaturesDecodeErrorZ { + contents: CResult_NodeFeaturesDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, } } +/// Checks if the given object is currently in the success state #[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_C2Tuple_usizeTransactionZZ_free(_res: CVec_C2Tuple_usizeTransactionZZ) { } -impl Drop for CVec_C2Tuple_usizeTransactionZZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } +pub extern "C" fn CResult_NodeFeaturesDecodeErrorZ_is_ok(o: &CResult_NodeFeaturesDecodeErrorZ) -> bool { + o.result_ok } -impl Clone for CVec_C2Tuple_usizeTransactionZZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) +#[no_mangle] +/// Frees any resources used by the CResult_NodeFeaturesDecodeErrorZ. +pub extern "C" fn CResult_NodeFeaturesDecodeErrorZ_free(_res: CResult_NodeFeaturesDecodeErrorZ) { } +impl Drop for CResult_NodeFeaturesDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } } } -#[repr(C)] -/// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple_TxidBlockHashZ { - /// The element at position 0 - pub a: crate::c_types::ThirtyTwoBytes, - /// The element at position 1 - pub b: crate::c_types::ThirtyTwoBytes, -} -impl From<(crate::c_types::ThirtyTwoBytes, crate::c_types::ThirtyTwoBytes)> for C2Tuple_TxidBlockHashZ { - fn from (tup: (crate::c_types::ThirtyTwoBytes, crate::c_types::ThirtyTwoBytes)) -> Self { +impl From> for CResult_NodeFeaturesDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_NodeFeaturesDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_NodeFeaturesDecodeErrorZPtr { err } + }; Self { - a: tup.0, - b: tup.1, + contents, + result_ok: o.result_ok, } } } -impl C2Tuple_TxidBlockHashZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoBytes, crate::c_types::ThirtyTwoBytes) { - (self.a, self.b) - } -} -impl Clone for C2Tuple_TxidBlockHashZ { +impl Clone for CResult_NodeFeaturesDecodeErrorZ { 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_NodeFeaturesDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_NodeFeaturesDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } } } } #[no_mangle] -/// Creates a new tuple which has the same data as `orig` +/// Creates a new CResult_NodeFeaturesDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C2Tuple_TxidBlockHashZ_clone(orig: &C2Tuple_TxidBlockHashZ) -> C2Tuple_TxidBlockHashZ { Clone::clone(&orig) } -/// Creates a new C2Tuple_TxidBlockHashZ from the contained elements. -#[no_mangle] -pub extern "C" fn C2Tuple_TxidBlockHashZ_new(a: crate::c_types::ThirtyTwoBytes, b: crate::c_types::ThirtyTwoBytes) -> C2Tuple_TxidBlockHashZ { - C2Tuple_TxidBlockHashZ { a, b, } +pub extern "C" fn CResult_NodeFeaturesDecodeErrorZ_clone(orig: &CResult_NodeFeaturesDecodeErrorZ) -> CResult_NodeFeaturesDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_InvoiceFeaturesDecodeErrorZ +pub union CResult_InvoiceFeaturesDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::features::InvoiceFeatures, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, } - -#[no_mangle] -/// Frees any resources used by the C2Tuple_TxidBlockHashZ. -pub extern "C" fn C2Tuple_TxidBlockHashZ_free(_res: C2Tuple_TxidBlockHashZ) { } #[repr(C)] -/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_TxidBlockHashZs of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_C2Tuple_TxidBlockHashZZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::derived::C2Tuple_TxidBlockHashZ, - /// The number of elements pointed to by `data`. - pub datalen: usize +/// A CResult_InvoiceFeaturesDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::features::InvoiceFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_InvoiceFeaturesDecodeErrorZ { + /// The contents of this CResult_InvoiceFeaturesDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_InvoiceFeaturesDecodeErrorZPtr, + /// Whether this CResult_InvoiceFeaturesDecodeErrorZ represents a success state. + pub result_ok: bool, } -impl CVec_C2Tuple_TxidBlockHashZZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_TxidBlockHashZ] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } +#[no_mangle] +/// Creates a new CResult_InvoiceFeaturesDecodeErrorZ in the success state. +pub extern "C" fn CResult_InvoiceFeaturesDecodeErrorZ_ok(o: crate::lightning::ln::features::InvoiceFeatures) -> CResult_InvoiceFeaturesDecodeErrorZ { + CResult_InvoiceFeaturesDecodeErrorZ { + contents: CResult_InvoiceFeaturesDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, } } -impl From> for CVec_C2Tuple_TxidBlockHashZZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } +#[no_mangle] +/// Creates a new CResult_InvoiceFeaturesDecodeErrorZ in the error state. +pub extern "C" fn CResult_InvoiceFeaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_InvoiceFeaturesDecodeErrorZ { + CResult_InvoiceFeaturesDecodeErrorZ { + contents: CResult_InvoiceFeaturesDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, } } +/// Checks if the given object is currently in the success state #[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_C2Tuple_TxidBlockHashZZ_free(_res: CVec_C2Tuple_TxidBlockHashZZ) { } -impl Drop for CVec_C2Tuple_TxidBlockHashZZ { +pub extern "C" fn CResult_InvoiceFeaturesDecodeErrorZ_is_ok(o: &CResult_InvoiceFeaturesDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_InvoiceFeaturesDecodeErrorZ. +pub extern "C" fn CResult_InvoiceFeaturesDecodeErrorZ_free(_res: CResult_InvoiceFeaturesDecodeErrorZ) { } +impl Drop for CResult_InvoiceFeaturesDecodeErrorZ { fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } } } -impl Clone for CVec_C2Tuple_TxidBlockHashZZ { +impl From> for CResult_InvoiceFeaturesDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_InvoiceFeaturesDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_InvoiceFeaturesDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_InvoiceFeaturesDecodeErrorZ { fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) + if self.result_ok { + Self { result_ok: true, contents: CResult_InvoiceFeaturesDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_InvoiceFeaturesDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } } } +#[no_mangle] +/// Creates a new CResult_InvoiceFeaturesDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_InvoiceFeaturesDecodeErrorZ_clone(orig: &CResult_InvoiceFeaturesDecodeErrorZ) -> CResult_InvoiceFeaturesDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// A dynamically-allocated array of crate::lightning::chain::channelmonitor::MonitorEvents of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_MonitorEventZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::chain::channelmonitor::MonitorEvent, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_MonitorEventZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::chain::channelmonitor::MonitorEvent] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } +/// The contents of CResult_BlindedHopFeaturesDecodeErrorZ +pub union CResult_BlindedHopFeaturesDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::features::BlindedHopFeatures, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, } -impl From> for CVec_MonitorEventZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } +#[repr(C)] +/// A CResult_BlindedHopFeaturesDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::features::BlindedHopFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_BlindedHopFeaturesDecodeErrorZ { + /// The contents of this CResult_BlindedHopFeaturesDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_BlindedHopFeaturesDecodeErrorZPtr, + /// Whether this CResult_BlindedHopFeaturesDecodeErrorZ represents a success state. + pub result_ok: bool, } #[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_MonitorEventZ_free(_res: CVec_MonitorEventZ) { } -impl Drop for CVec_MonitorEventZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; +/// Creates a new CResult_BlindedHopFeaturesDecodeErrorZ in the success state. +pub extern "C" fn CResult_BlindedHopFeaturesDecodeErrorZ_ok(o: crate::lightning::ln::features::BlindedHopFeatures) -> CResult_BlindedHopFeaturesDecodeErrorZ { + CResult_BlindedHopFeaturesDecodeErrorZ { + contents: CResult_BlindedHopFeaturesDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, } } -impl Clone for CVec_MonitorEventZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) +#[no_mangle] +/// Creates a new CResult_BlindedHopFeaturesDecodeErrorZ in the error state. +pub extern "C" fn CResult_BlindedHopFeaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_BlindedHopFeaturesDecodeErrorZ { + CResult_BlindedHopFeaturesDecodeErrorZ { + contents: CResult_BlindedHopFeaturesDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, } } -#[repr(C)] -/// A tuple of 3 elements. See the individual fields for the types contained. -pub struct C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ { - /// The element at position 0 - pub a: crate::lightning::chain::transaction::OutPoint, - /// The element at position 1 - pub b: crate::c_types::derived::CVec_MonitorEventZ, - /// The element at position 2 - pub c: crate::c_types::PublicKey, +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_BlindedHopFeaturesDecodeErrorZ_is_ok(o: &CResult_BlindedHopFeaturesDecodeErrorZ) -> bool { + o.result_ok } -impl From<(crate::lightning::chain::transaction::OutPoint, crate::c_types::derived::CVec_MonitorEventZ, crate::c_types::PublicKey)> for C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ { - fn from (tup: (crate::lightning::chain::transaction::OutPoint, crate::c_types::derived::CVec_MonitorEventZ, crate::c_types::PublicKey)) -> Self { - Self { - a: tup.0, - b: tup.1, - c: tup.2, +#[no_mangle] +/// Frees any resources used by the CResult_BlindedHopFeaturesDecodeErrorZ. +pub extern "C" fn CResult_BlindedHopFeaturesDecodeErrorZ_free(_res: CResult_BlindedHopFeaturesDecodeErrorZ) { } +impl Drop for CResult_BlindedHopFeaturesDecodeErrorZ { + 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 C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::lightning::chain::transaction::OutPoint, crate::c_types::derived::CVec_MonitorEventZ, crate::c_types::PublicKey) { - (self.a, self.b, self.c) +impl From> for CResult_BlindedHopFeaturesDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_BlindedHopFeaturesDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_BlindedHopFeaturesDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } } } -impl Clone for C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ { +impl Clone for CResult_BlindedHopFeaturesDecodeErrorZ { fn clone(&self) -> Self { - Self { - a: Clone::clone(&self.a), - b: Clone::clone(&self.b), - c: Clone::clone(&self.c), + if self.result_ok { + Self { result_ok: true, contents: CResult_BlindedHopFeaturesDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_BlindedHopFeaturesDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } } } } #[no_mangle] -/// Creates a new tuple which has the same data as `orig` +/// Creates a new CResult_BlindedHopFeaturesDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(orig: &C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ) -> C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ { Clone::clone(&orig) } -/// Creates a new C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ from the contained elements. -#[no_mangle] -pub extern "C" fn C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_new(a: crate::lightning::chain::transaction::OutPoint, b: crate::c_types::derived::CVec_MonitorEventZ, c: crate::c_types::PublicKey) -> C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ { - C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ { a, b, c, } +pub extern "C" fn CResult_BlindedHopFeaturesDecodeErrorZ_clone(orig: &CResult_BlindedHopFeaturesDecodeErrorZ) -> CResult_BlindedHopFeaturesDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_ChannelTypeFeaturesDecodeErrorZ +pub union CResult_ChannelTypeFeaturesDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::features::ChannelTypeFeatures, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, } - -#[no_mangle] -/// Frees any resources used by the C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ. -pub extern "C" fn C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_free(_res: C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ) { } #[repr(C)] -/// A dynamically-allocated array of crate::c_types::derived::C3Tuple_OutPointCVec_MonitorEventZPublicKeyZs of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::derived::C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ, - /// The number of elements pointed to by `data`. - pub datalen: usize +/// A CResult_ChannelTypeFeaturesDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::features::ChannelTypeFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_ChannelTypeFeaturesDecodeErrorZ { + /// The contents of this CResult_ChannelTypeFeaturesDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_ChannelTypeFeaturesDecodeErrorZPtr, + /// Whether this CResult_ChannelTypeFeaturesDecodeErrorZ represents a success state. + pub result_ok: bool, } -impl CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret +#[no_mangle] +/// Creates a new CResult_ChannelTypeFeaturesDecodeErrorZ in the success state. +pub extern "C" fn CResult_ChannelTypeFeaturesDecodeErrorZ_ok(o: crate::lightning::ln::features::ChannelTypeFeatures) -> CResult_ChannelTypeFeaturesDecodeErrorZ { + CResult_ChannelTypeFeaturesDecodeErrorZ { + contents: CResult_ChannelTypeFeaturesDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } +} +#[no_mangle] +/// Creates a new CResult_ChannelTypeFeaturesDecodeErrorZ in the error state. +pub extern "C" fn CResult_ChannelTypeFeaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelTypeFeaturesDecodeErrorZ { + CResult_ChannelTypeFeaturesDecodeErrorZ { + contents: CResult_ChannelTypeFeaturesDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, } } -impl From> for CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(o: &CResult_ChannelTypeFeaturesDecodeErrorZ) -> bool { + o.result_ok } #[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ_free(_res: CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ) { } -impl Drop for CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ { +/// Frees any resources used by the CResult_ChannelTypeFeaturesDecodeErrorZ. +pub extern "C" fn CResult_ChannelTypeFeaturesDecodeErrorZ_free(_res: CResult_ChannelTypeFeaturesDecodeErrorZ) { } +impl Drop for CResult_ChannelTypeFeaturesDecodeErrorZ { fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } } } -impl Clone for CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ { +impl From> for CResult_ChannelTypeFeaturesDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_ChannelTypeFeaturesDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_ChannelTypeFeaturesDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_ChannelTypeFeaturesDecodeErrorZ { fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) + if self.result_ok { + Self { result_ok: true, contents: CResult_ChannelTypeFeaturesDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_ChannelTypeFeaturesDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } } } +#[no_mangle] +/// Creates a new CResult_ChannelTypeFeaturesDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_ChannelTypeFeaturesDecodeErrorZ_clone(orig: &CResult_ChannelTypeFeaturesDecodeErrorZ) -> CResult_ChannelTypeFeaturesDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_FixedPenaltyScorerDecodeErrorZ -pub union CResult_FixedPenaltyScorerDecodeErrorZPtr { +/// The contents of CResult_PaymentPurposeDecodeErrorZ +pub union CResult_PaymentPurposeDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::routing::scoring::FixedPenaltyScorer, + 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_FixedPenaltyScorerDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::routing::scoring::FixedPenaltyScorer on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_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_FixedPenaltyScorerDecodeErrorZ { - /// The contents of this CResult_FixedPenaltyScorerDecodeErrorZ, 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_FixedPenaltyScorerDecodeErrorZPtr, - /// Whether this CResult_FixedPenaltyScorerDecodeErrorZ 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_FixedPenaltyScorerDecodeErrorZ in the success state. -pub extern "C" fn CResult_FixedPenaltyScorerDecodeErrorZ_ok(o: crate::lightning::routing::scoring::FixedPenaltyScorer) -> CResult_FixedPenaltyScorerDecodeErrorZ { - CResult_FixedPenaltyScorerDecodeErrorZ { - contents: CResult_FixedPenaltyScorerDecodeErrorZPtr { +/// Creates a new CResult_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_FixedPenaltyScorerDecodeErrorZ in the error state. -pub extern "C" fn CResult_FixedPenaltyScorerDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_FixedPenaltyScorerDecodeErrorZ { - CResult_FixedPenaltyScorerDecodeErrorZ { - contents: CResult_FixedPenaltyScorerDecodeErrorZPtr { +/// Creates a new CResult_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, @@ -4407,13 +4914,13 @@ pub extern "C" fn CResult_FixedPenaltyScorerDecodeErrorZ_err(e: crate::lightning } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(o: &CResult_FixedPenaltyScorerDecodeErrorZ) -> bool { +pub extern "C" fn CResult_PaymentPurposeDecodeErrorZ_is_ok(o: &CResult_PaymentPurposeDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_FixedPenaltyScorerDecodeErrorZ. -pub extern "C" fn CResult_FixedPenaltyScorerDecodeErrorZ_free(_res: CResult_FixedPenaltyScorerDecodeErrorZ) { } -impl Drop for CResult_FixedPenaltyScorerDecodeErrorZ { +/// Frees any resources used by the CResult_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() } { @@ -4426,16 +4933,16 @@ impl Drop for CResult_FixedPenaltyScorerDecodeErrorZ { } } } -impl From> for CResult_FixedPenaltyScorerDecodeErrorZ { - 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_FixedPenaltyScorerDecodeErrorZPtr { result } + CResult_PaymentPurposeDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_FixedPenaltyScorerDecodeErrorZPtr { err } + CResult_PaymentPurposeDecodeErrorZPtr { err } }; Self { contents, @@ -4443,305 +4950,266 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_FixedPenaltyScorerDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_PaymentPurposeDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_FixedPenaltyScorerDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_PaymentPurposeDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_FixedPenaltyScorerDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_PaymentPurposeDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_FixedPenaltyScorerDecodeErrorZ_clone(orig: &CResult_FixedPenaltyScorerDecodeErrorZ) -> CResult_FixedPenaltyScorerDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_PaymentPurposeDecodeErrorZ_clone(orig: &CResult_PaymentPurposeDecodeErrorZ) -> CResult_PaymentPurposeDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple_u64u64Z { - /// The element at position 0 - pub a: u64, - /// The element at position 1 - pub b: u64, +#[derive(Clone)] +/// An enum which can either contain a crate::lightning::routing::gossip::NetworkUpdate or not +pub enum COption_NetworkUpdateZ { + /// When we're in this state, this COption_NetworkUpdateZ contains a crate::lightning::routing::gossip::NetworkUpdate + Some(crate::lightning::routing::gossip::NetworkUpdate), + /// When we're in this state, this COption_NetworkUpdateZ contains nothing + None } -impl From<(u64, u64)> for C2Tuple_u64u64Z { - fn from (tup: (u64, u64)) -> Self { - Self { - a: tup.0, - b: tup.1, - } +impl COption_NetworkUpdateZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } } -} -impl C2Tuple_u64u64Z { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (u64, u64) { - (self.a, self.b) + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() } -} -impl Clone for C2Tuple_u64u64Z { - fn clone(&self) -> Self { - Self { - a: Clone::clone(&self.a), - b: Clone::clone(&self.b), - } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::routing::gossip::NetworkUpdate { + if let Self::Some(v) = self { v } else { unreachable!() } } } #[no_mangle] -/// Creates a new tuple which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C2Tuple_u64u64Z_clone(orig: &C2Tuple_u64u64Z) -> C2Tuple_u64u64Z { Clone::clone(&orig) } -/// Creates a new C2Tuple_u64u64Z from the contained elements. +/// Constructs a new COption_NetworkUpdateZ containing a crate::lightning::routing::gossip::NetworkUpdate +pub extern "C" fn COption_NetworkUpdateZ_some(o: crate::lightning::routing::gossip::NetworkUpdate) -> COption_NetworkUpdateZ { + COption_NetworkUpdateZ::Some(o) +} #[no_mangle] -pub extern "C" fn C2Tuple_u64u64Z_new(a: u64, b: u64) -> C2Tuple_u64u64Z { - C2Tuple_u64u64Z { a, b, } +/// Constructs a new COption_NetworkUpdateZ containing nothing +pub extern "C" fn COption_NetworkUpdateZ_none() -> COption_NetworkUpdateZ { + COption_NetworkUpdateZ::None } - #[no_mangle] -/// Frees any resources used by the C2Tuple_u64u64Z. -pub extern "C" fn C2Tuple_u64u64Z_free(_res: C2Tuple_u64u64Z) { } +/// Frees any resources associated with the crate::lightning::routing::gossip::NetworkUpdate, if we are in the Some state +pub extern "C" fn COption_NetworkUpdateZ_free(_res: COption_NetworkUpdateZ) { } +#[no_mangle] +/// Creates a new COption_NetworkUpdateZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_NetworkUpdateZ_clone(orig: &COption_NetworkUpdateZ) -> COption_NetworkUpdateZ { Clone::clone(&orig) } #[repr(C)] #[derive(Clone)] -/// An enum which can either contain a crate::c_types::derived::C2Tuple_u64u64Z or not -pub enum COption_C2Tuple_u64u64ZZ { - /// When we're in this state, this COption_C2Tuple_u64u64ZZ contains a crate::c_types::derived::C2Tuple_u64u64Z - Some(crate::c_types::derived::C2Tuple_u64u64Z), - /// When we're in this state, this COption_C2Tuple_u64u64ZZ contains nothing +/// 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_C2Tuple_u64u64ZZ { +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::derived::C2Tuple_u64u64Z { + #[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_C2Tuple_u64u64ZZ containing a crate::c_types::derived::C2Tuple_u64u64Z -pub extern "C" fn COption_C2Tuple_u64u64ZZ_some(o: crate::c_types::derived::C2Tuple_u64u64Z) -> COption_C2Tuple_u64u64ZZ { - COption_C2Tuple_u64u64ZZ::Some(o) +/// 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_C2Tuple_u64u64ZZ containing nothing -pub extern "C" fn COption_C2Tuple_u64u64ZZ_none() -> COption_C2Tuple_u64u64ZZ { - COption_C2Tuple_u64u64ZZ::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::derived::C2Tuple_u64u64Z, if we are in the Some state -pub extern "C" fn COption_C2Tuple_u64u64ZZ_free(_res: COption_C2Tuple_u64u64ZZ) { } +/// 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_C2Tuple_u64u64ZZ 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_C2Tuple_u64u64ZZ_clone(orig: &COption_C2Tuple_u64u64ZZ) -> COption_C2Tuple_u64u64ZZ { Clone::clone(&orig) } +pub extern "C" fn COption_PathFailureZ_clone(orig: &COption_PathFailureZ) -> COption_PathFailureZ { Clone::clone(&orig) } #[repr(C)] -/// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple_Z { - /// The element at position 0 - pub a: crate::c_types::EightU16s, - /// The element at position 1 - pub b: crate::c_types::EightU16s, +/// 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<(crate::c_types::EightU16s, crate::c_types::EightU16s)> for C2Tuple_Z { - fn from (tup: (crate::c_types::EightU16s, crate::c_types::EightU16s)) -> Self { - Self { - a: tup.0, - b: tup.1, - } - } +#[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, } -impl C2Tuple_Z { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::EightU16s, crate::c_types::EightU16s) { - (self.a, self.b) +#[no_mangle] +/// 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 C2Tuple_Z { - fn clone(&self) -> Self { - Self { - a: Clone::clone(&self.a), - b: Clone::clone(&self.b), - } +#[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, } } +/// Checks if the given object is currently in the success state #[no_mangle] -/// Creates a new tuple which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C2Tuple_Z_clone(orig: &C2Tuple_Z) -> C2Tuple_Z { Clone::clone(&orig) } -/// Creates a new C2Tuple_Z from the contained elements. -#[no_mangle] -pub extern "C" fn C2Tuple_Z_new(a: crate::c_types::EightU16s, b: crate::c_types::EightU16s) -> C2Tuple_Z { - C2Tuple_Z { a, b, } +pub extern "C" fn CResult_COption_PathFailureZDecodeErrorZ_is_ok(o: &CResult_COption_PathFailureZDecodeErrorZ) -> bool { + o.result_ok } - #[no_mangle] -/// Frees any resources used by the C2Tuple_Z. -pub extern "C" fn C2Tuple_Z_free(_res: C2Tuple_Z) { } -#[repr(C)] -/// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple__u168_u168Z { - /// The element at position 0 - pub a: crate::c_types::EightU16s, - /// The element at position 1 - pub b: crate::c_types::EightU16s, -} -impl From<(crate::c_types::EightU16s, crate::c_types::EightU16s)> for C2Tuple__u168_u168Z { - fn from (tup: (crate::c_types::EightU16s, crate::c_types::EightU16s)) -> Self { - Self { - a: tup.0, - b: tup.1, +/// 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) }; + } } } } -impl C2Tuple__u168_u168Z { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::EightU16s, crate::c_types::EightU16s) { - (self.a, self.b) +impl 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, + } } } -impl Clone for C2Tuple__u168_u168Z { +impl Clone for CResult_COption_PathFailureZDecodeErrorZ { 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_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] -/// Creates a new tuple 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 C2Tuple__u168_u168Z_clone(orig: &C2Tuple__u168_u168Z) -> C2Tuple__u168_u168Z { Clone::clone(&orig) } -/// Creates a new C2Tuple__u168_u168Z from the contained elements. -#[no_mangle] -pub extern "C" fn C2Tuple__u168_u168Z_new(a: crate::c_types::EightU16s, b: crate::c_types::EightU16s) -> C2Tuple__u168_u168Z { - C2Tuple__u168_u168Z { a, b, } -} - -#[no_mangle] -/// Frees any resources used by the C2Tuple__u168_u168Z. -pub extern "C" fn C2Tuple__u168_u168Z_free(_res: C2Tuple__u168_u168Z) { } +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::c_types::derived::C2Tuple__u168_u168Z or not -pub enum COption_C2Tuple_EightU16sEightU16sZZ { - /// When we're in this state, this COption_C2Tuple_EightU16sEightU16sZZ contains a crate::c_types::derived::C2Tuple__u168_u168Z - Some(crate::c_types::derived::C2Tuple__u168_u168Z), - /// When we're in this state, this COption_C2Tuple_EightU16sEightU16sZZ contains nothing +/// 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_C2Tuple_EightU16sEightU16sZZ { +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::c_types::derived::C2Tuple__u168_u168Z { + #[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_C2Tuple_EightU16sEightU16sZZ containing a crate::c_types::derived::C2Tuple__u168_u168Z -pub extern "C" fn COption_C2Tuple_EightU16sEightU16sZZ_some(o: crate::c_types::derived::C2Tuple__u168_u168Z) -> COption_C2Tuple_EightU16sEightU16sZZ { - COption_C2Tuple_EightU16sEightU16sZZ::Some(o) +/// 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_C2Tuple_EightU16sEightU16sZZ containing nothing -pub extern "C" fn COption_C2Tuple_EightU16sEightU16sZZ_none() -> COption_C2Tuple_EightU16sEightU16sZZ { - COption_C2Tuple_EightU16sEightU16sZZ::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::c_types::derived::C2Tuple__u168_u168Z, if we are in the Some state -pub extern "C" fn COption_C2Tuple_EightU16sEightU16sZZ_free(_res: COption_C2Tuple_EightU16sEightU16sZZ) { } +/// Frees any resources 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_C2Tuple_EightU16sEightU16sZZ 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_C2Tuple_EightU16sEightU16sZZ_clone(orig: &COption_C2Tuple_EightU16sEightU16sZZ) -> COption_C2Tuple_EightU16sEightU16sZZ { Clone::clone(&orig) } -#[repr(C)] -/// A dynamically-allocated array of crate::lightning::routing::gossip::NodeIds of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_NodeIdZ { - /// 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::gossip::NodeId, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_NodeIdZ { - #[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::gossip::NodeId] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_NodeIdZ { - 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_NodeIdZ_free(_res: CVec_NodeIdZ) { } -impl Drop for CVec_NodeIdZ { - 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_NodeIdZ { - 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 COption_ClosureReasonZ_clone(orig: &COption_ClosureReasonZ) -> COption_ClosureReasonZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_ProbabilisticScorerDecodeErrorZ -pub union CResult_ProbabilisticScorerDecodeErrorZPtr { +/// The contents of CResult_COption_ClosureReasonZDecodeErrorZ +pub union CResult_COption_ClosureReasonZDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::routing::scoring::ProbabilisticScorer, + 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_ProbabilisticScorerDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::routing::scoring::ProbabilisticScorer on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// 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_ProbabilisticScorerDecodeErrorZ { - /// The contents of this CResult_ProbabilisticScorerDecodeErrorZ, 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_ProbabilisticScorerDecodeErrorZPtr, - /// Whether this CResult_ProbabilisticScorerDecodeErrorZ 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_ProbabilisticScorerDecodeErrorZ in the success state. -pub extern "C" fn CResult_ProbabilisticScorerDecodeErrorZ_ok(o: crate::lightning::routing::scoring::ProbabilisticScorer) -> CResult_ProbabilisticScorerDecodeErrorZ { - CResult_ProbabilisticScorerDecodeErrorZ { - contents: CResult_ProbabilisticScorerDecodeErrorZPtr { +/// 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_ProbabilisticScorerDecodeErrorZ in the error state. -pub extern "C" fn CResult_ProbabilisticScorerDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ProbabilisticScorerDecodeErrorZ { - CResult_ProbabilisticScorerDecodeErrorZ { - contents: CResult_ProbabilisticScorerDecodeErrorZPtr { +/// 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, @@ -4749,13 +5217,13 @@ pub extern "C" fn CResult_ProbabilisticScorerDecodeErrorZ_err(e: crate::lightnin } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ProbabilisticScorerDecodeErrorZ_is_ok(o: &CResult_ProbabilisticScorerDecodeErrorZ) -> bool { +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_ProbabilisticScorerDecodeErrorZ. -pub extern "C" fn CResult_ProbabilisticScorerDecodeErrorZ_free(_res: CResult_ProbabilisticScorerDecodeErrorZ) { } -impl Drop for CResult_ProbabilisticScorerDecodeErrorZ { +/// 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() } { @@ -4768,16 +5236,16 @@ impl Drop for CResult_ProbabilisticScorerDecodeErrorZ { } } } -impl From> for CResult_ProbabilisticScorerDecodeErrorZ { - 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_ProbabilisticScorerDecodeErrorZPtr { result } + CResult_COption_ClosureReasonZDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ProbabilisticScorerDecodeErrorZPtr { err } + CResult_COption_ClosureReasonZDecodeErrorZPtr { err } }; Self { contents, @@ -4785,42 +5253,96 @@ 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 }))) + } } + } else { + 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_ClosureReasonZDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_COption_ClosureReasonZDecodeErrorZ_clone(orig: &CResult_COption_ClosureReasonZDecodeErrorZ) -> CResult_COption_ClosureReasonZDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +#[derive(Clone)] +/// An enum which can either contain a crate::lightning::events::HTLCDestination or not +pub enum COption_HTLCDestinationZ { + /// When we're in this state, this COption_HTLCDestinationZ contains a crate::lightning::events::HTLCDestination + Some(crate::lightning::events::HTLCDestination), + /// When we're in this state, this COption_HTLCDestinationZ contains nothing + None +} +impl COption_HTLCDestinationZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::events::HTLCDestination { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_HTLCDestinationZ containing a crate::lightning::events::HTLCDestination +pub extern "C" fn COption_HTLCDestinationZ_some(o: crate::lightning::events::HTLCDestination) -> COption_HTLCDestinationZ { + COption_HTLCDestinationZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_HTLCDestinationZ containing nothing +pub extern "C" fn COption_HTLCDestinationZ_none() -> COption_HTLCDestinationZ { + COption_HTLCDestinationZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::lightning::events::HTLCDestination, if we are in the Some state +pub extern "C" fn COption_HTLCDestinationZ_free(_res: COption_HTLCDestinationZ) { } +#[no_mangle] +/// Creates a new COption_HTLCDestinationZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_HTLCDestinationZ_clone(orig: &COption_HTLCDestinationZ) -> COption_HTLCDestinationZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_InitFeaturesDecodeErrorZ -pub union CResult_InitFeaturesDecodeErrorZPtr { +/// The contents of CResult_COption_HTLCDestinationZDecodeErrorZ +pub union CResult_COption_HTLCDestinationZDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::features::InitFeatures, + pub result: *mut crate::c_types::derived::COption_HTLCDestinationZ, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_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. +/// 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_InitFeaturesDecodeErrorZ { - /// The contents of this CResult_InitFeaturesDecodeErrorZ, 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_InitFeaturesDecodeErrorZPtr, - /// Whether this CResult_InitFeaturesDecodeErrorZ represents a success state. + pub contents: CResult_COption_HTLCDestinationZDecodeErrorZPtr, + /// Whether this CResult_COption_HTLCDestinationZDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_InitFeaturesDecodeErrorZ in the success state. -pub extern "C" fn CResult_InitFeaturesDecodeErrorZ_ok(o: crate::lightning::ln::features::InitFeatures) -> CResult_InitFeaturesDecodeErrorZ { - CResult_InitFeaturesDecodeErrorZ { - contents: CResult_InitFeaturesDecodeErrorZPtr { +/// 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_InitFeaturesDecodeErrorZ in the error state. -pub extern "C" fn CResult_InitFeaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_InitFeaturesDecodeErrorZ { - CResult_InitFeaturesDecodeErrorZ { - contents: CResult_InitFeaturesDecodeErrorZPtr { +/// 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, @@ -4828,13 +5350,13 @@ pub extern "C" fn CResult_InitFeaturesDecodeErrorZ_err(e: crate::lightning::ln:: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_InitFeaturesDecodeErrorZ_is_ok(o: &CResult_InitFeaturesDecodeErrorZ) -> bool { +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_InitFeaturesDecodeErrorZ. -pub extern "C" fn CResult_InitFeaturesDecodeErrorZ_free(_res: CResult_InitFeaturesDecodeErrorZ) { } -impl Drop for CResult_InitFeaturesDecodeErrorZ { +/// 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() } { @@ -4847,16 +5369,16 @@ impl Drop for CResult_InitFeaturesDecodeErrorZ { } } } -impl From> for CResult_InitFeaturesDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_COption_HTLCDestinationZDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_InitFeaturesDecodeErrorZPtr { result } + CResult_COption_HTLCDestinationZDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_InitFeaturesDecodeErrorZPtr { err } + CResult_COption_HTLCDestinationZDecodeErrorZPtr { err } }; Self { contents, @@ -4864,59 +5386,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_InitFeaturesDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_COption_HTLCDestinationZDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_InitFeaturesDecodeErrorZPtr { + 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_InitFeaturesDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_COption_HTLCDestinationZDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_InitFeaturesDecodeErrorZ_clone(orig: &CResult_InitFeaturesDecodeErrorZ) -> CResult_InitFeaturesDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_COption_HTLCDestinationZDecodeErrorZ_clone(orig: &CResult_COption_HTLCDestinationZDecodeErrorZ) -> CResult_COption_HTLCDestinationZDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_ChannelFeaturesDecodeErrorZ -pub union CResult_ChannelFeaturesDecodeErrorZPtr { +/// The contents of CResult_PaymentFailureReasonDecodeErrorZ +pub union CResult_PaymentFailureReasonDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::features::ChannelFeatures, + pub result: *mut crate::lightning::events::PaymentFailureReason, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_ChannelFeaturesDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::features::ChannelFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_PaymentFailureReasonDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::events::PaymentFailureReason on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ChannelFeaturesDecodeErrorZ { - /// The contents of this CResult_ChannelFeaturesDecodeErrorZ, accessible via either +pub struct CResult_PaymentFailureReasonDecodeErrorZ { + /// The contents of this CResult_PaymentFailureReasonDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ChannelFeaturesDecodeErrorZPtr, - /// Whether this CResult_ChannelFeaturesDecodeErrorZ represents a success state. + pub contents: CResult_PaymentFailureReasonDecodeErrorZPtr, + /// Whether this CResult_PaymentFailureReasonDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ChannelFeaturesDecodeErrorZ in the success state. -pub extern "C" fn CResult_ChannelFeaturesDecodeErrorZ_ok(o: crate::lightning::ln::features::ChannelFeatures) -> CResult_ChannelFeaturesDecodeErrorZ { - CResult_ChannelFeaturesDecodeErrorZ { - contents: CResult_ChannelFeaturesDecodeErrorZPtr { +/// Creates a new CResult_PaymentFailureReasonDecodeErrorZ in the success state. +pub extern "C" fn CResult_PaymentFailureReasonDecodeErrorZ_ok(o: crate::lightning::events::PaymentFailureReason) -> CResult_PaymentFailureReasonDecodeErrorZ { + CResult_PaymentFailureReasonDecodeErrorZ { + contents: CResult_PaymentFailureReasonDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ChannelFeaturesDecodeErrorZ in the error state. -pub extern "C" fn CResult_ChannelFeaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelFeaturesDecodeErrorZ { - CResult_ChannelFeaturesDecodeErrorZ { - contents: CResult_ChannelFeaturesDecodeErrorZPtr { +/// Creates a new CResult_PaymentFailureReasonDecodeErrorZ in the error state. +pub extern "C" fn CResult_PaymentFailureReasonDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_PaymentFailureReasonDecodeErrorZ { + CResult_PaymentFailureReasonDecodeErrorZ { + contents: CResult_PaymentFailureReasonDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -4924,13 +5446,13 @@ pub extern "C" fn CResult_ChannelFeaturesDecodeErrorZ_err(e: crate::lightning::l } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ChannelFeaturesDecodeErrorZ_is_ok(o: &CResult_ChannelFeaturesDecodeErrorZ) -> bool { +pub extern "C" fn CResult_PaymentFailureReasonDecodeErrorZ_is_ok(o: &CResult_PaymentFailureReasonDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_ChannelFeaturesDecodeErrorZ. -pub extern "C" fn CResult_ChannelFeaturesDecodeErrorZ_free(_res: CResult_ChannelFeaturesDecodeErrorZ) { } -impl Drop for CResult_ChannelFeaturesDecodeErrorZ { +/// Frees any resources used by the CResult_PaymentFailureReasonDecodeErrorZ. +pub extern "C" fn CResult_PaymentFailureReasonDecodeErrorZ_free(_res: CResult_PaymentFailureReasonDecodeErrorZ) { } +impl Drop for CResult_PaymentFailureReasonDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -4943,16 +5465,16 @@ impl Drop for CResult_ChannelFeaturesDecodeErrorZ { } } } -impl From> for CResult_ChannelFeaturesDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_PaymentFailureReasonDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ChannelFeaturesDecodeErrorZPtr { result } + CResult_PaymentFailureReasonDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ChannelFeaturesDecodeErrorZPtr { err } + CResult_PaymentFailureReasonDecodeErrorZPtr { err } }; Self { contents, @@ -4960,155 +5482,216 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ChannelFeaturesDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_PaymentFailureReasonDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_ChannelFeaturesDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_PaymentFailureReasonDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_ChannelFeaturesDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_PaymentFailureReasonDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ChannelFeaturesDecodeErrorZ_clone(orig: &CResult_ChannelFeaturesDecodeErrorZ) -> CResult_ChannelFeaturesDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_PaymentFailureReasonDecodeErrorZ_clone(orig: &CResult_PaymentFailureReasonDecodeErrorZ) -> CResult_PaymentFailureReasonDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_NodeFeaturesDecodeErrorZ -pub union CResult_NodeFeaturesDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::features::NodeFeatures, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, +#[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 } -#[repr(C)] -/// A CResult_NodeFeaturesDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::features::NodeFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_NodeFeaturesDecodeErrorZ { - /// The contents of this CResult_NodeFeaturesDecodeErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_NodeFeaturesDecodeErrorZPtr, - /// Whether this CResult_NodeFeaturesDecodeErrorZ represents a success state. - pub result_ok: bool, +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] -/// Creates a new CResult_NodeFeaturesDecodeErrorZ in the success state. -pub extern "C" fn CResult_NodeFeaturesDecodeErrorZ_ok(o: crate::lightning::ln::features::NodeFeatures) -> CResult_NodeFeaturesDecodeErrorZ { - CResult_NodeFeaturesDecodeErrorZ { - contents: CResult_NodeFeaturesDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, - } +/// 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] -/// Creates a new CResult_NodeFeaturesDecodeErrorZ in the error state. -pub extern "C" fn CResult_NodeFeaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_NodeFeaturesDecodeErrorZ { - CResult_NodeFeaturesDecodeErrorZ { - contents: CResult_NodeFeaturesDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), - }, - result_ok: false, +/// Constructs a new COption_u128Z containing nothing +pub extern "C" fn COption_u128Z_none() -> COption_u128Z { + COption_u128Z::None +} +#[no_mangle] +/// Frees any resources associated with the crate::c_types::U128, if we are in the Some state +pub extern "C" fn COption_u128Z_free(_res: COption_u128Z) { } +#[no_mangle] +/// Creates a new COption_u128Z which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_u128Z_clone(orig: &COption_u128Z) -> COption_u128Z { Clone::clone(&orig) } +#[repr(C)] +#[derive(Clone)] +/// An enum which can either contain a crate::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!() } } } -/// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_NodeFeaturesDecodeErrorZ_is_ok(o: &CResult_NodeFeaturesDecodeErrorZ) -> bool { - o.result_ok +/// 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] -/// Frees any resources used by the CResult_NodeFeaturesDecodeErrorZ. -pub extern "C" fn CResult_NodeFeaturesDecodeErrorZ_free(_res: CResult_NodeFeaturesDecodeErrorZ) { } -impl Drop for CResult_NodeFeaturesDecodeErrorZ { +/// Constructs a new COption_PaymentFailureReasonZ containing nothing +pub extern "C" fn COption_PaymentFailureReasonZ_none() -> COption_PaymentFailureReasonZ { + COption_PaymentFailureReasonZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::lightning::events::PaymentFailureReason, if we are in the Some state +pub extern "C" fn COption_PaymentFailureReasonZ_free(_res: COption_PaymentFailureReasonZ) { } +#[no_mangle] +/// Creates a new COption_PaymentFailureReasonZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_PaymentFailureReasonZ_clone(orig: &COption_PaymentFailureReasonZ) -> COption_PaymentFailureReasonZ { Clone::clone(&orig) } +#[repr(C)] +/// A dynamically-allocated array of crate::lightning::chain::keysinterface::SpendableOutputDescriptors of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_SpendableOutputDescriptorZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::chain::keysinterface::SpendableOutputDescriptor, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_SpendableOutputDescriptorZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::chain::keysinterface::SpendableOutputDescriptor] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_SpendableOutputDescriptorZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_SpendableOutputDescriptorZ_free(_res: CVec_SpendableOutputDescriptorZ) { } +impl Drop for CVec_SpendableOutputDescriptorZ { fn drop(&mut self) { - if self.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_NodeFeaturesDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { - let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_NodeFeaturesDecodeErrorZPtr { result } - } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_NodeFeaturesDecodeErrorZPtr { err } - }; - Self { - contents, - result_ok: o.result_ok, - } +impl Clone for CVec_SpendableOutputDescriptorZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +#[derive(Clone)] +/// An enum which can either contain a crate::lightning::events::Event or not +pub enum COption_EventZ { + /// When we're in this state, this COption_EventZ contains a crate::lightning::events::Event + Some(crate::lightning::events::Event), + /// When we're in this state, this COption_EventZ contains nothing + None +} +impl COption_EventZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } } -} -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 }))) - } } - } else { - Self { result_ok: false, contents: CResult_NodeFeaturesDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } - } + #[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] -/// Creates a new CResult_NodeFeaturesDecodeErrorZ which has the same data as `orig` +/// 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 CResult_NodeFeaturesDecodeErrorZ_clone(orig: &CResult_NodeFeaturesDecodeErrorZ) -> CResult_NodeFeaturesDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn COption_EventZ_clone(orig: &COption_EventZ) -> COption_EventZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_InvoiceFeaturesDecodeErrorZ -pub union CResult_InvoiceFeaturesDecodeErrorZPtr { +/// The contents of CResult_COption_EventZDecodeErrorZ +pub union CResult_COption_EventZDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::features::InvoiceFeatures, + 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_InvoiceFeaturesDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::features::InvoiceFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_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_InvoiceFeaturesDecodeErrorZ { - /// The contents of this CResult_InvoiceFeaturesDecodeErrorZ, accessible via either +pub struct CResult_COption_EventZDecodeErrorZ { + /// The contents of this CResult_COption_EventZDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_InvoiceFeaturesDecodeErrorZPtr, - /// Whether this CResult_InvoiceFeaturesDecodeErrorZ represents a success state. + pub contents: CResult_COption_EventZDecodeErrorZPtr, + /// Whether this CResult_COption_EventZDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_InvoiceFeaturesDecodeErrorZ in the success state. -pub extern "C" fn CResult_InvoiceFeaturesDecodeErrorZ_ok(o: crate::lightning::ln::features::InvoiceFeatures) -> CResult_InvoiceFeaturesDecodeErrorZ { - CResult_InvoiceFeaturesDecodeErrorZ { - contents: CResult_InvoiceFeaturesDecodeErrorZPtr { +/// 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_InvoiceFeaturesDecodeErrorZ in the error state. -pub extern "C" fn CResult_InvoiceFeaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_InvoiceFeaturesDecodeErrorZ { - CResult_InvoiceFeaturesDecodeErrorZ { - contents: CResult_InvoiceFeaturesDecodeErrorZPtr { +/// 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, @@ -5116,13 +5699,13 @@ pub extern "C" fn CResult_InvoiceFeaturesDecodeErrorZ_err(e: crate::lightning::l } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_InvoiceFeaturesDecodeErrorZ_is_ok(o: &CResult_InvoiceFeaturesDecodeErrorZ) -> bool { +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_InvoiceFeaturesDecodeErrorZ. -pub extern "C" fn CResult_InvoiceFeaturesDecodeErrorZ_free(_res: CResult_InvoiceFeaturesDecodeErrorZ) { } -impl Drop for CResult_InvoiceFeaturesDecodeErrorZ { +/// 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() } { @@ -5135,16 +5718,16 @@ impl Drop for CResult_InvoiceFeaturesDecodeErrorZ { } } } -impl From> for CResult_InvoiceFeaturesDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_COption_EventZDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_InvoiceFeaturesDecodeErrorZPtr { result } + CResult_COption_EventZDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_InvoiceFeaturesDecodeErrorZPtr { err } + CResult_COption_EventZDecodeErrorZPtr { err } }; Self { contents, @@ -5152,155 +5735,151 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_InvoiceFeaturesDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_COption_EventZDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_InvoiceFeaturesDecodeErrorZPtr { + 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_InvoiceFeaturesDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_COption_EventZDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_InvoiceFeaturesDecodeErrorZ_clone(orig: &CResult_InvoiceFeaturesDecodeErrorZ) -> CResult_InvoiceFeaturesDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_COption_EventZDecodeErrorZ_clone(orig: &CResult_COption_EventZDecodeErrorZ) -> CResult_COption_EventZDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_BlindedHopFeaturesDecodeErrorZ -pub union CResult_BlindedHopFeaturesDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::features::BlindedHopFeatures, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, +/// A dynamically-allocated array of crate::lightning::events::MessageSendEvents of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_MessageSendEventZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::events::MessageSendEvent, + /// The number of elements pointed to by `data`. + pub datalen: usize } -#[repr(C)] -/// A CResult_BlindedHopFeaturesDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::features::BlindedHopFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_BlindedHopFeaturesDecodeErrorZ { - /// The contents of this CResult_BlindedHopFeaturesDecodeErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_BlindedHopFeaturesDecodeErrorZPtr, - /// Whether this CResult_BlindedHopFeaturesDecodeErrorZ represents a success state. - pub result_ok: bool, +impl CVec_MessageSendEventZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::events::MessageSendEvent] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } } -#[no_mangle] -/// Creates a new CResult_BlindedHopFeaturesDecodeErrorZ in the success state. -pub extern "C" fn CResult_BlindedHopFeaturesDecodeErrorZ_ok(o: crate::lightning::ln::features::BlindedHopFeatures) -> CResult_BlindedHopFeaturesDecodeErrorZ { - CResult_BlindedHopFeaturesDecodeErrorZ { - contents: CResult_BlindedHopFeaturesDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, +impl From> for CVec_MessageSendEventZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } } } #[no_mangle] -/// Creates a new CResult_BlindedHopFeaturesDecodeErrorZ in the error state. -pub extern "C" fn CResult_BlindedHopFeaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_BlindedHopFeaturesDecodeErrorZ { - CResult_BlindedHopFeaturesDecodeErrorZ { - contents: CResult_BlindedHopFeaturesDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), - }, - result_ok: false, +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_MessageSendEventZ_free(_res: CVec_MessageSendEventZ) { } +impl Drop for CVec_MessageSendEventZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -/// Checks if the given object is currently in the success state -#[no_mangle] -pub extern "C" fn CResult_BlindedHopFeaturesDecodeErrorZ_is_ok(o: &CResult_BlindedHopFeaturesDecodeErrorZ) -> bool { - o.result_ok +impl Clone for CVec_MessageSendEventZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } } -#[no_mangle] -/// Frees any resources used by the CResult_BlindedHopFeaturesDecodeErrorZ. -pub extern "C" fn CResult_BlindedHopFeaturesDecodeErrorZ_free(_res: CResult_BlindedHopFeaturesDecodeErrorZ) { } -impl Drop for CResult_BlindedHopFeaturesDecodeErrorZ { - 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) }; - } - } +#[repr(C)] +/// A dynamically-allocated array of crate::c_types::ThirtyTwoBytess of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_ChainHashZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::ThirtyTwoBytes, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_ChainHashZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::ThirtyTwoBytes] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl From> for CResult_BlindedHopFeaturesDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { - let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_BlindedHopFeaturesDecodeErrorZPtr { result } - } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_BlindedHopFeaturesDecodeErrorZPtr { err } - }; - Self { - contents, - result_ok: o.result_ok, - } +impl From> for CVec_ChainHashZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } } } -impl Clone for CResult_BlindedHopFeaturesDecodeErrorZ { +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_ChainHashZ_free(_res: CVec_ChainHashZ) { } +impl Drop for CVec_ChainHashZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_ChainHashZ { fn clone(&self) -> Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_BlindedHopFeaturesDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_BlindedHopFeaturesDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } - } + 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_BlindedHopFeaturesDecodeErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_BlindedHopFeaturesDecodeErrorZ_clone(orig: &CResult_BlindedHopFeaturesDecodeErrorZ) -> CResult_BlindedHopFeaturesDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_ChannelTypeFeaturesDecodeErrorZ -pub union CResult_ChannelTypeFeaturesDecodeErrorZPtr { +/// The contents of CResult_PublicKeyErrorZ +pub union CResult_PublicKeyErrorZPtr { /// A 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::c_types::PublicKey, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::c_types::Secp256k1Error, } #[repr(C)] -/// A CResult_ChannelTypeFeaturesDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::features::ChannelTypeFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_PublicKeyErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::PublicKey on success and a crate::c_types::Secp256k1Error on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ChannelTypeFeaturesDecodeErrorZ { - /// The contents of this CResult_ChannelTypeFeaturesDecodeErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ChannelTypeFeaturesDecodeErrorZPtr, - /// Whether this CResult_ChannelTypeFeaturesDecodeErrorZ represents a success state. +pub struct CResult_PublicKeyErrorZ { + /// The contents of this CResult_PublicKeyErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_PublicKeyErrorZPtr, + /// Whether this CResult_PublicKeyErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ChannelTypeFeaturesDecodeErrorZ in the success state. -pub extern "C" fn CResult_ChannelTypeFeaturesDecodeErrorZ_ok(o: crate::lightning::ln::features::ChannelTypeFeatures) -> CResult_ChannelTypeFeaturesDecodeErrorZ { - CResult_ChannelTypeFeaturesDecodeErrorZ { - contents: CResult_ChannelTypeFeaturesDecodeErrorZPtr { +/// Creates a new CResult_PublicKeyErrorZ in the success state. +pub extern "C" fn CResult_PublicKeyErrorZ_ok(o: crate::c_types::PublicKey) -> CResult_PublicKeyErrorZ { + CResult_PublicKeyErrorZ { + contents: CResult_PublicKeyErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ChannelTypeFeaturesDecodeErrorZ in the error state. -pub extern "C" fn CResult_ChannelTypeFeaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelTypeFeaturesDecodeErrorZ { - CResult_ChannelTypeFeaturesDecodeErrorZ { - contents: CResult_ChannelTypeFeaturesDecodeErrorZPtr { +/// Creates a new CResult_PublicKeyErrorZ in the error state. +pub extern "C" fn CResult_PublicKeyErrorZ_err(e: crate::c_types::Secp256k1Error) -> CResult_PublicKeyErrorZ { + CResult_PublicKeyErrorZ { + contents: CResult_PublicKeyErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -5308,13 +5887,13 @@ pub extern "C" fn CResult_ChannelTypeFeaturesDecodeErrorZ_err(e: crate::lightnin } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(o: &CResult_ChannelTypeFeaturesDecodeErrorZ) -> bool { +pub extern "C" fn CResult_PublicKeyErrorZ_is_ok(o: &CResult_PublicKeyErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_ChannelTypeFeaturesDecodeErrorZ. -pub extern "C" fn CResult_ChannelTypeFeaturesDecodeErrorZ_free(_res: CResult_ChannelTypeFeaturesDecodeErrorZ) { } -impl Drop for CResult_ChannelTypeFeaturesDecodeErrorZ { +/// Frees any resources used by the CResult_PublicKeyErrorZ. +pub extern "C" fn CResult_PublicKeyErrorZ_free(_res: CResult_PublicKeyErrorZ) { } +impl Drop for CResult_PublicKeyErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -5327,16 +5906,16 @@ impl Drop for CResult_ChannelTypeFeaturesDecodeErrorZ { } } } -impl From> for CResult_ChannelTypeFeaturesDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_PublicKeyErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ChannelTypeFeaturesDecodeErrorZPtr { result } + CResult_PublicKeyErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ChannelTypeFeaturesDecodeErrorZPtr { err } + CResult_PublicKeyErrorZPtr { err } }; Self { contents, @@ -5344,23 +5923,23 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ChannelTypeFeaturesDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_PublicKeyErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_ChannelTypeFeaturesDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_PublicKeyErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_ChannelTypeFeaturesDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_PublicKeyErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ChannelTypeFeaturesDecodeErrorZ_clone(orig: &CResult_ChannelTypeFeaturesDecodeErrorZ) -> CResult_ChannelTypeFeaturesDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_PublicKeyErrorZ_clone(orig: &CResult_PublicKeyErrorZ) -> CResult_PublicKeyErrorZ { Clone::clone(&orig) } #[repr(C)] /// The contents of CResult_NodeIdDecodeErrorZ pub union CResult_NodeIdDecodeErrorZPtr { @@ -7588,52 +8167,6 @@ impl From 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) -> &[u8] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_u8Z { - 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_u8Z_free(_res: CVec_u8Z) { } -impl Drop for CVec_u8Z { - 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_u8Z { - 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::derived::CVec_u8Zs of arbitrary size. /// This corresponds to std::vector in C++ pub struct CVec_CVec_u8ZZ { @@ -10158,6 +10691,102 @@ impl Clone for CResult_COption_APIErrorZDecodeErrorZ { /// but with all dynamically-allocated buffers duplicated in new buffers. pub extern "C" fn CResult_COption_APIErrorZDecodeErrorZ_clone(orig: &CResult_COption_APIErrorZDecodeErrorZ) -> CResult_COption_APIErrorZDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] +/// The contents of CResult_UntrustedStringDecodeErrorZ +pub union CResult_UntrustedStringDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::util::string::UntrustedString, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_UntrustedStringDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::util::string::UntrustedString on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_UntrustedStringDecodeErrorZ { + /// The contents of this CResult_UntrustedStringDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_UntrustedStringDecodeErrorZPtr, + /// Whether this CResult_UntrustedStringDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_UntrustedStringDecodeErrorZ in the success state. +pub extern "C" fn CResult_UntrustedStringDecodeErrorZ_ok(o: crate::lightning::util::string::UntrustedString) -> CResult_UntrustedStringDecodeErrorZ { + CResult_UntrustedStringDecodeErrorZ { + contents: CResult_UntrustedStringDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_UntrustedStringDecodeErrorZ in the error state. +pub extern "C" fn CResult_UntrustedStringDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_UntrustedStringDecodeErrorZ { + CResult_UntrustedStringDecodeErrorZ { + contents: CResult_UntrustedStringDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_UntrustedStringDecodeErrorZ_is_ok(o: &CResult_UntrustedStringDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_UntrustedStringDecodeErrorZ. +pub extern "C" fn CResult_UntrustedStringDecodeErrorZ_free(_res: CResult_UntrustedStringDecodeErrorZ) { } +impl Drop for CResult_UntrustedStringDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_UntrustedStringDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_UntrustedStringDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_UntrustedStringDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_UntrustedStringDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_UntrustedStringDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_UntrustedStringDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_UntrustedStringDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_UntrustedStringDecodeErrorZ_clone(orig: &CResult_UntrustedStringDecodeErrorZ) -> CResult_UntrustedStringDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] /// The contents of CResult_OutPointDecodeErrorZ pub union CResult_OutPointDecodeErrorZPtr { /// A pointer to the contents in the success state. @@ -10638,112 +11267,16 @@ impl Clone for CResult_StringErrorZ { result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_StringErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } - } - } -} -#[no_mangle] -/// Creates a new CResult_StringErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_StringErrorZ_clone(orig: &CResult_StringErrorZ) -> CResult_StringErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// The contents of CResult_PublicKeyErrorZ -pub union CResult_PublicKeyErrorZPtr { - /// A 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, - /// 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_PublicKeyErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::PublicKey on success and a crate::c_types::Secp256k1Error on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_PublicKeyErrorZ { - /// The contents of this CResult_PublicKeyErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_PublicKeyErrorZPtr, - /// Whether this CResult_PublicKeyErrorZ represents a success state. - pub result_ok: bool, -} -#[no_mangle] -/// Creates a new CResult_PublicKeyErrorZ in the success state. -pub extern "C" fn CResult_PublicKeyErrorZ_ok(o: crate::c_types::PublicKey) -> CResult_PublicKeyErrorZ { - CResult_PublicKeyErrorZ { - contents: CResult_PublicKeyErrorZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, - } -} -#[no_mangle] -/// Creates a new CResult_PublicKeyErrorZ in the error state. -pub extern "C" fn CResult_PublicKeyErrorZ_err(e: crate::c_types::Secp256k1Error) -> CResult_PublicKeyErrorZ { - CResult_PublicKeyErrorZ { - contents: CResult_PublicKeyErrorZPtr { - 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_PublicKeyErrorZ_is_ok(o: &CResult_PublicKeyErrorZ) -> bool { - o.result_ok -} -#[no_mangle] -/// Frees any resources used by the CResult_PublicKeyErrorZ. -pub extern "C" fn CResult_PublicKeyErrorZ_free(_res: CResult_PublicKeyErrorZ) { } -impl Drop for CResult_PublicKeyErrorZ { - 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_PublicKeyErrorZ { - fn from(mut o: crate::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_PublicKeyErrorZPtr { result } - } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_PublicKeyErrorZPtr { err } - }; - Self { - contents, - result_ok: o.result_ok, - } - } -} -impl Clone for CResult_PublicKeyErrorZ { - fn clone(&self) -> Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_PublicKeyErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_PublicKeyErrorZPtr { + Self { result_ok: false, contents: CResult_StringErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_PublicKeyErrorZ which has the same data as `orig` +/// Creates a new CResult_StringErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_PublicKeyErrorZ_clone(orig: &CResult_PublicKeyErrorZ) -> CResult_PublicKeyErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_StringErrorZ_clone(orig: &CResult_StringErrorZ) -> CResult_StringErrorZ { Clone::clone(&orig) } #[repr(C)] /// The contents of CResult_ChannelMonitorUpdateDecodeErrorZ pub union CResult_ChannelMonitorUpdateDecodeErrorZPtr { @@ -11288,29 +11821,29 @@ impl Clone for CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ { } } #[repr(C)] -/// A dynamically-allocated array of crate::lightning::util::events::Events of arbitrary size. +/// A dynamically-allocated array of crate::lightning::events::Events of arbitrary size. /// This corresponds to std::vector in C++ pub struct CVec_EventZ { /// The elements in the array. /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::util::events::Event, + pub data: *mut crate::lightning::events::Event, /// The number of elements pointed to by `data`. pub datalen: usize } impl CVec_EventZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + #[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::events::Event] { + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::events::Event] { unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl From> for CVec_EventZ { - fn from(v: Vec) -> Self { +impl From> for CVec_EventZ { + fn from(v: Vec) -> Self { let datalen = v.len(); let data = Box::into_raw(v.into_boxed_slice()); Self { datalen, data: unsafe { (*data).as_mut_ptr() } } @@ -12422,16 +12955,283 @@ impl Drop for CResult_NoneSendErrorZ { } } } -impl From> for CResult_NoneSendErrorZ { - fn from(mut o: crate::c_types::CResultTempl<(), crate::lightning::onion_message::messenger::SendError>) -> Self { +impl From> for CResult_NoneSendErrorZ { + fn from(mut o: crate::c_types::CResultTempl<(), crate::lightning::onion_message::messenger::SendError>) -> Self { + let contents = if o.result_ok { + let _ = unsafe { Box::from_raw(o.contents.result) }; + o.contents.result = core::ptr::null_mut(); + CResult_NoneSendErrorZPtr { result: core::ptr::null_mut() } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_NoneSendErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +#[repr(C)] +/// The contents of CResult_BlindedPathNoneZ +pub union CResult_BlindedPathNoneZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::blinded_path::BlindedPath, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut core::ffi::c_void, +} +#[repr(C)] +/// A CResult_BlindedPathNoneZ represents the result of a fallible operation, +/// containing a crate::lightning::blinded_path::BlindedPath on success and a () on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_BlindedPathNoneZ { + /// The contents of this CResult_BlindedPathNoneZ, 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 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 { + 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(), + }, + 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 { + 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 { + 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_BlindedPathNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_BlindedPathNoneZPtr { result } + } else { + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_BlindedPathNoneZPtr { err: core::ptr::null_mut() } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_BlindedPathNoneZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_BlindedPathNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_BlindedPathNoneZPtr { + err: core::ptr::null_mut() + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_BlindedPathNoneZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_BlindedPathNoneZ_clone(orig: &CResult_BlindedPathNoneZ) -> CResult_BlindedPathNoneZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_BlindedPathDecodeErrorZ +pub union CResult_BlindedPathDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::blinded_path::BlindedPath, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_BlindedPathDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::blinded_path::BlindedPath on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_BlindedPathDecodeErrorZ { + /// The contents of this CResult_BlindedPathDecodeErrorZ, 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 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 { + 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 { + 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_BlindedPathDecodeErrorZ_is_ok(o: &CResult_BlindedPathDecodeErrorZ) -> 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 { + 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_BlindedPathDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_BlindedPathDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_BlindedPathDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_BlindedPathDecodeErrorZ { + fn clone(&self) -> 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 }))) + } } + } + } +} +#[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) } +#[repr(C)] +/// The contents of CResult_BlindedHopDecodeErrorZ +pub union CResult_BlindedHopDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::blinded_path::BlindedHop, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_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_BlindedHopDecodeErrorZ { + /// The contents of this CResult_BlindedHopDecodeErrorZ, 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 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 { + 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 { + 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_BlindedHopDecodeErrorZ_is_ok(o: &CResult_BlindedHopDecodeErrorZ) -> 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 { + 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_BlindedHopDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { - let _ = unsafe { Box::from_raw(o.contents.result) }; - o.contents.result = core::ptr::null_mut(); - CResult_NoneSendErrorZPtr { result: core::ptr::null_mut() } + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_BlindedHopDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_NoneSendErrorZPtr { err } + CResult_BlindedHopDecodeErrorZPtr { err } }; Self { contents, @@ -12439,6 +13239,23 @@ 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_SiPrefixParseErrorZ pub union CResult_SiPrefixParseErrorZPtr { @@ -13200,6 +14017,52 @@ impl Clone for CResult_InvoiceSemanticErrorZ { /// but with all dynamically-allocated buffers duplicated in new buffers. pub extern "C" fn CResult_InvoiceSemanticErrorZ_clone(orig: &CResult_InvoiceSemanticErrorZ) -> CResult_InvoiceSemanticErrorZ { Clone::clone(&orig) } #[repr(C)] +/// A dynamically-allocated array of crate::c_types::Strs of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_AddressZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::Str, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_AddressZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::Str] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_AddressZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_AddressZ_free(_res: CVec_AddressZ) { } +impl Drop for CVec_AddressZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_AddressZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] /// The contents of CResult_DescriptionCreationErrorZ pub union CResult_DescriptionCreationErrorZPtr { /// A pointer to the contents in the success state. @@ -13392,85 +14255,6 @@ impl Clone for CResult_PrivateRouteCreationErrorZ { /// but with all dynamically-allocated buffers duplicated in new buffers. pub extern "C" fn CResult_PrivateRouteCreationErrorZ_clone(orig: &CResult_PrivateRouteCreationErrorZ) -> CResult_PrivateRouteCreationErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_u32GraphSyncErrorZ -pub union CResult_u32GraphSyncErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut u32, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning_rapid_gossip_sync::error::GraphSyncError, -} -#[repr(C)] -/// A CResult_u32GraphSyncErrorZ represents the result of a fallible operation, -/// containing a u32 on success and a crate::lightning_rapid_gossip_sync::error::GraphSyncError on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_u32GraphSyncErrorZ { - /// The contents of this CResult_u32GraphSyncErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_u32GraphSyncErrorZPtr, - /// Whether this CResult_u32GraphSyncErrorZ represents a success state. - pub result_ok: bool, -} -#[no_mangle] -/// Creates a new CResult_u32GraphSyncErrorZ in the success state. -pub extern "C" fn CResult_u32GraphSyncErrorZ_ok(o: u32) -> CResult_u32GraphSyncErrorZ { - CResult_u32GraphSyncErrorZ { - contents: CResult_u32GraphSyncErrorZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, - } -} -#[no_mangle] -/// Creates a new CResult_u32GraphSyncErrorZ in the error state. -pub extern "C" fn CResult_u32GraphSyncErrorZ_err(e: crate::lightning_rapid_gossip_sync::error::GraphSyncError) -> CResult_u32GraphSyncErrorZ { - CResult_u32GraphSyncErrorZ { - contents: CResult_u32GraphSyncErrorZPtr { - err: Box::into_raw(Box::new(e)), - }, - result_ok: false, - } -} -/// Checks if the given object is currently in the success state -#[no_mangle] -pub extern "C" fn CResult_u32GraphSyncErrorZ_is_ok(o: &CResult_u32GraphSyncErrorZ) -> bool { - o.result_ok -} -#[no_mangle] -/// Frees any resources used by the CResult_u32GraphSyncErrorZ. -pub extern "C" fn CResult_u32GraphSyncErrorZ_free(_res: CResult_u32GraphSyncErrorZ) { } -impl Drop for CResult_u32GraphSyncErrorZ { - fn drop(&mut self) { - if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } - } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } - } - } -} -impl From> for CResult_u32GraphSyncErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { - let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_u32GraphSyncErrorZPtr { result } - } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_u32GraphSyncErrorZPtr { err } - }; - Self { - contents, - result_ok: o.result_ok, - } - } -} -#[repr(C)] /// The contents of CResult_NetAddressDecodeErrorZ pub union CResult_NetAddressDecodeErrorZPtr { /// A pointer to the contents in the success state. @@ -17157,6 +17941,52 @@ impl Clone for CResult_InvoiceSignOrCreationErrorZ { /// but with all dynamically-allocated buffers duplicated in new buffers. pub extern "C" fn CResult_InvoiceSignOrCreationErrorZ_clone(orig: &CResult_InvoiceSignOrCreationErrorZ) -> CResult_InvoiceSignOrCreationErrorZ { Clone::clone(&orig) } #[repr(C)] +/// A dynamically-allocated array of crate::lightning::util::wakers::Futures of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_FutureZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::util::wakers::Future, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_FutureZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::util::wakers::Future] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_FutureZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_FutureZ_free(_res: CVec_FutureZ) { } +impl Drop for CVec_FutureZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_FutureZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[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 @@ -17443,3 +18273,82 @@ impl Clone for CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ { Self::from(res) } } +#[repr(C)] +/// The contents of CResult_u32GraphSyncErrorZ +pub union CResult_u32GraphSyncErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut u32, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning_rapid_gossip_sync::error::GraphSyncError, +} +#[repr(C)] +/// A CResult_u32GraphSyncErrorZ represents the result of a fallible operation, +/// containing a u32 on success and a crate::lightning_rapid_gossip_sync::error::GraphSyncError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_u32GraphSyncErrorZ { + /// The contents of this CResult_u32GraphSyncErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_u32GraphSyncErrorZPtr, + /// Whether this CResult_u32GraphSyncErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_u32GraphSyncErrorZ in the success state. +pub extern "C" fn CResult_u32GraphSyncErrorZ_ok(o: u32) -> CResult_u32GraphSyncErrorZ { + CResult_u32GraphSyncErrorZ { + contents: CResult_u32GraphSyncErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_u32GraphSyncErrorZ in the error state. +pub extern "C" fn CResult_u32GraphSyncErrorZ_err(e: crate::lightning_rapid_gossip_sync::error::GraphSyncError) -> CResult_u32GraphSyncErrorZ { + CResult_u32GraphSyncErrorZ { + contents: CResult_u32GraphSyncErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_u32GraphSyncErrorZ_is_ok(o: &CResult_u32GraphSyncErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_u32GraphSyncErrorZ. +pub extern "C" fn CResult_u32GraphSyncErrorZ_free(_res: CResult_u32GraphSyncErrorZ) { } +impl Drop for CResult_u32GraphSyncErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_u32GraphSyncErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_u32GraphSyncErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_u32GraphSyncErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} diff --git a/lightning-c-bindings/src/lightning/onion_message/blinded_path.rs b/lightning-c-bindings/src/lightning/blinded_path.rs similarity index 64% rename from lightning-c-bindings/src/lightning/onion_message/blinded_path.rs rename to lightning-c-bindings/src/lightning/blinded_path.rs index 9051d24..febf222 100644 --- a/lightning-c-bindings/src/lightning/onion_message/blinded_path.rs +++ b/lightning-c-bindings/src/lightning/blinded_path.rs @@ -16,12 +16,23 @@ use crate::c_types::*; #[cfg(feature="no-std")] use alloc::{vec::Vec, boxed::Box}; +mod utils { -use lightning::onion_message::blinded_path::BlindedPath as nativeBlindedPathImport; +use alloc::str::FromStr; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + +} + +use lightning::blinded_path::BlindedPath as nativeBlindedPathImport; pub(crate) type nativeBlindedPath = nativeBlindedPathImport; -/// Onion messages can be sent and received to blinded paths, which serve to hide the identity of -/// the recipient. +/// 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 { @@ -87,8 +98,27 @@ pub(crate) extern "C" fn BlindedPath_clone_void(this_ptr: *const c_void) -> *mut pub extern "C" fn BlindedPath_clone(orig: &BlindedPath) -> BlindedPath { orig.clone() } +/// 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 } +} -use lightning::onion_message::blinded_path::BlindedHop as nativeBlindedHopImport; +use lightning::blinded_path::BlindedHop as nativeBlindedHopImport; pub(crate) type nativeBlindedHop = nativeBlindedHopImport; /// Used to construct the blinded hops portion of a blinded path. These hops cannot be identified @@ -158,22 +188,41 @@ pub(crate) extern "C" fn BlindedHop_clone_void(this_ptr: *const c_void) -> *mut pub extern "C" fn BlindedHop_clone(orig: &BlindedHop) -> BlindedHop { orig.clone() } -/// Create a blinded path to be forwarded along `node_pks`. The last node pubkey in `node_pks` -/// will be the destination node. +/// Generates a non-cryptographic 64-bit hash of the BlindedHop. +#[no_mangle] +pub extern "C" fn BlindedHop_hash(o: &BlindedHop) -> 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 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. +#[no_mangle] +pub extern "C" fn BlindedHop_eq(a: &BlindedHop, b: &BlindedHop) -> 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 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 less than two hops are provided or if `node_pk`(s) are invalid. #[must_use] #[no_mangle] -pub extern "C" fn BlindedPath_new(mut node_pks: crate::c_types::derived::CVec_PublicKeyZ, entropy_source: &crate::lightning::chain::keysinterface::EntropySource) -> crate::c_types::derived::CResult_BlindedPathNoneZ { +pub extern "C" fn BlindedPath_new_for_message(mut node_pks: crate::c_types::derived::CVec_PublicKeyZ, entropy_source: &crate::lightning::chain::keysinterface::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::onion_message::blinded_path::BlindedPath::new(&local_node_pks[..], entropy_source, secp256k1::global::SECP256K1); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::onion_message::blinded_path::BlindedPath { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + 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 } #[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::onion_message::blinded_path::BlindedPath) -> crate::c_types::derived::CVec_u8Z { +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()) } #[no_mangle] @@ -183,13 +232,13 @@ pub(crate) extern "C" fn BlindedPath_write_void(obj: *const c_void) -> crate::c_ #[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::onion_message::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() }; + 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::onion_message::blinded_path::BlindedHop) -> crate::c_types::derived::CVec_u8Z { +pub extern "C" fn BlindedHop_write(obj: &crate::lightning::blinded_path::BlindedHop) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) } #[no_mangle] @@ -199,7 +248,7 @@ pub(crate) extern "C" fn BlindedHop_write_void(obj: *const c_void) -> crate::c_t #[no_mangle] /// Read a BlindedHop from a byte array, created by BlindedHop_write pub extern "C" fn BlindedHop_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_BlindedHopDecodeErrorZ { - 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::blinded_path::BlindedHop { 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::blinded_path::BlindedHop { 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/chain/chaininterface.rs b/lightning-c-bindings/src/lightning/chain/chaininterface.rs index 4c22d56..687262b 100644 --- a/lightning-c-bindings/src/lightning/chain/chaininterface.rs +++ b/lightning-c-bindings/src/lightning/chain/chaininterface.rs @@ -135,7 +135,7 @@ pub extern "C" fn ConfirmationTarget_normal() -> ConfirmationTarget { /// Utility method to constructs a new HighPriority-variant ConfirmationTarget pub extern "C" fn ConfirmationTarget_high_priority() -> ConfirmationTarget { ConfirmationTarget::HighPriority} -/// Checks if two ConfirmationTargets contain equal inner contents. +/// Generates a non-cryptographic 64-bit hash of the ConfirmationTarget. #[no_mangle] pub extern "C" fn ConfirmationTarget_hash(o: &ConfirmationTarget) -> u64 { // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core diff --git a/lightning-c-bindings/src/lightning/chain/chainmonitor.rs b/lightning-c-bindings/src/lightning/chain/chainmonitor.rs index 049fe4e..f6a97a3 100644 --- a/lightning-c-bindings/src/lightning/chain/chainmonitor.rs +++ b/lightning-c-bindings/src/lightning/chain/chainmonitor.rs @@ -100,7 +100,7 @@ pub(crate) extern "C" fn MonitorUpdateId_clone_void(this_ptr: *const c_void) -> pub extern "C" fn MonitorUpdateId_clone(orig: &MonitorUpdateId) -> MonitorUpdateId { orig.clone() } -/// Checks if two MonitorUpdateIds contain equal inner contents. +/// 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; } @@ -310,8 +310,15 @@ pub(crate) type nativeChainMonitor = nativeChainMonitorImport crate::lightning::chain::chainmonitor::ChainMonitor { - let mut local_chain_source = { /* chain_source*/ let chain_source_opt = chain_source; { } if chain_source_opt.is_none() { None } else { Some({ chain_source_opt.take() }) } }; + let mut local_chain_source = { /*chain_source*/ let chain_source_opt = chain_source; if chain_source_opt.is_none() { None } else { Some({ { { chain_source_opt.take() } }})} }; let mut ret = lightning::chain::chainmonitor::ChainMonitor::new(local_chain_source, broadcaster, logger, feeest, persister); crate::lightning::chain::chainmonitor::ChainMonitor { inner: ObjOps::heap_alloc(ret), is_owned: true } } @@ -446,6 +453,31 @@ pub extern "C" fn ChainMonitor_channel_monitor_updated(this_arg: &crate::lightni local_ret } +/// Gets a [`Future`] that completes when an event is available either via +/// [`chain::Watch::release_pending_monitor_events`] or +/// [`EventsProvider::process_pending_events`]. +/// +/// Note that callbacks registered on the [`Future`] MUST NOT call back into this +/// [`ChainMonitor`] and should instead register actions to be taken later. +/// +/// [`EventsProvider::process_pending_events`]: crate::events::EventsProvider::process_pending_events +#[must_use] +#[no_mangle] +pub extern "C" fn ChainMonitor_get_update_future(this_arg: &crate::lightning::chain::chainmonitor::ChainMonitor) -> 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 } +} + +/// Triggers rebroadcasts/fee-bumps of pending claims from a force-closed channel. This is +/// crucial in preventing certain classes of pinning attacks, detecting substantial mempool +/// feerate changes between blocks, and ensuring reliability if broadcasting fails. We recommend +/// invoking this every 30 seconds, or lower if running in an environment with spotty +/// connections, like on mobile. +#[no_mangle] +pub extern "C" fn ChainMonitor_rebroadcast_pending_claims(this_arg: &crate::lightning::chain::chainmonitor::ChainMonitor) { + unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.rebroadcast_pending_claims() +} + impl From for crate::lightning::chain::Listen { fn from(obj: nativeChainMonitor) -> Self { let mut rust_obj = ChainMonitor { inner: ObjOps::heap_alloc(obj), is_owned: true }; @@ -561,7 +593,7 @@ extern "C" fn ChainMonitor_Watch_release_pending_monitor_events(this_arg: *const local_ret.into() } -impl From for crate::lightning::util::events::EventsProvider { +impl From for crate::lightning::events::EventsProvider { fn from(obj: nativeChainMonitor) -> Self { let mut rust_obj = ChainMonitor { inner: ObjOps::heap_alloc(obj), is_owned: true }; let mut ret = ChainMonitor_as_EventsProvider(&rust_obj); @@ -574,15 +606,15 @@ impl From for crate::lightning::util::events::EventsProvider /// 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 ChainMonitor_as_EventsProvider(this_arg: &ChainMonitor) -> crate::lightning::util::events::EventsProvider { - crate::lightning::util::events::EventsProvider { +pub extern "C" fn ChainMonitor_as_EventsProvider(this_arg: &ChainMonitor) -> 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: ChainMonitor_EventsProvider_process_pending_events, } } -extern "C" fn ChainMonitor_EventsProvider_process_pending_events(this_arg: *const c_void, mut handler: crate::lightning::util::events::EventHandler) { - >::process_pending_events(unsafe { &mut *(this_arg as *mut nativeChainMonitor) }, handler) +extern "C" fn ChainMonitor_EventsProvider_process_pending_events(this_arg: *const c_void, mut handler: crate::lightning::events::EventHandler) { + >::process_pending_events(unsafe { &mut *(this_arg as *mut nativeChainMonitor) }, handler) } diff --git a/lightning-c-bindings/src/lightning/chain/channelmonitor.rs b/lightning-c-bindings/src/lightning/chain/channelmonitor.rs index 1378873..dbe2932 100644 --- a/lightning-c-bindings/src/lightning/chain/channelmonitor.rs +++ b/lightning-c-bindings/src/lightning/chain/channelmonitor.rs @@ -86,15 +86,17 @@ impl ChannelMonitorUpdate { } /// The sequence number of this update. Updates *must* be replayed in-order according to this /// sequence number (and updates may panic if they are not). The update_id values are strictly -/// increasing and increase by one for each new update, with one exception specified below. +/// increasing and increase by one for each new update, with two exceptions specified below. /// /// This sequence number is also used to track up to which points updates which returned /// [`ChannelMonitorUpdateStatus::InProgress`] have been applied to all copies of a given /// ChannelMonitor when ChannelManager::channel_monitor_updated is called. /// -/// The only instance where update_id values are not strictly increasing is the case where we -/// allow post-force-close updates with a special update ID of [`CLOSED_CHANNEL_UPDATE_ID`]. See -/// its docs for more details. +/// The only instances we allow where update_id values are not strictly increasing have a +/// special update ID of [`CLOSED_CHANNEL_UPDATE_ID`]. This update ID is used for updates that +/// will force close the channel by broadcasting the latest commitment transaction or +/// special post-force-close updates, like providing preimages necessary to claim outputs on the +/// broadcast commitment transaction. See its docs for more details. /// /// [`ChannelMonitorUpdateStatus::InProgress`]: super::ChannelMonitorUpdateStatus::InProgress #[no_mangle] @@ -104,15 +106,17 @@ pub extern "C" fn ChannelMonitorUpdate_get_update_id(this_ptr: &ChannelMonitorUp } /// The sequence number of this update. Updates *must* be replayed in-order according to this /// sequence number (and updates may panic if they are not). The update_id values are strictly -/// increasing and increase by one for each new update, with one exception specified below. +/// increasing and increase by one for each new update, with two exceptions specified below. /// /// This sequence number is also used to track up to which points updates which returned /// [`ChannelMonitorUpdateStatus::InProgress`] have been applied to all copies of a given /// ChannelMonitor when ChannelManager::channel_monitor_updated is called. /// -/// The only instance where update_id values are not strictly increasing is the case where we -/// allow post-force-close updates with a special update ID of [`CLOSED_CHANNEL_UPDATE_ID`]. See -/// its docs for more details. +/// The only instances we allow where update_id values are not strictly increasing have a +/// special update ID of [`CLOSED_CHANNEL_UPDATE_ID`]. This update ID is used for updates that +/// will force close the channel by broadcasting the latest commitment transaction or +/// special post-force-close updates, like providing preimages necessary to claim outputs on the +/// broadcast commitment transaction. See its docs for more details. /// /// [`ChannelMonitorUpdateStatus::InProgress`]: super::ChannelMonitorUpdateStatus::InProgress #[no_mangle] @@ -138,13 +142,23 @@ pub(crate) extern "C" fn ChannelMonitorUpdate_clone_void(this_ptr: *const c_void pub extern "C" fn ChannelMonitorUpdate_clone(orig: &ChannelMonitorUpdate) -> ChannelMonitorUpdate { orig.clone() } -/// If: -/// (1) a channel has been force closed and -/// (2) we receive a preimage from a forward link that allows us to spend an HTLC output on -/// this channel's (the backward link's) broadcasted commitment transaction -/// then we allow the `ChannelManager` to send a `ChannelMonitorUpdate` with this update ID, -/// with the update providing said payment preimage. No other update types are allowed after -/// force-close. +/// Checks if two ChannelMonitorUpdates contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn ChannelMonitorUpdate_eq(a: &ChannelMonitorUpdate, b: &ChannelMonitorUpdate) -> 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 update ID used for a [`ChannelMonitorUpdate`] that is either: +/// +///\t(1) attempting to force close the channel by broadcasting our latest commitment transaction or +///\t(2) providing a preimage (after the channel has been force closed) from a forward link that +///\t\tallows us to spend an HTLC output on this channel's (the backward link's) broadcasted +///\t\tcommitment transaction. +/// +/// No other [`ChannelMonitorUpdate`]s are allowed after force-close. #[no_mangle] pub static CLOSED_CHANNEL_UPDATE_ID: u64 = lightning::chain::channelmonitor::CLOSED_CHANNEL_UPDATE_ID; @@ -927,13 +941,13 @@ pub extern "C" fn ChannelMonitor_get_and_clear_pending_monitor_events(this_arg: /// This is called by the [`EventsProvider::process_pending_events`] implementation for /// [`ChainMonitor`]. /// -/// [`EventsProvider::process_pending_events`]: crate::util::events::EventsProvider::process_pending_events +/// [`EventsProvider::process_pending_events`]: crate::events::EventsProvider::process_pending_events /// [`ChainMonitor`]: crate::chain::chainmonitor::ChainMonitor #[must_use] #[no_mangle] pub extern "C" fn ChannelMonitor_get_and_clear_pending_events(this_arg: &crate::lightning::chain::channelmonitor::ChannelMonitor) -> crate::c_types::derived::CVec_EventZ { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_and_clear_pending_events(); - let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::util::events::Event::native_into(item) }); }; + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::events::Event::native_into(item) }); }; local_ret.into() } @@ -1061,6 +1075,16 @@ pub extern "C" fn ChannelMonitor_current_best_block(this_arg: &crate::lightning: crate::lightning::chain::BestBlock { inner: ObjOps::heap_alloc(ret), is_owned: true } } +/// Triggers rebroadcasts/fee-bumps of pending claims from a force-closed channel. This is +/// crucial in preventing certain classes of pinning attacks, detecting substantial mempool +/// feerate changes between blocks, and ensuring reliability if broadcasting fails. We recommend +/// invoking this every 30 seconds, or lower if running in an environment with spotty +/// connections, like on mobile. +#[no_mangle] +pub extern "C" fn ChannelMonitor_rebroadcast_pending_claims(this_arg: &crate::lightning::chain::channelmonitor::ChannelMonitor, mut broadcaster: crate::lightning::chain::chaininterface::BroadcasterInterface, mut fee_estimator: crate::lightning::chain::chaininterface::FeeEstimator, mut logger: crate::lightning::util::logger::Logger) { + unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.rebroadcast_pending_claims(broadcaster, fee_estimator, logger) +} + /// Gets the balances in this channel which are either claimable by us if we were to /// force-close the channel now or which are claimable on-chain (possibly awaiting /// confirmation). diff --git a/lightning-c-bindings/src/lightning/chain/keysinterface.rs b/lightning-c-bindings/src/lightning/chain/keysinterface.rs index c8db360..eaf36ac 100644 --- a/lightning-c-bindings/src/lightning/chain/keysinterface.rs +++ b/lightning-c-bindings/src/lightning/chain/keysinterface.rs @@ -379,7 +379,7 @@ pub extern "C" fn StaticPaymentOutputDescriptor_read(ser: crate::c_types::u8slic /// outpoint describing which `txid` and output `index` is available, the full output which exists /// at that `txid`/`index`, and any keys or other information required to sign. /// -/// [`SpendableOutputs`]: crate::util::events::Event::SpendableOutputs +/// [`SpendableOutputs`]: crate::events::Event::SpendableOutputs #[derive(Clone)] #[must_use] #[repr(C)] @@ -1305,7 +1305,7 @@ impl rustNodeSigner for NodeSigner { local_ret } fn ecdh(&self, mut recipient: lightning::chain::keysinterface::Recipient, mut other_key: &bitcoin::secp256k1::PublicKey, mut tweak: Option<&bitcoin::secp256k1::Scalar>) -> Result { - let mut local_tweak = if tweak.is_none() { crate::c_types::derived::COption_ScalarZ::None } else { crate::c_types::derived::COption_ScalarZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option is otherwise un-expressable. */ { crate::c_types::BigEndianScalar::from_rust(tweak.clone().unwrap()) }) }; + let mut local_tweak = if tweak.is_none() { crate::c_types::derived::COption_ScalarZ::None } else { crate::c_types::derived::COption_ScalarZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option is otherwise un-expressable. */ { crate::c_types::BigEndianScalar::from_rust(&(*tweak.as_ref().unwrap()).clone()) }) }; let mut ret = (self.ecdh)(self.this_arg, crate::lightning::chain::keysinterface::Recipient::native_into(recipient), crate::c_types::PublicKey::from_rust(&other_key), local_tweak); let mut local_ret = match ret.result_ok { true => Ok( { ::bitcoin::secp256k1::ecdh::SharedSecret::from_bytes((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).data) }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; local_ret @@ -1599,8 +1599,8 @@ pub extern "C" fn InMemorySigner_clone(orig: &InMemorySigner) -> InMemorySigner /// Creates a new [`InMemorySigner`]. #[must_use] #[no_mangle] -pub extern "C" fn InMemorySigner_new(mut funding_key: crate::c_types::SecretKey, mut revocation_base_key: crate::c_types::SecretKey, mut payment_key: crate::c_types::SecretKey, mut delayed_payment_base_key: crate::c_types::SecretKey, mut htlc_base_key: crate::c_types::SecretKey, mut commitment_seed: crate::c_types::ThirtyTwoBytes, mut channel_value_satoshis: u64, mut channel_keys_id: crate::c_types::ThirtyTwoBytes) -> crate::lightning::chain::keysinterface::InMemorySigner { - let mut ret = lightning::chain::keysinterface::InMemorySigner::new(secp256k1::global::SECP256K1, funding_key.into_rust(), revocation_base_key.into_rust(), payment_key.into_rust(), delayed_payment_base_key.into_rust(), htlc_base_key.into_rust(), commitment_seed.data, channel_value_satoshis, channel_keys_id.data); +pub extern "C" fn InMemorySigner_new(mut funding_key: crate::c_types::SecretKey, mut revocation_base_key: crate::c_types::SecretKey, mut payment_key: crate::c_types::SecretKey, mut delayed_payment_base_key: crate::c_types::SecretKey, mut htlc_base_key: crate::c_types::SecretKey, mut commitment_seed: crate::c_types::ThirtyTwoBytes, mut channel_value_satoshis: u64, mut channel_keys_id: crate::c_types::ThirtyTwoBytes, mut rand_bytes_unique_start: crate::c_types::ThirtyTwoBytes) -> crate::lightning::chain::keysinterface::InMemorySigner { + let mut ret = lightning::chain::keysinterface::InMemorySigner::new(secp256k1::global::SECP256K1, funding_key.into_rust(), revocation_base_key.into_rust(), payment_key.into_rust(), delayed_payment_base_key.into_rust(), htlc_base_key.into_rust(), commitment_seed.data, channel_value_satoshis, channel_keys_id.data, rand_bytes_unique_start.data); crate::lightning::chain::keysinterface::InMemorySigner { inner: ObjOps::heap_alloc(ret), is_owned: true } } @@ -1713,6 +1713,33 @@ pub extern "C" fn InMemorySigner_sign_dynamic_p2wsh_input(this_arg: &crate::ligh local_ret } +impl From for crate::lightning::chain::keysinterface::EntropySource { + fn from(obj: nativeInMemorySigner) -> Self { + let mut rust_obj = InMemorySigner { inner: ObjOps::heap_alloc(obj), is_owned: true }; + let mut ret = InMemorySigner_as_EntropySource(&rust_obj); + // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn + rust_obj.inner = core::ptr::null_mut(); + ret.free = Some(InMemorySigner_free_void); + ret + } +} +/// Constructs a new EntropySource which calls the relevant methods on this_arg. +/// This copies the `inner` pointer in this_arg and thus the returned EntropySource must be freed before this_arg is +#[no_mangle] +pub extern "C" fn InMemorySigner_as_EntropySource(this_arg: &InMemorySigner) -> crate::lightning::chain::keysinterface::EntropySource { + crate::lightning::chain::keysinterface::EntropySource { + this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, + free: None, + get_secure_random_bytes: InMemorySigner_EntropySource_get_secure_random_bytes, + } +} + +#[must_use] +extern "C" fn InMemorySigner_EntropySource_get_secure_random_bytes(this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes { + let mut ret = >::get_secure_random_bytes(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, ); + crate::c_types::ThirtyTwoBytes { data: ret } +} + impl From for crate::lightning::chain::keysinterface::ChannelSigner { fn from(obj: nativeInMemorySigner) -> Self { let mut rust_obj = InMemorySigner { inner: ObjOps::heap_alloc(obj), is_owned: true }; @@ -1934,8 +1961,9 @@ pub(crate) extern "C" fn InMemorySigner_write_void(obj: *const c_void) -> crate: } #[no_mangle] /// Read a InMemorySigner from a byte array, created by InMemorySigner_write -pub extern "C" fn InMemorySigner_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_InMemorySignerDecodeErrorZ { - let res: Result = crate::c_types::deserialize_obj(ser); +pub extern "C" fn InMemorySigner_read(ser: crate::c_types::u8slice, arg: crate::lightning::chain::keysinterface::EntropySource) -> crate::c_types::derived::CResult_InMemorySignerDecodeErrorZ { + let arg_conv = arg; + let res: Result = crate::c_types::deserialize_obj_arg(ser, arg_conv); let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::chain::keysinterface::InMemorySigner { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; local_res } @@ -2129,7 +2157,7 @@ extern "C" fn KeysManager_NodeSigner_get_node_id(this_arg: *const c_void, mut re } #[must_use] extern "C" fn KeysManager_NodeSigner_ecdh(this_arg: *const c_void, mut recipient: crate::lightning::chain::keysinterface::Recipient, mut other_key: crate::c_types::PublicKey, mut tweak: crate::c_types::derived::COption_ScalarZ) -> crate::c_types::derived::CResult_SharedSecretNoneZ { - let mut local_tweak_base = { /* tweak*/ let tweak_opt = tweak; { } if tweak_opt.is_none() { None } else { Some({ tweak_opt.take().into_rust() }) } }; let mut local_tweak = local_tweak_base.as_ref(); + let mut local_tweak_base = { /*tweak*/ let tweak_opt = tweak; if tweak_opt.is_none() { None } else { Some({ { { tweak_opt.take() }.into_rust() }})} }; let mut local_tweak = local_tweak_base.as_ref(); let mut ret = >::ecdh(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, recipient.into_native(), &other_key.into_rust(), local_tweak); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ThirtyTwoBytes { data: o.secret_bytes() } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; local_ret @@ -2330,7 +2358,7 @@ extern "C" fn PhantomKeysManager_NodeSigner_get_node_id(this_arg: *const c_void, } #[must_use] extern "C" fn PhantomKeysManager_NodeSigner_ecdh(this_arg: *const c_void, mut recipient: crate::lightning::chain::keysinterface::Recipient, mut other_key: crate::c_types::PublicKey, mut tweak: crate::c_types::derived::COption_ScalarZ) -> crate::c_types::derived::CResult_SharedSecretNoneZ { - let mut local_tweak_base = { /* tweak*/ let tweak_opt = tweak; { } if tweak_opt.is_none() { None } else { Some({ tweak_opt.take().into_rust() }) } }; let mut local_tweak = local_tweak_base.as_ref(); + let mut local_tweak_base = { /*tweak*/ let tweak_opt = tweak; if tweak_opt.is_none() { None } else { Some({ { { tweak_opt.take() }.into_rust() }})} }; let mut local_tweak = local_tweak_base.as_ref(); let mut ret = >::ecdh(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, recipient.into_native(), &other_key.into_rust(), local_tweak); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ThirtyTwoBytes { data: o.secret_bytes() } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; local_ret diff --git a/lightning-c-bindings/src/lightning/chain/mod.rs b/lightning-c-bindings/src/lightning/chain/mod.rs index 62d26cb..74fe721 100644 --- a/lightning-c-bindings/src/lightning/chain/mod.rs +++ b/lightning-c-bindings/src/lightning/chain/mod.rs @@ -846,7 +846,7 @@ pub extern "C" fn WatchedOutput_eq(a: &WatchedOutput, b: &WatchedOutput) -> bool 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 WatchedOutputs contain equal inner contents. +/// Generates a non-cryptographic 64-bit hash of the WatchedOutput. #[no_mangle] pub extern "C" fn WatchedOutput_hash(o: &WatchedOutput) -> u64 { if o.inner.is_null() { return 0; } diff --git a/lightning-c-bindings/src/lightning/chain/transaction.rs b/lightning-c-bindings/src/lightning/chain/transaction.rs index 203b755..520180a 100644 --- a/lightning-c-bindings/src/lightning/chain/transaction.rs +++ b/lightning-c-bindings/src/lightning/chain/transaction.rs @@ -129,7 +129,7 @@ pub extern "C" fn OutPoint_eq(a: &OutPoint, b: &OutPoint) -> bool { 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 OutPoints contain equal inner contents. +/// Generates a non-cryptographic 64-bit hash of the OutPoint. #[no_mangle] pub extern "C" fn OutPoint_hash(o: &OutPoint) -> u64 { if o.inner.is_null() { return 0; } diff --git a/lightning-c-bindings/src/lightning/util/events.rs b/lightning-c-bindings/src/lightning/events.rs similarity index 84% rename from lightning-c-bindings/src/lightning/util/events.rs rename to lightning-c-bindings/src/lightning/events.rs index 2d280f1..50b6875 100644 --- a/lightning-c-bindings/src/lightning/util/events.rs +++ b/lightning-c-bindings/src/lightning/events.rs @@ -55,7 +55,7 @@ pub enum PaymentPurpose { SpontaneousPayment( crate::c_types::ThirtyTwoBytes), } -use lightning::util::events::PaymentPurpose as PaymentPurposeImport; +use lightning::events::PaymentPurpose as PaymentPurposeImport; pub(crate) type nativePaymentPurpose = PaymentPurposeImport; impl PaymentPurpose { @@ -163,14 +163,14 @@ pub extern "C" fn PaymentPurpose_eq(a: &PaymentPurpose, b: &PaymentPurpose) -> b } #[no_mangle] /// Serialize the PaymentPurpose object into a byte array which can be read by PaymentPurpose_read -pub extern "C" fn PaymentPurpose_write(obj: &crate::lightning::util::events::PaymentPurpose) -> crate::c_types::derived::CVec_u8Z { +pub extern "C" fn PaymentPurpose_write(obj: &crate::lightning::events::PaymentPurpose) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(&unsafe { &*obj }.to_native()) } #[no_mangle] /// Read a PaymentPurpose from a byte array, created by PaymentPurpose_write pub extern "C" fn PaymentPurpose_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PaymentPurposeDecodeErrorZ { - let res: Result = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::util::events::PaymentPurpose::native_into(o) }).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::events::PaymentPurpose::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; local_res } /// When the payment path failure took place and extra details about it. [`PathFailure::OnPath`] may @@ -198,7 +198,7 @@ pub enum PathFailure { network_update: crate::c_types::derived::COption_NetworkUpdateZ, }, } -use lightning::util::events::PathFailure as PathFailureImport; +use lightning::events::PathFailure as PathFailureImport; pub(crate) type nativePathFailure = PathFailureImport; impl PathFailure { @@ -213,7 +213,7 @@ impl PathFailure { }, PathFailure::OnPath {ref network_update, } => { let mut network_update_nonref = Clone::clone(network_update); - let mut local_network_update_nonref = { /* network_update_nonref*/ let network_update_nonref_opt = network_update_nonref; { } if network_update_nonref_opt.is_none() { None } else { Some({ network_update_nonref_opt.take().into_native() }) } }; + let mut local_network_update_nonref = { /*network_update_nonref*/ let network_update_nonref_opt = network_update_nonref; if network_update_nonref_opt.is_none() { None } else { Some({ { { network_update_nonref_opt.take() }.into_native() }})} }; nativePathFailure::OnPath { network_update: local_network_update_nonref, } @@ -229,7 +229,7 @@ impl PathFailure { } }, PathFailure::OnPath {mut network_update, } => { - let mut local_network_update = { /* network_update*/ let network_update_opt = network_update; { } if network_update_opt.is_none() { None } else { Some({ network_update_opt.take().into_native() }) } }; + let mut local_network_update = { /*network_update*/ let network_update_opt = network_update; if network_update_opt.is_none() { None } else { Some({ { { network_update_opt.take() }.into_native() }})} }; nativePathFailure::OnPath { network_update: local_network_update, } @@ -301,14 +301,14 @@ pub extern "C" fn PathFailure_eq(a: &PathFailure, b: &PathFailure) -> bool { } #[no_mangle] /// Serialize the PathFailure object into a byte array which can be read by PathFailure_read -pub extern "C" fn PathFailure_write(obj: &crate::lightning::util::events::PathFailure) -> crate::c_types::derived::CVec_u8Z { +pub extern "C" fn PathFailure_write(obj: &crate::lightning::events::PathFailure) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(&unsafe { &*obj }.to_native()) } #[no_mangle] /// Read a PathFailure from a byte array, created by PathFailure_write pub extern "C" fn PathFailure_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_COption_PathFailureZDecodeErrorZ { - let res: Result, lightning::ln::msgs::DecodeError> = crate::c_types::maybe_deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_res_0 = if o.is_none() { crate::c_types::derived::COption_PathFailureZ::None } else { crate::c_types::derived::COption_PathFailureZ::Some( { crate::lightning::util::events::PathFailure::native_into(o.unwrap()) }) }; local_res_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + let res: Result, lightning::ln::msgs::DecodeError> = crate::c_types::maybe_deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_res_0 = if o.is_none() { crate::c_types::derived::COption_PathFailureZ::None } else { crate::c_types::derived::COption_PathFailureZ::Some( { crate::lightning::events::PathFailure::native_into(o.unwrap()) }) }; local_res_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; local_res } /// The reason the channel was closed. See individual variants more details. @@ -323,10 +323,12 @@ pub enum ClosureReason { CounterpartyForceClosed { /// The error which the peer sent us. /// - /// The string should be sanitized before it is used (e.g emitted to logs - /// or printed to stdout). Otherwise, a well crafted error message may exploit + /// Be careful about printing the peer_msg, a well-crafted message could exploit /// a security vulnerability in the terminal emulator or the logging subsystem. - peer_msg: crate::c_types::Str, + /// To be safe, use `Display` on `UntrustedString` + /// + /// [`UntrustedString`]: crate::util::string::UntrustedString + peer_msg: crate::lightning::util::string::UntrustedString, }, /// Closure generated from [`ChannelManager::force_close_channel`], called by the user. /// @@ -364,7 +366,7 @@ pub enum ClosureReason { /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager OutdatedChannelManager, } -use lightning::util::events::ClosureReason as ClosureReasonImport; +use lightning::events::ClosureReason as ClosureReasonImport; pub(crate) type nativeClosureReason = ClosureReasonImport; impl ClosureReason { @@ -374,7 +376,7 @@ impl ClosureReason { ClosureReason::CounterpartyForceClosed {ref peer_msg, } => { let mut peer_msg_nonref = Clone::clone(peer_msg); nativeClosureReason::CounterpartyForceClosed { - peer_msg: peer_msg_nonref.into_string(), + peer_msg: *unsafe { Box::from_raw(peer_msg_nonref.take_inner()) }, } }, ClosureReason::HolderForceClosed => nativeClosureReason::HolderForceClosed, @@ -396,7 +398,7 @@ impl ClosureReason { match self { ClosureReason::CounterpartyForceClosed {mut peer_msg, } => { nativeClosureReason::CounterpartyForceClosed { - peer_msg: peer_msg.into_string(), + peer_msg: *unsafe { Box::from_raw(peer_msg.take_inner()) }, } }, ClosureReason::HolderForceClosed => nativeClosureReason::HolderForceClosed, @@ -418,7 +420,7 @@ impl ClosureReason { nativeClosureReason::CounterpartyForceClosed {ref peer_msg, } => { let mut peer_msg_nonref = Clone::clone(peer_msg); ClosureReason::CounterpartyForceClosed { - peer_msg: peer_msg_nonref.into(), + peer_msg: crate::lightning::util::string::UntrustedString { inner: ObjOps::heap_alloc(peer_msg_nonref), is_owned: true }, } }, nativeClosureReason::HolderForceClosed => ClosureReason::HolderForceClosed, @@ -440,7 +442,7 @@ impl ClosureReason { match native { nativeClosureReason::CounterpartyForceClosed {mut peer_msg, } => { ClosureReason::CounterpartyForceClosed { - peer_msg: peer_msg.into(), + peer_msg: crate::lightning::util::string::UntrustedString { inner: ObjOps::heap_alloc(peer_msg), is_owned: true }, } }, nativeClosureReason::HolderForceClosed => ClosureReason::HolderForceClosed, @@ -467,7 +469,7 @@ pub extern "C" fn ClosureReason_clone(orig: &ClosureReason) -> ClosureReason { } #[no_mangle] /// Utility method to constructs a new CounterpartyForceClosed-variant ClosureReason -pub extern "C" fn ClosureReason_counterparty_force_closed(peer_msg: crate::c_types::Str) -> ClosureReason { +pub extern "C" fn ClosureReason_counterparty_force_closed(peer_msg: crate::lightning::util::string::UntrustedString) -> ClosureReason { ClosureReason::CounterpartyForceClosed { peer_msg, } @@ -511,14 +513,14 @@ pub extern "C" fn ClosureReason_eq(a: &ClosureReason, b: &ClosureReason) -> bool } #[no_mangle] /// Serialize the ClosureReason object into a byte array which can be read by ClosureReason_read -pub extern "C" fn ClosureReason_write(obj: &crate::lightning::util::events::ClosureReason) -> crate::c_types::derived::CVec_u8Z { +pub extern "C" fn ClosureReason_write(obj: &crate::lightning::events::ClosureReason) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(&unsafe { &*obj }.to_native()) } #[no_mangle] /// Read a ClosureReason from a byte array, created by ClosureReason_write pub extern "C" fn ClosureReason_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_COption_ClosureReasonZDecodeErrorZ { - let res: Result, lightning::ln::msgs::DecodeError> = crate::c_types::maybe_deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_res_0 = if o.is_none() { crate::c_types::derived::COption_ClosureReasonZ::None } else { crate::c_types::derived::COption_ClosureReasonZ::Some( { crate::lightning::util::events::ClosureReason::native_into(o.unwrap()) }) }; local_res_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + let res: Result, lightning::ln::msgs::DecodeError> = crate::c_types::maybe_deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_res_0 = if o.is_none() { crate::c_types::derived::COption_ClosureReasonZ::None } else { crate::c_types::derived::COption_ClosureReasonZ::Some( { crate::lightning::events::ClosureReason::native_into(o.unwrap()) }) }; local_res_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; local_res } /// Intended destination of a failed HTLC as indicated in [`Event::HTLCHandlingFailed`]. @@ -554,14 +556,17 @@ pub enum HTLCDestination { /// /// Some of the reasons may include: /// * HTLC Timeouts - /// * Expected MPP amount to claim does not equal HTLC total - /// * Claimable amount does not match expected amount + /// * Excess HTLCs for a payment that we have already fully received, over-paying for the + /// payment, + /// * The counterparty node modified the HTLC in transit, + /// * A probing attack where an intermediary node is trying to detect if we are the ultimate + /// recipient for a payment. FailedPayment { /// The payment hash of the payment we attempted to process. payment_hash: crate::c_types::ThirtyTwoBytes, }, } -use lightning::util::events::HTLCDestination as HTLCDestinationImport; +use lightning::events::HTLCDestination as HTLCDestinationImport; pub(crate) type nativeHTLCDestination = HTLCDestinationImport; impl HTLCDestination { @@ -729,14 +734,139 @@ pub extern "C" fn HTLCDestination_eq(a: &HTLCDestination, b: &HTLCDestination) - } #[no_mangle] /// Serialize the HTLCDestination object into a byte array which can be read by HTLCDestination_read -pub extern "C" fn HTLCDestination_write(obj: &crate::lightning::util::events::HTLCDestination) -> crate::c_types::derived::CVec_u8Z { +pub extern "C" fn HTLCDestination_write(obj: &crate::lightning::events::HTLCDestination) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(&unsafe { &*obj }.to_native()) } #[no_mangle] /// Read a HTLCDestination from a byte array, created by HTLCDestination_write pub extern "C" fn HTLCDestination_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_COption_HTLCDestinationZDecodeErrorZ { - let res: Result, lightning::ln::msgs::DecodeError> = crate::c_types::maybe_deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_res_0 = if o.is_none() { crate::c_types::derived::COption_HTLCDestinationZ::None } else { crate::c_types::derived::COption_HTLCDestinationZ::Some( { crate::lightning::util::events::HTLCDestination::native_into(o.unwrap()) }) }; local_res_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + let res: Result, lightning::ln::msgs::DecodeError> = crate::c_types::maybe_deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_res_0 = if o.is_none() { crate::c_types::derived::COption_HTLCDestinationZ::None } else { crate::c_types::derived::COption_HTLCDestinationZ::Some( { crate::lightning::events::HTLCDestination::native_into(o.unwrap()) }) }; local_res_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} +/// The reason the payment failed. Used in [`Event::PaymentFailed`]. +#[derive(Clone)] +#[must_use] +#[repr(C)] +pub enum PaymentFailureReason { + /// The intended recipient rejected our payment. + RecipientRejected, + /// The user chose to abandon this payment by calling [`ChannelManager::abandon_payment`]. + /// + /// [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment + UserAbandoned, + /// We exhausted all of our retry attempts while trying to send the payment, or we + /// exhausted the [`Retry::Timeout`] if the user set one. If at any point a retry + /// attempt failed while being forwarded along the path, an [`Event::PaymentPathFailed`] will + /// have come before this. + /// + /// [`Retry::Timeout`]: crate::ln::channelmanager::Retry::Timeout + RetriesExhausted, + /// The payment expired while retrying, based on the provided + /// [`PaymentParameters::expiry_time`]. + /// + /// [`PaymentParameters::expiry_time`]: crate::routing::router::PaymentParameters::expiry_time + PaymentExpired, + /// We failed to find a route while retrying the payment. + RouteNotFound, + /// This error should generally never happen. This likely means that there is a problem with + /// your router. + UnexpectedError, +} +use lightning::events::PaymentFailureReason as PaymentFailureReasonImport; +pub(crate) type nativePaymentFailureReason = PaymentFailureReasonImport; + +impl PaymentFailureReason { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativePaymentFailureReason { + match self { + PaymentFailureReason::RecipientRejected => nativePaymentFailureReason::RecipientRejected, + PaymentFailureReason::UserAbandoned => nativePaymentFailureReason::UserAbandoned, + PaymentFailureReason::RetriesExhausted => nativePaymentFailureReason::RetriesExhausted, + PaymentFailureReason::PaymentExpired => nativePaymentFailureReason::PaymentExpired, + PaymentFailureReason::RouteNotFound => nativePaymentFailureReason::RouteNotFound, + PaymentFailureReason::UnexpectedError => nativePaymentFailureReason::UnexpectedError, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativePaymentFailureReason { + match self { + PaymentFailureReason::RecipientRejected => nativePaymentFailureReason::RecipientRejected, + PaymentFailureReason::UserAbandoned => nativePaymentFailureReason::UserAbandoned, + PaymentFailureReason::RetriesExhausted => nativePaymentFailureReason::RetriesExhausted, + PaymentFailureReason::PaymentExpired => nativePaymentFailureReason::PaymentExpired, + PaymentFailureReason::RouteNotFound => nativePaymentFailureReason::RouteNotFound, + PaymentFailureReason::UnexpectedError => nativePaymentFailureReason::UnexpectedError, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &nativePaymentFailureReason) -> Self { + match native { + nativePaymentFailureReason::RecipientRejected => PaymentFailureReason::RecipientRejected, + nativePaymentFailureReason::UserAbandoned => PaymentFailureReason::UserAbandoned, + nativePaymentFailureReason::RetriesExhausted => PaymentFailureReason::RetriesExhausted, + nativePaymentFailureReason::PaymentExpired => PaymentFailureReason::PaymentExpired, + nativePaymentFailureReason::RouteNotFound => PaymentFailureReason::RouteNotFound, + nativePaymentFailureReason::UnexpectedError => PaymentFailureReason::UnexpectedError, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativePaymentFailureReason) -> Self { + match native { + nativePaymentFailureReason::RecipientRejected => PaymentFailureReason::RecipientRejected, + nativePaymentFailureReason::UserAbandoned => PaymentFailureReason::UserAbandoned, + nativePaymentFailureReason::RetriesExhausted => PaymentFailureReason::RetriesExhausted, + nativePaymentFailureReason::PaymentExpired => PaymentFailureReason::PaymentExpired, + nativePaymentFailureReason::RouteNotFound => PaymentFailureReason::RouteNotFound, + nativePaymentFailureReason::UnexpectedError => PaymentFailureReason::UnexpectedError, + } + } +} +/// Creates a copy of the PaymentFailureReason +#[no_mangle] +pub extern "C" fn PaymentFailureReason_clone(orig: &PaymentFailureReason) -> PaymentFailureReason { + orig.clone() +} +#[no_mangle] +/// Utility method to constructs a new RecipientRejected-variant PaymentFailureReason +pub extern "C" fn PaymentFailureReason_recipient_rejected() -> PaymentFailureReason { + PaymentFailureReason::RecipientRejected} +#[no_mangle] +/// Utility method to constructs a new UserAbandoned-variant PaymentFailureReason +pub extern "C" fn PaymentFailureReason_user_abandoned() -> PaymentFailureReason { + PaymentFailureReason::UserAbandoned} +#[no_mangle] +/// Utility method to constructs a new RetriesExhausted-variant PaymentFailureReason +pub extern "C" fn PaymentFailureReason_retries_exhausted() -> PaymentFailureReason { + PaymentFailureReason::RetriesExhausted} +#[no_mangle] +/// Utility method to constructs a new PaymentExpired-variant PaymentFailureReason +pub extern "C" fn PaymentFailureReason_payment_expired() -> PaymentFailureReason { + PaymentFailureReason::PaymentExpired} +#[no_mangle] +/// Utility method to constructs a new RouteNotFound-variant PaymentFailureReason +pub extern "C" fn PaymentFailureReason_route_not_found() -> PaymentFailureReason { + PaymentFailureReason::RouteNotFound} +#[no_mangle] +/// Utility method to constructs a new UnexpectedError-variant PaymentFailureReason +pub extern "C" fn PaymentFailureReason_unexpected_error() -> PaymentFailureReason { + PaymentFailureReason::UnexpectedError} +/// Checks if two PaymentFailureReasons contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +#[no_mangle] +pub extern "C" fn PaymentFailureReason_eq(a: &PaymentFailureReason, b: &PaymentFailureReason) -> bool { + if &a.to_native() == &b.to_native() { true } else { false } +} +#[no_mangle] +/// Serialize the PaymentFailureReason object into a byte array which can be read by PaymentFailureReason_read +pub extern "C" fn PaymentFailureReason_write(obj: &crate::lightning::events::PaymentFailureReason) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(&unsafe { &*obj }.to_native()) +} +#[no_mangle] +/// Read a PaymentFailureReason from a byte array, created by PaymentFailureReason_write +pub extern "C" fn PaymentFailureReason_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PaymentFailureReasonDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::events::PaymentFailureReason::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; local_res } /// An Event which you should probably take some action in response to. @@ -790,7 +920,9 @@ pub enum Event { /// /// # Note /// LDK will not stop an inbound payment from being paid multiple times, so multiple - /// `PaymentClaimable` events may be generated for the same payment. + /// `PaymentClaimable` events may be generated for the same payment. In such a case it is + /// polite (and required in the lightning specification) to fail the payment the second time + /// and give the sender their money back rather than accepting double payment. /// /// # Note /// This event used to be called `PaymentReceived` in LDK versions 0.0.112 and earlier. @@ -811,17 +943,32 @@ pub enum Event { /// The hash for which the preimage should be handed to the ChannelManager. Note that LDK will /// not stop you from registering duplicate payment hashes for inbound payments. payment_hash: crate::c_types::ThirtyTwoBytes, + /// The fields in the onion which were received with each HTLC. Only fields which were + /// identical in each HTLC involved in the payment will be included here. + /// + /// Payments received on LDK versions prior to 0.0.115 will have this field unset. + /// + /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + onion_fields: crate::lightning::ln::outbound_payment::RecipientOnionFields, /// The value, in thousandths of a satoshi, that this payment is for. amount_msat: u64, /// Information for claiming this received payment, based on whether the purpose of the /// payment is to pay an invoice or to send a spontaneous payment. - purpose: crate::lightning::util::events::PaymentPurpose, + purpose: crate::lightning::events::PaymentPurpose, /// The `channel_id` indicating over which channel we received the payment. /// /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None via_channel_id: crate::c_types::ThirtyTwoBytes, /// The `user_channel_id` indicating over which channel we received the payment. via_user_channel_id: crate::c_types::derived::COption_u128Z, + /// The block height at which this payment will be failed back and will no longer be + /// eligible for claiming. + /// + /// Prior to this height, a call to [`ChannelManager::claim_funds`] is guaranteed to + /// succeed, however you should wait for [`Event::PaymentClaimed`] to be sure. + /// + /// [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds + claim_deadline: crate::c_types::derived::COption_u32Z, }, /// Indicates a payment has been claimed and we've received money! /// @@ -854,7 +1001,7 @@ pub enum Event { amount_msat: u64, /// The purpose of the claimed payment, i.e. whether the payment was for an invoice or a /// spontaneous payment. - purpose: crate::lightning::util::events::PaymentPurpose, + purpose: crate::lightning::events::PaymentPurpose, }, /// Indicates an outbound payment we made succeeded (i.e. it made it all the way to its target /// and we got back the payment preimage for it). @@ -862,7 +1009,7 @@ pub enum Event { /// Note for MPP payments: in rare cases, this event may be preceded by a `PaymentPathFailed` /// event. In this situation, you SHOULD treat this payment as having succeeded. PaymentSent { - /// The id returned by [`ChannelManager::send_payment`]. + /// The `payment_id` passed to [`ChannelManager::send_payment`]. /// /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment /// @@ -897,23 +1044,24 @@ pub enum Event { /// [`Retry`]: crate::ln::channelmanager::Retry /// [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment PaymentFailed { - /// The id returned by [`ChannelManager::send_payment`] and used with - /// [`ChannelManager::abandon_payment`]. + /// The `payment_id` passed to [`ChannelManager::send_payment`]. /// /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment - /// [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment payment_id: crate::c_types::ThirtyTwoBytes, /// The hash that was given to [`ChannelManager::send_payment`]. /// /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment payment_hash: crate::c_types::ThirtyTwoBytes, + /// The reason the payment failed. This is only `None` for events generated or serialized + /// by versions prior to 0.0.115. + reason: crate::c_types::derived::COption_PaymentFailureReasonZ, }, /// Indicates that a path for an outbound payment was successful. /// /// Always generated after [`Event::PaymentSent`] and thus useful for scoring channels. See /// [`Event::PaymentSent`] for obtaining the payment preimage. PaymentPathSuccessful { - /// The id returned by [`ChannelManager::send_payment`]. + /// The `payment_id` passed to [`ChannelManager::send_payment`]. /// /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment payment_id: crate::c_types::ThirtyTwoBytes, @@ -926,7 +1074,7 @@ pub enum Event { /// The payment path that was successful. /// /// May contain a closed channel if the HTLC sent along the path was fulfilled on chain. - path: crate::c_types::derived::CVec_RouteHopZ, + path: crate::lightning::routing::router::Path, }, /// Indicates an outbound HTLC we sent failed, likely due to an intermediary node being unable to /// handle the HTLC. @@ -939,8 +1087,7 @@ pub enum Event { /// /// [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment PaymentPathFailed { - /// The id returned by [`ChannelManager::send_payment`] and used with - /// [`ChannelManager::abandon_payment`]. + /// The `payment_id` passed to [`ChannelManager::send_payment`]. /// /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment /// [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment @@ -959,9 +1106,9 @@ pub enum Event { /// applied to the [`NetworkGraph`]. /// /// [`NetworkGraph`]: crate::routing::gossip::NetworkGraph - failure: crate::lightning::util::events::PathFailure, + failure: crate::lightning::events::PathFailure, /// The payment path that failed. - path: crate::c_types::derived::CVec_RouteHopZ, + path: crate::lightning::routing::router::Path, /// The channel responsible for the failed payment path. /// /// Note that for route hints or for the first hop in a path this may be an SCID alias and @@ -971,12 +1118,6 @@ pub enum Event { /// If this is `Some`, then the corresponding channel should be avoided when the payment is /// retried. May be `None` for older [`Event`] serializations. short_channel_id: crate::c_types::derived::COption_u64Z, - /// Parameters used by LDK to compute a new [`Route`] when retrying the failed payment path. - /// - /// [`Route`]: crate::routing::router::Route - /// - /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None - retry: crate::lightning::routing::router::RouteParameters, }, /// Indicates that a probe payment we sent returned successful, i.e., only failed at the destination. ProbeSuccessful { @@ -989,7 +1130,7 @@ pub enum Event { /// [`ChannelManager::send_probe`]: crate::ln::channelmanager::ChannelManager::send_probe payment_hash: crate::c_types::ThirtyTwoBytes, /// The payment path that was successful. - path: crate::c_types::derived::CVec_RouteHopZ, + path: crate::lightning::routing::router::Path, }, /// Indicates that a probe payment we sent failed at an intermediary node on the path. ProbeFailed { @@ -1002,7 +1143,7 @@ pub enum Event { /// [`ChannelManager::send_probe`]: crate::ln::channelmanager::ChannelManager::send_probe payment_hash: crate::c_types::ThirtyTwoBytes, /// The payment path that failed. - path: crate::c_types::derived::CVec_RouteHopZ, + path: crate::lightning::routing::router::Path, /// The channel responsible for the failed probe. /// /// Note that for route hints or for the first hop in a path this may be an SCID alias and @@ -1092,13 +1233,46 @@ pub enum Event { /// If this is `true`, the forwarded HTLC was claimed by our counterparty via an on-chain /// transaction. claim_from_onchain_tx: bool, + /// The final amount forwarded, in milli-satoshis, after the fee is deducted. + /// + /// The caveat described above the `fee_earned_msat` field applies here as well. + outbound_amount_forwarded_msat: crate::c_types::derived::COption_u64Z, + }, + /// Used to indicate that a channel with the given `channel_id` is being opened and pending + /// confirmation on-chain. + /// + /// This event is emitted when the funding transaction has been signed and is broadcast to the + /// network. For 0conf channels it will be immediately followed by the corresponding + /// [`Event::ChannelReady`] event. + ChannelPending { + /// The `channel_id` of the channel that is pending confirmation. + channel_id: crate::c_types::ThirtyTwoBytes, + /// The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound + /// channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if + /// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise + /// `user_channel_id` will be randomized for an inbound channel. + /// + /// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel + /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel + /// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels + user_channel_id: crate::c_types::U128, + /// The `temporary_channel_id` this channel used to be known by during channel establishment. + /// + /// Will be `None` for channels created prior to LDK version 0.0.115. + /// + /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + former_temporary_channel_id: crate::c_types::ThirtyTwoBytes, + /// The `node_id` of the channel counterparty. + counterparty_node_id: crate::c_types::PublicKey, + /// The outpoint of the channel's funding transaction. + funding_txo: crate::lightning::chain::transaction::OutPoint, }, /// Used to indicate that a channel with the given `channel_id` is ready to /// be used. This event is emitted either when the funding transaction has been confirmed /// on-chain, or, in case of a 0conf channel, when both parties have confirmed the channel /// establishment. ChannelReady { - /// The channel_id of the channel that is ready. + /// The `channel_id` of the channel that is ready. channel_id: crate::c_types::ThirtyTwoBytes, /// The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound /// channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if @@ -1109,7 +1283,7 @@ 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 user_channel_id: crate::c_types::U128, - /// The node_id of the channel counterparty. + /// 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, @@ -1117,7 +1291,7 @@ pub enum Event { /// Used to indicate that a previously opened channel with the given `channel_id` is in the /// process of closure. ChannelClosed { - /// The channel_id of the channel which has been closed. Note that on-chain transactions + /// The `channel_id` of the channel which has been closed. Note that on-chain transactions /// resolving the channel are likely still awaiting confirmation. channel_id: crate::c_types::ThirtyTwoBytes, /// The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound @@ -1132,7 +1306,7 @@ pub enum Event { /// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels user_channel_id: crate::c_types::U128, /// The reason the channel was closed. - reason: crate::lightning::util::events::ClosureReason, + reason: crate::lightning::events::ClosureReason, }, /// Used to indicate to the user that they can abandon the funding transaction and recycle the /// inputs for another purpose. @@ -1201,7 +1375,7 @@ pub enum Event { /// * Insufficient capacity in the outbound channel /// * While waiting to forward the HTLC, the channel it is meant to be forwarded through closes /// * When an unknown SCID is requested for forwarding a payment. - /// * Claiming an amount for an MPP payment that exceeds the HTLC total + /// * Expected MPP amount has already been reached /// * The HTLC has timed out /// /// This event, however, does not get generated if an HTLC fails to meet the forwarding @@ -1210,10 +1384,10 @@ pub enum Event { /// The channel over which the HTLC was received. prev_channel_id: crate::c_types::ThirtyTwoBytes, /// Destination of the HTLC that failed to be processed. - failed_next_destination: crate::lightning::util::events::HTLCDestination, + failed_next_destination: crate::lightning::events::HTLCDestination, }, } -use lightning::util::events::Event as EventImport; +use lightning::events::Event as EventImport; pub(crate) type nativeEvent = EventImport; impl Event { @@ -1234,23 +1408,29 @@ impl Event { user_channel_id: user_channel_id_nonref.into(), } }, - Event::PaymentClaimable {ref receiver_node_id, ref payment_hash, ref amount_msat, ref purpose, ref via_channel_id, ref via_user_channel_id, } => { + Event::PaymentClaimable {ref receiver_node_id, ref payment_hash, ref onion_fields, ref amount_msat, ref purpose, ref via_channel_id, ref via_user_channel_id, ref claim_deadline, } => { let mut receiver_node_id_nonref = Clone::clone(receiver_node_id); let mut local_receiver_node_id_nonref = if receiver_node_id_nonref.is_null() { None } else { Some( { receiver_node_id_nonref.into_rust() }) }; let mut payment_hash_nonref = Clone::clone(payment_hash); + let mut onion_fields_nonref = Clone::clone(onion_fields); + let mut local_onion_fields_nonref = if onion_fields_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(onion_fields_nonref.take_inner()) } }) }; let mut amount_msat_nonref = Clone::clone(amount_msat); let mut purpose_nonref = Clone::clone(purpose); let mut via_channel_id_nonref = Clone::clone(via_channel_id); let mut local_via_channel_id_nonref = if via_channel_id_nonref.data == [0; 32] { None } else { Some( { via_channel_id_nonref.data }) }; let mut via_user_channel_id_nonref = Clone::clone(via_user_channel_id); - let mut local_via_user_channel_id_nonref = { /* via_user_channel_id_nonref*/ let via_user_channel_id_nonref_opt = via_user_channel_id_nonref; { } if via_user_channel_id_nonref_opt.is_none() { None } else { Some({ via_user_channel_id_nonref_opt.take().into() }) } }; + let mut local_via_user_channel_id_nonref = { /*via_user_channel_id_nonref*/ let via_user_channel_id_nonref_opt = via_user_channel_id_nonref; if via_user_channel_id_nonref_opt.is_none() { None } else { Some({ { { via_user_channel_id_nonref_opt.take() }.into() }})} }; + let mut claim_deadline_nonref = Clone::clone(claim_deadline); + let mut local_claim_deadline_nonref = if claim_deadline_nonref.is_some() { Some( { claim_deadline_nonref.take() }) } else { None }; nativeEvent::PaymentClaimable { receiver_node_id: local_receiver_node_id_nonref, payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data), + onion_fields: local_onion_fields_nonref, amount_msat: amount_msat_nonref, purpose: purpose_nonref.into_native(), via_channel_id: local_via_channel_id_nonref, via_user_channel_id: local_via_user_channel_id_nonref, + claim_deadline: local_claim_deadline_nonref, } }, Event::PaymentClaimed {ref receiver_node_id, ref payment_hash, ref amount_msat, ref purpose, } => { @@ -1280,12 +1460,15 @@ impl Event { fee_paid_msat: local_fee_paid_msat_nonref, } }, - Event::PaymentFailed {ref payment_id, ref payment_hash, } => { + Event::PaymentFailed {ref payment_id, ref payment_hash, ref reason, } => { let mut payment_id_nonref = Clone::clone(payment_id); let mut payment_hash_nonref = Clone::clone(payment_hash); + let mut reason_nonref = Clone::clone(reason); + let mut local_reason_nonref = { /*reason_nonref*/ let reason_nonref_opt = reason_nonref; if reason_nonref_opt.is_none() { None } else { Some({ { { reason_nonref_opt.take() }.into_native() }})} }; nativeEvent::PaymentFailed { payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data), payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data), + reason: local_reason_nonref, } }, Event::PaymentPathSuccessful {ref payment_id, ref payment_hash, ref path, } => { @@ -1293,57 +1476,50 @@ impl Event { let mut payment_hash_nonref = Clone::clone(payment_hash); let mut local_payment_hash_nonref = if payment_hash_nonref.data == [0; 32] { None } else { Some( { ::lightning::ln::PaymentHash(payment_hash_nonref.data) }) }; let mut path_nonref = Clone::clone(path); - let mut local_path_nonref = Vec::new(); for mut item in path_nonref.into_rust().drain(..) { local_path_nonref.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; nativeEvent::PaymentPathSuccessful { payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data), payment_hash: local_payment_hash_nonref, - path: local_path_nonref, + path: *unsafe { Box::from_raw(path_nonref.take_inner()) }, } }, - Event::PaymentPathFailed {ref payment_id, ref payment_hash, ref payment_failed_permanently, ref failure, ref path, ref short_channel_id, ref retry, } => { + Event::PaymentPathFailed {ref payment_id, ref payment_hash, ref payment_failed_permanently, ref failure, ref path, ref short_channel_id, } => { let mut payment_id_nonref = Clone::clone(payment_id); let mut local_payment_id_nonref = if payment_id_nonref.data == [0; 32] { None } else { Some( { ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data) }) }; let mut payment_hash_nonref = Clone::clone(payment_hash); let mut payment_failed_permanently_nonref = Clone::clone(payment_failed_permanently); let mut failure_nonref = Clone::clone(failure); let mut path_nonref = Clone::clone(path); - let mut local_path_nonref = Vec::new(); for mut item in path_nonref.into_rust().drain(..) { local_path_nonref.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; let mut short_channel_id_nonref = Clone::clone(short_channel_id); let mut local_short_channel_id_nonref = if short_channel_id_nonref.is_some() { Some( { short_channel_id_nonref.take() }) } else { None }; - let mut retry_nonref = Clone::clone(retry); - let mut local_retry_nonref = if retry_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(retry_nonref.take_inner()) } }) }; nativeEvent::PaymentPathFailed { payment_id: local_payment_id_nonref, payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data), payment_failed_permanently: payment_failed_permanently_nonref, failure: failure_nonref.into_native(), - path: local_path_nonref, + path: *unsafe { Box::from_raw(path_nonref.take_inner()) }, short_channel_id: local_short_channel_id_nonref, - retry: local_retry_nonref, } }, Event::ProbeSuccessful {ref payment_id, ref payment_hash, ref path, } => { let mut payment_id_nonref = Clone::clone(payment_id); let mut payment_hash_nonref = Clone::clone(payment_hash); let mut path_nonref = Clone::clone(path); - let mut local_path_nonref = Vec::new(); for mut item in path_nonref.into_rust().drain(..) { local_path_nonref.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; nativeEvent::ProbeSuccessful { payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data), payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data), - path: local_path_nonref, + path: *unsafe { Box::from_raw(path_nonref.take_inner()) }, } }, Event::ProbeFailed {ref payment_id, ref payment_hash, ref path, ref short_channel_id, } => { let mut payment_id_nonref = Clone::clone(payment_id); let mut payment_hash_nonref = Clone::clone(payment_hash); let mut path_nonref = Clone::clone(path); - let mut local_path_nonref = Vec::new(); for mut item in path_nonref.into_rust().drain(..) { local_path_nonref.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; let mut short_channel_id_nonref = Clone::clone(short_channel_id); let mut local_short_channel_id_nonref = if short_channel_id_nonref.is_some() { Some( { short_channel_id_nonref.take() }) } else { None }; nativeEvent::ProbeFailed { payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data), payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data), - path: local_path_nonref, + path: *unsafe { Box::from_raw(path_nonref.take_inner()) }, short_channel_id: local_short_channel_id_nonref, } }, @@ -1374,7 +1550,7 @@ impl Event { outputs: local_outputs_nonref, } }, - Event::PaymentForwarded {ref prev_channel_id, ref next_channel_id, ref fee_earned_msat, ref claim_from_onchain_tx, } => { + Event::PaymentForwarded {ref prev_channel_id, ref next_channel_id, ref fee_earned_msat, ref claim_from_onchain_tx, ref outbound_amount_forwarded_msat, } => { let mut prev_channel_id_nonref = Clone::clone(prev_channel_id); let mut local_prev_channel_id_nonref = if prev_channel_id_nonref.data == [0; 32] { None } else { Some( { prev_channel_id_nonref.data }) }; let mut next_channel_id_nonref = Clone::clone(next_channel_id); @@ -1382,11 +1558,29 @@ impl Event { let mut fee_earned_msat_nonref = Clone::clone(fee_earned_msat); let mut local_fee_earned_msat_nonref = if fee_earned_msat_nonref.is_some() { Some( { fee_earned_msat_nonref.take() }) } else { None }; let mut claim_from_onchain_tx_nonref = Clone::clone(claim_from_onchain_tx); + let mut outbound_amount_forwarded_msat_nonref = Clone::clone(outbound_amount_forwarded_msat); + let mut local_outbound_amount_forwarded_msat_nonref = if outbound_amount_forwarded_msat_nonref.is_some() { Some( { outbound_amount_forwarded_msat_nonref.take() }) } else { None }; nativeEvent::PaymentForwarded { prev_channel_id: local_prev_channel_id_nonref, next_channel_id: local_next_channel_id_nonref, fee_earned_msat: local_fee_earned_msat_nonref, claim_from_onchain_tx: claim_from_onchain_tx_nonref, + outbound_amount_forwarded_msat: local_outbound_amount_forwarded_msat_nonref, + } + }, + Event::ChannelPending {ref channel_id, ref user_channel_id, ref former_temporary_channel_id, ref counterparty_node_id, ref funding_txo, } => { + let mut channel_id_nonref = Clone::clone(channel_id); + let mut user_channel_id_nonref = Clone::clone(user_channel_id); + let mut former_temporary_channel_id_nonref = Clone::clone(former_temporary_channel_id); + let mut local_former_temporary_channel_id_nonref = if former_temporary_channel_id_nonref.data == [0; 32] { None } else { Some( { former_temporary_channel_id_nonref.data }) }; + let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id); + let mut funding_txo_nonref = Clone::clone(funding_txo); + nativeEvent::ChannelPending { + channel_id: channel_id_nonref.data, + user_channel_id: user_channel_id_nonref.into(), + former_temporary_channel_id: local_former_temporary_channel_id_nonref, + counterparty_node_id: counterparty_node_id_nonref.into_rust(), + funding_txo: crate::c_types::C_to_bitcoin_outpoint(funding_txo_nonref), } }, Event::ChannelReady {ref channel_id, ref user_channel_id, ref counterparty_node_id, ref channel_type, } => { @@ -1455,17 +1649,21 @@ impl Event { user_channel_id: user_channel_id.into(), } }, - Event::PaymentClaimable {mut receiver_node_id, mut payment_hash, mut amount_msat, mut purpose, mut via_channel_id, mut via_user_channel_id, } => { + Event::PaymentClaimable {mut receiver_node_id, mut payment_hash, mut onion_fields, mut amount_msat, mut purpose, mut via_channel_id, mut via_user_channel_id, mut claim_deadline, } => { let mut local_receiver_node_id = if receiver_node_id.is_null() { None } else { Some( { receiver_node_id.into_rust() }) }; + let mut local_onion_fields = if onion_fields.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(onion_fields.take_inner()) } }) }; let mut local_via_channel_id = if via_channel_id.data == [0; 32] { None } else { Some( { via_channel_id.data }) }; - let mut local_via_user_channel_id = { /* via_user_channel_id*/ let via_user_channel_id_opt = via_user_channel_id; { } if via_user_channel_id_opt.is_none() { None } else { Some({ via_user_channel_id_opt.take().into() }) } }; + let mut local_via_user_channel_id = { /*via_user_channel_id*/ let via_user_channel_id_opt = via_user_channel_id; if via_user_channel_id_opt.is_none() { None } else { Some({ { { via_user_channel_id_opt.take() }.into() }})} }; + let mut local_claim_deadline = if claim_deadline.is_some() { Some( { claim_deadline.take() }) } else { None }; nativeEvent::PaymentClaimable { receiver_node_id: local_receiver_node_id, payment_hash: ::lightning::ln::PaymentHash(payment_hash.data), + onion_fields: local_onion_fields, amount_msat: amount_msat, purpose: purpose.into_native(), via_channel_id: local_via_channel_id, via_user_channel_id: local_via_user_channel_id, + claim_deadline: local_claim_deadline, } }, Event::PaymentClaimed {mut receiver_node_id, mut payment_hash, mut amount_msat, mut purpose, } => { @@ -1487,51 +1685,47 @@ impl Event { fee_paid_msat: local_fee_paid_msat, } }, - Event::PaymentFailed {mut payment_id, mut payment_hash, } => { + Event::PaymentFailed {mut payment_id, mut payment_hash, mut reason, } => { + let mut local_reason = { /*reason*/ let reason_opt = reason; if reason_opt.is_none() { None } else { Some({ { { reason_opt.take() }.into_native() }})} }; nativeEvent::PaymentFailed { payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id.data), payment_hash: ::lightning::ln::PaymentHash(payment_hash.data), + reason: local_reason, } }, Event::PaymentPathSuccessful {mut payment_id, mut payment_hash, mut path, } => { let mut local_payment_hash = if payment_hash.data == [0; 32] { None } else { Some( { ::lightning::ln::PaymentHash(payment_hash.data) }) }; - let mut local_path = Vec::new(); for mut item in path.into_rust().drain(..) { local_path.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; nativeEvent::PaymentPathSuccessful { payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id.data), payment_hash: local_payment_hash, - path: local_path, + path: *unsafe { Box::from_raw(path.take_inner()) }, } }, - Event::PaymentPathFailed {mut payment_id, mut payment_hash, mut payment_failed_permanently, mut failure, mut path, mut short_channel_id, mut retry, } => { + Event::PaymentPathFailed {mut payment_id, mut payment_hash, mut payment_failed_permanently, mut failure, mut path, mut short_channel_id, } => { let mut local_payment_id = if payment_id.data == [0; 32] { None } else { Some( { ::lightning::ln::channelmanager::PaymentId(payment_id.data) }) }; - let mut local_path = Vec::new(); for mut item in path.into_rust().drain(..) { local_path.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; let mut local_short_channel_id = if short_channel_id.is_some() { Some( { short_channel_id.take() }) } else { None }; - let mut local_retry = if retry.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(retry.take_inner()) } }) }; nativeEvent::PaymentPathFailed { payment_id: local_payment_id, payment_hash: ::lightning::ln::PaymentHash(payment_hash.data), payment_failed_permanently: payment_failed_permanently, failure: failure.into_native(), - path: local_path, + path: *unsafe { Box::from_raw(path.take_inner()) }, short_channel_id: local_short_channel_id, - retry: local_retry, } }, Event::ProbeSuccessful {mut payment_id, mut payment_hash, mut path, } => { - let mut local_path = Vec::new(); for mut item in path.into_rust().drain(..) { local_path.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; nativeEvent::ProbeSuccessful { payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id.data), payment_hash: ::lightning::ln::PaymentHash(payment_hash.data), - path: local_path, + path: *unsafe { Box::from_raw(path.take_inner()) }, } }, Event::ProbeFailed {mut payment_id, mut payment_hash, mut path, mut short_channel_id, } => { - let mut local_path = Vec::new(); for mut item in path.into_rust().drain(..) { local_path.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; let mut local_short_channel_id = if short_channel_id.is_some() { Some( { short_channel_id.take() }) } else { None }; nativeEvent::ProbeFailed { payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id.data), payment_hash: ::lightning::ln::PaymentHash(payment_hash.data), - path: local_path, + path: *unsafe { Box::from_raw(path.take_inner()) }, short_channel_id: local_short_channel_id, } }, @@ -1555,15 +1749,27 @@ impl Event { outputs: local_outputs, } }, - Event::PaymentForwarded {mut prev_channel_id, mut next_channel_id, mut fee_earned_msat, mut claim_from_onchain_tx, } => { + Event::PaymentForwarded {mut prev_channel_id, mut next_channel_id, mut fee_earned_msat, mut claim_from_onchain_tx, mut outbound_amount_forwarded_msat, } => { let mut local_prev_channel_id = if prev_channel_id.data == [0; 32] { None } else { Some( { prev_channel_id.data }) }; let mut local_next_channel_id = if next_channel_id.data == [0; 32] { None } else { Some( { next_channel_id.data }) }; let mut local_fee_earned_msat = if fee_earned_msat.is_some() { Some( { fee_earned_msat.take() }) } else { None }; + let mut local_outbound_amount_forwarded_msat = if outbound_amount_forwarded_msat.is_some() { Some( { outbound_amount_forwarded_msat.take() }) } else { None }; nativeEvent::PaymentForwarded { prev_channel_id: local_prev_channel_id, next_channel_id: local_next_channel_id, fee_earned_msat: local_fee_earned_msat, claim_from_onchain_tx: claim_from_onchain_tx, + outbound_amount_forwarded_msat: local_outbound_amount_forwarded_msat, + } + }, + Event::ChannelPending {mut channel_id, mut user_channel_id, mut former_temporary_channel_id, mut counterparty_node_id, mut funding_txo, } => { + let mut local_former_temporary_channel_id = if former_temporary_channel_id.data == [0; 32] { None } else { Some( { former_temporary_channel_id.data }) }; + nativeEvent::ChannelPending { + channel_id: channel_id.data, + user_channel_id: user_channel_id.into(), + former_temporary_channel_id: local_former_temporary_channel_id, + counterparty_node_id: counterparty_node_id.into_rust(), + funding_txo: crate::c_types::C_to_bitcoin_outpoint(funding_txo), } }, Event::ChannelReady {mut channel_id, mut user_channel_id, mut counterparty_node_id, mut channel_type, } => { @@ -1621,23 +1827,29 @@ impl Event { user_channel_id: user_channel_id_nonref.into(), } }, - nativeEvent::PaymentClaimable {ref receiver_node_id, ref payment_hash, ref amount_msat, ref purpose, ref via_channel_id, ref via_user_channel_id, } => { + nativeEvent::PaymentClaimable {ref receiver_node_id, ref payment_hash, ref onion_fields, ref amount_msat, ref purpose, ref via_channel_id, ref via_user_channel_id, ref claim_deadline, } => { let mut receiver_node_id_nonref = Clone::clone(receiver_node_id); let mut local_receiver_node_id_nonref = if receiver_node_id_nonref.is_none() { crate::c_types::PublicKey::null() } else { { crate::c_types::PublicKey::from_rust(&(receiver_node_id_nonref.unwrap())) } }; let mut payment_hash_nonref = Clone::clone(payment_hash); + let mut onion_fields_nonref = Clone::clone(onion_fields); + let mut local_onion_fields_nonref = crate::lightning::ln::outbound_payment::RecipientOnionFields { inner: if onion_fields_nonref.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((onion_fields_nonref.unwrap())) } }, is_owned: true }; let mut amount_msat_nonref = Clone::clone(amount_msat); let mut purpose_nonref = Clone::clone(purpose); let mut via_channel_id_nonref = Clone::clone(via_channel_id); let mut local_via_channel_id_nonref = if via_channel_id_nonref.is_none() { crate::c_types::ThirtyTwoBytes { data: [0; 32] } } else { { crate::c_types::ThirtyTwoBytes { data: (via_channel_id_nonref.unwrap()) } } }; let mut via_user_channel_id_nonref = Clone::clone(via_user_channel_id); let mut local_via_user_channel_id_nonref = if via_user_channel_id_nonref.is_none() { crate::c_types::derived::COption_u128Z::None } else { crate::c_types::derived::COption_u128Z::Some( { via_user_channel_id_nonref.unwrap().into() }) }; + let mut claim_deadline_nonref = Clone::clone(claim_deadline); + let mut local_claim_deadline_nonref = if claim_deadline_nonref.is_none() { crate::c_types::derived::COption_u32Z::None } else { crate::c_types::derived::COption_u32Z::Some( { claim_deadline_nonref.unwrap() }) }; Event::PaymentClaimable { receiver_node_id: local_receiver_node_id_nonref, payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 }, + onion_fields: local_onion_fields_nonref, amount_msat: amount_msat_nonref, - purpose: crate::lightning::util::events::PaymentPurpose::native_into(purpose_nonref), + purpose: crate::lightning::events::PaymentPurpose::native_into(purpose_nonref), via_channel_id: local_via_channel_id_nonref, via_user_channel_id: local_via_user_channel_id_nonref, + claim_deadline: local_claim_deadline_nonref, } }, nativeEvent::PaymentClaimed {ref receiver_node_id, ref payment_hash, ref amount_msat, ref purpose, } => { @@ -1650,7 +1862,7 @@ impl Event { receiver_node_id: local_receiver_node_id_nonref, payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 }, amount_msat: amount_msat_nonref, - purpose: crate::lightning::util::events::PaymentPurpose::native_into(purpose_nonref), + purpose: crate::lightning::events::PaymentPurpose::native_into(purpose_nonref), } }, nativeEvent::PaymentSent {ref payment_id, ref payment_preimage, ref payment_hash, ref fee_paid_msat, } => { @@ -1667,12 +1879,15 @@ impl Event { fee_paid_msat: local_fee_paid_msat_nonref, } }, - nativeEvent::PaymentFailed {ref payment_id, ref payment_hash, } => { + nativeEvent::PaymentFailed {ref payment_id, ref payment_hash, ref reason, } => { let mut payment_id_nonref = Clone::clone(payment_id); let mut payment_hash_nonref = Clone::clone(payment_hash); + let mut reason_nonref = Clone::clone(reason); + let mut local_reason_nonref = if reason_nonref.is_none() { crate::c_types::derived::COption_PaymentFailureReasonZ::None } else { crate::c_types::derived::COption_PaymentFailureReasonZ::Some( { crate::lightning::events::PaymentFailureReason::native_into(reason_nonref.unwrap()) }) }; Event::PaymentFailed { payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id_nonref.0 }, payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 }, + reason: local_reason_nonref, } }, nativeEvent::PaymentPathSuccessful {ref payment_id, ref payment_hash, ref path, } => { @@ -1680,57 +1895,50 @@ impl Event { let mut payment_hash_nonref = Clone::clone(payment_hash); let mut local_payment_hash_nonref = if payment_hash_nonref.is_none() { crate::c_types::ThirtyTwoBytes::null() } else { { crate::c_types::ThirtyTwoBytes { data: (payment_hash_nonref.unwrap()).0 } } }; let mut path_nonref = Clone::clone(path); - let mut local_path_nonref = Vec::new(); for mut item in path_nonref.drain(..) { local_path_nonref.push( { crate::lightning::routing::router::RouteHop { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; Event::PaymentPathSuccessful { payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id_nonref.0 }, payment_hash: local_payment_hash_nonref, - path: local_path_nonref.into(), + path: crate::lightning::routing::router::Path { inner: ObjOps::heap_alloc(path_nonref), is_owned: true }, } }, - nativeEvent::PaymentPathFailed {ref payment_id, ref payment_hash, ref payment_failed_permanently, ref failure, ref path, ref short_channel_id, ref retry, } => { + nativeEvent::PaymentPathFailed {ref payment_id, ref payment_hash, ref payment_failed_permanently, ref failure, ref path, ref short_channel_id, } => { let mut payment_id_nonref = Clone::clone(payment_id); let mut local_payment_id_nonref = if payment_id_nonref.is_none() { crate::c_types::ThirtyTwoBytes::null() } else { { crate::c_types::ThirtyTwoBytes { data: (payment_id_nonref.unwrap()).0 } } }; let mut payment_hash_nonref = Clone::clone(payment_hash); let mut payment_failed_permanently_nonref = Clone::clone(payment_failed_permanently); let mut failure_nonref = Clone::clone(failure); let mut path_nonref = Clone::clone(path); - let mut local_path_nonref = Vec::new(); for mut item in path_nonref.drain(..) { local_path_nonref.push( { crate::lightning::routing::router::RouteHop { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; let mut short_channel_id_nonref = Clone::clone(short_channel_id); let mut local_short_channel_id_nonref = if short_channel_id_nonref.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { short_channel_id_nonref.unwrap() }) }; - let mut retry_nonref = Clone::clone(retry); - let mut local_retry_nonref = crate::lightning::routing::router::RouteParameters { inner: if retry_nonref.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((retry_nonref.unwrap())) } }, is_owned: true }; Event::PaymentPathFailed { payment_id: local_payment_id_nonref, payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 }, payment_failed_permanently: payment_failed_permanently_nonref, - failure: crate::lightning::util::events::PathFailure::native_into(failure_nonref), - path: local_path_nonref.into(), + failure: crate::lightning::events::PathFailure::native_into(failure_nonref), + path: crate::lightning::routing::router::Path { inner: ObjOps::heap_alloc(path_nonref), is_owned: true }, short_channel_id: local_short_channel_id_nonref, - retry: local_retry_nonref, } }, nativeEvent::ProbeSuccessful {ref payment_id, ref payment_hash, ref path, } => { let mut payment_id_nonref = Clone::clone(payment_id); let mut payment_hash_nonref = Clone::clone(payment_hash); let mut path_nonref = Clone::clone(path); - let mut local_path_nonref = Vec::new(); for mut item in path_nonref.drain(..) { local_path_nonref.push( { crate::lightning::routing::router::RouteHop { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; Event::ProbeSuccessful { payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id_nonref.0 }, payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 }, - path: local_path_nonref.into(), + path: crate::lightning::routing::router::Path { inner: ObjOps::heap_alloc(path_nonref), is_owned: true }, } }, nativeEvent::ProbeFailed {ref payment_id, ref payment_hash, ref path, ref short_channel_id, } => { let mut payment_id_nonref = Clone::clone(payment_id); let mut payment_hash_nonref = Clone::clone(payment_hash); let mut path_nonref = Clone::clone(path); - let mut local_path_nonref = Vec::new(); for mut item in path_nonref.drain(..) { local_path_nonref.push( { crate::lightning::routing::router::RouteHop { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; let mut short_channel_id_nonref = Clone::clone(short_channel_id); let mut local_short_channel_id_nonref = if short_channel_id_nonref.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { short_channel_id_nonref.unwrap() }) }; Event::ProbeFailed { payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id_nonref.0 }, payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 }, - path: local_path_nonref.into(), + path: crate::lightning::routing::router::Path { inner: ObjOps::heap_alloc(path_nonref), is_owned: true }, short_channel_id: local_short_channel_id_nonref, } }, @@ -1761,7 +1969,7 @@ impl Event { outputs: local_outputs_nonref.into(), } }, - nativeEvent::PaymentForwarded {ref prev_channel_id, ref next_channel_id, ref fee_earned_msat, ref claim_from_onchain_tx, } => { + nativeEvent::PaymentForwarded {ref prev_channel_id, ref next_channel_id, ref fee_earned_msat, ref claim_from_onchain_tx, ref outbound_amount_forwarded_msat, } => { let mut prev_channel_id_nonref = Clone::clone(prev_channel_id); let mut local_prev_channel_id_nonref = if prev_channel_id_nonref.is_none() { crate::c_types::ThirtyTwoBytes { data: [0; 32] } } else { { crate::c_types::ThirtyTwoBytes { data: (prev_channel_id_nonref.unwrap()) } } }; let mut next_channel_id_nonref = Clone::clone(next_channel_id); @@ -1769,11 +1977,29 @@ impl Event { let mut fee_earned_msat_nonref = Clone::clone(fee_earned_msat); let mut local_fee_earned_msat_nonref = if fee_earned_msat_nonref.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { fee_earned_msat_nonref.unwrap() }) }; let mut claim_from_onchain_tx_nonref = Clone::clone(claim_from_onchain_tx); + let mut outbound_amount_forwarded_msat_nonref = Clone::clone(outbound_amount_forwarded_msat); + let mut local_outbound_amount_forwarded_msat_nonref = if outbound_amount_forwarded_msat_nonref.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { outbound_amount_forwarded_msat_nonref.unwrap() }) }; Event::PaymentForwarded { prev_channel_id: local_prev_channel_id_nonref, next_channel_id: local_next_channel_id_nonref, fee_earned_msat: local_fee_earned_msat_nonref, claim_from_onchain_tx: claim_from_onchain_tx_nonref, + outbound_amount_forwarded_msat: local_outbound_amount_forwarded_msat_nonref, + } + }, + nativeEvent::ChannelPending {ref channel_id, ref user_channel_id, ref former_temporary_channel_id, ref counterparty_node_id, ref funding_txo, } => { + let mut channel_id_nonref = Clone::clone(channel_id); + let mut user_channel_id_nonref = Clone::clone(user_channel_id); + let mut former_temporary_channel_id_nonref = Clone::clone(former_temporary_channel_id); + let mut local_former_temporary_channel_id_nonref = if former_temporary_channel_id_nonref.is_none() { crate::c_types::ThirtyTwoBytes { data: [0; 32] } } else { { crate::c_types::ThirtyTwoBytes { data: (former_temporary_channel_id_nonref.unwrap()) } } }; + let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id); + let mut funding_txo_nonref = Clone::clone(funding_txo); + Event::ChannelPending { + channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id_nonref }, + user_channel_id: user_channel_id_nonref.into(), + former_temporary_channel_id: local_former_temporary_channel_id_nonref, + counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id_nonref), + funding_txo: crate::c_types::bitcoin_to_C_outpoint(funding_txo_nonref), } }, nativeEvent::ChannelReady {ref channel_id, ref user_channel_id, ref counterparty_node_id, ref channel_type, } => { @@ -1795,7 +2021,7 @@ impl Event { Event::ChannelClosed { channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id_nonref }, user_channel_id: user_channel_id_nonref.into(), - reason: crate::lightning::util::events::ClosureReason::native_into(reason_nonref), + reason: crate::lightning::events::ClosureReason::native_into(reason_nonref), } }, nativeEvent::DiscardFunding {ref channel_id, ref transaction, } => { @@ -1825,7 +2051,7 @@ impl Event { let mut failed_next_destination_nonref = Clone::clone(failed_next_destination); Event::HTLCHandlingFailed { prev_channel_id: crate::c_types::ThirtyTwoBytes { data: prev_channel_id_nonref }, - failed_next_destination: crate::lightning::util::events::HTLCDestination::native_into(failed_next_destination_nonref), + failed_next_destination: crate::lightning::events::HTLCDestination::native_into(failed_next_destination_nonref), } }, } @@ -1842,17 +2068,21 @@ impl Event { user_channel_id: user_channel_id.into(), } }, - nativeEvent::PaymentClaimable {mut receiver_node_id, mut payment_hash, mut amount_msat, mut purpose, mut via_channel_id, mut via_user_channel_id, } => { + nativeEvent::PaymentClaimable {mut receiver_node_id, mut payment_hash, mut onion_fields, mut amount_msat, mut purpose, mut via_channel_id, mut via_user_channel_id, mut claim_deadline, } => { let mut local_receiver_node_id = if receiver_node_id.is_none() { crate::c_types::PublicKey::null() } else { { crate::c_types::PublicKey::from_rust(&(receiver_node_id.unwrap())) } }; + let mut local_onion_fields = crate::lightning::ln::outbound_payment::RecipientOnionFields { inner: if onion_fields.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((onion_fields.unwrap())) } }, is_owned: true }; let mut local_via_channel_id = if via_channel_id.is_none() { crate::c_types::ThirtyTwoBytes { data: [0; 32] } } else { { crate::c_types::ThirtyTwoBytes { data: (via_channel_id.unwrap()) } } }; let mut local_via_user_channel_id = if via_user_channel_id.is_none() { crate::c_types::derived::COption_u128Z::None } else { crate::c_types::derived::COption_u128Z::Some( { via_user_channel_id.unwrap().into() }) }; + let mut local_claim_deadline = if claim_deadline.is_none() { crate::c_types::derived::COption_u32Z::None } else { crate::c_types::derived::COption_u32Z::Some( { claim_deadline.unwrap() }) }; Event::PaymentClaimable { receiver_node_id: local_receiver_node_id, payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 }, + onion_fields: local_onion_fields, amount_msat: amount_msat, - purpose: crate::lightning::util::events::PaymentPurpose::native_into(purpose), + purpose: crate::lightning::events::PaymentPurpose::native_into(purpose), via_channel_id: local_via_channel_id, via_user_channel_id: local_via_user_channel_id, + claim_deadline: local_claim_deadline, } }, nativeEvent::PaymentClaimed {mut receiver_node_id, mut payment_hash, mut amount_msat, mut purpose, } => { @@ -1861,7 +2091,7 @@ impl Event { receiver_node_id: local_receiver_node_id, payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 }, amount_msat: amount_msat, - purpose: crate::lightning::util::events::PaymentPurpose::native_into(purpose), + purpose: crate::lightning::events::PaymentPurpose::native_into(purpose), } }, nativeEvent::PaymentSent {mut payment_id, mut payment_preimage, mut payment_hash, mut fee_paid_msat, } => { @@ -1874,51 +2104,47 @@ impl Event { fee_paid_msat: local_fee_paid_msat, } }, - nativeEvent::PaymentFailed {mut payment_id, mut payment_hash, } => { + nativeEvent::PaymentFailed {mut payment_id, mut payment_hash, mut reason, } => { + let mut local_reason = if reason.is_none() { crate::c_types::derived::COption_PaymentFailureReasonZ::None } else { crate::c_types::derived::COption_PaymentFailureReasonZ::Some( { crate::lightning::events::PaymentFailureReason::native_into(reason.unwrap()) }) }; Event::PaymentFailed { payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id.0 }, payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 }, + reason: local_reason, } }, nativeEvent::PaymentPathSuccessful {mut payment_id, mut payment_hash, mut path, } => { let mut local_payment_hash = if payment_hash.is_none() { crate::c_types::ThirtyTwoBytes::null() } else { { crate::c_types::ThirtyTwoBytes { data: (payment_hash.unwrap()).0 } } }; - let mut local_path = Vec::new(); for mut item in path.drain(..) { local_path.push( { crate::lightning::routing::router::RouteHop { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; Event::PaymentPathSuccessful { payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id.0 }, payment_hash: local_payment_hash, - path: local_path.into(), + path: crate::lightning::routing::router::Path { inner: ObjOps::heap_alloc(path), is_owned: true }, } }, - nativeEvent::PaymentPathFailed {mut payment_id, mut payment_hash, mut payment_failed_permanently, mut failure, mut path, mut short_channel_id, mut retry, } => { + nativeEvent::PaymentPathFailed {mut payment_id, mut payment_hash, mut payment_failed_permanently, mut failure, mut path, mut short_channel_id, } => { let mut local_payment_id = if payment_id.is_none() { crate::c_types::ThirtyTwoBytes::null() } else { { crate::c_types::ThirtyTwoBytes { data: (payment_id.unwrap()).0 } } }; - let mut local_path = Vec::new(); for mut item in path.drain(..) { local_path.push( { crate::lightning::routing::router::RouteHop { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; let mut local_short_channel_id = if short_channel_id.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { short_channel_id.unwrap() }) }; - let mut local_retry = crate::lightning::routing::router::RouteParameters { inner: if retry.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((retry.unwrap())) } }, is_owned: true }; Event::PaymentPathFailed { payment_id: local_payment_id, payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 }, payment_failed_permanently: payment_failed_permanently, - failure: crate::lightning::util::events::PathFailure::native_into(failure), - path: local_path.into(), + failure: crate::lightning::events::PathFailure::native_into(failure), + path: crate::lightning::routing::router::Path { inner: ObjOps::heap_alloc(path), is_owned: true }, short_channel_id: local_short_channel_id, - retry: local_retry, } }, nativeEvent::ProbeSuccessful {mut payment_id, mut payment_hash, mut path, } => { - let mut local_path = Vec::new(); for mut item in path.drain(..) { local_path.push( { crate::lightning::routing::router::RouteHop { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; Event::ProbeSuccessful { payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id.0 }, payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 }, - path: local_path.into(), + path: crate::lightning::routing::router::Path { inner: ObjOps::heap_alloc(path), is_owned: true }, } }, nativeEvent::ProbeFailed {mut payment_id, mut payment_hash, mut path, mut short_channel_id, } => { - let mut local_path = Vec::new(); for mut item in path.drain(..) { local_path.push( { crate::lightning::routing::router::RouteHop { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; let mut local_short_channel_id = if short_channel_id.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { short_channel_id.unwrap() }) }; Event::ProbeFailed { payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id.0 }, payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 }, - path: local_path.into(), + path: crate::lightning::routing::router::Path { inner: ObjOps::heap_alloc(path), is_owned: true }, short_channel_id: local_short_channel_id, } }, @@ -1942,15 +2168,27 @@ impl Event { outputs: local_outputs.into(), } }, - nativeEvent::PaymentForwarded {mut prev_channel_id, mut next_channel_id, mut fee_earned_msat, mut claim_from_onchain_tx, } => { + nativeEvent::PaymentForwarded {mut prev_channel_id, mut next_channel_id, mut fee_earned_msat, mut claim_from_onchain_tx, mut outbound_amount_forwarded_msat, } => { let mut local_prev_channel_id = if prev_channel_id.is_none() { crate::c_types::ThirtyTwoBytes { data: [0; 32] } } else { { crate::c_types::ThirtyTwoBytes { data: (prev_channel_id.unwrap()) } } }; let mut local_next_channel_id = if next_channel_id.is_none() { crate::c_types::ThirtyTwoBytes { data: [0; 32] } } else { { crate::c_types::ThirtyTwoBytes { data: (next_channel_id.unwrap()) } } }; let mut local_fee_earned_msat = if fee_earned_msat.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { fee_earned_msat.unwrap() }) }; + let mut local_outbound_amount_forwarded_msat = if outbound_amount_forwarded_msat.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { outbound_amount_forwarded_msat.unwrap() }) }; Event::PaymentForwarded { prev_channel_id: local_prev_channel_id, next_channel_id: local_next_channel_id, fee_earned_msat: local_fee_earned_msat, claim_from_onchain_tx: claim_from_onchain_tx, + outbound_amount_forwarded_msat: local_outbound_amount_forwarded_msat, + } + }, + nativeEvent::ChannelPending {mut channel_id, mut user_channel_id, mut former_temporary_channel_id, mut counterparty_node_id, mut funding_txo, } => { + let mut local_former_temporary_channel_id = if former_temporary_channel_id.is_none() { crate::c_types::ThirtyTwoBytes { data: [0; 32] } } else { { crate::c_types::ThirtyTwoBytes { data: (former_temporary_channel_id.unwrap()) } } }; + Event::ChannelPending { + channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id }, + user_channel_id: user_channel_id.into(), + former_temporary_channel_id: local_former_temporary_channel_id, + counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id), + funding_txo: crate::c_types::bitcoin_to_C_outpoint(funding_txo), } }, nativeEvent::ChannelReady {mut channel_id, mut user_channel_id, mut counterparty_node_id, mut channel_type, } => { @@ -1965,7 +2203,7 @@ impl Event { Event::ChannelClosed { channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id }, user_channel_id: user_channel_id.into(), - reason: crate::lightning::util::events::ClosureReason::native_into(reason), + reason: crate::lightning::events::ClosureReason::native_into(reason), } }, nativeEvent::DiscardFunding {mut channel_id, mut transaction, } => { @@ -1986,7 +2224,7 @@ impl Event { nativeEvent::HTLCHandlingFailed {mut prev_channel_id, mut failed_next_destination, } => { Event::HTLCHandlingFailed { prev_channel_id: crate::c_types::ThirtyTwoBytes { data: prev_channel_id }, - failed_next_destination: crate::lightning::util::events::HTLCDestination::native_into(failed_next_destination), + failed_next_destination: crate::lightning::events::HTLCDestination::native_into(failed_next_destination), } }, } @@ -2013,19 +2251,21 @@ pub extern "C" fn Event_funding_generation_ready(temporary_channel_id: crate::c_ } #[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, amount_msat: u64, purpose: crate::lightning::util::events::PaymentPurpose, via_channel_id: crate::c_types::ThirtyTwoBytes, via_user_channel_id: crate::c_types::derived::COption_u128Z) -> Event { +pub extern "C" fn Event_payment_claimable(receiver_node_id: crate::c_types::PublicKey, payment_hash: crate::c_types::ThirtyTwoBytes, onion_fields: crate::lightning::ln::outbound_payment::RecipientOnionFields, amount_msat: u64, purpose: crate::lightning::events::PaymentPurpose, via_channel_id: crate::c_types::ThirtyTwoBytes, via_user_channel_id: crate::c_types::derived::COption_u128Z, claim_deadline: crate::c_types::derived::COption_u32Z) -> Event { Event::PaymentClaimable { receiver_node_id, payment_hash, + onion_fields, amount_msat, purpose, via_channel_id, via_user_channel_id, + claim_deadline, } } #[no_mangle] /// Utility method to constructs a new PaymentClaimed-variant Event -pub extern "C" fn Event_payment_claimed(receiver_node_id: crate::c_types::PublicKey, payment_hash: crate::c_types::ThirtyTwoBytes, amount_msat: u64, purpose: crate::lightning::util::events::PaymentPurpose) -> Event { +pub extern "C" fn Event_payment_claimed(receiver_node_id: crate::c_types::PublicKey, payment_hash: crate::c_types::ThirtyTwoBytes, amount_msat: u64, purpose: crate::lightning::events::PaymentPurpose) -> Event { Event::PaymentClaimed { receiver_node_id, payment_hash, @@ -2045,15 +2285,16 @@ pub extern "C" fn Event_payment_sent(payment_id: crate::c_types::ThirtyTwoBytes, } #[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) -> Event { +pub extern "C" fn Event_payment_failed(payment_id: crate::c_types::ThirtyTwoBytes, payment_hash: crate::c_types::ThirtyTwoBytes, reason: crate::c_types::derived::COption_PaymentFailureReasonZ) -> Event { Event::PaymentFailed { payment_id, payment_hash, + reason, } } #[no_mangle] /// Utility method to constructs a new PaymentPathSuccessful-variant Event -pub extern "C" fn Event_payment_path_successful(payment_id: crate::c_types::ThirtyTwoBytes, payment_hash: crate::c_types::ThirtyTwoBytes, path: crate::c_types::derived::CVec_RouteHopZ) -> Event { +pub extern "C" fn Event_payment_path_successful(payment_id: crate::c_types::ThirtyTwoBytes, payment_hash: crate::c_types::ThirtyTwoBytes, path: crate::lightning::routing::router::Path) -> Event { Event::PaymentPathSuccessful { payment_id, payment_hash, @@ -2062,7 +2303,7 @@ pub extern "C" fn Event_payment_path_successful(payment_id: crate::c_types::Thir } #[no_mangle] /// Utility method to constructs a new PaymentPathFailed-variant Event -pub extern "C" fn Event_payment_path_failed(payment_id: crate::c_types::ThirtyTwoBytes, payment_hash: crate::c_types::ThirtyTwoBytes, payment_failed_permanently: bool, failure: crate::lightning::util::events::PathFailure, path: crate::c_types::derived::CVec_RouteHopZ, short_channel_id: crate::c_types::derived::COption_u64Z, retry: crate::lightning::routing::router::RouteParameters) -> Event { +pub extern "C" fn Event_payment_path_failed(payment_id: crate::c_types::ThirtyTwoBytes, payment_hash: crate::c_types::ThirtyTwoBytes, payment_failed_permanently: bool, failure: crate::lightning::events::PathFailure, path: crate::lightning::routing::router::Path, short_channel_id: crate::c_types::derived::COption_u64Z) -> Event { Event::PaymentPathFailed { payment_id, payment_hash, @@ -2070,12 +2311,11 @@ pub extern "C" fn Event_payment_path_failed(payment_id: crate::c_types::ThirtyTw failure, path, short_channel_id, - retry, } } #[no_mangle] /// Utility method to constructs a new ProbeSuccessful-variant Event -pub extern "C" fn Event_probe_successful(payment_id: crate::c_types::ThirtyTwoBytes, payment_hash: crate::c_types::ThirtyTwoBytes, path: crate::c_types::derived::CVec_RouteHopZ) -> Event { +pub extern "C" fn Event_probe_successful(payment_id: crate::c_types::ThirtyTwoBytes, payment_hash: crate::c_types::ThirtyTwoBytes, path: crate::lightning::routing::router::Path) -> Event { Event::ProbeSuccessful { payment_id, payment_hash, @@ -2084,7 +2324,7 @@ pub extern "C" fn Event_probe_successful(payment_id: crate::c_types::ThirtyTwoBy } #[no_mangle] /// Utility method to constructs a new ProbeFailed-variant Event -pub extern "C" fn Event_probe_failed(payment_id: crate::c_types::ThirtyTwoBytes, payment_hash: crate::c_types::ThirtyTwoBytes, path: crate::c_types::derived::CVec_RouteHopZ, short_channel_id: crate::c_types::derived::COption_u64Z) -> Event { +pub extern "C" fn Event_probe_failed(payment_id: crate::c_types::ThirtyTwoBytes, payment_hash: crate::c_types::ThirtyTwoBytes, path: crate::lightning::routing::router::Path, short_channel_id: crate::c_types::derived::COption_u64Z) -> Event { Event::ProbeFailed { payment_id, payment_hash, @@ -2119,12 +2359,24 @@ pub extern "C" fn Event_spendable_outputs(outputs: crate::c_types::derived::CVec } #[no_mangle] /// Utility method to constructs a new PaymentForwarded-variant Event -pub extern "C" fn Event_payment_forwarded(prev_channel_id: crate::c_types::ThirtyTwoBytes, next_channel_id: crate::c_types::ThirtyTwoBytes, fee_earned_msat: crate::c_types::derived::COption_u64Z, claim_from_onchain_tx: bool) -> Event { +pub extern "C" fn Event_payment_forwarded(prev_channel_id: crate::c_types::ThirtyTwoBytes, next_channel_id: crate::c_types::ThirtyTwoBytes, fee_earned_msat: crate::c_types::derived::COption_u64Z, claim_from_onchain_tx: bool, outbound_amount_forwarded_msat: crate::c_types::derived::COption_u64Z) -> Event { Event::PaymentForwarded { prev_channel_id, next_channel_id, fee_earned_msat, claim_from_onchain_tx, + outbound_amount_forwarded_msat, + } +} +#[no_mangle] +/// Utility method to constructs a new ChannelPending-variant Event +pub extern "C" fn Event_channel_pending(channel_id: crate::c_types::ThirtyTwoBytes, user_channel_id: crate::c_types::U128, former_temporary_channel_id: crate::c_types::ThirtyTwoBytes, counterparty_node_id: crate::c_types::PublicKey, funding_txo: crate::lightning::chain::transaction::OutPoint) -> Event { + Event::ChannelPending { + channel_id, + user_channel_id, + former_temporary_channel_id, + counterparty_node_id, + funding_txo, } } #[no_mangle] @@ -2139,7 +2391,7 @@ pub extern "C" fn Event_channel_ready(channel_id: crate::c_types::ThirtyTwoBytes } #[no_mangle] /// Utility method to constructs a new ChannelClosed-variant Event -pub extern "C" fn Event_channel_closed(channel_id: crate::c_types::ThirtyTwoBytes, user_channel_id: crate::c_types::U128, reason: crate::lightning::util::events::ClosureReason) -> Event { +pub extern "C" fn Event_channel_closed(channel_id: crate::c_types::ThirtyTwoBytes, user_channel_id: crate::c_types::U128, reason: crate::lightning::events::ClosureReason) -> Event { Event::ChannelClosed { channel_id, user_channel_id, @@ -2167,7 +2419,7 @@ pub extern "C" fn Event_open_channel_request(temporary_channel_id: crate::c_type } #[no_mangle] /// Utility method to constructs a new HTLCHandlingFailed-variant Event -pub extern "C" fn Event_htlchandling_failed(prev_channel_id: crate::c_types::ThirtyTwoBytes, failed_next_destination: crate::lightning::util::events::HTLCDestination) -> Event { +pub extern "C" fn Event_htlchandling_failed(prev_channel_id: crate::c_types::ThirtyTwoBytes, failed_next_destination: crate::lightning::events::HTLCDestination) -> Event { Event::HTLCHandlingFailed { prev_channel_id, failed_next_destination, @@ -2181,14 +2433,14 @@ pub extern "C" fn Event_eq(a: &Event, b: &Event) -> bool { } #[no_mangle] /// Serialize the Event object into a byte array which can be read by Event_read -pub extern "C" fn Event_write(obj: &crate::lightning::util::events::Event) -> crate::c_types::derived::CVec_u8Z { +pub extern "C" fn Event_write(obj: &crate::lightning::events::Event) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(&unsafe { &*obj }.to_native()) } #[no_mangle] /// Read a Event from a byte array, created by Event_write pub extern "C" fn Event_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_COption_EventZDecodeErrorZ { - let res: Result, lightning::ln::msgs::DecodeError> = crate::c_types::maybe_deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_res_0 = if o.is_none() { crate::c_types::derived::COption_EventZ::None } else { crate::c_types::derived::COption_EventZ::Some( { crate::lightning::util::events::Event::native_into(o.unwrap()) }) }; local_res_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + let res: Result, lightning::ln::msgs::DecodeError> = crate::c_types::maybe_deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_res_0 = if o.is_none() { crate::c_types::derived::COption_EventZ::None } else { crate::c_types::derived::COption_EventZ::Some( { crate::lightning::events::Event::native_into(o.unwrap()) }) }; local_res_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; local_res } /// An event generated by ChannelManager which indicates a message should be sent to a peer (or @@ -2364,7 +2616,7 @@ pub enum MessageSendEvent { msg: crate::lightning::ln::msgs::GossipTimestampFilter, }, } -use lightning::util::events::MessageSendEvent as MessageSendEventImport; +use lightning::events::MessageSendEvent as MessageSendEventImport; pub(crate) type nativeMessageSendEvent = MessageSendEventImport; impl MessageSendEvent { @@ -3175,9 +3427,9 @@ pub(crate) extern "C" fn MessageSendEventsProvider_clone_fields(orig: &MessageSe } } -use lightning::util::events::MessageSendEventsProvider as rustMessageSendEventsProvider; +use lightning::events::MessageSendEventsProvider as rustMessageSendEventsProvider; impl rustMessageSendEventsProvider for MessageSendEventsProvider { - fn get_and_clear_pending_msg_events(&self) -> Vec { + fn get_and_clear_pending_msg_events(&self) -> Vec { let mut ret = (self.get_and_clear_pending_msg_events)(self.this_arg); let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); }; local_ret @@ -3228,7 +3480,7 @@ pub(crate) extern "C" fn OnionMessageProvider_clone_fields(orig: &OnionMessagePr } } -use lightning::util::events::OnionMessageProvider as rustOnionMessageProvider; +use lightning::events::OnionMessageProvider as rustOnionMessageProvider; impl rustOnionMessageProvider for OnionMessageProvider { fn next_onion_message_for_peer(&self, mut peer_node_id: bitcoin::secp256k1::PublicKey) -> Option { let mut ret = (self.next_onion_message_for_peer)(self.this_arg, crate::c_types::PublicKey::from_rust(&peer_node_id)); @@ -3299,7 +3551,7 @@ pub struct EventsProvider { /// Processes any events generated since the last call using the given event handler. /// /// See the trait-level documentation for requirements. - pub process_pending_events: extern "C" fn (this_arg: *const c_void, handler: crate::lightning::util::events::EventHandler), + pub process_pending_events: extern "C" fn (this_arg: *const c_void, handler: crate::lightning::events::EventHandler), /// Frees any resources associated with this object given its this_arg pointer. /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. pub free: Option, @@ -3315,7 +3567,7 @@ pub(crate) extern "C" fn EventsProvider_clone_fields(orig: &EventsProvider) -> E } } -use lightning::util::events::EventsProvider as rustEventsProvider; +use lightning::events::EventsProvider as rustEventsProvider; /// Calls the free function if one is set #[no_mangle] pub extern "C" fn EventsProvider_free(this_ptr: EventsProvider) { } @@ -3339,7 +3591,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::util::events::Event), + pub handle_event: extern "C" fn (this_arg: *const c_void, event: crate::lightning::events::Event), /// Frees any resources associated with this object given its this_arg pointer. /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. pub free: Option, @@ -3355,10 +3607,10 @@ pub(crate) extern "C" fn EventHandler_clone_fields(orig: &EventHandler) -> Event } } -use lightning::util::events::EventHandler as rustEventHandler; +use lightning::events::EventHandler as rustEventHandler; impl rustEventHandler for EventHandler { - fn handle_event(&self, mut event: lightning::util::events::Event) { - (self.handle_event)(self.this_arg, crate::lightning::util::events::Event::native_into(event)) + fn handle_event(&self, mut event: lightning::events::Event) { + (self.handle_event)(self.this_arg, crate::lightning::events::Event::native_into(event)) } } diff --git a/lightning-c-bindings/src/lightning/ln/chan_utils.rs b/lightning-c-bindings/src/lightning/ln/chan_utils.rs index 0b0c8b2..ebfd129 100644 --- a/lightning-c-bindings/src/lightning/ln/chan_utils.rs +++ b/lightning-c-bindings/src/lightning/ln/chan_utils.rs @@ -7,7 +7,7 @@ // source was automatically generated. //! Various utilities for building scripts and deriving keys related to channels. These are -//! largely of interest for those implementing chain::keysinterface::Sign message signing by hand. +//! largely of interest for those implementing the traits on [`chain::keysinterface`] by hand. use alloc::str::FromStr; use core::ffi::c_void; @@ -1163,6 +1163,15 @@ pub(crate) extern "C" fn ChannelTransactionParameters_clone_void(this_ptr: *cons pub extern "C" fn ChannelTransactionParameters_clone(orig: &ChannelTransactionParameters) -> ChannelTransactionParameters { orig.clone() } +/// Checks if two ChannelTransactionParameterss contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn ChannelTransactionParameters_eq(a: &ChannelTransactionParameters, b: &ChannelTransactionParameters) -> 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::chan_utils::CounterpartyChannelTransactionParameters as nativeCounterpartyChannelTransactionParametersImport; pub(crate) type nativeCounterpartyChannelTransactionParameters = nativeCounterpartyChannelTransactionParametersImport; @@ -1264,6 +1273,15 @@ pub(crate) extern "C" fn CounterpartyChannelTransactionParameters_clone_void(thi pub extern "C" fn CounterpartyChannelTransactionParameters_clone(orig: &CounterpartyChannelTransactionParameters) -> CounterpartyChannelTransactionParameters { orig.clone() } +/// Checks if two CounterpartyChannelTransactionParameterss contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn CounterpartyChannelTransactionParameters_eq(a: &CounterpartyChannelTransactionParameters, b: &CounterpartyChannelTransactionParameters) -> 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 } +} /// Whether the late bound parameters are populated. #[must_use] #[no_mangle] @@ -1690,12 +1708,19 @@ pub extern "C" fn BuiltCommitmentTransaction_get_sighash_all(this_arg: &crate::l crate::c_types::ThirtyTwoBytes { data: ret.as_ref().clone() } } -/// Sign a transaction, either because we are counter-signing the counterparty's transaction or -/// because we are about to broadcast a holder transaction. +/// Signs the counterparty's commitment transaction. #[must_use] #[no_mangle] -pub extern "C" fn BuiltCommitmentTransaction_sign(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::Signature { - 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(Vec::from(funding_redeemscript.to_slice())), channel_value_satoshis, secp256k1::global::SECP256K1); +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::Signature { + 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(Vec::from(funding_redeemscript.to_slice())), channel_value_satoshis, secp256k1::global::SECP256K1); + crate::c_types::Signature::from_rust(&ret) +} + +/// Signs the holder commitment transaction because we are about to broadcast it. +#[must_use] +#[no_mangle] +pub extern "C" fn BuiltCommitmentTransaction_sign_holder_commitment(this_arg: &crate::lightning::ln::chan_utils::BuiltCommitmentTransaction, funding_key: *const [u8; 32], mut funding_redeemscript: crate::c_types::u8slice, mut channel_value_satoshis: u64, entropy_source: &crate::lightning::chain::keysinterface::EntropySource) -> crate::c_types::Signature { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.sign_holder_commitment(&::bitcoin::secp256k1::SecretKey::from_slice(&unsafe { *funding_key}[..]).unwrap(), &::bitcoin::blockdata::script::Script::from(Vec::from(funding_redeemscript.to_slice())), channel_value_satoshis, entropy_source, secp256k1::global::SECP256K1); crate::c_types::Signature::from_rust(&ret) } @@ -1773,7 +1798,7 @@ pub(crate) extern "C" fn ClosingTransaction_clone_void(this_ptr: *const c_void) pub extern "C" fn ClosingTransaction_clone(orig: &ClosingTransaction) -> ClosingTransaction { orig.clone() } -/// Checks if two ClosingTransactions contain equal inner contents. +/// Generates a non-cryptographic 64-bit hash of the ClosingTransaction. #[no_mangle] pub extern "C" fn ClosingTransaction_hash(o: &ClosingTransaction) -> u64 { if o.inner.is_null() { return 0; } @@ -2188,8 +2213,8 @@ pub extern "C" fn TrustedCommitmentTransaction_opt_anchors(this_arg: &crate::lig /// This function is only valid in the holder commitment context, it always uses EcdsaSighashType::All. #[must_use] #[no_mangle] -pub extern "C" fn TrustedCommitmentTransaction_get_htlc_sigs(this_arg: &crate::lightning::ln::chan_utils::TrustedCommitmentTransaction, htlc_base_key: *const [u8; 32], channel_parameters: &crate::lightning::ln::chan_utils::DirectedChannelTransactionParameters) -> crate::c_types::derived::CResult_CVec_SignatureZNoneZ { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_htlc_sigs(&::bitcoin::secp256k1::SecretKey::from_slice(&unsafe { *htlc_base_key}[..]).unwrap(), channel_parameters.get_native_ref(), secp256k1::global::SECP256K1); +pub extern "C" fn TrustedCommitmentTransaction_get_htlc_sigs(this_arg: &crate::lightning::ln::chan_utils::TrustedCommitmentTransaction, htlc_base_key: *const [u8; 32], channel_parameters: &crate::lightning::ln::chan_utils::DirectedChannelTransactionParameters, entropy_source: &crate::lightning::chain::keysinterface::EntropySource) -> crate::c_types::derived::CResult_CVec_SignatureZNoneZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_htlc_sigs(&::bitcoin::secp256k1::SecretKey::from_slice(&unsafe { *htlc_base_key}[..]).unwrap(), channel_parameters.get_native_ref(), entropy_source, secp256k1::global::SECP256K1); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = Vec::new(); for mut item in o.drain(..) { local_ret_0.push( { crate::c_types::Signature::from_rust(&item) }); }; local_ret_0.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; local_ret } diff --git a/lightning-c-bindings/src/lightning/ln/channelmanager.rs b/lightning-c-bindings/src/lightning/ln/channelmanager.rs index 79daeb2..bcca9df 100644 --- a/lightning-c-bindings/src/lightning/ln/channelmanager.rs +++ b/lightning-c-bindings/src/lightning/ln/channelmanager.rs @@ -8,7 +8,7 @@ //! The top-level channel management and payment tracking stuff lives here. //! -//! The ChannelManager is the main chunk of logic implementing the lightning protocol and is +//! The [`ChannelManager`] is the main chunk of logic implementing the lightning protocol and is //! responsible for tracking which channels are open, HTLCs are in flight and reestablishing those //! upon reconnect to the relevant peer(s). //! @@ -105,35 +105,33 @@ pub(crate) type nativeChannelManager = nativeChannelManagerImport Chann use lightning::ln::channelmanager::ChannelDetails as nativeChannelDetailsImport; pub(crate) type nativeChannelDetails = nativeChannelDetailsImport; -/// Details of a channel, as returned by ChannelManager::list_channels and ChannelManager::list_usable_channels +/// Details of a channel, as returned by [`ChannelManager::list_channels`] and [`ChannelManager::list_usable_channels`] #[must_use] #[repr(C)] pub struct ChannelDetails { @@ -905,6 +912,25 @@ pub extern "C" fn ChannelDetails_get_user_channel_id(this_ptr: &ChannelDetails) pub extern "C" fn ChannelDetails_set_user_channel_id(this_ptr: &mut ChannelDetails, mut val: crate::c_types::U128) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.user_channel_id = val.into(); } +/// The currently negotiated fee rate denominated in satoshi per 1000 weight units, +/// which is applied to commitment and HTLC transactions. +/// +/// This value will be `None` for objects serialized with LDK versions prior to 0.0.115. +#[no_mangle] +pub extern "C" fn ChannelDetails_get_feerate_sat_per_1000_weight(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u32Z { + let mut inner_val = &mut this_ptr.get_native_mut_ref().feerate_sat_per_1000_weight; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u32Z::None } else { crate::c_types::derived::COption_u32Z::Some( { inner_val.unwrap() }) }; + local_inner_val +} +/// The currently negotiated fee rate denominated in satoshi per 1000 weight units, +/// which is applied to commitment and HTLC transactions. +/// +/// This value will be `None` for objects serialized with LDK versions prior to 0.0.115. +#[no_mangle] +pub extern "C" fn ChannelDetails_set_feerate_sat_per_1000_weight(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u32Z) { + let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.feerate_sat_per_1000_weight = local_val; +} /// Our total balance. This is the amount we would get if we close the channel. /// This value is not exact. Due to various in-flight changes and feerate changes, exactly this /// amount is not likely to be recoverable on close. @@ -1200,13 +1226,14 @@ pub extern "C" fn ChannelDetails_set_config(this_ptr: &mut ChannelDetails, mut v /// Constructs a new ChannelDetails given each field #[must_use] #[no_mangle] -pub extern "C" fn ChannelDetails_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut counterparty_arg: crate::lightning::ln::channelmanager::ChannelCounterparty, mut funding_txo_arg: crate::lightning::chain::transaction::OutPoint, mut channel_type_arg: crate::lightning::ln::features::ChannelTypeFeatures, mut short_channel_id_arg: crate::c_types::derived::COption_u64Z, mut outbound_scid_alias_arg: crate::c_types::derived::COption_u64Z, mut inbound_scid_alias_arg: crate::c_types::derived::COption_u64Z, mut channel_value_satoshis_arg: u64, mut unspendable_punishment_reserve_arg: crate::c_types::derived::COption_u64Z, mut user_channel_id_arg: crate::c_types::U128, mut balance_msat_arg: u64, mut outbound_capacity_msat_arg: u64, mut next_outbound_htlc_limit_msat_arg: u64, mut inbound_capacity_msat_arg: u64, mut confirmations_required_arg: crate::c_types::derived::COption_u32Z, mut confirmations_arg: crate::c_types::derived::COption_u32Z, mut force_close_spend_delay_arg: crate::c_types::derived::COption_u16Z, mut is_outbound_arg: bool, mut is_channel_ready_arg: bool, mut is_usable_arg: bool, mut is_public_arg: bool, mut inbound_htlc_minimum_msat_arg: crate::c_types::derived::COption_u64Z, mut inbound_htlc_maximum_msat_arg: crate::c_types::derived::COption_u64Z, mut config_arg: crate::lightning::util::config::ChannelConfig) -> ChannelDetails { +pub extern "C" fn ChannelDetails_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut counterparty_arg: crate::lightning::ln::channelmanager::ChannelCounterparty, mut funding_txo_arg: crate::lightning::chain::transaction::OutPoint, mut channel_type_arg: crate::lightning::ln::features::ChannelTypeFeatures, mut short_channel_id_arg: crate::c_types::derived::COption_u64Z, mut outbound_scid_alias_arg: crate::c_types::derived::COption_u64Z, mut inbound_scid_alias_arg: crate::c_types::derived::COption_u64Z, mut channel_value_satoshis_arg: u64, mut unspendable_punishment_reserve_arg: crate::c_types::derived::COption_u64Z, mut user_channel_id_arg: crate::c_types::U128, mut feerate_sat_per_1000_weight_arg: crate::c_types::derived::COption_u32Z, mut balance_msat_arg: u64, mut outbound_capacity_msat_arg: u64, mut next_outbound_htlc_limit_msat_arg: u64, mut inbound_capacity_msat_arg: u64, mut confirmations_required_arg: crate::c_types::derived::COption_u32Z, mut confirmations_arg: crate::c_types::derived::COption_u32Z, mut force_close_spend_delay_arg: crate::c_types::derived::COption_u16Z, mut is_outbound_arg: bool, mut is_channel_ready_arg: bool, mut is_usable_arg: bool, mut is_public_arg: bool, mut inbound_htlc_minimum_msat_arg: crate::c_types::derived::COption_u64Z, mut inbound_htlc_maximum_msat_arg: crate::c_types::derived::COption_u64Z, mut config_arg: crate::lightning::util::config::ChannelConfig) -> ChannelDetails { 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 }; let mut local_outbound_scid_alias_arg = if outbound_scid_alias_arg.is_some() { Some( { outbound_scid_alias_arg.take() }) } else { None }; let mut local_inbound_scid_alias_arg = if inbound_scid_alias_arg.is_some() { Some( { inbound_scid_alias_arg.take() }) } else { None }; let mut local_unspendable_punishment_reserve_arg = if unspendable_punishment_reserve_arg.is_some() { Some( { unspendable_punishment_reserve_arg.take() }) } else { None }; + let mut local_feerate_sat_per_1000_weight_arg = if feerate_sat_per_1000_weight_arg.is_some() { Some( { feerate_sat_per_1000_weight_arg.take() }) } else { None }; let mut local_confirmations_required_arg = if confirmations_required_arg.is_some() { Some( { confirmations_required_arg.take() }) } else { None }; let mut local_confirmations_arg = if confirmations_arg.is_some() { Some( { confirmations_arg.take() }) } else { None }; let mut local_force_close_spend_delay_arg = if force_close_spend_delay_arg.is_some() { Some( { force_close_spend_delay_arg.take() }) } else { None }; @@ -1224,6 +1251,7 @@ pub extern "C" fn ChannelDetails_new(mut channel_id_arg: crate::c_types::ThirtyT channel_value_satoshis: channel_value_satoshis_arg, unspendable_punishment_reserve: local_unspendable_punishment_reserve_arg, user_channel_id: user_channel_id_arg.into(), + feerate_sat_per_1000_weight: local_feerate_sat_per_1000_weight_arg, balance_msat: balance_msat_arg, outbound_capacity_msat: outbound_capacity_msat_arg, next_outbound_htlc_limit_msat: next_outbound_htlc_limit_msat_arg, @@ -1571,16 +1599,21 @@ pub(crate) extern "C" fn PhantomRouteHints_clone_void(this_ptr: *const c_void) - pub extern "C" fn PhantomRouteHints_clone(orig: &PhantomRouteHints) -> PhantomRouteHints { orig.clone() } -/// Constructs a new ChannelManager to hold several channels and route between them. +/// Constructs a new `ChannelManager` to hold several channels and route between them. /// /// This is the main \"logic hub\" for all channel-related actions, and implements -/// ChannelMessageHandler. +/// [`ChannelMessageHandler`]. /// /// Non-proportional fees are fixed according to our risk using the provided fee estimator. /// -/// Users need to notify the new ChannelManager when a new block is connected or -/// disconnected using its `block_connected` and `block_disconnected` methods, starting -/// from after `params.latest_hash`. +/// Users need to notify the new `ChannelManager` when a new block is connected or +/// disconnected using its [`block_connected`] and [`block_disconnected`] methods, starting +/// from after [`params.best_block.block_hash`]. See [`chain::Listen`] and [`chain::Confirm`] for +/// more details. +/// +/// [`block_connected`]: chain::Listen::block_connected +/// [`block_disconnected`]: chain::Listen::block_disconnected +/// [`params.best_block.block_hash`]: chain::BestBlock::block_hash #[must_use] #[no_mangle] pub extern "C" fn ChannelManager_new(mut fee_est: crate::lightning::chain::chaininterface::FeeEstimator, mut chain_monitor: crate::lightning::chain::Watch, mut tx_broadcaster: crate::lightning::chain::chaininterface::BroadcasterInterface, mut router: crate::lightning::routing::router::Router, mut logger: crate::lightning::util::logger::Logger, mut entropy_source: crate::lightning::chain::keysinterface::EntropySource, mut node_signer: crate::lightning::chain::keysinterface::NodeSigner, mut signer_provider: crate::lightning::chain::keysinterface::SignerProvider, mut config: crate::lightning::util::config::UserConfig, mut params: crate::lightning::ln::channelmanager::ChainParameters) -> crate::lightning::ln::channelmanager::ChannelManager { @@ -1632,7 +1665,7 @@ pub extern "C" fn ChannelManager_create_channel(this_arg: &crate::lightning::ln: local_ret } -/// Gets the list of open channels, in random order. See ChannelDetail field documentation for +/// Gets the list of open channels, in random order. See [`ChannelDetails`] field documentation for /// more information. #[must_use] #[no_mangle] @@ -1656,6 +1689,15 @@ pub extern "C" fn ChannelManager_list_usable_channels(this_arg: &crate::lightnin local_ret.into() } +/// Gets the list of channels we have with a given counterparty, in random order. +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelManager_list_channels_with_counterparty(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut counterparty_node_id: crate::c_types::PublicKey) -> crate::c_types::derived::CVec_ChannelDetailsZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.list_channels_with_counterparty(&counterparty_node_id.into_rust()); + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::ln::channelmanager::ChannelDetails { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; + local_ret.into() +} + /// Returns in an undefined order recent payments that -- if not fulfilled -- have yet to find a /// successful path, or have unresolved HTLCs. /// @@ -1684,11 +1726,12 @@ pub extern "C" fn ChannelManager_list_recent_payments(this_arg: &crate::lightnin /// would appear on a force-closure transaction, whichever is lower. We will allow our /// counterparty to pay as much fee as they'd like, however. /// -/// May generate a SendShutdown message event on success, which should be relayed. +/// May generate a [`SendShutdown`] message event on success, which should be relayed. /// /// [`ChannelConfig::force_close_avoidance_max_fee_satoshis`]: crate::util::config::ChannelConfig::force_close_avoidance_max_fee_satoshis /// [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background /// [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal +/// [`SendShutdown`]: crate::events::MessageSendEvent::SendShutdown #[must_use] #[no_mangle] pub extern "C" fn ChannelManager_close_channel(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, channel_id: *const [u8; 32], mut counterparty_node_id: crate::c_types::PublicKey) -> crate::c_types::derived::CResult_NoneAPIErrorZ { @@ -1711,11 +1754,12 @@ pub extern "C" fn ChannelManager_close_channel(this_arg: &crate::lightning::ln:: /// transaction feerate below `target_feerate_sat_per_1000_weight` (or the feerate which /// will appear on a force-closure transaction, whichever is lower). /// -/// May generate a SendShutdown message event on success, which should be relayed. +/// May generate a [`SendShutdown`] message event on success, which should be relayed. /// /// [`ChannelConfig::force_close_avoidance_max_fee_satoshis`]: crate::util::config::ChannelConfig::force_close_avoidance_max_fee_satoshis /// [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background /// [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal +/// [`SendShutdown`]: crate::events::MessageSendEvent::SendShutdown #[must_use] #[no_mangle] pub extern "C" fn ChannelManager_close_channel_with_target_feerate(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, channel_id: *const [u8; 32], mut counterparty_node_id: crate::c_types::PublicKey, mut target_feerate_sats_per_1000_weight: u32) -> crate::c_types::derived::CResult_NoneAPIErrorZ { @@ -1769,7 +1813,7 @@ pub extern "C" fn ChannelManager_force_close_all_channels_without_broadcasting_t /// Value parameters are provided via the last hop in route, see documentation for [`RouteHop`] /// fields for more info. /// -/// May generate SendHTLCs message(s) event on success, which should be relayed (e.g. via +/// May generate [`UpdateHTLCs`] message(s) event on success, which should be relayed (e.g. via /// [`PeerManager::process_events`]). /// /// # Avoiding Duplicate Payments @@ -1793,7 +1837,7 @@ pub extern "C" fn ChannelManager_force_close_all_channels_without_broadcasting_t /// /// # Possible Error States on [`PaymentSendFailure`] /// -/// Each path may have a different return value, and PaymentSendValue may return a Vec with +/// Each path may have a different return value, and [`PaymentSendFailure`] may return a `Vec` with /// each entry matching the corresponding-index entry in the route paths, see /// [`PaymentSendFailure`] for more info. /// @@ -1806,46 +1850,29 @@ pub extern "C" fn ChannelManager_force_close_all_channels_without_broadcasting_t /// * [`APIError::MonitorUpdateInProgress`] if a new monitor update failure prevented sending the /// relevant updates. /// -/// Note that depending on the type of the PaymentSendFailure the HTLC may have been +/// Note that depending on the type of the [`PaymentSendFailure`] the HTLC may have been /// irrevocably committed to on our end. In such a case, do NOT retry the payment with a /// different route unless you intend to pay twice! /// -/// # A caution on `payment_secret` -/// -/// `payment_secret` is unrelated to `payment_hash` (or [`PaymentPreimage`]) and exists to -/// authenticate the sender to the recipient and prevent payment-probing (deanonymization) -/// attacks. For newer nodes, it will be provided to you in the invoice. If you do not have one, -/// the [`Route`] must not contain multiple paths as multi-path payments require a -/// recipient-provided `payment_secret`. -/// -/// If a `payment_secret` *is* provided, we assume that the invoice had the payment_secret -/// feature bit set (either as required or as available). If multiple paths are present in the -/// [`Route`], we assume the invoice had the basic_mpp feature set. -/// /// [`Event::PaymentSent`]: events::Event::PaymentSent /// [`Event::PaymentFailed`]: events::Event::PaymentFailed +/// [`UpdateHTLCs`]: events::MessageSendEvent::UpdateHTLCs /// [`PeerManager::process_events`]: crate::ln::peer_handler::PeerManager::process_events /// [`ChannelMonitorUpdateStatus::InProgress`]: crate::chain::ChannelMonitorUpdateStatus::InProgress -/// -/// Note that payment_secret (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn ChannelManager_send_payment(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, route: &crate::lightning::routing::router::Route, mut payment_hash: crate::c_types::ThirtyTwoBytes, mut payment_secret: crate::c_types::ThirtyTwoBytes, mut payment_id: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_NonePaymentSendFailureZ { - let mut local_payment_secret = if payment_secret.data == [0; 32] { None } else { Some( { ::lightning::ln::PaymentSecret(payment_secret.data) }) }; - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.send_payment(route.get_native_ref(), ::lightning::ln::PaymentHash(payment_hash.data), &local_payment_secret, ::lightning::ln::channelmanager::PaymentId(payment_id.data)); +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::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 } /// Similar to [`ChannelManager::send_payment`], but will automatically find a route based on /// `route_params` and retry failed payment paths based on `retry_strategy`. -/// -/// Note that payment_secret (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn ChannelManager_send_payment_with_retry(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut payment_hash: crate::c_types::ThirtyTwoBytes, mut payment_secret: crate::c_types::ThirtyTwoBytes, mut payment_id: crate::c_types::ThirtyTwoBytes, mut route_params: crate::lightning::routing::router::RouteParameters, mut retry_strategy: crate::lightning::ln::outbound_payment::Retry) -> crate::c_types::derived::CResult_NoneRetryableSendFailureZ { - let mut local_payment_secret = if payment_secret.data == [0; 32] { None } else { Some( { ::lightning::ln::PaymentSecret(payment_secret.data) }) }; - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.send_payment_with_retry(::lightning::ln::PaymentHash(payment_hash.data), &local_payment_secret, ::lightning::ln::channelmanager::PaymentId(payment_id.data), *unsafe { Box::from_raw(route_params.take_inner()) }, retry_strategy.into_native()); +pub extern "C" fn ChannelManager_send_payment(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut payment_hash: crate::c_types::ThirtyTwoBytes, mut recipient_onion: crate::lightning::ln::outbound_payment::RecipientOnionFields, mut payment_id: crate::c_types::ThirtyTwoBytes, mut route_params: crate::lightning::routing::router::RouteParameters, mut retry_strategy: crate::lightning::ln::outbound_payment::Retry) -> crate::c_types::derived::CResult_NoneRetryableSendFailureZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.send_payment(::lightning::ln::PaymentHash(payment_hash.data), *unsafe { Box::from_raw(recipient_onion.take_inner()) }, ::lightning::ln::channelmanager::PaymentId(payment_id.data), *unsafe { Box::from_raw(route_params.take_inner()) }, retry_strategy.into_native()); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::outbound_payment::RetryableSendFailure::native_into(e) }).into() }; local_ret } @@ -1890,9 +1917,9 @@ pub extern "C" fn ChannelManager_abandon_payment(this_arg: &crate::lightning::ln /// Note that payment_preimage (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn ChannelManager_send_spontaneous_payment(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, route: &crate::lightning::routing::router::Route, mut payment_preimage: crate::c_types::ThirtyTwoBytes, mut payment_id: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_PaymentHashPaymentSendFailureZ { +pub extern "C" fn ChannelManager_send_spontaneous_payment(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, route: &crate::lightning::routing::router::Route, mut payment_preimage: crate::c_types::ThirtyTwoBytes, mut recipient_onion: crate::lightning::ln::outbound_payment::RecipientOnionFields, mut payment_id: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_PaymentHashPaymentSendFailureZ { let mut local_payment_preimage = if payment_preimage.data == [0; 32] { None } else { Some( { ::lightning::ln::PaymentPreimage(payment_preimage.data) }) }; - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.send_spontaneous_payment(route.get_native_ref(), local_payment_preimage, ::lightning::ln::channelmanager::PaymentId(payment_id.data)); + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.send_spontaneous_payment(route.get_native_ref(), local_payment_preimage, *unsafe { Box::from_raw(recipient_onion.take_inner()) }, ::lightning::ln::channelmanager::PaymentId(payment_id.data)); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ThirtyTwoBytes { data: o.0 } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::outbound_payment::PaymentSendFailure::native_into(e) }).into() }; local_ret } @@ -1908,9 +1935,9 @@ pub extern "C" fn ChannelManager_send_spontaneous_payment(this_arg: &crate::ligh /// Note that payment_preimage (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn ChannelManager_send_spontaneous_payment_with_retry(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut payment_preimage: crate::c_types::ThirtyTwoBytes, mut payment_id: crate::c_types::ThirtyTwoBytes, mut route_params: crate::lightning::routing::router::RouteParameters, mut retry_strategy: crate::lightning::ln::outbound_payment::Retry) -> crate::c_types::derived::CResult_PaymentHashRetryableSendFailureZ { +pub extern "C" fn ChannelManager_send_spontaneous_payment_with_retry(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut payment_preimage: crate::c_types::ThirtyTwoBytes, mut recipient_onion: crate::lightning::ln::outbound_payment::RecipientOnionFields, mut payment_id: crate::c_types::ThirtyTwoBytes, mut route_params: crate::lightning::routing::router::RouteParameters, mut retry_strategy: crate::lightning::ln::outbound_payment::Retry) -> crate::c_types::derived::CResult_PaymentHashRetryableSendFailureZ { let mut local_payment_preimage = if payment_preimage.data == [0; 32] { None } else { Some( { ::lightning::ln::PaymentPreimage(payment_preimage.data) }) }; - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.send_spontaneous_payment_with_retry(local_payment_preimage, ::lightning::ln::channelmanager::PaymentId(payment_id.data), *unsafe { Box::from_raw(route_params.take_inner()) }, retry_strategy.into_native()); + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.send_spontaneous_payment_with_retry(local_payment_preimage, *unsafe { Box::from_raw(recipient_onion.take_inner()) }, ::lightning::ln::channelmanager::PaymentId(payment_id.data), *unsafe { Box::from_raw(route_params.take_inner()) }, retry_strategy.into_native()); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ThirtyTwoBytes { data: o.0 } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::outbound_payment::RetryableSendFailure::native_into(e) }).into() }; local_ret } @@ -1920,9 +1947,8 @@ pub extern "C" fn ChannelManager_send_spontaneous_payment_with_retry(this_arg: & /// us to easily discern them from real payments. #[must_use] #[no_mangle] -pub extern "C" fn ChannelManager_send_probe(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut hops: crate::c_types::derived::CVec_RouteHopZ) -> crate::c_types::derived::CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ { - let mut local_hops = Vec::new(); for mut item in hops.into_rust().drain(..) { local_hops.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.send_probe(local_hops); +pub extern "C" fn ChannelManager_send_probe(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut path: crate::lightning::routing::router::Path) -> crate::c_types::derived::CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.send_probe(*unsafe { Box::from_raw(path.take_inner()) }); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = o; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0.0 }, crate::c_types::ThirtyTwoBytes { data: orig_ret_0_1.0 }).into(); local_ret_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::outbound_payment::PaymentSendFailure::native_into(e) }).into() }; local_ret } @@ -1955,8 +1981,8 @@ pub extern "C" fn ChannelManager_send_probe(this_arg: &crate::lightning::ln::cha /// implemented by Bitcoin Core wallet. See /// for more details. /// -/// [`Event::FundingGenerationReady`]: crate::util::events::Event::FundingGenerationReady -/// [`Event::ChannelClosed`]: crate::util::events::Event::ChannelClosed +/// [`Event::FundingGenerationReady`]: crate::events::Event::FundingGenerationReady +/// [`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: *const [u8; 32], mut counterparty_node_id: crate::c_types::PublicKey, mut funding_transaction: crate::c_types::Transaction) -> crate::c_types::derived::CResult_NoneAPIErrorZ { @@ -2052,15 +2078,18 @@ pub extern "C" fn ChannelManager_process_pending_htlc_forwards(this_arg: &crate: /// /// This currently includes: /// * Increasing or decreasing the on-chain feerate estimates for our outbound channels, -/// * Broadcasting `ChannelUpdate` messages if we've been disconnected from our peer for more +/// * Broadcasting [`ChannelUpdate`] messages if we've been disconnected from our peer for more /// than a minute, informing the network that they should no longer attempt to route over /// the channel. -/// * Expiring a channel's previous `ChannelConfig` if necessary to only allow forwarding HTLCs -/// with the current `ChannelConfig`. +/// * Expiring a channel's previous [`ChannelConfig`] if necessary to only allow forwarding HTLCs +/// with the current [`ChannelConfig`]. /// * Removing peers which have disconnected but and no longer have any channels. /// -/// Note that this may cause reentrancy through `chain::Watch::update_channel` calls or feerate +/// Note that this may cause reentrancy through [`chain::Watch::update_channel`] calls or feerate /// estimate fetches. +/// +/// [`ChannelUpdate`]: msgs::ChannelUpdate +/// [`ChannelConfig`]: crate::util::config::ChannelConfig #[no_mangle] pub extern "C" fn ChannelManager_timer_tick_occurred(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) { unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.timer_tick_occurred() @@ -2096,17 +2125,19 @@ pub extern "C" fn ChannelManager_fail_htlc_backwards_with_reason(this_arg: &crat /// Provides a payment preimage in response to [`Event::PaymentClaimable`], generating any /// [`MessageSendEvent`]s needed to claim the payment. /// -/// Note that calling this method does *not* guarantee that the payment has been claimed. You -/// *must* wait for an [`Event::PaymentClaimed`] event which upon a successful claim will be -/// provided to your [`EventHandler`] when [`process_pending_events`] is next called. +/// This method is guaranteed to ensure the payment has been claimed but only if the current +/// height is strictly below [`Event::PaymentClaimable::claim_deadline`]. To avoid race +/// conditions, you should wait for an [`Event::PaymentClaimed`] before considering the payment +/// successful. It will generally be available in the next [`process_pending_events`] call. /// /// Note that if you did not set an `amount_msat` when calling [`create_inbound_payment`] or /// [`create_inbound_payment_for_hash`] you must check that the amount in the `PaymentClaimable` /// event matches your expectation. If you fail to do so and call this method, you may provide /// the sender \"proof-of-payment\" when they did not fulfill the full expected payment. /// -/// [`Event::PaymentClaimable`]: crate::util::events::Event::PaymentClaimable -/// [`Event::PaymentClaimed`]: crate::util::events::Event::PaymentClaimed +/// [`Event::PaymentClaimable`]: crate::events::Event::PaymentClaimable +/// [`Event::PaymentClaimable::claim_deadline`]: crate::events::Event::PaymentClaimable::claim_deadline +/// [`Event::PaymentClaimed`]: crate::events::Event::PaymentClaimed /// [`process_pending_events`]: EventsProvider::process_pending_events /// [`create_inbound_payment`]: Self::create_inbound_payment /// [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash @@ -2362,7 +2393,7 @@ pub extern "C" fn ChannelManager_compute_inflight_htlcs(this_arg: &crate::lightn crate::lightning::routing::router::InFlightHtlcs { inner: ObjOps::heap_alloc(ret), is_owned: true } } -impl From for crate::lightning::util::events::MessageSendEventsProvider { +impl From for crate::lightning::events::MessageSendEventsProvider { fn from(obj: nativeChannelManager) -> Self { let mut rust_obj = ChannelManager { inner: ObjOps::heap_alloc(obj), is_owned: true }; let mut ret = ChannelManager_as_MessageSendEventsProvider(&rust_obj); @@ -2375,8 +2406,8 @@ impl From for crate::lightning::util::events::MessageSendE /// 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 #[no_mangle] -pub extern "C" fn ChannelManager_as_MessageSendEventsProvider(this_arg: &ChannelManager) -> crate::lightning::util::events::MessageSendEventsProvider { - crate::lightning::util::events::MessageSendEventsProvider { +pub extern "C" fn ChannelManager_as_MessageSendEventsProvider(this_arg: &ChannelManager) -> crate::lightning::events::MessageSendEventsProvider { + crate::lightning::events::MessageSendEventsProvider { this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, free: None, get_and_clear_pending_msg_events: ChannelManager_MessageSendEventsProvider_get_and_clear_pending_msg_events, @@ -2385,12 +2416,12 @@ pub extern "C" fn ChannelManager_as_MessageSendEventsProvider(this_arg: &Channel #[must_use] extern "C" fn ChannelManager_MessageSendEventsProvider_get_and_clear_pending_msg_events(this_arg: *const c_void) -> crate::c_types::derived::CVec_MessageSendEventZ { - let mut ret = >::get_and_clear_pending_msg_events(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, ); - let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::util::events::MessageSendEvent::native_into(item) }); }; + let mut ret = >::get_and_clear_pending_msg_events(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, ); + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::events::MessageSendEvent::native_into(item) }); }; local_ret.into() } -impl From for crate::lightning::util::events::EventsProvider { +impl From for crate::lightning::events::EventsProvider { fn from(obj: nativeChannelManager) -> Self { let mut rust_obj = ChannelManager { inner: ObjOps::heap_alloc(obj), is_owned: true }; let mut ret = ChannelManager_as_EventsProvider(&rust_obj); @@ -2403,16 +2434,16 @@ impl From for crate::lightning::util::events::EventsProvid /// 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 ChannelManager_as_EventsProvider(this_arg: &ChannelManager) -> crate::lightning::util::events::EventsProvider { - crate::lightning::util::events::EventsProvider { +pub extern "C" fn ChannelManager_as_EventsProvider(this_arg: &ChannelManager) -> 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: ChannelManager_EventsProvider_process_pending_events, } } -extern "C" fn ChannelManager_EventsProvider_process_pending_events(this_arg: *const c_void, mut handler: crate::lightning::util::events::EventHandler) { - >::process_pending_events(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, handler) +extern "C" fn ChannelManager_EventsProvider_process_pending_events(this_arg: *const c_void, mut handler: crate::lightning::events::EventHandler) { + >::process_pending_events(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, handler) } impl From for crate::lightning::chain::Listen { @@ -2490,37 +2521,11 @@ extern "C" fn ChannelManager_Confirm_get_relevant_txids(this_arg: *const c_void) local_ret.into() } -/// Blocks until ChannelManager needs to be persisted or a timeout is reached. It returns a bool -/// indicating whether persistence is necessary. Only one listener on -/// [`await_persistable_update`], [`await_persistable_update_timeout`], or a future returned by -/// [`get_persistable_update_future`] is guaranteed to be woken up. +/// Gets a [`Future`] that completes when this [`ChannelManager`] needs to be persisted. /// -/// Note that this method is not available with the `no-std` feature. +/// Note that callbacks registered on the [`Future`] MUST NOT call back into this +/// [`ChannelManager`] and should instead register actions to be taken later. /// -/// [`await_persistable_update`]: Self::await_persistable_update -/// [`await_persistable_update_timeout`]: Self::await_persistable_update_timeout -/// [`get_persistable_update_future`]: Self::get_persistable_update_future -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelManager_await_persistable_update_timeout(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut max_wait: u64) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.await_persistable_update_timeout(core::time::Duration::from_secs(max_wait)); - ret -} - -/// Blocks until ChannelManager needs to be persisted. Only one listener on -/// [`await_persistable_update`], `await_persistable_update_timeout`, or a future returned by -/// [`get_persistable_update_future`] is guaranteed to be woken up. -/// -/// [`await_persistable_update`]: Self::await_persistable_update -/// [`get_persistable_update_future`]: Self::get_persistable_update_future -#[no_mangle] -pub extern "C" fn ChannelManager_await_persistable_update(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) { - unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.await_persistable_update() -} - -/// Gets a [`Future`] that completes when a persistable update is available. Note that -/// callbacks registered on the [`Future`] MUST NOT call back into this [`ChannelManager`] and -/// should instead register actions to be taken later. #[must_use] #[no_mangle] pub extern "C" fn ChannelManager_get_persistable_update_future(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::lightning::util::wakers::Future { @@ -2612,7 +2617,7 @@ pub extern "C" fn ChannelManager_as_ChannelMessageHandler(this_arg: &ChannelMana handle_error: ChannelManager_ChannelMessageHandler_handle_error, provided_node_features: ChannelManager_ChannelMessageHandler_provided_node_features, provided_init_features: ChannelManager_ChannelMessageHandler_provided_init_features, - MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider { + MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider { this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, free: None, get_and_clear_pending_msg_events: ChannelManager_MessageSendEventsProvider_get_and_clear_pending_msg_events, diff --git a/lightning-c-bindings/src/lightning/ln/features.rs b/lightning-c-bindings/src/lightning/ln/features.rs index 18fe70c..7f8c8e8 100644 --- a/lightning-c-bindings/src/lightning/ln/features.rs +++ b/lightning-c-bindings/src/lightning/ln/features.rs @@ -44,17 +44,24 @@ //! (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). -//! TODO: update link //! - `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). //! - `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). +//! 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). //! //! [BOLT #9]: https://github.com/lightning/bolts/blob/master/09-features.md //! [messages]: crate::ln::msgs @@ -1021,6 +1028,34 @@ pub extern "C" fn ChannelTypeFeatures_requires_scid_privacy(this_arg: &crate::li ret } +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn InvoiceFeatures_set_payment_metadata_optional(this_arg: &mut crate::lightning::ln::features::InvoiceFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInvoiceFeatures)) }.set_payment_metadata_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn InvoiceFeatures_set_payment_metadata_required(this_arg: &mut crate::lightning::ln::features::InvoiceFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInvoiceFeatures)) }.set_payment_metadata_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn InvoiceFeatures_supports_payment_metadata(this_arg: &crate::lightning::ln::features::InvoiceFeatures) -> bool { + 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 InvoiceFeatures_requires_payment_metadata(this_arg: &crate::lightning::ln::features::InvoiceFeatures) -> 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) { diff --git a/lightning-c-bindings/src/lightning/ln/mod.rs b/lightning-c-bindings/src/lightning/ln/mod.rs index 879ce5e..9859403 100644 --- a/lightning-c-bindings/src/lightning/ln/mod.rs +++ b/lightning-c-bindings/src/lightning/ln/mod.rs @@ -6,19 +6,7 @@ // license as that which applies to the original source files from which this // source was automatically generated. -//! High level lightning structs and impls live here. -//! -//! You probably want to create a [`ChannelManager`], and a [`P2PGossipSync`] first. -//! Then, you probably want to pass them both on to a peer_handler::PeerManager and use that to -//! create/manage connections and call get_and_clear_pending_events after each action, handling -//! them appropriately. -//! -//! When you want to open/close a channel or send a payment, call into your [`ChannelManager`] and -//! when you want to learn things about the network topology (eg get a route for sending a payment), -//! call into your [`P2PGossipSync`]. -//! -//! [`ChannelManager`]: channelmanager::ChannelManager -//! [`P2PGossipSync`]: crate::routing::gossip::P2PGossipSync +//! Implementations of various parts of the Lightning protocol are in this module. use alloc::str::FromStr; use core::ffi::c_void; diff --git a/lightning-c-bindings/src/lightning/ln/msgs.rs b/lightning-c-bindings/src/lightning/ln/msgs.rs index 54269e6..02b5eba 100644 --- a/lightning-c-bindings/src/lightning/ln/msgs.rs +++ b/lightning-c-bindings/src/lightning/ln/msgs.rs @@ -245,7 +245,7 @@ pub extern "C" fn Init_set_features(this_ptr: &mut Init, mut val: crate::lightni #[no_mangle] pub extern "C" fn Init_get_remote_network_address(this_ptr: &Init) -> crate::c_types::derived::COption_NetAddressZ { let mut inner_val = &mut this_ptr.get_native_mut_ref().remote_network_address; - let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_NetAddressZ::None } else { crate::c_types::derived::COption_NetAddressZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option is otherwise un-expressable. */ { crate::lightning::ln::msgs::NetAddress::native_into(inner_val.clone().unwrap()) }) }; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_NetAddressZ::None } else { crate::c_types::derived::COption_NetAddressZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option is otherwise un-expressable. */ { crate::lightning::ln::msgs::NetAddress::native_into((*inner_val.as_ref().unwrap()).clone()) }) }; local_inner_val } /// The receipient's network address. @@ -256,14 +256,14 @@ pub extern "C" fn Init_get_remote_network_address(this_ptr: &Init) -> crate::c_t /// the new address. #[no_mangle] pub extern "C" fn Init_set_remote_network_address(this_ptr: &mut Init, mut val: crate::c_types::derived::COption_NetAddressZ) { - let mut local_val = { /* val*/ let val_opt = val; { } if val_opt.is_none() { None } else { Some({ val_opt.take().into_native() }) } }; + 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) }.remote_network_address = local_val; } /// Constructs a new Init given each field #[must_use] #[no_mangle] pub extern "C" fn Init_new(mut features_arg: crate::lightning::ln::features::InitFeatures, mut remote_network_address_arg: crate::c_types::derived::COption_NetAddressZ) -> Init { - 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() }) } }; + 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()) }, remote_network_address: local_remote_network_address_arg, @@ -3911,16 +3911,16 @@ pub extern "C" fn UnsignedNodeAnnouncement_set_rgb(this_ptr: &mut UnsignedNodeAn /// /// This should be sanitized before use. There is no guarantee of uniqueness. #[no_mangle] -pub extern "C" fn UnsignedNodeAnnouncement_get_alias(this_ptr: &UnsignedNodeAnnouncement) -> *const [u8; 32] { +pub extern "C" fn UnsignedNodeAnnouncement_get_alias(this_ptr: &UnsignedNodeAnnouncement) -> crate::lightning::routing::gossip::NodeAlias { let mut inner_val = &mut this_ptr.get_native_mut_ref().alias; - inner_val + 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 } } /// An alias, for UI purposes. /// /// This should be sanitized before use. There is no guarantee of uniqueness. #[no_mangle] -pub extern "C" fn UnsignedNodeAnnouncement_set_alias(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.alias = val.data; +pub extern "C" fn UnsignedNodeAnnouncement_set_alias(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::lightning::routing::gossip::NodeAlias) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.alias = *unsafe { Box::from_raw(val.take_inner()) }; } /// List of addresses on which this node is reachable /// @@ -5945,7 +5945,7 @@ pub struct ChannelMessageHandler { #[must_use] pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures, /// Implementation of MessageSendEventsProvider for this object. - pub MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider, + pub MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider, /// Frees any resources associated with this object given its this_arg pointer. /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. pub free: Option, @@ -5978,12 +5978,12 @@ pub(crate) extern "C" fn ChannelMessageHandler_clone_fields(orig: &ChannelMessag handle_error: Clone::clone(&orig.handle_error), provided_node_features: Clone::clone(&orig.provided_node_features), provided_init_features: Clone::clone(&orig.provided_init_features), - MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider_clone_fields(&orig.MessageSendEventsProvider), + MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider_clone_fields(&orig.MessageSendEventsProvider), free: Clone::clone(&orig.free), } } -impl lightning::util::events::MessageSendEventsProvider for ChannelMessageHandler { - fn get_and_clear_pending_msg_events(&self) -> Vec { +impl lightning::events::MessageSendEventsProvider for ChannelMessageHandler { + fn get_and_clear_pending_msg_events(&self) -> Vec { let mut ret = (self.MessageSendEventsProvider.get_and_clear_pending_msg_events)(self.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 @@ -6167,7 +6167,7 @@ pub struct RoutingMessageHandler { #[must_use] pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures, /// Implementation of MessageSendEventsProvider for this object. - pub MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider, + pub MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider, /// Frees any resources associated with this object given its this_arg pointer. /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. pub free: Option, @@ -6191,12 +6191,12 @@ pub(crate) extern "C" fn RoutingMessageHandler_clone_fields(orig: &RoutingMessag processing_queue_high: Clone::clone(&orig.processing_queue_high), provided_node_features: Clone::clone(&orig.provided_node_features), provided_init_features: Clone::clone(&orig.provided_init_features), - MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider_clone_fields(&orig.MessageSendEventsProvider), + MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider_clone_fields(&orig.MessageSendEventsProvider), free: Clone::clone(&orig.free), } } -impl lightning::util::events::MessageSendEventsProvider for RoutingMessageHandler { - fn get_and_clear_pending_msg_events(&self) -> Vec { +impl lightning::events::MessageSendEventsProvider for RoutingMessageHandler { + fn get_and_clear_pending_msg_events(&self) -> Vec { let mut ret = (self.MessageSendEventsProvider.get_and_clear_pending_msg_events)(self.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 @@ -6320,7 +6320,7 @@ pub struct OnionMessageHandler { #[must_use] pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures, /// Implementation of OnionMessageProvider for this object. - pub OnionMessageProvider: crate::lightning::util::events::OnionMessageProvider, + pub OnionMessageProvider: crate::lightning::events::OnionMessageProvider, /// Frees any resources associated with this object given its this_arg pointer. /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. pub free: Option, @@ -6336,11 +6336,11 @@ pub(crate) extern "C" fn OnionMessageHandler_clone_fields(orig: &OnionMessageHan peer_disconnected: Clone::clone(&orig.peer_disconnected), provided_node_features: Clone::clone(&orig.provided_node_features), provided_init_features: Clone::clone(&orig.provided_init_features), - OnionMessageProvider: crate::lightning::util::events::OnionMessageProvider_clone_fields(&orig.OnionMessageProvider), + OnionMessageProvider: crate::lightning::events::OnionMessageProvider_clone_fields(&orig.OnionMessageProvider), free: Clone::clone(&orig.free), } } -impl lightning::util::events::OnionMessageProvider for OnionMessageHandler { +impl lightning::events::OnionMessageProvider for OnionMessageHandler { fn next_onion_message_for_peer(&self, mut peer_node_id: bitcoin::secp256k1::PublicKey) -> Option { let mut ret = (self.OnionMessageProvider.next_onion_message_for_peer)(self.OnionMessageProvider.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()) } }) }; diff --git a/lightning-c-bindings/src/lightning/ln/outbound_payment.rs b/lightning-c-bindings/src/lightning/ln/outbound_payment.rs index e7f0ff2..004ba53 100644 --- a/lightning-c-bindings/src/lightning/ln/outbound_payment.rs +++ b/lightning-c-bindings/src/lightning/ln/outbound_payment.rs @@ -25,7 +25,7 @@ pub enum Retry { /// /// Each attempt may be multiple HTLCs along multiple paths if the router decides to split up a /// retry, and may retry multiple failed HTLCs at once if they failed around the same time and - /// were retried along a route from a single call to [`Router::find_route`]. + /// were retried along a route from a single call to [`Router::find_route_with_id`]. Attempts( usize), /// Time elapsed before abandoning retries for a payment. At least one attempt at payment is made; @@ -128,7 +128,7 @@ pub extern "C" fn Retry_timeout(a: u64) -> Retry { pub extern "C" fn Retry_eq(a: &Retry, b: &Retry) -> bool { if &a.to_native() == &b.to_native() { true } else { false } } -/// Checks if two Retrys contain equal inner contents. +/// Generates a non-cryptographic 64-bit hash of the Retry. #[no_mangle] pub extern "C" fn Retry_hash(o: &Retry) -> u64 { // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core @@ -137,12 +137,12 @@ pub extern "C" fn Retry_hash(o: &Retry) -> u64 { core::hash::Hash::hash(&o.to_native(), &mut hasher); core::hash::Hasher::finish(&hasher) } -/// Indicates an immediate error on [`ChannelManager::send_payment_with_retry`]. Further errors -/// may be surfaced later via [`Event::PaymentPathFailed`] and [`Event::PaymentFailed`]. +/// Indicates an immediate error on [`ChannelManager::send_payment`]. Further errors may be +/// surfaced later via [`Event::PaymentPathFailed`] and [`Event::PaymentFailed`]. /// -/// [`ChannelManager::send_payment_with_retry`]: crate::ln::channelmanager::ChannelManager::send_payment_with_retry -/// [`Event::PaymentPathFailed`]: crate::util::events::Event::PaymentPathFailed -/// [`Event::PaymentFailed`]: crate::util::events::Event::PaymentFailed +/// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment +/// [`Event::PaymentPathFailed`]: crate::events::Event::PaymentPathFailed +/// [`Event::PaymentFailed`]: crate::events::Event::PaymentFailed #[derive(Clone)] #[must_use] #[repr(C)] @@ -158,8 +158,8 @@ pub enum RetryableSendFailure { /// yet completed (i.e. generated an [`Event::PaymentSent`] or [`Event::PaymentFailed`]). /// /// [`PaymentId`]: crate::ln::channelmanager::PaymentId - /// [`Event::PaymentSent`]: crate::util::events::Event::PaymentSent - /// [`Event::PaymentFailed`]: crate::util::events::Event::PaymentFailed + /// [`Event::PaymentSent`]: crate::events::Event::PaymentSent + /// [`Event::PaymentFailed`]: crate::events::Event::PaymentFailed DuplicatePayment, } use lightning::ln::outbound_payment::RetryableSendFailure as RetryableSendFailureImport; @@ -216,11 +216,11 @@ 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} -/// If a payment fails to send with [`ChannelManager::send_payment`], it can be in one of several -/// states. This enum is returned as the Err() type describing which state the payment is in, see -/// the description of individual enum states for more. +/// If a payment fails to send with [`ChannelManager::send_payment_with_route`], it can be in one +/// of several states. This enum is returned as the Err() type describing which state the payment +/// is in, see the description of individual enum states for more. /// -/// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment +/// [`ChannelManager::send_payment_with_route`]: crate::ln::channelmanager::ChannelManager::send_payment_with_route #[derive(Clone)] #[must_use] #[repr(C)] @@ -233,8 +233,8 @@ pub enum PaymentSendFailure { /// Because the payment failed outright, no payment tracking is done and no /// [`Event::PaymentPathFailed`] or [`Event::PaymentFailed`] events will be generated. /// - /// [`Event::PaymentPathFailed`]: crate::util::events::Event::PaymentPathFailed - /// [`Event::PaymentFailed`]: crate::util::events::Event::PaymentFailed + /// [`Event::PaymentPathFailed`]: crate::events::Event::PaymentPathFailed + /// [`Event::PaymentFailed`]: crate::events::Event::PaymentFailed ParameterError( crate::lightning::util::errors::APIError), /// A parameter in a single path which was passed to send_payment was invalid, preventing us @@ -248,8 +248,8 @@ pub enum PaymentSendFailure { /// The results here are ordered the same as the paths in the route object which was passed to /// send_payment. /// - /// [`Event::PaymentPathFailed`]: crate::util::events::Event::PaymentPathFailed - /// [`Event::PaymentFailed`]: crate::util::events::Event::PaymentFailed + /// [`Event::PaymentPathFailed`]: crate::events::Event::PaymentPathFailed + /// [`Event::PaymentFailed`]: crate::events::Event::PaymentFailed PathParameterError( crate::c_types::derived::CVec_CResult_NoneAPIErrorZZ), /// All paths which were attempted failed to send, with no channel state change taking place. @@ -259,16 +259,16 @@ pub enum PaymentSendFailure { /// Because the payment failed outright, no payment tracking is done and no /// [`Event::PaymentPathFailed`] or [`Event::PaymentFailed`] events will be generated. /// - /// [`Event::PaymentPathFailed`]: crate::util::events::Event::PaymentPathFailed - /// [`Event::PaymentFailed`]: crate::util::events::Event::PaymentFailed + /// [`Event::PaymentPathFailed`]: crate::events::Event::PaymentPathFailed + /// [`Event::PaymentFailed`]: crate::events::Event::PaymentFailed AllFailedResendSafe( crate::c_types::derived::CVec_APIErrorZ), /// Indicates that a payment for the provided [`PaymentId`] is already in-flight and has not /// yet completed (i.e. generated an [`Event::PaymentSent`] or [`Event::PaymentFailed`]). /// /// [`PaymentId`]: crate::ln::channelmanager::PaymentId - /// [`Event::PaymentSent`]: crate::util::events::Event::PaymentSent - /// [`Event::PaymentFailed`]: crate::util::events::Event::PaymentFailed + /// [`Event::PaymentSent`]: crate::events::Event::PaymentSent + /// [`Event::PaymentFailed`]: crate::events::Event::PaymentFailed DuplicatePayment, /// Some paths that were attempted failed to send, though some paths may have succeeded. At least /// some paths have irrevocably committed to the HTLC. @@ -473,3 +473,208 @@ pub extern "C" fn PaymentSendFailure_partial_failure(results: crate::c_types::de payment_id, } } + +use lightning::ln::outbound_payment::RecipientOnionFields as nativeRecipientOnionFieldsImport; +pub(crate) type nativeRecipientOnionFields = nativeRecipientOnionFieldsImport; + +/// Information which is provided, encrypted, to the payment recipient when sending HTLCs. +/// +/// This should generally be constructed with data communicated to us from the recipient (via a +/// BOLT11 or BOLT12 invoice). +#[must_use] +#[repr(C)] +pub struct RecipientOnionFields { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, 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 nativeRecipientOnionFields, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust 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 RecipientOnionFields { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeRecipientOnionFields>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the RecipientOnionFields, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn RecipientOnionFields_free(this_obj: RecipientOnionFields) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn RecipientOnionFields_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeRecipientOnionFields) }; +} +#[allow(unused)] +impl RecipientOnionFields { + pub(crate) fn get_native_ref(&self) -> &'static nativeRecipientOnionFields { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeRecipientOnionFields { + 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 nativeRecipientOnionFields { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +/// The [`PaymentSecret`] is an arbitrary 32 bytes provided by the recipient for us to repeat +/// in the onion. It is unrelated to `payment_hash` (or [`PaymentPreimage`]) and exists to +/// authenticate the sender to the recipient and prevent payment-probing (deanonymization) +/// attacks. +/// +/// If you do not have one, the [`Route`] you pay over must not contain multiple paths as +/// multi-path payments require a recipient-provided secret. +/// +/// Note that for spontaneous payments most lightning nodes do not currently support MPP +/// receives, thus you should generally never be providing a secret here for spontaneous +/// payments. +/// +/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None +#[no_mangle] +pub extern "C" fn RecipientOnionFields_get_payment_secret(this_ptr: &RecipientOnionFields) -> crate::c_types::ThirtyTwoBytes { + let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_secret; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::ThirtyTwoBytes::null() } else { { crate::c_types::ThirtyTwoBytes { data: (inner_val.unwrap()).0 } } }; + local_inner_val +} +/// The [`PaymentSecret`] is an arbitrary 32 bytes provided by the recipient for us to repeat +/// in the onion. It is unrelated to `payment_hash` (or [`PaymentPreimage`]) and exists to +/// authenticate the sender to the recipient and prevent payment-probing (deanonymization) +/// attacks. +/// +/// If you do not have one, the [`Route`] you pay over must not contain multiple paths as +/// multi-path payments require a recipient-provided secret. +/// +/// Note that for spontaneous payments most lightning nodes do not currently support MPP +/// receives, thus you should generally never be providing a secret here for spontaneous +/// payments. +/// +/// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None +#[no_mangle] +pub extern "C" fn RecipientOnionFields_set_payment_secret(this_ptr: &mut RecipientOnionFields, mut val: crate::c_types::ThirtyTwoBytes) { + let mut local_val = if val.data == [0; 32] { None } else { Some( { ::lightning::ln::PaymentSecret(val.data) }) }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_secret = local_val; +} +/// The payment metadata serves a similar purpose as [`Self::payment_secret`] but is of +/// 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. +#[no_mangle] +pub extern "C" fn RecipientOnionFields_get_payment_metadata(this_ptr: &RecipientOnionFields) -> crate::c_types::derived::COption_CVec_u8ZZ { + let mut inner_val = this_ptr.get_native_mut_ref().payment_metadata.clone(); + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_CVec_u8ZZ::None } else { crate::c_types::derived::COption_CVec_u8ZZ::Some( { let mut local_inner_val_0 = Vec::new(); for mut item in inner_val.unwrap().drain(..) { local_inner_val_0.push( { item }); }; local_inner_val_0.into() }) }; + local_inner_val +} +/// 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. +#[no_mangle] +pub extern "C" fn RecipientOnionFields_set_payment_metadata(this_ptr: &mut RecipientOnionFields, mut val: crate::c_types::derived::COption_CVec_u8ZZ) { + let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { let mut local_val_0 = Vec::new(); for mut item in { val_opt.take() }.into_rust().drain(..) { local_val_0.push( { item }); }; local_val_0 }})} }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_metadata = local_val; +} +/// Constructs a new RecipientOnionFields given each field +#[must_use] +#[no_mangle] +pub extern "C" fn RecipientOnionFields_new(mut payment_secret_arg: crate::c_types::ThirtyTwoBytes, mut payment_metadata_arg: crate::c_types::derived::COption_CVec_u8ZZ) -> RecipientOnionFields { + let mut local_payment_secret_arg = if payment_secret_arg.data == [0; 32] { None } else { Some( { ::lightning::ln::PaymentSecret(payment_secret_arg.data) }) }; + let mut local_payment_metadata_arg = { /*payment_metadata_arg*/ let payment_metadata_arg_opt = payment_metadata_arg; if payment_metadata_arg_opt.is_none() { None } else { Some({ { let mut local_payment_metadata_arg_0 = Vec::new(); for mut item in { payment_metadata_arg_opt.take() }.into_rust().drain(..) { local_payment_metadata_arg_0.push( { item }); }; local_payment_metadata_arg_0 }})} }; + RecipientOnionFields { inner: ObjOps::heap_alloc(nativeRecipientOnionFields { + payment_secret: local_payment_secret_arg, + payment_metadata: local_payment_metadata_arg, + }), is_owned: true } +} +impl Clone for RecipientOnionFields { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeRecipientOnionFields>::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 RecipientOnionFields_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeRecipientOnionFields)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the RecipientOnionFields +pub extern "C" fn RecipientOnionFields_clone(orig: &RecipientOnionFields) -> RecipientOnionFields { + orig.clone() +} +/// 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. +#[no_mangle] +pub extern "C" fn RecipientOnionFields_eq(a: &RecipientOnionFields, b: &RecipientOnionFields) -> 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 RecipientOnionFields object into a byte array which can be read by RecipientOnionFields_read +pub extern "C" fn RecipientOnionFields_write(obj: &crate::lightning::ln::outbound_payment::RecipientOnionFields) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[no_mangle] +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) }) +} +#[no_mangle] +/// Read a RecipientOnionFields from a byte array, created by RecipientOnionFields_write +pub extern "C" fn RecipientOnionFields_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RecipientOnionFieldsDecodeErrorZ { + 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::outbound_payment::RecipientOnionFields { 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 [`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. +#[must_use] +#[no_mangle] +pub extern "C" fn RecipientOnionFields_secret_only(mut payment_secret: crate::c_types::ThirtyTwoBytes) -> crate::lightning::ln::outbound_payment::RecipientOnionFields { + let mut ret = lightning::ln::outbound_payment::RecipientOnionFields::secret_only(::lightning::ln::PaymentSecret(payment_secret.data)); + crate::lightning::ln::outbound_payment::RecipientOnionFields { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Creates a new [`RecipientOnionFields`] with no fields. This generally does not create +/// payable HTLCs except for spontaneous payments, i.e. this should generally only be used for +/// calls to [`ChannelManager::send_spontaneous_payment`]. +/// +/// [`ChannelManager::send_spontaneous_payment`]: super::channelmanager::ChannelManager::send_spontaneous_payment +#[must_use] +#[no_mangle] +pub extern "C" fn RecipientOnionFields_spontaneous_empty() -> crate::lightning::ln::outbound_payment::RecipientOnionFields { + let mut ret = lightning::ln::outbound_payment::RecipientOnionFields::spontaneous_empty(); + crate::lightning::ln::outbound_payment::RecipientOnionFields { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + diff --git a/lightning-c-bindings/src/lightning/ln/peer_handler.rs b/lightning-c-bindings/src/lightning/ln/peer_handler.rs index 74fa42f..0842280 100644 --- a/lightning-c-bindings/src/lightning/ln/peer_handler.rs +++ b/lightning-c-bindings/src/lightning/ln/peer_handler.rs @@ -67,7 +67,7 @@ impl lightning::ln::wire::CustomMessageReader for CustomMessageHandler { 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.CustomMessageReader.read)(self.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() })}; + 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 } } @@ -163,7 +163,7 @@ pub extern "C" fn IgnoringMessageHandler_new() -> IgnoringMessageHandler { IgnoringMessageHandler { inner: ObjOps::heap_alloc(nativeIgnoringMessageHandler { }), is_owned: true } } -impl From for crate::lightning::util::events::MessageSendEventsProvider { +impl From for crate::lightning::events::MessageSendEventsProvider { fn from(obj: nativeIgnoringMessageHandler) -> Self { let mut rust_obj = IgnoringMessageHandler { inner: ObjOps::heap_alloc(obj), is_owned: true }; let mut ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&rust_obj); @@ -176,8 +176,8 @@ impl From for crate::lightning::util::events::Mess /// 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 #[no_mangle] -pub extern "C" fn IgnoringMessageHandler_as_MessageSendEventsProvider(this_arg: &IgnoringMessageHandler) -> crate::lightning::util::events::MessageSendEventsProvider { - crate::lightning::util::events::MessageSendEventsProvider { +pub extern "C" fn IgnoringMessageHandler_as_MessageSendEventsProvider(this_arg: &IgnoringMessageHandler) -> crate::lightning::events::MessageSendEventsProvider { + crate::lightning::events::MessageSendEventsProvider { this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, free: None, get_and_clear_pending_msg_events: IgnoringMessageHandler_MessageSendEventsProvider_get_and_clear_pending_msg_events, @@ -186,8 +186,8 @@ pub extern "C" fn IgnoringMessageHandler_as_MessageSendEventsProvider(this_arg: #[must_use] extern "C" fn IgnoringMessageHandler_MessageSendEventsProvider_get_and_clear_pending_msg_events(this_arg: *const c_void) -> crate::c_types::derived::CVec_MessageSendEventZ { - let mut ret = >::get_and_clear_pending_msg_events(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, ); - let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::util::events::MessageSendEvent::native_into(item) }); }; + let mut ret = >::get_and_clear_pending_msg_events(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, ); + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::events::MessageSendEvent::native_into(item) }); }; local_ret.into() } @@ -221,7 +221,7 @@ pub extern "C" fn IgnoringMessageHandler_as_RoutingMessageHandler(this_arg: &Ign processing_queue_high: IgnoringMessageHandler_RoutingMessageHandler_processing_queue_high, provided_node_features: IgnoringMessageHandler_RoutingMessageHandler_provided_node_features, provided_init_features: IgnoringMessageHandler_RoutingMessageHandler_provided_init_features, - MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider { + MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider { this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, free: None, get_and_clear_pending_msg_events: IgnoringMessageHandler_MessageSendEventsProvider_get_and_clear_pending_msg_events, @@ -306,7 +306,7 @@ extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_provided_init_feature crate::lightning::ln::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } -impl From for crate::lightning::util::events::OnionMessageProvider { +impl From for crate::lightning::events::OnionMessageProvider { fn from(obj: nativeIgnoringMessageHandler) -> Self { let mut rust_obj = IgnoringMessageHandler { inner: ObjOps::heap_alloc(obj), is_owned: true }; let mut ret = IgnoringMessageHandler_as_OnionMessageProvider(&rust_obj); @@ -319,8 +319,8 @@ impl From for crate::lightning::util::events::Onio /// Constructs a new OnionMessageProvider which calls the relevant methods on this_arg. /// This copies the `inner` pointer in this_arg and thus the returned OnionMessageProvider must be freed before this_arg is #[no_mangle] -pub extern "C" fn IgnoringMessageHandler_as_OnionMessageProvider(this_arg: &IgnoringMessageHandler) -> crate::lightning::util::events::OnionMessageProvider { - crate::lightning::util::events::OnionMessageProvider { +pub extern "C" fn IgnoringMessageHandler_as_OnionMessageProvider(this_arg: &IgnoringMessageHandler) -> crate::lightning::events::OnionMessageProvider { + crate::lightning::events::OnionMessageProvider { this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, free: None, next_onion_message_for_peer: IgnoringMessageHandler_OnionMessageProvider_next_onion_message_for_peer, @@ -329,7 +329,7 @@ pub extern "C" fn IgnoringMessageHandler_as_OnionMessageProvider(this_arg: &Igno #[must_use] extern "C" fn IgnoringMessageHandler_OnionMessageProvider_next_onion_message_for_peer(this_arg: *const c_void, mut peer_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::msgs::OnionMessage { - let mut ret = >::next_onion_message_for_peer(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, peer_node_id.into_rust()); + let mut ret = >::next_onion_message_for_peer(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, peer_node_id.into_rust()); let mut local_ret = crate::lightning::ln::msgs::OnionMessage { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; local_ret } @@ -356,7 +356,7 @@ pub extern "C" fn IgnoringMessageHandler_as_OnionMessageHandler(this_arg: &Ignor peer_disconnected: IgnoringMessageHandler_OnionMessageHandler_peer_disconnected, provided_node_features: IgnoringMessageHandler_OnionMessageHandler_provided_node_features, provided_init_features: IgnoringMessageHandler_OnionMessageHandler_provided_init_features, - OnionMessageProvider: crate::lightning::util::events::OnionMessageProvider { + OnionMessageProvider: crate::lightning::events::OnionMessageProvider { this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, free: None, next_onion_message_for_peer: IgnoringMessageHandler_OnionMessageProvider_next_onion_message_for_peer, @@ -555,7 +555,7 @@ pub extern "C" fn ErroringMessageHandler_new() -> crate::lightning::ln::peer_han crate::lightning::ln::peer_handler::ErroringMessageHandler { inner: ObjOps::heap_alloc(ret), is_owned: true } } -impl From for crate::lightning::util::events::MessageSendEventsProvider { +impl From for crate::lightning::events::MessageSendEventsProvider { fn from(obj: nativeErroringMessageHandler) -> Self { let mut rust_obj = ErroringMessageHandler { inner: ObjOps::heap_alloc(obj), is_owned: true }; let mut ret = ErroringMessageHandler_as_MessageSendEventsProvider(&rust_obj); @@ -568,8 +568,8 @@ impl From for crate::lightning::util::events::Mess /// 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 #[no_mangle] -pub extern "C" fn ErroringMessageHandler_as_MessageSendEventsProvider(this_arg: &ErroringMessageHandler) -> crate::lightning::util::events::MessageSendEventsProvider { - crate::lightning::util::events::MessageSendEventsProvider { +pub extern "C" fn ErroringMessageHandler_as_MessageSendEventsProvider(this_arg: &ErroringMessageHandler) -> crate::lightning::events::MessageSendEventsProvider { + crate::lightning::events::MessageSendEventsProvider { this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, free: None, get_and_clear_pending_msg_events: ErroringMessageHandler_MessageSendEventsProvider_get_and_clear_pending_msg_events, @@ -578,8 +578,8 @@ pub extern "C" fn ErroringMessageHandler_as_MessageSendEventsProvider(this_arg: #[must_use] extern "C" fn ErroringMessageHandler_MessageSendEventsProvider_get_and_clear_pending_msg_events(this_arg: *const c_void) -> crate::c_types::derived::CVec_MessageSendEventZ { - let mut ret = >::get_and_clear_pending_msg_events(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, ); - let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::util::events::MessageSendEvent::native_into(item) }); }; + let mut ret = >::get_and_clear_pending_msg_events(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, ); + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::events::MessageSendEvent::native_into(item) }); }; local_ret.into() } @@ -622,7 +622,7 @@ pub extern "C" fn ErroringMessageHandler_as_ChannelMessageHandler(this_arg: &Err handle_error: ErroringMessageHandler_ChannelMessageHandler_handle_error, provided_node_features: ErroringMessageHandler_ChannelMessageHandler_provided_node_features, provided_init_features: ErroringMessageHandler_ChannelMessageHandler_provided_init_features, - MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider { + MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider { this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, free: None, get_and_clear_pending_msg_events: ErroringMessageHandler_MessageSendEventsProvider_get_and_clear_pending_msg_events, @@ -816,7 +816,7 @@ pub extern "C" fn MessageHandler_new(mut chan_handler_arg: crate::lightning::ln: /// to a remote host. You will need to be able to generate multiple of these which meet Eq and /// implement Hash to meet the PeerManager API. /// -/// For efficiency, Clone should be relatively cheap for this type. +/// For efficiency, [`Clone`] should be relatively cheap for this type. /// /// Two descriptors may compare equal (by [`cmp::Eq`] and [`hash::Hash`]) as long as the original /// has been disconnected, the [`PeerManager`] has been informed of the disconnection (either by it @@ -1025,10 +1025,10 @@ pub(crate) type nativePeerManager = nativePeerManagerImport crate::c_types::derived::CResult_CVec_u8ZPeerHandleErrorZ { - let mut local_remote_network_address = { /* remote_network_address*/ let remote_network_address_opt = remote_network_address; { } if remote_network_address_opt.is_none() { None } else { Some({ remote_network_address_opt.take().into_native() }) } }; + let mut local_remote_network_address = { /*remote_network_address*/ let remote_network_address_opt = remote_network_address; if remote_network_address_opt.is_none() { None } else { Some({ { { remote_network_address_opt.take() }.into_native() }})} }; let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.new_outbound_connection(their_node_id.into_rust(), descriptor, local_remote_network_address); 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::lightning::ln::peer_handler::PeerHandleError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; local_ret @@ -1147,13 +1148,13 @@ pub extern "C" fn PeerManager_new_outbound_connection(this_arg: &crate::lightnin /// the connection immediately. /// /// Panics if descriptor is duplicative with some other descriptor which has not yet been -/// [`socket_disconnected()`]. +/// [`socket_disconnected`]. /// -/// [`socket_disconnected()`]: PeerManager::socket_disconnected +/// [`socket_disconnected`]: PeerManager::socket_disconnected #[must_use] #[no_mangle] pub extern "C" fn PeerManager_new_inbound_connection(this_arg: &crate::lightning::ln::peer_handler::PeerManager, mut descriptor: crate::lightning::ln::peer_handler::SocketDescriptor, mut remote_network_address: crate::c_types::derived::COption_NetAddressZ) -> crate::c_types::derived::CResult_NonePeerHandleErrorZ { - let mut local_remote_network_address = { /* remote_network_address*/ let remote_network_address_opt = remote_network_address; { } if remote_network_address_opt.is_none() { None } else { Some({ remote_network_address_opt.take().into_native() }) } }; + let mut local_remote_network_address = { /*remote_network_address*/ let remote_network_address_opt = remote_network_address; if remote_network_address_opt.is_none() { None } else { Some({ { { remote_network_address_opt.take() }.into_native() }})} }; let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.new_inbound_connection(descriptor, local_remote_network_address); 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::peer_handler::PeerHandleError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; local_ret @@ -1166,7 +1167,7 @@ pub extern "C" fn PeerManager_new_inbound_connection(this_arg: &crate::lightning /// May call [`send_data`] on the descriptor passed in (or an equal descriptor) before /// returning. Thus, be very careful with reentrancy issues! The invariants around calling /// [`write_buffer_space_avail`] in case a write did not fully complete must still hold - be -/// ready to call `[write_buffer_space_avail`] again if a write call generated here isn't +/// ready to call [`write_buffer_space_avail`] again if a write call generated here isn't /// sufficient! /// /// [`send_data`]: SocketDescriptor::send_data diff --git a/lightning-c-bindings/src/lightning/ln/wire.rs b/lightning-c-bindings/src/lightning/ln/wire.rs index ac2efb1..849b981 100644 --- a/lightning-c-bindings/src/lightning/ln/wire.rs +++ b/lightning-c-bindings/src/lightning/ln/wire.rs @@ -52,7 +52,7 @@ impl rustCustomMessageReader for CustomMessageReader { 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.read)(self.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() })}; + 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 } } diff --git a/lightning-c-bindings/src/lightning/mod.rs b/lightning-c-bindings/src/lightning/mod.rs index dc497c5..20cee4b 100644 --- a/lightning-c-bindings/src/lightning/mod.rs +++ b/lightning-c-bindings/src/lightning/mod.rs @@ -46,107 +46,11 @@ use alloc::{vec::Vec, boxed::Box}; pub mod util; pub mod chain; pub mod ln; +pub mod offers; pub mod routing; pub mod onion_message; -mod offers { - -use alloc::str::FromStr; -use core::ffi::c_void; -use core::convert::Infallible; -use bitcoin::hashes::Hash; -use crate::c_types::*; -#[cfg(feature="no-std")] -use alloc::{vec::Vec, boxed::Box}; - -mod invoice { - -use alloc::str::FromStr; -use core::ffi::c_void; -use core::convert::Infallible; -use bitcoin::hashes::Hash; -use crate::c_types::*; -#[cfg(feature="no-std")] -use alloc::{vec::Vec, boxed::Box}; - -} -mod invoice_request { - -use alloc::str::FromStr; -use core::ffi::c_void; -use core::convert::Infallible; -use bitcoin::hashes::Hash; -use crate::c_types::*; -#[cfg(feature="no-std")] -use alloc::{vec::Vec, boxed::Box}; - -} -mod merkle { - -use alloc::str::FromStr; -use core::ffi::c_void; -use core::convert::Infallible; -use bitcoin::hashes::Hash; -use crate::c_types::*; -#[cfg(feature="no-std")] -use alloc::{vec::Vec, boxed::Box}; - -} -mod offer { - -use alloc::str::FromStr; -use core::ffi::c_void; -use core::convert::Infallible; -use bitcoin::hashes::Hash; -use crate::c_types::*; -#[cfg(feature="no-std")] -use alloc::{vec::Vec, boxed::Box}; - -} -mod parse { - -use alloc::str::FromStr; -use core::ffi::c_void; -use core::convert::Infallible; -use bitcoin::hashes::Hash; -use crate::c_types::*; -#[cfg(feature="no-std")] -use alloc::{vec::Vec, boxed::Box}; - -mod sealed { - -use alloc::str::FromStr; -use core::ffi::c_void; -use core::convert::Infallible; -use bitcoin::hashes::Hash; -use crate::c_types::*; -#[cfg(feature="no-std")] -use alloc::{vec::Vec, boxed::Box}; - -} -} -mod payer { - -use alloc::str::FromStr; -use core::ffi::c_void; -use core::convert::Infallible; -use bitcoin::hashes::Hash; -use crate::c_types::*; -#[cfg(feature="no-std")] -use alloc::{vec::Vec, boxed::Box}; - -} -mod refund { - -use alloc::str::FromStr; -use core::ffi::c_void; -use core::convert::Infallible; -use bitcoin::hashes::Hash; -use crate::c_types::*; -#[cfg(feature="no-std")] -use alloc::{vec::Vec, boxed::Box}; - -} -} +pub mod blinded_path; +pub mod events; mod io_extras { use alloc::str::FromStr; diff --git a/lightning-c-bindings/src/lightning/offers/invoice.rs b/lightning-c-bindings/src/lightning/offers/invoice.rs new file mode 100644 index 0000000..778d5b4 --- /dev/null +++ b/lightning-c-bindings/src/lightning/offers/invoice.rs @@ -0,0 +1,353 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//! Data structures and encoding for `invoice` messages. +//! +//! An [`Invoice`] can be built from a parsed [`InvoiceRequest`] for the \"offer to be paid\" flow or +//! from a [`Refund`] as an \"offer for money\" flow. The expected recipient of the payment then sends +//! the invoice to the intended payer, who will then pay it. +//! +//! 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. +//! +//! ``` +//! extern crate bitcoin; +//! extern crate lightning; +//! +//! use bitcoin::hashes::Hash; +//! use bitcoin::secp256k1::{KeyPair, PublicKey, Secp256k1, SecretKey}; +//! use core::convert::{Infallible, TryFrom}; +//! use lightning::offers::invoice_request::InvoiceRequest; +//! use lightning::offers::refund::Refund; +//! use lightning::util::ser::Writeable; +//! +//! # use lightning::ln::PaymentHash; +//! # use lightning::offers::invoice::BlindedPayInfo; +//! # use lightning::blinded_path::BlindedPath; +//! # +//! # fn create_payment_paths() -> Vec<(BlindedPath, BlindedPayInfo)> { unimplemented!() } +//! # fn create_payment_hash() -> PaymentHash { unimplemented!() } +//! # +//! # fn parse_invoice_request(bytes: Vec) -> Result<(), lightning::offers::parse::ParseError> { +//! 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 pubkey = PublicKey::from(keys); +//! let wpubkey_hash = bitcoin::util::key::PublicKey::new(pubkey).wpubkey_hash().unwrap(); +//! let mut buffer = Vec::new(); +//! +//! // Invoice for the \"offer to be paid\" flow. +//! InvoiceRequest::try_from(bytes)? +//! +//! .respond_with(payment_paths, payment_hash)? +//! +//! .relative_expiry(3600) +//! .allow_mpp() +//! .fallback_v0_p2wpkh(&wpubkey_hash) +//! .build()? +//! .sign::<_, Infallible>(|digest| Ok(secp_ctx.sign_schnorr_no_aux_rand(digest, &keys))) +//! .expect(\"failed verifying signature\") +//! .write(&mut buffer) +//! .unwrap(); +//! # Ok(()) +//! # } +//! +//! # fn parse_refund(bytes: Vec) -> Result<(), lightning::offers::parse::ParseError> { +//! # 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 pubkey = PublicKey::from(keys); +//! # let wpubkey_hash = bitcoin::util::key::PublicKey::new(pubkey).wpubkey_hash().unwrap(); +//! # let mut buffer = Vec::new(); +//! +//! // Invoice for the \"offer for money\" flow. +//! \"lnr1qcp4256ypq\" +//! .parse::()? +//! +//! .respond_with(payment_paths, payment_hash, pubkey)? +//! +//! .relative_expiry(3600) +//! .allow_mpp() +//! .fallback_v0_p2wpkh(&wpubkey_hash) +//! .build()? +//! .sign::<_, Infallible>(|digest| Ok(secp_ctx.sign_schnorr_no_aux_rand(digest, &keys))) +//! .expect(\"failed verifying signature\") +//! .write(&mut buffer) +//! .unwrap(); +//! # Ok(()) +//! # } +//! +//! ``` + +use alloc::str::FromStr; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + + +use lightning::offers::invoice::UnsignedInvoice as nativeUnsignedInvoiceImport; +pub(crate) type nativeUnsignedInvoice = nativeUnsignedInvoiceImport<'static>; + +/// A semantically valid [`Invoice`] that hasn't been signed. +#[must_use] +#[repr(C)] +pub struct UnsignedInvoice { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeUnsignedInvoice, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust 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 UnsignedInvoice { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeUnsignedInvoice>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the UnsignedInvoice, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn UnsignedInvoice_free(this_obj: UnsignedInvoice) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn UnsignedInvoice_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUnsignedInvoice) }; +} +#[allow(unused)] +impl UnsignedInvoice { + pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedInvoice { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedInvoice { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedInvoice { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +/// The public key corresponding to the key needed to sign the invoice. +#[must_use] +#[no_mangle] +pub extern "C" fn UnsignedInvoice_signing_pubkey(this_arg: &crate::lightning::offers::invoice::UnsignedInvoice) -> crate::c_types::PublicKey { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signing_pubkey(); + crate::c_types::PublicKey::from_rust(&ret) +} + + +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 *mut 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() +} +/// 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()) +} +#[no_mangle] +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) }) +} +#[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() }; + local_res +} diff --git a/lightning-c-bindings/src/lightning/offers/invoice_request.rs b/lightning-c-bindings/src/lightning/offers/invoice_request.rs new file mode 100644 index 0000000..fb0e322 --- /dev/null +++ b/lightning-c-bindings/src/lightning/offers/invoice_request.rs @@ -0,0 +1,266 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//! Data structures and encoding for `invoice_request` messages. +//! +//! An [`InvoiceRequest`] can be built from a parsed [`Offer`] as an \"offer to be paid\". It is +//! typically constructed by a customer and sent to the merchant who had published the corresponding +//! offer. The recipient of the request responds with an [`Invoice`]. +//! +//! For an \"offer for money\" (e.g., refund, ATM withdrawal), where an offer doesn't exist as a +//! precursor, see [`Refund`]. +//! +//! [`Invoice`]: crate::offers::invoice::Invoice +//! [`Refund`]: crate::offers::refund::Refund +//! +//! ``` +//! extern crate bitcoin; +//! extern crate lightning; +//! +//! use bitcoin::network::constants::Network; +//! use bitcoin::secp256k1::{KeyPair, PublicKey, Secp256k1, SecretKey}; +//! use core::convert::Infallible; +//! use lightning::ln::features::OfferFeatures; +//! use lightning::offers::offer::Offer; +//! use lightning::util::ser::Writeable; +//! +//! # fn parse() -> Result<(), lightning::offers::parse::ParseError> { +//! let secp_ctx = Secp256k1::new(); +//! let keys = KeyPair::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32])?); +//! let pubkey = PublicKey::from(keys); +//! let mut buffer = Vec::new(); +//! +//! \"lno1qcp4256ypq\" +//! .parse::()? +//! .request_invoice(vec![42; 64], pubkey)? +//! .chain(Network::Testnet)? +//! .amount_msats(1000)? +//! .quantity(5)? +//! .payer_note(\"foo\".to_string()) +//! .build()? +//! .sign::<_, Infallible>(|digest| Ok(secp_ctx.sign_schnorr_no_aux_rand(digest, &keys))) +//! .expect(\"failed verifying signature\") +//! .write(&mut buffer) +//! .unwrap(); +//! # Ok(()) +//! # } +//! ``` + +use alloc::str::FromStr; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + + +use lightning::offers::invoice_request::UnsignedInvoiceRequest as nativeUnsignedInvoiceRequestImport; +pub(crate) type nativeUnsignedInvoiceRequest = nativeUnsignedInvoiceRequestImport<'static>; + +/// A semantically valid [`InvoiceRequest`] that hasn't been signed. +#[must_use] +#[repr(C)] +pub struct UnsignedInvoiceRequest { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, 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 nativeUnsignedInvoiceRequest, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust 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 UnsignedInvoiceRequest { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeUnsignedInvoiceRequest>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the UnsignedInvoiceRequest, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn UnsignedInvoiceRequest_free(this_obj: UnsignedInvoiceRequest) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn UnsignedInvoiceRequest_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUnsignedInvoiceRequest) }; +} +#[allow(unused)] +impl UnsignedInvoiceRequest { + pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedInvoiceRequest { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedInvoiceRequest { + 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 nativeUnsignedInvoiceRequest { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} + +use lightning::offers::invoice_request::InvoiceRequest as nativeInvoiceRequestImport; +pub(crate) type nativeInvoiceRequest = nativeInvoiceRequestImport; + +/// An `InvoiceRequest` is a request for an [`Invoice`] formulated from an [`Offer`]. +/// +/// An offer may provide choices such as quantity, amount, chain, features, etc. An invoice request +/// specifies these such that its recipient can send an invoice for payment. +/// +/// [`Invoice`]: crate::offers::invoice::Invoice +/// [`Offer`]: crate::offers::offer::Offer +#[must_use] +#[repr(C)] +pub struct InvoiceRequest { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, 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 nativeInvoiceRequest, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust 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 InvoiceRequest { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeInvoiceRequest>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the InvoiceRequest, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn InvoiceRequest_free(this_obj: InvoiceRequest) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn InvoiceRequest_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeInvoiceRequest) }; +} +#[allow(unused)] +impl InvoiceRequest { + pub(crate) fn get_native_ref(&self) -> &'static nativeInvoiceRequest { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInvoiceRequest { + 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 nativeInvoiceRequest { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +impl Clone for InvoiceRequest { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeInvoiceRequest>::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 InvoiceRequest_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeInvoiceRequest)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the InvoiceRequest +pub extern "C" fn InvoiceRequest_clone(orig: &InvoiceRequest) -> InvoiceRequest { + orig.clone() +} +/// An unpredictable series of bytes, typically containing information about the derivation of +/// [`payer_id`]. +/// +/// [`payer_id`]: Self::payer_id +#[must_use] +#[no_mangle] +pub extern "C" fn InvoiceRequest_metadata(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::u8slice { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.metadata(); + let mut local_ret = crate::c_types::u8slice::from_slice(ret); + local_ret +} + +/// A chain from [`Offer::chains`] that the offer is valid for. +#[must_use] +#[no_mangle] +pub extern "C" fn InvoiceRequest_chain(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::ThirtyTwoBytes { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.chain(); + crate::c_types::ThirtyTwoBytes { data: ret.to_bytes() } +} + +/// 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] +#[no_mangle] +pub extern "C" fn InvoiceRequest_amount_msats(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::derived::COption_u64Z { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount_msats(); + let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { ret.unwrap() }) }; + local_ret +} + +/// Features pertaining to requesting an invoice. +#[must_use] +#[no_mangle] +pub extern "C" fn InvoiceRequest_features(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::lightning::ln::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 } +} + +/// The quantity of the offer's item conforming to [`Offer::is_valid_quantity`]. +#[must_use] +#[no_mangle] +pub extern "C" fn InvoiceRequest_quantity(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::derived::COption_u64Z { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.quantity(); + let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { ret.unwrap() }) }; + local_ret +} + +/// A possibly transient pubkey used to sign the invoice request. +#[must_use] +#[no_mangle] +pub extern "C" fn InvoiceRequest_payer_id(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::PublicKey { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_id(); + crate::c_types::PublicKey::from_rust(&ret) +} + +/// 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] +#[no_mangle] +pub extern "C" fn InvoiceRequest_payer_note(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::lightning::util::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 }; + local_ret +} + +#[no_mangle] +/// Serialize the InvoiceRequest object into a byte array which can be read by InvoiceRequest_read +pub extern "C" fn InvoiceRequest_write(obj: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[no_mangle] +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) }) +} diff --git a/lightning-c-bindings/src/lightning/offers/mod.rs b/lightning-c-bindings/src/lightning/offers/mod.rs new file mode 100644 index 0000000..41c8bef --- /dev/null +++ b/lightning-c-bindings/src/lightning/offers/mod.rs @@ -0,0 +1,59 @@ +// 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. + +//! Implementation of Lightning Offers +//! ([BOLT 12](https://github.com/lightning/bolts/blob/master/12-offer-encoding.md)). +//! +//! Offers are a flexible protocol for Lightning payments. + +use alloc::str::FromStr; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + +pub mod invoice; +pub mod invoice_request; +pub mod offer; +pub mod parse; +pub mod refund; +mod merkle { + +use alloc::str::FromStr; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + +} +mod payer { + +use alloc::str::FromStr; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + +} +mod signer { + +use alloc::str::FromStr; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + +} diff --git a/lightning-c-bindings/src/lightning/offers/offer.rs b/lightning-c-bindings/src/lightning/offers/offer.rs new file mode 100644 index 0000000..bef11fa --- /dev/null +++ b/lightning-c-bindings/src/lightning/offers/offer.rs @@ -0,0 +1,439 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//! Data structures and encoding for `offer` messages. +//! +//! An [`Offer`] represents an \"offer to be paid.\" It is typically constructed by a merchant and +//! published as a QR code to be scanned by a customer. The customer uses the offer to request an +//! invoice from the merchant to be paid. +//! +//! ``` +//! extern crate bitcoin; +//! extern crate core; +//! extern crate lightning; +//! +//! use core::convert::TryFrom; +//! use core::num::NonZeroU64; +//! use core::time::Duration; +//! +//! use bitcoin::secp256k1::{KeyPair, PublicKey, Secp256k1, SecretKey}; +//! use lightning::offers::offer::{Offer, OfferBuilder, Quantity}; +//! use lightning::offers::parse::ParseError; +//! use lightning::util::ser::{Readable, Writeable}; +//! +//! # use lightning::blinded_path::BlindedPath; +//! # #[cfg(feature = \"std\")] +//! # use std::time::SystemTime; +//! # +//! # fn create_blinded_path() -> BlindedPath { unimplemented!() } +//! # fn create_another_blinded_path() -> BlindedPath { unimplemented!() } +//! # +//! # #[cfg(feature = \"std\")] +//! # fn build() -> Result<(), ParseError> { +//! let secp_ctx = Secp256k1::new(); +//! 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); +//! let offer = OfferBuilder::new(\"coffee, large\".to_string(), pubkey) +//! .amount_msats(20_000) +//! .supported_quantity(Quantity::Unbounded) +//! .absolute_expiry(expiration.duration_since(SystemTime::UNIX_EPOCH).unwrap()) +//! .issuer(\"Foo Bar\".to_string()) +//! .path(create_blinded_path()) +//! .path(create_another_blinded_path()) +//! .build()?; +//! +//! // Encode as a bech32 string for use in a QR code. +//! let encoded_offer = offer.to_string(); +//! +//! // Parse from a bech32 string after scanning from a QR code. +//! let offer = encoded_offer.parse::()?; +//! +//! // Encode offer as raw bytes. +//! let mut bytes = Vec::new(); +//! offer.write(&mut bytes).unwrap(); +//! +//! // Decode raw bytes into an offer. +//! let offer = Offer::try_from(bytes)?; +//! # Ok(()) +//! # } +//! ``` + +use alloc::str::FromStr; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + + +use lightning::offers::offer::Offer as nativeOfferImport; +pub(crate) type nativeOffer = nativeOfferImport; + +/// An `Offer` is a potentially long-lived proposal for payment of a good or service. +/// +/// An offer is a precursor to an [`InvoiceRequest`]. A merchant publishes an offer from which a +/// customer may request an [`Invoice`] for a specific quantity and using an amount sufficient to +/// cover that quantity (i.e., at least `quantity * amount`). See [`Offer::amount`]. +/// +/// Offers may be denominated in currency other than bitcoin but are ultimately paid using the +/// latter. +/// +/// Through the use of [`BlindedPath`]s, offers provide recipient privacy. +/// +/// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest +/// [`Invoice`]: crate::offers::invoice::Invoice +#[must_use] +#[repr(C)] +pub struct Offer { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, 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 nativeOffer, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust 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 Offer { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeOffer>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the Offer, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn Offer_free(this_obj: Offer) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn Offer_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeOffer) }; +} +#[allow(unused)] +impl Offer { + pub(crate) fn get_native_ref(&self) -> &'static nativeOffer { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOffer { + 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 nativeOffer { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +impl Clone for Offer { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeOffer>::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 Offer_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeOffer)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the Offer +pub extern "C" fn Offer_clone(orig: &Offer) -> Offer { + orig.clone() +} +/// 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] +#[no_mangle] +pub extern "C" fn Offer_chains(this_arg: &crate::lightning::offers::offer::Offer) -> crate::c_types::derived::CVec_ChainHashZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.chains(); + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::c_types::ThirtyTwoBytes { data: item.to_bytes() } }); }; + local_ret.into() +} + +/// Returns whether the given chain is supported by the 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[..])); + ret +} + +/// 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`. +#[must_use] +#[no_mangle] +pub extern "C" fn Offer_metadata(this_arg: &crate::lightning::offers::offer::Offer) -> crate::c_types::derived::COption_CVec_u8ZZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.metadata(); + let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_CVec_u8ZZ::None } else { crate::c_types::derived::COption_CVec_u8ZZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option is otherwise un-expressable. */ { let mut local_ret_0 = Vec::new(); for mut item in (*ret.as_ref().unwrap()).clone().drain(..) { local_ret_0.push( { item }); }; local_ret_0.into() }) }; + local_ret +} + +/// The minimum amount required for a successful payment of a single item. +/// +/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None +#[must_use] +#[no_mangle] +pub extern "C" fn Offer_amount(this_arg: &crate::lightning::offers::offer::Offer) -> crate::lightning::offers::offer::Amount { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount(); + let mut local_ret = crate::lightning::offers::offer::Amount { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning::offers::offer::Amount<>) as *mut _ }, is_owned: false }; + local_ret +} + +/// A complete description of the purpose of the payment. Intended to be displayed to the user +/// but with the caveat that it has not been verified in any way. +#[must_use] +#[no_mangle] +pub extern "C" fn Offer_description(this_arg: &crate::lightning::offers::offer::Offer) -> crate::lightning::util::string::PrintableString { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.description(); + crate::lightning::util::string::PrintableString { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Features pertaining to the offer. +#[must_use] +#[no_mangle] +pub extern "C" fn Offer_features(this_arg: &crate::lightning::offers::offer::Offer) -> crate::lightning::ln::features::OfferFeatures { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.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 } +} + +/// Duration since the Unix epoch when an invoice should no longer be requested. +/// +/// If `None`, the offer does not expire. +#[must_use] +#[no_mangle] +pub extern "C" fn Offer_absolute_expiry(this_arg: &crate::lightning::offers::offer::Offer) -> crate::c_types::derived::COption_DurationZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.absolute_expiry(); + let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_DurationZ::None } else { crate::c_types::derived::COption_DurationZ::Some( { ret.unwrap().as_secs() }) }; + local_ret +} + +/// Whether the offer has expired. +#[must_use] +#[no_mangle] +pub extern "C" fn Offer_is_expired(this_arg: &crate::lightning::offers::offer::Offer) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.is_expired(); + ret +} + +/// 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] +#[no_mangle] +pub extern "C" fn Offer_issuer(this_arg: &crate::lightning::offers::offer::Offer) -> crate::lightning::util::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 }; + local_ret +} + +/// Paths to the recipient originating from publicly reachable nodes. Blinded paths provide +/// 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 { + 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 } }); }; + local_ret.into() +} + +/// The quantity of items supported. +#[must_use] +#[no_mangle] +pub extern "C" fn Offer_supported_quantity(this_arg: &crate::lightning::offers::offer::Offer) -> crate::lightning::offers::offer::Quantity { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supported_quantity(); + crate::lightning::offers::offer::Quantity { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Returns whether the given quantity is valid for the offer. +#[must_use] +#[no_mangle] +pub extern "C" fn Offer_is_valid_quantity(this_arg: &crate::lightning::offers::offer::Offer, mut quantity: u64) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.is_valid_quantity(quantity); + ret +} + +/// Returns whether a quantity is expected in an [`InvoiceRequest`] for the offer. +/// +/// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest +#[must_use] +#[no_mangle] +pub extern "C" fn Offer_expects_quantity(this_arg: &crate::lightning::offers::offer::Offer) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.expects_quantity(); + ret +} + +/// The public key used by the recipient to sign invoices. +#[must_use] +#[no_mangle] +pub extern "C" fn Offer_signing_pubkey(this_arg: &crate::lightning::offers::offer::Offer) -> crate::c_types::PublicKey { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signing_pubkey(); + crate::c_types::PublicKey::from_rust(&ret) +} + +#[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()) +} +#[no_mangle] +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) }) +} + +use lightning::offers::offer::Amount as nativeAmountImport; +pub(crate) type nativeAmount = nativeAmountImport; + +/// The minimum amount required for an item in an [`Offer`], denominated in either bitcoin or +/// another currency. +#[must_use] +#[repr(C)] +pub struct Amount { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, 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 nativeAmount, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust 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 Amount { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeAmount>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the Amount, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn Amount_free(this_obj: Amount) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn Amount_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeAmount) }; +} +#[allow(unused)] +impl Amount { + pub(crate) fn get_native_ref(&self) -> &'static nativeAmount { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeAmount { + 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 nativeAmount { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +impl Clone for Amount { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeAmount>::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 Amount_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeAmount)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the Amount +pub extern "C" fn Amount_clone(orig: &Amount) -> Amount { + orig.clone() +} + +use lightning::offers::offer::Quantity as nativeQuantityImport; +pub(crate) type nativeQuantity = nativeQuantityImport; + +/// Quantity of items supported by an [`Offer`]. +#[must_use] +#[repr(C)] +pub struct Quantity { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, 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 nativeQuantity, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust 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 Quantity { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeQuantity>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the Quantity, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn Quantity_free(this_obj: Quantity) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn Quantity_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeQuantity) }; +} +#[allow(unused)] +impl Quantity { + pub(crate) fn get_native_ref(&self) -> &'static nativeQuantity { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeQuantity { + 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 nativeQuantity { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +impl Clone for Quantity { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeQuantity>::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 Quantity_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeQuantity)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the Quantity +pub extern "C" fn Quantity_clone(orig: &Quantity) -> Quantity { + orig.clone() +} diff --git a/lightning-c-bindings/src/lightning/offers/parse.rs b/lightning-c-bindings/src/lightning/offers/parse.rs new file mode 100644 index 0000000..c1664e8 --- /dev/null +++ b/lightning-c-bindings/src/lightning/offers/parse.rs @@ -0,0 +1,29 @@ +// 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. + +//! Parsing and formatting for bech32 message encoding. + +use alloc::str::FromStr; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + +mod sealed { + +use alloc::str::FromStr; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + +} diff --git a/lightning-c-bindings/src/lightning/offers/refund.rs b/lightning-c-bindings/src/lightning/offers/refund.rs new file mode 100644 index 0000000..1e44848 --- /dev/null +++ b/lightning-c-bindings/src/lightning/offers/refund.rs @@ -0,0 +1,285 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//! Data structures and encoding for refunds. +//! +//! A [`Refund`] is an \"offer for money\" and is typically constructed by a merchant and presented +//! directly to the customer. The recipient responds with an [`Invoice`] to be paid. +//! +//! This is an [`InvoiceRequest`] produced *not* in response to an [`Offer`]. +//! +//! [`Invoice`]: crate::offers::invoice::Invoice +//! [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest +//! [`Offer`]: crate::offers::offer::Offer +//! +//! ``` +//! extern crate bitcoin; +//! extern crate core; +//! extern crate lightning; +//! +//! use core::convert::TryFrom; +//! use core::time::Duration; +//! +//! use bitcoin::network::constants::Network; +//! use bitcoin::secp256k1::{KeyPair, PublicKey, Secp256k1, SecretKey}; +//! use lightning::offers::parse::ParseError; +//! use lightning::offers::refund::{Refund, RefundBuilder}; +//! use lightning::util::ser::{Readable, Writeable}; +//! +//! # use lightning::blinded_path::BlindedPath; +//! # #[cfg(feature = \"std\")] +//! # use std::time::SystemTime; +//! # +//! # fn create_blinded_path() -> BlindedPath { unimplemented!() } +//! # fn create_another_blinded_path() -> BlindedPath { unimplemented!() } +//! # +//! # #[cfg(feature = \"std\")] +//! # fn build() -> Result<(), ParseError> { +//! let secp_ctx = Secp256k1::new(); +//! 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); +//! let refund = RefundBuilder::new(\"coffee, large\".to_string(), vec![1; 32], pubkey, 20_000)? +//! .absolute_expiry(expiration.duration_since(SystemTime::UNIX_EPOCH).unwrap()) +//! .issuer(\"Foo Bar\".to_string()) +//! .path(create_blinded_path()) +//! .path(create_another_blinded_path()) +//! .chain(Network::Bitcoin) +//! .payer_note(\"refund for order #12345\".to_string()) +//! .build()?; +//! +//! // Encode as a bech32 string for use in a QR code. +//! let encoded_refund = refund.to_string(); +//! +//! // Parse from a bech32 string after scanning from a QR code. +//! let refund = encoded_refund.parse::()?; +//! +//! // Encode refund as raw bytes. +//! let mut bytes = Vec::new(); +//! refund.write(&mut bytes).unwrap(); +//! +//! // Decode raw bytes into an refund. +//! let refund = Refund::try_from(bytes)?; +//! # Ok(()) +//! # } +//! ``` + +use alloc::str::FromStr; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + + +use lightning::offers::refund::Refund as nativeRefundImport; +pub(crate) type nativeRefund = nativeRefundImport; + +/// A `Refund` is a request to send an [`Invoice`] without a preceding [`Offer`]. +/// +/// Typically, after an invoice is paid, the recipient may publish a refund allowing the sender to +/// recoup their funds. A refund may be used more generally as an \"offer for money\", such as with a +/// bitcoin ATM. +/// +/// [`Invoice`]: crate::offers::invoice::Invoice +/// [`Offer`]: crate::offers::offer::Offer +#[must_use] +#[repr(C)] +pub struct Refund { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, 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 nativeRefund, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust 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 Refund { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeRefund>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the Refund, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn Refund_free(this_obj: Refund) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn Refund_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeRefund) }; +} +#[allow(unused)] +impl Refund { + pub(crate) fn get_native_ref(&self) -> &'static nativeRefund { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeRefund { + 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 nativeRefund { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +impl Clone for Refund { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeRefund>::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 Refund_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeRefund)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the Refund +pub extern "C" fn Refund_clone(orig: &Refund) -> Refund { + orig.clone() +} +/// 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] +#[no_mangle] +pub extern "C" fn Refund_description(this_arg: &crate::lightning::offers::refund::Refund) -> crate::lightning::util::string::PrintableString { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.description(); + crate::lightning::util::string::PrintableString { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Duration since the Unix epoch when an invoice should no longer be sent. +/// +/// If `None`, the refund does not expire. +#[must_use] +#[no_mangle] +pub extern "C" fn Refund_absolute_expiry(this_arg: &crate::lightning::offers::refund::Refund) -> crate::c_types::derived::COption_DurationZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.absolute_expiry(); + let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_DurationZ::None } else { crate::c_types::derived::COption_DurationZ::Some( { ret.unwrap().as_secs() }) }; + local_ret +} + +/// Whether the refund has expired. +#[must_use] +#[no_mangle] +pub extern "C" fn Refund_is_expired(this_arg: &crate::lightning::offers::refund::Refund) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.is_expired(); + ret +} + +/// 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] +#[no_mangle] +pub extern "C" fn Refund_issuer(this_arg: &crate::lightning::offers::refund::Refund) -> crate::lightning::util::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 }; + local_ret +} + +/// Paths to the sender originating from publicly reachable nodes. Blinded paths provide sender +/// 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 { + 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 } }); }; + local_ret.into() +} + +/// An unpredictable series of bytes, typically containing information about the derivation of +/// [`payer_id`]. +/// +/// [`payer_id`]: Self::payer_id +#[must_use] +#[no_mangle] +pub extern "C" fn Refund_metadata(this_arg: &crate::lightning::offers::refund::Refund) -> crate::c_types::u8slice { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.metadata(); + let mut local_ret = crate::c_types::u8slice::from_slice(ret); + local_ret +} + +/// A chain that the refund is valid for. +#[must_use] +#[no_mangle] +pub extern "C" fn Refund_chain(this_arg: &crate::lightning::offers::refund::Refund) -> crate::c_types::ThirtyTwoBytes { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.chain(); + crate::c_types::ThirtyTwoBytes { data: ret.to_bytes() } +} + +/// The amount to refund in msats (i.e., the minimum lightning-payable unit for [`chain`]). +/// +/// [`chain`]: Self::chain +#[must_use] +#[no_mangle] +pub extern "C" fn Refund_amount_msats(this_arg: &crate::lightning::offers::refund::Refund) -> u64 { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount_msats(); + ret +} + +/// 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 { + 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 } +} + +/// The quantity of an item that refund is for. +#[must_use] +#[no_mangle] +pub extern "C" fn Refund_quantity(this_arg: &crate::lightning::offers::refund::Refund) -> crate::c_types::derived::COption_u64Z { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.quantity(); + let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { ret.unwrap() }) }; + local_ret +} + +/// A public node id to send to in the case where there are no [`paths`]. Otherwise, a possibly +/// transient pubkey. +/// +/// [`paths`]: Self::paths +#[must_use] +#[no_mangle] +pub extern "C" fn Refund_payer_id(this_arg: &crate::lightning::offers::refund::Refund) -> crate::c_types::PublicKey { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_id(); + crate::c_types::PublicKey::from_rust(&ret) +} + +/// Payer provided note to include in the invoice. +/// +/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None +#[must_use] +#[no_mangle] +pub extern "C" fn Refund_payer_note(this_arg: &crate::lightning::offers::refund::Refund) -> crate::lightning::util::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 }; + local_ret +} + +#[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()) +} +#[no_mangle] +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) }) +} diff --git a/lightning-c-bindings/src/lightning/onion_message/messenger.rs b/lightning-c-bindings/src/lightning/onion_message/messenger.rs index fec6c76..1018d03 100644 --- a/lightning-c-bindings/src/lightning/onion_message/messenger.rs +++ b/lightning-c-bindings/src/lightning/onion_message/messenger.rs @@ -31,9 +31,9 @@ pub(crate) type nativeOnionMessenger = nativeOnionMessengerImport { let mut a_nonref = Clone::clone(a); Destination::BlindedPath ( - crate::lightning::onion_message::blinded_path::BlindedPath { inner: ObjOps::heap_alloc(a_nonref), is_owned: true }, + crate::lightning::blinded_path::BlindedPath { inner: ObjOps::heap_alloc(a_nonref), is_owned: true }, ) }, } @@ -214,7 +214,7 @@ impl Destination { }, nativeDestination::BlindedPath (mut a, ) => { Destination::BlindedPath ( - crate::lightning::onion_message::blinded_path::BlindedPath { inner: ObjOps::heap_alloc(a), is_owned: true }, + crate::lightning::blinded_path::BlindedPath { inner: ObjOps::heap_alloc(a), is_owned: true }, ) }, } @@ -235,7 +235,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::onion_message::blinded_path::BlindedPath) -> Destination { +pub extern "C" fn Destination_blinded_path(a: crate::lightning::blinded_path::BlindedPath) -> Destination { Destination::BlindedPath(a, ) } /// Errors that may occur when [sending an onion message]. @@ -437,7 +437,7 @@ impl rustCustomOnionMessageHandler for CustomOnionMessageHandler { } fn read_custom_message(&self, mut message_type: u64, mut buffer: &mut R) -> Result, lightning::ln::msgs::DecodeError> { let mut ret = (self.read_custom_message)(self.this_arg, message_type, crate::c_types::u8slice::from_vec(&crate::c_types::reader_to_vec(buffer))); - 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() })}; + 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 } } @@ -475,7 +475,7 @@ pub extern "C" fn OnionMessenger_new(mut entropy_source: crate::lightning::chain /// Note that reply_path (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn OnionMessenger_send_onion_message(this_arg: &crate::lightning::onion_message::messenger::OnionMessenger, mut intermediate_nodes: crate::c_types::derived::CVec_PublicKeyZ, mut destination: crate::lightning::onion_message::messenger::Destination, mut message: crate::lightning::onion_message::packet::OnionMessageContents, mut reply_path: crate::lightning::onion_message::blinded_path::BlindedPath) -> crate::c_types::derived::CResult_NoneSendErrorZ { +pub extern "C" fn OnionMessenger_send_onion_message(this_arg: &crate::lightning::onion_message::messenger::OnionMessenger, mut intermediate_nodes: crate::c_types::derived::CVec_PublicKeyZ, mut destination: crate::lightning::onion_message::messenger::Destination, mut message: crate::lightning::onion_message::packet::OnionMessageContents, mut reply_path: crate::lightning::blinded_path::BlindedPath) -> crate::c_types::derived::CResult_NoneSendErrorZ { let mut local_intermediate_nodes = Vec::new(); for mut item in intermediate_nodes.into_rust().drain(..) { local_intermediate_nodes.push( { item.into_rust() }); }; let mut local_reply_path = if reply_path.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(reply_path.take_inner()) } }) }; let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.send_onion_message(&local_intermediate_nodes[..], destination.into_native(), message.into_native(), local_reply_path); @@ -505,7 +505,7 @@ pub extern "C" fn OnionMessenger_as_OnionMessageHandler(this_arg: &OnionMessenge peer_disconnected: OnionMessenger_OnionMessageHandler_peer_disconnected, provided_node_features: OnionMessenger_OnionMessageHandler_provided_node_features, provided_init_features: OnionMessenger_OnionMessageHandler_provided_init_features, - OnionMessageProvider: crate::lightning::util::events::OnionMessageProvider { + OnionMessageProvider: crate::lightning::events::OnionMessageProvider { this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, free: None, next_onion_message_for_peer: OnionMessenger_OnionMessageProvider_next_onion_message_for_peer, @@ -536,7 +536,7 @@ extern "C" fn OnionMessenger_OnionMessageHandler_provided_init_features(this_arg crate::lightning::ln::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } -impl From for crate::lightning::util::events::OnionMessageProvider { +impl From for crate::lightning::events::OnionMessageProvider { fn from(obj: nativeOnionMessenger) -> Self { let mut rust_obj = OnionMessenger { inner: ObjOps::heap_alloc(obj), is_owned: true }; let mut ret = OnionMessenger_as_OnionMessageProvider(&rust_obj); @@ -549,8 +549,8 @@ impl From for crate::lightning::util::events::OnionMessage /// Constructs a new OnionMessageProvider which calls the relevant methods on this_arg. /// This copies the `inner` pointer in this_arg and thus the returned OnionMessageProvider must be freed before this_arg is #[no_mangle] -pub extern "C" fn OnionMessenger_as_OnionMessageProvider(this_arg: &OnionMessenger) -> crate::lightning::util::events::OnionMessageProvider { - crate::lightning::util::events::OnionMessageProvider { +pub extern "C" fn OnionMessenger_as_OnionMessageProvider(this_arg: &OnionMessenger) -> crate::lightning::events::OnionMessageProvider { + crate::lightning::events::OnionMessageProvider { this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, free: None, next_onion_message_for_peer: OnionMessenger_OnionMessageProvider_next_onion_message_for_peer, @@ -559,7 +559,7 @@ pub extern "C" fn OnionMessenger_as_OnionMessageProvider(this_arg: &OnionMesseng #[must_use] extern "C" fn OnionMessenger_OnionMessageProvider_next_onion_message_for_peer(this_arg: *const c_void, mut peer_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::msgs::OnionMessage { - let mut ret = >::next_onion_message_for_peer(unsafe { &mut *(this_arg as *mut nativeOnionMessenger) }, peer_node_id.into_rust()); + let mut ret = >::next_onion_message_for_peer(unsafe { &mut *(this_arg as *mut nativeOnionMessenger) }, peer_node_id.into_rust()); let mut local_ret = crate::lightning::ln::msgs::OnionMessage { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; local_ret } diff --git a/lightning-c-bindings/src/lightning/onion_message/mod.rs b/lightning-c-bindings/src/lightning/onion_message/mod.rs index 8df06b2..ad9bd5d 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::onion_message::BlindedPath +//! [blinded paths]: crate::blinded_path::BlindedPath use alloc::str::FromStr; use core::ffi::c_void; @@ -27,17 +27,5 @@ use crate::c_types::*; #[cfg(feature="no-std")] use alloc::{vec::Vec, boxed::Box}; -pub mod blinded_path; pub mod messenger; pub mod packet; -mod utils { - -use alloc::str::FromStr; -use core::ffi::c_void; -use core::convert::Infallible; -use bitcoin::hashes::Hash; -use crate::c_types::*; -#[cfg(feature="no-std")] -use alloc::{vec::Vec, boxed::Box}; - -} diff --git a/lightning-c-bindings/src/lightning/routing/gossip.rs b/lightning-c-bindings/src/lightning/routing/gossip.rs index 6284e6c..021fa0b 100644 --- a/lightning-c-bindings/src/lightning/routing/gossip.rs +++ b/lightning-c-bindings/src/lightning/routing/gossip.rs @@ -103,7 +103,16 @@ pub extern "C" fn NodeId_as_slice(this_arg: &crate::lightning::routing::gossip:: local_ret } -/// Checks if two NodeIds contain equal inner contents. +/// Get the public key from this NodeId +#[must_use] +#[no_mangle] +pub extern "C" fn NodeId_as_pubkey(this_arg: &crate::lightning::routing::gossip::NodeId) -> crate::c_types::derived::CResult_PublicKeyErrorZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.as_pubkey(); + 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( { crate::c_types::Secp256k1Error::from_rust(e) }).into() }; + local_ret +} + +/// Generates a non-cryptographic 64-bit hash of the NodeId. #[no_mangle] pub extern "C" fn NodeId_hash(o: &NodeId) -> u64 { if o.inner.is_null() { return 0; } @@ -246,7 +255,7 @@ pub enum NetworkUpdate { 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`]. + /// [`NetworkGraph::channel_failed_permanent`] if permanent. ChannelFailure { /// The short channel id of the closed channel. short_channel_id: u64, @@ -472,13 +481,13 @@ impl P2PGossipSync { } } /// Creates a new tracker of the actual state of the network of channels and nodes, -/// assuming an existing Network Graph. +/// 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] #[no_mangle] pub extern "C" fn P2PGossipSync_new(network_graph: &crate::lightning::routing::gossip::NetworkGraph, mut utxo_lookup: crate::c_types::derived::COption_UtxoLookupZ, mut logger: crate::lightning::util::logger::Logger) -> crate::lightning::routing::gossip::P2PGossipSync { - let mut local_utxo_lookup = { /* utxo_lookup*/ let utxo_lookup_opt = utxo_lookup; { } if utxo_lookup_opt.is_none() { None } else { Some({ utxo_lookup_opt.take() }) } }; + let mut local_utxo_lookup = { /*utxo_lookup*/ let utxo_lookup_opt = utxo_lookup; if utxo_lookup_opt.is_none() { None } else { Some({ { { utxo_lookup_opt.take() } }})} }; let mut ret = lightning::routing::gossip::P2PGossipSync::new(network_graph.get_native_ref(), local_utxo_lookup, logger); crate::lightning::routing::gossip::P2PGossipSync { inner: ObjOps::heap_alloc(ret), is_owned: true } } @@ -488,13 +497,13 @@ pub extern "C" fn P2PGossipSync_new(network_graph: &crate::lightning::routing::g /// Add, update or remove the provider would replace the current one. #[no_mangle] pub extern "C" fn P2PGossipSync_add_utxo_lookup(this_arg: &mut crate::lightning::routing::gossip::P2PGossipSync, mut utxo_lookup: crate::c_types::derived::COption_UtxoLookupZ) { - let mut local_utxo_lookup = { /* utxo_lookup*/ let utxo_lookup_opt = utxo_lookup; { } if utxo_lookup_opt.is_none() { None } else { Some({ utxo_lookup_opt.take() }) } }; + let mut local_utxo_lookup = { /*utxo_lookup*/ let utxo_lookup_opt = utxo_lookup; if utxo_lookup_opt.is_none() { None } else { Some({ { { utxo_lookup_opt.take() } }})} }; unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::routing::gossip::nativeP2PGossipSync)) }.add_utxo_lookup(local_utxo_lookup) } /// Handles any network updates originating from [`Event`]s. /// -/// [`Event`]: crate::util::events::Event +/// [`Event`]: crate::events::Event #[no_mangle] pub extern "C" fn NetworkGraph_handle_network_update(this_arg: &crate::lightning::routing::gossip::NetworkGraph, network_update: &crate::lightning::routing::gossip::NetworkUpdate) { unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.handle_network_update(&network_update.to_native()) @@ -530,7 +539,7 @@ pub extern "C" fn P2PGossipSync_as_RoutingMessageHandler(this_arg: &P2PGossipSyn processing_queue_high: P2PGossipSync_RoutingMessageHandler_processing_queue_high, provided_node_features: P2PGossipSync_RoutingMessageHandler_provided_node_features, provided_init_features: P2PGossipSync_RoutingMessageHandler_provided_init_features, - MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider { + MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider { this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, free: None, get_and_clear_pending_msg_events: P2PGossipSync_MessageSendEventsProvider_get_and_clear_pending_msg_events, @@ -615,7 +624,7 @@ extern "C" fn P2PGossipSync_RoutingMessageHandler_provided_init_features(this_ar crate::lightning::ln::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } -impl From for crate::lightning::util::events::MessageSendEventsProvider { +impl From for crate::lightning::events::MessageSendEventsProvider { fn from(obj: nativeP2PGossipSync) -> Self { let mut rust_obj = P2PGossipSync { inner: ObjOps::heap_alloc(obj), is_owned: true }; let mut ret = P2PGossipSync_as_MessageSendEventsProvider(&rust_obj); @@ -628,8 +637,8 @@ impl From for crate::lightning::util::events::MessageSendEv /// 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 #[no_mangle] -pub extern "C" fn P2PGossipSync_as_MessageSendEventsProvider(this_arg: &P2PGossipSync) -> crate::lightning::util::events::MessageSendEventsProvider { - crate::lightning::util::events::MessageSendEventsProvider { +pub extern "C" fn P2PGossipSync_as_MessageSendEventsProvider(this_arg: &P2PGossipSync) -> crate::lightning::events::MessageSendEventsProvider { + crate::lightning::events::MessageSendEventsProvider { this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, free: None, get_and_clear_pending_msg_events: P2PGossipSync_MessageSendEventsProvider_get_and_clear_pending_msg_events, @@ -638,8 +647,8 @@ pub extern "C" fn P2PGossipSync_as_MessageSendEventsProvider(this_arg: &P2PGossi #[must_use] extern "C" fn P2PGossipSync_MessageSendEventsProvider_get_and_clear_pending_msg_events(this_arg: *const c_void) -> crate::c_types::derived::CVec_MessageSendEventZ { - let mut ret = >::get_and_clear_pending_msg_events(unsafe { &mut *(this_arg as *mut nativeP2PGossipSync) }, ); - let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::util::events::MessageSendEvent::native_into(item) }); }; + let mut ret = >::get_and_clear_pending_msg_events(unsafe { &mut *(this_arg as *mut nativeP2PGossipSync) }, ); + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::events::MessageSendEvent::native_into(item) }); }; local_ret.into() } @@ -1455,7 +1464,7 @@ pub(crate) extern "C" fn RoutingFees_clone_void(this_ptr: *const c_void) -> *mut pub extern "C" fn RoutingFees_clone(orig: &RoutingFees) -> RoutingFees { orig.clone() } -/// Checks if two RoutingFeess contain equal inner contents. +/// 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; } @@ -1582,21 +1591,6 @@ pub extern "C" fn NodeAnnouncementInfo_get_alias(this_ptr: &NodeAnnouncementInfo pub extern "C" fn NodeAnnouncementInfo_set_alias(this_ptr: &mut NodeAnnouncementInfo, mut val: crate::lightning::routing::gossip::NodeAlias) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.alias = *unsafe { Box::from_raw(val.take_inner()) }; } -/// Internet-level addresses via which one can connect to the node -/// -/// Returns a copy of the field. -#[no_mangle] -pub extern "C" fn NodeAnnouncementInfo_get_addresses(this_ptr: &NodeAnnouncementInfo) -> crate::c_types::derived::CVec_NetAddressZ { - 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::NetAddress::native_into(item) }); }; - local_inner_val.into() -} -/// Internet-level addresses via which one can connect to the node -#[no_mangle] -pub extern "C" fn NodeAnnouncementInfo_set_addresses(this_ptr: &mut NodeAnnouncementInfo, mut val: crate::c_types::derived::CVec_NetAddressZ) { - 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; -} /// 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. @@ -1623,15 +1617,13 @@ pub extern "C" fn NodeAnnouncementInfo_set_announcement_message(this_ptr: &mut N /// Constructs a new NodeAnnouncementInfo 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 addresses_arg: crate::c_types::derived::CVec_NetAddressZ, mut announcement_message_arg: crate::lightning::ln::msgs::NodeAnnouncement) -> NodeAnnouncementInfo { - let mut local_addresses_arg = Vec::new(); for mut item in addresses_arg.into_rust().drain(..) { local_addresses_arg.push( { item.into_native() }); }; +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 { 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()) }, - addresses: local_addresses_arg, announcement_message: local_announcement_message_arg, }), is_owned: true } } @@ -1663,6 +1655,15 @@ pub extern "C" fn NodeAnnouncementInfo_eq(a: &NodeAnnouncementInfo, b: &NodeAnno if a.inner.is_null() || b.inner.is_null() { return false; } if a.get_native_ref() == b.get_native_ref() { true } else { false } } +/// 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_NetAddressZ { + 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::NetAddress::native_into(item) }); }; + local_ret.into() +} + #[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 { @@ -2023,7 +2024,7 @@ pub extern "C" fn NetworkGraph_update_node_from_unsigned_announcement(this_arg: #[must_use] #[no_mangle] pub extern "C" fn NetworkGraph_update_channel_from_announcement(this_arg: &crate::lightning::routing::gossip::NetworkGraph, msg: &crate::lightning::ln::msgs::ChannelAnnouncement, mut utxo_lookup: crate::c_types::derived::COption_UtxoLookupZ) -> crate::c_types::derived::CResult_NoneLightningErrorZ { - let mut local_utxo_lookup = { /* utxo_lookup*/ let utxo_lookup_opt = utxo_lookup; { } if utxo_lookup_opt.is_none() { None } else { Some({ utxo_lookup_opt.take() }) } }; + let mut local_utxo_lookup = { /*utxo_lookup*/ let utxo_lookup_opt = utxo_lookup; if utxo_lookup_opt.is_none() { None } else { Some({ { { utxo_lookup_opt.take() } }})} }; let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.update_channel_from_announcement(msg.get_native_ref(), &local_utxo_lookup); 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 @@ -2038,7 +2039,7 @@ pub extern "C" fn NetworkGraph_update_channel_from_announcement(this_arg: &crate #[must_use] #[no_mangle] pub extern "C" fn NetworkGraph_update_channel_from_unsigned_announcement(this_arg: &crate::lightning::routing::gossip::NetworkGraph, msg: &crate::lightning::ln::msgs::UnsignedChannelAnnouncement, mut utxo_lookup: crate::c_types::derived::COption_UtxoLookupZ) -> crate::c_types::derived::CResult_NoneLightningErrorZ { - let mut local_utxo_lookup = { /* utxo_lookup*/ let utxo_lookup_opt = utxo_lookup; { } if utxo_lookup_opt.is_none() { None } else { Some({ utxo_lookup_opt.take() }) } }; + let mut local_utxo_lookup = { /*utxo_lookup*/ let utxo_lookup_opt = utxo_lookup; if utxo_lookup_opt.is_none() { None } else { Some({ { { utxo_lookup_opt.take() } }})} }; let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.update_channel_from_unsigned_announcement(msg.get_native_ref(), &local_utxo_lookup); 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 @@ -2058,13 +2059,12 @@ pub extern "C" fn NetworkGraph_add_channel_from_partial_announcement(this_arg: & local_ret } -/// Marks a channel in the graph as failed if a corresponding HTLC fail was sent. -/// If permanent, removes a channel from the local storage. -/// May cause the removal of nodes too, if this was their last channel. -/// If not permanent, makes channels unavailable for routing. +/// 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. #[no_mangle] -pub extern "C" fn NetworkGraph_channel_failed(this_arg: &crate::lightning::routing::gossip::NetworkGraph, mut short_channel_id: u64, mut is_permanent: bool) { - unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.channel_failed(short_channel_id, is_permanent) +pub extern "C" fn NetworkGraph_channel_failed_permanent(this_arg: &crate::lightning::routing::gossip::NetworkGraph, mut short_channel_id: u64) { + unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.channel_failed_permanent(short_channel_id) } /// Marks a node in the graph as permanently failed, effectively removing it and its channels diff --git a/lightning-c-bindings/src/lightning/routing/router.rs b/lightning-c-bindings/src/lightning/routing/router.rs index cacfc22..2b7cc35 100644 --- a/lightning-c-bindings/src/lightning/routing/router.rs +++ b/lightning-c-bindings/src/lightning/routing/router.rs @@ -283,21 +283,17 @@ extern "C" fn ScorerAccountingForInFlightHtlcs_Score_channel_penalty_msat(this_a let mut ret = >::channel_penalty_msat(unsafe { &mut *(this_arg as *mut nativeScorerAccountingForInFlightHtlcs) }, short_channel_id, source.get_native_ref(), target.get_native_ref(), *unsafe { Box::from_raw(usage.take_inner()) }); ret } -extern "C" fn ScorerAccountingForInFlightHtlcs_Score_payment_path_failed(this_arg: *mut c_void, mut path: crate::c_types::derived::CVec_RouteHopZ, mut short_channel_id: u64) { - let mut local_path = Vec::new(); for mut item in path.as_slice().iter() { local_path.push( { item.get_native_ref() }); }; - >::payment_path_failed(unsafe { &mut *(this_arg as *mut nativeScorerAccountingForInFlightHtlcs) }, &local_path[..], short_channel_id) +extern "C" fn ScorerAccountingForInFlightHtlcs_Score_payment_path_failed(this_arg: *mut c_void, path: &crate::lightning::routing::router::Path, mut short_channel_id: u64) { + >::payment_path_failed(unsafe { &mut *(this_arg as *mut nativeScorerAccountingForInFlightHtlcs) }, path.get_native_ref(), short_channel_id) } -extern "C" fn ScorerAccountingForInFlightHtlcs_Score_payment_path_successful(this_arg: *mut c_void, mut path: crate::c_types::derived::CVec_RouteHopZ) { - let mut local_path = Vec::new(); for mut item in path.as_slice().iter() { local_path.push( { item.get_native_ref() }); }; - >::payment_path_successful(unsafe { &mut *(this_arg as *mut nativeScorerAccountingForInFlightHtlcs) }, &local_path[..]) +extern "C" fn ScorerAccountingForInFlightHtlcs_Score_payment_path_successful(this_arg: *mut c_void, path: &crate::lightning::routing::router::Path) { + >::payment_path_successful(unsafe { &mut *(this_arg as *mut nativeScorerAccountingForInFlightHtlcs) }, path.get_native_ref()) } -extern "C" fn ScorerAccountingForInFlightHtlcs_Score_probe_failed(this_arg: *mut c_void, mut path: crate::c_types::derived::CVec_RouteHopZ, mut short_channel_id: u64) { - let mut local_path = Vec::new(); for mut item in path.as_slice().iter() { local_path.push( { item.get_native_ref() }); }; - >::probe_failed(unsafe { &mut *(this_arg as *mut nativeScorerAccountingForInFlightHtlcs) }, &local_path[..], short_channel_id) +extern "C" fn ScorerAccountingForInFlightHtlcs_Score_probe_failed(this_arg: *mut c_void, path: &crate::lightning::routing::router::Path, mut short_channel_id: u64) { + >::probe_failed(unsafe { &mut *(this_arg as *mut nativeScorerAccountingForInFlightHtlcs) }, path.get_native_ref(), short_channel_id) } -extern "C" fn ScorerAccountingForInFlightHtlcs_Score_probe_successful(this_arg: *mut c_void, mut path: crate::c_types::derived::CVec_RouteHopZ) { - let mut local_path = Vec::new(); for mut item in path.as_slice().iter() { local_path.push( { item.get_native_ref() }); }; - >::probe_successful(unsafe { &mut *(this_arg as *mut nativeScorerAccountingForInFlightHtlcs) }, &local_path[..]) +extern "C" fn ScorerAccountingForInFlightHtlcs_Score_probe_successful(this_arg: *mut c_void, path: &crate::lightning::routing::router::Path) { + >::probe_successful(unsafe { &mut *(this_arg as *mut nativeScorerAccountingForInFlightHtlcs) }, path.get_native_ref()) } @@ -379,6 +375,12 @@ pub extern "C" fn InFlightHtlcs_new() -> crate::lightning::routing::router::InFl crate::lightning::routing::router::InFlightHtlcs { inner: ObjOps::heap_alloc(ret), is_owned: true } } +/// Takes in a path with payer's node id and adds the path's details to `InFlightHtlcs`. +#[no_mangle] +pub extern "C" fn InFlightHtlcs_process_path(this_arg: &mut crate::lightning::routing::router::InFlightHtlcs, path: &crate::lightning::routing::router::Path, mut payer_node_id: crate::c_types::PublicKey) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::routing::router::nativeInFlightHtlcs)) }.process_path(path.get_native_ref(), payer_node_id.into_rust()) +} + /// Returns liquidity in msat given the public key of the HTLC source, target, and short channel /// id. #[must_use] @@ -409,7 +411,8 @@ pub extern "C" fn InFlightHtlcs_read(ser: crate::c_types::u8slice) -> crate::c_t use lightning::routing::router::RouteHop as nativeRouteHopImport; pub(crate) type nativeRouteHop = nativeRouteHopImport; -/// A hop in a route +/// A hop in a route, and additional metadata about it. \"Hop\" is defined as a node and the channel +/// that leads to it. #[must_use] #[repr(C)] pub struct RouteHop { @@ -505,29 +508,43 @@ pub extern "C" fn RouteHop_set_channel_features(this_ptr: &mut RouteHop, mut val 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). -/// For the last hop, this should be the full value of the payment (might be more than -/// requested if we had to match htlc_minimum_msat). +/// 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 #[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; *inner_val } /// The fee taken on this hop (for paying for the use of the *next* channel in the path). -/// For the last hop, this should be the full value of the payment (might be more than -/// requested if we had to match htlc_minimum_msat). +/// 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 #[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. For the last hop, this should be the full CLTV value -/// expected at the destination, in excess of the current block height. +/// 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 #[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; *inner_val } -/// The CLTV delta added for this hop. For the last hop, this should be the full CLTV value -/// expected at the destination, in excess of the current block height. +/// 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 #[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; @@ -564,7 +581,7 @@ pub(crate) extern "C" fn RouteHop_clone_void(this_ptr: *const c_void) -> *mut c_ pub extern "C" fn RouteHop_clone(orig: &RouteHop) -> RouteHop { orig.clone() } -/// Checks if two RouteHops contain equal inner contents. +/// Generates a non-cryptographic 64-bit hash of the RouteHop. #[no_mangle] pub extern "C" fn RouteHop_hash(o: &RouteHop) -> u64 { if o.inner.is_null() { return 0; } @@ -600,6 +617,338 @@ pub extern "C" fn RouteHop_read(ser: crate::c_types::u8slice) -> crate::c_types: local_res } +use lightning::routing::router::BlindedTail as nativeBlindedTailImport; +pub(crate) type nativeBlindedTail = nativeBlindedTailImport; + +/// The blinded portion of a [`Path`], if we're routing to a recipient who provided blinded paths in +/// their BOLT12 [`Invoice`]. +/// +/// [`Invoice`]: crate::offers::invoice::Invoice +#[must_use] +#[repr(C)] +pub struct BlindedTail { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, 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 nativeBlindedTail, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust 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 BlindedTail { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeBlindedTail>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the BlindedTail, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn BlindedTail_free(this_obj: BlindedTail) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn BlindedTail_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeBlindedTail) }; +} +#[allow(unused)] +impl BlindedTail { + pub(crate) fn get_native_ref(&self) -> &'static nativeBlindedTail { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeBlindedTail { + 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 nativeBlindedTail { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +/// The hops of the [`BlindedPath`] provided by the recipient. +/// +/// [`BlindedPath`]: crate::blinded_path::BlindedPath +#[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 +#[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 +#[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 +#[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(); +} +/// Excess CLTV delta added to the recipient's CLTV expiry to deter intermediate nodes from +/// inferring the destination. May be 0. +#[no_mangle] +pub extern "C" fn BlindedTail_get_excess_final_cltv_expiry_delta(this_ptr: &BlindedTail) -> u32 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().excess_final_cltv_expiry_delta; + *inner_val +} +/// Excess CLTV delta added to the recipient's CLTV expiry to deter intermediate nodes from +/// inferring the destination. May be 0. +#[no_mangle] +pub extern "C" fn BlindedTail_set_excess_final_cltv_expiry_delta(this_ptr: &mut BlindedTail, mut val: u32) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.excess_final_cltv_expiry_delta = val; +} +/// The total amount paid on this [`Path`], excluding the fees. +#[no_mangle] +pub extern "C" fn BlindedTail_get_final_value_msat(this_ptr: &BlindedTail) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().final_value_msat; + *inner_val +} +/// The total amount paid on this [`Path`], excluding the fees. +#[no_mangle] +pub extern "C" fn BlindedTail_set_final_value_msat(this_ptr: &mut BlindedTail, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.final_value_msat = val; +} +/// Constructs a new BlindedTail given each field +#[must_use] +#[no_mangle] +pub extern "C" fn BlindedTail_new(mut hops_arg: crate::c_types::derived::CVec_BlindedHopZ, mut blinding_point_arg: crate::c_types::PublicKey, mut excess_final_cltv_expiry_delta_arg: u32, mut final_value_msat_arg: u64) -> BlindedTail { + let mut local_hops_arg = Vec::new(); for mut item in hops_arg.into_rust().drain(..) { local_hops_arg.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; + BlindedTail { inner: ObjOps::heap_alloc(nativeBlindedTail { + hops: local_hops_arg, + blinding_point: blinding_point_arg.into_rust(), + excess_final_cltv_expiry_delta: excess_final_cltv_expiry_delta_arg, + final_value_msat: final_value_msat_arg, + }), is_owned: true } +} +impl Clone for BlindedTail { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeBlindedTail>::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 BlindedTail_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeBlindedTail)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the BlindedTail +pub extern "C" fn BlindedTail_clone(orig: &BlindedTail) -> BlindedTail { + orig.clone() +} +/// Generates a non-cryptographic 64-bit hash of the BlindedTail. +#[no_mangle] +pub extern "C" fn BlindedTail_hash(o: &BlindedTail) -> 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 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. +#[no_mangle] +pub extern "C" fn BlindedTail_eq(a: &BlindedTail, b: &BlindedTail) -> 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 BlindedTail object into a byte array which can be read by BlindedTail_read +pub extern "C" fn BlindedTail_write(obj: &crate::lightning::routing::router::BlindedTail) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[no_mangle] +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) }) +} +#[no_mangle] +/// Read a BlindedTail from a byte array, created by BlindedTail_write +pub extern "C" fn BlindedTail_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_BlindedTailDecodeErrorZ { + 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::BlindedTail { 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::Path as nativePathImport; +pub(crate) type nativePath = nativePathImport; + +/// A path in a [`Route`] to the payment recipient. Must always be at least length one. +/// If no [`Path::blinded_tail`] is present, then [`Path::hops`] length may be up to 19. +#[must_use] +#[repr(C)] +pub struct Path { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativePath, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust 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 Path { + fn drop(&mut self) { + if self.is_owned && !<*mut nativePath>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the Path, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn Path_free(this_obj: Path) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn Path_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativePath) }; +} +#[allow(unused)] +impl Path { + pub(crate) fn get_native_ref(&self) -> &'static nativePath { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePath { + 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 nativePath { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +/// The list of unblinded hops in this [`Path`]. Must be at least length one. +#[no_mangle] +pub extern "C" fn Path_get_hops(this_ptr: &Path) -> crate::c_types::derived::CVec_RouteHopZ { + 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::routing::router::RouteHop { inner: unsafe { ObjOps::nonnull_ptr_to_inner((item as *const lightning::routing::router::RouteHop<>) as *mut _) }, is_owned: false } }); }; + local_inner_val.into() +} +/// The list of unblinded hops in this [`Path`]. Must be at least length one. +#[no_mangle] +pub extern "C" fn Path_set_hops(this_ptr: &mut Path, mut val: crate::c_types::derived::CVec_RouteHopZ) { + 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 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 +#[no_mangle] +pub extern "C" fn Path_get_blinded_tail(this_ptr: &Path) -> crate::lightning::routing::router::BlindedTail { + let mut inner_val = &mut this_ptr.get_native_mut_ref().blinded_tail; + let mut local_inner_val = crate::lightning::routing::router::BlindedTail { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::routing::router::BlindedTail<>) as *mut _ }, is_owned: false }; + local_inner_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 +#[no_mangle] +pub extern "C" fn Path_set_blinded_tail(this_ptr: &mut Path, mut val: crate::lightning::routing::router::BlindedTail) { + 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) }.blinded_tail = local_val; +} +/// Constructs a new Path given each field +#[must_use] +#[no_mangle] +pub extern "C" fn Path_new(mut hops_arg: crate::c_types::derived::CVec_RouteHopZ, mut blinded_tail_arg: crate::lightning::routing::router::BlindedTail) -> Path { + let mut local_hops_arg = Vec::new(); for mut item in hops_arg.into_rust().drain(..) { local_hops_arg.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; + let mut local_blinded_tail_arg = if blinded_tail_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(blinded_tail_arg.take_inner()) } }) }; + Path { inner: ObjOps::heap_alloc(nativePath { + hops: local_hops_arg, + blinded_tail: local_blinded_tail_arg, + }), is_owned: true } +} +impl Clone for Path { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativePath>::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 Path_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativePath)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the Path +pub extern "C" fn Path_clone(orig: &Path) -> Path { + orig.clone() +} +/// Generates a non-cryptographic 64-bit hash of the Path. +#[no_mangle] +pub extern "C" fn Path_hash(o: &Path) -> 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 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. +#[no_mangle] +pub extern "C" fn Path_eq(a: &Path, b: &Path) -> 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 } +} +/// Gets the fees for a given path, excluding any excess paid to the recipient. +#[must_use] +#[no_mangle] +pub extern "C" fn Path_fee_msat(this_arg: &crate::lightning::routing::router::Path) -> u64 { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.fee_msat(); + ret +} + +/// Gets the total amount paid on this [`Path`], excluding the fees. +#[must_use] +#[no_mangle] +pub extern "C" fn Path_final_value_msat(this_arg: &crate::lightning::routing::router::Path) -> u64 { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.final_value_msat(); + ret +} + +/// Gets the final hop's CLTV expiry delta. +#[must_use] +#[no_mangle] +pub extern "C" fn Path_final_cltv_expiry_delta(this_arg: &crate::lightning::routing::router::Path) -> crate::c_types::derived::COption_u32Z { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.final_cltv_expiry_delta(); + let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_u32Z::None } else { crate::c_types::derived::COption_u32Z::Some( { ret.unwrap() }) }; + local_ret +} + + use lightning::routing::router::Route as nativeRouteImport; pub(crate) type nativeRoute = nativeRouteImport; @@ -651,32 +1000,28 @@ impl Route { ret } } -/// The list of routes taken for a single (potentially-)multi-part payment. The pubkey of the -/// last RouteHop in each path must be the same. Each entry represents a list of hops, NOT -/// INCLUDING our own, where the last hop is the destination. Thus, this must always be at -/// least length one. While the maximum length of any given path is variable, keeping the length -/// of any path less or equal to 19 should currently ensure it is viable. +/// 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. #[no_mangle] -pub extern "C" fn Route_get_paths(this_ptr: &Route) -> crate::c_types::derived::CVec_CVec_RouteHopZZ { +pub extern "C" fn Route_get_paths(this_ptr: &Route) -> crate::c_types::derived::CVec_PathZ { let mut inner_val = &mut this_ptr.get_native_mut_ref().paths; - let mut local_inner_val = Vec::new(); for item in inner_val.iter() { local_inner_val.push( { let mut local_inner_val_0 = Vec::new(); for item in item.iter() { local_inner_val_0.push( { crate::lightning::routing::router::RouteHop { inner: unsafe { ObjOps::nonnull_ptr_to_inner((item as *const lightning::routing::router::RouteHop<>) as *mut _) }, is_owned: false } }); }; local_inner_val_0.into() }); }; + let mut local_inner_val = Vec::new(); for item in inner_val.iter() { local_inner_val.push( { crate::lightning::routing::router::Path { inner: unsafe { ObjOps::nonnull_ptr_to_inner((item as *const lightning::routing::router::Path<>) as *mut _) }, is_owned: false } }); }; local_inner_val.into() } -/// The list of routes taken for a single (potentially-)multi-part payment. The pubkey of the -/// last RouteHop in each path must be the same. Each entry represents a list of hops, NOT -/// INCLUDING our own, where the last hop is the destination. Thus, this must always be at -/// least length one. While the maximum length of any given path is variable, keeping the length -/// of any path less or equal to 19 should currently ensure it is viable. +/// 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. #[no_mangle] -pub extern "C" fn Route_set_paths(this_ptr: &mut Route, mut val: crate::c_types::derived::CVec_CVec_RouteHopZZ) { - let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { let mut local_val_0 = Vec::new(); for mut item in item.into_rust().drain(..) { local_val_0.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; local_val_0 }); }; +pub extern "C" fn Route_set_paths(this_ptr: &mut Route, mut val: crate::c_types::derived::CVec_PathZ) { + let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.paths = local_val; } /// The `payment_params` parameter passed to [`find_route`]. /// This is used by `ChannelManager` to track information which may be required for retries, /// provided back to you via [`Event::PaymentPathFailed`]. /// -/// [`Event::PaymentPathFailed`]: crate::util::events::Event::PaymentPathFailed +/// [`Event::PaymentPathFailed`]: crate::events::Event::PaymentPathFailed /// /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[no_mangle] @@ -689,7 +1034,7 @@ pub extern "C" fn Route_get_payment_params(this_ptr: &Route) -> crate::lightning /// This is used by `ChannelManager` to track information which may be required for retries, /// provided back to you via [`Event::PaymentPathFailed`]. /// -/// [`Event::PaymentPathFailed`]: crate::util::events::Event::PaymentPathFailed +/// [`Event::PaymentPathFailed`]: crate::events::Event::PaymentPathFailed /// /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None #[no_mangle] @@ -700,8 +1045,8 @@ pub extern "C" fn Route_set_payment_params(this_ptr: &mut Route, mut val: crate: /// Constructs a new Route given each field #[must_use] #[no_mangle] -pub extern "C" fn Route_new(mut paths_arg: crate::c_types::derived::CVec_CVec_RouteHopZZ, mut payment_params_arg: crate::lightning::routing::router::PaymentParameters) -> Route { - let mut local_paths_arg = Vec::new(); for mut item in paths_arg.into_rust().drain(..) { local_paths_arg.push( { let mut local_paths_arg_0 = Vec::new(); for mut item in item.into_rust().drain(..) { local_paths_arg_0.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; local_paths_arg_0 }); }; +pub extern "C" fn Route_new(mut paths_arg: crate::c_types::derived::CVec_PathZ, mut payment_params_arg: crate::lightning::routing::router::PaymentParameters) -> Route { + let mut local_paths_arg = Vec::new(); for mut item in paths_arg.into_rust().drain(..) { local_paths_arg.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; let mut local_payment_params_arg = if payment_params_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(payment_params_arg.take_inner()) } }) }; Route { inner: ObjOps::heap_alloc(nativeRoute { paths: local_paths_arg, @@ -727,7 +1072,7 @@ pub(crate) extern "C" fn Route_clone_void(this_ptr: *const c_void) -> *mut c_voi pub extern "C" fn Route_clone(orig: &Route) -> Route { orig.clone() } -/// Checks if two Routes contain equal inner contents. +/// Generates a non-cryptographic 64-bit hash of the Route. #[no_mangle] pub extern "C" fn Route_hash(o: &Route) -> u64 { if o.inner.is_null() { return 0; } @@ -757,7 +1102,8 @@ pub extern "C" fn Route_get_total_fees(this_arg: &crate::lightning::routing::rou ret } -/// Returns the total amount paid on this [`Route`], excluding the fees. +/// Returns the total amount paid on this [`Route`], excluding the fees. Might be more than +/// requested if we had to reach htlc_minimum_msat. #[must_use] #[no_mangle] pub extern "C" fn Route_get_total_amount(this_arg: &crate::lightning::routing::router::Route) -> u64 { @@ -790,7 +1136,7 @@ pub(crate) type nativeRouteParameters = nativeRouteParametersImport; /// Passed to [`find_route`] and [`build_route_from_hops`], but also provided in /// [`Event::PaymentPathFailed`]. /// -/// [`Event::PaymentPathFailed`]: crate::util::events::Event::PaymentPathFailed +/// [`Event::PaymentPathFailed`]: crate::events::Event::PaymentPathFailed #[must_use] #[repr(C)] pub struct RouteParameters { @@ -1011,16 +1357,14 @@ pub extern "C" fn PaymentParameters_set_features(this_ptr: &mut PaymentParameter } /// Hints for routing to the payee, containing channels connecting the payee to public nodes. #[no_mangle] -pub extern "C" fn PaymentParameters_get_route_hints(this_ptr: &PaymentParameters) -> crate::c_types::derived::CVec_RouteHintZ { +pub extern "C" fn PaymentParameters_get_route_hints(this_ptr: &PaymentParameters) -> crate::lightning::routing::router::Hints { let mut inner_val = &mut this_ptr.get_native_mut_ref().route_hints; - let mut local_inner_val = Vec::new(); for item in inner_val.iter() { local_inner_val.push( { crate::lightning::routing::router::RouteHint { inner: unsafe { ObjOps::nonnull_ptr_to_inner((item as *const lightning::routing::router::RouteHint<>) as *mut _) }, is_owned: false } }); }; - local_inner_val.into() + crate::lightning::routing::router::Hints::from_native(inner_val) } /// Hints for routing to the payee, containing channels connecting the payee to public nodes. #[no_mangle] -pub extern "C" fn PaymentParameters_set_route_hints(this_ptr: &mut PaymentParameters, mut val: crate::c_types::derived::CVec_RouteHintZ) { - 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) }.route_hints = local_val; +pub extern "C" fn PaymentParameters_set_route_hints(this_ptr: &mut PaymentParameters, mut val: crate::lightning::routing::router::Hints) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.route_hints = val.into_native(); } /// Expiration of a payment to the payee, in seconds relative to the UNIX epoch. #[no_mangle] @@ -1129,15 +1473,14 @@ pub extern "C" fn PaymentParameters_set_final_cltv_expiry_delta(this_ptr: &mut P /// Constructs a new PaymentParameters given each field #[must_use] #[no_mangle] -pub extern "C" fn PaymentParameters_new(mut payee_pubkey_arg: crate::c_types::PublicKey, mut features_arg: crate::lightning::ln::features::InvoiceFeatures, mut route_hints_arg: crate::c_types::derived::CVec_RouteHintZ, mut expiry_time_arg: crate::c_types::derived::COption_u64Z, mut max_total_cltv_expiry_delta_arg: u32, mut max_path_count_arg: u8, mut max_channel_saturation_power_of_half_arg: u8, mut previously_failed_channels_arg: crate::c_types::derived::CVec_u64Z, mut final_cltv_expiry_delta_arg: u32) -> PaymentParameters { +pub extern "C" fn PaymentParameters_new(mut payee_pubkey_arg: crate::c_types::PublicKey, mut features_arg: crate::lightning::ln::features::InvoiceFeatures, mut route_hints_arg: crate::lightning::routing::router::Hints, mut expiry_time_arg: crate::c_types::derived::COption_u64Z, mut max_total_cltv_expiry_delta_arg: u32, mut max_path_count_arg: u8, mut max_channel_saturation_power_of_half_arg: u8, mut previously_failed_channels_arg: crate::c_types::derived::CVec_u64Z, mut final_cltv_expiry_delta_arg: u32) -> PaymentParameters { let mut local_features_arg = if features_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(features_arg.take_inner()) } }) }; - let mut local_route_hints_arg = Vec::new(); for mut item in route_hints_arg.into_rust().drain(..) { local_route_hints_arg.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; let mut local_expiry_time_arg = if expiry_time_arg.is_some() { Some( { expiry_time_arg.take() }) } else { None }; let mut local_previously_failed_channels_arg = Vec::new(); for mut item in previously_failed_channels_arg.into_rust().drain(..) { local_previously_failed_channels_arg.push( { item }); }; PaymentParameters { inner: ObjOps::heap_alloc(nativePaymentParameters { payee_pubkey: payee_pubkey_arg.into_rust(), features: local_features_arg, - route_hints: local_route_hints_arg, + route_hints: route_hints_arg.into_native(), expiry_time: local_expiry_time_arg, max_total_cltv_expiry_delta: max_total_cltv_expiry_delta_arg, max_path_count: max_path_count_arg, @@ -1165,7 +1508,7 @@ pub(crate) extern "C" fn PaymentParameters_clone_void(this_ptr: *const c_void) - pub extern "C" fn PaymentParameters_clone(orig: &PaymentParameters) -> PaymentParameters { orig.clone() } -/// Checks if two PaymentParameterss contain equal inner contents. +/// Generates a non-cryptographic 64-bit hash of the PaymentParameters. #[no_mangle] pub extern "C" fn PaymentParameters_hash(o: &PaymentParameters) -> u64 { if o.inner.is_null() { return 0; } @@ -1223,6 +1566,129 @@ pub extern "C" fn PaymentParameters_for_keysend(mut payee_pubkey: crate::c_types crate::lightning::routing::router::PaymentParameters { inner: ObjOps::heap_alloc(ret), is_owned: true } } +/// Routing hints for the tail of the route. +#[derive(Clone)] +#[must_use] +#[repr(C)] +pub enum Hints { + /// The recipient provided blinded paths and payinfo to reach them. The blinded paths themselves + /// will be included in the final [`Route`]. + Blinded( + crate::c_types::derived::CVec_C2Tuple_BlindedPayInfoBlindedPathZZ), + /// The recipient included these route hints in their BOLT11 invoice. + Clear( + crate::c_types::derived::CVec_RouteHintZ), +} +use lightning::routing::router::Hints as HintsImport; +pub(crate) type nativeHints = HintsImport; + +impl Hints { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeHints { + match self { + Hints::Blinded (ref a, ) => { + let mut a_nonref = Clone::clone(a); + let mut local_a_nonref = Vec::new(); for mut item in a_nonref.into_rust().drain(..) { local_a_nonref.push( { let (mut orig_a_nonref_0_0, mut orig_a_nonref_0_1) = item.to_rust(); let mut local_a_nonref_0 = (*unsafe { Box::from_raw(orig_a_nonref_0_0.take_inner()) }, *unsafe { Box::from_raw(orig_a_nonref_0_1.take_inner()) }); local_a_nonref_0 }); }; + nativeHints::Blinded ( + local_a_nonref, + ) + }, + Hints::Clear (ref a, ) => { + let mut a_nonref = Clone::clone(a); + let mut local_a_nonref = Vec::new(); for mut item in a_nonref.into_rust().drain(..) { local_a_nonref.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; + nativeHints::Clear ( + local_a_nonref, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeHints { + match self { + Hints::Blinded (mut a, ) => { + let mut local_a = Vec::new(); for mut item in a.into_rust().drain(..) { local_a.push( { let (mut orig_a_0_0, mut orig_a_0_1) = item.to_rust(); let mut local_a_0 = (*unsafe { Box::from_raw(orig_a_0_0.take_inner()) }, *unsafe { Box::from_raw(orig_a_0_1.take_inner()) }); local_a_0 }); }; + nativeHints::Blinded ( + local_a, + ) + }, + Hints::Clear (mut a, ) => { + let mut local_a = Vec::new(); for mut item in a.into_rust().drain(..) { local_a.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; + nativeHints::Clear ( + local_a, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &nativeHints) -> Self { + match native { + nativeHints::Blinded (ref a, ) => { + let mut a_nonref = Clone::clone(a); + let mut local_a_nonref = Vec::new(); for mut item in a_nonref.drain(..) { local_a_nonref.push( { let (mut orig_a_nonref_0_0, mut orig_a_nonref_0_1) = item; let mut local_a_nonref_0 = (crate::lightning::offers::invoice::BlindedPayInfo { inner: ObjOps::heap_alloc(orig_a_nonref_0_0), is_owned: true }, crate::lightning::blinded_path::BlindedPath { inner: ObjOps::heap_alloc(orig_a_nonref_0_1), is_owned: true }).into(); local_a_nonref_0 }); }; + Hints::Blinded ( + local_a_nonref.into(), + ) + }, + nativeHints::Clear (ref a, ) => { + let mut a_nonref = Clone::clone(a); + let mut local_a_nonref = Vec::new(); for mut item in a_nonref.drain(..) { local_a_nonref.push( { crate::lightning::routing::router::RouteHint { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; + Hints::Clear ( + local_a_nonref.into(), + ) + }, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeHints) -> Self { + match native { + nativeHints::Blinded (mut a, ) => { + let mut local_a = Vec::new(); for mut item in a.drain(..) { local_a.push( { let (mut orig_a_0_0, mut orig_a_0_1) = item; let mut local_a_0 = (crate::lightning::offers::invoice::BlindedPayInfo { inner: ObjOps::heap_alloc(orig_a_0_0), is_owned: true }, crate::lightning::blinded_path::BlindedPath { inner: ObjOps::heap_alloc(orig_a_0_1), is_owned: true }).into(); local_a_0 }); }; + Hints::Blinded ( + local_a.into(), + ) + }, + nativeHints::Clear (mut a, ) => { + let mut local_a = Vec::new(); for mut item in a.drain(..) { local_a.push( { crate::lightning::routing::router::RouteHint { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; + Hints::Clear ( + local_a.into(), + ) + }, + } + } +} +/// Frees any resources used by the Hints +#[no_mangle] +pub extern "C" fn Hints_free(this_ptr: Hints) { } +/// Creates a copy of the Hints +#[no_mangle] +pub extern "C" fn Hints_clone(orig: &Hints) -> Hints { + orig.clone() +} +#[no_mangle] +/// Utility method to constructs a new Blinded-variant Hints +pub extern "C" fn Hints_blinded(a: crate::c_types::derived::CVec_C2Tuple_BlindedPayInfoBlindedPathZZ) -> Hints { + Hints::Blinded(a, ) +} +#[no_mangle] +/// Utility method to constructs a new Clear-variant Hints +pub extern "C" fn Hints_clear(a: crate::c_types::derived::CVec_RouteHintZ) -> Hints { + Hints::Clear(a, ) +} +/// Generates a non-cryptographic 64-bit hash of the Hints. +#[no_mangle] +pub extern "C" fn Hints_hash(o: &Hints) -> u64 { + // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core + #[allow(deprecated)] + let mut hasher = core::hash::SipHasher::new(); + core::hash::Hash::hash(&o.to_native(), &mut hasher); + core::hash::Hasher::finish(&hasher) +} +/// Checks if two Hintss contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +#[no_mangle] +pub extern "C" fn Hints_eq(a: &Hints, b: &Hints) -> bool { + if &a.to_native() == &b.to_native() { true } else { false } +} use lightning::routing::router::RouteHint as nativeRouteHintImport; pub(crate) type nativeRouteHint = nativeRouteHintImport; @@ -1313,7 +1779,7 @@ pub(crate) extern "C" fn RouteHint_clone_void(this_ptr: *const c_void) -> *mut c pub extern "C" fn RouteHint_clone(orig: &RouteHint) -> RouteHint { orig.clone() } -/// Checks if two RouteHints contain equal inner contents. +/// 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; } @@ -1503,7 +1969,7 @@ pub(crate) extern "C" fn RouteHintHop_clone_void(this_ptr: *const c_void) -> *mu pub extern "C" fn RouteHintHop_clone(orig: &RouteHintHop) -> RouteHintHop { orig.clone() } -/// Checks if two RouteHintHops contain equal inner contents. +/// 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; } @@ -1565,7 +2031,7 @@ pub extern "C" fn RouteHintHop_read(ser: crate::c_types::u8slice) -> crate::c_ty /// [`ChannelManager::list_usable_channels`] will never include such channels. /// /// [`ChannelManager::list_usable_channels`]: crate::ln::channelmanager::ChannelManager::list_usable_channels -/// [`Event::PaymentPathFailed`]: crate::util::events::Event::PaymentPathFailed +/// [`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 diff --git a/lightning-c-bindings/src/lightning/routing/scoring.rs b/lightning-c-bindings/src/lightning/routing/scoring.rs index 2c2980a..820a7b1 100644 --- a/lightning-c-bindings/src/lightning/routing/scoring.rs +++ b/lightning-c-bindings/src/lightning/routing/scoring.rs @@ -80,13 +80,13 @@ pub struct Score { #[must_use] pub channel_penalty_msat: extern "C" fn (this_arg: *const c_void, short_channel_id: u64, source: &crate::lightning::routing::gossip::NodeId, target: &crate::lightning::routing::gossip::NodeId, usage: crate::lightning::routing::scoring::ChannelUsage) -> u64, /// Handles updating channel penalties after failing to route through a channel. - pub payment_path_failed: extern "C" fn (this_arg: *mut c_void, path: crate::c_types::derived::CVec_RouteHopZ, short_channel_id: u64), + pub payment_path_failed: extern "C" fn (this_arg: *mut c_void, path: &crate::lightning::routing::router::Path, short_channel_id: u64), /// Handles updating channel penalties after successfully routing along a path. - pub payment_path_successful: extern "C" fn (this_arg: *mut c_void, path: crate::c_types::derived::CVec_RouteHopZ), + pub payment_path_successful: extern "C" fn (this_arg: *mut c_void, path: &crate::lightning::routing::router::Path), /// Handles updating channel penalties after a probe over the given path failed. - pub probe_failed: extern "C" fn (this_arg: *mut c_void, path: crate::c_types::derived::CVec_RouteHopZ, short_channel_id: u64), + pub probe_failed: extern "C" fn (this_arg: *mut c_void, path: &crate::lightning::routing::router::Path, short_channel_id: u64), /// Handles updating channel penalties after a probe over the given path succeeded. - pub probe_successful: extern "C" fn (this_arg: *mut c_void, path: crate::c_types::derived::CVec_RouteHopZ), + pub probe_successful: extern "C" fn (this_arg: *mut c_void, path: &crate::lightning::routing::router::Path), /// Serialize the object into a byte array pub write: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_u8Z, /// Frees any resources associated with this object given its this_arg pointer. @@ -121,21 +121,17 @@ impl rustScore for Score { let mut ret = (self.channel_penalty_msat)(self.this_arg, short_channel_id, &crate::lightning::routing::gossip::NodeId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((source as *const lightning::routing::gossip::NodeId<>) as *mut _) }, is_owned: false }, &crate::lightning::routing::gossip::NodeId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((target as *const lightning::routing::gossip::NodeId<>) as *mut _) }, is_owned: false }, crate::lightning::routing::scoring::ChannelUsage { inner: ObjOps::heap_alloc(usage), is_owned: true }); ret } - fn payment_path_failed(&mut self, mut path: &[&lightning::routing::router::RouteHop], mut short_channel_id: u64) { - let mut local_path = Vec::new(); for item in path.iter() { local_path.push( { crate::lightning::routing::router::RouteHop { inner: unsafe { ObjOps::nonnull_ptr_to_inner(((*item) as *const lightning::routing::router::RouteHop<>) as *mut _) }, is_owned: false } }); }; - (self.payment_path_failed)(self.this_arg, local_path.into(), short_channel_id) + fn payment_path_failed(&mut self, mut path: &lightning::routing::router::Path, mut short_channel_id: u64) { + (self.payment_path_failed)(self.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) } - fn payment_path_successful(&mut self, mut path: &[&lightning::routing::router::RouteHop]) { - let mut local_path = Vec::new(); for item in path.iter() { local_path.push( { crate::lightning::routing::router::RouteHop { inner: unsafe { ObjOps::nonnull_ptr_to_inner(((*item) as *const lightning::routing::router::RouteHop<>) as *mut _) }, is_owned: false } }); }; - (self.payment_path_successful)(self.this_arg, local_path.into()) + fn payment_path_successful(&mut self, mut path: &lightning::routing::router::Path) { + (self.payment_path_successful)(self.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 }) } - fn probe_failed(&mut self, mut path: &[&lightning::routing::router::RouteHop], mut short_channel_id: u64) { - let mut local_path = Vec::new(); for item in path.iter() { local_path.push( { crate::lightning::routing::router::RouteHop { inner: unsafe { ObjOps::nonnull_ptr_to_inner(((*item) as *const lightning::routing::router::RouteHop<>) as *mut _) }, is_owned: false } }); }; - (self.probe_failed)(self.this_arg, local_path.into(), short_channel_id) + fn probe_failed(&mut self, mut path: &lightning::routing::router::Path, mut short_channel_id: u64) { + (self.probe_failed)(self.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) } - fn probe_successful(&mut self, mut path: &[&lightning::routing::router::RouteHop]) { - let mut local_path = Vec::new(); for item in path.iter() { local_path.push( { crate::lightning::routing::router::RouteHop { inner: unsafe { ObjOps::nonnull_ptr_to_inner(((*item) as *const lightning::routing::router::RouteHop<>) as *mut _) }, is_owned: false } }); }; - (self.probe_successful)(self.this_arg, local_path.into()) + fn probe_successful(&mut self, mut path: &lightning::routing::router::Path) { + (self.probe_successful)(self.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 }) } } @@ -412,21 +408,17 @@ extern "C" fn MultiThreadedScoreLock_Score_channel_penalty_msat(this_arg: *const let mut ret = >::channel_penalty_msat(unsafe { &mut *(this_arg as *mut nativeMultiThreadedScoreLock) }, short_channel_id, source.get_native_ref(), target.get_native_ref(), *unsafe { Box::from_raw(usage.take_inner()) }); ret } -extern "C" fn MultiThreadedScoreLock_Score_payment_path_failed(this_arg: *mut c_void, mut path: crate::c_types::derived::CVec_RouteHopZ, mut short_channel_id: u64) { - let mut local_path = Vec::new(); for mut item in path.as_slice().iter() { local_path.push( { item.get_native_ref() }); }; - >::payment_path_failed(unsafe { &mut *(this_arg as *mut nativeMultiThreadedScoreLock) }, &local_path[..], short_channel_id) +extern "C" fn MultiThreadedScoreLock_Score_payment_path_failed(this_arg: *mut c_void, path: &crate::lightning::routing::router::Path, mut short_channel_id: u64) { + >::payment_path_failed(unsafe { &mut *(this_arg as *mut nativeMultiThreadedScoreLock) }, path.get_native_ref(), short_channel_id) } -extern "C" fn MultiThreadedScoreLock_Score_payment_path_successful(this_arg: *mut c_void, mut path: crate::c_types::derived::CVec_RouteHopZ) { - let mut local_path = Vec::new(); for mut item in path.as_slice().iter() { local_path.push( { item.get_native_ref() }); }; - >::payment_path_successful(unsafe { &mut *(this_arg as *mut nativeMultiThreadedScoreLock) }, &local_path[..]) +extern "C" fn MultiThreadedScoreLock_Score_payment_path_successful(this_arg: *mut c_void, path: &crate::lightning::routing::router::Path) { + >::payment_path_successful(unsafe { &mut *(this_arg as *mut nativeMultiThreadedScoreLock) }, path.get_native_ref()) } -extern "C" fn MultiThreadedScoreLock_Score_probe_failed(this_arg: *mut c_void, mut path: crate::c_types::derived::CVec_RouteHopZ, mut short_channel_id: u64) { - let mut local_path = Vec::new(); for mut item in path.as_slice().iter() { local_path.push( { item.get_native_ref() }); }; - >::probe_failed(unsafe { &mut *(this_arg as *mut nativeMultiThreadedScoreLock) }, &local_path[..], short_channel_id) +extern "C" fn MultiThreadedScoreLock_Score_probe_failed(this_arg: *mut c_void, path: &crate::lightning::routing::router::Path, mut short_channel_id: u64) { + >::probe_failed(unsafe { &mut *(this_arg as *mut nativeMultiThreadedScoreLock) }, path.get_native_ref(), short_channel_id) } -extern "C" fn MultiThreadedScoreLock_Score_probe_successful(this_arg: *mut c_void, mut path: crate::c_types::derived::CVec_RouteHopZ) { - let mut local_path = Vec::new(); for mut item in path.as_slice().iter() { local_path.push( { item.get_native_ref() }); }; - >::probe_successful(unsafe { &mut *(this_arg as *mut nativeMultiThreadedScoreLock) }, &local_path[..]) +extern "C" fn MultiThreadedScoreLock_Score_probe_successful(this_arg: *mut c_void, path: &crate::lightning::routing::router::Path) { + >::probe_successful(unsafe { &mut *(this_arg as *mut nativeMultiThreadedScoreLock) }, path.get_native_ref()) } #[no_mangle] @@ -733,21 +725,17 @@ extern "C" fn FixedPenaltyScorer_Score_channel_penalty_msat(this_arg: *const c_v let mut ret = >::channel_penalty_msat(unsafe { &mut *(this_arg as *mut nativeFixedPenaltyScorer) }, short_channel_id, source.get_native_ref(), target.get_native_ref(), *unsafe { Box::from_raw(usage.take_inner()) }); ret } -extern "C" fn FixedPenaltyScorer_Score_payment_path_failed(this_arg: *mut c_void, mut path: crate::c_types::derived::CVec_RouteHopZ, mut short_channel_id: u64) { - let mut local_path = Vec::new(); for mut item in path.as_slice().iter() { local_path.push( { item.get_native_ref() }); }; - >::payment_path_failed(unsafe { &mut *(this_arg as *mut nativeFixedPenaltyScorer) }, &local_path[..], short_channel_id) +extern "C" fn FixedPenaltyScorer_Score_payment_path_failed(this_arg: *mut c_void, path: &crate::lightning::routing::router::Path, mut short_channel_id: u64) { + >::payment_path_failed(unsafe { &mut *(this_arg as *mut nativeFixedPenaltyScorer) }, path.get_native_ref(), short_channel_id) } -extern "C" fn FixedPenaltyScorer_Score_payment_path_successful(this_arg: *mut c_void, mut path: crate::c_types::derived::CVec_RouteHopZ) { - let mut local_path = Vec::new(); for mut item in path.as_slice().iter() { local_path.push( { item.get_native_ref() }); }; - >::payment_path_successful(unsafe { &mut *(this_arg as *mut nativeFixedPenaltyScorer) }, &local_path[..]) +extern "C" fn FixedPenaltyScorer_Score_payment_path_successful(this_arg: *mut c_void, path: &crate::lightning::routing::router::Path) { + >::payment_path_successful(unsafe { &mut *(this_arg as *mut nativeFixedPenaltyScorer) }, path.get_native_ref()) } -extern "C" fn FixedPenaltyScorer_Score_probe_failed(this_arg: *mut c_void, mut path: crate::c_types::derived::CVec_RouteHopZ, mut short_channel_id: u64) { - let mut local_path = Vec::new(); for mut item in path.as_slice().iter() { local_path.push( { item.get_native_ref() }); }; - >::probe_failed(unsafe { &mut *(this_arg as *mut nativeFixedPenaltyScorer) }, &local_path[..], short_channel_id) +extern "C" fn FixedPenaltyScorer_Score_probe_failed(this_arg: *mut c_void, path: &crate::lightning::routing::router::Path, mut short_channel_id: u64) { + >::probe_failed(unsafe { &mut *(this_arg as *mut nativeFixedPenaltyScorer) }, path.get_native_ref(), short_channel_id) } -extern "C" fn FixedPenaltyScorer_Score_probe_successful(this_arg: *mut c_void, mut path: crate::c_types::derived::CVec_RouteHopZ) { - let mut local_path = Vec::new(); for mut item in path.as_slice().iter() { local_path.push( { item.get_native_ref() }); }; - >::probe_successful(unsafe { &mut *(this_arg as *mut nativeFixedPenaltyScorer) }, &local_path[..]) +extern "C" fn FixedPenaltyScorer_Score_probe_successful(this_arg: *mut c_void, path: &crate::lightning::routing::router::Path) { + >::probe_successful(unsafe { &mut *(this_arg as *mut nativeFixedPenaltyScorer) }, path.get_native_ref()) } #[no_mangle] @@ -1414,21 +1402,17 @@ extern "C" fn ProbabilisticScorer_Score_channel_penalty_msat(this_arg: *const c_ let mut ret = >::channel_penalty_msat(unsafe { &mut *(this_arg as *mut nativeProbabilisticScorer) }, short_channel_id, source.get_native_ref(), target.get_native_ref(), *unsafe { Box::from_raw(usage.take_inner()) }); ret } -extern "C" fn ProbabilisticScorer_Score_payment_path_failed(this_arg: *mut c_void, mut path: crate::c_types::derived::CVec_RouteHopZ, mut short_channel_id: u64) { - let mut local_path = Vec::new(); for mut item in path.as_slice().iter() { local_path.push( { item.get_native_ref() }); }; - >::payment_path_failed(unsafe { &mut *(this_arg as *mut nativeProbabilisticScorer) }, &local_path[..], short_channel_id) +extern "C" fn ProbabilisticScorer_Score_payment_path_failed(this_arg: *mut c_void, path: &crate::lightning::routing::router::Path, mut short_channel_id: u64) { + >::payment_path_failed(unsafe { &mut *(this_arg as *mut nativeProbabilisticScorer) }, path.get_native_ref(), short_channel_id) } -extern "C" fn ProbabilisticScorer_Score_payment_path_successful(this_arg: *mut c_void, mut path: crate::c_types::derived::CVec_RouteHopZ) { - let mut local_path = Vec::new(); for mut item in path.as_slice().iter() { local_path.push( { item.get_native_ref() }); }; - >::payment_path_successful(unsafe { &mut *(this_arg as *mut nativeProbabilisticScorer) }, &local_path[..]) +extern "C" fn ProbabilisticScorer_Score_payment_path_successful(this_arg: *mut c_void, path: &crate::lightning::routing::router::Path) { + >::payment_path_successful(unsafe { &mut *(this_arg as *mut nativeProbabilisticScorer) }, path.get_native_ref()) } -extern "C" fn ProbabilisticScorer_Score_probe_failed(this_arg: *mut c_void, mut path: crate::c_types::derived::CVec_RouteHopZ, mut short_channel_id: u64) { - let mut local_path = Vec::new(); for mut item in path.as_slice().iter() { local_path.push( { item.get_native_ref() }); }; - >::probe_failed(unsafe { &mut *(this_arg as *mut nativeProbabilisticScorer) }, &local_path[..], short_channel_id) +extern "C" fn ProbabilisticScorer_Score_probe_failed(this_arg: *mut c_void, path: &crate::lightning::routing::router::Path, mut short_channel_id: u64) { + >::probe_failed(unsafe { &mut *(this_arg as *mut nativeProbabilisticScorer) }, path.get_native_ref(), short_channel_id) } -extern "C" fn ProbabilisticScorer_Score_probe_successful(this_arg: *mut c_void, mut path: crate::c_types::derived::CVec_RouteHopZ) { - let mut local_path = Vec::new(); for mut item in path.as_slice().iter() { local_path.push( { item.get_native_ref() }); }; - >::probe_successful(unsafe { &mut *(this_arg as *mut nativeProbabilisticScorer) }, &local_path[..]) +extern "C" fn ProbabilisticScorer_Score_probe_successful(this_arg: *mut c_void, path: &crate::lightning::routing::router::Path) { + >::probe_successful(unsafe { &mut *(this_arg as *mut nativeProbabilisticScorer) }, path.get_native_ref()) } mod approx { diff --git a/lightning-c-bindings/src/lightning/util/config.rs b/lightning-c-bindings/src/lightning/util/config.rs index 1b93b9a..13e65a4 100644 --- a/lightning-c-bindings/src/lightning/util/config.rs +++ b/lightning-c-bindings/src/lightning/util/config.rs @@ -388,10 +388,41 @@ pub extern "C" fn ChannelHandshakeConfig_get_their_channel_reserve_proportional_ pub extern "C" fn ChannelHandshakeConfig_set_their_channel_reserve_proportional_millionths(this_ptr: &mut ChannelHandshakeConfig, mut val: u32) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.their_channel_reserve_proportional_millionths = val; } +/// The maximum number of HTLCs in-flight from our counterparty towards us at the same time. +/// +/// Increasing the value can help improve liquidity and stability in +/// routing at the cost of higher long term disk / DB usage. +/// +/// Note: Versions of LDK earlier than v0.0.115 will fail to read channels with a configuration +/// other than the default value. +/// +/// Default value: 50 +/// Maximum value: 483, any values larger will be treated as 483. +/// This is the BOLT #2 spec limit on `max_accepted_htlcs`. +#[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; + *inner_val +} +/// The maximum number of HTLCs in-flight from our counterparty towards us at the same time. +/// +/// Increasing the value can help improve liquidity and stability in +/// routing at the cost of higher long term disk / DB usage. +/// +/// Note: Versions of LDK earlier than v0.0.115 will fail to read channels with a configuration +/// other than the default value. +/// +/// Default value: 50 +/// Maximum value: 483, any values larger will be treated as 483. +/// This is the BOLT #2 spec limit on `max_accepted_htlcs`. +#[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; +} /// 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) -> ChannelHandshakeConfig { +pub extern "C" fn ChannelHandshakeConfig_new(mut minimum_depth_arg: u32, mut our_to_self_delay_arg: u16, mut our_htlc_minimum_msat_arg: u64, mut max_inbound_htlc_value_in_flight_percent_of_channel_arg: u8, mut negotiate_scid_privacy_arg: bool, mut announced_channel_arg: bool, mut commit_upfront_shutdown_pubkey_arg: bool, mut their_channel_reserve_proportional_millionths_arg: u32, mut 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, @@ -401,6 +432,7 @@ pub extern "C" fn ChannelHandshakeConfig_new(mut minimum_depth_arg: u32, mut our announced_channel: announced_channel_arg, commit_upfront_shutdown_pubkey: commit_upfront_shutdown_pubkey_arg, their_channel_reserve_proportional_millionths: their_channel_reserve_proportional_millionths_arg, + our_max_accepted_htlcs: our_max_accepted_htlcs_arg, }), is_owned: true } } impl Clone for ChannelHandshakeConfig { @@ -1217,7 +1249,7 @@ pub extern "C" fn UserConfig_set_accept_inbound_channels(this_ptr: &mut UserConf /// /// Default value: false. /// -/// [`Event::OpenChannelRequest`]: crate::util::events::Event::OpenChannelRequest +/// [`Event::OpenChannelRequest`]: crate::events::Event::OpenChannelRequest /// [`msgs::OpenChannel`]: crate::ln::msgs::OpenChannel /// [`msgs::AcceptChannel`]: crate::ln::msgs::AcceptChannel #[no_mangle] @@ -1235,7 +1267,7 @@ pub extern "C" fn UserConfig_get_manually_accept_inbound_channels(this_ptr: &Use /// /// Default value: false. /// -/// [`Event::OpenChannelRequest`]: crate::util::events::Event::OpenChannelRequest +/// [`Event::OpenChannelRequest`]: crate::events::Event::OpenChannelRequest /// [`msgs::OpenChannel`]: crate::ln::msgs::OpenChannel /// [`msgs::AcceptChannel`]: crate::ln::msgs::AcceptChannel #[no_mangle] @@ -1251,7 +1283,7 @@ pub extern "C" fn UserConfig_set_manually_accept_inbound_channels(this_ptr: &mut /// Default value: false. /// /// [`ChannelManager::get_intercept_scid`]: crate::ln::channelmanager::ChannelManager::get_intercept_scid -/// [`Event::HTLCIntercepted`]: crate::util::events::Event::HTLCIntercepted +/// [`Event::HTLCIntercepted`]: crate::events::Event::HTLCIntercepted #[no_mangle] pub extern "C" fn UserConfig_get_accept_intercept_htlcs(this_ptr: &UserConfig) -> bool { let mut inner_val = &mut this_ptr.get_native_mut_ref().accept_intercept_htlcs; @@ -1266,7 +1298,7 @@ pub extern "C" fn UserConfig_get_accept_intercept_htlcs(this_ptr: &UserConfig) - /// Default value: false. /// /// [`ChannelManager::get_intercept_scid`]: crate::ln::channelmanager::ChannelManager::get_intercept_scid -/// [`Event::HTLCIntercepted`]: crate::util::events::Event::HTLCIntercepted +/// [`Event::HTLCIntercepted`]: crate::events::Event::HTLCIntercepted #[no_mangle] 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; diff --git a/lightning-c-bindings/src/lightning/util/logger.rs b/lightning-c-bindings/src/lightning/util/logger.rs index 1e4051d..651255b 100644 --- a/lightning-c-bindings/src/lightning/util/logger.rs +++ b/lightning-c-bindings/src/lightning/util/logger.rs @@ -123,7 +123,7 @@ pub extern "C" fn Level_error() -> Level { pub extern "C" fn Level_eq(a: &Level, b: &Level) -> bool { if &a.to_native() == &b.to_native() { true } else { false } } -/// Checks if two Levels contain equal inner contents. +/// Generates a non-cryptographic 64-bit hash of the Level. #[no_mangle] pub extern "C" fn Level_hash(o: &Level) -> u64 { // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core diff --git a/lightning-c-bindings/src/lightning/util/mod.rs b/lightning-c-bindings/src/lightning/util/mod.rs index 7318fb1..47f5c1d 100644 --- a/lightning-c-bindings/src/lightning/util/mod.rs +++ b/lightning-c-bindings/src/lightning/util/mod.rs @@ -17,7 +17,6 @@ use crate::c_types::*; use alloc::{vec::Vec, boxed::Box}; pub mod ser_macros; -pub mod events; pub mod errors; pub mod ser; pub mod message_signing; diff --git a/lightning-c-bindings/src/lightning/util/string.rs b/lightning-c-bindings/src/lightning/util/string.rs index 34a70c8..2e4e495 100644 --- a/lightning-c-bindings/src/lightning/util/string.rs +++ b/lightning-c-bindings/src/lightning/util/string.rs @@ -17,6 +17,118 @@ use crate::c_types::*; 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 *mut 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() +} +/// 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 } +} +#[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()) +} +#[no_mangle] +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 +} + use lightning::util::string::PrintableString as nativePrintableStringImport; pub(crate) type nativePrintableString = nativePrintableStringImport<'static>; diff --git a/lightning-c-bindings/src/lightning/util/wakers.rs b/lightning-c-bindings/src/lightning/util/wakers.rs index 84a442e..59a096a 100644 --- a/lightning-c-bindings/src/lightning/util/wakers.rs +++ b/lightning-c-bindings/src/lightning/util/wakers.rs @@ -80,6 +80,8 @@ use lightning::util::wakers::Future as nativeFutureImport; pub(crate) type nativeFuture = nativeFutureImport; /// A simple future which can complete once, and calls some callback(s) when it does so. +/// +/// Clones can be made and all futures cloned from the same source will complete at the same time. #[must_use] #[repr(C)] pub struct Future { @@ -126,6 +128,25 @@ impl Future { ret } } +impl Clone for Future { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeFuture>::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 Future_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeFuture)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the Future +pub extern "C" fn Future_clone(orig: &Future) -> Future { + orig.clone() +} /// Registers a callback to be called upon completion of this future. If the future has already /// completed, the callback will be called immediately. #[no_mangle] @@ -133,3 +154,112 @@ pub extern "C" fn Future_register_callback_fn(this_arg: &crate::lightning::util: unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.register_callback_fn(callback) } +/// Waits until this [`Future`] completes. +#[no_mangle] +pub extern "C" fn Future_wait(mut this_arg: crate::lightning::util::wakers::Future) { + (*unsafe { Box::from_raw(this_arg.take_inner()) }).wait() +} + +/// Waits until this [`Future`] completes or the given amount of time has elapsed. +/// +/// Returns true if the [`Future`] completed, false if the time elapsed. +#[must_use] +#[no_mangle] +pub extern "C" fn Future_wait_timeout(mut this_arg: crate::lightning::util::wakers::Future, mut max_wait: u64) -> bool { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).wait_timeout(core::time::Duration::from_secs(max_wait)); + ret +} + + +use lightning::util::wakers::Sleeper as nativeSleeperImport; +pub(crate) type nativeSleeper = nativeSleeperImport; + +/// A struct which can be used to select across many [`Future`]s at once without relying on a full +/// async context. +#[must_use] +#[repr(C)] +pub struct Sleeper { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, 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 nativeSleeper, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust 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 Sleeper { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeSleeper>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the Sleeper, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn Sleeper_free(this_obj: Sleeper) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn Sleeper_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeSleeper) }; +} +#[allow(unused)] +impl Sleeper { + pub(crate) fn get_native_ref(&self) -> &'static nativeSleeper { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeSleeper { + 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 nativeSleeper { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +/// Constructs a new sleeper from one future, allowing blocking on it. +#[must_use] +#[no_mangle] +pub extern "C" fn Sleeper_from_single_future(mut future: crate::lightning::util::wakers::Future) -> crate::lightning::util::wakers::Sleeper { + let mut ret = lightning::util::wakers::Sleeper::from_single_future(*unsafe { Box::from_raw(future.take_inner()) }); + crate::lightning::util::wakers::Sleeper { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Constructs a new sleeper from two futures, allowing blocking on both at once. +#[must_use] +#[no_mangle] +pub extern "C" fn Sleeper_from_two_futures(mut fut_a: crate::lightning::util::wakers::Future, mut fut_b: crate::lightning::util::wakers::Future) -> crate::lightning::util::wakers::Sleeper { + let mut ret = lightning::util::wakers::Sleeper::from_two_futures(*unsafe { Box::from_raw(fut_a.take_inner()) }, *unsafe { Box::from_raw(fut_b.take_inner()) }); + 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] +pub extern "C" fn Sleeper_new(mut futures: crate::c_types::derived::CVec_FutureZ) -> crate::lightning::util::wakers::Sleeper { + let mut local_futures = Vec::new(); for mut item in futures.into_rust().drain(..) { local_futures.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; + let mut ret = lightning::util::wakers::Sleeper::new(local_futures); + crate::lightning::util::wakers::Sleeper { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Wait until one of the [`Future`]s registered with this [`Sleeper`] has completed. +#[no_mangle] +pub extern "C" fn Sleeper_wait(this_arg: &crate::lightning::util::wakers::Sleeper) { + unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.wait() +} + +/// Wait until one of the [`Future`]s registered with this [`Sleeper`] has completed or the +/// given amount of time has elapsed. Returns true if a [`Future`] completed, false if the time +/// elapsed. +#[must_use] +#[no_mangle] +pub extern "C" fn Sleeper_wait_timeout(this_arg: &crate::lightning::util::wakers::Sleeper, mut max_wait: u64) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.wait_timeout(core::time::Duration::from_secs(max_wait)); + ret +} + diff --git a/lightning-c-bindings/src/lightning_background_processor.rs b/lightning-c-bindings/src/lightning_background_processor.rs index bee829f..4b8360b 100644 --- a/lightning-c-bindings/src/lightning_background_processor.rs +++ b/lightning-c-bindings/src/lightning_background_processor.rs @@ -29,8 +29,8 @@ pub(crate) type nativeBackgroundProcessor = nativeBackgroundProcessorImport; /// * Monitoring whether the [`ChannelManager`] needs to be re-persisted to disk, and if so, /// writing it to disk/backups by invoking the callback given to it at startup. /// [`ChannelManager`] persistence should be done in the background. -/// * Calling [`ChannelManager::timer_tick_occurred`] and [`PeerManager::timer_tick_occurred`] -/// at the appropriate intervals. +/// * Calling [`ChannelManager::timer_tick_occurred`], [`ChainMonitor::rebroadcast_pending_claims`] +/// and [`PeerManager::timer_tick_occurred`] at the appropriate intervals. /// * Calling [`NetworkGraph::remove_stale_channels_and_tracking`] (if a [`GossipSync`] with a /// [`NetworkGraph`] is provided to [`BackgroundProcessor::start`]). /// @@ -45,7 +45,7 @@ pub(crate) type nativeBackgroundProcessor = nativeBackgroundProcessorImport; /// unilateral chain closure fees are at risk. /// /// [`ChannelMonitor`]: lightning::chain::channelmonitor::ChannelMonitor -/// [`Event`]: lightning::util::events::Event +/// [`Event`]: lightning::events::Event ///BackgroundProcessor will immediately stop on drop. It should be stored until shutdown. #[must_use] #[repr(C)] @@ -208,8 +208,8 @@ 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::util::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 { - let mut local_scorer = { /* scorer*/ let scorer_opt = scorer; { } if scorer_opt.is_none() { None } else { Some({ scorer_opt.take() }) } }; +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 { + 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); crate::lightning_background_processor::BackgroundProcessor { inner: ObjOps::heap_alloc(ret), is_owned: true } } diff --git a/lightning-c-bindings/src/lightning_invoice/constants.rs b/lightning-c-bindings/src/lightning_invoice/constants.rs index a51113f..7a32722 100644 --- a/lightning-c-bindings/src/lightning_invoice/constants.rs +++ b/lightning-c-bindings/src/lightning_invoice/constants.rs @@ -44,5 +44,8 @@ pub static TAG_PRIVATE_ROUTE: u8 = lightning_invoice::constants::TAG_PRIVATE_ROU #[no_mangle] pub static TAG_PAYMENT_SECRET: u8 = lightning_invoice::constants::TAG_PAYMENT_SECRET; +#[no_mangle] +pub static TAG_PAYMENT_METADATA: u8 = lightning_invoice::constants::TAG_PAYMENT_METADATA; + #[no_mangle] pub static TAG_FEATURES: u8 = lightning_invoice::constants::TAG_FEATURES; diff --git a/lightning-c-bindings/src/lightning_invoice/mod.rs b/lightning-c-bindings/src/lightning_invoice/mod.rs index 4b12f32..6fb6248 100644 --- a/lightning-c-bindings/src/lightning_invoice/mod.rs +++ b/lightning-c-bindings/src/lightning_invoice/mod.rs @@ -11,9 +11,11 @@ //! invoices and functions to create, encode and decode these. If you just want to use the standard //! en-/decoding functionality this should get you started: //! -//! * For parsing use `str::parse::(&self)` (see the docs of `impl FromStr for Invoice`) -//! * For constructing invoices use the `InvoiceBuilder` -//! * For serializing invoices use the `Display`/`ToString` traits +//! * For parsing use `str::parse::(&self)` (see [`Invoice::from_str`]) +//! * For constructing invoices use the [`InvoiceBuilder`] +//! * For serializing invoices use the [`Display`]/[`ToString`] traits +//! +//! [`Invoice::from_str`]: crate::Invoice#impl-FromStr use alloc::str::FromStr; use core::ffi::c_void; @@ -627,9 +629,11 @@ pub(crate) type nativeInvoice = nativeInvoiceImport; /// Represents a syntactically and semantically correct lightning BOLT11 invoice. /// /// There are three ways to construct an `Invoice`: -/// 1. using `InvoiceBuilder` -/// 2. using `Invoice::from_signed(SignedRawInvoice)` -/// 3. using `str::parse::(&str)` +/// 1. using [`InvoiceBuilder`] +/// 2. using [`Invoice::from_signed`] +/// 3. using `str::parse::(&str)` (see [`Invoice::from_str`]) +/// +/// [`Invoice::from_str`]: crate::Invoice#impl-FromStr #[must_use] #[repr(C)] pub struct Invoice { @@ -704,7 +708,7 @@ pub(crate) extern "C" fn Invoice_clone_void(this_ptr: *const c_void) -> *mut c_v pub extern "C" fn Invoice_clone(orig: &Invoice) -> Invoice { orig.clone() } -/// Checks if two Invoices contain equal inner contents. +/// Generates a non-cryptographic 64-bit hash of the Invoice. #[no_mangle] pub extern "C" fn Invoice_hash(o: &Invoice) -> u64 { if o.inner.is_null() { return 0; } @@ -718,11 +722,11 @@ pub extern "C" fn Invoice_hash(o: &Invoice) -> u64 { use lightning_invoice::SignedRawInvoice as nativeSignedRawInvoiceImport; pub(crate) type nativeSignedRawInvoice = nativeSignedRawInvoiceImport; -/// Represents a signed `RawInvoice` with cached hash. The signature is not checked and may be +/// Represents a signed [`RawInvoice`] with cached hash. The signature is not checked and may be /// invalid. /// /// # Invariants -/// The hash has to be either from the deserialized invoice or from the serialized `raw_invoice`. +/// The hash has to be either from the deserialized invoice or from the serialized [`RawInvoice`]. #[must_use] #[repr(C)] pub struct SignedRawInvoice { @@ -797,7 +801,7 @@ pub(crate) extern "C" fn SignedRawInvoice_clone_void(this_ptr: *const c_void) -> pub extern "C" fn SignedRawInvoice_clone(orig: &SignedRawInvoice) -> SignedRawInvoice { orig.clone() } -/// Checks if two SignedRawInvoices contain equal inner contents. +/// Generates a non-cryptographic 64-bit hash of the SignedRawInvoice. #[no_mangle] pub extern "C" fn SignedRawInvoice_hash(o: &SignedRawInvoice) -> u64 { if o.inner.is_null() { return 0; } @@ -811,11 +815,11 @@ pub extern "C" fn SignedRawInvoice_hash(o: &SignedRawInvoice) -> u64 { use lightning_invoice::RawInvoice as nativeRawInvoiceImport; pub(crate) type nativeRawInvoice = nativeRawInvoiceImport; -/// Represents an syntactically correct Invoice for a payment on the lightning network, +/// Represents an syntactically correct [`Invoice`] for a payment on the lightning network, /// but without the signature information. -/// De- and encoding should not lead to information loss but may lead to different hashes. +/// Decoding and encoding should not lead to information loss but may lead to different hashes. /// -/// For methods without docs see the corresponding methods in `Invoice`. +/// For methods without docs see the corresponding methods in [`Invoice`]. #[must_use] #[repr(C)] pub struct RawInvoice { @@ -901,7 +905,7 @@ pub(crate) extern "C" fn RawInvoice_clone_void(this_ptr: *const c_void) -> *mut pub extern "C" fn RawInvoice_clone(orig: &RawInvoice) -> RawInvoice { orig.clone() } -/// Checks if two RawInvoices contain equal inner contents. +/// Generates a non-cryptographic 64-bit hash of the RawInvoice. #[no_mangle] pub extern "C" fn RawInvoice_hash(o: &RawInvoice) -> u64 { if o.inner.is_null() { return 0; } @@ -915,7 +919,7 @@ pub extern "C" fn RawInvoice_hash(o: &RawInvoice) -> u64 { use lightning_invoice::RawDataPart as nativeRawDataPartImport; pub(crate) type nativeRawDataPart = nativeRawDataPartImport; -/// Data of the `RawInvoice` that is encoded in the data part +/// Data of the [`RawInvoice`] that is encoded in the data part #[must_use] #[repr(C)] pub struct RawDataPart { @@ -1001,7 +1005,7 @@ pub(crate) extern "C" fn RawDataPart_clone_void(this_ptr: *const c_void) -> *mut pub extern "C" fn RawDataPart_clone(orig: &RawDataPart) -> RawDataPart { orig.clone() } -/// Checks if two RawDataParts contain equal inner contents. +/// Generates a non-cryptographic 64-bit hash of the RawDataPart. #[no_mangle] pub extern "C" fn RawDataPart_hash(o: &RawDataPart) -> u64 { if o.inner.is_null() { return 0; } @@ -1095,7 +1099,7 @@ pub(crate) extern "C" fn PositiveTimestamp_clone_void(this_ptr: *const c_void) - pub extern "C" fn PositiveTimestamp_clone(orig: &PositiveTimestamp) -> PositiveTimestamp { orig.clone() } -/// Checks if two PositiveTimestamps contain equal inner contents. +/// Generates a non-cryptographic 64-bit hash of the PositiveTimestamp. #[no_mangle] pub extern "C" fn PositiveTimestamp_hash(o: &PositiveTimestamp) -> u64 { if o.inner.is_null() { return 0; } @@ -1187,7 +1191,7 @@ pub extern "C" fn SiPrefix_pico() -> SiPrefix { pub extern "C" fn SiPrefix_eq(a: &SiPrefix, b: &SiPrefix) -> bool { if &a.to_native() == &b.to_native() { true } else { false } } -/// Checks if two SiPrefixs contain equal inner contents. +/// Generates a non-cryptographic 64-bit hash of the SiPrefix. #[no_mangle] pub extern "C" fn SiPrefix_hash(o: &SiPrefix) -> u64 { // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core @@ -1291,7 +1295,7 @@ pub extern "C" fn Currency_simnet() -> Currency { /// Utility method to constructs a new Signet-variant Currency pub extern "C" fn Currency_signet() -> Currency { Currency::Signet} -/// Checks if two Currencys contain equal inner contents. +/// Generates a non-cryptographic 64-bit hash of the Currency. #[no_mangle] pub extern "C" fn Currency_hash(o: &Currency) -> u64 { // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core @@ -1376,7 +1380,7 @@ pub(crate) extern "C" fn Sha256_clone_void(this_ptr: *const c_void) -> *mut c_vo pub extern "C" fn Sha256_clone(orig: &Sha256) -> Sha256 { orig.clone() } -/// Checks if two Sha256s contain equal inner contents. +/// Generates a non-cryptographic 64-bit hash of the Sha256. #[no_mangle] pub extern "C" fn Sha256_hash(o: &Sha256) -> u64 { if o.inner.is_null() { return 0; } @@ -1395,6 +1399,15 @@ pub extern "C" fn Sha256_eq(a: &Sha256, b: &Sha256) -> bool { if a.inner.is_null() || b.inner.is_null() { return false; } if a.get_native_ref() == b.get_native_ref() { true } else { false } } +/// Constructs a new [`Sha256`] from the given bytes, which are assumed to be the output of a +/// single sha256 hash. +#[must_use] +#[no_mangle] +pub extern "C" fn Sha256_from_bytes(bytes: *const [u8; 32]) -> crate::lightning_invoice::Sha256 { + let mut ret = lightning_invoice::Sha256::from_bytes(unsafe { &*bytes}); + crate::lightning_invoice::Sha256 { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + use lightning_invoice::Description as nativeDescriptionImport; pub(crate) type nativeDescription = nativeDescriptionImport; @@ -1468,7 +1481,7 @@ pub(crate) extern "C" fn Description_clone_void(this_ptr: *const c_void) -> *mut pub extern "C" fn Description_clone(orig: &Description) -> Description { orig.clone() } -/// Checks if two Descriptions contain equal inner contents. +/// Generates a non-cryptographic 64-bit hash of the Description. #[no_mangle] pub extern "C" fn Description_hash(o: &Description) -> u64 { if o.inner.is_null() { return 0; } @@ -1574,7 +1587,7 @@ pub(crate) extern "C" fn PayeePubKey_clone_void(this_ptr: *const c_void) -> *mut pub extern "C" fn PayeePubKey_clone(orig: &PayeePubKey) -> PayeePubKey { orig.clone() } -/// Checks if two PayeePubKeys contain equal inner contents. +/// Generates a non-cryptographic 64-bit hash of the PayeePubKey. #[no_mangle] pub extern "C" fn PayeePubKey_hash(o: &PayeePubKey) -> u64 { if o.inner.is_null() { return 0; } @@ -1664,7 +1677,7 @@ pub(crate) extern "C" fn ExpiryTime_clone_void(this_ptr: *const c_void) -> *mut pub extern "C" fn ExpiryTime_clone(orig: &ExpiryTime) -> ExpiryTime { orig.clone() } -/// Checks if two ExpiryTimes contain equal inner contents. +/// Generates a non-cryptographic 64-bit hash of the ExpiryTime. #[no_mangle] pub extern "C" fn ExpiryTime_hash(o: &ExpiryTime) -> u64 { if o.inner.is_null() { return 0; } @@ -1770,7 +1783,7 @@ pub(crate) extern "C" fn MinFinalCltvExpiryDelta_clone_void(this_ptr: *const c_v pub extern "C" fn MinFinalCltvExpiryDelta_clone(orig: &MinFinalCltvExpiryDelta) -> MinFinalCltvExpiryDelta { orig.clone() } -/// Checks if two MinFinalCltvExpiryDeltas contain equal inner contents. +/// Generates a non-cryptographic 64-bit hash of the MinFinalCltvExpiryDelta. #[no_mangle] pub extern "C" fn MinFinalCltvExpiryDelta_hash(o: &MinFinalCltvExpiryDelta) -> u64 { if o.inner.is_null() { return 0; } @@ -1795,7 +1808,7 @@ pub extern "C" fn MinFinalCltvExpiryDelta_eq(a: &MinFinalCltvExpiryDelta, b: &Mi #[repr(C)] pub enum Fallback { SegWitProgram { - version: crate::c_types::U5, + version: crate::c_types::WitnessVersion, program: crate::c_types::derived::CVec_u8Z, }, PubKeyHash( @@ -1822,13 +1835,13 @@ impl Fallback { Fallback::PubKeyHash (ref a, ) => { let mut a_nonref = Clone::clone(a); nativeFallback::PubKeyHash ( - a_nonref.data, + bitcoin::hash_types::PubkeyHash::from_hash(bitcoin::hashes::Hash::from_inner(a_nonref.data)), ) }, Fallback::ScriptHash (ref a, ) => { let mut a_nonref = Clone::clone(a); nativeFallback::ScriptHash ( - a_nonref.data, + bitcoin::hash_types::ScriptHash::from_hash(bitcoin::hashes::Hash::from_inner(a_nonref.data)), ) }, } @@ -1845,12 +1858,12 @@ impl Fallback { }, Fallback::PubKeyHash (mut a, ) => { nativeFallback::PubKeyHash ( - a.data, + bitcoin::hash_types::PubkeyHash::from_hash(bitcoin::hashes::Hash::from_inner(a.data)), ) }, Fallback::ScriptHash (mut a, ) => { nativeFallback::ScriptHash ( - a.data, + bitcoin::hash_types::ScriptHash::from_hash(bitcoin::hashes::Hash::from_inner(a.data)), ) }, } @@ -1870,13 +1883,13 @@ impl Fallback { nativeFallback::PubKeyHash (ref a, ) => { let mut a_nonref = Clone::clone(a); Fallback::PubKeyHash ( - crate::c_types::TwentyBytes { data: a_nonref }, + crate::c_types::TwentyBytes { data: a_nonref.as_hash().into_inner() }, ) }, nativeFallback::ScriptHash (ref a, ) => { let mut a_nonref = Clone::clone(a); Fallback::ScriptHash ( - crate::c_types::TwentyBytes { data: a_nonref }, + crate::c_types::TwentyBytes { data: a_nonref.as_hash().into_inner() }, ) }, } @@ -1893,12 +1906,12 @@ impl Fallback { }, nativeFallback::PubKeyHash (mut a, ) => { Fallback::PubKeyHash ( - crate::c_types::TwentyBytes { data: a }, + crate::c_types::TwentyBytes { data: a.as_hash().into_inner() }, ) }, nativeFallback::ScriptHash (mut a, ) => { Fallback::ScriptHash ( - crate::c_types::TwentyBytes { data: a }, + crate::c_types::TwentyBytes { data: a.as_hash().into_inner() }, ) }, } @@ -1914,7 +1927,7 @@ pub extern "C" fn Fallback_clone(orig: &Fallback) -> Fallback { } #[no_mangle] /// Utility method to constructs a new SegWitProgram-variant Fallback -pub extern "C" fn Fallback_seg_wit_program(version: crate::c_types::U5, program: crate::c_types::derived::CVec_u8Z) -> Fallback { +pub extern "C" fn Fallback_seg_wit_program(version: crate::c_types::WitnessVersion, program: crate::c_types::derived::CVec_u8Z) -> Fallback { Fallback::SegWitProgram { version, program, @@ -1930,7 +1943,7 @@ pub extern "C" fn Fallback_pub_key_hash(a: crate::c_types::TwentyBytes) -> Fallb pub extern "C" fn Fallback_script_hash(a: crate::c_types::TwentyBytes) -> Fallback { Fallback::ScriptHash(a, ) } -/// Checks if two Fallbacks contain equal inner contents. +/// Generates a non-cryptographic 64-bit hash of the Fallback. #[no_mangle] pub extern "C" fn Fallback_hash(o: &Fallback) -> u64 { // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core @@ -2015,7 +2028,7 @@ pub(crate) extern "C" fn InvoiceSignature_clone_void(this_ptr: *const c_void) -> pub extern "C" fn InvoiceSignature_clone(orig: &InvoiceSignature) -> InvoiceSignature { orig.clone() } -/// Checks if two InvoiceSignatures contain equal inner contents. +/// Generates a non-cryptographic 64-bit hash of the InvoiceSignature. #[no_mangle] pub extern "C" fn InvoiceSignature_hash(o: &InvoiceSignature) -> u64 { if o.inner.is_null() { return 0; } @@ -2108,7 +2121,7 @@ pub(crate) extern "C" fn PrivateRoute_clone_void(this_ptr: *const c_void) -> *mu pub extern "C" fn PrivateRoute_clone(orig: &PrivateRoute) -> PrivateRoute { orig.clone() } -/// Checks if two PrivateRoutes contain equal inner contents. +/// Generates a non-cryptographic 64-bit hash of the PrivateRoute. #[no_mangle] pub extern "C" fn PrivateRoute_hash(o: &PrivateRoute) -> u64 { if o.inner.is_null() { return 0; } @@ -2139,7 +2152,7 @@ pub extern "C" fn SignedRawInvoice_into_parts(mut this_arg: crate::lightning_inv local_ret } -/// The `RawInvoice` which was signed. +/// The [`RawInvoice`] which was signed. #[must_use] #[no_mangle] pub extern "C" fn SignedRawInvoice_raw_invoice(this_arg: &crate::lightning_invoice::SignedRawInvoice) -> crate::lightning_invoice::RawInvoice { @@ -2147,7 +2160,7 @@ pub extern "C" fn SignedRawInvoice_raw_invoice(this_arg: &crate::lightning_invoi crate::lightning_invoice::RawInvoice { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning_invoice::RawInvoice<>) as *mut _) }, is_owned: false } } -/// The hash of the `RawInvoice` that was signed. +/// The hash of the [`RawInvoice`] that was signed. #[must_use] #[no_mangle] pub extern "C" fn SignedRawInvoice_signable_hash(this_arg: &crate::lightning_invoice::SignedRawInvoice) -> *const [u8; 32] { @@ -2155,7 +2168,7 @@ pub extern "C" fn SignedRawInvoice_signable_hash(this_arg: &crate::lightning_inv ret } -/// InvoiceSignature for the invoice. +/// Signature for the invoice. #[must_use] #[no_mangle] pub extern "C" fn SignedRawInvoice_signature(this_arg: &crate::lightning_invoice::SignedRawInvoice) -> crate::lightning_invoice::InvoiceSignature { @@ -2259,6 +2272,14 @@ pub extern "C" fn RawInvoice_payment_secret(this_arg: &crate::lightning_invoice: local_ret } +#[must_use] +#[no_mangle] +pub extern "C" fn RawInvoice_payment_metadata(this_arg: &crate::lightning_invoice::RawInvoice) -> crate::c_types::derived::COption_CVec_u8ZZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payment_metadata(); + let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_CVec_u8ZZ::None } else { crate::c_types::derived::COption_CVec_u8ZZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option is otherwise un-expressable. */ { let mut local_ret_0 = Vec::new(); for mut item in (*ret.as_ref().unwrap()).clone().drain(..) { local_ret_0.push( { item }); }; local_ret_0.into() }) }; + local_ret +} + /// /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] @@ -2355,6 +2376,14 @@ pub extern "C" fn PositiveTimestamp_as_time(this_arg: &crate::lightning_invoice: ret.duration_since(::std::time::SystemTime::UNIX_EPOCH).expect("Times must be post-1970").as_secs() } +/// The hash of the [`RawInvoice`] that was signed. +#[must_use] +#[no_mangle] +pub extern "C" fn Invoice_signable_hash(this_arg: &crate::lightning_invoice::Invoice) -> crate::c_types::ThirtyTwoBytes { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signable_hash(); + crate::c_types::ThirtyTwoBytes { data: ret } +} + /// Transform the `Invoice` into it's unchecked version #[must_use] #[no_mangle] @@ -2372,7 +2401,7 @@ pub extern "C" fn Invoice_check_signature(this_arg: &crate::lightning_invoice::I local_ret } -/// Constructs an `Invoice` from a `SignedRawInvoice` by checking all its invariants. +/// Constructs an `Invoice` from a [`SignedRawInvoice`] by checking all its invariants. /// ``` /// use lightning_invoice::*; /// @@ -2443,6 +2472,15 @@ pub extern "C" fn Invoice_payment_secret(this_arg: &crate::lightning_invoice::In &ret.0 } +/// Get the payment metadata blob if one was included in the invoice +#[must_use] +#[no_mangle] +pub extern "C" fn Invoice_payment_metadata(this_arg: &crate::lightning_invoice::Invoice) -> crate::c_types::derived::COption_CVec_u8ZZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payment_metadata(); + let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_CVec_u8ZZ::None } else { crate::c_types::derived::COption_CVec_u8ZZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option is otherwise un-expressable. */ { let mut local_ret_0 = Vec::new(); for mut item in (*ret.as_ref().unwrap()).clone().drain(..) { local_ret_0.push( { item }); }; local_ret_0.into() }) }; + local_ret +} + /// Get the invoice features if they were included in the invoice /// /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None @@ -2462,6 +2500,16 @@ pub extern "C" fn Invoice_recover_payee_pub_key(this_arg: &crate::lightning_invo crate::c_types::PublicKey::from_rust(&ret) } +/// Returns the Duration since the Unix epoch at which the invoice expires. +/// Returning None if overflow occurred. +#[must_use] +#[no_mangle] +pub extern "C" fn Invoice_expires_at(this_arg: &crate::lightning_invoice::Invoice) -> crate::c_types::derived::COption_DurationZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.expires_at(); + let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_DurationZ::None } else { crate::c_types::derived::COption_DurationZ::Some( { ret.unwrap().as_secs() }) }; + local_ret +} + /// Returns the invoice's expiry time, if present, otherwise [`DEFAULT_EXPIRY_TIME`]. #[must_use] #[no_mangle] @@ -2478,6 +2526,23 @@ pub extern "C" fn Invoice_is_expired(this_arg: &crate::lightning_invoice::Invoic ret } +/// Returns the Duration remaining until the invoice expires. +#[must_use] +#[no_mangle] +pub extern "C" fn Invoice_duration_until_expiry(this_arg: &crate::lightning_invoice::Invoice) -> u64 { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.duration_until_expiry(); + ret.as_secs() +} + +/// Returns the Duration remaining until the invoice expires given the current time. +/// `time` is the timestamp as a duration since the Unix epoch. +#[must_use] +#[no_mangle] +pub extern "C" fn Invoice_expiration_remaining_from_epoch(this_arg: &crate::lightning_invoice::Invoice, mut time: u64) -> u64 { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.expiration_remaining_from_epoch(core::time::Duration::from_secs(time)); + ret.as_secs() +} + /// Returns whether the expiry time would pass at the given point in time. /// `at_time` is the timestamp as a duration since the Unix epoch. #[must_use] @@ -2496,6 +2561,15 @@ pub extern "C" fn Invoice_min_final_cltv_expiry_delta(this_arg: &crate::lightnin ret } +/// Returns a list of all fallback addresses as [`Address`]es +#[must_use] +#[no_mangle] +pub extern "C" fn Invoice_fallback_addresses(this_arg: &crate::lightning_invoice::Invoice) -> crate::c_types::derived::CVec_AddressZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.fallback_addresses(); + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { alloc::string::ToString::to_string(&item).into() }); }; + local_ret.into() +} + /// Returns a list of all routes included in the invoice #[must_use] #[no_mangle] @@ -2532,7 +2606,7 @@ pub extern "C" fn Invoice_amount_milli_satoshis(this_arg: &crate::lightning_invo } /// Creates a new `Description` if `description` is at most 1023 __bytes__ long, -/// returns `CreationError::DescriptionTooLong` otherwise +/// returns [`CreationError::DescriptionTooLong`] otherwise /// /// Please note that single characters may use more than one byte due to UTF8 encoding. #[must_use] @@ -2543,7 +2617,7 @@ pub extern "C" fn Description_new(mut description: crate::c_types::Str) -> crate local_ret } -/// Returns the underlying description `String` +/// Returns the underlying description [`String`] #[must_use] #[no_mangle] pub extern "C" fn Description_into_inner(mut this_arg: crate::lightning_invoice::Description) -> crate::c_types::Str { @@ -2559,7 +2633,7 @@ pub extern "C" fn ExpiryTime_from_seconds(mut seconds: u64) -> crate::lightning_ crate::lightning_invoice::ExpiryTime { inner: ObjOps::heap_alloc(ret), is_owned: true } } -/// Construct an `ExpiryTime` from a `Duration`, dropping the sub-second part. +/// Construct an `ExpiryTime` from a [`Duration`], dropping the sub-second part. #[must_use] #[no_mangle] pub extern "C" fn ExpiryTime_from_duration(mut duration: u64) -> crate::lightning_invoice::ExpiryTime { @@ -2575,7 +2649,7 @@ pub extern "C" fn ExpiryTime_as_seconds(this_arg: &crate::lightning_invoice::Exp ret } -/// Returns a reference to the underlying `Duration` (=expiry time) +/// Returns a reference to the underlying [`Duration`] (=expiry time) #[must_use] #[no_mangle] pub extern "C" fn ExpiryTime_as_duration(this_arg: &crate::lightning_invoice::ExpiryTime) -> u64 { @@ -2600,12 +2674,12 @@ pub extern "C" fn PrivateRoute_into_inner(mut this_arg: crate::lightning_invoice crate::lightning::routing::router::RouteHint { inner: ObjOps::heap_alloc(ret), is_owned: true } } -/// Errors that may occur when constructing a new `RawInvoice` or `Invoice` +/// Errors that may occur when constructing a new [`RawInvoice`] or [`Invoice`] #[derive(Clone)] #[must_use] #[repr(C)] pub enum CreationError { - /// The supplied description string was longer than 639 __bytes__ (see [`Description::new(…)`](./struct.Description.html#method.new)) + /// The supplied description string was longer than 639 __bytes__ (see [`Description::new`]) DescriptionTooLong, /// The specified route has too many hops and can't be encoded RouteTooLong, @@ -2712,7 +2786,7 @@ pub extern "C" fn CreationError_eq(a: &CreationError, b: &CreationError) -> bool pub extern "C" fn CreationError_to_str(o: &crate::lightning_invoice::CreationError) -> Str { alloc::format!("{}", &o.to_native()).into() } -/// Errors that may occur when converting a `RawInvoice` to an `Invoice`. They relate to the +/// Errors that may occur when converting a [`RawInvoice`] to an [`Invoice`]. They relate to the /// requirements sections in BOLT #11 #[derive(Clone)] #[must_use] @@ -2861,7 +2935,7 @@ pub extern "C" fn SemanticError_eq(a: &SemanticError, b: &SemanticError) -> bool pub extern "C" fn SemanticError_to_str(o: &crate::lightning_invoice::SemanticError) -> Str { alloc::format!("{}", &o.to_native()).into() } -/// When signing using a fallible method either an user-supplied `SignError` or a `CreationError` +/// When signing using a fallible method either an user-supplied `SignError` or a [`CreationError`] /// may occur. #[derive(Clone)] #[must_use] diff --git a/lightning-c-bindings/src/lightning_invoice/utils.rs b/lightning-c-bindings/src/lightning_invoice/utils.rs index 6bc7bea..e897a93 100644 --- a/lightning-c-bindings/src/lightning_invoice/utils.rs +++ b/lightning-c-bindings/src/lightning_invoice/utils.rs @@ -35,7 +35,7 @@ use alloc::{vec::Vec, boxed::Box}; /// /// `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 @@ -53,7 +53,7 @@ use alloc::{vec::Vec, boxed::Box}; /// [`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. /// @@ -90,7 +90,7 @@ pub extern "C" fn create_phantom_invoice(mut amt_msat: crate::c_types::derived:: /// /// `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 @@ -102,7 +102,7 @@ pub extern "C" fn create_phantom_invoice(mut amt_msat: crate::c_types::derived:: /// [`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. /// diff --git a/lightning-c-bindings/src/lightning_rapid_gossip_sync/mod.rs b/lightning-c-bindings/src/lightning_rapid_gossip_sync/mod.rs index fb40cca..87b15b2 100644 --- a/lightning-c-bindings/src/lightning_rapid_gossip_sync/mod.rs +++ b/lightning-c-bindings/src/lightning_rapid_gossip_sync/mod.rs @@ -45,14 +45,17 @@ //! # use lightning::util::logger::{Logger, Record}; //! # struct FakeLogger {} //! # impl Logger for FakeLogger { -//! # fn log(&self, record: &Record) { unimplemented!() } +//! # fn log(&self, record: &Record) { } //! # } //! # let logger = FakeLogger {}; //! //! let network_graph = NetworkGraph::new(Network::Bitcoin, &logger); //! let rapid_sync = RapidGossipSync::new(&network_graph, &logger); //! let snapshot_contents: &[u8] = &[0; 0]; -//! let new_last_sync_timestamp_result = rapid_sync.update_network_graph(snapshot_contents); +//! // In no-std you need to provide the current time in unix epoch seconds +//! // otherwise you can use update_network_graph +//! let current_time_unix = 0; +//! let new_last_sync_timestamp_result = rapid_sync.update_network_graph_no_std(snapshot_contents, Some(current_time_unix)); //! ``` use alloc::str::FromStr; @@ -138,18 +141,6 @@ pub extern "C" fn RapidGossipSync_new(network_graph: &crate::lightning::routing: crate::lightning_rapid_gossip_sync::RapidGossipSync { inner: ObjOps::heap_alloc(ret), is_owned: true } } -/// Update network graph from binary data. -/// Returns the last sync timestamp to be used the next time rapid sync data is queried. -/// -/// `update_data`: `&[u8]` binary stream that comprises the update data -#[must_use] -#[no_mangle] -pub extern "C" fn RapidGossipSync_update_network_graph(this_arg: &crate::lightning_rapid_gossip_sync::RapidGossipSync, mut update_data: crate::c_types::u8slice) -> crate::c_types::derived::CResult_u32GraphSyncErrorZ { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.update_network_graph(update_data.to_slice()); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { o }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_rapid_gossip_sync::error::GraphSyncError::native_into(e) }).into() }; - local_ret -} - /// Update network graph from binary data. /// Returns the last sync timestamp to be used the next time rapid sync data is queried. /// -- 2.39.5