From a78b48cb952048b8699d8d2519ffb7293cdaac8b Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Fri, 28 Jul 2023 23:27:07 +0000 Subject: [PATCH] Update auto-generated bindings to LDK 0.0.116 --- lightning-c-bindings/include/ldk_rust_types.h | 58 +- lightning-c-bindings/include/lightning.h | 3339 ++- lightning-c-bindings/include/lightningpp.hpp | 1160 +- lightning-c-bindings/src/c_types/derived.rs | 19729 +++++++++------- .../src/lightning/blinded_path.rs | 2 +- .../src/lightning/chain/chaininterface.rs | 54 +- .../src/lightning/chain/chainmonitor.rs | 16 +- .../src/lightning/chain/channelmonitor.rs | 124 +- .../src/lightning/chain/keysinterface.rs | 2485 -- .../src/lightning/chain/mod.rs | 29 +- lightning-c-bindings/src/lightning/events.rs | 3634 --- .../src/lightning/ln/chan_utils.rs | 102 +- .../src/lightning/ln/channelmanager.rs | 378 +- .../src/lightning/ln/features.rs | 564 +- .../src/lightning/ln/inbound_payment.rs | 14 +- lightning-c-bindings/src/lightning/ln/msgs.rs | 2456 +- .../src/lightning/ln/outbound_payment.rs | 41 +- .../src/lightning/ln/peer_handler.rs | 155 +- lightning-c-bindings/src/lightning/ln/wire.rs | 2 - lightning-c-bindings/src/lightning/mod.rs | 1 + .../src/lightning/offers/invoice.rs | 212 +- .../src/lightning/offers/invoice_request.rs | 23 +- .../src/lightning/offers/mod.rs | 1 + .../src/lightning/offers/offer.rs | 26 +- .../src/lightning/offers/parse.rs | 366 + .../src/lightning/offers/refund.rs | 28 +- .../src/lightning/onion_message/messenger.rs | 307 +- .../src/lightning/onion_message/mod.rs | 1 + .../src/lightning/onion_message/packet.rs | 19 +- .../src/lightning/routing/gossip.rs | 105 +- .../src/lightning/routing/router.rs | 398 +- .../src/lightning/routing/scoring.rs | 635 +- .../src/lightning/routing/utxo.rs | 5 +- .../src/lightning/util/config.rs | 499 +- .../src/lightning/util/errors.rs | 2 +- .../src/lightning/util/persist.rs | 7 +- .../src/lightning/util/ser.rs | 186 + .../src/lightning_background_processor.rs | 2 + .../src/lightning_invoice/mod.rs | 892 +- .../src/lightning_invoice/payment.rs | 55 +- .../src/lightning_invoice/utils.rs | 62 +- .../src/lightning_persister.rs | 2 +- .../src/lightning_rapid_gossip_sync/mod.rs | 27 + 43 files changed, 19829 insertions(+), 18374 deletions(-) delete mode 100644 lightning-c-bindings/src/lightning/chain/keysinterface.rs delete mode 100644 lightning-c-bindings/src/lightning/events.rs diff --git a/lightning-c-bindings/include/ldk_rust_types.h b/lightning-c-bindings/include/ldk_rust_types.h index dd6a43c1..7a5f03f7 100644 --- a/lightning-c-bindings/include/ldk_rust_types.h +++ b/lightning-c-bindings/include/ldk_rust_types.h @@ -48,8 +48,6 @@ struct nativeUnsignedInvoiceOpaque; typedef struct nativeUnsignedInvoiceOpaque LDKnativeUnsignedInvoice; struct nativeBlindedPayInfoOpaque; typedef struct nativeBlindedPayInfoOpaque LDKnativeBlindedPayInfo; -struct nativeBackgroundProcessorOpaque; -typedef struct nativeBackgroundProcessorOpaque LDKnativeBackgroundProcessor; struct nativeDefaultRouterOpaque; typedef struct nativeDefaultRouterOpaque LDKnativeDefaultRouter; struct nativeScorerAccountingForInFlightHtlcsOpaque; @@ -145,8 +143,6 @@ struct nativeKeysManagerOpaque; typedef struct nativeKeysManagerOpaque LDKnativeKeysManager; struct nativePhantomKeysManagerOpaque; typedef struct nativePhantomKeysManagerOpaque LDKnativePhantomKeysManager; -struct nativeFilesystemPersisterOpaque; -typedef struct nativeFilesystemPersisterOpaque LDKnativeFilesystemPersister; struct nativeChannelManagerOpaque; typedef struct nativeChannelManagerOpaque LDKnativeChannelManager; struct nativeChainParametersOpaque; @@ -205,30 +201,8 @@ struct nativeBlindedPathOpaque; typedef struct nativeBlindedPathOpaque LDKnativeBlindedPath; struct nativeBlindedHopOpaque; typedef struct nativeBlindedHopOpaque LDKnativeBlindedHop; -struct nativeInvoiceOpaque; -typedef struct nativeInvoiceOpaque LDKnativeInvoice; -struct nativeSignedRawInvoiceOpaque; -typedef struct nativeSignedRawInvoiceOpaque LDKnativeSignedRawInvoice; -struct nativeRawInvoiceOpaque; -typedef struct nativeRawInvoiceOpaque LDKnativeRawInvoice; -struct nativeRawDataPartOpaque; -typedef struct nativeRawDataPartOpaque LDKnativeRawDataPart; -struct nativePositiveTimestampOpaque; -typedef struct nativePositiveTimestampOpaque LDKnativePositiveTimestamp; -struct nativeSha256Opaque; -typedef struct nativeSha256Opaque LDKnativeSha256; -struct nativeDescriptionOpaque; -typedef struct nativeDescriptionOpaque LDKnativeDescription; -struct nativePayeePubKeyOpaque; -typedef struct nativePayeePubKeyOpaque LDKnativePayeePubKey; -struct nativeExpiryTimeOpaque; -typedef struct nativeExpiryTimeOpaque LDKnativeExpiryTime; -struct nativeMinFinalCltvExpiryDeltaOpaque; -typedef struct nativeMinFinalCltvExpiryDeltaOpaque LDKnativeMinFinalCltvExpiryDelta; -struct nativeInvoiceSignatureOpaque; -typedef struct nativeInvoiceSignatureOpaque LDKnativeInvoiceSignature; -struct nativePrivateRouteOpaque; -typedef struct nativePrivateRouteOpaque LDKnativePrivateRoute; +struct nativeRapidGossipSyncOpaque; +typedef struct nativeRapidGossipSyncOpaque LDKnativeRapidGossipSync; struct nativeInitOpaque; typedef struct nativeInitOpaque LDKnativeInit; struct nativeErrorMessageOpaque; @@ -311,13 +285,33 @@ 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; +struct nativeInvoiceOpaque; +typedef struct nativeInvoiceOpaque LDKnativeInvoice; +struct nativeSignedRawInvoiceOpaque; +typedef struct nativeSignedRawInvoiceOpaque LDKnativeSignedRawInvoice; +struct nativeRawInvoiceOpaque; +typedef struct nativeRawInvoiceOpaque LDKnativeRawInvoice; +struct nativeRawDataPartOpaque; +typedef struct nativeRawDataPartOpaque LDKnativeRawDataPart; +struct nativePositiveTimestampOpaque; +typedef struct nativePositiveTimestampOpaque LDKnativePositiveTimestamp; +struct nativeSha256Opaque; +typedef struct nativeSha256Opaque LDKnativeSha256; +struct nativeDescriptionOpaque; +typedef struct nativeDescriptionOpaque LDKnativeDescription; +struct nativePayeePubKeyOpaque; +typedef struct nativePayeePubKeyOpaque LDKnativePayeePubKey; +struct nativeExpiryTimeOpaque; +typedef struct nativeExpiryTimeOpaque LDKnativeExpiryTime; +struct nativeMinFinalCltvExpiryDeltaOpaque; +typedef struct nativeMinFinalCltvExpiryDeltaOpaque LDKnativeMinFinalCltvExpiryDelta; +struct nativeInvoiceSignatureOpaque; +typedef struct nativeInvoiceSignatureOpaque LDKnativeInvoiceSignature; +struct nativePrivateRouteOpaque; +typedef struct nativePrivateRouteOpaque LDKnativePrivateRoute; diff --git a/lightning-c-bindings/include/lightning.h b/lightning-c-bindings/include/lightning.h index cbbe93e2..dbad7c79 100644 --- a/lightning-c-bindings/include/lightning.h +++ b/lightning-c-bindings/include/lightning.h @@ -2125,229 +2125,6 @@ typedef struct LDKCResult_BlindedPayInfoDecodeErrorZ { -/** - * Represents the compressed public key of a node - */ -typedef struct MUST_USE_STRUCT LDKNodeId { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeNodeId *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; -} LDKNodeId; - - - -/** - * Proposed use of a channel passed as a parameter to [`Score::channel_penalty_msat`]. - */ -typedef struct MUST_USE_STRUCT LDKChannelUsage { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeChannelUsage *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; -} LDKChannelUsage; - - - -/** - * A path in a [`Route`] to the payment recipient. Must always be at least length one. - * If no [`Path::blinded_tail`] is present, then [`Path::hops`] length may be up to 19. - */ -typedef struct MUST_USE_STRUCT LDKPath { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - 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; -} LDKPath; - -/** - * An interface used to score payment channels for path finding. - * - *\tScoring is in terms of fees willing to be paid in order to avoid routing through a channel. - */ -typedef struct LDKScore { - /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. - */ - void *this_arg; - /** - * Returns the fee in msats willing to be paid to avoid routing `send_amt_msat` through the - * given channel in the direction from `source` to `target`. - * - * The channel's capacity (less any other MPP parts that are also being considered for use in - * the same payment) is given by `capacity_msat`. It may be determined from various sources - * such as a chain data, network gossip, or invoice hints. For invoice hints, a capacity near - * [`u64::max_value`] is given to indicate sufficient capacity for the invoice's full amount. - * Thus, implementations should be overflow-safe. - */ - uint64_t (*channel_penalty_msat)(const void *this_arg, uint64_t short_channel_id, const struct LDKNodeId *NONNULL_PTR source, const struct LDKNodeId *NONNULL_PTR target, struct LDKChannelUsage usage); - /** - * Handles updating channel penalties after failing to route through a channel. - */ - 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, const struct LDKPath *NONNULL_PTR path); - /** - * Handles updating channel penalties after a probe over the given path failed. - */ - 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, const struct LDKPath *NONNULL_PTR path); - /** - * Serialize the object into a byte array - */ - struct LDKCVec_u8Z (*write)(const void *this_arg); - /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. - */ - void (*free)(void *this_arg); -} LDKScore; - -/** - * A scorer that is accessed under a lock. - * - * Needed so that calls to [`Score::channel_penalty_msat`] in [`find_route`] can be made while - * having shared ownership of a scorer but without requiring internal locking in [`Score`] - * implementations. Internal locking would be detrimental to route finding performance and could - * result in [`Score::channel_penalty_msat`] returning a different value for the same channel. - * - * [`find_route`]: crate::routing::router::find_route - */ -typedef struct LDKLockableScore { - /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. - */ - void *this_arg; - /** - * Returns the locked scorer. - */ - struct LDKScore (*lock)(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); -} LDKLockableScore; - -/** - * Refers to a scorer that is accessible under lock and also writeable to disk - * - * We need this trait to be able to pass in a scorer to `lightning-background-processor` that will enable us to - * use the Persister to persist it. - */ -typedef struct LDKWriteableScore { - /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. - */ - void *this_arg; - /** - * Implementation of LockableScore for this object. - */ - struct LDKLockableScore LockableScore; - /** - * Serialize the object into a byte array - */ - struct LDKCVec_u8Z (*write)(const void *this_arg); - /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. - */ - void (*free)(void *this_arg); -} LDKWriteableScore; - -/** - * An enum which can either contain a crate::lightning::routing::scoring::WriteableScore or not - */ -typedef enum LDKCOption_WriteableScoreZ_Tag { - /** - * When we're in this state, this COption_WriteableScoreZ contains a crate::lightning::routing::scoring::WriteableScore - */ - LDKCOption_WriteableScoreZ_Some, - /** - * When we're in this state, this COption_WriteableScoreZ contains nothing - */ - LDKCOption_WriteableScoreZ_None, - /** - * Must be last for serialization purposes - */ - LDKCOption_WriteableScoreZ_Sentinel, -} LDKCOption_WriteableScoreZ_Tag; - -typedef struct LDKCOption_WriteableScoreZ { - LDKCOption_WriteableScoreZ_Tag tag; - union { - struct { - struct LDKWriteableScore some; - }; - }; -} LDKCOption_WriteableScoreZ; - -/** - * The contents of CResult_NoneErrorZ - */ -typedef union LDKCResult_NoneErrorZPtr { - /** - * Note that this value is always NULL, as there are no contents in the OK variant - */ - void *result; - /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. - */ - enum LDKIOError *err; -} LDKCResult_NoneErrorZPtr; - -/** - * A CResult_NoneErrorZ represents the result of a fallible operation, - * containing a () on success and a crate::c_types::IOError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_NoneErrorZ { - /** - * The contents of this CResult_NoneErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. - */ - union LDKCResult_NoneErrorZPtr contents; - /** - * Whether this CResult_NoneErrorZ represents a success state. - */ - bool result_ok; -} LDKCResult_NoneErrorZ; - - - /** * Details of a channel, as returned by [`ChannelManager::list_channels`] and [`ChannelManager::list_usable_channels`] */ @@ -2673,6 +2450,27 @@ typedef struct LDKCVec_RouteHopZ { uintptr_t datalen; } LDKCVec_RouteHopZ; + + +/** + * A path in a [`Route`] to the payment recipient. Must always be at least length one. + * If no [`Path::blinded_tail`] is present, then [`Path::hops`] length may be up to 19. + */ +typedef struct MUST_USE_STRUCT LDKPath { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativePath *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust 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; +} LDKPath; + /** * A dynamically-allocated array of crate::lightning::routing::router::Paths of arbitrary size. * This corresponds to std::vector in C++ @@ -3420,6 +3218,26 @@ typedef struct LDKCOption_C2Tuple_EightU16sEightU16sZZ { }; } LDKCOption_C2Tuple_EightU16sEightU16sZZ; + + +/** + * Represents the compressed public key of a node + */ +typedef struct MUST_USE_STRUCT LDKNodeId { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeNodeId *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; +} LDKNodeId; + /** * A dynamically-allocated array of crate::lightning::routing::gossip::NodeIds of arbitrary size. * This corresponds to std::vector in C++ @@ -8280,104 +8098,6 @@ typedef struct LDKCResult_TransactionNoneZ { bool result_ok; } LDKCResult_TransactionNoneZ; - - -/** - * A ChannelMonitor handles chain events (blocks connected and disconnected) and generates - * on-chain transactions to ensure no loss of funds occurs. - * - * You MUST ensure that no ChannelMonitors for a given channel anywhere contain out-of-date - * information and are actively monitoring the chain. - * - * Pending Events or updated HTLCs which have not yet been read out by - * get_and_clear_pending_monitor_events or get_and_clear_pending_events are serialized to disk and - * reloaded at deserialize-time. Thus, you must ensure that, when handling events, all events - * gotten are fully handled before re-serializing the new state. - * - * Note that the deserializer is only implemented for (BlockHash, ChannelMonitor), which - * tells you the last block hash which was block_connect()ed. You MUST rescan any blocks along - * the \"reorg path\" (ie disconnecting blocks until you find a common ancestor from both the - * returned block hash and the the current chain and then reconnecting blocks to get to the - * best chain) upon deserializing the object! - */ -typedef struct MUST_USE_STRUCT LDKChannelMonitor { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeChannelMonitor *inner; - /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. - */ - bool is_owned; -} LDKChannelMonitor; - -/** - * A tuple of 2 elements. See the individual fields for the types contained. - */ -typedef struct LDKC2Tuple_BlockHashChannelMonitorZ { - /** - * The element at position 0 - */ - struct LDKThirtyTwoBytes a; - /** - * The element at position 1 - */ - struct LDKChannelMonitor b; -} LDKC2Tuple_BlockHashChannelMonitorZ; - -/** - * A dynamically-allocated array of crate::c_types::derived::C2Tuple_BlockHashChannelMonitorZs of arbitrary size. - * This corresponds to std::vector in C++ - */ -typedef struct LDKCVec_C2Tuple_BlockHashChannelMonitorZZ { - /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - */ - struct LDKC2Tuple_BlockHashChannelMonitorZ *data; - /** - * The number of elements pointed to by `data`. - */ - uintptr_t datalen; -} LDKCVec_C2Tuple_BlockHashChannelMonitorZZ; - -/** - * The contents of CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ - */ -typedef union LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZPtr { - /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. - */ - struct LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *result; - /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. - */ - enum LDKIOError *err; -} LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZPtr; - -/** - * A CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ represents the result of a fallible operation, - * containing a crate::c_types::derived::CVec_C2Tuple_BlockHashChannelMonitorZZ on success and a crate::c_types::IOError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ { - /** - * The contents of this CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. - */ - union LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZPtr contents; - /** - * Whether this CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ represents a success state. - */ - bool result_ok; -} LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ; - /** * An enum which can either contain a u16 or not */ @@ -9196,6 +8916,41 @@ typedef struct LDKCResult_PhantomRouteHintsDecodeErrorZ { bool result_ok; } LDKCResult_PhantomRouteHintsDecodeErrorZ; + + +/** + * A ChannelMonitor handles chain events (blocks connected and disconnected) and generates + * on-chain transactions to ensure no loss of funds occurs. + * + * You MUST ensure that no ChannelMonitors for a given channel anywhere contain out-of-date + * information and are actively monitoring the chain. + * + * Pending Events or updated HTLCs which have not yet been read out by + * get_and_clear_pending_monitor_events or get_and_clear_pending_events are serialized to disk and + * reloaded at deserialize-time. Thus, you must ensure that, when handling events, all events + * gotten are fully handled before re-serializing the new state. + * + * Note that the deserializer is only implemented for (BlockHash, ChannelMonitor), which + * tells you the last block hash which was block_connect()ed. You MUST rescan any blocks along + * the \"reorg path\" (ie disconnecting blocks until you find a common ancestor from both the + * returned block hash and the the current chain and then reconnecting blocks to get to the + * best chain) upon deserializing the object! + */ +typedef struct MUST_USE_STRUCT LDKChannelMonitor { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeChannelMonitor *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKChannelMonitor; + /** * A dynamically-allocated array of crate::lightning::chain::channelmonitor::ChannelMonitors of arbitrary size. * This corresponds to std::vector in C++ @@ -10600,6 +10355,20 @@ typedef struct LDKCVec_BalanceZ { uintptr_t datalen; } LDKCVec_BalanceZ; +/** + * A tuple of 2 elements. See the individual fields for the types contained. + */ +typedef struct LDKC2Tuple_BlockHashChannelMonitorZ { + /** + * The element at position 0 + */ + struct LDKThirtyTwoBytes a; + /** + * The element at position 1 + */ + struct LDKChannelMonitor b; +} LDKC2Tuple_BlockHashChannelMonitorZ; + /** * The contents of CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ */ @@ -11115,958 +10884,426 @@ typedef struct LDKCResult_BlindedHopDecodeErrorZ { } LDKCResult_BlindedHopDecodeErrorZ; /** - * Sub-errors which don't have specific information in them use this type. + * All-encompassing standard error type that processing can return */ -typedef struct LDKError { +typedef enum LDKGraphSyncError_Tag { /** - * Zero-Sized_types aren't consistent across Rust/C/C++, so we add some size here + * 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 */ - uint8_t _dummy; -} LDKError; - -/** - * Errors that indicate what is wrong with the invoice. They have some granularity for debug - * reasons, but should generally result in an \"invalid BOLT11 invoice\" message for the user. - */ -typedef enum LDKParseError_Tag { - LDKParseError_Bech32Error, - LDKParseError_ParseAmountError, - LDKParseError_MalformedSignature, - LDKParseError_BadPrefix, - LDKParseError_UnknownCurrency, - LDKParseError_UnknownSiPrefix, - LDKParseError_MalformedHRP, - LDKParseError_TooShortDataPart, - LDKParseError_UnexpectedEndOfTaggedFields, - LDKParseError_DescriptionDecodeError, - LDKParseError_PaddingError, - LDKParseError_IntegerOverflowError, - LDKParseError_InvalidSegWitProgramLength, - LDKParseError_InvalidPubKeyHashLength, - LDKParseError_InvalidScriptHashLength, - LDKParseError_InvalidRecoveryId, - LDKParseError_InvalidSliceLength, + LDKGraphSyncError_DecodeError, /** - * Not an error, but used internally to signal that a part of the invoice should be ignored - * according to BOLT11 + * 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 */ - LDKParseError_Skip, + LDKGraphSyncError_LightningError, /** * Must be last for serialization purposes */ - LDKParseError_Sentinel, -} LDKParseError_Tag; + LDKGraphSyncError_Sentinel, +} LDKGraphSyncError_Tag; -typedef struct MUST_USE_STRUCT LDKParseError { - LDKParseError_Tag tag; +typedef struct MUST_USE_STRUCT LDKGraphSyncError { + LDKGraphSyncError_Tag tag; union { struct { - struct LDKBech32Error bech32_error; - }; - struct { - struct LDKError parse_amount_error; - }; - struct { - enum LDKSecp256k1Error malformed_signature; - }; - struct { - struct LDKError description_decode_error; + struct LDKDecodeError decode_error; }; struct { - struct LDKStr invalid_slice_length; + struct LDKLightningError lightning_error; }; }; -} LDKParseError; +} LDKGraphSyncError; /** - * The contents of CResult_SiPrefixParseErrorZ + * The contents of CResult_u32GraphSyncErrorZ */ -typedef union LDKCResult_SiPrefixParseErrorZPtr { +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. */ - enum LDKSiPrefix *result; + uint32_t *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKParseError *err; -} LDKCResult_SiPrefixParseErrorZPtr; + struct LDKGraphSyncError *err; +} LDKCResult_u32GraphSyncErrorZPtr; /** - * A CResult_SiPrefixParseErrorZ represents the result of a fallible operation, - * containing a crate::lightning_invoice::SiPrefix on success and a crate::lightning_invoice::ParseError on failure. + * A CResult_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_SiPrefixParseErrorZ { +typedef struct LDKCResult_u32GraphSyncErrorZ { /** - * The contents of this CResult_SiPrefixParseErrorZ, accessible via either + * The contents of this CResult_u32GraphSyncErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_SiPrefixParseErrorZPtr contents; + union LDKCResult_u32GraphSyncErrorZPtr contents; /** - * Whether this CResult_SiPrefixParseErrorZ represents a success state. + * Whether this CResult_u32GraphSyncErrorZ represents a success state. */ bool result_ok; -} LDKCResult_SiPrefixParseErrorZ; - - +} LDKCResult_u32GraphSyncErrorZ; /** - * Represents a syntactically and semantically correct lightning BOLT11 invoice. - * - * There are three ways to construct an `Invoice`: - * 1. using [`InvoiceBuilder`] - * 2. using [`Invoice::from_signed`] - * 3. using `str::parse::(&str)` (see [`Invoice::from_str`]) - * - * [`Invoice::from_str`]: crate::Invoice#impl-FromStr + * The contents of CResult_NoneErrorZ */ -typedef struct MUST_USE_STRUCT LDKInvoice { +typedef union LDKCResult_NoneErrorZPtr { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * Note that this value is always NULL, as there are no contents in the OK variant */ - LDKnativeInvoice *inner; + void *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; -} LDKInvoice; + enum LDKIOError *err; +} LDKCResult_NoneErrorZPtr; /** - * Indicates that something went wrong while parsing or validating the invoice. Parsing errors - * should be mostly seen as opaque and are only there for debugging reasons. Semantic errors - * like wrong signatures, missing fields etc. could mean that someone tampered with the invoice. + * A CResult_NoneErrorZ represents the result of a fallible operation, + * containing a () on success and a crate::c_types::IOError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef enum LDKParseOrSemanticError_Tag { - /** - * The invoice couldn't be decoded - */ - LDKParseOrSemanticError_ParseError, +typedef struct LDKCResult_NoneErrorZ { /** - * The invoice could be decoded but violates the BOLT11 standard + * The contents of this CResult_NoneErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKParseOrSemanticError_SemanticError, + union LDKCResult_NoneErrorZPtr contents; /** - * Must be last for serialization purposes + * Whether this CResult_NoneErrorZ represents a success state. */ - LDKParseOrSemanticError_Sentinel, -} LDKParseOrSemanticError_Tag; - -typedef struct MUST_USE_STRUCT LDKParseOrSemanticError { - LDKParseOrSemanticError_Tag tag; - union { - struct { - struct LDKParseError parse_error; - }; - struct { - enum LDKSemanticError semantic_error; - }; - }; -} LDKParseOrSemanticError; + bool result_ok; +} LDKCResult_NoneErrorZ; /** - * The contents of CResult_InvoiceParseOrSemanticErrorZ + * The contents of CResult_NetAddressDecodeErrorZ */ -typedef union LDKCResult_InvoiceParseOrSemanticErrorZPtr { +typedef union LDKCResult_NetAddressDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKInvoice *result; + struct LDKNetAddress *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKParseOrSemanticError *err; -} LDKCResult_InvoiceParseOrSemanticErrorZPtr; + struct LDKDecodeError *err; +} LDKCResult_NetAddressDecodeErrorZPtr; /** - * A CResult_InvoiceParseOrSemanticErrorZ represents the result of a fallible operation, - * containing a crate::lightning_invoice::Invoice on success and a crate::lightning_invoice::ParseOrSemanticError on failure. + * A CResult_NetAddressDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::NetAddress on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_InvoiceParseOrSemanticErrorZ { +typedef struct LDKCResult_NetAddressDecodeErrorZ { /** - * The contents of this CResult_InvoiceParseOrSemanticErrorZ, accessible via either + * The contents of this CResult_NetAddressDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_InvoiceParseOrSemanticErrorZPtr contents; + union LDKCResult_NetAddressDecodeErrorZPtr contents; /** - * Whether this CResult_InvoiceParseOrSemanticErrorZ represents a success state. + * Whether this CResult_NetAddressDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_InvoiceParseOrSemanticErrorZ; +} LDKCResult_NetAddressDecodeErrorZ; /** - * Represents a signed [`RawInvoice`] with cached hash. The signature is not checked and may be - * invalid. + * An [`update_add_htlc`] message to be sent to or received from a peer. * - * # Invariants - * The hash has to be either from the deserialized invoice or from the serialized [`RawInvoice`]. + * [`update_add_htlc`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#adding-an-htlc-update_add_htlc */ -typedef struct MUST_USE_STRUCT LDKSignedRawInvoice { +typedef struct MUST_USE_STRUCT LDKUpdateAddHTLC { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeSignedRawInvoice *inner; + LDKnativeUpdateAddHTLC *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKSignedRawInvoice; - -/** - * The contents of CResult_SignedRawInvoiceParseErrorZ - */ -typedef union LDKCResult_SignedRawInvoiceParseErrorZPtr { - /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. - */ - struct LDKSignedRawInvoice *result; - /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. - */ - struct LDKParseError *err; -} LDKCResult_SignedRawInvoiceParseErrorZPtr; +} LDKUpdateAddHTLC; /** - * A CResult_SignedRawInvoiceParseErrorZ represents the result of a fallible operation, - * containing a crate::lightning_invoice::SignedRawInvoice on success and a crate::lightning_invoice::ParseError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * A dynamically-allocated array of crate::lightning::ln::msgs::UpdateAddHTLCs of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef struct LDKCResult_SignedRawInvoiceParseErrorZ { +typedef struct LDKCVec_UpdateAddHTLCZ { /** - * The contents of this CResult_SignedRawInvoiceParseErrorZ, 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_SignedRawInvoiceParseErrorZPtr contents; + struct LDKUpdateAddHTLC *data; /** - * Whether this CResult_SignedRawInvoiceParseErrorZ represents a success state. + * The number of elements pointed to by `data`. */ - bool result_ok; -} LDKCResult_SignedRawInvoiceParseErrorZ; + uintptr_t datalen; +} LDKCVec_UpdateAddHTLCZ; /** - * Represents an syntactically correct [`Invoice`] for a payment on the lightning network, - * but without the signature information. - * Decoding and encoding should not lead to information loss but may lead to different hashes. + * An [`update_fulfill_htlc`] message to be sent to or received from a peer. * - * For methods without docs see the corresponding methods in [`Invoice`]. - */ -typedef struct MUST_USE_STRUCT LDKRawInvoice { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeRawInvoice *inner; - /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. - */ - bool is_owned; -} LDKRawInvoice; - - - -/** - * Recoverable signature + * [`update_fulfill_htlc`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#removing-an-htlc-update_fulfill_htlc-update_fail_htlc-and-update_fail_malformed_htlc */ -typedef struct MUST_USE_STRUCT LDKInvoiceSignature { +typedef struct MUST_USE_STRUCT LDKUpdateFulfillHTLC { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeInvoiceSignature *inner; + LDKnativeUpdateFulfillHTLC *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKInvoiceSignature; +} LDKUpdateFulfillHTLC; /** - * A tuple of 3 elements. See the individual fields for the types contained. + * A dynamically-allocated array of crate::lightning::ln::msgs::UpdateFulfillHTLCs of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef struct LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ { - /** - * The element at position 0 - */ - struct LDKRawInvoice a; +typedef struct LDKCVec_UpdateFulfillHTLCZ { /** - * The element at position 1 + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - struct LDKThirtyTwoBytes b; + struct LDKUpdateFulfillHTLC *data; /** - * The element at position 2 + * The number of elements pointed to by `data`. */ - struct LDKInvoiceSignature c; -} LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ; + uintptr_t datalen; +} LDKCVec_UpdateFulfillHTLCZ; /** - * Payee public key + * An [`update_fail_htlc`] message to be sent to or received from a peer. + * + * [`update_fail_htlc`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#removing-an-htlc-update_fulfill_htlc-update_fail_htlc-and-update_fail_malformed_htlc */ -typedef struct MUST_USE_STRUCT LDKPayeePubKey { +typedef struct MUST_USE_STRUCT LDKUpdateFailHTLC { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativePayeePubKey *inner; + LDKnativeUpdateFailHTLC *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKPayeePubKey; - -/** - * The contents of CResult_PayeePubKeyErrorZ - */ -typedef union LDKCResult_PayeePubKeyErrorZPtr { - /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. - */ - struct LDKPayeePubKey *result; - /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. - */ - enum LDKSecp256k1Error *err; -} LDKCResult_PayeePubKeyErrorZPtr; +} LDKUpdateFailHTLC; /** - * A CResult_PayeePubKeyErrorZ represents the result of a fallible operation, - * containing a crate::lightning_invoice::PayeePubKey on success and a crate::c_types::Secp256k1Error on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * A dynamically-allocated array of crate::lightning::ln::msgs::UpdateFailHTLCs of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef struct LDKCResult_PayeePubKeyErrorZ { +typedef struct LDKCVec_UpdateFailHTLCZ { /** - * The contents of this CResult_PayeePubKeyErrorZ, 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_PayeePubKeyErrorZPtr contents; + struct LDKUpdateFailHTLC *data; /** - * Whether this CResult_PayeePubKeyErrorZ represents a success state. + * The number of elements pointed to by `data`. */ - bool result_ok; -} LDKCResult_PayeePubKeyErrorZ; + uintptr_t datalen; +} LDKCVec_UpdateFailHTLCZ; /** - * Private routing information - * - * # Invariants - * The encoded route has to be <1024 5bit characters long (<=639 bytes or <=12 hops) + * An [`update_fail_malformed_htlc`] message to be sent to or received from a peer. * + * [`update_fail_malformed_htlc`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#removing-an-htlc-update_fulfill_htlc-update_fail_htlc-and-update_fail_malformed_htlc */ -typedef struct MUST_USE_STRUCT LDKPrivateRoute { +typedef struct MUST_USE_STRUCT LDKUpdateFailMalformedHTLC { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativePrivateRoute *inner; + LDKnativeUpdateFailMalformedHTLC *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; -} LDKPrivateRoute; +} LDKUpdateFailMalformedHTLC; /** - * A dynamically-allocated array of crate::lightning_invoice::PrivateRoutes of arbitrary size. + * A dynamically-allocated array of crate::lightning::ln::msgs::UpdateFailMalformedHTLCs of arbitrary size. * This corresponds to std::vector in C++ */ -typedef struct LDKCVec_PrivateRouteZ { +typedef struct LDKCVec_UpdateFailMalformedHTLCZ { /** * The elements in the array. * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - struct LDKPrivateRoute *data; + struct LDKUpdateFailMalformedHTLC *data; /** * The number of elements pointed to by `data`. */ uintptr_t datalen; -} LDKCVec_PrivateRouteZ; - +} LDKCVec_UpdateFailMalformedHTLCZ; +/** + * The contents of CResult_AcceptChannelDecodeErrorZ + */ +typedef union LDKCResult_AcceptChannelDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKAcceptChannel *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + struct LDKDecodeError *err; +} LDKCResult_AcceptChannelDecodeErrorZPtr; /** - * A timestamp that refers to a date after 1 January 1970. - * - * # Invariants - * - * The Unix timestamp representing the stored time has to be positive and no greater than - * [`MAX_TIMESTAMP`]. + * A CResult_AcceptChannelDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::AcceptChannel on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct MUST_USE_STRUCT LDKPositiveTimestamp { +typedef struct LDKCResult_AcceptChannelDecodeErrorZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, 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_AcceptChannelDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKnativePositiveTimestamp *inner; + union LDKCResult_AcceptChannelDecodeErrorZPtr 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_AcceptChannelDecodeErrorZ represents a success state. */ - bool is_owned; -} LDKPositiveTimestamp; + bool result_ok; +} LDKCResult_AcceptChannelDecodeErrorZ; /** - * The contents of CResult_PositiveTimestampCreationErrorZ + * The contents of CResult_AnnouncementSignaturesDecodeErrorZ */ -typedef union LDKCResult_PositiveTimestampCreationErrorZPtr { +typedef union LDKCResult_AnnouncementSignaturesDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKPositiveTimestamp *result; + struct LDKAnnouncementSignatures *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - enum LDKCreationError *err; -} LDKCResult_PositiveTimestampCreationErrorZPtr; + struct LDKDecodeError *err; +} LDKCResult_AnnouncementSignaturesDecodeErrorZPtr; /** - * A CResult_PositiveTimestampCreationErrorZ represents the result of a fallible operation, - * containing a crate::lightning_invoice::PositiveTimestamp on success and a crate::lightning_invoice::CreationError on failure. + * A CResult_AnnouncementSignaturesDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::AnnouncementSignatures on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_PositiveTimestampCreationErrorZ { +typedef struct LDKCResult_AnnouncementSignaturesDecodeErrorZ { /** - * The contents of this CResult_PositiveTimestampCreationErrorZ, accessible via either + * The contents of this CResult_AnnouncementSignaturesDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_PositiveTimestampCreationErrorZPtr contents; + union LDKCResult_AnnouncementSignaturesDecodeErrorZPtr contents; /** - * Whether this CResult_PositiveTimestampCreationErrorZ represents a success state. + * Whether this CResult_AnnouncementSignaturesDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_PositiveTimestampCreationErrorZ; +} LDKCResult_AnnouncementSignaturesDecodeErrorZ; /** - * The contents of CResult_NoneSemanticErrorZ + * The contents of CResult_ChannelReestablishDecodeErrorZ */ -typedef union LDKCResult_NoneSemanticErrorZPtr { +typedef union LDKCResult_ChannelReestablishDecodeErrorZPtr { /** - * Note that this value is always NULL, as there are no contents in the OK variant + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - void *result; + struct LDKChannelReestablish *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - enum LDKSemanticError *err; -} LDKCResult_NoneSemanticErrorZPtr; + struct LDKDecodeError *err; +} LDKCResult_ChannelReestablishDecodeErrorZPtr; /** - * A CResult_NoneSemanticErrorZ represents the result of a fallible operation, - * containing a () on success and a crate::lightning_invoice::SemanticError on failure. + * A CResult_ChannelReestablishDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::ChannelReestablish on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_NoneSemanticErrorZ { +typedef struct LDKCResult_ChannelReestablishDecodeErrorZ { /** - * The contents of this CResult_NoneSemanticErrorZ, accessible via either + * The contents of this CResult_ChannelReestablishDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_NoneSemanticErrorZPtr contents; + union LDKCResult_ChannelReestablishDecodeErrorZPtr contents; /** - * Whether this CResult_NoneSemanticErrorZ represents a success state. + * Whether this CResult_ChannelReestablishDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_NoneSemanticErrorZ; +} LDKCResult_ChannelReestablishDecodeErrorZ; /** - * The contents of CResult_InvoiceSemanticErrorZ + * The contents of CResult_ClosingSignedDecodeErrorZ */ -typedef union LDKCResult_InvoiceSemanticErrorZPtr { +typedef union LDKCResult_ClosingSignedDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKInvoice *result; + struct LDKClosingSigned *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - enum LDKSemanticError *err; -} LDKCResult_InvoiceSemanticErrorZPtr; + struct LDKDecodeError *err; +} LDKCResult_ClosingSignedDecodeErrorZPtr; /** - * A CResult_InvoiceSemanticErrorZ represents the result of a fallible operation, - * containing a crate::lightning_invoice::Invoice on success and a crate::lightning_invoice::SemanticError on failure. + * A CResult_ClosingSignedDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::ClosingSigned on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_InvoiceSemanticErrorZ { +typedef struct LDKCResult_ClosingSignedDecodeErrorZ { /** - * The contents of this CResult_InvoiceSemanticErrorZ, accessible via either + * The contents of this CResult_ClosingSignedDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_InvoiceSemanticErrorZPtr contents; + union LDKCResult_ClosingSignedDecodeErrorZPtr contents; /** - * Whether this CResult_InvoiceSemanticErrorZ represents a success state. + * Whether this CResult_ClosingSignedDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_InvoiceSemanticErrorZ; +} LDKCResult_ClosingSignedDecodeErrorZ; + + /** - * 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; - - - -/** - * Description string - * - * # Invariants - * The description can be at most 639 __bytes__ long - */ -typedef struct MUST_USE_STRUCT LDKDescription { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeDescription *inner; - /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. - */ - bool is_owned; -} LDKDescription; - -/** - * The contents of CResult_DescriptionCreationErrorZ - */ -typedef union LDKCResult_DescriptionCreationErrorZPtr { - /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. - */ - struct LDKDescription *result; - /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. - */ - enum LDKCreationError *err; -} LDKCResult_DescriptionCreationErrorZPtr; - -/** - * A CResult_DescriptionCreationErrorZ represents the result of a fallible operation, - * containing a crate::lightning_invoice::Description on success and a crate::lightning_invoice::CreationError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_DescriptionCreationErrorZ { - /** - * The contents of this CResult_DescriptionCreationErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. - */ - union LDKCResult_DescriptionCreationErrorZPtr contents; - /** - * Whether this CResult_DescriptionCreationErrorZ represents a success state. - */ - bool result_ok; -} LDKCResult_DescriptionCreationErrorZ; - -/** - * The contents of CResult_PrivateRouteCreationErrorZ - */ -typedef union LDKCResult_PrivateRouteCreationErrorZPtr { - /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. - */ - struct LDKPrivateRoute *result; - /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. - */ - enum LDKCreationError *err; -} LDKCResult_PrivateRouteCreationErrorZPtr; - -/** - * A CResult_PrivateRouteCreationErrorZ represents the result of a fallible operation, - * containing a crate::lightning_invoice::PrivateRoute on success and a crate::lightning_invoice::CreationError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_PrivateRouteCreationErrorZ { - /** - * The contents of this CResult_PrivateRouteCreationErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. - */ - union LDKCResult_PrivateRouteCreationErrorZPtr contents; - /** - * Whether this CResult_PrivateRouteCreationErrorZ represents a success state. - */ - bool result_ok; -} LDKCResult_PrivateRouteCreationErrorZ; - -/** - * The contents of CResult_NetAddressDecodeErrorZ - */ -typedef union LDKCResult_NetAddressDecodeErrorZPtr { - /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. - */ - struct LDKNetAddress *result; - /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. - */ - struct LDKDecodeError *err; -} LDKCResult_NetAddressDecodeErrorZPtr; - -/** - * A CResult_NetAddressDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::NetAddress on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_NetAddressDecodeErrorZ { - /** - * The contents of this CResult_NetAddressDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. - */ - union LDKCResult_NetAddressDecodeErrorZPtr contents; - /** - * Whether this CResult_NetAddressDecodeErrorZ represents a success state. - */ - bool result_ok; -} LDKCResult_NetAddressDecodeErrorZ; - - - -/** - * An [`update_add_htlc`] message to be sent to or received from a peer. - * - * [`update_add_htlc`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#adding-an-htlc-update_add_htlc - */ -typedef struct MUST_USE_STRUCT LDKUpdateAddHTLC { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeUpdateAddHTLC *inner; - /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. - */ - bool is_owned; -} LDKUpdateAddHTLC; - -/** - * A dynamically-allocated array of crate::lightning::ln::msgs::UpdateAddHTLCs of arbitrary size. - * This corresponds to std::vector in C++ - */ -typedef struct LDKCVec_UpdateAddHTLCZ { - /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - */ - struct LDKUpdateAddHTLC *data; - /** - * The number of elements pointed to by `data`. - */ - uintptr_t datalen; -} LDKCVec_UpdateAddHTLCZ; - - - -/** - * An [`update_fulfill_htlc`] message to be sent to or received from a peer. - * - * [`update_fulfill_htlc`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#removing-an-htlc-update_fulfill_htlc-update_fail_htlc-and-update_fail_malformed_htlc - */ -typedef struct MUST_USE_STRUCT LDKUpdateFulfillHTLC { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeUpdateFulfillHTLC *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; -} LDKUpdateFulfillHTLC; - -/** - * A dynamically-allocated array of crate::lightning::ln::msgs::UpdateFulfillHTLCs of arbitrary size. - * This corresponds to std::vector in C++ - */ -typedef struct LDKCVec_UpdateFulfillHTLCZ { - /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - */ - struct LDKUpdateFulfillHTLC *data; - /** - * The number of elements pointed to by `data`. - */ - uintptr_t datalen; -} LDKCVec_UpdateFulfillHTLCZ; - - - -/** - * An [`update_fail_htlc`] message to be sent to or received from a peer. - * - * [`update_fail_htlc`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#removing-an-htlc-update_fulfill_htlc-update_fail_htlc-and-update_fail_malformed_htlc - */ -typedef struct MUST_USE_STRUCT LDKUpdateFailHTLC { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeUpdateFailHTLC *inner; - /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. - */ - bool is_owned; -} LDKUpdateFailHTLC; - -/** - * A dynamically-allocated array of crate::lightning::ln::msgs::UpdateFailHTLCs of arbitrary size. - * This corresponds to std::vector in C++ - */ -typedef struct LDKCVec_UpdateFailHTLCZ { - /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - */ - struct LDKUpdateFailHTLC *data; - /** - * The number of elements pointed to by `data`. - */ - uintptr_t datalen; -} LDKCVec_UpdateFailHTLCZ; - - - -/** - * An [`update_fail_malformed_htlc`] message to be sent to or received from a peer. - * - * [`update_fail_malformed_htlc`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#removing-an-htlc-update_fulfill_htlc-update_fail_htlc-and-update_fail_malformed_htlc - */ -typedef struct MUST_USE_STRUCT LDKUpdateFailMalformedHTLC { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeUpdateFailMalformedHTLC *inner; - /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. - */ - bool is_owned; -} LDKUpdateFailMalformedHTLC; - -/** - * A dynamically-allocated array of crate::lightning::ln::msgs::UpdateFailMalformedHTLCs of arbitrary size. - * This corresponds to std::vector in C++ - */ -typedef struct LDKCVec_UpdateFailMalformedHTLCZ { - /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - */ - struct LDKUpdateFailMalformedHTLC *data; - /** - * The number of elements pointed to by `data`. - */ - uintptr_t datalen; -} LDKCVec_UpdateFailMalformedHTLCZ; - -/** - * The contents of CResult_AcceptChannelDecodeErrorZ - */ -typedef union LDKCResult_AcceptChannelDecodeErrorZPtr { - /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. - */ - struct LDKAcceptChannel *result; - /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. - */ - struct LDKDecodeError *err; -} LDKCResult_AcceptChannelDecodeErrorZPtr; - -/** - * A CResult_AcceptChannelDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::AcceptChannel on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_AcceptChannelDecodeErrorZ { - /** - * The contents of this CResult_AcceptChannelDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. - */ - union LDKCResult_AcceptChannelDecodeErrorZPtr contents; - /** - * Whether this CResult_AcceptChannelDecodeErrorZ represents a success state. - */ - bool result_ok; -} LDKCResult_AcceptChannelDecodeErrorZ; - -/** - * The contents of CResult_AnnouncementSignaturesDecodeErrorZ - */ -typedef union LDKCResult_AnnouncementSignaturesDecodeErrorZPtr { - /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. - */ - struct LDKAnnouncementSignatures *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_AnnouncementSignaturesDecodeErrorZPtr; - -/** - * A CResult_AnnouncementSignaturesDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::AnnouncementSignatures on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_AnnouncementSignaturesDecodeErrorZ { - /** - * The contents of this CResult_AnnouncementSignaturesDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. - */ - union LDKCResult_AnnouncementSignaturesDecodeErrorZPtr contents; - /** - * Whether this CResult_AnnouncementSignaturesDecodeErrorZ represents a success state. - */ - bool result_ok; -} LDKCResult_AnnouncementSignaturesDecodeErrorZ; - -/** - * The contents of CResult_ChannelReestablishDecodeErrorZ - */ -typedef union LDKCResult_ChannelReestablishDecodeErrorZPtr { - /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. - */ - struct LDKChannelReestablish *result; - /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. - */ - struct LDKDecodeError *err; -} LDKCResult_ChannelReestablishDecodeErrorZPtr; - -/** - * A CResult_ChannelReestablishDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::ChannelReestablish on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_ChannelReestablishDecodeErrorZ { - /** - * The contents of this CResult_ChannelReestablishDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. - */ - union LDKCResult_ChannelReestablishDecodeErrorZPtr contents; - /** - * Whether this CResult_ChannelReestablishDecodeErrorZ represents a success state. - */ - bool result_ok; -} LDKCResult_ChannelReestablishDecodeErrorZ; - -/** - * The contents of CResult_ClosingSignedDecodeErrorZ - */ -typedef union LDKCResult_ClosingSignedDecodeErrorZPtr { - /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. - */ - struct LDKClosingSigned *result; - /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. - */ - struct LDKDecodeError *err; -} LDKCResult_ClosingSignedDecodeErrorZPtr; - -/** - * A CResult_ClosingSignedDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::ClosingSigned on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_ClosingSignedDecodeErrorZ { - /** - * The contents of this CResult_ClosingSignedDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. - */ - union LDKCResult_ClosingSignedDecodeErrorZPtr contents; - /** - * Whether this CResult_ClosingSignedDecodeErrorZ represents a success state. - */ - bool result_ok; -} LDKCResult_ClosingSignedDecodeErrorZ; - - - -/** - * The minimum and maximum fees which the sender is willing to place on the closing transaction. - * - * This is provided in [`ClosingSigned`] by both sides to indicate the fee range they are willing - * to use. + * The minimum and maximum fees which the sender is willing to place on the closing transaction. + * + * This is provided in [`ClosingSigned`] by both sides to indicate the fee range they are willing + * to use. */ typedef struct MUST_USE_STRUCT LDKClosingSignedFeeRange { /** @@ -13229,6 +12466,249 @@ typedef struct LDKCResult_GossipTimestampFilterDecodeErrorZ { bool result_ok; } LDKCResult_GossipTimestampFilterDecodeErrorZ; + + +/** + * A transaction output watched by a [`ChannelMonitor`] for spends on-chain. + * + * Used to convey to a [`Filter`] such an output with a given spending condition. Any transaction + * spending the output must be given to [`ChannelMonitor::block_connected`] either directly or via + * [`Confirm::transactions_confirmed`]. + * + * If `block_hash` is `Some`, this indicates the output was created in the corresponding block and + * may have been spent there. See [`Filter::register_output`] for details. + * + * [`ChannelMonitor`]: channelmonitor::ChannelMonitor + * [`ChannelMonitor::block_connected`]: channelmonitor::ChannelMonitor::block_connected + */ +typedef struct MUST_USE_STRUCT LDKWatchedOutput { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeWatchedOutput *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKWatchedOutput; + +/** + * The `Filter` trait defines behavior for indicating chain activity of interest pertaining to + * channels. + * + * This is useful in order to have a [`Watch`] implementation convey to a chain source which + * transactions to be notified of. Notification may take the form of pre-filtering blocks or, in + * the case of [BIP 157]/[BIP 158], only fetching a block if the compact filter matches. If + * receiving full blocks from a chain source, any further filtering is unnecessary. + * + * After an output has been registered, subsequent block retrievals from the chain source must not + * exclude any transactions matching the new criteria nor any in-block descendants of such + * transactions. + * + * Note that use as part of a [`Watch`] implementation involves reentrancy. Therefore, the `Filter` + * should not block on I/O. Implementations should instead queue the newly monitored data to be + * processed later. Then, in order to block until the data has been processed, any [`Watch`] + * invocation that has called the `Filter` must return [`InProgress`]. + * + * [`InProgress`]: ChannelMonitorUpdateStatus::InProgress + * [BIP 157]: https://github.com/bitcoin/bips/blob/master/bip-0157.mediawiki + * [BIP 158]: https://github.com/bitcoin/bips/blob/master/bip-0158.mediawiki + */ +typedef struct LDKFilter { + /** + * 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; + /** + * Registers interest in a transaction with `txid` and having an output with `script_pubkey` as + * a spending condition. + */ + void (*register_tx)(const void *this_arg, const uint8_t (*txid)[32], struct LDKu8slice script_pubkey); + /** + * Registers interest in spends of a transaction output. + * + * Note that this method might be called during processing of a new block. You therefore need + * to ensure that also dependent output spents within an already connected block are correctly + * handled, e.g., by re-scanning the block in question whenever new outputs have been + * registered mid-processing. + */ + void (*register_output)(const void *this_arg, struct LDKWatchedOutput output); + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKFilter; + +/** + * An enum which can either contain a crate::lightning::chain::Filter or not + */ +typedef enum LDKCOption_FilterZ_Tag { + /** + * When we're in this state, this COption_FilterZ contains a crate::lightning::chain::Filter + */ + LDKCOption_FilterZ_Some, + /** + * When we're in this state, this COption_FilterZ contains nothing + */ + LDKCOption_FilterZ_None, + /** + * Must be last for serialization purposes + */ + LDKCOption_FilterZ_Sentinel, +} LDKCOption_FilterZ_Tag; + +typedef struct LDKCOption_FilterZ { + LDKCOption_FilterZ_Tag tag; + union { + struct { + struct LDKFilter some; + }; + }; +} LDKCOption_FilterZ; + + + +/** + * A read-only reference to a current ChannelMonitor. + * + * Note that this holds a mutex in [`ChainMonitor`] and may block other events until it is + * released. + */ +typedef struct MUST_USE_STRUCT LDKLockedChannelMonitor { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeLockedChannelMonitor *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKLockedChannelMonitor; + +/** + * The contents of CResult_LockedChannelMonitorNoneZ + */ +typedef union LDKCResult_LockedChannelMonitorNoneZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKLockedChannelMonitor *result; + /** + * Note that this value is always NULL, as there are no contents in the Err variant + */ + void *err; +} LDKCResult_LockedChannelMonitorNoneZPtr; + +/** + * A CResult_LockedChannelMonitorNoneZ represents the result of a fallible operation, + * containing a crate::lightning::chain::chainmonitor::LockedChannelMonitor on success and a () on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_LockedChannelMonitorNoneZ { + /** + * The contents of this CResult_LockedChannelMonitorNoneZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_LockedChannelMonitorNoneZPtr contents; + /** + * Whether this CResult_LockedChannelMonitorNoneZ represents a success state. + */ + bool result_ok; +} LDKCResult_LockedChannelMonitorNoneZ; + +/** + * A dynamically-allocated array of crate::lightning::chain::transaction::OutPoints of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_OutPointZ { + /** + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + */ + struct LDKOutPoint *data; + /** + * The number of elements pointed to by `data`. + */ + uintptr_t datalen; +} LDKCVec_OutPointZ; + + + +/** + * An opaque identifier describing a specific [`Persist`] method call. + */ +typedef struct MUST_USE_STRUCT LDKMonitorUpdateId { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeMonitorUpdateId *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKMonitorUpdateId; + +/** + * A dynamically-allocated array of crate::lightning::chain::chainmonitor::MonitorUpdateIds of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_MonitorUpdateIdZ { + /** + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + */ + struct LDKMonitorUpdateId *data; + /** + * The number of elements pointed to by `data`. + */ + uintptr_t datalen; +} LDKCVec_MonitorUpdateIdZ; + +/** + * A tuple of 2 elements. See the individual fields for the types contained. + */ +typedef struct LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ { + /** + * The element at position 0 + */ + struct LDKOutPoint a; + /** + * The element at position 1 + */ + struct LDKCVec_MonitorUpdateIdZ b; +} LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ; + +/** + * A dynamically-allocated array of crate::c_types::derived::C2Tuple_OutPointCVec_MonitorUpdateIdZZs of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ { + /** + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + */ + struct LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ *data; + /** + * The number of elements pointed to by `data`. + */ + uintptr_t datalen; +} LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ; + /** * A dynamically-allocated array of crate::lightning::ln::channelmanager::PhantomRouteHintss of arbitrary size. * This corresponds to std::vector in C++ @@ -13245,6 +12725,33 @@ typedef struct LDKCVec_PhantomRouteHintsZ { uintptr_t datalen; } LDKCVec_PhantomRouteHintsZ; + + +/** + * Represents a syntactically and semantically correct lightning BOLT11 invoice. + * + * There are three ways to construct an `Invoice`: + * 1. using [`InvoiceBuilder`] + * 2. using [`Invoice::from_signed`] + * 3. using `str::parse::(&str)` (see [`Invoice::from_str`]) + * + * [`Invoice::from_str`]: crate::Invoice#impl-FromStr + */ +typedef struct MUST_USE_STRUCT LDKInvoice { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeInvoice *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKInvoice; + /** * When signing using a fallible method either an user-supplied `SignError` or a [`CreationError`] * may occur. @@ -13306,351 +12813,607 @@ typedef struct LDKCResult_InvoiceSignOrCreationErrorZ { bool result_ok; } LDKCResult_InvoiceSignOrCreationErrorZ; +/** + * Sub-errors which don't have specific information in them use this type. + */ +typedef struct LDKError { + /** + * Zero-Sized_types aren't consistent across Rust/C/C++, so we add some size here + */ + uint8_t _dummy; +} LDKError; +/** + * Errors that indicate what is wrong with the invoice. They have some granularity for debug + * reasons, but should generally result in an \"invalid BOLT11 invoice\" message for the user. + */ +typedef enum LDKParseError_Tag { + LDKParseError_Bech32Error, + LDKParseError_ParseAmountError, + LDKParseError_MalformedSignature, + LDKParseError_BadPrefix, + LDKParseError_UnknownCurrency, + LDKParseError_UnknownSiPrefix, + LDKParseError_MalformedHRP, + LDKParseError_TooShortDataPart, + LDKParseError_UnexpectedEndOfTaggedFields, + LDKParseError_DescriptionDecodeError, + LDKParseError_PaddingError, + LDKParseError_IntegerOverflowError, + LDKParseError_InvalidSegWitProgramLength, + LDKParseError_InvalidPubKeyHashLength, + LDKParseError_InvalidScriptHashLength, + LDKParseError_InvalidRecoveryId, + LDKParseError_InvalidSliceLength, + /** + * Not an error, but used internally to signal that a part of the invoice should be ignored + * according to BOLT11 + */ + LDKParseError_Skip, + /** + * Must be last for serialization purposes + */ + LDKParseError_Sentinel, +} LDKParseError_Tag; + +typedef struct MUST_USE_STRUCT LDKParseError { + LDKParseError_Tag tag; + union { + struct { + struct LDKBech32Error bech32_error; + }; + struct { + struct LDKError parse_amount_error; + }; + struct { + enum LDKSecp256k1Error malformed_signature; + }; + struct { + struct LDKError description_decode_error; + }; + struct { + struct LDKStr invalid_slice_length; + }; + }; +} LDKParseError; /** - * A simple future which can complete once, and calls some callback(s) when it does so. + * The contents of CResult_SiPrefixParseErrorZ + */ +typedef union LDKCResult_SiPrefixParseErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + enum LDKSiPrefix *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + struct LDKParseError *err; +} LDKCResult_SiPrefixParseErrorZPtr; + +/** + * A CResult_SiPrefixParseErrorZ represents the result of a fallible operation, + * containing a crate::lightning_invoice::SiPrefix on success and a crate::lightning_invoice::ParseError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_SiPrefixParseErrorZ { + /** + * The contents of this CResult_SiPrefixParseErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_SiPrefixParseErrorZPtr contents; + /** + * Whether this CResult_SiPrefixParseErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_SiPrefixParseErrorZ; + +/** + * Indicates that something went wrong while parsing or validating the invoice. Parsing errors + * should be mostly seen as opaque and are only there for debugging reasons. Semantic errors + * like wrong signatures, missing fields etc. could mean that someone tampered with the invoice. + */ +typedef enum LDKParseOrSemanticError_Tag { + /** + * The invoice couldn't be decoded + */ + LDKParseOrSemanticError_ParseError, + /** + * The invoice could be decoded but violates the BOLT11 standard + */ + LDKParseOrSemanticError_SemanticError, + /** + * Must be last for serialization purposes + */ + LDKParseOrSemanticError_Sentinel, +} LDKParseOrSemanticError_Tag; + +typedef struct MUST_USE_STRUCT LDKParseOrSemanticError { + LDKParseOrSemanticError_Tag tag; + union { + struct { + struct LDKParseError parse_error; + }; + struct { + enum LDKSemanticError semantic_error; + }; + }; +} LDKParseOrSemanticError; + +/** + * The contents of CResult_InvoiceParseOrSemanticErrorZ + */ +typedef union LDKCResult_InvoiceParseOrSemanticErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKInvoice *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + struct LDKParseOrSemanticError *err; +} LDKCResult_InvoiceParseOrSemanticErrorZPtr; + +/** + * A CResult_InvoiceParseOrSemanticErrorZ represents the result of a fallible operation, + * containing a crate::lightning_invoice::Invoice on success and a crate::lightning_invoice::ParseOrSemanticError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_InvoiceParseOrSemanticErrorZ { + /** + * The contents of this CResult_InvoiceParseOrSemanticErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_InvoiceParseOrSemanticErrorZPtr contents; + /** + * Whether this CResult_InvoiceParseOrSemanticErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_InvoiceParseOrSemanticErrorZ; + + + +/** + * Represents a signed [`RawInvoice`] with cached hash. The signature is not checked and may be + * invalid. * - * Clones can be made and all futures cloned from the same source will complete at the same time. + * # Invariants + * The hash has to be either from the deserialized invoice or from the serialized [`RawInvoice`]. */ -typedef struct MUST_USE_STRUCT LDKFuture { +typedef struct MUST_USE_STRUCT LDKSignedRawInvoice { /** * A pointer to the opaque Rust object. * Nearly everywhere, 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; + LDKnativeSignedRawInvoice *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; +} LDKSignedRawInvoice; /** - * A dynamically-allocated array of crate::lightning::util::wakers::Futures of arbitrary size. - * This corresponds to std::vector in C++ + * The contents of CResult_SignedRawInvoiceParseErrorZ */ -typedef struct LDKCVec_FutureZ { +typedef union LDKCResult_SignedRawInvoiceParseErrorZPtr { /** - * 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 LDKFuture *data; + struct LDKSignedRawInvoice *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_FutureZ; + struct LDKParseError *err; +} LDKCResult_SignedRawInvoiceParseErrorZPtr; + +/** + * A CResult_SignedRawInvoiceParseErrorZ represents the result of a fallible operation, + * containing a crate::lightning_invoice::SignedRawInvoice on success and a crate::lightning_invoice::ParseError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_SignedRawInvoiceParseErrorZ { + /** + * The contents of this CResult_SignedRawInvoiceParseErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_SignedRawInvoiceParseErrorZPtr contents; + /** + * Whether this CResult_SignedRawInvoiceParseErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_SignedRawInvoiceParseErrorZ; /** - * A transaction output watched by a [`ChannelMonitor`] for spends on-chain. - * - * Used to convey to a [`Filter`] such an output with a given spending condition. Any transaction - * spending the output must be given to [`ChannelMonitor::block_connected`] either directly or via - * [`Confirm::transactions_confirmed`]. - * - * If `block_hash` is `Some`, this indicates the output was created in the corresponding block and - * may have been spent there. See [`Filter::register_output`] for details. + * Represents an syntactically correct [`Invoice`] for a payment on the lightning network, + * but without the signature information. + * Decoding and encoding should not lead to information loss but may lead to different hashes. * - * [`ChannelMonitor`]: channelmonitor::ChannelMonitor - * [`ChannelMonitor::block_connected`]: channelmonitor::ChannelMonitor::block_connected + * For methods without docs see the corresponding methods in [`Invoice`]. */ -typedef struct MUST_USE_STRUCT LDKWatchedOutput { +typedef struct MUST_USE_STRUCT LDKRawInvoice { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeWatchedOutput *inner; + LDKnativeRawInvoice *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKWatchedOutput; +} LDKRawInvoice; + + /** - * The `Filter` trait defines behavior for indicating chain activity of interest pertaining to - * channels. - * - * This is useful in order to have a [`Watch`] implementation convey to a chain source which - * transactions to be notified of. Notification may take the form of pre-filtering blocks or, in - * the case of [BIP 157]/[BIP 158], only fetching a block if the compact filter matches. If - * receiving full blocks from a chain source, any further filtering is unnecessary. - * - * After an output has been registered, subsequent block retrievals from the chain source must not - * exclude any transactions matching the new criteria nor any in-block descendants of such - * transactions. - * - * Note that use as part of a [`Watch`] implementation involves reentrancy. Therefore, the `Filter` - * should not block on I/O. Implementations should instead queue the newly monitored data to be - * processed later. Then, in order to block until the data has been processed, any [`Watch`] - * invocation that has called the `Filter` must return [`InProgress`]. - * - * [`InProgress`]: ChannelMonitorUpdateStatus::InProgress - * [BIP 157]: https://github.com/bitcoin/bips/blob/master/bip-0157.mediawiki - * [BIP 158]: https://github.com/bitcoin/bips/blob/master/bip-0158.mediawiki + * Recoverable signature */ -typedef struct LDKFilter { +typedef struct MUST_USE_STRUCT LDKInvoiceSignature { /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - void *this_arg; + LDKnativeInvoiceSignature *inner; /** - * Registers interest in a transaction with `txid` and having an output with `script_pubkey` as - * a spending condition. + * Indicates that this is the only struct which contains the same pointer. + * Rust 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 (*register_tx)(const void *this_arg, const uint8_t (*txid)[32], struct LDKu8slice script_pubkey); + bool is_owned; +} LDKInvoiceSignature; + +/** + * A tuple of 3 elements. See the individual fields for the types contained. + */ +typedef struct LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ { + /** + * The element at position 0 + */ + struct LDKRawInvoice a; + /** + * The element at position 1 + */ + struct LDKThirtyTwoBytes b; + /** + * The element at position 2 + */ + struct LDKInvoiceSignature c; +} LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ; + + + +/** + * Payee public key + */ +typedef struct MUST_USE_STRUCT LDKPayeePubKey { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativePayeePubKey *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKPayeePubKey; + +/** + * The contents of CResult_PayeePubKeyErrorZ + */ +typedef union LDKCResult_PayeePubKeyErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKPayeePubKey *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + enum LDKSecp256k1Error *err; +} LDKCResult_PayeePubKeyErrorZPtr; + +/** + * A CResult_PayeePubKeyErrorZ represents the result of a fallible operation, + * containing a crate::lightning_invoice::PayeePubKey on success and a crate::c_types::Secp256k1Error on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_PayeePubKeyErrorZ { + /** + * The contents of this CResult_PayeePubKeyErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_PayeePubKeyErrorZPtr contents; + /** + * Whether this CResult_PayeePubKeyErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_PayeePubKeyErrorZ; + + + +/** + * Private routing information + * + * # Invariants + * The encoded route has to be <1024 5bit characters long (<=639 bytes or <=12 hops) + * + */ +typedef struct MUST_USE_STRUCT LDKPrivateRoute { /** - * Registers interest in spends of a transaction output. - * - * Note that this method might be called during processing of a new block. You therefore need - * to ensure that also dependent output spents within an already connected block are correctly - * handled, e.g., by re-scanning the block in question whenever new outputs have been - * registered mid-processing. + * A pointer to the opaque Rust object. + * Nearly everywhere, 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 (*register_output)(const void *this_arg, struct LDKWatchedOutput output); + LDKnativePrivateRoute *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); -} LDKFilter; + bool is_owned; +} LDKPrivateRoute; /** - * An enum which can either contain a crate::lightning::chain::Filter or not + * A dynamically-allocated array of crate::lightning_invoice::PrivateRoutes of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef enum LDKCOption_FilterZ_Tag { - /** - * When we're in this state, this COption_FilterZ contains a crate::lightning::chain::Filter - */ - LDKCOption_FilterZ_Some, +typedef struct LDKCVec_PrivateRouteZ { /** - * When we're in this state, this COption_FilterZ contains nothing + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - LDKCOption_FilterZ_None, + struct LDKPrivateRoute *data; /** - * Must be last for serialization purposes + * The number of elements pointed to by `data`. */ - LDKCOption_FilterZ_Sentinel, -} LDKCOption_FilterZ_Tag; - -typedef struct LDKCOption_FilterZ { - LDKCOption_FilterZ_Tag tag; - union { - struct { - struct LDKFilter some; - }; - }; -} LDKCOption_FilterZ; + uintptr_t datalen; +} LDKCVec_PrivateRouteZ; /** - * A read-only reference to a current ChannelMonitor. + * A timestamp that refers to a date after 1 January 1970. * - * Note that this holds a mutex in [`ChainMonitor`] and may block other events until it is - * released. + * # Invariants + * + * The Unix timestamp representing the stored time has to be positive and no greater than + * [`MAX_TIMESTAMP`]. */ -typedef struct MUST_USE_STRUCT LDKLockedChannelMonitor { +typedef struct MUST_USE_STRUCT LDKPositiveTimestamp { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeLockedChannelMonitor *inner; + LDKnativePositiveTimestamp *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKLockedChannelMonitor; +} LDKPositiveTimestamp; /** - * The contents of CResult_LockedChannelMonitorNoneZ + * The contents of CResult_PositiveTimestampCreationErrorZ */ -typedef union LDKCResult_LockedChannelMonitorNoneZPtr { +typedef union LDKCResult_PositiveTimestampCreationErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKLockedChannelMonitor *result; + struct LDKPositiveTimestamp *result; /** - * Note that this value is always NULL, as there are no contents in the Err variant + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - void *err; -} LDKCResult_LockedChannelMonitorNoneZPtr; + enum LDKCreationError *err; +} LDKCResult_PositiveTimestampCreationErrorZPtr; /** - * A CResult_LockedChannelMonitorNoneZ represents the result of a fallible operation, - * containing a crate::lightning::chain::chainmonitor::LockedChannelMonitor on success and a () on failure. + * A CResult_PositiveTimestampCreationErrorZ represents the result of a fallible operation, + * containing a crate::lightning_invoice::PositiveTimestamp on success and a crate::lightning_invoice::CreationError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_LockedChannelMonitorNoneZ { +typedef struct LDKCResult_PositiveTimestampCreationErrorZ { /** - * The contents of this CResult_LockedChannelMonitorNoneZ, accessible via either + * The contents of this CResult_PositiveTimestampCreationErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_LockedChannelMonitorNoneZPtr contents; + union LDKCResult_PositiveTimestampCreationErrorZPtr contents; /** - * Whether this CResult_LockedChannelMonitorNoneZ represents a success state. + * Whether this CResult_PositiveTimestampCreationErrorZ represents a success state. */ bool result_ok; -} LDKCResult_LockedChannelMonitorNoneZ; +} LDKCResult_PositiveTimestampCreationErrorZ; /** - * A dynamically-allocated array of crate::lightning::chain::transaction::OutPoints of arbitrary size. - * This corresponds to std::vector in C++ + * The contents of CResult_NoneSemanticErrorZ */ -typedef struct LDKCVec_OutPointZ { +typedef union LDKCResult_NoneSemanticErrorZPtr { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * Note that this value is always NULL, as there are no contents in the OK variant */ - struct LDKOutPoint *data; + void *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_OutPointZ; - - + enum LDKSemanticError *err; +} LDKCResult_NoneSemanticErrorZPtr; /** - * An opaque identifier describing a specific [`Persist`] method call. + * A CResult_NoneSemanticErrorZ represents the result of a fallible operation, + * containing a () on success and a crate::lightning_invoice::SemanticError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct MUST_USE_STRUCT LDKMonitorUpdateId { +typedef struct LDKCResult_NoneSemanticErrorZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, 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_NoneSemanticErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKnativeMonitorUpdateId *inner; + union LDKCResult_NoneSemanticErrorZPtr 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_NoneSemanticErrorZ represents a success state. */ - bool is_owned; -} LDKMonitorUpdateId; + bool result_ok; +} LDKCResult_NoneSemanticErrorZ; /** - * A dynamically-allocated array of crate::lightning::chain::chainmonitor::MonitorUpdateIds of arbitrary size. - * This corresponds to std::vector in C++ + * The contents of CResult_InvoiceSemanticErrorZ */ -typedef struct LDKCVec_MonitorUpdateIdZ { +typedef union LDKCResult_InvoiceSemanticErrorZPtr { /** - * 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 LDKMonitorUpdateId *data; + struct LDKInvoice *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_MonitorUpdateIdZ; + enum LDKSemanticError *err; +} LDKCResult_InvoiceSemanticErrorZPtr; /** - * A tuple of 2 elements. See the individual fields for the types contained. + * A CResult_InvoiceSemanticErrorZ represents the result of a fallible operation, + * containing a crate::lightning_invoice::Invoice on success and a crate::lightning_invoice::SemanticError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ { +typedef struct LDKCResult_InvoiceSemanticErrorZ { /** - * The element at position 0 + * The contents of this CResult_InvoiceSemanticErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKOutPoint a; + union LDKCResult_InvoiceSemanticErrorZPtr contents; /** - * The element at position 1 + * Whether this CResult_InvoiceSemanticErrorZ represents a success state. */ - struct LDKCVec_MonitorUpdateIdZ b; -} LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ; + bool result_ok; +} LDKCResult_InvoiceSemanticErrorZ; /** - * A dynamically-allocated array of crate::c_types::derived::C2Tuple_OutPointCVec_MonitorUpdateIdZZs of arbitrary size. + * A dynamically-allocated array of crate::c_types::Strs of arbitrary size. * This corresponds to std::vector in C++ */ -typedef struct LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ { +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 LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ *data; + struct LDKStr *data; /** * The number of elements pointed to by `data`. */ uintptr_t datalen; -} LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ; +} LDKCVec_AddressZ; + + /** - * All-encompassing standard error type that processing can return + * Description string + * + * # Invariants + * The description can be at most 639 __bytes__ long */ -typedef enum LDKGraphSyncError_Tag { +typedef struct MUST_USE_STRUCT LDKDescription { /** - * 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 + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKGraphSyncError_DecodeError, + LDKnativeDescription *inner; /** - * 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 + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - LDKGraphSyncError_LightningError, + bool is_owned; +} LDKDescription; + +/** + * The contents of CResult_DescriptionCreationErrorZ + */ +typedef union LDKCResult_DescriptionCreationErrorZPtr { /** - * Must be last for serialization purposes + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - LDKGraphSyncError_Sentinel, -} LDKGraphSyncError_Tag; + struct LDKDescription *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + enum LDKCreationError *err; +} LDKCResult_DescriptionCreationErrorZPtr; -typedef struct MUST_USE_STRUCT LDKGraphSyncError { - LDKGraphSyncError_Tag tag; - union { - struct { - struct LDKDecodeError decode_error; - }; - struct { - struct LDKLightningError lightning_error; - }; - }; -} LDKGraphSyncError; +/** + * A CResult_DescriptionCreationErrorZ represents the result of a fallible operation, + * containing a crate::lightning_invoice::Description on success and a crate::lightning_invoice::CreationError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_DescriptionCreationErrorZ { + /** + * The contents of this CResult_DescriptionCreationErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_DescriptionCreationErrorZPtr contents; + /** + * Whether this CResult_DescriptionCreationErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_DescriptionCreationErrorZ; /** - * The contents of CResult_u32GraphSyncErrorZ + * The contents of CResult_PrivateRouteCreationErrorZ */ -typedef union LDKCResult_u32GraphSyncErrorZPtr { +typedef union LDKCResult_PrivateRouteCreationErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - uint32_t *result; + struct LDKPrivateRoute *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; + enum LDKCreationError *err; +} LDKCResult_PrivateRouteCreationErrorZPtr; /** - * A CResult_u32GraphSyncErrorZ represents the result of a fallible operation, - * containing a u32 on success and a crate::lightning_rapid_gossip_sync::error::GraphSyncError on failure. + * A CResult_PrivateRouteCreationErrorZ represents the result of a fallible operation, + * containing a crate::lightning_invoice::PrivateRoute on success and a crate::lightning_invoice::CreationError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_u32GraphSyncErrorZ { +typedef struct LDKCResult_PrivateRouteCreationErrorZ { /** - * The contents of this CResult_u32GraphSyncErrorZ, accessible via either + * The contents of this CResult_PrivateRouteCreationErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_u32GraphSyncErrorZPtr contents; + union LDKCResult_PrivateRouteCreationErrorZPtr contents; /** - * Whether this CResult_u32GraphSyncErrorZ represents a success state. + * Whether this CResult_PrivateRouteCreationErrorZ represents a success state. */ bool result_ok; -} LDKCResult_u32GraphSyncErrorZ; +} LDKCResult_PrivateRouteCreationErrorZ; @@ -13678,6 +13441,129 @@ typedef struct MUST_USE_STRUCT LDKBigSize { bool is_owned; } LDKBigSize; + + +/** + * Proposed use of a channel passed as a parameter to [`Score::channel_penalty_msat`]. + */ +typedef struct MUST_USE_STRUCT LDKChannelUsage { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeChannelUsage *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; +} LDKChannelUsage; + +/** + * An interface used to score payment channels for path finding. + * + *\tScoring is in terms of fees willing to be paid in order to avoid routing through a channel. + */ +typedef struct LDKScore { + /** + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. + */ + void *this_arg; + /** + * Returns the fee in msats willing to be paid to avoid routing `send_amt_msat` through the + * given channel in the direction from `source` to `target`. + * + * The channel's capacity (less any other MPP parts that are also being considered for use in + * the same payment) is given by `capacity_msat`. It may be determined from various sources + * such as a chain data, network gossip, or invoice hints. For invoice hints, a capacity near + * [`u64::max_value`] is given to indicate sufficient capacity for the invoice's full amount. + * Thus, implementations should be overflow-safe. + */ + uint64_t (*channel_penalty_msat)(const void *this_arg, uint64_t short_channel_id, const struct LDKNodeId *NONNULL_PTR source, const struct LDKNodeId *NONNULL_PTR target, struct LDKChannelUsage usage); + /** + * Handles updating channel penalties after failing to route through a channel. + */ + 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, const struct LDKPath *NONNULL_PTR path); + /** + * Handles updating channel penalties after a probe over the given path failed. + */ + 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, const struct LDKPath *NONNULL_PTR path); + /** + * Serialize the object into a byte array + */ + struct LDKCVec_u8Z (*write)(const void *this_arg); + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKScore; + +/** + * A scorer that is accessed under a lock. + * + * Needed so that calls to [`Score::channel_penalty_msat`] in [`find_route`] can be made while + * having shared ownership of a scorer but without requiring internal locking in [`Score`] + * implementations. Internal locking would be detrimental to route finding performance and could + * result in [`Score::channel_penalty_msat`] returning a different value for the same channel. + * + * [`find_route`]: crate::routing::router::find_route + */ +typedef struct LDKLockableScore { + /** + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. + */ + void *this_arg; + /** + * Returns the locked scorer. + */ + struct LDKScore (*lock)(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); +} LDKLockableScore; + +/** + * Refers to a scorer that is accessible under lock and also writeable to disk + * + * We need this trait to be able to pass in a scorer to `lightning-background-processor` that will enable us to + * use the Persister to persist it. + */ +typedef struct LDKWriteableScore { + /** + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. + */ + void *this_arg; + /** + * Implementation of LockableScore for this object. + */ + struct LDKLockableScore LockableScore; + /** + * Serialize the object into a byte array + */ + struct LDKCVec_u8Z (*write)(const void *this_arg); + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKWriteableScore; + /** * Trait that handles persisting a [`ChannelManager`], [`NetworkGraph`], and [`WriteableScore`] to disk. */ @@ -13757,23 +13643,24 @@ typedef struct LDKFutureCallback { /** - * A struct which can be used to select across many [`Future`]s at once without relying on a full - * async context. + * 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 LDKSleeper { +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. */ - LDKnativeSleeper *inner; + LDKnativeFuture *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKSleeper; +} LDKFuture; @@ -14340,13 +14227,6 @@ typedef enum LDKRetry_Tag { * were retried along a route from a single call to [`Router::find_route_with_id`]. */ LDKRetry_Attempts, - /** - * Time elapsed before abandoning retries for a payment. At least one attempt at payment is made; - * see [`PaymentParameters::expiry_time`] to avoid any attempt at payment after a specific time. - * - * [`PaymentParameters::expiry_time`]: crate::routing::router::PaymentParameters::expiry_time - */ - LDKRetry_Timeout, /** * Must be last for serialization purposes */ @@ -14359,9 +14239,6 @@ typedef struct MUST_USE_STRUCT LDKRetry { struct { uintptr_t attempts; }; - struct { - uint64_t timeout; - }; }; } LDKRetry; @@ -15748,81 +15625,6 @@ typedef struct MUST_USE_STRUCT LDKOnionMessageContents { -/** - * FilesystemPersister persists channel data on disk, where each channel's - * data is stored in a file named after its funding outpoint. - * - * Warning: this module does the best it can with calls to persist data, but it - * can only guarantee that the data is passed to the drive. It is up to the - * drive manufacturers to do the actual persistence properly, which they often - * don't (especially on consumer-grade hardware). Therefore, it is up to the - * user to validate their entire storage stack, to ensure the writes are - * persistent. - * Corollary: especially when dealing with larger amounts of money, it is best - * practice to have multiple channel data backups and not rely only on one - * FilesystemPersister. - */ -typedef struct MUST_USE_STRUCT LDKFilesystemPersister { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeFilesystemPersister *inner; - /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. - */ - bool is_owned; -} LDKFilesystemPersister; - - - -/** - * `BackgroundProcessor` takes care of tasks that (1) need to happen periodically to keep - * Rust-Lightning running properly, and (2) either can or should be run in the background. Its - * responsibilities are: - * * Processing [`Event`]s with a user-provided [`EventHandler`]. - * * Monitoring whether the [`ChannelManager`] needs to be re-persisted to disk, and if so, - * writing it to disk/backups by invoking the callback given to it at startup. - * [`ChannelManager`] persistence should be done in the background. - * * Calling [`ChannelManager::timer_tick_occurred`], [`ChainMonitor::rebroadcast_pending_claims`] - * and [`PeerManager::timer_tick_occurred`] at the appropriate intervals. - * * Calling [`NetworkGraph::remove_stale_channels_and_tracking`] (if a [`GossipSync`] with a - * [`NetworkGraph`] is provided to [`BackgroundProcessor::start`]). - * - * It will also call [`PeerManager::process_events`] periodically though this shouldn't be relied - * upon as doing so may result in high latency. - * - * # Note - * - * If [`ChannelManager`] persistence fails and the persisted manager becomes out-of-date, then - * there is a risk of channels force-closing on startup when the manager realizes it's outdated. - * However, as long as [`ChannelMonitor`] backups are sound, no funds besides those used for - * unilateral chain closure fees are at risk. - * - * [`ChannelMonitor`]: lightning::chain::channelmonitor::ChannelMonitor - * [`Event`]: lightning::events::Event - *BackgroundProcessor will immediately stop on drop. It should be stored until shutdown. - */ -typedef struct MUST_USE_STRUCT LDKBackgroundProcessor { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeBackgroundProcessor *inner; - /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. - */ - bool is_owned; -} LDKBackgroundProcessor; - - - /** * The main Rapid Gossip Sync object. * @@ -16729,47 +16531,6 @@ void CResult_BlindedPayInfoDecodeErrorZ_free(struct LDKCResult_BlindedPayInfoDec */ 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 - */ -struct LDKCOption_WriteableScoreZ COption_WriteableScoreZ_some(struct LDKWriteableScore o); - -/** - * Constructs a new COption_WriteableScoreZ containing nothing - */ -struct LDKCOption_WriteableScoreZ COption_WriteableScoreZ_none(void); - -/** - * Frees any resources associated with the crate::lightning::routing::scoring::WriteableScore, if we are in the Some state - */ -void COption_WriteableScoreZ_free(struct LDKCOption_WriteableScoreZ _res); - -/** - * Creates a new CResult_NoneErrorZ in the success state. - */ -struct LDKCResult_NoneErrorZ CResult_NoneErrorZ_ok(void); - -/** - * Creates a new CResult_NoneErrorZ in the error state. - */ -struct LDKCResult_NoneErrorZ CResult_NoneErrorZ_err(enum LDKIOError e); - -/** - * Checks if the given object is currently in the success state - */ -bool CResult_NoneErrorZ_is_ok(const struct LDKCResult_NoneErrorZ *NONNULL_PTR o); - -/** - * Frees any resources used by the CResult_NoneErrorZ. - */ -void CResult_NoneErrorZ_free(struct LDKCResult_NoneErrorZ _res); - -/** - * Creates a new CResult_NoneErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKCResult_NoneErrorZ CResult_NoneErrorZ_clone(const struct LDKCResult_NoneErrorZ *NONNULL_PTR orig); - /** * Frees the buffer pointed to by `data` if `datalen` is non-0. */ @@ -18495,41 +18256,6 @@ void CResult_TransactionNoneZ_free(struct LDKCResult_TransactionNoneZ _res); */ struct LDKCResult_TransactionNoneZ CResult_TransactionNoneZ_clone(const struct LDKCResult_TransactionNoneZ *NONNULL_PTR orig); -/** - * Creates a new C2Tuple_BlockHashChannelMonitorZ from the contained elements. - */ -struct LDKC2Tuple_BlockHashChannelMonitorZ C2Tuple_BlockHashChannelMonitorZ_new(struct LDKThirtyTwoBytes a, struct LDKChannelMonitor b); - -/** - * Frees any resources used by the C2Tuple_BlockHashChannelMonitorZ. - */ -void C2Tuple_BlockHashChannelMonitorZ_free(struct LDKC2Tuple_BlockHashChannelMonitorZ _res); - -/** - * Frees the buffer pointed to by `data` if `datalen` is non-0. - */ -void CVec_C2Tuple_BlockHashChannelMonitorZZ_free(struct LDKCVec_C2Tuple_BlockHashChannelMonitorZZ _res); - -/** - * Creates a new CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ in the success state. - */ -struct LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(struct LDKCVec_C2Tuple_BlockHashChannelMonitorZZ o); - -/** - * Creates a new CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ in the error state. - */ -struct LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(enum LDKIOError e); - -/** - * Checks if the given object is currently in the success state - */ -bool CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_is_ok(const struct LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR o); - -/** - * Frees any resources used by the CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ. - */ -void CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(struct LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res); - /** * Constructs a new COption_u16Z containing a u16 */ @@ -19470,6 +19196,16 @@ void CVec_TransactionOutputsZ_free(struct LDKCVec_TransactionOutputsZ _res); */ void CVec_BalanceZ_free(struct LDKCVec_BalanceZ _res); +/** + * Creates a new C2Tuple_BlockHashChannelMonitorZ from the contained elements. + */ +struct LDKC2Tuple_BlockHashChannelMonitorZ C2Tuple_BlockHashChannelMonitorZ_new(struct LDKThirtyTwoBytes a, struct LDKChannelMonitor b); + +/** + * Frees any resources used by the C2Tuple_BlockHashChannelMonitorZ. + */ +void C2Tuple_BlockHashChannelMonitorZ_free(struct LDKC2Tuple_BlockHashChannelMonitorZ _res); + /** * Creates a new CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ in the success state. */ @@ -19785,264 +19521,50 @@ void CResult_BlindedHopDecodeErrorZ_free(struct LDKCResult_BlindedHopDecodeError struct LDKCResult_BlindedHopDecodeErrorZ CResult_BlindedHopDecodeErrorZ_clone(const struct LDKCResult_BlindedHopDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_SiPrefixParseErrorZ in the success state. - */ -struct LDKCResult_SiPrefixParseErrorZ CResult_SiPrefixParseErrorZ_ok(enum LDKSiPrefix o); - -/** - * Creates a new CResult_SiPrefixParseErrorZ in the error state. - */ -struct LDKCResult_SiPrefixParseErrorZ CResult_SiPrefixParseErrorZ_err(struct LDKParseError e); - -/** - * Checks if the given object is currently in the success state - */ -bool CResult_SiPrefixParseErrorZ_is_ok(const struct LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR o); - -/** - * Frees any resources used by the CResult_SiPrefixParseErrorZ. - */ -void CResult_SiPrefixParseErrorZ_free(struct LDKCResult_SiPrefixParseErrorZ _res); - -/** - * Creates a new CResult_SiPrefixParseErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKCResult_SiPrefixParseErrorZ CResult_SiPrefixParseErrorZ_clone(const struct LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR orig); - -/** - * Creates a new CResult_InvoiceParseOrSemanticErrorZ in the success state. - */ -struct LDKCResult_InvoiceParseOrSemanticErrorZ CResult_InvoiceParseOrSemanticErrorZ_ok(struct LDKInvoice o); - -/** - * Creates a new CResult_InvoiceParseOrSemanticErrorZ in the error state. - */ -struct LDKCResult_InvoiceParseOrSemanticErrorZ CResult_InvoiceParseOrSemanticErrorZ_err(struct LDKParseOrSemanticError e); - -/** - * Checks if the given object is currently in the success state - */ -bool CResult_InvoiceParseOrSemanticErrorZ_is_ok(const struct LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR o); - -/** - * Frees any resources used by the CResult_InvoiceParseOrSemanticErrorZ. - */ -void CResult_InvoiceParseOrSemanticErrorZ_free(struct LDKCResult_InvoiceParseOrSemanticErrorZ _res); - -/** - * Creates a new CResult_InvoiceParseOrSemanticErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKCResult_InvoiceParseOrSemanticErrorZ CResult_InvoiceParseOrSemanticErrorZ_clone(const struct LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR orig); - -/** - * Creates a new CResult_SignedRawInvoiceParseErrorZ in the success state. - */ -struct LDKCResult_SignedRawInvoiceParseErrorZ CResult_SignedRawInvoiceParseErrorZ_ok(struct LDKSignedRawInvoice o); - -/** - * Creates a new CResult_SignedRawInvoiceParseErrorZ in the error state. - */ -struct LDKCResult_SignedRawInvoiceParseErrorZ CResult_SignedRawInvoiceParseErrorZ_err(struct LDKParseError e); - -/** - * Checks if the given object is currently in the success state - */ -bool CResult_SignedRawInvoiceParseErrorZ_is_ok(const struct LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR o); - -/** - * Frees any resources used by the CResult_SignedRawInvoiceParseErrorZ. - */ -void CResult_SignedRawInvoiceParseErrorZ_free(struct LDKCResult_SignedRawInvoiceParseErrorZ _res); - -/** - * Creates a new CResult_SignedRawInvoiceParseErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKCResult_SignedRawInvoiceParseErrorZ CResult_SignedRawInvoiceParseErrorZ_clone(const struct LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR orig); - -/** - * Creates a new tuple which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(const struct LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR orig); - -/** - * Creates a new C3Tuple_RawInvoice_u832InvoiceSignatureZ from the contained elements. - */ -struct LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(struct LDKRawInvoice a, struct LDKThirtyTwoBytes b, struct LDKInvoiceSignature c); - -/** - * Frees any resources used by the C3Tuple_RawInvoice_u832InvoiceSignatureZ. - */ -void C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(struct LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res); - -/** - * Creates a new CResult_PayeePubKeyErrorZ in the success state. - */ -struct LDKCResult_PayeePubKeyErrorZ CResult_PayeePubKeyErrorZ_ok(struct LDKPayeePubKey o); - -/** - * Creates a new CResult_PayeePubKeyErrorZ in the error state. - */ -struct LDKCResult_PayeePubKeyErrorZ CResult_PayeePubKeyErrorZ_err(enum LDKSecp256k1Error e); - -/** - * Checks if the given object is currently in the success state - */ -bool CResult_PayeePubKeyErrorZ_is_ok(const struct LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR o); - -/** - * Frees any resources used by the CResult_PayeePubKeyErrorZ. - */ -void CResult_PayeePubKeyErrorZ_free(struct LDKCResult_PayeePubKeyErrorZ _res); - -/** - * Creates a new CResult_PayeePubKeyErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKCResult_PayeePubKeyErrorZ CResult_PayeePubKeyErrorZ_clone(const struct LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR orig); - -/** - * Frees the buffer pointed to by `data` if `datalen` is non-0. - */ -void CVec_PrivateRouteZ_free(struct LDKCVec_PrivateRouteZ _res); - -/** - * Creates a new CResult_PositiveTimestampCreationErrorZ in the success state. - */ -struct LDKCResult_PositiveTimestampCreationErrorZ CResult_PositiveTimestampCreationErrorZ_ok(struct LDKPositiveTimestamp o); - -/** - * Creates a new CResult_PositiveTimestampCreationErrorZ in the error state. - */ -struct LDKCResult_PositiveTimestampCreationErrorZ CResult_PositiveTimestampCreationErrorZ_err(enum LDKCreationError e); - -/** - * Checks if the given object is currently in the success state - */ -bool CResult_PositiveTimestampCreationErrorZ_is_ok(const struct LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR o); - -/** - * Frees any resources used by the CResult_PositiveTimestampCreationErrorZ. - */ -void CResult_PositiveTimestampCreationErrorZ_free(struct LDKCResult_PositiveTimestampCreationErrorZ _res); - -/** - * Creates a new CResult_PositiveTimestampCreationErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKCResult_PositiveTimestampCreationErrorZ CResult_PositiveTimestampCreationErrorZ_clone(const struct LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR orig); - -/** - * Creates a new CResult_NoneSemanticErrorZ in the success state. - */ -struct LDKCResult_NoneSemanticErrorZ CResult_NoneSemanticErrorZ_ok(void); - -/** - * Creates a new CResult_NoneSemanticErrorZ in the error state. - */ -struct LDKCResult_NoneSemanticErrorZ CResult_NoneSemanticErrorZ_err(enum LDKSemanticError e); - -/** - * Checks if the given object is currently in the success state - */ -bool CResult_NoneSemanticErrorZ_is_ok(const struct LDKCResult_NoneSemanticErrorZ *NONNULL_PTR o); - -/** - * Frees any resources used by the CResult_NoneSemanticErrorZ. - */ -void CResult_NoneSemanticErrorZ_free(struct LDKCResult_NoneSemanticErrorZ _res); - -/** - * Creates a new CResult_NoneSemanticErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKCResult_NoneSemanticErrorZ CResult_NoneSemanticErrorZ_clone(const struct LDKCResult_NoneSemanticErrorZ *NONNULL_PTR orig); - -/** - * Creates a new CResult_InvoiceSemanticErrorZ in the success state. - */ -struct LDKCResult_InvoiceSemanticErrorZ CResult_InvoiceSemanticErrorZ_ok(struct LDKInvoice o); - -/** - * Creates a new CResult_InvoiceSemanticErrorZ in the error state. - */ -struct LDKCResult_InvoiceSemanticErrorZ CResult_InvoiceSemanticErrorZ_err(enum LDKSemanticError e); - -/** - * Checks if the given object is currently in the success state - */ -bool CResult_InvoiceSemanticErrorZ_is_ok(const struct LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR o); - -/** - * Frees any resources used by the CResult_InvoiceSemanticErrorZ. - */ -void CResult_InvoiceSemanticErrorZ_free(struct LDKCResult_InvoiceSemanticErrorZ _res); - -/** - * Creates a new CResult_InvoiceSemanticErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -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. + * Creates a new CResult_u32GraphSyncErrorZ in the success state. */ -struct LDKCResult_DescriptionCreationErrorZ CResult_DescriptionCreationErrorZ_ok(struct LDKDescription o); +struct LDKCResult_u32GraphSyncErrorZ CResult_u32GraphSyncErrorZ_ok(uint32_t o); /** - * Creates a new CResult_DescriptionCreationErrorZ in the error state. + * Creates a new CResult_u32GraphSyncErrorZ in the error state. */ -struct LDKCResult_DescriptionCreationErrorZ CResult_DescriptionCreationErrorZ_err(enum LDKCreationError e); +struct LDKCResult_u32GraphSyncErrorZ CResult_u32GraphSyncErrorZ_err(struct LDKGraphSyncError e); /** * Checks if the given object is currently in the success state */ -bool CResult_DescriptionCreationErrorZ_is_ok(const struct LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR o); - -/** - * Frees any resources used by the CResult_DescriptionCreationErrorZ. - */ -void CResult_DescriptionCreationErrorZ_free(struct LDKCResult_DescriptionCreationErrorZ _res); +bool CResult_u32GraphSyncErrorZ_is_ok(const struct LDKCResult_u32GraphSyncErrorZ *NONNULL_PTR o); /** - * Creates a new CResult_DescriptionCreationErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Frees any resources used by the CResult_u32GraphSyncErrorZ. */ -struct LDKCResult_DescriptionCreationErrorZ CResult_DescriptionCreationErrorZ_clone(const struct LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR orig); +void CResult_u32GraphSyncErrorZ_free(struct LDKCResult_u32GraphSyncErrorZ _res); /** - * Creates a new CResult_PrivateRouteCreationErrorZ in the success state. + * Creates a new CResult_NoneErrorZ in the success state. */ -struct LDKCResult_PrivateRouteCreationErrorZ CResult_PrivateRouteCreationErrorZ_ok(struct LDKPrivateRoute o); +struct LDKCResult_NoneErrorZ CResult_NoneErrorZ_ok(void); /** - * Creates a new CResult_PrivateRouteCreationErrorZ in the error state. + * Creates a new CResult_NoneErrorZ in the error state. */ -struct LDKCResult_PrivateRouteCreationErrorZ CResult_PrivateRouteCreationErrorZ_err(enum LDKCreationError e); +struct LDKCResult_NoneErrorZ CResult_NoneErrorZ_err(enum LDKIOError e); /** * Checks if the given object is currently in the success state */ -bool CResult_PrivateRouteCreationErrorZ_is_ok(const struct LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR o); +bool CResult_NoneErrorZ_is_ok(const struct LDKCResult_NoneErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_PrivateRouteCreationErrorZ. + * Frees any resources used by the CResult_NoneErrorZ. */ -void CResult_PrivateRouteCreationErrorZ_free(struct LDKCResult_PrivateRouteCreationErrorZ _res); +void CResult_NoneErrorZ_free(struct LDKCResult_NoneErrorZ _res); /** - * Creates a new CResult_PrivateRouteCreationErrorZ which has the same data as `orig` + * Creates a new CResult_NoneErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_PrivateRouteCreationErrorZ CResult_PrivateRouteCreationErrorZ_clone(const struct LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR orig); +struct LDKCResult_NoneErrorZ CResult_NoneErrorZ_clone(const struct LDKCResult_NoneErrorZ *NONNULL_PTR orig); /** * Creates a new CResult_NetAddressDecodeErrorZ in the success state. @@ -20974,6 +20496,72 @@ void CResult_GossipTimestampFilterDecodeErrorZ_free(struct LDKCResult_GossipTime */ struct LDKCResult_GossipTimestampFilterDecodeErrorZ CResult_GossipTimestampFilterDecodeErrorZ_clone(const struct LDKCResult_GossipTimestampFilterDecodeErrorZ *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); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ_free(struct LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ _res); + /** * Frees the buffer pointed to by `data` if `datalen` is non-0. */ @@ -21006,95 +20594,264 @@ void CResult_InvoiceSignOrCreationErrorZ_free(struct LDKCResult_InvoiceSignOrCre struct LDKCResult_InvoiceSignOrCreationErrorZ CResult_InvoiceSignOrCreationErrorZ_clone(const struct LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR orig); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Creates a new CResult_SiPrefixParseErrorZ in the success state. */ -void CVec_FutureZ_free(struct LDKCVec_FutureZ _res); +struct LDKCResult_SiPrefixParseErrorZ CResult_SiPrefixParseErrorZ_ok(enum LDKSiPrefix o); /** - * Constructs a new COption_FilterZ containing a crate::lightning::chain::Filter + * Creates a new CResult_SiPrefixParseErrorZ in the error state. */ -struct LDKCOption_FilterZ COption_FilterZ_some(struct LDKFilter o); +struct LDKCResult_SiPrefixParseErrorZ CResult_SiPrefixParseErrorZ_err(struct LDKParseError e); /** - * Constructs a new COption_FilterZ containing nothing + * Checks if the given object is currently in the success state */ -struct LDKCOption_FilterZ COption_FilterZ_none(void); +bool CResult_SiPrefixParseErrorZ_is_ok(const struct LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR o); /** - * Frees any resources associated with the crate::lightning::chain::Filter, if we are in the Some state + * Frees any resources used by the CResult_SiPrefixParseErrorZ. */ -void COption_FilterZ_free(struct LDKCOption_FilterZ _res); +void CResult_SiPrefixParseErrorZ_free(struct LDKCResult_SiPrefixParseErrorZ _res); /** - * Creates a new CResult_LockedChannelMonitorNoneZ in the success state. + * Creates a new CResult_SiPrefixParseErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_LockedChannelMonitorNoneZ CResult_LockedChannelMonitorNoneZ_ok(struct LDKLockedChannelMonitor o); +struct LDKCResult_SiPrefixParseErrorZ CResult_SiPrefixParseErrorZ_clone(const struct LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_LockedChannelMonitorNoneZ in the error state. + * Creates a new CResult_InvoiceParseOrSemanticErrorZ in the success state. */ -struct LDKCResult_LockedChannelMonitorNoneZ CResult_LockedChannelMonitorNoneZ_err(void); +struct LDKCResult_InvoiceParseOrSemanticErrorZ CResult_InvoiceParseOrSemanticErrorZ_ok(struct LDKInvoice o); + +/** + * Creates a new CResult_InvoiceParseOrSemanticErrorZ in the error state. + */ +struct LDKCResult_InvoiceParseOrSemanticErrorZ CResult_InvoiceParseOrSemanticErrorZ_err(struct LDKParseOrSemanticError e); /** * Checks if the given object is currently in the success state */ -bool CResult_LockedChannelMonitorNoneZ_is_ok(const struct LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR o); +bool CResult_InvoiceParseOrSemanticErrorZ_is_ok(const struct LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_LockedChannelMonitorNoneZ. + * Frees any resources used by the CResult_InvoiceParseOrSemanticErrorZ. */ -void CResult_LockedChannelMonitorNoneZ_free(struct LDKCResult_LockedChannelMonitorNoneZ _res); +void CResult_InvoiceParseOrSemanticErrorZ_free(struct LDKCResult_InvoiceParseOrSemanticErrorZ _res); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Creates a new CResult_InvoiceParseOrSemanticErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -void CVec_OutPointZ_free(struct LDKCVec_OutPointZ _res); +struct LDKCResult_InvoiceParseOrSemanticErrorZ CResult_InvoiceParseOrSemanticErrorZ_clone(const struct LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR orig); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Creates a new CResult_SignedRawInvoiceParseErrorZ in the success state. */ -void CVec_MonitorUpdateIdZ_free(struct LDKCVec_MonitorUpdateIdZ _res); +struct LDKCResult_SignedRawInvoiceParseErrorZ CResult_SignedRawInvoiceParseErrorZ_ok(struct LDKSignedRawInvoice o); + +/** + * Creates a new CResult_SignedRawInvoiceParseErrorZ in the error state. + */ +struct LDKCResult_SignedRawInvoiceParseErrorZ CResult_SignedRawInvoiceParseErrorZ_err(struct LDKParseError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_SignedRawInvoiceParseErrorZ_is_ok(const struct LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_SignedRawInvoiceParseErrorZ. + */ +void CResult_SignedRawInvoiceParseErrorZ_free(struct LDKCResult_SignedRawInvoiceParseErrorZ _res); + +/** + * Creates a new CResult_SignedRawInvoiceParseErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_SignedRawInvoiceParseErrorZ CResult_SignedRawInvoiceParseErrorZ_clone(const struct LDKCResult_SignedRawInvoiceParseErrorZ *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_OutPointCVec_MonitorUpdateIdZZ C2Tuple_OutPointCVec_MonitorUpdateIdZZ_clone(const struct LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ *NONNULL_PTR orig); +struct LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(const struct LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR orig); /** - * Creates a new C2Tuple_OutPointCVec_MonitorUpdateIdZZ from the contained elements. + * Creates a new C3Tuple_RawInvoice_u832InvoiceSignatureZ from the contained elements. */ -struct LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ C2Tuple_OutPointCVec_MonitorUpdateIdZZ_new(struct LDKOutPoint a, struct LDKCVec_MonitorUpdateIdZ b); +struct LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(struct LDKRawInvoice a, struct LDKThirtyTwoBytes b, struct LDKInvoiceSignature c); /** - * Frees any resources used by the C2Tuple_OutPointCVec_MonitorUpdateIdZZ. + * Frees any resources used by the C3Tuple_RawInvoice_u832InvoiceSignatureZ. */ -void C2Tuple_OutPointCVec_MonitorUpdateIdZZ_free(struct LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ _res); +void C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(struct LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res); + +/** + * Creates a new CResult_PayeePubKeyErrorZ in the success state. + */ +struct LDKCResult_PayeePubKeyErrorZ CResult_PayeePubKeyErrorZ_ok(struct LDKPayeePubKey o); + +/** + * Creates a new CResult_PayeePubKeyErrorZ in the error state. + */ +struct LDKCResult_PayeePubKeyErrorZ CResult_PayeePubKeyErrorZ_err(enum LDKSecp256k1Error e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_PayeePubKeyErrorZ_is_ok(const struct LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_PayeePubKeyErrorZ. + */ +void CResult_PayeePubKeyErrorZ_free(struct LDKCResult_PayeePubKeyErrorZ _res); + +/** + * Creates a new CResult_PayeePubKeyErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_PayeePubKeyErrorZ CResult_PayeePubKeyErrorZ_clone(const struct LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR orig); /** * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -void CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ_free(struct LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ _res); +void CVec_PrivateRouteZ_free(struct LDKCVec_PrivateRouteZ _res); /** - * Creates a new CResult_u32GraphSyncErrorZ in the success state. + * Creates a new CResult_PositiveTimestampCreationErrorZ in the success state. */ -struct LDKCResult_u32GraphSyncErrorZ CResult_u32GraphSyncErrorZ_ok(uint32_t o); +struct LDKCResult_PositiveTimestampCreationErrorZ CResult_PositiveTimestampCreationErrorZ_ok(struct LDKPositiveTimestamp o); /** - * Creates a new CResult_u32GraphSyncErrorZ in the error state. + * Creates a new CResult_PositiveTimestampCreationErrorZ in the error state. */ -struct LDKCResult_u32GraphSyncErrorZ CResult_u32GraphSyncErrorZ_err(struct LDKGraphSyncError e); +struct LDKCResult_PositiveTimestampCreationErrorZ CResult_PositiveTimestampCreationErrorZ_err(enum LDKCreationError e); /** * Checks if the given object is currently in the success state */ -bool CResult_u32GraphSyncErrorZ_is_ok(const struct LDKCResult_u32GraphSyncErrorZ *NONNULL_PTR o); +bool CResult_PositiveTimestampCreationErrorZ_is_ok(const struct LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_u32GraphSyncErrorZ. + * Frees any resources used by the CResult_PositiveTimestampCreationErrorZ. */ -void CResult_u32GraphSyncErrorZ_free(struct LDKCResult_u32GraphSyncErrorZ _res); +void CResult_PositiveTimestampCreationErrorZ_free(struct LDKCResult_PositiveTimestampCreationErrorZ _res); + +/** + * Creates a new CResult_PositiveTimestampCreationErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_PositiveTimestampCreationErrorZ CResult_PositiveTimestampCreationErrorZ_clone(const struct LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_NoneSemanticErrorZ in the success state. + */ +struct LDKCResult_NoneSemanticErrorZ CResult_NoneSemanticErrorZ_ok(void); + +/** + * Creates a new CResult_NoneSemanticErrorZ in the error state. + */ +struct LDKCResult_NoneSemanticErrorZ CResult_NoneSemanticErrorZ_err(enum LDKSemanticError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_NoneSemanticErrorZ_is_ok(const struct LDKCResult_NoneSemanticErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_NoneSemanticErrorZ. + */ +void CResult_NoneSemanticErrorZ_free(struct LDKCResult_NoneSemanticErrorZ _res); + +/** + * Creates a new CResult_NoneSemanticErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_NoneSemanticErrorZ CResult_NoneSemanticErrorZ_clone(const struct LDKCResult_NoneSemanticErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_InvoiceSemanticErrorZ in the success state. + */ +struct LDKCResult_InvoiceSemanticErrorZ CResult_InvoiceSemanticErrorZ_ok(struct LDKInvoice o); + +/** + * Creates a new CResult_InvoiceSemanticErrorZ in the error state. + */ +struct LDKCResult_InvoiceSemanticErrorZ CResult_InvoiceSemanticErrorZ_err(enum LDKSemanticError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_InvoiceSemanticErrorZ_is_ok(const struct LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_InvoiceSemanticErrorZ. + */ +void CResult_InvoiceSemanticErrorZ_free(struct LDKCResult_InvoiceSemanticErrorZ _res); + +/** + * Creates a new CResult_InvoiceSemanticErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +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. + */ +struct LDKCResult_DescriptionCreationErrorZ CResult_DescriptionCreationErrorZ_ok(struct LDKDescription o); + +/** + * Creates a new CResult_DescriptionCreationErrorZ in the error state. + */ +struct LDKCResult_DescriptionCreationErrorZ CResult_DescriptionCreationErrorZ_err(enum LDKCreationError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_DescriptionCreationErrorZ_is_ok(const struct LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_DescriptionCreationErrorZ. + */ +void CResult_DescriptionCreationErrorZ_free(struct LDKCResult_DescriptionCreationErrorZ _res); + +/** + * Creates a new CResult_DescriptionCreationErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_DescriptionCreationErrorZ CResult_DescriptionCreationErrorZ_clone(const struct LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_PrivateRouteCreationErrorZ in the success state. + */ +struct LDKCResult_PrivateRouteCreationErrorZ CResult_PrivateRouteCreationErrorZ_ok(struct LDKPrivateRoute o); + +/** + * Creates a new CResult_PrivateRouteCreationErrorZ in the error state. + */ +struct LDKCResult_PrivateRouteCreationErrorZ CResult_PrivateRouteCreationErrorZ_err(enum LDKCreationError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_PrivateRouteCreationErrorZ_is_ok(const struct LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_PrivateRouteCreationErrorZ. + */ +void CResult_PrivateRouteCreationErrorZ_free(struct LDKCResult_PrivateRouteCreationErrorZ _res); + +/** + * Creates a new CResult_PrivateRouteCreationErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_PrivateRouteCreationErrorZ CResult_PrivateRouteCreationErrorZ_clone(const struct LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR orig); /** * Frees any resources used by the APIError @@ -21287,50 +21044,6 @@ struct LDKFuture Future_clone(const struct LDKFuture *NONNULL_PTR orig); */ 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 */ @@ -31024,11 +30737,6 @@ struct LDKRetry Retry_clone(const struct LDKRetry *NONNULL_PTR orig); */ struct LDKRetry Retry_attempts(uintptr_t a); -/** - * Utility method to constructs a new Timeout-variant Retry - */ -struct LDKRetry Retry_timeout(uint64_t a); - /** * Checks if two Retrys contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. @@ -31459,11 +31167,6 @@ MUST_USE_RES struct LDKOfferFeatures Offer_features(const struct LDKOffer *NONNU */ 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. @@ -31548,11 +31251,6 @@ MUST_USE_RES struct LDKPrintableString Refund_description(const struct LDKRefund */ 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. @@ -32492,26 +32190,6 @@ void NetworkGraph_channel_failed_permanent(const struct LDKNetworkGraph *NONNULL */ void NetworkGraph_node_failed_permanent(const struct LDKNetworkGraph *NONNULL_PTR this_arg, struct LDKPublicKey node_id); -/** - * Removes information about channels that we haven't heard any updates about in some time. - * This can be used regularly to prune the network graph of channels that likely no longer - * exist. - * - * While there is no formal requirement that nodes regularly re-broadcast their channel - * updates every two weeks, the non-normative section of BOLT 7 currently suggests that - * pruning occur for updates which are at least two weeks old, which we implement here. - * - * Note that for users of the `lightning-background-processor` crate this method may be - * automatically called regularly for you. - * - * This method will also cause us to stop tracking removed nodes and channels if they have been - * in the map for a while so that these can be resynced from gossip in the future. - * - * This method is only available with the `std` feature. See - * [`NetworkGraph::remove_stale_channels_and_tracking_with_time`] for `no-std` use. - */ -void NetworkGraph_remove_stale_channels_and_tracking(const struct LDKNetworkGraph *NONNULL_PTR this_arg); - /** * Removes information about channels that we haven't heard any updates about in some time. * This can be used regularly to prune the network graph of channels that likely no longer @@ -34759,124 +34437,68 @@ void EventsProvider_free(struct LDKEventsProvider this_ptr); void EventHandler_free(struct LDKEventHandler this_ptr); /** - * Frees any resources used by the FilesystemPersister, if is_owned is set and inner is non-NULL. + * Frees any resources used by the GossipSync */ -void FilesystemPersister_free(struct LDKFilesystemPersister this_obj); +void GossipSync_free(struct LDKGossipSync this_ptr); /** - * Initialize a new FilesystemPersister and set the path to the individual channels' - * files. + * Utility method to constructs a new P2P-variant GossipSync */ -MUST_USE_RES struct LDKFilesystemPersister FilesystemPersister_new(struct LDKStr path_to_channel_data); +struct LDKGossipSync GossipSync_p2_p(const struct LDKP2PGossipSync *NONNULL_PTR a); /** - * Get the directory which was provided when this persister was initialized. + * Utility method to constructs a new Rapid-variant GossipSync */ -MUST_USE_RES struct LDKStr FilesystemPersister_get_data_dir(const struct LDKFilesystemPersister *NONNULL_PTR this_arg); +struct LDKGossipSync GossipSync_rapid(const struct LDKRapidGossipSync *NONNULL_PTR a); /** - * Read `ChannelMonitor`s from disk. + * Utility method to constructs a new None-variant GossipSync */ -MUST_USE_RES struct LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ FilesystemPersister_read_channelmonitors(const struct LDKFilesystemPersister *NONNULL_PTR this_arg, struct LDKEntropySource entropy_source, const struct LDKSignerProvider *NONNULL_PTR signer_provider); +struct LDKGossipSync GossipSync_none(void); /** - * Frees any resources used by the BackgroundProcessor, if is_owned is set and inner is non-NULL. + * Frees any resources used by the RapidGossipSync, if is_owned is set and inner is non-NULL. */ -void BackgroundProcessor_free(struct LDKBackgroundProcessor this_obj); +void RapidGossipSync_free(struct LDKRapidGossipSync this_obj); /** - * Frees any resources used by the GossipSync + * Instantiate a new [`RapidGossipSync`] instance. */ -void GossipSync_free(struct LDKGossipSync this_ptr); +MUST_USE_RES struct LDKRapidGossipSync RapidGossipSync_new(const struct LDKNetworkGraph *NONNULL_PTR network_graph, struct LDKLogger logger); /** - * Utility method to constructs a new P2P-variant GossipSync + * 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 + * `current_time_unix`: `Option` optional current timestamp to verify data age */ -struct LDKGossipSync GossipSync_p2_p(const struct LDKP2PGossipSync *NONNULL_PTR a); +MUST_USE_RES struct LDKCResult_u32GraphSyncErrorZ RapidGossipSync_update_network_graph_no_std(const struct LDKRapidGossipSync *NONNULL_PTR this_arg, struct LDKu8slice update_data, struct LDKCOption_u64Z current_time_unix); /** - * Utility method to constructs a new Rapid-variant GossipSync + * Returns whether a rapid gossip sync has completed at least once. */ -struct LDKGossipSync GossipSync_rapid(const struct LDKRapidGossipSync *NONNULL_PTR a); +MUST_USE_RES bool RapidGossipSync_is_initial_sync_complete(const struct LDKRapidGossipSync *NONNULL_PTR this_arg); /** - * Utility method to constructs a new None-variant GossipSync + * Frees any resources used by the GraphSyncError */ -struct LDKGossipSync GossipSync_none(void); +void GraphSyncError_free(struct LDKGraphSyncError this_ptr); /** - * Start a background thread that takes care of responsibilities enumerated in the [top-level - * documentation]. - * - * The thread runs indefinitely unless the object is dropped, [`stop`] is called, or - * [`Persister::persist_manager`] returns an error. In case of an error, the error is retrieved by calling - * either [`join`] or [`stop`]. - * - * # Data Persistence - * - * [`Persister::persist_manager`] is responsible for writing out the [`ChannelManager`] to disk, and/or - * uploading to one or more backup services. See [`ChannelManager::write`] for writing out a - * [`ChannelManager`]. See the `lightning-persister` crate for LDK's - * provided implementation. - * - * [`Persister::persist_graph`] is responsible for writing out the [`NetworkGraph`] to disk, if - * [`GossipSync`] is supplied. See [`NetworkGraph::write`] for writing out a [`NetworkGraph`]. - * See the `lightning-persister` crate for LDK's provided implementation. - * - * Typically, users should either implement [`Persister::persist_manager`] to never return an - * error or call [`join`] and handle any error that may arise. For the latter case, - * `BackgroundProcessor` must be restarted by calling `start` again after handling the error. - * - * # Event Handling - * - * `event_handler` is responsible for handling events that users should be notified of (e.g., - * payment failed). [`BackgroundProcessor`] may decorate the given [`EventHandler`] with common - * functionality implemented by other handlers. - * * [`P2PGossipSync`] if given will update the [`NetworkGraph`] based on payment failures. - * - * # Rapid Gossip Sync - * - * If rapid gossip sync is meant to run at startup, pass [`RapidGossipSync`] via `gossip_sync` - * to indicate that the [`BackgroundProcessor`] should not prune the [`NetworkGraph`] instance - * until the [`RapidGossipSync`] instance completes its first sync. - * - * [top-level documentation]: BackgroundProcessor - * [`join`]: Self::join - * [`stop`]: Self::stop - * [`ChannelManager`]: lightning::ln::channelmanager::ChannelManager - * [`ChannelManager::write`]: lightning::ln::channelmanager::ChannelManager#impl-Writeable - * [`Persister::persist_manager`]: lightning::util::persist::Persister::persist_manager - * [`Persister::persist_graph`]: lightning::util::persist::Persister::persist_graph - * [`NetworkGraph`]: lightning::routing::gossip::NetworkGraph - * [`NetworkGraph::write`]: lightning::routing::gossip::NetworkGraph#impl-Writeable + * Creates a copy of the GraphSyncError */ -MUST_USE_RES struct LDKBackgroundProcessor BackgroundProcessor_start(struct LDKPersister persister, struct LDKEventHandler event_handler, const struct LDKChainMonitor *NONNULL_PTR chain_monitor, const struct LDKChannelManager *NONNULL_PTR channel_manager, struct LDKGossipSync gossip_sync, const struct LDKPeerManager *NONNULL_PTR peer_manager, struct LDKLogger logger, struct LDKCOption_WriteableScoreZ scorer); +struct LDKGraphSyncError GraphSyncError_clone(const struct LDKGraphSyncError *NONNULL_PTR orig); /** - * Join `BackgroundProcessor`'s thread, returning any error that occurred while persisting - * [`ChannelManager`]. - * - * # Panics - * - * This function panics if the background thread has panicked such as while persisting or - * handling events. - * - * [`ChannelManager`]: lightning::ln::channelmanager::ChannelManager + * Utility method to constructs a new DecodeError-variant GraphSyncError */ -MUST_USE_RES struct LDKCResult_NoneErrorZ BackgroundProcessor_join(struct LDKBackgroundProcessor this_arg); +struct LDKGraphSyncError GraphSyncError_decode_error(struct LDKDecodeError a); /** - * Stop `BackgroundProcessor`'s thread, returning any error that occurred while persisting - * [`ChannelManager`]. - * - * # Panics - * - * This function panics if the background thread has panicked such as while persisting or - * handling events. - * - * [`ChannelManager`]: lightning::ln::channelmanager::ChannelManager + * Utility method to constructs a new LightningError-variant GraphSyncError */ -MUST_USE_RES struct LDKCResult_NoneErrorZ BackgroundProcessor_stop(struct LDKBackgroundProcessor this_arg); +struct LDKGraphSyncError GraphSyncError_lightning_error(struct LDKLightningError a); /** * Frees any resources used by the ParseError @@ -35539,16 +35161,6 @@ MUST_USE_RES enum LDKCurrency RawInvoice_currency(const struct LDKRawInvoice *NO */ MUST_USE_RES struct LDKCResult_PositiveTimestampCreationErrorZ PositiveTimestamp_from_unix_timestamp(uint64_t unix_seconds); -/** - * Creates a `PositiveTimestamp` from a [`SystemTime`] with a corresponding Unix timestamp in - * the range `0..=MAX_TIMESTAMP`. - * - * Note that the subsecond part is dropped as it is not representable in BOLT 11 invoices. - * - * Otherwise, returns a [`CreationError::TimestampOutOfBounds`]. - */ -MUST_USE_RES struct LDKCResult_PositiveTimestampCreationErrorZ PositiveTimestamp_from_system_time(uint64_t time); - /** * Creates a `PositiveTimestamp` from a [`Duration`] since the Unix epoch in the range * `0..=MAX_TIMESTAMP`. @@ -35569,11 +35181,6 @@ MUST_USE_RES uint64_t PositiveTimestamp_as_unix_timestamp(const struct LDKPositi */ MUST_USE_RES uint64_t PositiveTimestamp_as_duration_since_epoch(const struct LDKPositiveTimestamp *NONNULL_PTR this_arg); -/** - * Returns the [`SystemTime`] representing the stored time - */ -MUST_USE_RES uint64_t PositiveTimestamp_as_time(const struct LDKPositiveTimestamp *NONNULL_PTR this_arg); - /** * The hash of the [`RawInvoice`] that was signed. */ @@ -35613,11 +35220,6 @@ MUST_USE_RES struct LDKCResult_NoneSemanticErrorZ Invoice_check_signature(const */ MUST_USE_RES struct LDKCResult_InvoiceSemanticErrorZ Invoice_from_signed(struct LDKSignedRawInvoice signed_invoice); -/** - * Returns the `Invoice`'s timestamp (should equal its creation time) - */ -MUST_USE_RES uint64_t Invoice_timestamp(const struct LDKInvoice *NONNULL_PTR this_arg); - /** * Returns the `Invoice`'s timestamp as a duration since the Unix epoch */ @@ -35668,16 +35270,6 @@ MUST_USE_RES struct LDKCOption_DurationZ Invoice_expires_at(const struct LDKInvo */ MUST_USE_RES uint64_t Invoice_expiry_time(const struct LDKInvoice *NONNULL_PTR this_arg); -/** - * Returns whether the invoice has expired. - */ -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. @@ -36067,45 +35659,6 @@ struct LDKCResult_InvoiceSignOrCreationErrorZ create_phantom_invoice(struct LDKC */ struct LDKCResult_InvoiceSignOrCreationErrorZ create_phantom_invoice_with_description_hash(struct LDKCOption_u64Z amt_msat, struct LDKThirtyTwoBytes payment_hash, uint32_t invoice_expiry_delta_secs, struct LDKSha256 description_hash, struct LDKCVec_PhantomRouteHintsZ phantom_route_hints, struct LDKEntropySource entropy_source, struct LDKNodeSigner node_signer, struct LDKLogger logger, enum LDKCurrency network, struct LDKCOption_u16Z min_final_cltv_expiry_delta, uint64_t duration_since_epoch); -/** - * Utility to construct an invoice. Generally, unless you want to do something like a custom - * cltv_expiry, this is what you should be using to create an invoice. The reason being, this - * method stores the invoice's payment secret and preimage in `ChannelManager`, so (a) the user - * doesn't have to store preimage/payment secret information and (b) `ChannelManager` can verify - * that the payment secret is valid when the invoice is paid. - * - * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for - * in excess of the current time. - * - * You can specify a custom `min_final_cltv_expiry_delta`, or let LDK default it to - * [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. The provided expiry must be at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. - * Note that LDK will add a buffer of 3 blocks to the delta to allow for up to a few new block - * confirmations during routing. - * - * [`MIN_FINAL_CLTV_EXPIRY_DETLA`]: lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA - */ -struct LDKCResult_InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager(const struct LDKChannelManager *NONNULL_PTR channelmanager, struct LDKNodeSigner node_signer, struct LDKLogger logger, enum LDKCurrency network, struct LDKCOption_u64Z amt_msat, struct LDKStr description, uint32_t invoice_expiry_delta_secs, struct LDKCOption_u16Z min_final_cltv_expiry_delta); - -/** - * Utility to construct an invoice. Generally, unless you want to do something like a custom - * cltv_expiry, this is what you should be using to create an invoice. The reason being, this - * method stores the invoice's payment secret and preimage in `ChannelManager`, so (a) the user - * doesn't have to store preimage/payment secret information and (b) `ChannelManager` can verify - * that the payment secret is valid when the invoice is paid. - * Use this variant if you want to pass the `description_hash` to the invoice. - * - * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for - * in excess of the current time. - * - * You can specify a custom `min_final_cltv_expiry_delta`, or let LDK default it to - * [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. The provided expiry must be at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. - * Note that LDK will add a buffer of 3 blocks to the delta to allow for up to a few new block - * confirmations during routing. - * - * [`MIN_FINAL_CLTV_EXPIRY_DETLA`]: lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA - */ -struct LDKCResult_InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager_with_description_hash(const struct LDKChannelManager *NONNULL_PTR channelmanager, struct LDKNodeSigner node_signer, struct LDKLogger logger, enum LDKCurrency network, struct LDKCOption_u64Z amt_msat, struct LDKSha256 description_hash, uint32_t invoice_expiry_delta_secs, struct LDKCOption_u16Z min_final_cltv_expiry_delta); - /** * See [`create_invoice_from_channelmanager_with_description_hash`] * This version can be used in a `no_std` environment, where [`std::time::SystemTime`] is not @@ -36173,50 +35726,6 @@ struct LDKStr Currency_to_str(const enum LDKCurrency *NONNULL_PTR o); */ struct LDKStr SiPrefix_to_str(const enum LDKSiPrefix *NONNULL_PTR o); -/** - * Frees any resources used by the RapidGossipSync, if is_owned is set and inner is non-NULL. - */ -void RapidGossipSync_free(struct LDKRapidGossipSync this_obj); - -/** - * Instantiate a new [`RapidGossipSync`] instance. - */ -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 - * `current_time_unix`: `Option` optional current timestamp to verify data age - */ -MUST_USE_RES struct LDKCResult_u32GraphSyncErrorZ RapidGossipSync_update_network_graph_no_std(const struct LDKRapidGossipSync *NONNULL_PTR this_arg, struct LDKu8slice update_data, struct LDKCOption_u64Z current_time_unix); - -/** - * Returns whether a rapid gossip sync has completed at least once. - */ -MUST_USE_RES bool RapidGossipSync_is_initial_sync_complete(const struct LDKRapidGossipSync *NONNULL_PTR this_arg); - -/** - * Frees any resources used by the GraphSyncError - */ -void GraphSyncError_free(struct LDKGraphSyncError this_ptr); - -/** - * Creates a copy of the GraphSyncError - */ -struct LDKGraphSyncError GraphSyncError_clone(const struct LDKGraphSyncError *NONNULL_PTR orig); - -/** - * Utility method to constructs a new DecodeError-variant GraphSyncError - */ -struct LDKGraphSyncError GraphSyncError_decode_error(struct LDKDecodeError a); - -/** - * Utility method to constructs a new LightningError-variant GraphSyncError - */ -struct LDKGraphSyncError GraphSyncError_lightning_error(struct LDKLightningError a); - #endif /* LDK_C_BINDINGS_H */ #include "ldk_ver.h" diff --git a/lightning-c-bindings/include/lightningpp.hpp b/lightning-c-bindings/include/lightningpp.hpp index c4ef0ea7..b6f63305 100644 --- a/lightning-c-bindings/include/lightningpp.hpp +++ b/lightning-c-bindings/include/lightningpp.hpp @@ -25,7 +25,6 @@ class ShutdownScript; class InvalidShutdownScript; class UnsignedInvoice; class BlindedPayInfo; -class BackgroundProcessor; class GossipSync; class DefaultRouter; class Router; @@ -110,7 +109,6 @@ class SignerProvider; class InMemorySigner; class KeysManager; class PhantomKeysManager; -class FilesystemPersister; class FailureCode; class ChannelManager; class ChainParameters; @@ -156,26 +154,7 @@ class SendError; class CustomOnionMessageHandler; class BlindedPath; class BlindedHop; -class ParseError; -class ParseOrSemanticError; -class Invoice; -class SignedRawInvoice; -class RawInvoice; -class RawDataPart; -class PositiveTimestamp; -class SiPrefix; -class Currency; -class Sha256; -class Description; -class PayeePubKey; -class ExpiryTime; -class MinFinalCltvExpiryDelta; -class Fallback; -class InvoiceSignature; -class PrivateRoute; -class CreationError; -class SemanticError; -class SignOrCreationError; +class RapidGossipSync; class Persister; class DecodeError; class Init; @@ -223,25 +202,42 @@ class RoutingMessageHandler; class OnionMessageHandler; class UnsignedInvoiceRequest; class InvoiceRequest; +class GraphSyncError; 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 ParseError; +class ParseOrSemanticError; +class Invoice; +class SignedRawInvoice; +class RawInvoice; +class RawDataPart; +class PositiveTimestamp; +class SiPrefix; +class Currency; +class Sha256; +class Description; +class PayeePubKey; +class ExpiryTime; +class MinFinalCltvExpiryDelta; +class Fallback; +class InvoiceSignature; +class PrivateRoute; +class CreationError; +class SemanticError; +class SignOrCreationError; class CResult_LockedChannelMonitorNoneZ; class CVec_C2Tuple_BlindedPayInfoBlindedPathZZ; class CResult_PhantomRouteHintsDecodeErrorZ; -class CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ; +class CResult_FundingCreatedDecodeErrorZ; class CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ; class CVec_C2Tuple_u32TxOutZZ; -class CResult_FundingCreatedDecodeErrorZ; class CResult_ChannelInfoDecodeErrorZ; class CResult_NoneSendErrorZ; class CResult_CVec_u8ZPeerHandleErrorZ; @@ -275,17 +271,16 @@ class CResult_HTLCOutputInCommitmentDecodeErrorZ; class CResult_boolLightningErrorZ; class CResult_NodeIdDecodeErrorZ; class COption_HTLCDestinationZ; -class C2Tuple_BlockHashChannelMonitorZ; +class CResult_NoneRetryableSendFailureZ; class CResult_ShutdownScriptInvalidShutdownScriptZ; class CResult_NodeAnnouncementInfoDecodeErrorZ; class CResult_COption_NetworkUpdateZDecodeErrorZ; -class CResult_NoneRetryableSendFailureZ; +class C2Tuple_BlockHashChannelMonitorZ; class CVec_UpdateFailMalformedHTLCZ; class CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ; class CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ; class CVec_RouteHopZ; class COption_CustomOnionMessageContentsZ; -class CVec_C2Tuple_BlockHashChannelMonitorZZ; class CVec_ThirtyTwoBytesZ; class CResult_ClosingSignedDecodeErrorZ; class CResult_NonePaymentErrorZ; @@ -308,9 +303,9 @@ class CResult_WriteableEcdsaChannelSignerDecodeErrorZ; class CResult_DelayedPaymentOutputDescriptorDecodeErrorZ; class C2Tuple_PaymentHashPaymentIdZ; class CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ; -class CResult_NoneErrorZ; class CResult_InFlightHtlcsDecodeErrorZ; class CResult_COption_HTLCDestinationZDecodeErrorZ; +class CResult_NoneErrorZ; class CResult_SiPrefixParseErrorZ; class CResult_BlindedHopDecodeErrorZ; class CResult_TrustedCommitmentTransactionNoneZ; @@ -331,8 +326,8 @@ class CResult_NonePeerHandleErrorZ; class CResult_PayeePubKeyErrorZ; class CResult_DescriptionCreationErrorZ; class CResult_QueryShortChannelIdsDecodeErrorZ; -class CResult_InvoiceSemanticErrorZ; class CResult_UpdateAddHTLCDecodeErrorZ; +class CResult_InvoiceSemanticErrorZ; class COption_MonitorEventZ; class COption_TypeZ; class CResult_COption_TypeZDecodeErrorZ; @@ -371,7 +366,6 @@ class CResult_ChannelAnnouncementDecodeErrorZ; class CResult_HTLCUpdateDecodeErrorZ; class C2Tuple_SignatureCVec_SignatureZZ; class CVec_OutPointZ; -class COption_WriteableScoreZ; class CResult_PositiveTimestampCreationErrorZ; class C2Tuple__u168_u168Z; class CResult_InvoiceFeaturesDecodeErrorZ; @@ -400,7 +394,6 @@ class CResult_TxCreationKeysDecodeErrorZ; class CResult_NodeAnnouncementDecodeErrorZ; class CVec_ChannelMonitorZ; class CResult_BlindedPathDecodeErrorZ; -class CVec_FutureZ; class CResult_RouteHopDecodeErrorZ; class CVec_BalanceZ; class CResult_FundingSignedDecodeErrorZ; @@ -476,8 +469,8 @@ class COption_ClosureReasonZ; class COption_u128Z; class CVec_APIErrorZ; class CResult_boolPeerHandleErrorZ; -class CVec_AddressZ; class CResult_ChannelUpdateDecodeErrorZ; +class CVec_AddressZ; class CResult_PaymentSecretAPIErrorZ; class CResult_CounterpartyForwardingInfoDecodeErrorZ; class C2Tuple_u32ScriptZ; @@ -845,21 +838,6 @@ class BlindedPayInfo { const LDKBlindedPayInfo* operator &() const { return &self; } const LDKBlindedPayInfo* operator ->() const { return &self; } }; -class BackgroundProcessor { -private: - LDKBackgroundProcessor self; -public: - BackgroundProcessor(const BackgroundProcessor&) = delete; - BackgroundProcessor(BackgroundProcessor&& o) : self(o.self) { memset(&o, 0, sizeof(BackgroundProcessor)); } - BackgroundProcessor(LDKBackgroundProcessor&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBackgroundProcessor)); } - operator LDKBackgroundProcessor() && { LDKBackgroundProcessor res = self; memset(&self, 0, sizeof(LDKBackgroundProcessor)); return res; } - ~BackgroundProcessor() { BackgroundProcessor_free(self); } - BackgroundProcessor& operator=(BackgroundProcessor&& o) { BackgroundProcessor_free(self); self = o.self; memset(&o, 0, sizeof(BackgroundProcessor)); return *this; } - LDKBackgroundProcessor* operator &() { return &self; } - LDKBackgroundProcessor* operator ->() { return &self; } - const LDKBackgroundProcessor* operator &() const { return &self; } - const LDKBackgroundProcessor* operator ->() const { return &self; } -}; class GossipSync { private: LDKGossipSync self; @@ -2606,21 +2584,6 @@ class PhantomKeysManager { const LDKPhantomKeysManager* operator &() const { return &self; } const LDKPhantomKeysManager* operator ->() const { return &self; } }; -class FilesystemPersister { -private: - LDKFilesystemPersister self; -public: - FilesystemPersister(const FilesystemPersister&) = delete; - FilesystemPersister(FilesystemPersister&& o) : self(o.self) { memset(&o, 0, sizeof(FilesystemPersister)); } - FilesystemPersister(LDKFilesystemPersister&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKFilesystemPersister)); } - operator LDKFilesystemPersister() && { LDKFilesystemPersister res = self; memset(&self, 0, sizeof(LDKFilesystemPersister)); return res; } - ~FilesystemPersister() { FilesystemPersister_free(self); } - FilesystemPersister& operator=(FilesystemPersister&& o) { FilesystemPersister_free(self); self = o.self; memset(&o, 0, sizeof(FilesystemPersister)); return *this; } - LDKFilesystemPersister* operator &() { return &self; } - LDKFilesystemPersister* operator ->() { return &self; } - const LDKFilesystemPersister* operator &() const { return &self; } - const LDKFilesystemPersister* operator ->() const { return &self; } -}; class FailureCode { private: LDKFailureCode self; @@ -3372,407 +3335,126 @@ class BlindedHop { const LDKBlindedHop* operator &() const { return &self; } const LDKBlindedHop* operator ->() const { return &self; } }; -class ParseError { +class RapidGossipSync { private: - LDKParseError self; + LDKRapidGossipSync self; public: - ParseError(const ParseError&) = delete; - ParseError(ParseError&& o) : self(o.self) { memset(&o, 0, sizeof(ParseError)); } - ParseError(LDKParseError&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKParseError)); } - operator LDKParseError() && { LDKParseError res = self; memset(&self, 0, sizeof(LDKParseError)); return res; } - ~ParseError() { ParseError_free(self); } - ParseError& operator=(ParseError&& o) { ParseError_free(self); self = o.self; memset(&o, 0, sizeof(ParseError)); return *this; } - LDKParseError* operator &() { return &self; } - LDKParseError* operator ->() { return &self; } - const LDKParseError* operator &() const { return &self; } - const LDKParseError* operator ->() const { return &self; } + 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 ParseOrSemanticError { +class Persister { private: - LDKParseOrSemanticError self; + LDKPersister self; public: - ParseOrSemanticError(const ParseOrSemanticError&) = delete; - ParseOrSemanticError(ParseOrSemanticError&& o) : self(o.self) { memset(&o, 0, sizeof(ParseOrSemanticError)); } - ParseOrSemanticError(LDKParseOrSemanticError&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKParseOrSemanticError)); } - operator LDKParseOrSemanticError() && { LDKParseOrSemanticError res = self; memset(&self, 0, sizeof(LDKParseOrSemanticError)); return res; } - ~ParseOrSemanticError() { ParseOrSemanticError_free(self); } - ParseOrSemanticError& operator=(ParseOrSemanticError&& o) { ParseOrSemanticError_free(self); self = o.self; memset(&o, 0, sizeof(ParseOrSemanticError)); return *this; } - LDKParseOrSemanticError* operator &() { return &self; } - LDKParseOrSemanticError* operator ->() { return &self; } - const LDKParseOrSemanticError* operator &() const { return &self; } - const LDKParseOrSemanticError* operator ->() const { return &self; } + Persister(const Persister&) = delete; + Persister(Persister&& o) : self(o.self) { memset(&o, 0, sizeof(Persister)); } + Persister(LDKPersister&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPersister)); } + operator LDKPersister() && { LDKPersister res = self; memset(&self, 0, sizeof(LDKPersister)); return res; } + ~Persister() { Persister_free(self); } + Persister& operator=(Persister&& o) { Persister_free(self); self = o.self; memset(&o, 0, sizeof(Persister)); return *this; } + LDKPersister* operator &() { return &self; } + LDKPersister* operator ->() { return &self; } + const LDKPersister* operator &() const { return &self; } + const LDKPersister* operator ->() const { return &self; } + /** + * Persist the given ['ChannelManager'] to disk, returning an error if persistence failed. + */ + inline LDK::CResult_NoneErrorZ persist_manager(const struct LDKChannelManager *NONNULL_PTR channel_manager); + /** + * Persist the given [`NetworkGraph`] to disk, returning an error if persistence failed. + */ + inline LDK::CResult_NoneErrorZ persist_graph(const struct LDKNetworkGraph *NONNULL_PTR network_graph); + /** + * Persist the given [`WriteableScore`] to disk, returning an error if persistence failed. + */ + inline LDK::CResult_NoneErrorZ persist_scorer(const struct LDKWriteableScore *NONNULL_PTR scorer); }; -class Invoice { +class DecodeError { private: - LDKInvoice self; + LDKDecodeError self; public: - Invoice(const Invoice&) = delete; - Invoice(Invoice&& o) : self(o.self) { memset(&o, 0, sizeof(Invoice)); } - Invoice(LDKInvoice&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKInvoice)); } - operator LDKInvoice() && { LDKInvoice res = self; memset(&self, 0, sizeof(LDKInvoice)); return res; } - ~Invoice() { Invoice_free(self); } - Invoice& operator=(Invoice&& o) { Invoice_free(self); self = o.self; memset(&o, 0, sizeof(Invoice)); return *this; } - LDKInvoice* operator &() { return &self; } - LDKInvoice* operator ->() { return &self; } - const LDKInvoice* operator &() const { return &self; } - const LDKInvoice* operator ->() const { return &self; } + DecodeError(const DecodeError&) = delete; + DecodeError(DecodeError&& o) : self(o.self) { memset(&o, 0, sizeof(DecodeError)); } + DecodeError(LDKDecodeError&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKDecodeError)); } + operator LDKDecodeError() && { LDKDecodeError res = self; memset(&self, 0, sizeof(LDKDecodeError)); return res; } + ~DecodeError() { DecodeError_free(self); } + DecodeError& operator=(DecodeError&& o) { DecodeError_free(self); self = o.self; memset(&o, 0, sizeof(DecodeError)); return *this; } + LDKDecodeError* operator &() { return &self; } + LDKDecodeError* operator ->() { return &self; } + const LDKDecodeError* operator &() const { return &self; } + const LDKDecodeError* operator ->() const { return &self; } }; -class SignedRawInvoice { +class Init { private: - LDKSignedRawInvoice self; + LDKInit self; public: - SignedRawInvoice(const SignedRawInvoice&) = delete; - SignedRawInvoice(SignedRawInvoice&& o) : self(o.self) { memset(&o, 0, sizeof(SignedRawInvoice)); } - SignedRawInvoice(LDKSignedRawInvoice&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKSignedRawInvoice)); } - operator LDKSignedRawInvoice() && { LDKSignedRawInvoice res = self; memset(&self, 0, sizeof(LDKSignedRawInvoice)); return res; } - ~SignedRawInvoice() { SignedRawInvoice_free(self); } - SignedRawInvoice& operator=(SignedRawInvoice&& o) { SignedRawInvoice_free(self); self = o.self; memset(&o, 0, sizeof(SignedRawInvoice)); return *this; } - LDKSignedRawInvoice* operator &() { return &self; } - LDKSignedRawInvoice* operator ->() { return &self; } - const LDKSignedRawInvoice* operator &() const { return &self; } - const LDKSignedRawInvoice* operator ->() const { return &self; } + Init(const Init&) = delete; + Init(Init&& o) : self(o.self) { memset(&o, 0, sizeof(Init)); } + Init(LDKInit&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKInit)); } + operator LDKInit() && { LDKInit res = self; memset(&self, 0, sizeof(LDKInit)); return res; } + ~Init() { Init_free(self); } + Init& operator=(Init&& o) { Init_free(self); self = o.self; memset(&o, 0, sizeof(Init)); return *this; } + LDKInit* operator &() { return &self; } + LDKInit* operator ->() { return &self; } + const LDKInit* operator &() const { return &self; } + const LDKInit* operator ->() const { return &self; } }; -class RawInvoice { +class ErrorMessage { private: - LDKRawInvoice self; + LDKErrorMessage self; public: - RawInvoice(const RawInvoice&) = delete; - RawInvoice(RawInvoice&& o) : self(o.self) { memset(&o, 0, sizeof(RawInvoice)); } - RawInvoice(LDKRawInvoice&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKRawInvoice)); } - operator LDKRawInvoice() && { LDKRawInvoice res = self; memset(&self, 0, sizeof(LDKRawInvoice)); return res; } - ~RawInvoice() { RawInvoice_free(self); } - RawInvoice& operator=(RawInvoice&& o) { RawInvoice_free(self); self = o.self; memset(&o, 0, sizeof(RawInvoice)); return *this; } - LDKRawInvoice* operator &() { return &self; } - LDKRawInvoice* operator ->() { return &self; } - const LDKRawInvoice* operator &() const { return &self; } - const LDKRawInvoice* operator ->() const { return &self; } + ErrorMessage(const ErrorMessage&) = delete; + ErrorMessage(ErrorMessage&& o) : self(o.self) { memset(&o, 0, sizeof(ErrorMessage)); } + ErrorMessage(LDKErrorMessage&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKErrorMessage)); } + operator LDKErrorMessage() && { LDKErrorMessage res = self; memset(&self, 0, sizeof(LDKErrorMessage)); return res; } + ~ErrorMessage() { ErrorMessage_free(self); } + ErrorMessage& operator=(ErrorMessage&& o) { ErrorMessage_free(self); self = o.self; memset(&o, 0, sizeof(ErrorMessage)); return *this; } + LDKErrorMessage* operator &() { return &self; } + LDKErrorMessage* operator ->() { return &self; } + const LDKErrorMessage* operator &() const { return &self; } + const LDKErrorMessage* operator ->() const { return &self; } }; -class RawDataPart { +class WarningMessage { private: - LDKRawDataPart self; + LDKWarningMessage self; public: - RawDataPart(const RawDataPart&) = delete; - RawDataPart(RawDataPart&& o) : self(o.self) { memset(&o, 0, sizeof(RawDataPart)); } - RawDataPart(LDKRawDataPart&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKRawDataPart)); } - operator LDKRawDataPart() && { LDKRawDataPart res = self; memset(&self, 0, sizeof(LDKRawDataPart)); return res; } - ~RawDataPart() { RawDataPart_free(self); } - RawDataPart& operator=(RawDataPart&& o) { RawDataPart_free(self); self = o.self; memset(&o, 0, sizeof(RawDataPart)); return *this; } - LDKRawDataPart* operator &() { return &self; } - LDKRawDataPart* operator ->() { return &self; } - const LDKRawDataPart* operator &() const { return &self; } - const LDKRawDataPart* operator ->() const { return &self; } + WarningMessage(const WarningMessage&) = delete; + WarningMessage(WarningMessage&& o) : self(o.self) { memset(&o, 0, sizeof(WarningMessage)); } + WarningMessage(LDKWarningMessage&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKWarningMessage)); } + operator LDKWarningMessage() && { LDKWarningMessage res = self; memset(&self, 0, sizeof(LDKWarningMessage)); return res; } + ~WarningMessage() { WarningMessage_free(self); } + WarningMessage& operator=(WarningMessage&& o) { WarningMessage_free(self); self = o.self; memset(&o, 0, sizeof(WarningMessage)); return *this; } + LDKWarningMessage* operator &() { return &self; } + LDKWarningMessage* operator ->() { return &self; } + const LDKWarningMessage* operator &() const { return &self; } + const LDKWarningMessage* operator ->() const { return &self; } }; -class PositiveTimestamp { +class Ping { private: - LDKPositiveTimestamp self; + LDKPing self; public: - PositiveTimestamp(const PositiveTimestamp&) = delete; - PositiveTimestamp(PositiveTimestamp&& o) : self(o.self) { memset(&o, 0, sizeof(PositiveTimestamp)); } - PositiveTimestamp(LDKPositiveTimestamp&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPositiveTimestamp)); } - operator LDKPositiveTimestamp() && { LDKPositiveTimestamp res = self; memset(&self, 0, sizeof(LDKPositiveTimestamp)); return res; } - ~PositiveTimestamp() { PositiveTimestamp_free(self); } - PositiveTimestamp& operator=(PositiveTimestamp&& o) { PositiveTimestamp_free(self); self = o.self; memset(&o, 0, sizeof(PositiveTimestamp)); return *this; } - LDKPositiveTimestamp* operator &() { return &self; } - LDKPositiveTimestamp* operator ->() { return &self; } - const LDKPositiveTimestamp* operator &() const { return &self; } - const LDKPositiveTimestamp* operator ->() const { return &self; } + Ping(const Ping&) = delete; + Ping(Ping&& o) : self(o.self) { memset(&o, 0, sizeof(Ping)); } + Ping(LDKPing&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPing)); } + operator LDKPing() && { LDKPing res = self; memset(&self, 0, sizeof(LDKPing)); return res; } + ~Ping() { Ping_free(self); } + Ping& operator=(Ping&& o) { Ping_free(self); self = o.self; memset(&o, 0, sizeof(Ping)); return *this; } + LDKPing* operator &() { return &self; } + LDKPing* operator ->() { return &self; } + const LDKPing* operator &() const { return &self; } + const LDKPing* operator ->() const { return &self; } }; -class SiPrefix { +class Pong { private: - LDKSiPrefix self; -public: - SiPrefix(const SiPrefix&) = delete; - SiPrefix(SiPrefix&& o) : self(o.self) { memset(&o, 0, sizeof(SiPrefix)); } - SiPrefix(LDKSiPrefix&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKSiPrefix)); } - operator LDKSiPrefix() && { LDKSiPrefix res = self; memset(&self, 0, sizeof(LDKSiPrefix)); return res; } - SiPrefix& operator=(SiPrefix&& o) { self = o.self; memset(&o, 0, sizeof(SiPrefix)); return *this; } - LDKSiPrefix* operator &() { return &self; } - LDKSiPrefix* operator ->() { return &self; } - const LDKSiPrefix* operator &() const { return &self; } - const LDKSiPrefix* operator ->() const { return &self; } -}; -class Currency { -private: - LDKCurrency self; -public: - Currency(const Currency&) = delete; - Currency(Currency&& o) : self(o.self) { memset(&o, 0, sizeof(Currency)); } - Currency(LDKCurrency&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCurrency)); } - operator LDKCurrency() && { LDKCurrency res = self; memset(&self, 0, sizeof(LDKCurrency)); return res; } - Currency& operator=(Currency&& o) { self = o.self; memset(&o, 0, sizeof(Currency)); return *this; } - LDKCurrency* operator &() { return &self; } - LDKCurrency* operator ->() { return &self; } - const LDKCurrency* operator &() const { return &self; } - const LDKCurrency* operator ->() const { return &self; } -}; -class Sha256 { -private: - LDKSha256 self; -public: - Sha256(const Sha256&) = delete; - Sha256(Sha256&& o) : self(o.self) { memset(&o, 0, sizeof(Sha256)); } - Sha256(LDKSha256&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKSha256)); } - operator LDKSha256() && { LDKSha256 res = self; memset(&self, 0, sizeof(LDKSha256)); return res; } - ~Sha256() { Sha256_free(self); } - Sha256& operator=(Sha256&& o) { Sha256_free(self); self = o.self; memset(&o, 0, sizeof(Sha256)); return *this; } - LDKSha256* operator &() { return &self; } - LDKSha256* operator ->() { return &self; } - const LDKSha256* operator &() const { return &self; } - const LDKSha256* operator ->() const { return &self; } -}; -class Description { -private: - LDKDescription self; -public: - Description(const Description&) = delete; - Description(Description&& o) : self(o.self) { memset(&o, 0, sizeof(Description)); } - Description(LDKDescription&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKDescription)); } - operator LDKDescription() && { LDKDescription res = self; memset(&self, 0, sizeof(LDKDescription)); return res; } - ~Description() { Description_free(self); } - Description& operator=(Description&& o) { Description_free(self); self = o.self; memset(&o, 0, sizeof(Description)); return *this; } - LDKDescription* operator &() { return &self; } - LDKDescription* operator ->() { return &self; } - const LDKDescription* operator &() const { return &self; } - const LDKDescription* operator ->() const { return &self; } -}; -class PayeePubKey { -private: - LDKPayeePubKey self; -public: - PayeePubKey(const PayeePubKey&) = delete; - PayeePubKey(PayeePubKey&& o) : self(o.self) { memset(&o, 0, sizeof(PayeePubKey)); } - PayeePubKey(LDKPayeePubKey&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPayeePubKey)); } - operator LDKPayeePubKey() && { LDKPayeePubKey res = self; memset(&self, 0, sizeof(LDKPayeePubKey)); return res; } - ~PayeePubKey() { PayeePubKey_free(self); } - PayeePubKey& operator=(PayeePubKey&& o) { PayeePubKey_free(self); self = o.self; memset(&o, 0, sizeof(PayeePubKey)); return *this; } - LDKPayeePubKey* operator &() { return &self; } - LDKPayeePubKey* operator ->() { return &self; } - const LDKPayeePubKey* operator &() const { return &self; } - const LDKPayeePubKey* operator ->() const { return &self; } -}; -class ExpiryTime { -private: - LDKExpiryTime self; -public: - ExpiryTime(const ExpiryTime&) = delete; - ExpiryTime(ExpiryTime&& o) : self(o.self) { memset(&o, 0, sizeof(ExpiryTime)); } - ExpiryTime(LDKExpiryTime&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKExpiryTime)); } - operator LDKExpiryTime() && { LDKExpiryTime res = self; memset(&self, 0, sizeof(LDKExpiryTime)); return res; } - ~ExpiryTime() { ExpiryTime_free(self); } - ExpiryTime& operator=(ExpiryTime&& o) { ExpiryTime_free(self); self = o.self; memset(&o, 0, sizeof(ExpiryTime)); return *this; } - LDKExpiryTime* operator &() { return &self; } - LDKExpiryTime* operator ->() { return &self; } - const LDKExpiryTime* operator &() const { return &self; } - const LDKExpiryTime* operator ->() const { return &self; } -}; -class MinFinalCltvExpiryDelta { -private: - LDKMinFinalCltvExpiryDelta self; -public: - MinFinalCltvExpiryDelta(const MinFinalCltvExpiryDelta&) = delete; - MinFinalCltvExpiryDelta(MinFinalCltvExpiryDelta&& o) : self(o.self) { memset(&o, 0, sizeof(MinFinalCltvExpiryDelta)); } - MinFinalCltvExpiryDelta(LDKMinFinalCltvExpiryDelta&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKMinFinalCltvExpiryDelta)); } - operator LDKMinFinalCltvExpiryDelta() && { LDKMinFinalCltvExpiryDelta res = self; memset(&self, 0, sizeof(LDKMinFinalCltvExpiryDelta)); return res; } - ~MinFinalCltvExpiryDelta() { MinFinalCltvExpiryDelta_free(self); } - MinFinalCltvExpiryDelta& operator=(MinFinalCltvExpiryDelta&& o) { MinFinalCltvExpiryDelta_free(self); self = o.self; memset(&o, 0, sizeof(MinFinalCltvExpiryDelta)); return *this; } - LDKMinFinalCltvExpiryDelta* operator &() { return &self; } - LDKMinFinalCltvExpiryDelta* operator ->() { return &self; } - const LDKMinFinalCltvExpiryDelta* operator &() const { return &self; } - const LDKMinFinalCltvExpiryDelta* operator ->() const { return &self; } -}; -class Fallback { -private: - LDKFallback self; -public: - Fallback(const Fallback&) = delete; - Fallback(Fallback&& o) : self(o.self) { memset(&o, 0, sizeof(Fallback)); } - Fallback(LDKFallback&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKFallback)); } - operator LDKFallback() && { LDKFallback res = self; memset(&self, 0, sizeof(LDKFallback)); return res; } - ~Fallback() { Fallback_free(self); } - Fallback& operator=(Fallback&& o) { Fallback_free(self); self = o.self; memset(&o, 0, sizeof(Fallback)); return *this; } - LDKFallback* operator &() { return &self; } - LDKFallback* operator ->() { return &self; } - const LDKFallback* operator &() const { return &self; } - const LDKFallback* operator ->() const { return &self; } -}; -class InvoiceSignature { -private: - LDKInvoiceSignature self; -public: - InvoiceSignature(const InvoiceSignature&) = delete; - InvoiceSignature(InvoiceSignature&& o) : self(o.self) { memset(&o, 0, sizeof(InvoiceSignature)); } - InvoiceSignature(LDKInvoiceSignature&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKInvoiceSignature)); } - operator LDKInvoiceSignature() && { LDKInvoiceSignature res = self; memset(&self, 0, sizeof(LDKInvoiceSignature)); return res; } - ~InvoiceSignature() { InvoiceSignature_free(self); } - InvoiceSignature& operator=(InvoiceSignature&& o) { InvoiceSignature_free(self); self = o.self; memset(&o, 0, sizeof(InvoiceSignature)); return *this; } - LDKInvoiceSignature* operator &() { return &self; } - LDKInvoiceSignature* operator ->() { return &self; } - const LDKInvoiceSignature* operator &() const { return &self; } - const LDKInvoiceSignature* operator ->() const { return &self; } -}; -class PrivateRoute { -private: - LDKPrivateRoute self; -public: - PrivateRoute(const PrivateRoute&) = delete; - PrivateRoute(PrivateRoute&& o) : self(o.self) { memset(&o, 0, sizeof(PrivateRoute)); } - PrivateRoute(LDKPrivateRoute&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPrivateRoute)); } - operator LDKPrivateRoute() && { LDKPrivateRoute res = self; memset(&self, 0, sizeof(LDKPrivateRoute)); return res; } - ~PrivateRoute() { PrivateRoute_free(self); } - PrivateRoute& operator=(PrivateRoute&& o) { PrivateRoute_free(self); self = o.self; memset(&o, 0, sizeof(PrivateRoute)); return *this; } - LDKPrivateRoute* operator &() { return &self; } - LDKPrivateRoute* operator ->() { return &self; } - const LDKPrivateRoute* operator &() const { return &self; } - const LDKPrivateRoute* operator ->() const { return &self; } -}; -class CreationError { -private: - LDKCreationError self; -public: - CreationError(const CreationError&) = delete; - CreationError(CreationError&& o) : self(o.self) { memset(&o, 0, sizeof(CreationError)); } - CreationError(LDKCreationError&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCreationError)); } - operator LDKCreationError() && { LDKCreationError res = self; memset(&self, 0, sizeof(LDKCreationError)); return res; } - CreationError& operator=(CreationError&& o) { self = o.self; memset(&o, 0, sizeof(CreationError)); return *this; } - LDKCreationError* operator &() { return &self; } - LDKCreationError* operator ->() { return &self; } - const LDKCreationError* operator &() const { return &self; } - const LDKCreationError* operator ->() const { return &self; } -}; -class SemanticError { -private: - LDKSemanticError self; -public: - SemanticError(const SemanticError&) = delete; - SemanticError(SemanticError&& o) : self(o.self) { memset(&o, 0, sizeof(SemanticError)); } - SemanticError(LDKSemanticError&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKSemanticError)); } - operator LDKSemanticError() && { LDKSemanticError res = self; memset(&self, 0, sizeof(LDKSemanticError)); return res; } - SemanticError& operator=(SemanticError&& o) { self = o.self; memset(&o, 0, sizeof(SemanticError)); return *this; } - LDKSemanticError* operator &() { return &self; } - LDKSemanticError* operator ->() { return &self; } - const LDKSemanticError* operator &() const { return &self; } - const LDKSemanticError* operator ->() const { return &self; } -}; -class SignOrCreationError { -private: - LDKSignOrCreationError self; -public: - SignOrCreationError(const SignOrCreationError&) = delete; - SignOrCreationError(SignOrCreationError&& o) : self(o.self) { memset(&o, 0, sizeof(SignOrCreationError)); } - SignOrCreationError(LDKSignOrCreationError&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKSignOrCreationError)); } - operator LDKSignOrCreationError() && { LDKSignOrCreationError res = self; memset(&self, 0, sizeof(LDKSignOrCreationError)); return res; } - ~SignOrCreationError() { SignOrCreationError_free(self); } - SignOrCreationError& operator=(SignOrCreationError&& o) { SignOrCreationError_free(self); self = o.self; memset(&o, 0, sizeof(SignOrCreationError)); return *this; } - LDKSignOrCreationError* operator &() { return &self; } - LDKSignOrCreationError* operator ->() { return &self; } - const LDKSignOrCreationError* operator &() const { return &self; } - const LDKSignOrCreationError* operator ->() const { return &self; } -}; -class Persister { -private: - LDKPersister self; -public: - Persister(const Persister&) = delete; - Persister(Persister&& o) : self(o.self) { memset(&o, 0, sizeof(Persister)); } - Persister(LDKPersister&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPersister)); } - operator LDKPersister() && { LDKPersister res = self; memset(&self, 0, sizeof(LDKPersister)); return res; } - ~Persister() { Persister_free(self); } - Persister& operator=(Persister&& o) { Persister_free(self); self = o.self; memset(&o, 0, sizeof(Persister)); return *this; } - LDKPersister* operator &() { return &self; } - LDKPersister* operator ->() { return &self; } - const LDKPersister* operator &() const { return &self; } - const LDKPersister* operator ->() const { return &self; } - /** - * Persist the given ['ChannelManager'] to disk, returning an error if persistence failed. - */ - inline LDK::CResult_NoneErrorZ persist_manager(const struct LDKChannelManager *NONNULL_PTR channel_manager); - /** - * Persist the given [`NetworkGraph`] to disk, returning an error if persistence failed. - */ - inline LDK::CResult_NoneErrorZ persist_graph(const struct LDKNetworkGraph *NONNULL_PTR network_graph); - /** - * Persist the given [`WriteableScore`] to disk, returning an error if persistence failed. - */ - inline LDK::CResult_NoneErrorZ persist_scorer(const struct LDKWriteableScore *NONNULL_PTR scorer); -}; -class DecodeError { -private: - LDKDecodeError self; -public: - DecodeError(const DecodeError&) = delete; - DecodeError(DecodeError&& o) : self(o.self) { memset(&o, 0, sizeof(DecodeError)); } - DecodeError(LDKDecodeError&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKDecodeError)); } - operator LDKDecodeError() && { LDKDecodeError res = self; memset(&self, 0, sizeof(LDKDecodeError)); return res; } - ~DecodeError() { DecodeError_free(self); } - DecodeError& operator=(DecodeError&& o) { DecodeError_free(self); self = o.self; memset(&o, 0, sizeof(DecodeError)); return *this; } - LDKDecodeError* operator &() { return &self; } - LDKDecodeError* operator ->() { return &self; } - const LDKDecodeError* operator &() const { return &self; } - const LDKDecodeError* operator ->() const { return &self; } -}; -class Init { -private: - LDKInit self; -public: - Init(const Init&) = delete; - Init(Init&& o) : self(o.self) { memset(&o, 0, sizeof(Init)); } - Init(LDKInit&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKInit)); } - operator LDKInit() && { LDKInit res = self; memset(&self, 0, sizeof(LDKInit)); return res; } - ~Init() { Init_free(self); } - Init& operator=(Init&& o) { Init_free(self); self = o.self; memset(&o, 0, sizeof(Init)); return *this; } - LDKInit* operator &() { return &self; } - LDKInit* operator ->() { return &self; } - const LDKInit* operator &() const { return &self; } - const LDKInit* operator ->() const { return &self; } -}; -class ErrorMessage { -private: - LDKErrorMessage self; -public: - ErrorMessage(const ErrorMessage&) = delete; - ErrorMessage(ErrorMessage&& o) : self(o.self) { memset(&o, 0, sizeof(ErrorMessage)); } - ErrorMessage(LDKErrorMessage&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKErrorMessage)); } - operator LDKErrorMessage() && { LDKErrorMessage res = self; memset(&self, 0, sizeof(LDKErrorMessage)); return res; } - ~ErrorMessage() { ErrorMessage_free(self); } - ErrorMessage& operator=(ErrorMessage&& o) { ErrorMessage_free(self); self = o.self; memset(&o, 0, sizeof(ErrorMessage)); return *this; } - LDKErrorMessage* operator &() { return &self; } - LDKErrorMessage* operator ->() { return &self; } - const LDKErrorMessage* operator &() const { return &self; } - const LDKErrorMessage* operator ->() const { return &self; } -}; -class WarningMessage { -private: - LDKWarningMessage self; -public: - WarningMessage(const WarningMessage&) = delete; - WarningMessage(WarningMessage&& o) : self(o.self) { memset(&o, 0, sizeof(WarningMessage)); } - WarningMessage(LDKWarningMessage&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKWarningMessage)); } - operator LDKWarningMessage() && { LDKWarningMessage res = self; memset(&self, 0, sizeof(LDKWarningMessage)); return res; } - ~WarningMessage() { WarningMessage_free(self); } - WarningMessage& operator=(WarningMessage&& o) { WarningMessage_free(self); self = o.self; memset(&o, 0, sizeof(WarningMessage)); return *this; } - LDKWarningMessage* operator &() { return &self; } - LDKWarningMessage* operator ->() { return &self; } - const LDKWarningMessage* operator &() const { return &self; } - const LDKWarningMessage* operator ->() const { return &self; } -}; -class Ping { -private: - LDKPing self; -public: - Ping(const Ping&) = delete; - Ping(Ping&& o) : self(o.self) { memset(&o, 0, sizeof(Ping)); } - Ping(LDKPing&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPing)); } - operator LDKPing() && { LDKPing res = self; memset(&self, 0, sizeof(LDKPing)); return res; } - ~Ping() { Ping_free(self); } - Ping& operator=(Ping&& o) { Ping_free(self); self = o.self; memset(&o, 0, sizeof(Ping)); return *this; } - LDKPing* operator &() { return &self; } - LDKPing* operator ->() { return &self; } - const LDKPing* operator &() const { return &self; } - const LDKPing* operator ->() const { return &self; } -}; -class Pong { -private: - LDKPong self; + LDKPong self; public: Pong(const Pong&) = delete; Pong(Pong&& o) : self(o.self) { memset(&o, 0, sizeof(Pong)); } @@ -4600,6 +4282,21 @@ class InvoiceRequest { const LDKInvoiceRequest* operator &() const { return &self; } const LDKInvoiceRequest* 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 Level { private: LDKLevel self; @@ -4682,21 +4379,6 @@ class Future { 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; @@ -4798,50 +4480,316 @@ class LockedChannelMonitor { const LDKLockedChannelMonitor* operator &() const { return &self; } const LDKLockedChannelMonitor* operator ->() const { return &self; } }; -class ChainMonitor { +class ChainMonitor { +private: + LDKChainMonitor self; +public: + ChainMonitor(const ChainMonitor&) = delete; + ChainMonitor(ChainMonitor&& o) : self(o.self) { memset(&o, 0, sizeof(ChainMonitor)); } + ChainMonitor(LDKChainMonitor&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChainMonitor)); } + operator LDKChainMonitor() && { LDKChainMonitor res = self; memset(&self, 0, sizeof(LDKChainMonitor)); return res; } + ~ChainMonitor() { ChainMonitor_free(self); } + ChainMonitor& operator=(ChainMonitor&& o) { ChainMonitor_free(self); self = o.self; memset(&o, 0, sizeof(ChainMonitor)); return *this; } + LDKChainMonitor* operator &() { return &self; } + LDKChainMonitor* operator ->() { return &self; } + const LDKChainMonitor* operator &() const { return &self; } + const LDKChainMonitor* operator ->() const { return &self; } +}; +class ParseError { +private: + LDKParseError self; +public: + ParseError(const ParseError&) = delete; + ParseError(ParseError&& o) : self(o.self) { memset(&o, 0, sizeof(ParseError)); } + ParseError(LDKParseError&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKParseError)); } + operator LDKParseError() && { LDKParseError res = self; memset(&self, 0, sizeof(LDKParseError)); return res; } + ~ParseError() { ParseError_free(self); } + ParseError& operator=(ParseError&& o) { ParseError_free(self); self = o.self; memset(&o, 0, sizeof(ParseError)); return *this; } + LDKParseError* operator &() { return &self; } + LDKParseError* operator ->() { return &self; } + const LDKParseError* operator &() const { return &self; } + const LDKParseError* operator ->() const { return &self; } +}; +class ParseOrSemanticError { +private: + LDKParseOrSemanticError self; +public: + ParseOrSemanticError(const ParseOrSemanticError&) = delete; + ParseOrSemanticError(ParseOrSemanticError&& o) : self(o.self) { memset(&o, 0, sizeof(ParseOrSemanticError)); } + ParseOrSemanticError(LDKParseOrSemanticError&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKParseOrSemanticError)); } + operator LDKParseOrSemanticError() && { LDKParseOrSemanticError res = self; memset(&self, 0, sizeof(LDKParseOrSemanticError)); return res; } + ~ParseOrSemanticError() { ParseOrSemanticError_free(self); } + ParseOrSemanticError& operator=(ParseOrSemanticError&& o) { ParseOrSemanticError_free(self); self = o.self; memset(&o, 0, sizeof(ParseOrSemanticError)); return *this; } + LDKParseOrSemanticError* operator &() { return &self; } + LDKParseOrSemanticError* operator ->() { return &self; } + const LDKParseOrSemanticError* operator &() const { return &self; } + const LDKParseOrSemanticError* operator ->() const { return &self; } +}; +class Invoice { +private: + LDKInvoice self; +public: + Invoice(const Invoice&) = delete; + Invoice(Invoice&& o) : self(o.self) { memset(&o, 0, sizeof(Invoice)); } + Invoice(LDKInvoice&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKInvoice)); } + operator LDKInvoice() && { LDKInvoice res = self; memset(&self, 0, sizeof(LDKInvoice)); return res; } + ~Invoice() { Invoice_free(self); } + Invoice& operator=(Invoice&& o) { Invoice_free(self); self = o.self; memset(&o, 0, sizeof(Invoice)); return *this; } + LDKInvoice* operator &() { return &self; } + LDKInvoice* operator ->() { return &self; } + const LDKInvoice* operator &() const { return &self; } + const LDKInvoice* operator ->() const { return &self; } +}; +class SignedRawInvoice { +private: + LDKSignedRawInvoice self; +public: + SignedRawInvoice(const SignedRawInvoice&) = delete; + SignedRawInvoice(SignedRawInvoice&& o) : self(o.self) { memset(&o, 0, sizeof(SignedRawInvoice)); } + SignedRawInvoice(LDKSignedRawInvoice&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKSignedRawInvoice)); } + operator LDKSignedRawInvoice() && { LDKSignedRawInvoice res = self; memset(&self, 0, sizeof(LDKSignedRawInvoice)); return res; } + ~SignedRawInvoice() { SignedRawInvoice_free(self); } + SignedRawInvoice& operator=(SignedRawInvoice&& o) { SignedRawInvoice_free(self); self = o.self; memset(&o, 0, sizeof(SignedRawInvoice)); return *this; } + LDKSignedRawInvoice* operator &() { return &self; } + LDKSignedRawInvoice* operator ->() { return &self; } + const LDKSignedRawInvoice* operator &() const { return &self; } + const LDKSignedRawInvoice* operator ->() const { return &self; } +}; +class RawInvoice { +private: + LDKRawInvoice self; +public: + RawInvoice(const RawInvoice&) = delete; + RawInvoice(RawInvoice&& o) : self(o.self) { memset(&o, 0, sizeof(RawInvoice)); } + RawInvoice(LDKRawInvoice&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKRawInvoice)); } + operator LDKRawInvoice() && { LDKRawInvoice res = self; memset(&self, 0, sizeof(LDKRawInvoice)); return res; } + ~RawInvoice() { RawInvoice_free(self); } + RawInvoice& operator=(RawInvoice&& o) { RawInvoice_free(self); self = o.self; memset(&o, 0, sizeof(RawInvoice)); return *this; } + LDKRawInvoice* operator &() { return &self; } + LDKRawInvoice* operator ->() { return &self; } + const LDKRawInvoice* operator &() const { return &self; } + const LDKRawInvoice* operator ->() const { return &self; } +}; +class RawDataPart { +private: + LDKRawDataPart self; +public: + RawDataPart(const RawDataPart&) = delete; + RawDataPart(RawDataPart&& o) : self(o.self) { memset(&o, 0, sizeof(RawDataPart)); } + RawDataPart(LDKRawDataPart&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKRawDataPart)); } + operator LDKRawDataPart() && { LDKRawDataPart res = self; memset(&self, 0, sizeof(LDKRawDataPart)); return res; } + ~RawDataPart() { RawDataPart_free(self); } + RawDataPart& operator=(RawDataPart&& o) { RawDataPart_free(self); self = o.self; memset(&o, 0, sizeof(RawDataPart)); return *this; } + LDKRawDataPart* operator &() { return &self; } + LDKRawDataPart* operator ->() { return &self; } + const LDKRawDataPart* operator &() const { return &self; } + const LDKRawDataPart* operator ->() const { return &self; } +}; +class PositiveTimestamp { +private: + LDKPositiveTimestamp self; +public: + PositiveTimestamp(const PositiveTimestamp&) = delete; + PositiveTimestamp(PositiveTimestamp&& o) : self(o.self) { memset(&o, 0, sizeof(PositiveTimestamp)); } + PositiveTimestamp(LDKPositiveTimestamp&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPositiveTimestamp)); } + operator LDKPositiveTimestamp() && { LDKPositiveTimestamp res = self; memset(&self, 0, sizeof(LDKPositiveTimestamp)); return res; } + ~PositiveTimestamp() { PositiveTimestamp_free(self); } + PositiveTimestamp& operator=(PositiveTimestamp&& o) { PositiveTimestamp_free(self); self = o.self; memset(&o, 0, sizeof(PositiveTimestamp)); return *this; } + LDKPositiveTimestamp* operator &() { return &self; } + LDKPositiveTimestamp* operator ->() { return &self; } + const LDKPositiveTimestamp* operator &() const { return &self; } + const LDKPositiveTimestamp* operator ->() const { return &self; } +}; +class SiPrefix { +private: + LDKSiPrefix self; +public: + SiPrefix(const SiPrefix&) = delete; + SiPrefix(SiPrefix&& o) : self(o.self) { memset(&o, 0, sizeof(SiPrefix)); } + SiPrefix(LDKSiPrefix&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKSiPrefix)); } + operator LDKSiPrefix() && { LDKSiPrefix res = self; memset(&self, 0, sizeof(LDKSiPrefix)); return res; } + SiPrefix& operator=(SiPrefix&& o) { self = o.self; memset(&o, 0, sizeof(SiPrefix)); return *this; } + LDKSiPrefix* operator &() { return &self; } + LDKSiPrefix* operator ->() { return &self; } + const LDKSiPrefix* operator &() const { return &self; } + const LDKSiPrefix* operator ->() const { return &self; } +}; +class Currency { +private: + LDKCurrency self; +public: + Currency(const Currency&) = delete; + Currency(Currency&& o) : self(o.self) { memset(&o, 0, sizeof(Currency)); } + Currency(LDKCurrency&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCurrency)); } + operator LDKCurrency() && { LDKCurrency res = self; memset(&self, 0, sizeof(LDKCurrency)); return res; } + Currency& operator=(Currency&& o) { self = o.self; memset(&o, 0, sizeof(Currency)); return *this; } + LDKCurrency* operator &() { return &self; } + LDKCurrency* operator ->() { return &self; } + const LDKCurrency* operator &() const { return &self; } + const LDKCurrency* operator ->() const { return &self; } +}; +class Sha256 { +private: + LDKSha256 self; +public: + Sha256(const Sha256&) = delete; + Sha256(Sha256&& o) : self(o.self) { memset(&o, 0, sizeof(Sha256)); } + Sha256(LDKSha256&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKSha256)); } + operator LDKSha256() && { LDKSha256 res = self; memset(&self, 0, sizeof(LDKSha256)); return res; } + ~Sha256() { Sha256_free(self); } + Sha256& operator=(Sha256&& o) { Sha256_free(self); self = o.self; memset(&o, 0, sizeof(Sha256)); return *this; } + LDKSha256* operator &() { return &self; } + LDKSha256* operator ->() { return &self; } + const LDKSha256* operator &() const { return &self; } + const LDKSha256* operator ->() const { return &self; } +}; +class Description { +private: + LDKDescription self; +public: + Description(const Description&) = delete; + Description(Description&& o) : self(o.self) { memset(&o, 0, sizeof(Description)); } + Description(LDKDescription&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKDescription)); } + operator LDKDescription() && { LDKDescription res = self; memset(&self, 0, sizeof(LDKDescription)); return res; } + ~Description() { Description_free(self); } + Description& operator=(Description&& o) { Description_free(self); self = o.self; memset(&o, 0, sizeof(Description)); return *this; } + LDKDescription* operator &() { return &self; } + LDKDescription* operator ->() { return &self; } + const LDKDescription* operator &() const { return &self; } + const LDKDescription* operator ->() const { return &self; } +}; +class PayeePubKey { +private: + LDKPayeePubKey self; +public: + PayeePubKey(const PayeePubKey&) = delete; + PayeePubKey(PayeePubKey&& o) : self(o.self) { memset(&o, 0, sizeof(PayeePubKey)); } + PayeePubKey(LDKPayeePubKey&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPayeePubKey)); } + operator LDKPayeePubKey() && { LDKPayeePubKey res = self; memset(&self, 0, sizeof(LDKPayeePubKey)); return res; } + ~PayeePubKey() { PayeePubKey_free(self); } + PayeePubKey& operator=(PayeePubKey&& o) { PayeePubKey_free(self); self = o.self; memset(&o, 0, sizeof(PayeePubKey)); return *this; } + LDKPayeePubKey* operator &() { return &self; } + LDKPayeePubKey* operator ->() { return &self; } + const LDKPayeePubKey* operator &() const { return &self; } + const LDKPayeePubKey* operator ->() const { return &self; } +}; +class ExpiryTime { +private: + LDKExpiryTime self; +public: + ExpiryTime(const ExpiryTime&) = delete; + ExpiryTime(ExpiryTime&& o) : self(o.self) { memset(&o, 0, sizeof(ExpiryTime)); } + ExpiryTime(LDKExpiryTime&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKExpiryTime)); } + operator LDKExpiryTime() && { LDKExpiryTime res = self; memset(&self, 0, sizeof(LDKExpiryTime)); return res; } + ~ExpiryTime() { ExpiryTime_free(self); } + ExpiryTime& operator=(ExpiryTime&& o) { ExpiryTime_free(self); self = o.self; memset(&o, 0, sizeof(ExpiryTime)); return *this; } + LDKExpiryTime* operator &() { return &self; } + LDKExpiryTime* operator ->() { return &self; } + const LDKExpiryTime* operator &() const { return &self; } + const LDKExpiryTime* operator ->() const { return &self; } +}; +class MinFinalCltvExpiryDelta { +private: + LDKMinFinalCltvExpiryDelta self; +public: + MinFinalCltvExpiryDelta(const MinFinalCltvExpiryDelta&) = delete; + MinFinalCltvExpiryDelta(MinFinalCltvExpiryDelta&& o) : self(o.self) { memset(&o, 0, sizeof(MinFinalCltvExpiryDelta)); } + MinFinalCltvExpiryDelta(LDKMinFinalCltvExpiryDelta&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKMinFinalCltvExpiryDelta)); } + operator LDKMinFinalCltvExpiryDelta() && { LDKMinFinalCltvExpiryDelta res = self; memset(&self, 0, sizeof(LDKMinFinalCltvExpiryDelta)); return res; } + ~MinFinalCltvExpiryDelta() { MinFinalCltvExpiryDelta_free(self); } + MinFinalCltvExpiryDelta& operator=(MinFinalCltvExpiryDelta&& o) { MinFinalCltvExpiryDelta_free(self); self = o.self; memset(&o, 0, sizeof(MinFinalCltvExpiryDelta)); return *this; } + LDKMinFinalCltvExpiryDelta* operator &() { return &self; } + LDKMinFinalCltvExpiryDelta* operator ->() { return &self; } + const LDKMinFinalCltvExpiryDelta* operator &() const { return &self; } + const LDKMinFinalCltvExpiryDelta* operator ->() const { return &self; } +}; +class Fallback { +private: + LDKFallback self; +public: + Fallback(const Fallback&) = delete; + Fallback(Fallback&& o) : self(o.self) { memset(&o, 0, sizeof(Fallback)); } + Fallback(LDKFallback&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKFallback)); } + operator LDKFallback() && { LDKFallback res = self; memset(&self, 0, sizeof(LDKFallback)); return res; } + ~Fallback() { Fallback_free(self); } + Fallback& operator=(Fallback&& o) { Fallback_free(self); self = o.self; memset(&o, 0, sizeof(Fallback)); return *this; } + LDKFallback* operator &() { return &self; } + LDKFallback* operator ->() { return &self; } + const LDKFallback* operator &() const { return &self; } + const LDKFallback* operator ->() const { return &self; } +}; +class InvoiceSignature { +private: + LDKInvoiceSignature self; +public: + InvoiceSignature(const InvoiceSignature&) = delete; + InvoiceSignature(InvoiceSignature&& o) : self(o.self) { memset(&o, 0, sizeof(InvoiceSignature)); } + InvoiceSignature(LDKInvoiceSignature&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKInvoiceSignature)); } + operator LDKInvoiceSignature() && { LDKInvoiceSignature res = self; memset(&self, 0, sizeof(LDKInvoiceSignature)); return res; } + ~InvoiceSignature() { InvoiceSignature_free(self); } + InvoiceSignature& operator=(InvoiceSignature&& o) { InvoiceSignature_free(self); self = o.self; memset(&o, 0, sizeof(InvoiceSignature)); return *this; } + LDKInvoiceSignature* operator &() { return &self; } + LDKInvoiceSignature* operator ->() { return &self; } + const LDKInvoiceSignature* operator &() const { return &self; } + const LDKInvoiceSignature* operator ->() const { return &self; } +}; +class PrivateRoute { +private: + LDKPrivateRoute self; +public: + PrivateRoute(const PrivateRoute&) = delete; + PrivateRoute(PrivateRoute&& o) : self(o.self) { memset(&o, 0, sizeof(PrivateRoute)); } + PrivateRoute(LDKPrivateRoute&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPrivateRoute)); } + operator LDKPrivateRoute() && { LDKPrivateRoute res = self; memset(&self, 0, sizeof(LDKPrivateRoute)); return res; } + ~PrivateRoute() { PrivateRoute_free(self); } + PrivateRoute& operator=(PrivateRoute&& o) { PrivateRoute_free(self); self = o.self; memset(&o, 0, sizeof(PrivateRoute)); return *this; } + LDKPrivateRoute* operator &() { return &self; } + LDKPrivateRoute* operator ->() { return &self; } + const LDKPrivateRoute* operator &() const { return &self; } + const LDKPrivateRoute* operator ->() const { return &self; } +}; +class CreationError { private: - LDKChainMonitor self; + LDKCreationError self; public: - ChainMonitor(const ChainMonitor&) = delete; - ChainMonitor(ChainMonitor&& o) : self(o.self) { memset(&o, 0, sizeof(ChainMonitor)); } - ChainMonitor(LDKChainMonitor&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChainMonitor)); } - operator LDKChainMonitor() && { LDKChainMonitor res = self; memset(&self, 0, sizeof(LDKChainMonitor)); return res; } - ~ChainMonitor() { ChainMonitor_free(self); } - ChainMonitor& operator=(ChainMonitor&& o) { ChainMonitor_free(self); self = o.self; memset(&o, 0, sizeof(ChainMonitor)); return *this; } - LDKChainMonitor* operator &() { return &self; } - LDKChainMonitor* operator ->() { return &self; } - const LDKChainMonitor* operator &() const { return &self; } - const LDKChainMonitor* operator ->() const { return &self; } + CreationError(const CreationError&) = delete; + CreationError(CreationError&& o) : self(o.self) { memset(&o, 0, sizeof(CreationError)); } + CreationError(LDKCreationError&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCreationError)); } + operator LDKCreationError() && { LDKCreationError res = self; memset(&self, 0, sizeof(LDKCreationError)); return res; } + CreationError& operator=(CreationError&& o) { self = o.self; memset(&o, 0, sizeof(CreationError)); return *this; } + LDKCreationError* operator &() { return &self; } + LDKCreationError* operator ->() { return &self; } + const LDKCreationError* operator &() const { return &self; } + const LDKCreationError* operator ->() const { return &self; } }; -class GraphSyncError { +class SemanticError { private: - LDKGraphSyncError self; + LDKSemanticError 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; } + SemanticError(const SemanticError&) = delete; + SemanticError(SemanticError&& o) : self(o.self) { memset(&o, 0, sizeof(SemanticError)); } + SemanticError(LDKSemanticError&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKSemanticError)); } + operator LDKSemanticError() && { LDKSemanticError res = self; memset(&self, 0, sizeof(LDKSemanticError)); return res; } + SemanticError& operator=(SemanticError&& o) { self = o.self; memset(&o, 0, sizeof(SemanticError)); return *this; } + LDKSemanticError* operator &() { return &self; } + LDKSemanticError* operator ->() { return &self; } + const LDKSemanticError* operator &() const { return &self; } + const LDKSemanticError* operator ->() const { return &self; } }; -class RapidGossipSync { +class SignOrCreationError { private: - LDKRapidGossipSync self; + LDKSignOrCreationError 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; } + SignOrCreationError(const SignOrCreationError&) = delete; + SignOrCreationError(SignOrCreationError&& o) : self(o.self) { memset(&o, 0, sizeof(SignOrCreationError)); } + SignOrCreationError(LDKSignOrCreationError&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKSignOrCreationError)); } + operator LDKSignOrCreationError() && { LDKSignOrCreationError res = self; memset(&self, 0, sizeof(LDKSignOrCreationError)); return res; } + ~SignOrCreationError() { SignOrCreationError_free(self); } + SignOrCreationError& operator=(SignOrCreationError&& o) { SignOrCreationError_free(self); self = o.self; memset(&o, 0, sizeof(SignOrCreationError)); return *this; } + LDKSignOrCreationError* operator &() { return &self; } + LDKSignOrCreationError* operator ->() { return &self; } + const LDKSignOrCreationError* operator &() const { return &self; } + const LDKSignOrCreationError* operator ->() const { return &self; } }; class CResult_LockedChannelMonitorNoneZ { private: @@ -4888,20 +4836,20 @@ class CResult_PhantomRouteHintsDecodeErrorZ { const LDKCResult_PhantomRouteHintsDecodeErrorZ* operator &() const { return &self; } const LDKCResult_PhantomRouteHintsDecodeErrorZ* operator ->() const { return &self; } }; -class CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ { +class CResult_FundingCreatedDecodeErrorZ { private: - LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ self; + LDKCResult_FundingCreatedDecodeErrorZ self; public: - CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ(const CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ&) = delete; - CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ(CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ)); } - CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ)); } - operator LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ() && { LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ)); return res; } - ~CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ() { CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(self); } - CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ& operator=(CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ&& o) { CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ)); return *this; } - LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* operator &() { return &self; } - LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* operator ->() { return &self; } - const LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* operator &() const { return &self; } - const LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* operator ->() const { return &self; } + CResult_FundingCreatedDecodeErrorZ(const CResult_FundingCreatedDecodeErrorZ&) = delete; + CResult_FundingCreatedDecodeErrorZ(CResult_FundingCreatedDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_FundingCreatedDecodeErrorZ)); } + CResult_FundingCreatedDecodeErrorZ(LDKCResult_FundingCreatedDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_FundingCreatedDecodeErrorZ)); } + operator LDKCResult_FundingCreatedDecodeErrorZ() && { LDKCResult_FundingCreatedDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_FundingCreatedDecodeErrorZ)); return res; } + ~CResult_FundingCreatedDecodeErrorZ() { CResult_FundingCreatedDecodeErrorZ_free(self); } + CResult_FundingCreatedDecodeErrorZ& operator=(CResult_FundingCreatedDecodeErrorZ&& o) { CResult_FundingCreatedDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_FundingCreatedDecodeErrorZ)); return *this; } + LDKCResult_FundingCreatedDecodeErrorZ* operator &() { return &self; } + LDKCResult_FundingCreatedDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_FundingCreatedDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_FundingCreatedDecodeErrorZ* operator ->() const { return &self; } }; class CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ { private: @@ -4933,21 +4881,6 @@ class CVec_C2Tuple_u32TxOutZZ { const LDKCVec_C2Tuple_u32TxOutZZ* operator &() const { return &self; } const LDKCVec_C2Tuple_u32TxOutZZ* operator ->() const { return &self; } }; -class CResult_FundingCreatedDecodeErrorZ { -private: - LDKCResult_FundingCreatedDecodeErrorZ self; -public: - CResult_FundingCreatedDecodeErrorZ(const CResult_FundingCreatedDecodeErrorZ&) = delete; - CResult_FundingCreatedDecodeErrorZ(CResult_FundingCreatedDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_FundingCreatedDecodeErrorZ)); } - CResult_FundingCreatedDecodeErrorZ(LDKCResult_FundingCreatedDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_FundingCreatedDecodeErrorZ)); } - operator LDKCResult_FundingCreatedDecodeErrorZ() && { LDKCResult_FundingCreatedDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_FundingCreatedDecodeErrorZ)); return res; } - ~CResult_FundingCreatedDecodeErrorZ() { CResult_FundingCreatedDecodeErrorZ_free(self); } - CResult_FundingCreatedDecodeErrorZ& operator=(CResult_FundingCreatedDecodeErrorZ&& o) { CResult_FundingCreatedDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_FundingCreatedDecodeErrorZ)); return *this; } - LDKCResult_FundingCreatedDecodeErrorZ* operator &() { return &self; } - LDKCResult_FundingCreatedDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_FundingCreatedDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_FundingCreatedDecodeErrorZ* operator ->() const { return &self; } -}; class CResult_ChannelInfoDecodeErrorZ { private: LDKCResult_ChannelInfoDecodeErrorZ self; @@ -5443,20 +5376,20 @@ class COption_HTLCDestinationZ { const LDKCOption_HTLCDestinationZ* operator &() const { return &self; } const LDKCOption_HTLCDestinationZ* operator ->() const { return &self; } }; -class C2Tuple_BlockHashChannelMonitorZ { +class CResult_NoneRetryableSendFailureZ { private: - LDKC2Tuple_BlockHashChannelMonitorZ self; + LDKCResult_NoneRetryableSendFailureZ self; public: - C2Tuple_BlockHashChannelMonitorZ(const C2Tuple_BlockHashChannelMonitorZ&) = delete; - C2Tuple_BlockHashChannelMonitorZ(C2Tuple_BlockHashChannelMonitorZ&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_BlockHashChannelMonitorZ)); } - C2Tuple_BlockHashChannelMonitorZ(LDKC2Tuple_BlockHashChannelMonitorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_BlockHashChannelMonitorZ)); } - operator LDKC2Tuple_BlockHashChannelMonitorZ() && { LDKC2Tuple_BlockHashChannelMonitorZ res = self; memset(&self, 0, sizeof(LDKC2Tuple_BlockHashChannelMonitorZ)); return res; } - ~C2Tuple_BlockHashChannelMonitorZ() { C2Tuple_BlockHashChannelMonitorZ_free(self); } - C2Tuple_BlockHashChannelMonitorZ& operator=(C2Tuple_BlockHashChannelMonitorZ&& o) { C2Tuple_BlockHashChannelMonitorZ_free(self); self = o.self; memset(&o, 0, sizeof(C2Tuple_BlockHashChannelMonitorZ)); return *this; } - LDKC2Tuple_BlockHashChannelMonitorZ* operator &() { return &self; } - LDKC2Tuple_BlockHashChannelMonitorZ* operator ->() { return &self; } - const LDKC2Tuple_BlockHashChannelMonitorZ* operator &() const { return &self; } - const LDKC2Tuple_BlockHashChannelMonitorZ* operator ->() const { return &self; } + CResult_NoneRetryableSendFailureZ(const CResult_NoneRetryableSendFailureZ&) = delete; + CResult_NoneRetryableSendFailureZ(CResult_NoneRetryableSendFailureZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_NoneRetryableSendFailureZ)); } + CResult_NoneRetryableSendFailureZ(LDKCResult_NoneRetryableSendFailureZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_NoneRetryableSendFailureZ)); } + operator LDKCResult_NoneRetryableSendFailureZ() && { LDKCResult_NoneRetryableSendFailureZ res = self; memset(&self, 0, sizeof(LDKCResult_NoneRetryableSendFailureZ)); return res; } + ~CResult_NoneRetryableSendFailureZ() { CResult_NoneRetryableSendFailureZ_free(self); } + CResult_NoneRetryableSendFailureZ& operator=(CResult_NoneRetryableSendFailureZ&& o) { CResult_NoneRetryableSendFailureZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_NoneRetryableSendFailureZ)); return *this; } + LDKCResult_NoneRetryableSendFailureZ* operator &() { return &self; } + LDKCResult_NoneRetryableSendFailureZ* operator ->() { return &self; } + const LDKCResult_NoneRetryableSendFailureZ* operator &() const { return &self; } + const LDKCResult_NoneRetryableSendFailureZ* operator ->() const { return &self; } }; class CResult_ShutdownScriptInvalidShutdownScriptZ { private: @@ -5503,20 +5436,20 @@ class CResult_COption_NetworkUpdateZDecodeErrorZ { const LDKCResult_COption_NetworkUpdateZDecodeErrorZ* operator &() const { return &self; } const LDKCResult_COption_NetworkUpdateZDecodeErrorZ* operator ->() const { return &self; } }; -class CResult_NoneRetryableSendFailureZ { +class C2Tuple_BlockHashChannelMonitorZ { private: - LDKCResult_NoneRetryableSendFailureZ self; + LDKC2Tuple_BlockHashChannelMonitorZ self; public: - CResult_NoneRetryableSendFailureZ(const CResult_NoneRetryableSendFailureZ&) = delete; - CResult_NoneRetryableSendFailureZ(CResult_NoneRetryableSendFailureZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_NoneRetryableSendFailureZ)); } - CResult_NoneRetryableSendFailureZ(LDKCResult_NoneRetryableSendFailureZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_NoneRetryableSendFailureZ)); } - operator LDKCResult_NoneRetryableSendFailureZ() && { LDKCResult_NoneRetryableSendFailureZ res = self; memset(&self, 0, sizeof(LDKCResult_NoneRetryableSendFailureZ)); return res; } - ~CResult_NoneRetryableSendFailureZ() { CResult_NoneRetryableSendFailureZ_free(self); } - CResult_NoneRetryableSendFailureZ& operator=(CResult_NoneRetryableSendFailureZ&& o) { CResult_NoneRetryableSendFailureZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_NoneRetryableSendFailureZ)); return *this; } - LDKCResult_NoneRetryableSendFailureZ* operator &() { return &self; } - LDKCResult_NoneRetryableSendFailureZ* operator ->() { return &self; } - const LDKCResult_NoneRetryableSendFailureZ* operator &() const { return &self; } - const LDKCResult_NoneRetryableSendFailureZ* operator ->() const { return &self; } + C2Tuple_BlockHashChannelMonitorZ(const C2Tuple_BlockHashChannelMonitorZ&) = delete; + C2Tuple_BlockHashChannelMonitorZ(C2Tuple_BlockHashChannelMonitorZ&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_BlockHashChannelMonitorZ)); } + C2Tuple_BlockHashChannelMonitorZ(LDKC2Tuple_BlockHashChannelMonitorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_BlockHashChannelMonitorZ)); } + operator LDKC2Tuple_BlockHashChannelMonitorZ() && { LDKC2Tuple_BlockHashChannelMonitorZ res = self; memset(&self, 0, sizeof(LDKC2Tuple_BlockHashChannelMonitorZ)); return res; } + ~C2Tuple_BlockHashChannelMonitorZ() { C2Tuple_BlockHashChannelMonitorZ_free(self); } + C2Tuple_BlockHashChannelMonitorZ& operator=(C2Tuple_BlockHashChannelMonitorZ&& o) { C2Tuple_BlockHashChannelMonitorZ_free(self); self = o.self; memset(&o, 0, sizeof(C2Tuple_BlockHashChannelMonitorZ)); return *this; } + LDKC2Tuple_BlockHashChannelMonitorZ* operator &() { return &self; } + LDKC2Tuple_BlockHashChannelMonitorZ* operator ->() { return &self; } + const LDKC2Tuple_BlockHashChannelMonitorZ* operator &() const { return &self; } + const LDKC2Tuple_BlockHashChannelMonitorZ* operator ->() const { return &self; } }; class CVec_UpdateFailMalformedHTLCZ { private: @@ -5593,21 +5526,6 @@ class COption_CustomOnionMessageContentsZ { const LDKCOption_CustomOnionMessageContentsZ* operator &() const { return &self; } const LDKCOption_CustomOnionMessageContentsZ* operator ->() const { return &self; } }; -class CVec_C2Tuple_BlockHashChannelMonitorZZ { -private: - LDKCVec_C2Tuple_BlockHashChannelMonitorZZ self; -public: - CVec_C2Tuple_BlockHashChannelMonitorZZ(const CVec_C2Tuple_BlockHashChannelMonitorZZ&) = delete; - CVec_C2Tuple_BlockHashChannelMonitorZZ(CVec_C2Tuple_BlockHashChannelMonitorZZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_C2Tuple_BlockHashChannelMonitorZZ)); } - CVec_C2Tuple_BlockHashChannelMonitorZZ(LDKCVec_C2Tuple_BlockHashChannelMonitorZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_C2Tuple_BlockHashChannelMonitorZZ)); } - operator LDKCVec_C2Tuple_BlockHashChannelMonitorZZ() && { LDKCVec_C2Tuple_BlockHashChannelMonitorZZ res = self; memset(&self, 0, sizeof(LDKCVec_C2Tuple_BlockHashChannelMonitorZZ)); return res; } - ~CVec_C2Tuple_BlockHashChannelMonitorZZ() { CVec_C2Tuple_BlockHashChannelMonitorZZ_free(self); } - CVec_C2Tuple_BlockHashChannelMonitorZZ& operator=(CVec_C2Tuple_BlockHashChannelMonitorZZ&& o) { CVec_C2Tuple_BlockHashChannelMonitorZZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_C2Tuple_BlockHashChannelMonitorZZ)); return *this; } - LDKCVec_C2Tuple_BlockHashChannelMonitorZZ* operator &() { return &self; } - LDKCVec_C2Tuple_BlockHashChannelMonitorZZ* operator ->() { return &self; } - const LDKCVec_C2Tuple_BlockHashChannelMonitorZZ* operator &() const { return &self; } - const LDKCVec_C2Tuple_BlockHashChannelMonitorZZ* operator ->() const { return &self; } -}; class CVec_ThirtyTwoBytesZ { private: LDKCVec_ThirtyTwoBytesZ self; @@ -5938,21 +5856,6 @@ class CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ { const LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* operator &() const { return &self; } const LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* operator ->() const { return &self; } }; -class CResult_NoneErrorZ { -private: - LDKCResult_NoneErrorZ self; -public: - CResult_NoneErrorZ(const CResult_NoneErrorZ&) = delete; - CResult_NoneErrorZ(CResult_NoneErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_NoneErrorZ)); } - CResult_NoneErrorZ(LDKCResult_NoneErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_NoneErrorZ)); } - operator LDKCResult_NoneErrorZ() && { LDKCResult_NoneErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_NoneErrorZ)); return res; } - ~CResult_NoneErrorZ() { CResult_NoneErrorZ_free(self); } - CResult_NoneErrorZ& operator=(CResult_NoneErrorZ&& o) { CResult_NoneErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_NoneErrorZ)); return *this; } - LDKCResult_NoneErrorZ* operator &() { return &self; } - LDKCResult_NoneErrorZ* operator ->() { return &self; } - const LDKCResult_NoneErrorZ* operator &() const { return &self; } - const LDKCResult_NoneErrorZ* operator ->() const { return &self; } -}; class CResult_InFlightHtlcsDecodeErrorZ { private: LDKCResult_InFlightHtlcsDecodeErrorZ self; @@ -5983,6 +5886,21 @@ class CResult_COption_HTLCDestinationZDecodeErrorZ { const LDKCResult_COption_HTLCDestinationZDecodeErrorZ* operator &() const { return &self; } const LDKCResult_COption_HTLCDestinationZDecodeErrorZ* operator ->() const { return &self; } }; +class CResult_NoneErrorZ { +private: + LDKCResult_NoneErrorZ self; +public: + CResult_NoneErrorZ(const CResult_NoneErrorZ&) = delete; + CResult_NoneErrorZ(CResult_NoneErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_NoneErrorZ)); } + CResult_NoneErrorZ(LDKCResult_NoneErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_NoneErrorZ)); } + operator LDKCResult_NoneErrorZ() && { LDKCResult_NoneErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_NoneErrorZ)); return res; } + ~CResult_NoneErrorZ() { CResult_NoneErrorZ_free(self); } + CResult_NoneErrorZ& operator=(CResult_NoneErrorZ&& o) { CResult_NoneErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_NoneErrorZ)); return *this; } + LDKCResult_NoneErrorZ* operator &() { return &self; } + LDKCResult_NoneErrorZ* operator ->() { return &self; } + const LDKCResult_NoneErrorZ* operator &() const { return &self; } + const LDKCResult_NoneErrorZ* operator ->() const { return &self; } +}; class CResult_SiPrefixParseErrorZ { private: LDKCResult_SiPrefixParseErrorZ self; @@ -6283,21 +6201,6 @@ class CResult_QueryShortChannelIdsDecodeErrorZ { const LDKCResult_QueryShortChannelIdsDecodeErrorZ* operator &() const { return &self; } const LDKCResult_QueryShortChannelIdsDecodeErrorZ* operator ->() const { return &self; } }; -class CResult_InvoiceSemanticErrorZ { -private: - LDKCResult_InvoiceSemanticErrorZ self; -public: - CResult_InvoiceSemanticErrorZ(const CResult_InvoiceSemanticErrorZ&) = delete; - CResult_InvoiceSemanticErrorZ(CResult_InvoiceSemanticErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_InvoiceSemanticErrorZ)); } - CResult_InvoiceSemanticErrorZ(LDKCResult_InvoiceSemanticErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_InvoiceSemanticErrorZ)); } - operator LDKCResult_InvoiceSemanticErrorZ() && { LDKCResult_InvoiceSemanticErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_InvoiceSemanticErrorZ)); return res; } - ~CResult_InvoiceSemanticErrorZ() { CResult_InvoiceSemanticErrorZ_free(self); } - CResult_InvoiceSemanticErrorZ& operator=(CResult_InvoiceSemanticErrorZ&& o) { CResult_InvoiceSemanticErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_InvoiceSemanticErrorZ)); return *this; } - LDKCResult_InvoiceSemanticErrorZ* operator &() { return &self; } - LDKCResult_InvoiceSemanticErrorZ* operator ->() { return &self; } - const LDKCResult_InvoiceSemanticErrorZ* operator &() const { return &self; } - const LDKCResult_InvoiceSemanticErrorZ* operator ->() const { return &self; } -}; class CResult_UpdateAddHTLCDecodeErrorZ { private: LDKCResult_UpdateAddHTLCDecodeErrorZ self; @@ -6313,6 +6216,21 @@ class CResult_UpdateAddHTLCDecodeErrorZ { const LDKCResult_UpdateAddHTLCDecodeErrorZ* operator &() const { return &self; } const LDKCResult_UpdateAddHTLCDecodeErrorZ* operator ->() const { return &self; } }; +class CResult_InvoiceSemanticErrorZ { +private: + LDKCResult_InvoiceSemanticErrorZ self; +public: + CResult_InvoiceSemanticErrorZ(const CResult_InvoiceSemanticErrorZ&) = delete; + CResult_InvoiceSemanticErrorZ(CResult_InvoiceSemanticErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_InvoiceSemanticErrorZ)); } + CResult_InvoiceSemanticErrorZ(LDKCResult_InvoiceSemanticErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_InvoiceSemanticErrorZ)); } + operator LDKCResult_InvoiceSemanticErrorZ() && { LDKCResult_InvoiceSemanticErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_InvoiceSemanticErrorZ)); return res; } + ~CResult_InvoiceSemanticErrorZ() { CResult_InvoiceSemanticErrorZ_free(self); } + CResult_InvoiceSemanticErrorZ& operator=(CResult_InvoiceSemanticErrorZ&& o) { CResult_InvoiceSemanticErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_InvoiceSemanticErrorZ)); return *this; } + LDKCResult_InvoiceSemanticErrorZ* operator &() { return &self; } + LDKCResult_InvoiceSemanticErrorZ* operator ->() { return &self; } + const LDKCResult_InvoiceSemanticErrorZ* operator &() const { return &self; } + const LDKCResult_InvoiceSemanticErrorZ* operator ->() const { return &self; } +}; class COption_MonitorEventZ { private: LDKCOption_MonitorEventZ self; @@ -6883,21 +6801,6 @@ class CVec_OutPointZ { const LDKCVec_OutPointZ* operator &() const { return &self; } const LDKCVec_OutPointZ* operator ->() const { return &self; } }; -class COption_WriteableScoreZ { -private: - LDKCOption_WriteableScoreZ self; -public: - COption_WriteableScoreZ(const COption_WriteableScoreZ&) = delete; - COption_WriteableScoreZ(COption_WriteableScoreZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_WriteableScoreZ)); } - COption_WriteableScoreZ(LDKCOption_WriteableScoreZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_WriteableScoreZ)); } - operator LDKCOption_WriteableScoreZ() && { LDKCOption_WriteableScoreZ res = self; memset(&self, 0, sizeof(LDKCOption_WriteableScoreZ)); return res; } - ~COption_WriteableScoreZ() { COption_WriteableScoreZ_free(self); } - COption_WriteableScoreZ& operator=(COption_WriteableScoreZ&& o) { COption_WriteableScoreZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_WriteableScoreZ)); return *this; } - LDKCOption_WriteableScoreZ* operator &() { return &self; } - LDKCOption_WriteableScoreZ* operator ->() { return &self; } - const LDKCOption_WriteableScoreZ* operator &() const { return &self; } - const LDKCOption_WriteableScoreZ* operator ->() const { return &self; } -}; class CResult_PositiveTimestampCreationErrorZ { private: LDKCResult_PositiveTimestampCreationErrorZ self; @@ -7318,21 +7221,6 @@ class CResult_BlindedPathDecodeErrorZ { const LDKCResult_BlindedPathDecodeErrorZ* operator &() const { return &self; } const LDKCResult_BlindedPathDecodeErrorZ* operator ->() const { return &self; } }; -class CVec_FutureZ { -private: - LDKCVec_FutureZ self; -public: - CVec_FutureZ(const CVec_FutureZ&) = delete; - CVec_FutureZ(CVec_FutureZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_FutureZ)); } - CVec_FutureZ(LDKCVec_FutureZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_FutureZ)); } - operator LDKCVec_FutureZ() && { LDKCVec_FutureZ res = self; memset(&self, 0, sizeof(LDKCVec_FutureZ)); return res; } - ~CVec_FutureZ() { CVec_FutureZ_free(self); } - CVec_FutureZ& operator=(CVec_FutureZ&& o) { CVec_FutureZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_FutureZ)); return *this; } - LDKCVec_FutureZ* operator &() { return &self; } - LDKCVec_FutureZ* operator ->() { return &self; } - const LDKCVec_FutureZ* operator &() const { return &self; } - const LDKCVec_FutureZ* operator ->() const { return &self; } -}; class CResult_RouteHopDecodeErrorZ { private: LDKCResult_RouteHopDecodeErrorZ self; @@ -8458,21 +8346,6 @@ class CResult_boolPeerHandleErrorZ { 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; @@ -8488,6 +8361,21 @@ class CResult_ChannelUpdateDecodeErrorZ { const LDKCResult_ChannelUpdateDecodeErrorZ* operator &() const { return &self; } const LDKCResult_ChannelUpdateDecodeErrorZ* 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_PaymentSecretAPIErrorZ { private: LDKCResult_PaymentSecretAPIErrorZ self; diff --git a/lightning-c-bindings/src/c_types/derived.rs b/lightning-c-bindings/src/c_types/derived.rs index ad65e755..b98e1c3a 100644 --- a/lightning-c-bindings/src/c_types/derived.rs +++ b/lightning-c-bindings/src/c_types/derived.rs @@ -128,6 +128,102 @@ pub extern "C" fn COption_u64Z_free(_res: COption_u64Z) { } /// but with all dynamically-allocated buffers duplicated in new buffers. pub extern "C" fn COption_u64Z_clone(orig: &COption_u64Z) -> COption_u64Z { Clone::clone(&orig) } #[repr(C)] +/// The contents of CResult_RefundBolt12ParseErrorZ +pub union CResult_RefundBolt12ParseErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::offers::refund::Refund, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::offers::parse::Bolt12ParseError, +} +#[repr(C)] +/// A CResult_RefundBolt12ParseErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::offers::refund::Refund on success and a crate::lightning::offers::parse::Bolt12ParseError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_RefundBolt12ParseErrorZ { + /// The contents of this CResult_RefundBolt12ParseErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_RefundBolt12ParseErrorZPtr, + /// Whether this CResult_RefundBolt12ParseErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_RefundBolt12ParseErrorZ in the success state. +pub extern "C" fn CResult_RefundBolt12ParseErrorZ_ok(o: crate::lightning::offers::refund::Refund) -> CResult_RefundBolt12ParseErrorZ { + CResult_RefundBolt12ParseErrorZ { + contents: CResult_RefundBolt12ParseErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_RefundBolt12ParseErrorZ in the error state. +pub extern "C" fn CResult_RefundBolt12ParseErrorZ_err(e: crate::lightning::offers::parse::Bolt12ParseError) -> CResult_RefundBolt12ParseErrorZ { + CResult_RefundBolt12ParseErrorZ { + contents: CResult_RefundBolt12ParseErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_RefundBolt12ParseErrorZ_is_ok(o: &CResult_RefundBolt12ParseErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_RefundBolt12ParseErrorZ. +pub extern "C" fn CResult_RefundBolt12ParseErrorZ_free(_res: CResult_RefundBolt12ParseErrorZ) { } +impl Drop for CResult_RefundBolt12ParseErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_RefundBolt12ParseErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_RefundBolt12ParseErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_RefundBolt12ParseErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_RefundBolt12ParseErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_RefundBolt12ParseErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_RefundBolt12ParseErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_RefundBolt12ParseErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_RefundBolt12ParseErrorZ_clone(orig: &CResult_RefundBolt12ParseErrorZ) -> CResult_RefundBolt12ParseErrorZ { Clone::clone(&orig) } +#[repr(C)] /// The contents of CResult_NoneAPIErrorZ pub union CResult_NoneAPIErrorZPtr { /// Note that this value is always NULL, as there are no contents in the OK variant @@ -312,6 +408,43 @@ impl Clone for CVec_APIErrorZ { } } #[repr(C)] +#[derive(Clone)] +/// An enum which can either contain a crate::c_types::ThirtyTwoBytes or not +pub enum COption_PaymentSecretZ { + /// When we're in this state, this COption_PaymentSecretZ contains a crate::c_types::ThirtyTwoBytes + Some(crate::c_types::ThirtyTwoBytes), + /// When we're in this state, this COption_PaymentSecretZ contains nothing + None +} +impl COption_PaymentSecretZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::ThirtyTwoBytes { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_PaymentSecretZ containing a crate::c_types::ThirtyTwoBytes +pub extern "C" fn COption_PaymentSecretZ_some(o: crate::c_types::ThirtyTwoBytes) -> COption_PaymentSecretZ { + COption_PaymentSecretZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_PaymentSecretZ containing nothing +pub extern "C" fn COption_PaymentSecretZ_none() -> COption_PaymentSecretZ { + COption_PaymentSecretZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::c_types::ThirtyTwoBytes, if we are in the Some state +pub extern "C" fn COption_PaymentSecretZ_free(_res: COption_PaymentSecretZ) { } +#[no_mangle] +/// Creates a new COption_PaymentSecretZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_PaymentSecretZ_clone(orig: &COption_PaymentSecretZ) -> COption_PaymentSecretZ { Clone::clone(&orig) } +#[repr(C)] /// A dynamically-allocated array of u8s of arbitrary size. /// This corresponds to std::vector in C++ pub struct CVec_u8Z { @@ -491,101 +624,77 @@ impl Clone for CResult_RecipientOnionFieldsDecodeErrorZ { /// but with all dynamically-allocated buffers duplicated in new buffers. pub extern "C" fn CResult_RecipientOnionFieldsDecodeErrorZ_clone(orig: &CResult_RecipientOnionFieldsDecodeErrorZ) -> CResult_RecipientOnionFieldsDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// An enum which can either contain a crate::lightning::ln::chan_utils::HTLCClaim or not -pub enum COption_HTLCClaimZ { - /// When we're in this state, this COption_HTLCClaimZ contains a crate::lightning::ln::chan_utils::HTLCClaim - Some(crate::lightning::ln::chan_utils::HTLCClaim), - /// When we're in this state, this COption_HTLCClaimZ contains nothing - None -} -impl COption_HTLCClaimZ { - #[allow(unused)] pub(crate) fn is_some(&self) -> bool { - if let Self::None = self { false } else { true } - } - #[allow(unused)] pub(crate) fn is_none(&self) -> bool { - !self.is_some() - } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::ln::chan_utils::HTLCClaim { - if let Self::Some(v) = self { v } else { unreachable!() } - } -} -#[no_mangle] -/// Constructs a new COption_HTLCClaimZ containing a crate::lightning::ln::chan_utils::HTLCClaim -pub extern "C" fn COption_HTLCClaimZ_some(o: crate::lightning::ln::chan_utils::HTLCClaim) -> COption_HTLCClaimZ { - COption_HTLCClaimZ::Some(o) -} -#[no_mangle] -/// Constructs a new COption_HTLCClaimZ containing nothing -pub extern "C" fn COption_HTLCClaimZ_none() -> COption_HTLCClaimZ { - COption_HTLCClaimZ::None -} -#[no_mangle] -/// Frees any resources associated with the crate::lightning::ln::chan_utils::HTLCClaim, if we are in the Some state -pub extern "C" fn COption_HTLCClaimZ_free(_res: COption_HTLCClaimZ) { } -#[repr(C)] -/// The contents of CResult_NoneNoneZ -pub union CResult_NoneNoneZPtr { - /// Note that this value is always NULL, as there are no contents in the OK variant - pub result: *mut core::ffi::c_void, - /// Note that this value is always NULL, as there are no contents in the Err variant - pub err: *mut core::ffi::c_void, +/// The contents of CResult_BlindedPayInfoDecodeErrorZ +pub union CResult_BlindedPayInfoDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::offers::invoice::BlindedPayInfo, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_NoneNoneZ represents the result of a fallible operation, -/// containing a () on success and a () on failure. +/// A CResult_BlindedPayInfoDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::offers::invoice::BlindedPayInfo on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_NoneNoneZ { - /// The contents of this CResult_NoneNoneZ, accessible via either +pub struct CResult_BlindedPayInfoDecodeErrorZ { + /// The contents of this CResult_BlindedPayInfoDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_NoneNoneZPtr, - /// Whether this CResult_NoneNoneZ represents a success state. + pub contents: CResult_BlindedPayInfoDecodeErrorZPtr, + /// Whether this CResult_BlindedPayInfoDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_NoneNoneZ in the success state. -pub extern "C" fn CResult_NoneNoneZ_ok() -> CResult_NoneNoneZ { - CResult_NoneNoneZ { - contents: CResult_NoneNoneZPtr { - result: core::ptr::null_mut(), +/// Creates a new CResult_BlindedPayInfoDecodeErrorZ in the success state. +pub extern "C" fn CResult_BlindedPayInfoDecodeErrorZ_ok(o: crate::lightning::offers::invoice::BlindedPayInfo) -> CResult_BlindedPayInfoDecodeErrorZ { + CResult_BlindedPayInfoDecodeErrorZ { + contents: CResult_BlindedPayInfoDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_NoneNoneZ in the error state. -pub extern "C" fn CResult_NoneNoneZ_err() -> CResult_NoneNoneZ { - CResult_NoneNoneZ { - contents: CResult_NoneNoneZPtr { - err: core::ptr::null_mut(), +/// Creates a new CResult_BlindedPayInfoDecodeErrorZ in the error state. +pub extern "C" fn CResult_BlindedPayInfoDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_BlindedPayInfoDecodeErrorZ { + CResult_BlindedPayInfoDecodeErrorZ { + contents: CResult_BlindedPayInfoDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_NoneNoneZ_is_ok(o: &CResult_NoneNoneZ) -> bool { +pub extern "C" fn CResult_BlindedPayInfoDecodeErrorZ_is_ok(o: &CResult_BlindedPayInfoDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_NoneNoneZ. -pub extern "C" fn CResult_NoneNoneZ_free(_res: CResult_NoneNoneZ) { } -impl Drop for CResult_NoneNoneZ { +/// Frees any resources used by the CResult_BlindedPayInfoDecodeErrorZ. +pub extern "C" fn CResult_BlindedPayInfoDecodeErrorZ_free(_res: CResult_BlindedPayInfoDecodeErrorZ) { } +impl Drop for CResult_BlindedPayInfoDecodeErrorZ { fn drop(&mut self) { if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } } } } -impl From> for CResult_NoneNoneZ { - fn from(mut o: crate::c_types::CResultTempl<(), ()>) -> Self { +impl From> for CResult_BlindedPayInfoDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { - let _ = unsafe { Box::from_raw(o.contents.result) }; - o.contents.result = core::ptr::null_mut(); - CResult_NoneNoneZPtr { result: core::ptr::null_mut() } + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_BlindedPayInfoDecodeErrorZPtr { result } } else { - let _ = unsafe { Box::from_raw(o.contents.err) }; - o.contents.err = core::ptr::null_mut(); - CResult_NoneNoneZPtr { err: core::ptr::null_mut() } + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_BlindedPayInfoDecodeErrorZPtr { err } }; Self { contents, @@ -593,59 +702,59 @@ impl From> for CResult_NoneNoneZ { } } } -impl Clone for CResult_NoneNoneZ { +impl Clone for CResult_BlindedPayInfoDecodeErrorZ { fn clone(&self) -> Self { if self.result_ok { - Self { result_ok: true, contents: CResult_NoneNoneZPtr { - result: core::ptr::null_mut() + Self { result_ok: true, contents: CResult_BlindedPayInfoDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_NoneNoneZPtr { - err: core::ptr::null_mut() + Self { result_ok: false, contents: CResult_BlindedPayInfoDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_NoneNoneZ which has the same data as `orig` +/// Creates a new CResult_BlindedPayInfoDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_NoneNoneZ_clone(orig: &CResult_NoneNoneZ) -> CResult_NoneNoneZ { Clone::clone(&orig) } +pub extern "C" fn CResult_BlindedPayInfoDecodeErrorZ_clone(orig: &CResult_BlindedPayInfoDecodeErrorZ) -> CResult_BlindedPayInfoDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_CounterpartyCommitmentSecretsDecodeErrorZ -pub union CResult_CounterpartyCommitmentSecretsDecodeErrorZPtr { +/// The contents of CResult_DelayedPaymentOutputDescriptorDecodeErrorZ +pub union CResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::chan_utils::CounterpartyCommitmentSecrets, + pub result: *mut crate::lightning::sign::DelayedPaymentOutputDescriptor, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_CounterpartyCommitmentSecretsDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::chan_utils::CounterpartyCommitmentSecrets on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_DelayedPaymentOutputDescriptorDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::sign::DelayedPaymentOutputDescriptor on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_CounterpartyCommitmentSecretsDecodeErrorZ { - /// The contents of this CResult_CounterpartyCommitmentSecretsDecodeErrorZ, accessible via either +pub struct CResult_DelayedPaymentOutputDescriptorDecodeErrorZ { + /// The contents of this CResult_DelayedPaymentOutputDescriptorDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_CounterpartyCommitmentSecretsDecodeErrorZPtr, - /// Whether this CResult_CounterpartyCommitmentSecretsDecodeErrorZ represents a success state. + pub contents: CResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr, + /// Whether this CResult_DelayedPaymentOutputDescriptorDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_CounterpartyCommitmentSecretsDecodeErrorZ in the success state. -pub extern "C" fn CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok(o: crate::lightning::ln::chan_utils::CounterpartyCommitmentSecrets) -> CResult_CounterpartyCommitmentSecretsDecodeErrorZ { - CResult_CounterpartyCommitmentSecretsDecodeErrorZ { - contents: CResult_CounterpartyCommitmentSecretsDecodeErrorZPtr { +/// Creates a new CResult_DelayedPaymentOutputDescriptorDecodeErrorZ in the success state. +pub extern "C" fn CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o: crate::lightning::sign::DelayedPaymentOutputDescriptor) -> CResult_DelayedPaymentOutputDescriptorDecodeErrorZ { + CResult_DelayedPaymentOutputDescriptorDecodeErrorZ { + contents: CResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_CounterpartyCommitmentSecretsDecodeErrorZ in the error state. -pub extern "C" fn CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_CounterpartyCommitmentSecretsDecodeErrorZ { - CResult_CounterpartyCommitmentSecretsDecodeErrorZ { - contents: CResult_CounterpartyCommitmentSecretsDecodeErrorZPtr { +/// Creates a new CResult_DelayedPaymentOutputDescriptorDecodeErrorZ in the error state. +pub extern "C" fn CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_DelayedPaymentOutputDescriptorDecodeErrorZ { + CResult_DelayedPaymentOutputDescriptorDecodeErrorZ { + contents: CResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -653,13 +762,13 @@ pub extern "C" fn CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(e: crate } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok(o: &CResult_CounterpartyCommitmentSecretsDecodeErrorZ) -> bool { +pub extern "C" fn CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(o: &CResult_DelayedPaymentOutputDescriptorDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_CounterpartyCommitmentSecretsDecodeErrorZ. -pub extern "C" fn CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free(_res: CResult_CounterpartyCommitmentSecretsDecodeErrorZ) { } -impl Drop for CResult_CounterpartyCommitmentSecretsDecodeErrorZ { +/// Frees any resources used by the CResult_DelayedPaymentOutputDescriptorDecodeErrorZ. +pub extern "C" fn CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res: CResult_DelayedPaymentOutputDescriptorDecodeErrorZ) { } +impl Drop for CResult_DelayedPaymentOutputDescriptorDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -672,16 +781,16 @@ impl Drop for CResult_CounterpartyCommitmentSecretsDecodeErrorZ { } } } -impl From> for CResult_CounterpartyCommitmentSecretsDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_DelayedPaymentOutputDescriptorDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_CounterpartyCommitmentSecretsDecodeErrorZPtr { result } + CResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_CounterpartyCommitmentSecretsDecodeErrorZPtr { err } + CResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr { err } }; Self { contents, @@ -689,59 +798,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_CounterpartyCommitmentSecretsDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_CounterpartyCommitmentSecretsDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_CounterpartyCommitmentSecretsDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_DelayedPaymentOutputDescriptorDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(orig: &CResult_CounterpartyCommitmentSecretsDecodeErrorZ) -> CResult_CounterpartyCommitmentSecretsDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig: &CResult_DelayedPaymentOutputDescriptorDecodeErrorZ) -> CResult_DelayedPaymentOutputDescriptorDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_TxCreationKeysDecodeErrorZ -pub union CResult_TxCreationKeysDecodeErrorZPtr { +/// The contents of CResult_StaticPaymentOutputDescriptorDecodeErrorZ +pub union CResult_StaticPaymentOutputDescriptorDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::chan_utils::TxCreationKeys, + pub result: *mut crate::lightning::sign::StaticPaymentOutputDescriptor, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_TxCreationKeysDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::chan_utils::TxCreationKeys on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_StaticPaymentOutputDescriptorDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::sign::StaticPaymentOutputDescriptor on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_TxCreationKeysDecodeErrorZ { - /// The contents of this CResult_TxCreationKeysDecodeErrorZ, accessible via either +pub struct CResult_StaticPaymentOutputDescriptorDecodeErrorZ { + /// The contents of this CResult_StaticPaymentOutputDescriptorDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_TxCreationKeysDecodeErrorZPtr, - /// Whether this CResult_TxCreationKeysDecodeErrorZ represents a success state. + pub contents: CResult_StaticPaymentOutputDescriptorDecodeErrorZPtr, + /// Whether this CResult_StaticPaymentOutputDescriptorDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_TxCreationKeysDecodeErrorZ in the success state. -pub extern "C" fn CResult_TxCreationKeysDecodeErrorZ_ok(o: crate::lightning::ln::chan_utils::TxCreationKeys) -> CResult_TxCreationKeysDecodeErrorZ { - CResult_TxCreationKeysDecodeErrorZ { - contents: CResult_TxCreationKeysDecodeErrorZPtr { +/// Creates a new CResult_StaticPaymentOutputDescriptorDecodeErrorZ in the success state. +pub extern "C" fn CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o: crate::lightning::sign::StaticPaymentOutputDescriptor) -> CResult_StaticPaymentOutputDescriptorDecodeErrorZ { + CResult_StaticPaymentOutputDescriptorDecodeErrorZ { + contents: CResult_StaticPaymentOutputDescriptorDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_TxCreationKeysDecodeErrorZ in the error state. -pub extern "C" fn CResult_TxCreationKeysDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_TxCreationKeysDecodeErrorZ { - CResult_TxCreationKeysDecodeErrorZ { - contents: CResult_TxCreationKeysDecodeErrorZPtr { +/// Creates a new CResult_StaticPaymentOutputDescriptorDecodeErrorZ in the error state. +pub extern "C" fn CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_StaticPaymentOutputDescriptorDecodeErrorZ { + CResult_StaticPaymentOutputDescriptorDecodeErrorZ { + contents: CResult_StaticPaymentOutputDescriptorDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -749,13 +858,13 @@ pub extern "C" fn CResult_TxCreationKeysDecodeErrorZ_err(e: crate::lightning::ln } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_TxCreationKeysDecodeErrorZ_is_ok(o: &CResult_TxCreationKeysDecodeErrorZ) -> bool { +pub extern "C" fn CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(o: &CResult_StaticPaymentOutputDescriptorDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_TxCreationKeysDecodeErrorZ. -pub extern "C" fn CResult_TxCreationKeysDecodeErrorZ_free(_res: CResult_TxCreationKeysDecodeErrorZ) { } -impl Drop for CResult_TxCreationKeysDecodeErrorZ { +/// Frees any resources used by the CResult_StaticPaymentOutputDescriptorDecodeErrorZ. +pub extern "C" fn CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res: CResult_StaticPaymentOutputDescriptorDecodeErrorZ) { } +impl Drop for CResult_StaticPaymentOutputDescriptorDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -768,16 +877,16 @@ impl Drop for CResult_TxCreationKeysDecodeErrorZ { } } } -impl From> for CResult_TxCreationKeysDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_StaticPaymentOutputDescriptorDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_TxCreationKeysDecodeErrorZPtr { result } + CResult_StaticPaymentOutputDescriptorDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_TxCreationKeysDecodeErrorZPtr { err } + CResult_StaticPaymentOutputDescriptorDecodeErrorZPtr { err } }; Self { contents, @@ -785,59 +894,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_TxCreationKeysDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_StaticPaymentOutputDescriptorDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_TxCreationKeysDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_StaticPaymentOutputDescriptorDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_TxCreationKeysDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_StaticPaymentOutputDescriptorDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_TxCreationKeysDecodeErrorZ_clone(orig: &CResult_TxCreationKeysDecodeErrorZ) -> CResult_TxCreationKeysDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig: &CResult_StaticPaymentOutputDescriptorDecodeErrorZ) -> CResult_StaticPaymentOutputDescriptorDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_ChannelPublicKeysDecodeErrorZ -pub union CResult_ChannelPublicKeysDecodeErrorZPtr { +/// The contents of CResult_SpendableOutputDescriptorDecodeErrorZ +pub union CResult_SpendableOutputDescriptorDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::chan_utils::ChannelPublicKeys, + pub result: *mut crate::lightning::sign::SpendableOutputDescriptor, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_ChannelPublicKeysDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::chan_utils::ChannelPublicKeys on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_SpendableOutputDescriptorDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::sign::SpendableOutputDescriptor on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ChannelPublicKeysDecodeErrorZ { - /// The contents of this CResult_ChannelPublicKeysDecodeErrorZ, accessible via either +pub struct CResult_SpendableOutputDescriptorDecodeErrorZ { + /// The contents of this CResult_SpendableOutputDescriptorDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ChannelPublicKeysDecodeErrorZPtr, - /// Whether this CResult_ChannelPublicKeysDecodeErrorZ represents a success state. + pub contents: CResult_SpendableOutputDescriptorDecodeErrorZPtr, + /// Whether this CResult_SpendableOutputDescriptorDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ChannelPublicKeysDecodeErrorZ in the success state. -pub extern "C" fn CResult_ChannelPublicKeysDecodeErrorZ_ok(o: crate::lightning::ln::chan_utils::ChannelPublicKeys) -> CResult_ChannelPublicKeysDecodeErrorZ { - CResult_ChannelPublicKeysDecodeErrorZ { - contents: CResult_ChannelPublicKeysDecodeErrorZPtr { +/// Creates a new CResult_SpendableOutputDescriptorDecodeErrorZ in the success state. +pub extern "C" fn CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o: crate::lightning::sign::SpendableOutputDescriptor) -> CResult_SpendableOutputDescriptorDecodeErrorZ { + CResult_SpendableOutputDescriptorDecodeErrorZ { + contents: CResult_SpendableOutputDescriptorDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ChannelPublicKeysDecodeErrorZ in the error state. -pub extern "C" fn CResult_ChannelPublicKeysDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelPublicKeysDecodeErrorZ { - CResult_ChannelPublicKeysDecodeErrorZ { - contents: CResult_ChannelPublicKeysDecodeErrorZPtr { +/// Creates a new CResult_SpendableOutputDescriptorDecodeErrorZ in the error state. +pub extern "C" fn CResult_SpendableOutputDescriptorDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_SpendableOutputDescriptorDecodeErrorZ { + CResult_SpendableOutputDescriptorDecodeErrorZ { + contents: CResult_SpendableOutputDescriptorDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -845,13 +954,13 @@ pub extern "C" fn CResult_ChannelPublicKeysDecodeErrorZ_err(e: crate::lightning: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ChannelPublicKeysDecodeErrorZ_is_ok(o: &CResult_ChannelPublicKeysDecodeErrorZ) -> bool { +pub extern "C" fn CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(o: &CResult_SpendableOutputDescriptorDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_ChannelPublicKeysDecodeErrorZ. -pub extern "C" fn CResult_ChannelPublicKeysDecodeErrorZ_free(_res: CResult_ChannelPublicKeysDecodeErrorZ) { } -impl Drop for CResult_ChannelPublicKeysDecodeErrorZ { +/// Frees any resources used by the CResult_SpendableOutputDescriptorDecodeErrorZ. +pub extern "C" fn CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res: CResult_SpendableOutputDescriptorDecodeErrorZ) { } +impl Drop for CResult_SpendableOutputDescriptorDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -864,16 +973,16 @@ impl Drop for CResult_ChannelPublicKeysDecodeErrorZ { } } } -impl From> for CResult_ChannelPublicKeysDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_SpendableOutputDescriptorDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ChannelPublicKeysDecodeErrorZPtr { result } + CResult_SpendableOutputDescriptorDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ChannelPublicKeysDecodeErrorZPtr { err } + CResult_SpendableOutputDescriptorDecodeErrorZPtr { err } }; Self { contents, @@ -881,33 +990,125 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ChannelPublicKeysDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_SpendableOutputDescriptorDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_ChannelPublicKeysDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_SpendableOutputDescriptorDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_ChannelPublicKeysDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_SpendableOutputDescriptorDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ChannelPublicKeysDecodeErrorZ_clone(orig: &CResult_ChannelPublicKeysDecodeErrorZ) -> CResult_ChannelPublicKeysDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig: &CResult_SpendableOutputDescriptorDecodeErrorZ) -> CResult_SpendableOutputDescriptorDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// A dynamically-allocated array of crate::lightning::sign::SpendableOutputDescriptors of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_SpendableOutputDescriptorZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::sign::SpendableOutputDescriptor, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_SpendableOutputDescriptorZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::sign::SpendableOutputDescriptor] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_SpendableOutputDescriptorZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_SpendableOutputDescriptorZ_free(_res: CVec_SpendableOutputDescriptorZ) { } +impl Drop for CVec_SpendableOutputDescriptorZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_SpendableOutputDescriptorZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// A dynamically-allocated array of crate::c_types::TxOuts of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_TxOutZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::TxOut, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_TxOutZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::TxOut] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_TxOutZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_TxOutZ_free(_res: CVec_TxOutZ) { } +impl Drop for CVec_TxOutZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_TxOutZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} #[repr(C)] #[derive(Clone)] /// An enum which can either contain a u32 or not -pub enum COption_u32Z { - /// When we're in this state, this COption_u32Z contains a u32 +pub enum COption_PackedLockTimeZ { + /// When we're in this state, this COption_PackedLockTimeZ contains a u32 Some(u32), - /// When we're in this state, this COption_u32Z contains nothing + /// When we're in this state, this COption_PackedLockTimeZ contains nothing None } -impl COption_u32Z { +impl COption_PackedLockTimeZ { #[allow(unused)] pub(crate) fn is_some(&self) -> bool { if let Self::None = self { false } else { true } } @@ -919,94 +1120,132 @@ impl COption_u32Z { } } #[no_mangle] -/// Constructs a new COption_u32Z containing a u32 -pub extern "C" fn COption_u32Z_some(o: u32) -> COption_u32Z { - COption_u32Z::Some(o) +/// Constructs a new COption_PackedLockTimeZ containing a u32 +pub extern "C" fn COption_PackedLockTimeZ_some(o: u32) -> COption_PackedLockTimeZ { + COption_PackedLockTimeZ::Some(o) } #[no_mangle] -/// Constructs a new COption_u32Z containing nothing -pub extern "C" fn COption_u32Z_none() -> COption_u32Z { - COption_u32Z::None +/// Constructs a new COption_PackedLockTimeZ containing nothing +pub extern "C" fn COption_PackedLockTimeZ_none() -> COption_PackedLockTimeZ { + COption_PackedLockTimeZ::None } #[no_mangle] /// Frees any resources associated with the u32, if we are in the Some state -pub extern "C" fn COption_u32Z_free(_res: COption_u32Z) { } +pub extern "C" fn COption_PackedLockTimeZ_free(_res: COption_PackedLockTimeZ) { } #[no_mangle] -/// Creates a new COption_u32Z which has the same data as `orig` +/// Creates a new COption_PackedLockTimeZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_u32Z_clone(orig: &COption_u32Z) -> COption_u32Z { Clone::clone(&orig) } +pub extern "C" fn COption_PackedLockTimeZ_clone(orig: &COption_PackedLockTimeZ) -> COption_PackedLockTimeZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_HTLCOutputInCommitmentDecodeErrorZ -pub union CResult_HTLCOutputInCommitmentDecodeErrorZPtr { +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_PartiallySignedTransactionusizeZ { + /// The element at position 0 + pub a: crate::c_types::derived::CVec_u8Z, + /// The element at position 1 + pub b: usize, +} +impl From<(crate::c_types::derived::CVec_u8Z, usize)> for C2Tuple_PartiallySignedTransactionusizeZ { + fn from (tup: (crate::c_types::derived::CVec_u8Z, usize)) -> Self { + Self { + a: tup.0, + b: tup.1, + } + } +} +impl C2Tuple_PartiallySignedTransactionusizeZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::derived::CVec_u8Z, usize) { + (self.a, self.b) + } +} +impl Clone for C2Tuple_PartiallySignedTransactionusizeZ { + fn clone(&self) -> Self { + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), + } + } +} +#[no_mangle] +/// Creates a new tuple which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn C2Tuple_PartiallySignedTransactionusizeZ_clone(orig: &C2Tuple_PartiallySignedTransactionusizeZ) -> C2Tuple_PartiallySignedTransactionusizeZ { Clone::clone(&orig) } +/// Creates a new C2Tuple_PartiallySignedTransactionusizeZ from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_PartiallySignedTransactionusizeZ_new(a: crate::c_types::derived::CVec_u8Z, b: usize) -> C2Tuple_PartiallySignedTransactionusizeZ { + C2Tuple_PartiallySignedTransactionusizeZ { a, b, } +} + +#[no_mangle] +/// Frees any resources used by the C2Tuple_PartiallySignedTransactionusizeZ. +pub extern "C" fn C2Tuple_PartiallySignedTransactionusizeZ_free(_res: C2Tuple_PartiallySignedTransactionusizeZ) { } +#[repr(C)] +/// The contents of CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ +pub union CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::chan_utils::HTLCOutputInCommitment, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub result: *mut crate::c_types::derived::C2Tuple_PartiallySignedTransactionusizeZ, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut core::ffi::c_void, } #[repr(C)] -/// A CResult_HTLCOutputInCommitmentDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::chan_utils::HTLCOutputInCommitment on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::C2Tuple_PartiallySignedTransactionusizeZ on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_HTLCOutputInCommitmentDecodeErrorZ { - /// The contents of this CResult_HTLCOutputInCommitmentDecodeErrorZ, accessible via either +pub struct CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ { + /// The contents of this CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_HTLCOutputInCommitmentDecodeErrorZPtr, - /// Whether this CResult_HTLCOutputInCommitmentDecodeErrorZ represents a success state. + pub contents: CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZPtr, + /// Whether this CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_HTLCOutputInCommitmentDecodeErrorZ in the success state. -pub extern "C" fn CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o: crate::lightning::ln::chan_utils::HTLCOutputInCommitment) -> CResult_HTLCOutputInCommitmentDecodeErrorZ { - CResult_HTLCOutputInCommitmentDecodeErrorZ { - contents: CResult_HTLCOutputInCommitmentDecodeErrorZPtr { +/// Creates a new CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ in the success state. +pub extern "C" fn CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ_ok(o: crate::c_types::derived::C2Tuple_PartiallySignedTransactionusizeZ) -> CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ { + CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ { + contents: CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_HTLCOutputInCommitmentDecodeErrorZ in the error state. -pub extern "C" fn CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_HTLCOutputInCommitmentDecodeErrorZ { - CResult_HTLCOutputInCommitmentDecodeErrorZ { - contents: CResult_HTLCOutputInCommitmentDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), +/// Creates a new CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ in the error state. +pub extern "C" fn CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ_err() -> CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ { + CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ { + contents: CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZPtr { + err: core::ptr::null_mut(), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(o: &CResult_HTLCOutputInCommitmentDecodeErrorZ) -> bool { +pub extern "C" fn CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ_is_ok(o: &CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_HTLCOutputInCommitmentDecodeErrorZ. -pub extern "C" fn CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res: CResult_HTLCOutputInCommitmentDecodeErrorZ) { } -impl Drop for CResult_HTLCOutputInCommitmentDecodeErrorZ { +/// Frees any resources used by the CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ. +pub extern "C" fn CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ_free(_res: CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ) { } +impl Drop for CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } } } } -impl From> for CResult_HTLCOutputInCommitmentDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_HTLCOutputInCommitmentDecodeErrorZPtr { result } + CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZPtr { result } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_HTLCOutputInCommitmentDecodeErrorZPtr { err } + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -1014,124 +1253,133 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_HTLCOutputInCommitmentDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_HTLCOutputInCommitmentDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZPtr { + err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_HTLCOutputInCommitmentDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig: &CResult_HTLCOutputInCommitmentDecodeErrorZ) -> CResult_HTLCOutputInCommitmentDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ_clone(orig: &CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ) -> CResult_C2Tuple_PartiallySignedTransactionusizeZNoneZ { Clone::clone(&orig) } #[repr(C)] -/// An enum which can either contain a or not -pub enum COption_NoneZ { - /// When we're in this state, this COption_NoneZ contains a - Some, - /// When we're in this state, this COption_NoneZ contains nothing - None +/// A dynamically-allocated array of crate::c_types::ThirtyTwoBytess of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_PaymentPreimageZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::ThirtyTwoBytes, + /// The number of elements pointed to by `data`. + pub datalen: usize } -impl COption_NoneZ { - #[allow(unused)] pub(crate) fn is_some(&self) -> bool { - if let Self::None = self { false } else { true } +impl CVec_PaymentPreimageZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret } - #[allow(unused)] pub(crate) fn is_none(&self) -> bool { - !self.is_some() + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::ThirtyTwoBytes] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -#[no_mangle] -/// Constructs a new COption_NoneZ containing a -pub extern "C" fn COption_NoneZ_some() -> COption_NoneZ { - COption_NoneZ::Some +impl From> for CVec_PaymentPreimageZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } } #[no_mangle] -/// Constructs a new COption_NoneZ containing nothing -pub extern "C" fn COption_NoneZ_none() -> COption_NoneZ { - COption_NoneZ::None +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_PaymentPreimageZ_free(_res: CVec_PaymentPreimageZ) { } +impl Drop for CVec_PaymentPreimageZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_PaymentPreimageZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } } -#[no_mangle] -/// Frees any resources associated with the , if we are in the Some state -pub extern "C" fn COption_NoneZ_free(_res: COption_NoneZ) { } #[repr(C)] -/// The contents of CResult_CounterpartyChannelTransactionParametersDecodeErrorZ -pub union CResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::chan_utils::CounterpartyChannelTransactionParameters, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, +/// The contents of CResult_NoneNoneZ +pub union CResult_NoneNoneZPtr { + /// Note that this value is always NULL, as there are no contents in the OK variant + pub result: *mut core::ffi::c_void, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut core::ffi::c_void, } #[repr(C)] -/// A CResult_CounterpartyChannelTransactionParametersDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::chan_utils::CounterpartyChannelTransactionParameters on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_NoneNoneZ represents the result of a fallible operation, +/// containing a () on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { - /// The contents of this CResult_CounterpartyChannelTransactionParametersDecodeErrorZ, accessible via either +pub struct CResult_NoneNoneZ { + /// The contents of this CResult_NoneNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr, - /// Whether this CResult_CounterpartyChannelTransactionParametersDecodeErrorZ represents a success state. + pub contents: CResult_NoneNoneZPtr, + /// Whether this CResult_NoneNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_CounterpartyChannelTransactionParametersDecodeErrorZ in the success state. -pub extern "C" fn CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o: crate::lightning::ln::chan_utils::CounterpartyChannelTransactionParameters) -> CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { - CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { - contents: CResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), +/// Creates a new CResult_NoneNoneZ in the success state. +pub extern "C" fn CResult_NoneNoneZ_ok() -> CResult_NoneNoneZ { + CResult_NoneNoneZ { + contents: CResult_NoneNoneZPtr { + result: core::ptr::null_mut(), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_CounterpartyChannelTransactionParametersDecodeErrorZ in the error state. -pub extern "C" fn CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { - CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { - contents: CResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), +/// Creates a new CResult_NoneNoneZ in the error state. +pub extern "C" fn CResult_NoneNoneZ_err() -> CResult_NoneNoneZ { + CResult_NoneNoneZ { + contents: CResult_NoneNoneZPtr { + err: core::ptr::null_mut(), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(o: &CResult_CounterpartyChannelTransactionParametersDecodeErrorZ) -> bool { +pub extern "C" fn CResult_NoneNoneZ_is_ok(o: &CResult_NoneNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_CounterpartyChannelTransactionParametersDecodeErrorZ. -pub extern "C" fn CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res: CResult_CounterpartyChannelTransactionParametersDecodeErrorZ) { } -impl Drop for CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { +/// Frees any resources used by the CResult_NoneNoneZ. +pub extern "C" fn CResult_NoneNoneZ_free(_res: CResult_NoneNoneZ) { } +impl Drop for CResult_NoneNoneZ { fn drop(&mut self) { if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } } } } -impl From> for CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_NoneNoneZ { + fn from(mut o: crate::c_types::CResultTempl<(), ()>) -> Self { let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr { result } + let _ = unsafe { Box::from_raw(o.contents.result) }; + o.contents.result = core::ptr::null_mut(); + CResult_NoneNoneZPtr { result: core::ptr::null_mut() } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr { err } + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_NoneNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -1139,237 +1387,179 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_NoneNoneZPtr { + result: core::ptr::null_mut() } } } else { - Self { result_ok: false, contents: CResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_NoneNoneZPtr { + err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_CounterpartyChannelTransactionParametersDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_NoneNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig: &CResult_CounterpartyChannelTransactionParametersDecodeErrorZ) -> CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// The contents of CResult_ChannelTransactionParametersDecodeErrorZ -pub union CResult_ChannelTransactionParametersDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::chan_utils::ChannelTransactionParameters, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, -} +pub extern "C" fn CResult_NoneNoneZ_clone(orig: &CResult_NoneNoneZ) -> CResult_NoneNoneZ { Clone::clone(&orig) } #[repr(C)] -/// A CResult_ChannelTransactionParametersDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::chan_utils::ChannelTransactionParameters on success and a crate::lightning::ln::msgs::DecodeError on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ChannelTransactionParametersDecodeErrorZ { - /// The contents of this CResult_ChannelTransactionParametersDecodeErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ChannelTransactionParametersDecodeErrorZPtr, - /// Whether this CResult_ChannelTransactionParametersDecodeErrorZ represents a success state. - pub result_ok: bool, +/// A dynamically-allocated array of crate::c_types::Signatures of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_SignatureZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::Signature, + /// The number of elements pointed to by `data`. + pub datalen: usize } -#[no_mangle] -/// Creates a new CResult_ChannelTransactionParametersDecodeErrorZ in the success state. -pub extern "C" fn CResult_ChannelTransactionParametersDecodeErrorZ_ok(o: crate::lightning::ln::chan_utils::ChannelTransactionParameters) -> CResult_ChannelTransactionParametersDecodeErrorZ { - CResult_ChannelTransactionParametersDecodeErrorZ { - contents: CResult_ChannelTransactionParametersDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, +impl CVec_SignatureZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret } -} -#[no_mangle] -/// Creates a new CResult_ChannelTransactionParametersDecodeErrorZ in the error state. -pub extern "C" fn CResult_ChannelTransactionParametersDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelTransactionParametersDecodeErrorZ { - CResult_ChannelTransactionParametersDecodeErrorZ { - contents: CResult_ChannelTransactionParametersDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), - }, - result_ok: false, + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::Signature] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -/// Checks if the given object is currently in the success state -#[no_mangle] -pub extern "C" fn CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(o: &CResult_ChannelTransactionParametersDecodeErrorZ) -> bool { - o.result_ok +impl From> for CVec_SignatureZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } } #[no_mangle] -/// Frees any resources used by the CResult_ChannelTransactionParametersDecodeErrorZ. -pub extern "C" fn CResult_ChannelTransactionParametersDecodeErrorZ_free(_res: CResult_ChannelTransactionParametersDecodeErrorZ) { } -impl Drop for CResult_ChannelTransactionParametersDecodeErrorZ { +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_SignatureZ_free(_res: CVec_SignatureZ) { } +impl Drop for CVec_SignatureZ { fn drop(&mut self) { - if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } - } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } - } - } -} -impl From> for CResult_ChannelTransactionParametersDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { - let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ChannelTransactionParametersDecodeErrorZPtr { result } - } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ChannelTransactionParametersDecodeErrorZPtr { err } - }; - Self { - contents, - result_ok: o.result_ok, - } + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl Clone for CResult_ChannelTransactionParametersDecodeErrorZ { +impl Clone for CVec_SignatureZ { fn clone(&self) -> Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_ChannelTransactionParametersDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_ChannelTransactionParametersDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } - } + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) } } -#[no_mangle] -/// Creates a new CResult_ChannelTransactionParametersDecodeErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig: &CResult_ChannelTransactionParametersDecodeErrorZ) -> CResult_ChannelTransactionParametersDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// A dynamically-allocated array of crate::c_types::Signatures of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_SignatureZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::Signature, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_SignatureZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::Signature] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_SignatureCVec_SignatureZZ { + /// The element at position 0 + pub a: crate::c_types::Signature, + /// The element at position 1 + pub b: crate::c_types::derived::CVec_SignatureZ, } -impl From> for CVec_SignatureZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } +impl From<(crate::c_types::Signature, crate::c_types::derived::CVec_SignatureZ)> for C2Tuple_SignatureCVec_SignatureZZ { + fn from (tup: (crate::c_types::Signature, crate::c_types::derived::CVec_SignatureZ)) -> Self { + Self { + a: tup.0, + b: tup.1, + } } } -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_SignatureZ_free(_res: CVec_SignatureZ) { } -impl Drop for CVec_SignatureZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; +impl C2Tuple_SignatureCVec_SignatureZZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::Signature, crate::c_types::derived::CVec_SignatureZ) { + (self.a, self.b) } } -impl Clone for CVec_SignatureZ { +impl Clone for C2Tuple_SignatureCVec_SignatureZZ { fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), + } } } +#[no_mangle] +/// Creates a new tuple which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn C2Tuple_SignatureCVec_SignatureZZ_clone(orig: &C2Tuple_SignatureCVec_SignatureZZ) -> C2Tuple_SignatureCVec_SignatureZZ { Clone::clone(&orig) } +/// Creates a new C2Tuple_SignatureCVec_SignatureZZ from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_SignatureCVec_SignatureZZ_new(a: crate::c_types::Signature, b: crate::c_types::derived::CVec_SignatureZ) -> C2Tuple_SignatureCVec_SignatureZZ { + C2Tuple_SignatureCVec_SignatureZZ { a, b, } +} + +#[no_mangle] +/// Frees any resources used by the C2Tuple_SignatureCVec_SignatureZZ. +pub extern "C" fn C2Tuple_SignatureCVec_SignatureZZ_free(_res: C2Tuple_SignatureCVec_SignatureZZ) { } #[repr(C)] -/// The contents of CResult_HolderCommitmentTransactionDecodeErrorZ -pub union CResult_HolderCommitmentTransactionDecodeErrorZPtr { +/// The contents of CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ +pub union CResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::chan_utils::HolderCommitmentTransaction, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub result: *mut crate::c_types::derived::C2Tuple_SignatureCVec_SignatureZZ, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut core::ffi::c_void, } #[repr(C)] -/// A CResult_HolderCommitmentTransactionDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::chan_utils::HolderCommitmentTransaction on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::C2Tuple_SignatureCVec_SignatureZZ on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_HolderCommitmentTransactionDecodeErrorZ { - /// The contents of this CResult_HolderCommitmentTransactionDecodeErrorZ, accessible via either +pub struct CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { + /// The contents of this CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_HolderCommitmentTransactionDecodeErrorZPtr, - /// Whether this CResult_HolderCommitmentTransactionDecodeErrorZ represents a success state. + pub contents: CResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr, + /// Whether this CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_HolderCommitmentTransactionDecodeErrorZ in the success state. -pub extern "C" fn CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o: crate::lightning::ln::chan_utils::HolderCommitmentTransaction) -> CResult_HolderCommitmentTransactionDecodeErrorZ { - CResult_HolderCommitmentTransactionDecodeErrorZ { - contents: CResult_HolderCommitmentTransactionDecodeErrorZPtr { +/// Creates a new CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ in the success state. +pub extern "C" fn CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o: crate::c_types::derived::C2Tuple_SignatureCVec_SignatureZZ) -> CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { + CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { + contents: CResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_HolderCommitmentTransactionDecodeErrorZ in the error state. -pub extern "C" fn CResult_HolderCommitmentTransactionDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_HolderCommitmentTransactionDecodeErrorZ { - CResult_HolderCommitmentTransactionDecodeErrorZ { - contents: CResult_HolderCommitmentTransactionDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), +/// Creates a new CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ in the error state. +pub extern "C" fn CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err() -> CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { + CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { + contents: CResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr { + err: core::ptr::null_mut(), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(o: &CResult_HolderCommitmentTransactionDecodeErrorZ) -> bool { +pub extern "C" fn CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(o: &CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_HolderCommitmentTransactionDecodeErrorZ. -pub extern "C" fn CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res: CResult_HolderCommitmentTransactionDecodeErrorZ) { } -impl Drop for CResult_HolderCommitmentTransactionDecodeErrorZ { +/// Frees any resources used by the CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ. +pub extern "C" fn CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res: CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ) { } +impl Drop for CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } } } } -impl From> for CResult_HolderCommitmentTransactionDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_HolderCommitmentTransactionDecodeErrorZPtr { result } + CResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr { result } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_HolderCommitmentTransactionDecodeErrorZPtr { err } + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -1377,95 +1567,91 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_HolderCommitmentTransactionDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_HolderCommitmentTransactionDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr { + err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_HolderCommitmentTransactionDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig: &CResult_HolderCommitmentTransactionDecodeErrorZ) -> CResult_HolderCommitmentTransactionDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig: &CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ) -> CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_BuiltCommitmentTransactionDecodeErrorZ -pub union CResult_BuiltCommitmentTransactionDecodeErrorZPtr { +/// The contents of CResult_SignatureNoneZ +pub union CResult_SignatureNoneZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::chan_utils::BuiltCommitmentTransaction, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub result: *mut crate::c_types::Signature, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut core::ffi::c_void, } #[repr(C)] -/// A CResult_BuiltCommitmentTransactionDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::chan_utils::BuiltCommitmentTransaction on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_SignatureNoneZ represents the result of a fallible operation, +/// containing a crate::c_types::Signature on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_BuiltCommitmentTransactionDecodeErrorZ { - /// The contents of this CResult_BuiltCommitmentTransactionDecodeErrorZ, accessible via either +pub struct CResult_SignatureNoneZ { + /// The contents of this CResult_SignatureNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_BuiltCommitmentTransactionDecodeErrorZPtr, - /// Whether this CResult_BuiltCommitmentTransactionDecodeErrorZ represents a success state. + pub contents: CResult_SignatureNoneZPtr, + /// Whether this CResult_SignatureNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_BuiltCommitmentTransactionDecodeErrorZ in the success state. -pub extern "C" fn CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o: crate::lightning::ln::chan_utils::BuiltCommitmentTransaction) -> CResult_BuiltCommitmentTransactionDecodeErrorZ { - CResult_BuiltCommitmentTransactionDecodeErrorZ { - contents: CResult_BuiltCommitmentTransactionDecodeErrorZPtr { +/// Creates a new CResult_SignatureNoneZ in the success state. +pub extern "C" fn CResult_SignatureNoneZ_ok(o: crate::c_types::Signature) -> CResult_SignatureNoneZ { + CResult_SignatureNoneZ { + contents: CResult_SignatureNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_BuiltCommitmentTransactionDecodeErrorZ in the error state. -pub extern "C" fn CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_BuiltCommitmentTransactionDecodeErrorZ { - CResult_BuiltCommitmentTransactionDecodeErrorZ { - contents: CResult_BuiltCommitmentTransactionDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), +/// Creates a new CResult_SignatureNoneZ in the error state. +pub extern "C" fn CResult_SignatureNoneZ_err() -> CResult_SignatureNoneZ { + CResult_SignatureNoneZ { + contents: CResult_SignatureNoneZPtr { + err: core::ptr::null_mut(), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(o: &CResult_BuiltCommitmentTransactionDecodeErrorZ) -> bool { +pub extern "C" fn CResult_SignatureNoneZ_is_ok(o: &CResult_SignatureNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_BuiltCommitmentTransactionDecodeErrorZ. -pub extern "C" fn CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res: CResult_BuiltCommitmentTransactionDecodeErrorZ) { } -impl Drop for CResult_BuiltCommitmentTransactionDecodeErrorZ { +/// Frees any resources used by the CResult_SignatureNoneZ. +pub extern "C" fn CResult_SignatureNoneZ_free(_res: CResult_SignatureNoneZ) { } +impl Drop for CResult_SignatureNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } } } } -impl From> for CResult_BuiltCommitmentTransactionDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_SignatureNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_BuiltCommitmentTransactionDecodeErrorZPtr { result } + CResult_SignatureNoneZPtr { result } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_BuiltCommitmentTransactionDecodeErrorZPtr { err } + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_SignatureNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -1473,58 +1659,58 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_BuiltCommitmentTransactionDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_SignatureNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_BuiltCommitmentTransactionDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_SignatureNoneZPtr { + err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_BuiltCommitmentTransactionDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_SignatureNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig: &CResult_BuiltCommitmentTransactionDecodeErrorZ) -> CResult_BuiltCommitmentTransactionDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_SignatureNoneZ_clone(orig: &CResult_SignatureNoneZ) -> CResult_SignatureNoneZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_TrustedClosingTransactionNoneZ -pub union CResult_TrustedClosingTransactionNoneZPtr { +/// The contents of CResult_PublicKeyNoneZ +pub union CResult_PublicKeyNoneZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::chan_utils::TrustedClosingTransaction, + pub result: *mut crate::c_types::PublicKey, /// Note that this value is always NULL, as there are no contents in the Err variant pub err: *mut core::ffi::c_void, } #[repr(C)] -/// A CResult_TrustedClosingTransactionNoneZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::chan_utils::TrustedClosingTransaction on success and a () on failure. +/// A CResult_PublicKeyNoneZ represents the result of a fallible operation, +/// containing a crate::c_types::PublicKey on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_TrustedClosingTransactionNoneZ { - /// The contents of this CResult_TrustedClosingTransactionNoneZ, accessible via either +pub struct CResult_PublicKeyNoneZ { + /// The contents of this CResult_PublicKeyNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_TrustedClosingTransactionNoneZPtr, - /// Whether this CResult_TrustedClosingTransactionNoneZ represents a success state. + pub contents: CResult_PublicKeyNoneZPtr, + /// Whether this CResult_PublicKeyNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_TrustedClosingTransactionNoneZ in the success state. -pub extern "C" fn CResult_TrustedClosingTransactionNoneZ_ok(o: crate::lightning::ln::chan_utils::TrustedClosingTransaction) -> CResult_TrustedClosingTransactionNoneZ { - CResult_TrustedClosingTransactionNoneZ { - contents: CResult_TrustedClosingTransactionNoneZPtr { +/// Creates a new CResult_PublicKeyNoneZ in the success state. +pub extern "C" fn CResult_PublicKeyNoneZ_ok(o: crate::c_types::PublicKey) -> CResult_PublicKeyNoneZ { + CResult_PublicKeyNoneZ { + contents: CResult_PublicKeyNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_TrustedClosingTransactionNoneZ in the error state. -pub extern "C" fn CResult_TrustedClosingTransactionNoneZ_err() -> CResult_TrustedClosingTransactionNoneZ { - CResult_TrustedClosingTransactionNoneZ { - contents: CResult_TrustedClosingTransactionNoneZPtr { +/// Creates a new CResult_PublicKeyNoneZ in the error state. +pub extern "C" fn CResult_PublicKeyNoneZ_err() -> CResult_PublicKeyNoneZ { + CResult_PublicKeyNoneZ { + contents: CResult_PublicKeyNoneZPtr { err: core::ptr::null_mut(), }, result_ok: false, @@ -1532,13 +1718,13 @@ pub extern "C" fn CResult_TrustedClosingTransactionNoneZ_err() -> CResult_Truste } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_TrustedClosingTransactionNoneZ_is_ok(o: &CResult_TrustedClosingTransactionNoneZ) -> bool { +pub extern "C" fn CResult_PublicKeyNoneZ_is_ok(o: &CResult_PublicKeyNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_TrustedClosingTransactionNoneZ. -pub extern "C" fn CResult_TrustedClosingTransactionNoneZ_free(_res: CResult_TrustedClosingTransactionNoneZ) { } -impl Drop for CResult_TrustedClosingTransactionNoneZ { +/// Frees any resources used by the CResult_PublicKeyNoneZ. +pub extern "C" fn CResult_PublicKeyNoneZ_free(_res: CResult_PublicKeyNoneZ) { } +impl Drop for CResult_PublicKeyNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -1548,16 +1734,16 @@ impl Drop for CResult_TrustedClosingTransactionNoneZ { } } } -impl From> for CResult_TrustedClosingTransactionNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_PublicKeyNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_TrustedClosingTransactionNoneZPtr { result } + CResult_PublicKeyNoneZPtr { result } } else { let _ = unsafe { Box::from_raw(o.contents.err) }; o.contents.err = core::ptr::null_mut(); - CResult_TrustedClosingTransactionNoneZPtr { err: core::ptr::null_mut() } + CResult_PublicKeyNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -1565,78 +1751,128 @@ impl From Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_PublicKeyNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_PublicKeyNoneZPtr { + err: core::ptr::null_mut() + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_PublicKeyNoneZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_PublicKeyNoneZ_clone(orig: &CResult_PublicKeyNoneZ) -> CResult_PublicKeyNoneZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_CommitmentTransactionDecodeErrorZ -pub union CResult_CommitmentTransactionDecodeErrorZPtr { +#[derive(Clone)] +/// An enum which can either contain a crate::c_types::BigEndianScalar or not +pub enum COption_ScalarZ { + /// When we're in this state, this COption_ScalarZ contains a crate::c_types::BigEndianScalar + Some(crate::c_types::BigEndianScalar), + /// When we're in this state, this COption_ScalarZ contains nothing + None +} +impl COption_ScalarZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::BigEndianScalar { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_ScalarZ containing a crate::c_types::BigEndianScalar +pub extern "C" fn COption_ScalarZ_some(o: crate::c_types::BigEndianScalar) -> COption_ScalarZ { + COption_ScalarZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_ScalarZ containing nothing +pub extern "C" fn COption_ScalarZ_none() -> COption_ScalarZ { + COption_ScalarZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::c_types::BigEndianScalar, if we are in the Some state +pub extern "C" fn COption_ScalarZ_free(_res: COption_ScalarZ) { } +#[no_mangle] +/// Creates a new COption_ScalarZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_ScalarZ_clone(orig: &COption_ScalarZ) -> COption_ScalarZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_SharedSecretNoneZ +pub union CResult_SharedSecretNoneZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::chan_utils::CommitmentTransaction, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub result: *mut crate::c_types::ThirtyTwoBytes, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut core::ffi::c_void, } #[repr(C)] -/// A CResult_CommitmentTransactionDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::chan_utils::CommitmentTransaction on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_SharedSecretNoneZ represents the result of a fallible operation, +/// containing a crate::c_types::ThirtyTwoBytes on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_CommitmentTransactionDecodeErrorZ { - /// The contents of this CResult_CommitmentTransactionDecodeErrorZ, accessible via either +pub struct CResult_SharedSecretNoneZ { + /// The contents of this CResult_SharedSecretNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_CommitmentTransactionDecodeErrorZPtr, - /// Whether this CResult_CommitmentTransactionDecodeErrorZ represents a success state. + pub contents: CResult_SharedSecretNoneZPtr, + /// Whether this CResult_SharedSecretNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_CommitmentTransactionDecodeErrorZ in the success state. -pub extern "C" fn CResult_CommitmentTransactionDecodeErrorZ_ok(o: crate::lightning::ln::chan_utils::CommitmentTransaction) -> CResult_CommitmentTransactionDecodeErrorZ { - CResult_CommitmentTransactionDecodeErrorZ { - contents: CResult_CommitmentTransactionDecodeErrorZPtr { +/// Creates a new CResult_SharedSecretNoneZ in the success state. +pub extern "C" fn CResult_SharedSecretNoneZ_ok(o: crate::c_types::ThirtyTwoBytes) -> CResult_SharedSecretNoneZ { + CResult_SharedSecretNoneZ { + contents: CResult_SharedSecretNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_CommitmentTransactionDecodeErrorZ in the error state. -pub extern "C" fn CResult_CommitmentTransactionDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_CommitmentTransactionDecodeErrorZ { - CResult_CommitmentTransactionDecodeErrorZ { - contents: CResult_CommitmentTransactionDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), +/// Creates a new CResult_SharedSecretNoneZ in the error state. +pub extern "C" fn CResult_SharedSecretNoneZ_err() -> CResult_SharedSecretNoneZ { + CResult_SharedSecretNoneZ { + contents: CResult_SharedSecretNoneZPtr { + err: core::ptr::null_mut(), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_CommitmentTransactionDecodeErrorZ_is_ok(o: &CResult_CommitmentTransactionDecodeErrorZ) -> bool { +pub extern "C" fn CResult_SharedSecretNoneZ_is_ok(o: &CResult_SharedSecretNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_CommitmentTransactionDecodeErrorZ. -pub extern "C" fn CResult_CommitmentTransactionDecodeErrorZ_free(_res: CResult_CommitmentTransactionDecodeErrorZ) { } -impl Drop for CResult_CommitmentTransactionDecodeErrorZ { +/// Frees any resources used by the CResult_SharedSecretNoneZ. +pub extern "C" fn CResult_SharedSecretNoneZ_free(_res: CResult_SharedSecretNoneZ) { } +impl Drop for CResult_SharedSecretNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } } } } -impl From> for CResult_CommitmentTransactionDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_SharedSecretNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_CommitmentTransactionDecodeErrorZPtr { result } + CResult_SharedSecretNoneZPtr { result } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_CommitmentTransactionDecodeErrorZPtr { err } + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_SharedSecretNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -1644,58 +1880,104 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_CommitmentTransactionDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_SharedSecretNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_CommitmentTransactionDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_SharedSecretNoneZPtr { + err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_CommitmentTransactionDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_SharedSecretNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_CommitmentTransactionDecodeErrorZ_clone(orig: &CResult_CommitmentTransactionDecodeErrorZ) -> CResult_CommitmentTransactionDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_SharedSecretNoneZ_clone(orig: &CResult_SharedSecretNoneZ) -> CResult_SharedSecretNoneZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_TrustedCommitmentTransactionNoneZ -pub union CResult_TrustedCommitmentTransactionNoneZPtr { +/// A dynamically-allocated array of crate::c_types::U5s of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_U5Z { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::U5, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_U5Z { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::U5] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_U5Z { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_U5Z_free(_res: CVec_U5Z) { } +impl Drop for CVec_U5Z { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_U5Z { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// The contents of CResult_RecoverableSignatureNoneZ +pub union CResult_RecoverableSignatureNoneZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::chan_utils::TrustedCommitmentTransaction, + pub result: *mut crate::c_types::RecoverableSignature, /// Note that this value is always NULL, as there are no contents in the Err variant pub err: *mut core::ffi::c_void, } #[repr(C)] -/// A CResult_TrustedCommitmentTransactionNoneZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::chan_utils::TrustedCommitmentTransaction on success and a () on failure. +/// A CResult_RecoverableSignatureNoneZ represents the result of a fallible operation, +/// containing a crate::c_types::RecoverableSignature on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_TrustedCommitmentTransactionNoneZ { - /// The contents of this CResult_TrustedCommitmentTransactionNoneZ, accessible via either +pub struct CResult_RecoverableSignatureNoneZ { + /// The contents of this CResult_RecoverableSignatureNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_TrustedCommitmentTransactionNoneZPtr, - /// Whether this CResult_TrustedCommitmentTransactionNoneZ represents a success state. + pub contents: CResult_RecoverableSignatureNoneZPtr, + /// Whether this CResult_RecoverableSignatureNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_TrustedCommitmentTransactionNoneZ in the success state. -pub extern "C" fn CResult_TrustedCommitmentTransactionNoneZ_ok(o: crate::lightning::ln::chan_utils::TrustedCommitmentTransaction) -> CResult_TrustedCommitmentTransactionNoneZ { - CResult_TrustedCommitmentTransactionNoneZ { - contents: CResult_TrustedCommitmentTransactionNoneZPtr { +/// Creates a new CResult_RecoverableSignatureNoneZ in the success state. +pub extern "C" fn CResult_RecoverableSignatureNoneZ_ok(o: crate::c_types::RecoverableSignature) -> CResult_RecoverableSignatureNoneZ { + CResult_RecoverableSignatureNoneZ { + contents: CResult_RecoverableSignatureNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_TrustedCommitmentTransactionNoneZ in the error state. -pub extern "C" fn CResult_TrustedCommitmentTransactionNoneZ_err() -> CResult_TrustedCommitmentTransactionNoneZ { - CResult_TrustedCommitmentTransactionNoneZ { - contents: CResult_TrustedCommitmentTransactionNoneZPtr { +/// Creates a new CResult_RecoverableSignatureNoneZ in the error state. +pub extern "C" fn CResult_RecoverableSignatureNoneZ_err() -> CResult_RecoverableSignatureNoneZ { + CResult_RecoverableSignatureNoneZ { + contents: CResult_RecoverableSignatureNoneZPtr { err: core::ptr::null_mut(), }, result_ok: false, @@ -1703,13 +1985,13 @@ pub extern "C" fn CResult_TrustedCommitmentTransactionNoneZ_err() -> CResult_Tru } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_TrustedCommitmentTransactionNoneZ_is_ok(o: &CResult_TrustedCommitmentTransactionNoneZ) -> bool { +pub extern "C" fn CResult_RecoverableSignatureNoneZ_is_ok(o: &CResult_RecoverableSignatureNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_TrustedCommitmentTransactionNoneZ. -pub extern "C" fn CResult_TrustedCommitmentTransactionNoneZ_free(_res: CResult_TrustedCommitmentTransactionNoneZ) { } -impl Drop for CResult_TrustedCommitmentTransactionNoneZ { +/// Frees any resources used by the CResult_RecoverableSignatureNoneZ. +pub extern "C" fn CResult_RecoverableSignatureNoneZ_free(_res: CResult_RecoverableSignatureNoneZ) { } +impl Drop for CResult_RecoverableSignatureNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -1719,16 +2001,16 @@ impl Drop for CResult_TrustedCommitmentTransactionNoneZ { } } } -impl From> for CResult_TrustedCommitmentTransactionNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_RecoverableSignatureNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_TrustedCommitmentTransactionNoneZPtr { result } + CResult_RecoverableSignatureNoneZPtr { result } } else { let _ = unsafe { Box::from_raw(o.contents.err) }; o.contents.err = core::ptr::null_mut(); - CResult_TrustedCommitmentTransactionNoneZPtr { err: core::ptr::null_mut() } + CResult_RecoverableSignatureNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -1736,74 +2018,95 @@ impl From Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_RecoverableSignatureNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_RecoverableSignatureNoneZPtr { + err: core::ptr::null_mut() + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_RecoverableSignatureNoneZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_RecoverableSignatureNoneZ_clone(orig: &CResult_RecoverableSignatureNoneZ) -> CResult_RecoverableSignatureNoneZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_CVec_SignatureZNoneZ -pub union CResult_CVec_SignatureZNoneZPtr { +/// The contents of CResult_WriteableEcdsaChannelSignerDecodeErrorZ +pub union CResult_WriteableEcdsaChannelSignerDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::CVec_SignatureZ, - /// Note that this value is always NULL, as there are no contents in the Err variant - pub err: *mut core::ffi::c_void, + pub result: *mut crate::lightning::sign::WriteableEcdsaChannelSigner, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_CVec_SignatureZNoneZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::CVec_SignatureZ on success and a () on failure. +/// A CResult_WriteableEcdsaChannelSignerDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::sign::WriteableEcdsaChannelSigner on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_CVec_SignatureZNoneZ { - /// The contents of this CResult_CVec_SignatureZNoneZ, accessible via either +pub struct CResult_WriteableEcdsaChannelSignerDecodeErrorZ { + /// The contents of this CResult_WriteableEcdsaChannelSignerDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_CVec_SignatureZNoneZPtr, - /// Whether this CResult_CVec_SignatureZNoneZ represents a success state. + pub contents: CResult_WriteableEcdsaChannelSignerDecodeErrorZPtr, + /// Whether this CResult_WriteableEcdsaChannelSignerDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_CVec_SignatureZNoneZ in the success state. -pub extern "C" fn CResult_CVec_SignatureZNoneZ_ok(o: crate::c_types::derived::CVec_SignatureZ) -> CResult_CVec_SignatureZNoneZ { - CResult_CVec_SignatureZNoneZ { - contents: CResult_CVec_SignatureZNoneZPtr { +/// Creates a new CResult_WriteableEcdsaChannelSignerDecodeErrorZ in the success state. +pub extern "C" fn CResult_WriteableEcdsaChannelSignerDecodeErrorZ_ok(o: crate::lightning::sign::WriteableEcdsaChannelSigner) -> CResult_WriteableEcdsaChannelSignerDecodeErrorZ { + CResult_WriteableEcdsaChannelSignerDecodeErrorZ { + contents: CResult_WriteableEcdsaChannelSignerDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_CVec_SignatureZNoneZ in the error state. -pub extern "C" fn CResult_CVec_SignatureZNoneZ_err() -> CResult_CVec_SignatureZNoneZ { - CResult_CVec_SignatureZNoneZ { - contents: CResult_CVec_SignatureZNoneZPtr { - err: core::ptr::null_mut(), +/// Creates a new CResult_WriteableEcdsaChannelSignerDecodeErrorZ in the error state. +pub extern "C" fn CResult_WriteableEcdsaChannelSignerDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_WriteableEcdsaChannelSignerDecodeErrorZ { + CResult_WriteableEcdsaChannelSignerDecodeErrorZ { + contents: CResult_WriteableEcdsaChannelSignerDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_CVec_SignatureZNoneZ_is_ok(o: &CResult_CVec_SignatureZNoneZ) -> bool { +pub extern "C" fn CResult_WriteableEcdsaChannelSignerDecodeErrorZ_is_ok(o: &CResult_WriteableEcdsaChannelSignerDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_CVec_SignatureZNoneZ. -pub extern "C" fn CResult_CVec_SignatureZNoneZ_free(_res: CResult_CVec_SignatureZNoneZ) { } -impl Drop for CResult_CVec_SignatureZNoneZ { +/// Frees any resources used by the CResult_WriteableEcdsaChannelSignerDecodeErrorZ. +pub extern "C" fn CResult_WriteableEcdsaChannelSignerDecodeErrorZ_free(_res: CResult_WriteableEcdsaChannelSignerDecodeErrorZ) { } +impl Drop for CResult_WriteableEcdsaChannelSignerDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } } } } -impl From> for CResult_CVec_SignatureZNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_WriteableEcdsaChannelSignerDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_CVec_SignatureZNoneZPtr { result } + CResult_WriteableEcdsaChannelSignerDecodeErrorZPtr { result } } else { - let _ = unsafe { Box::from_raw(o.contents.err) }; - o.contents.err = core::ptr::null_mut(); - CResult_CVec_SignatureZNoneZPtr { err: core::ptr::null_mut() } + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_WriteableEcdsaChannelSignerDecodeErrorZPtr { err } }; Self { contents, @@ -1811,95 +2114,74 @@ impl From Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_CVec_SignatureZNoneZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_CVec_SignatureZNoneZPtr { - err: core::ptr::null_mut() - } } - } - } -} -#[no_mangle] -/// Creates a new CResult_CVec_SignatureZNoneZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_CVec_SignatureZNoneZ_clone(orig: &CResult_CVec_SignatureZNoneZ) -> CResult_CVec_SignatureZNoneZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_ShutdownScriptDecodeErrorZ -pub union CResult_ShutdownScriptDecodeErrorZPtr { +/// The contents of CResult_ScriptNoneZ +pub union CResult_ScriptNoneZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::script::ShutdownScript, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub result: *mut crate::c_types::derived::CVec_u8Z, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut core::ffi::c_void, } #[repr(C)] -/// A CResult_ShutdownScriptDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::script::ShutdownScript on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_ScriptNoneZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::CVec_u8Z on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ShutdownScriptDecodeErrorZ { - /// The contents of this CResult_ShutdownScriptDecodeErrorZ, accessible via either +pub struct CResult_ScriptNoneZ { + /// The contents of this CResult_ScriptNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ShutdownScriptDecodeErrorZPtr, - /// Whether this CResult_ShutdownScriptDecodeErrorZ represents a success state. + pub contents: CResult_ScriptNoneZPtr, + /// Whether this CResult_ScriptNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ShutdownScriptDecodeErrorZ in the success state. -pub extern "C" fn CResult_ShutdownScriptDecodeErrorZ_ok(o: crate::lightning::ln::script::ShutdownScript) -> CResult_ShutdownScriptDecodeErrorZ { - CResult_ShutdownScriptDecodeErrorZ { - contents: CResult_ShutdownScriptDecodeErrorZPtr { +/// Creates a new CResult_ScriptNoneZ in the success state. +pub extern "C" fn CResult_ScriptNoneZ_ok(o: crate::c_types::derived::CVec_u8Z) -> CResult_ScriptNoneZ { + CResult_ScriptNoneZ { + contents: CResult_ScriptNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ShutdownScriptDecodeErrorZ in the error state. -pub extern "C" fn CResult_ShutdownScriptDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ShutdownScriptDecodeErrorZ { - CResult_ShutdownScriptDecodeErrorZ { - contents: CResult_ShutdownScriptDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), +/// Creates a new CResult_ScriptNoneZ in the error state. +pub extern "C" fn CResult_ScriptNoneZ_err() -> CResult_ScriptNoneZ { + CResult_ScriptNoneZ { + contents: CResult_ScriptNoneZPtr { + err: core::ptr::null_mut(), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ShutdownScriptDecodeErrorZ_is_ok(o: &CResult_ShutdownScriptDecodeErrorZ) -> bool { +pub extern "C" fn CResult_ScriptNoneZ_is_ok(o: &CResult_ScriptNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_ShutdownScriptDecodeErrorZ. -pub extern "C" fn CResult_ShutdownScriptDecodeErrorZ_free(_res: CResult_ShutdownScriptDecodeErrorZ) { } -impl Drop for CResult_ShutdownScriptDecodeErrorZ { +/// Frees any resources used by the CResult_ScriptNoneZ. +pub extern "C" fn CResult_ScriptNoneZ_free(_res: CResult_ScriptNoneZ) { } +impl Drop for CResult_ScriptNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } } } } -impl From> for CResult_ShutdownScriptDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ScriptNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ShutdownScriptDecodeErrorZPtr { result } + CResult_ScriptNoneZPtr { result } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ShutdownScriptDecodeErrorZPtr { err } + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_ScriptNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -1907,95 +2189,91 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ShutdownScriptDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_ScriptNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_ShutdownScriptDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_ScriptNoneZPtr { + err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_ShutdownScriptDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_ScriptNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ShutdownScriptDecodeErrorZ_clone(orig: &CResult_ShutdownScriptDecodeErrorZ) -> CResult_ShutdownScriptDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_ScriptNoneZ_clone(orig: &CResult_ScriptNoneZ) -> CResult_ScriptNoneZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_ShutdownScriptInvalidShutdownScriptZ -pub union CResult_ShutdownScriptInvalidShutdownScriptZPtr { +/// The contents of CResult_ShutdownScriptNoneZ +pub union CResult_ShutdownScriptNoneZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. pub result: *mut crate::lightning::ln::script::ShutdownScript, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::script::InvalidShutdownScript, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut core::ffi::c_void, } #[repr(C)] -/// A CResult_ShutdownScriptInvalidShutdownScriptZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::script::ShutdownScript on success and a crate::lightning::ln::script::InvalidShutdownScript on failure. +/// A CResult_ShutdownScriptNoneZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::script::ShutdownScript on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ShutdownScriptInvalidShutdownScriptZ { - /// The contents of this CResult_ShutdownScriptInvalidShutdownScriptZ, accessible via either +pub struct CResult_ShutdownScriptNoneZ { + /// The contents of this CResult_ShutdownScriptNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ShutdownScriptInvalidShutdownScriptZPtr, - /// Whether this CResult_ShutdownScriptInvalidShutdownScriptZ represents a success state. + pub contents: CResult_ShutdownScriptNoneZPtr, + /// Whether this CResult_ShutdownScriptNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ShutdownScriptInvalidShutdownScriptZ in the success state. -pub extern "C" fn CResult_ShutdownScriptInvalidShutdownScriptZ_ok(o: crate::lightning::ln::script::ShutdownScript) -> CResult_ShutdownScriptInvalidShutdownScriptZ { - CResult_ShutdownScriptInvalidShutdownScriptZ { - contents: CResult_ShutdownScriptInvalidShutdownScriptZPtr { +/// Creates a new CResult_ShutdownScriptNoneZ in the success state. +pub extern "C" fn CResult_ShutdownScriptNoneZ_ok(o: crate::lightning::ln::script::ShutdownScript) -> CResult_ShutdownScriptNoneZ { + CResult_ShutdownScriptNoneZ { + contents: CResult_ShutdownScriptNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ShutdownScriptInvalidShutdownScriptZ in the error state. -pub extern "C" fn CResult_ShutdownScriptInvalidShutdownScriptZ_err(e: crate::lightning::ln::script::InvalidShutdownScript) -> CResult_ShutdownScriptInvalidShutdownScriptZ { - CResult_ShutdownScriptInvalidShutdownScriptZ { - contents: CResult_ShutdownScriptInvalidShutdownScriptZPtr { - err: Box::into_raw(Box::new(e)), +/// Creates a new CResult_ShutdownScriptNoneZ in the error state. +pub extern "C" fn CResult_ShutdownScriptNoneZ_err() -> CResult_ShutdownScriptNoneZ { + CResult_ShutdownScriptNoneZ { + contents: CResult_ShutdownScriptNoneZPtr { + err: core::ptr::null_mut(), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(o: &CResult_ShutdownScriptInvalidShutdownScriptZ) -> bool { +pub extern "C" fn CResult_ShutdownScriptNoneZ_is_ok(o: &CResult_ShutdownScriptNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_ShutdownScriptInvalidShutdownScriptZ. -pub extern "C" fn CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res: CResult_ShutdownScriptInvalidShutdownScriptZ) { } -impl Drop for CResult_ShutdownScriptInvalidShutdownScriptZ { +/// Frees any resources used by the CResult_ShutdownScriptNoneZ. +pub extern "C" fn CResult_ShutdownScriptNoneZ_free(_res: CResult_ShutdownScriptNoneZ) { } +impl Drop for CResult_ShutdownScriptNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } } } } -impl From> for CResult_ShutdownScriptInvalidShutdownScriptZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ShutdownScriptNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ShutdownScriptInvalidShutdownScriptZPtr { result } + CResult_ShutdownScriptNoneZPtr { result } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ShutdownScriptInvalidShutdownScriptZPtr { err } + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_ShutdownScriptNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -2003,95 +2281,137 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ShutdownScriptInvalidShutdownScriptZPtr { + Self { result_ok: true, contents: CResult_ShutdownScriptNoneZPtr { result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_ShutdownScriptInvalidShutdownScriptZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_ShutdownScriptNoneZPtr { + err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_ShutdownScriptInvalidShutdownScriptZ which has the same data as `orig` +/// Creates a new CResult_ShutdownScriptNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ShutdownScriptInvalidShutdownScriptZ_clone(orig: &CResult_ShutdownScriptInvalidShutdownScriptZ) -> CResult_ShutdownScriptInvalidShutdownScriptZ { Clone::clone(&orig) } -#[repr(C)] -/// The contents of CResult_BlindedPayInfoDecodeErrorZ -pub union CResult_BlindedPayInfoDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::offers::invoice::BlindedPayInfo, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, -} +pub extern "C" fn CResult_ShutdownScriptNoneZ_clone(orig: &CResult_ShutdownScriptNoneZ) -> CResult_ShutdownScriptNoneZ { Clone::clone(&orig) } #[repr(C)] -/// A CResult_BlindedPayInfoDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::offers::invoice::BlindedPayInfo on success and a crate::lightning::ln::msgs::DecodeError on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_BlindedPayInfoDecodeErrorZ { - /// The contents of this CResult_BlindedPayInfoDecodeErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_BlindedPayInfoDecodeErrorZPtr, - /// Whether this CResult_BlindedPayInfoDecodeErrorZ represents a success state. - pub result_ok: bool, +/// A dynamically-allocated array of crate::c_types::derived::CVec_u8Zs of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_CVec_u8ZZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::derived::CVec_u8Z, + /// The number of elements pointed to by `data`. + pub datalen: usize } -#[no_mangle] -/// Creates a new CResult_BlindedPayInfoDecodeErrorZ in the success state. -pub extern "C" fn CResult_BlindedPayInfoDecodeErrorZ_ok(o: crate::lightning::offers::invoice::BlindedPayInfo) -> CResult_BlindedPayInfoDecodeErrorZ { - CResult_BlindedPayInfoDecodeErrorZ { - contents: CResult_BlindedPayInfoDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), +impl CVec_CVec_u8ZZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::CVec_u8Z] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_CVec_u8ZZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_CVec_u8ZZ_free(_res: CVec_CVec_u8ZZ) { } +impl Drop for CVec_CVec_u8ZZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_CVec_u8ZZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// The contents of CResult_CVec_CVec_u8ZZNoneZ +pub union CResult_CVec_CVec_u8ZZNoneZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::c_types::derived::CVec_CVec_u8ZZ, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut core::ffi::c_void, +} +#[repr(C)] +/// A CResult_CVec_CVec_u8ZZNoneZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::CVec_CVec_u8ZZ on success and a () on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_CVec_CVec_u8ZZNoneZ { + /// The contents of this CResult_CVec_CVec_u8ZZNoneZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_CVec_CVec_u8ZZNoneZPtr, + /// Whether this CResult_CVec_CVec_u8ZZNoneZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_CVec_CVec_u8ZZNoneZ in the success state. +pub extern "C" fn CResult_CVec_CVec_u8ZZNoneZ_ok(o: crate::c_types::derived::CVec_CVec_u8ZZ) -> CResult_CVec_CVec_u8ZZNoneZ { + CResult_CVec_CVec_u8ZZNoneZ { + contents: CResult_CVec_CVec_u8ZZNoneZPtr { + result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_BlindedPayInfoDecodeErrorZ in the error state. -pub extern "C" fn CResult_BlindedPayInfoDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_BlindedPayInfoDecodeErrorZ { - CResult_BlindedPayInfoDecodeErrorZ { - contents: CResult_BlindedPayInfoDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), +/// Creates a new CResult_CVec_CVec_u8ZZNoneZ in the error state. +pub extern "C" fn CResult_CVec_CVec_u8ZZNoneZ_err() -> CResult_CVec_CVec_u8ZZNoneZ { + CResult_CVec_CVec_u8ZZNoneZ { + contents: CResult_CVec_CVec_u8ZZNoneZPtr { + err: core::ptr::null_mut(), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_BlindedPayInfoDecodeErrorZ_is_ok(o: &CResult_BlindedPayInfoDecodeErrorZ) -> bool { +pub extern "C" fn CResult_CVec_CVec_u8ZZNoneZ_is_ok(o: &CResult_CVec_CVec_u8ZZNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_BlindedPayInfoDecodeErrorZ. -pub extern "C" fn CResult_BlindedPayInfoDecodeErrorZ_free(_res: CResult_BlindedPayInfoDecodeErrorZ) { } -impl Drop for CResult_BlindedPayInfoDecodeErrorZ { +/// Frees any resources used by the CResult_CVec_CVec_u8ZZNoneZ. +pub extern "C" fn CResult_CVec_CVec_u8ZZNoneZ_free(_res: CResult_CVec_CVec_u8ZZNoneZ) { } +impl Drop for CResult_CVec_CVec_u8ZZNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } } } } -impl From> for CResult_BlindedPayInfoDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_CVec_CVec_u8ZZNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_BlindedPayInfoDecodeErrorZPtr { result } + CResult_CVec_CVec_u8ZZNoneZPtr { result } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_BlindedPayInfoDecodeErrorZPtr { err } + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_CVec_CVec_u8ZZNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -2099,90 +2419,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_BlindedPayInfoDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_CVec_CVec_u8ZZNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_BlindedPayInfoDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_CVec_CVec_u8ZZNoneZPtr { + err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_BlindedPayInfoDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_CVec_CVec_u8ZZNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_BlindedPayInfoDecodeErrorZ_clone(orig: &CResult_BlindedPayInfoDecodeErrorZ) -> CResult_BlindedPayInfoDecodeErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// An enum which can either contain a crate::lightning::routing::scoring::WriteableScore or not -pub enum COption_WriteableScoreZ { - /// When we're in this state, this COption_WriteableScoreZ contains a crate::lightning::routing::scoring::WriteableScore - Some(crate::lightning::routing::scoring::WriteableScore), - /// When we're in this state, this COption_WriteableScoreZ contains nothing - None -} -impl COption_WriteableScoreZ { - #[allow(unused)] pub(crate) fn is_some(&self) -> bool { - if let Self::None = self { false } else { true } - } - #[allow(unused)] pub(crate) fn is_none(&self) -> bool { - !self.is_some() - } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::routing::scoring::WriteableScore { - if let Self::Some(v) = self { v } else { unreachable!() } - } -} -#[no_mangle] -/// Constructs a new COption_WriteableScoreZ containing a crate::lightning::routing::scoring::WriteableScore -pub extern "C" fn COption_WriteableScoreZ_some(o: crate::lightning::routing::scoring::WriteableScore) -> COption_WriteableScoreZ { - COption_WriteableScoreZ::Some(o) -} -#[no_mangle] -/// Constructs a new COption_WriteableScoreZ containing nothing -pub extern "C" fn COption_WriteableScoreZ_none() -> COption_WriteableScoreZ { - COption_WriteableScoreZ::None -} -#[no_mangle] -/// Frees any resources associated with the crate::lightning::routing::scoring::WriteableScore, if we are in the Some state -pub extern "C" fn COption_WriteableScoreZ_free(_res: COption_WriteableScoreZ) { } +pub extern "C" fn CResult_CVec_CVec_u8ZZNoneZ_clone(orig: &CResult_CVec_CVec_u8ZZNoneZ) -> CResult_CVec_CVec_u8ZZNoneZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_NoneErrorZ -pub union CResult_NoneErrorZPtr { - /// Note that this value is always NULL, as there are no contents in the OK variant - pub result: *mut core::ffi::c_void, +/// The contents of CResult_InMemorySignerDecodeErrorZ +pub union CResult_InMemorySignerDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::sign::InMemorySigner, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::c_types::IOError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_NoneErrorZ represents the result of a fallible operation, -/// containing a () on success and a crate::c_types::IOError on failure. +/// A CResult_InMemorySignerDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::sign::InMemorySigner on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_NoneErrorZ { - /// The contents of this CResult_NoneErrorZ, accessible via either +pub struct CResult_InMemorySignerDecodeErrorZ { + /// The contents of this CResult_InMemorySignerDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_NoneErrorZPtr, - /// Whether this CResult_NoneErrorZ represents a success state. + pub contents: CResult_InMemorySignerDecodeErrorZPtr, + /// Whether this CResult_InMemorySignerDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_NoneErrorZ in the success state. -pub extern "C" fn CResult_NoneErrorZ_ok() -> CResult_NoneErrorZ { - CResult_NoneErrorZ { - contents: CResult_NoneErrorZPtr { - result: core::ptr::null_mut(), +/// Creates a new CResult_InMemorySignerDecodeErrorZ in the success state. +pub extern "C" fn CResult_InMemorySignerDecodeErrorZ_ok(o: crate::lightning::sign::InMemorySigner) -> CResult_InMemorySignerDecodeErrorZ { + CResult_InMemorySignerDecodeErrorZ { + contents: CResult_InMemorySignerDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_NoneErrorZ in the error state. -pub extern "C" fn CResult_NoneErrorZ_err(e: crate::c_types::IOError) -> CResult_NoneErrorZ { - CResult_NoneErrorZ { - contents: CResult_NoneErrorZPtr { +/// Creates a new CResult_InMemorySignerDecodeErrorZ in the error state. +pub extern "C" fn CResult_InMemorySignerDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_InMemorySignerDecodeErrorZ { + CResult_InMemorySignerDecodeErrorZ { + contents: CResult_InMemorySignerDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -2190,15 +2479,18 @@ pub extern "C" fn CResult_NoneErrorZ_err(e: crate::c_types::IOError) -> CResult_ } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_NoneErrorZ_is_ok(o: &CResult_NoneErrorZ) -> bool { +pub extern "C" fn CResult_InMemorySignerDecodeErrorZ_is_ok(o: &CResult_InMemorySignerDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_NoneErrorZ. -pub extern "C" fn CResult_NoneErrorZ_free(_res: CResult_NoneErrorZ) { } -impl Drop for CResult_NoneErrorZ { +/// Frees any resources used by the CResult_InMemorySignerDecodeErrorZ. +pub extern "C" fn CResult_InMemorySignerDecodeErrorZ_free(_res: CResult_InMemorySignerDecodeErrorZ) { } +impl Drop for CResult_InMemorySignerDecodeErrorZ { fn drop(&mut self) { if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } } else { if unsafe { !(self.contents.err as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.err) }; @@ -2206,16 +2498,16 @@ impl Drop for CResult_NoneErrorZ { } } } -impl From> for CResult_NoneErrorZ { - fn from(mut o: crate::c_types::CResultTempl<(), crate::c_types::IOError>) -> Self { +impl From> for CResult_InMemorySignerDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { - let _ = unsafe { Box::from_raw(o.contents.result) }; - o.contents.result = core::ptr::null_mut(); - CResult_NoneErrorZPtr { result: core::ptr::null_mut() } + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_InMemorySignerDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_NoneErrorZPtr { err } + CResult_InMemorySignerDecodeErrorZPtr { err } }; Self { contents, @@ -2223,141 +2515,91 @@ impl From> for CResult } } } -impl Clone for CResult_NoneErrorZ { +impl Clone for CResult_InMemorySignerDecodeErrorZ { fn clone(&self) -> Self { if self.result_ok { - Self { result_ok: true, contents: CResult_NoneErrorZPtr { - result: core::ptr::null_mut() + Self { result_ok: true, contents: CResult_InMemorySignerDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_NoneErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_InMemorySignerDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_NoneErrorZ which has the same data as `orig` +/// Creates a new CResult_InMemorySignerDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_NoneErrorZ_clone(orig: &CResult_NoneErrorZ) -> CResult_NoneErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_InMemorySignerDecodeErrorZ_clone(orig: &CResult_InMemorySignerDecodeErrorZ) -> CResult_InMemorySignerDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// A dynamically-allocated array of crate::lightning::ln::channelmanager::ChannelDetailss of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_ChannelDetailsZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::ln::channelmanager::ChannelDetails, - /// The number of elements pointed to by `data`. - pub datalen: usize +/// The contents of CResult_PartiallySignedTransactionNoneZ +pub union CResult_PartiallySignedTransactionNoneZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::c_types::derived::CVec_u8Z, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut core::ffi::c_void, } -impl CVec_ChannelDetailsZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::channelmanager::ChannelDetails] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } +#[repr(C)] +/// A CResult_PartiallySignedTransactionNoneZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::CVec_u8Z on success and a () on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_PartiallySignedTransactionNoneZ { + /// The contents of this CResult_PartiallySignedTransactionNoneZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_PartiallySignedTransactionNoneZPtr, + /// Whether this CResult_PartiallySignedTransactionNoneZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_PartiallySignedTransactionNoneZ in the success state. +pub extern "C" fn CResult_PartiallySignedTransactionNoneZ_ok(o: crate::c_types::derived::CVec_u8Z) -> CResult_PartiallySignedTransactionNoneZ { + CResult_PartiallySignedTransactionNoneZ { + contents: CResult_PartiallySignedTransactionNoneZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, } } -impl From> for CVec_ChannelDetailsZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } +#[no_mangle] +/// Creates a new CResult_PartiallySignedTransactionNoneZ in the error state. +pub extern "C" fn CResult_PartiallySignedTransactionNoneZ_err() -> CResult_PartiallySignedTransactionNoneZ { + CResult_PartiallySignedTransactionNoneZ { + contents: CResult_PartiallySignedTransactionNoneZPtr { + err: core::ptr::null_mut(), + }, + result_ok: false, } } +/// Checks if the given object is currently in the success state #[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_ChannelDetailsZ_free(_res: CVec_ChannelDetailsZ) { } -impl Drop for CVec_ChannelDetailsZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_ChannelDetailsZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} -#[repr(C)] -/// The contents of CResult_RouteLightningErrorZ -pub union CResult_RouteLightningErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::routing::router::Route, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::LightningError, -} -#[repr(C)] -/// A CResult_RouteLightningErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::routing::router::Route on success and a crate::lightning::ln::msgs::LightningError on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_RouteLightningErrorZ { - /// The contents of this CResult_RouteLightningErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_RouteLightningErrorZPtr, - /// Whether this CResult_RouteLightningErrorZ represents a success state. - pub result_ok: bool, -} -#[no_mangle] -/// Creates a new CResult_RouteLightningErrorZ in the success state. -pub extern "C" fn CResult_RouteLightningErrorZ_ok(o: crate::lightning::routing::router::Route) -> CResult_RouteLightningErrorZ { - CResult_RouteLightningErrorZ { - contents: CResult_RouteLightningErrorZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, - } -} -#[no_mangle] -/// Creates a new CResult_RouteLightningErrorZ in the error state. -pub extern "C" fn CResult_RouteLightningErrorZ_err(e: crate::lightning::ln::msgs::LightningError) -> CResult_RouteLightningErrorZ { - CResult_RouteLightningErrorZ { - contents: CResult_RouteLightningErrorZPtr { - err: Box::into_raw(Box::new(e)), - }, - result_ok: false, - } -} -/// Checks if the given object is currently in the success state -#[no_mangle] -pub extern "C" fn CResult_RouteLightningErrorZ_is_ok(o: &CResult_RouteLightningErrorZ) -> bool { +pub extern "C" fn CResult_PartiallySignedTransactionNoneZ_is_ok(o: &CResult_PartiallySignedTransactionNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_RouteLightningErrorZ. -pub extern "C" fn CResult_RouteLightningErrorZ_free(_res: CResult_RouteLightningErrorZ) { } -impl Drop for CResult_RouteLightningErrorZ { +/// Frees any resources used by the CResult_PartiallySignedTransactionNoneZ. +pub extern "C" fn CResult_PartiallySignedTransactionNoneZ_free(_res: CResult_PartiallySignedTransactionNoneZ) { } +impl Drop for CResult_PartiallySignedTransactionNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } } } } -impl From> for CResult_RouteLightningErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_PartiallySignedTransactionNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_RouteLightningErrorZPtr { result } + CResult_PartiallySignedTransactionNoneZPtr { result } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_RouteLightningErrorZPtr { err } + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_PartiallySignedTransactionNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -2365,95 +2607,91 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_RouteLightningErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_PartiallySignedTransactionNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_RouteLightningErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_PartiallySignedTransactionNoneZPtr { + err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_RouteLightningErrorZ which has the same data as `orig` +/// Creates a new CResult_PartiallySignedTransactionNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_RouteLightningErrorZ_clone(orig: &CResult_RouteLightningErrorZ) -> CResult_RouteLightningErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_PartiallySignedTransactionNoneZ_clone(orig: &CResult_PartiallySignedTransactionNoneZ) -> CResult_PartiallySignedTransactionNoneZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_InFlightHtlcsDecodeErrorZ -pub union CResult_InFlightHtlcsDecodeErrorZPtr { +/// The contents of CResult_TransactionNoneZ +pub union CResult_TransactionNoneZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::routing::router::InFlightHtlcs, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub result: *mut crate::c_types::Transaction, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut core::ffi::c_void, } #[repr(C)] -/// A CResult_InFlightHtlcsDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::routing::router::InFlightHtlcs on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_TransactionNoneZ represents the result of a fallible operation, +/// containing a crate::c_types::Transaction on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_InFlightHtlcsDecodeErrorZ { - /// The contents of this CResult_InFlightHtlcsDecodeErrorZ, accessible via either +pub struct CResult_TransactionNoneZ { + /// The contents of this CResult_TransactionNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_InFlightHtlcsDecodeErrorZPtr, - /// Whether this CResult_InFlightHtlcsDecodeErrorZ represents a success state. + pub contents: CResult_TransactionNoneZPtr, + /// Whether this CResult_TransactionNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_InFlightHtlcsDecodeErrorZ in the success state. -pub extern "C" fn CResult_InFlightHtlcsDecodeErrorZ_ok(o: crate::lightning::routing::router::InFlightHtlcs) -> CResult_InFlightHtlcsDecodeErrorZ { - CResult_InFlightHtlcsDecodeErrorZ { - contents: CResult_InFlightHtlcsDecodeErrorZPtr { +/// Creates a new CResult_TransactionNoneZ in the success state. +pub extern "C" fn CResult_TransactionNoneZ_ok(o: crate::c_types::Transaction) -> CResult_TransactionNoneZ { + CResult_TransactionNoneZ { + contents: CResult_TransactionNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_InFlightHtlcsDecodeErrorZ in the error state. -pub extern "C" fn CResult_InFlightHtlcsDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_InFlightHtlcsDecodeErrorZ { - CResult_InFlightHtlcsDecodeErrorZ { - contents: CResult_InFlightHtlcsDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), +/// Creates a new CResult_TransactionNoneZ in the error state. +pub extern "C" fn CResult_TransactionNoneZ_err() -> CResult_TransactionNoneZ { + CResult_TransactionNoneZ { + contents: CResult_TransactionNoneZPtr { + err: core::ptr::null_mut(), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_InFlightHtlcsDecodeErrorZ_is_ok(o: &CResult_InFlightHtlcsDecodeErrorZ) -> bool { +pub extern "C" fn CResult_TransactionNoneZ_is_ok(o: &CResult_TransactionNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_InFlightHtlcsDecodeErrorZ. -pub extern "C" fn CResult_InFlightHtlcsDecodeErrorZ_free(_res: CResult_InFlightHtlcsDecodeErrorZ) { } -impl Drop for CResult_InFlightHtlcsDecodeErrorZ { +/// Frees any resources used by the CResult_TransactionNoneZ. +pub extern "C" fn CResult_TransactionNoneZ_free(_res: CResult_TransactionNoneZ) { } +impl Drop for CResult_TransactionNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } } } } -impl From> for CResult_InFlightHtlcsDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_TransactionNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_InFlightHtlcsDecodeErrorZPtr { result } + CResult_TransactionNoneZPtr { result } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_InFlightHtlcsDecodeErrorZPtr { err } + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_TransactionNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -2461,59 +2699,90 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_InFlightHtlcsDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_TransactionNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_InFlightHtlcsDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_TransactionNoneZPtr { + err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_InFlightHtlcsDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_TransactionNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_InFlightHtlcsDecodeErrorZ_clone(orig: &CResult_InFlightHtlcsDecodeErrorZ) -> CResult_InFlightHtlcsDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_TransactionNoneZ_clone(orig: &CResult_TransactionNoneZ) -> CResult_TransactionNoneZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_RouteHopDecodeErrorZ -pub union CResult_RouteHopDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::routing::router::RouteHop, +/// An enum which can either contain a crate::lightning::routing::scoring::WriteableScore or not +pub enum COption_WriteableScoreZ { + /// When we're in this state, this COption_WriteableScoreZ contains a crate::lightning::routing::scoring::WriteableScore + Some(crate::lightning::routing::scoring::WriteableScore), + /// When we're in this state, this COption_WriteableScoreZ contains nothing + None +} +impl COption_WriteableScoreZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::routing::scoring::WriteableScore { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_WriteableScoreZ containing a crate::lightning::routing::scoring::WriteableScore +pub extern "C" fn COption_WriteableScoreZ_some(o: crate::lightning::routing::scoring::WriteableScore) -> COption_WriteableScoreZ { + COption_WriteableScoreZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_WriteableScoreZ containing nothing +pub extern "C" fn COption_WriteableScoreZ_none() -> COption_WriteableScoreZ { + COption_WriteableScoreZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::lightning::routing::scoring::WriteableScore, if we are in the Some state +pub extern "C" fn COption_WriteableScoreZ_free(_res: COption_WriteableScoreZ) { } +#[repr(C)] +/// The contents of CResult_NoneErrorZ +pub union CResult_NoneErrorZPtr { + /// Note that this value is always NULL, as there are no contents in the OK variant + pub result: *mut core::ffi::c_void, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::c_types::IOError, } #[repr(C)] -/// A CResult_RouteHopDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::routing::router::RouteHop on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_NoneErrorZ represents the result of a fallible operation, +/// containing a () on success and a crate::c_types::IOError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_RouteHopDecodeErrorZ { - /// The contents of this CResult_RouteHopDecodeErrorZ, accessible via either +pub struct CResult_NoneErrorZ { + /// The contents of this CResult_NoneErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_RouteHopDecodeErrorZPtr, - /// Whether this CResult_RouteHopDecodeErrorZ represents a success state. + pub contents: CResult_NoneErrorZPtr, + /// Whether this CResult_NoneErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_RouteHopDecodeErrorZ in the success state. -pub extern "C" fn CResult_RouteHopDecodeErrorZ_ok(o: crate::lightning::routing::router::RouteHop) -> CResult_RouteHopDecodeErrorZ { - CResult_RouteHopDecodeErrorZ { - contents: CResult_RouteHopDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), +/// Creates a new CResult_NoneErrorZ in the success state. +pub extern "C" fn CResult_NoneErrorZ_ok() -> CResult_NoneErrorZ { + CResult_NoneErrorZ { + contents: CResult_NoneErrorZPtr { + result: core::ptr::null_mut(), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_RouteHopDecodeErrorZ in the error state. -pub extern "C" fn CResult_RouteHopDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_RouteHopDecodeErrorZ { - CResult_RouteHopDecodeErrorZ { - contents: CResult_RouteHopDecodeErrorZPtr { +/// Creates a new CResult_NoneErrorZ in the error state. +pub extern "C" fn CResult_NoneErrorZ_err(e: crate::c_types::IOError) -> CResult_NoneErrorZ { + CResult_NoneErrorZ { + contents: CResult_NoneErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -2521,18 +2790,15 @@ pub extern "C" fn CResult_RouteHopDecodeErrorZ_err(e: crate::lightning::ln::msgs } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_RouteHopDecodeErrorZ_is_ok(o: &CResult_RouteHopDecodeErrorZ) -> bool { +pub extern "C" fn CResult_NoneErrorZ_is_ok(o: &CResult_NoneErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_RouteHopDecodeErrorZ. -pub extern "C" fn CResult_RouteHopDecodeErrorZ_free(_res: CResult_RouteHopDecodeErrorZ) { } -impl Drop for CResult_RouteHopDecodeErrorZ { +/// Frees any resources used by the CResult_NoneErrorZ. +pub extern "C" fn CResult_NoneErrorZ_free(_res: CResult_NoneErrorZ) { } +impl Drop for CResult_NoneErrorZ { fn drop(&mut self) { if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } } else { if unsafe { !(self.contents.err as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.err) }; @@ -2540,16 +2806,16 @@ impl Drop for CResult_RouteHopDecodeErrorZ { } } } -impl From> for CResult_RouteHopDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_NoneErrorZ { + fn from(mut o: crate::c_types::CResultTempl<(), crate::c_types::IOError>) -> Self { let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_RouteHopDecodeErrorZPtr { result } + let _ = unsafe { Box::from_raw(o.contents.result) }; + o.contents.result = core::ptr::null_mut(); + CResult_NoneErrorZPtr { result: core::ptr::null_mut() } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_RouteHopDecodeErrorZPtr { err } + CResult_NoneErrorZPtr { err } }; Self { contents, @@ -2557,47 +2823,47 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_RouteHopDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_NoneErrorZPtr { + result: core::ptr::null_mut() } } } else { - Self { result_ok: false, contents: CResult_RouteHopDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_NoneErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_RouteHopDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_NoneErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_RouteHopDecodeErrorZ_clone(orig: &CResult_RouteHopDecodeErrorZ) -> CResult_RouteHopDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_NoneErrorZ_clone(orig: &CResult_NoneErrorZ) -> CResult_NoneErrorZ { Clone::clone(&orig) } #[repr(C)] -/// A dynamically-allocated array of crate::lightning::blinded_path::BlindedHops of arbitrary size. +/// A dynamically-allocated array of crate::lightning::ln::channelmanager::ChannelDetailss of arbitrary size. /// This corresponds to std::vector in C++ -pub struct CVec_BlindedHopZ { +pub struct CVec_ChannelDetailsZ { /// The elements in the array. /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::blinded_path::BlindedHop, + pub data: *mut crate::lightning::ln::channelmanager::ChannelDetails, /// The number of elements pointed to by `data`. pub datalen: usize } -impl CVec_BlindedHopZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { +impl CVec_ChannelDetailsZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { if self.datalen == 0 { return Vec::new(); } let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); self.data = core::ptr::null_mut(); self.datalen = 0; ret } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::blinded_path::BlindedHop] { + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::channelmanager::ChannelDetails] { unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl From> for CVec_BlindedHopZ { - fn from(v: Vec) -> Self { +impl From> for CVec_ChannelDetailsZ { + fn from(v: Vec) -> Self { let datalen = v.len(); let data = Box::into_raw(v.into_boxed_slice()); Self { datalen, data: unsafe { (*data).as_mut_ptr() } } @@ -2605,14 +2871,14 @@ impl From> for CVec_BlindedHopZ } #[no_mangle] /// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_BlindedHopZ_free(_res: CVec_BlindedHopZ) { } -impl Drop for CVec_BlindedHopZ { +pub extern "C" fn CVec_ChannelDetailsZ_free(_res: CVec_ChannelDetailsZ) { } +impl Drop for CVec_ChannelDetailsZ { fn drop(&mut self) { if self.datalen == 0 { return; } let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl Clone for CVec_BlindedHopZ { +impl Clone for CVec_ChannelDetailsZ { fn clone(&self) -> Self { let mut res = Vec::new(); if self.datalen == 0 { return Self::from(res); } @@ -2621,41 +2887,41 @@ impl Clone for CVec_BlindedHopZ { } } #[repr(C)] -/// The contents of CResult_BlindedTailDecodeErrorZ -pub union CResult_BlindedTailDecodeErrorZPtr { +/// The contents of CResult_RouteLightningErrorZ +pub union CResult_RouteLightningErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::routing::router::BlindedTail, + pub result: *mut crate::lightning::routing::router::Route, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::lightning::ln::msgs::LightningError, } #[repr(C)] -/// A CResult_BlindedTailDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::routing::router::BlindedTail on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_RouteLightningErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::routing::router::Route on success and a crate::lightning::ln::msgs::LightningError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_BlindedTailDecodeErrorZ { - /// The contents of this CResult_BlindedTailDecodeErrorZ, accessible via either +pub struct CResult_RouteLightningErrorZ { + /// The contents of this CResult_RouteLightningErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_BlindedTailDecodeErrorZPtr, - /// Whether this CResult_BlindedTailDecodeErrorZ represents a success state. + pub contents: CResult_RouteLightningErrorZPtr, + /// Whether this CResult_RouteLightningErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_BlindedTailDecodeErrorZ in the success state. -pub extern "C" fn CResult_BlindedTailDecodeErrorZ_ok(o: crate::lightning::routing::router::BlindedTail) -> CResult_BlindedTailDecodeErrorZ { - CResult_BlindedTailDecodeErrorZ { - contents: CResult_BlindedTailDecodeErrorZPtr { +/// Creates a new CResult_RouteLightningErrorZ in the success state. +pub extern "C" fn CResult_RouteLightningErrorZ_ok(o: crate::lightning::routing::router::Route) -> CResult_RouteLightningErrorZ { + CResult_RouteLightningErrorZ { + contents: CResult_RouteLightningErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_BlindedTailDecodeErrorZ in the error state. -pub extern "C" fn CResult_BlindedTailDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_BlindedTailDecodeErrorZ { - CResult_BlindedTailDecodeErrorZ { - contents: CResult_BlindedTailDecodeErrorZPtr { +/// Creates a new CResult_RouteLightningErrorZ in the error state. +pub extern "C" fn CResult_RouteLightningErrorZ_err(e: crate::lightning::ln::msgs::LightningError) -> CResult_RouteLightningErrorZ { + CResult_RouteLightningErrorZ { + contents: CResult_RouteLightningErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -2663,13 +2929,13 @@ pub extern "C" fn CResult_BlindedTailDecodeErrorZ_err(e: crate::lightning::ln::m } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_BlindedTailDecodeErrorZ_is_ok(o: &CResult_BlindedTailDecodeErrorZ) -> bool { +pub extern "C" fn CResult_RouteLightningErrorZ_is_ok(o: &CResult_RouteLightningErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_BlindedTailDecodeErrorZ. -pub extern "C" fn CResult_BlindedTailDecodeErrorZ_free(_res: CResult_BlindedTailDecodeErrorZ) { } -impl Drop for CResult_BlindedTailDecodeErrorZ { +/// Frees any resources used by the CResult_RouteLightningErrorZ. +pub extern "C" fn CResult_RouteLightningErrorZ_free(_res: CResult_RouteLightningErrorZ) { } +impl Drop for CResult_RouteLightningErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -2682,16 +2948,16 @@ impl Drop for CResult_BlindedTailDecodeErrorZ { } } } -impl From> for CResult_BlindedTailDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_RouteLightningErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_BlindedTailDecodeErrorZPtr { result } + CResult_RouteLightningErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_BlindedTailDecodeErrorZPtr { err } + CResult_RouteLightningErrorZPtr { err } }; Self { contents, @@ -2699,151 +2965,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_BlindedTailDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_RouteLightningErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_BlindedTailDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_RouteLightningErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_BlindedTailDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_RouteLightningErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_BlindedTailDecodeErrorZ_clone(orig: &CResult_BlindedTailDecodeErrorZ) -> CResult_BlindedTailDecodeErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// A dynamically-allocated array of crate::lightning::routing::router::RouteHops of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_RouteHopZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::routing::router::RouteHop, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_RouteHopZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::routing::router::RouteHop] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_RouteHopZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_RouteHopZ_free(_res: CVec_RouteHopZ) { } -impl Drop for CVec_RouteHopZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_RouteHopZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} -#[repr(C)] -/// A dynamically-allocated array of crate::lightning::routing::router::Paths of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_PathZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::routing::router::Path, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_PathZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::routing::router::Path] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_PathZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_PathZ_free(_res: CVec_PathZ) { } -impl Drop for CVec_PathZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_PathZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} +pub extern "C" fn CResult_RouteLightningErrorZ_clone(orig: &CResult_RouteLightningErrorZ) -> CResult_RouteLightningErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_RouteDecodeErrorZ -pub union CResult_RouteDecodeErrorZPtr { +/// The contents of CResult_InFlightHtlcsDecodeErrorZ +pub union CResult_InFlightHtlcsDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::routing::router::Route, + pub result: *mut crate::lightning::routing::router::InFlightHtlcs, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_RouteDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::routing::router::Route on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_InFlightHtlcsDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::routing::router::InFlightHtlcs on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_RouteDecodeErrorZ { - /// The contents of this CResult_RouteDecodeErrorZ, accessible via either +pub struct CResult_InFlightHtlcsDecodeErrorZ { + /// The contents of this CResult_InFlightHtlcsDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_RouteDecodeErrorZPtr, - /// Whether this CResult_RouteDecodeErrorZ represents a success state. + pub contents: CResult_InFlightHtlcsDecodeErrorZPtr, + /// Whether this CResult_InFlightHtlcsDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_RouteDecodeErrorZ in the success state. -pub extern "C" fn CResult_RouteDecodeErrorZ_ok(o: crate::lightning::routing::router::Route) -> CResult_RouteDecodeErrorZ { - CResult_RouteDecodeErrorZ { - contents: CResult_RouteDecodeErrorZPtr { +/// Creates a new CResult_InFlightHtlcsDecodeErrorZ in the success state. +pub extern "C" fn CResult_InFlightHtlcsDecodeErrorZ_ok(o: crate::lightning::routing::router::InFlightHtlcs) -> CResult_InFlightHtlcsDecodeErrorZ { + CResult_InFlightHtlcsDecodeErrorZ { + contents: CResult_InFlightHtlcsDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_RouteDecodeErrorZ in the error state. -pub extern "C" fn CResult_RouteDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_RouteDecodeErrorZ { - CResult_RouteDecodeErrorZ { - contents: CResult_RouteDecodeErrorZPtr { +/// Creates a new CResult_InFlightHtlcsDecodeErrorZ in the error state. +pub extern "C" fn CResult_InFlightHtlcsDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_InFlightHtlcsDecodeErrorZ { + CResult_InFlightHtlcsDecodeErrorZ { + contents: CResult_InFlightHtlcsDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -2851,13 +3025,13 @@ pub extern "C" fn CResult_RouteDecodeErrorZ_err(e: crate::lightning::ln::msgs::D } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_RouteDecodeErrorZ_is_ok(o: &CResult_RouteDecodeErrorZ) -> bool { +pub extern "C" fn CResult_InFlightHtlcsDecodeErrorZ_is_ok(o: &CResult_InFlightHtlcsDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_RouteDecodeErrorZ. -pub extern "C" fn CResult_RouteDecodeErrorZ_free(_res: CResult_RouteDecodeErrorZ) { } -impl Drop for CResult_RouteDecodeErrorZ { +/// Frees any resources used by the CResult_InFlightHtlcsDecodeErrorZ. +pub extern "C" fn CResult_InFlightHtlcsDecodeErrorZ_free(_res: CResult_InFlightHtlcsDecodeErrorZ) { } +impl Drop for CResult_InFlightHtlcsDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -2870,16 +3044,16 @@ impl Drop for CResult_RouteDecodeErrorZ { } } } -impl From> for CResult_RouteDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_InFlightHtlcsDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_RouteDecodeErrorZPtr { result } + CResult_InFlightHtlcsDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_RouteDecodeErrorZPtr { err } + CResult_InFlightHtlcsDecodeErrorZPtr { err } }; Self { contents, @@ -2887,59 +3061,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_RouteDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_InFlightHtlcsDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_RouteDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_InFlightHtlcsDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_RouteDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_InFlightHtlcsDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_RouteDecodeErrorZ_clone(orig: &CResult_RouteDecodeErrorZ) -> CResult_RouteDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_InFlightHtlcsDecodeErrorZ_clone(orig: &CResult_InFlightHtlcsDecodeErrorZ) -> CResult_InFlightHtlcsDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_RouteParametersDecodeErrorZ -pub union CResult_RouteParametersDecodeErrorZPtr { +/// The contents of CResult_RouteHopDecodeErrorZ +pub union CResult_RouteHopDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::routing::router::RouteParameters, + pub result: *mut crate::lightning::routing::router::RouteHop, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_RouteParametersDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::routing::router::RouteParameters on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_RouteHopDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::routing::router::RouteHop on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_RouteParametersDecodeErrorZ { - /// The contents of this CResult_RouteParametersDecodeErrorZ, accessible via either +pub struct CResult_RouteHopDecodeErrorZ { + /// The contents of this CResult_RouteHopDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_RouteParametersDecodeErrorZPtr, - /// Whether this CResult_RouteParametersDecodeErrorZ represents a success state. + pub contents: CResult_RouteHopDecodeErrorZPtr, + /// Whether this CResult_RouteHopDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_RouteParametersDecodeErrorZ in the success state. -pub extern "C" fn CResult_RouteParametersDecodeErrorZ_ok(o: crate::lightning::routing::router::RouteParameters) -> CResult_RouteParametersDecodeErrorZ { - CResult_RouteParametersDecodeErrorZ { - contents: CResult_RouteParametersDecodeErrorZPtr { +/// Creates a new CResult_RouteHopDecodeErrorZ in the success state. +pub extern "C" fn CResult_RouteHopDecodeErrorZ_ok(o: crate::lightning::routing::router::RouteHop) -> CResult_RouteHopDecodeErrorZ { + CResult_RouteHopDecodeErrorZ { + contents: CResult_RouteHopDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_RouteParametersDecodeErrorZ in the error state. -pub extern "C" fn CResult_RouteParametersDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_RouteParametersDecodeErrorZ { - CResult_RouteParametersDecodeErrorZ { - contents: CResult_RouteParametersDecodeErrorZPtr { +/// Creates a new CResult_RouteHopDecodeErrorZ in the error state. +pub extern "C" fn CResult_RouteHopDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_RouteHopDecodeErrorZ { + CResult_RouteHopDecodeErrorZ { + contents: CResult_RouteHopDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -2947,13 +3121,13 @@ pub extern "C" fn CResult_RouteParametersDecodeErrorZ_err(e: crate::lightning::l } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_RouteParametersDecodeErrorZ_is_ok(o: &CResult_RouteParametersDecodeErrorZ) -> bool { +pub extern "C" fn CResult_RouteHopDecodeErrorZ_is_ok(o: &CResult_RouteHopDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_RouteParametersDecodeErrorZ. -pub extern "C" fn CResult_RouteParametersDecodeErrorZ_free(_res: CResult_RouteParametersDecodeErrorZ) { } -impl Drop for CResult_RouteParametersDecodeErrorZ { +/// Frees any resources used by the CResult_RouteHopDecodeErrorZ. +pub extern "C" fn CResult_RouteHopDecodeErrorZ_free(_res: CResult_RouteHopDecodeErrorZ) { } +impl Drop for CResult_RouteHopDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -2966,16 +3140,16 @@ impl Drop for CResult_RouteParametersDecodeErrorZ { } } } -impl From> for CResult_RouteParametersDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_RouteHopDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_RouteParametersDecodeErrorZPtr { result } + CResult_RouteHopDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_RouteParametersDecodeErrorZPtr { err } + CResult_RouteHopDecodeErrorZPtr { err } }; Self { contents, @@ -2983,47 +3157,47 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_RouteParametersDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_RouteHopDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_RouteParametersDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_RouteHopDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_RouteParametersDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_RouteHopDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_RouteParametersDecodeErrorZ_clone(orig: &CResult_RouteParametersDecodeErrorZ) -> CResult_RouteParametersDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_RouteHopDecodeErrorZ_clone(orig: &CResult_RouteHopDecodeErrorZ) -> CResult_RouteHopDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// A dynamically-allocated array of u64s of arbitrary size. +/// A dynamically-allocated array of crate::lightning::blinded_path::BlindedHops of arbitrary size. /// This corresponds to std::vector in C++ -pub struct CVec_u64Z { +pub struct CVec_BlindedHopZ { /// The elements in the array. /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut u64, + pub data: *mut crate::lightning::blinded_path::BlindedHop, /// The number of elements pointed to by `data`. pub datalen: usize } -impl CVec_u64Z { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { +impl CVec_BlindedHopZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { if self.datalen == 0 { return Vec::new(); } let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); self.data = core::ptr::null_mut(); self.datalen = 0; ret } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[u64] { + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::blinded_path::BlindedHop] { unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl From> for CVec_u64Z { - fn from(v: Vec) -> Self { +impl From> for CVec_BlindedHopZ { + fn from(v: Vec) -> Self { let datalen = v.len(); let data = Box::into_raw(v.into_boxed_slice()); Self { datalen, data: unsafe { (*data).as_mut_ptr() } } @@ -3031,14 +3205,14 @@ impl From> for CVec_u64Z { } #[no_mangle] /// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_u64Z_free(_res: CVec_u64Z) { } -impl Drop for CVec_u64Z { +pub extern "C" fn CVec_BlindedHopZ_free(_res: CVec_BlindedHopZ) { } +impl Drop for CVec_BlindedHopZ { fn drop(&mut self) { if self.datalen == 0 { return; } let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl Clone for CVec_u64Z { +impl Clone for CVec_BlindedHopZ { fn clone(&self) -> Self { let mut res = Vec::new(); if self.datalen == 0 { return Self::from(res); } @@ -3047,41 +3221,41 @@ impl Clone for CVec_u64Z { } } #[repr(C)] -/// The contents of CResult_PaymentParametersDecodeErrorZ -pub union CResult_PaymentParametersDecodeErrorZPtr { +/// The contents of CResult_BlindedTailDecodeErrorZ +pub union CResult_BlindedTailDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::routing::router::PaymentParameters, + pub result: *mut crate::lightning::routing::router::BlindedTail, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_PaymentParametersDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::routing::router::PaymentParameters on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_BlindedTailDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::routing::router::BlindedTail on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_PaymentParametersDecodeErrorZ { - /// The contents of this CResult_PaymentParametersDecodeErrorZ, accessible via either +pub struct CResult_BlindedTailDecodeErrorZ { + /// The contents of this CResult_BlindedTailDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_PaymentParametersDecodeErrorZPtr, - /// Whether this CResult_PaymentParametersDecodeErrorZ represents a success state. + pub contents: CResult_BlindedTailDecodeErrorZPtr, + /// Whether this CResult_BlindedTailDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_PaymentParametersDecodeErrorZ in the success state. -pub extern "C" fn CResult_PaymentParametersDecodeErrorZ_ok(o: crate::lightning::routing::router::PaymentParameters) -> CResult_PaymentParametersDecodeErrorZ { - CResult_PaymentParametersDecodeErrorZ { - contents: CResult_PaymentParametersDecodeErrorZPtr { +/// Creates a new CResult_BlindedTailDecodeErrorZ in the success state. +pub extern "C" fn CResult_BlindedTailDecodeErrorZ_ok(o: crate::lightning::routing::router::BlindedTail) -> CResult_BlindedTailDecodeErrorZ { + CResult_BlindedTailDecodeErrorZ { + contents: CResult_BlindedTailDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_PaymentParametersDecodeErrorZ in the error state. -pub extern "C" fn CResult_PaymentParametersDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_PaymentParametersDecodeErrorZ { - CResult_PaymentParametersDecodeErrorZ { - contents: CResult_PaymentParametersDecodeErrorZPtr { +/// Creates a new CResult_BlindedTailDecodeErrorZ in the error state. +pub extern "C" fn CResult_BlindedTailDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_BlindedTailDecodeErrorZ { + CResult_BlindedTailDecodeErrorZ { + contents: CResult_BlindedTailDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -3089,13 +3263,13 @@ pub extern "C" fn CResult_PaymentParametersDecodeErrorZ_err(e: crate::lightning: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_PaymentParametersDecodeErrorZ_is_ok(o: &CResult_PaymentParametersDecodeErrorZ) -> bool { +pub extern "C" fn CResult_BlindedTailDecodeErrorZ_is_ok(o: &CResult_BlindedTailDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_PaymentParametersDecodeErrorZ. -pub extern "C" fn CResult_PaymentParametersDecodeErrorZ_free(_res: CResult_PaymentParametersDecodeErrorZ) { } -impl Drop for CResult_PaymentParametersDecodeErrorZ { +/// Frees any resources used by the CResult_BlindedTailDecodeErrorZ. +pub extern "C" fn CResult_BlindedTailDecodeErrorZ_free(_res: CResult_BlindedTailDecodeErrorZ) { } +impl Drop for CResult_BlindedTailDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -3108,16 +3282,16 @@ impl Drop for CResult_PaymentParametersDecodeErrorZ { } } } -impl From> for CResult_PaymentParametersDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_BlindedTailDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_PaymentParametersDecodeErrorZPtr { result } + CResult_BlindedTailDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_PaymentParametersDecodeErrorZPtr { err } + CResult_BlindedTailDecodeErrorZPtr { err } }; Self { contents, @@ -3125,89 +3299,47 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_PaymentParametersDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_BlindedTailDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_PaymentParametersDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_BlindedTailDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_PaymentParametersDecodeErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_PaymentParametersDecodeErrorZ_clone(orig: &CResult_PaymentParametersDecodeErrorZ) -> CResult_PaymentParametersDecodeErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple_BlindedPayInfoBlindedPathZ { - /// The element at position 0 - pub a: crate::lightning::offers::invoice::BlindedPayInfo, - /// The element at position 1 - pub b: crate::lightning::blinded_path::BlindedPath, -} -impl From<(crate::lightning::offers::invoice::BlindedPayInfo, crate::lightning::blinded_path::BlindedPath)> for C2Tuple_BlindedPayInfoBlindedPathZ { - fn from (tup: (crate::lightning::offers::invoice::BlindedPayInfo, crate::lightning::blinded_path::BlindedPath)) -> Self { - Self { - a: tup.0, - b: tup.1, - } - } -} -impl C2Tuple_BlindedPayInfoBlindedPathZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::lightning::offers::invoice::BlindedPayInfo, crate::lightning::blinded_path::BlindedPath) { - (self.a, self.b) - } -} -impl Clone for C2Tuple_BlindedPayInfoBlindedPathZ { - fn clone(&self) -> Self { - Self { - a: Clone::clone(&self.a), - b: Clone::clone(&self.b), - } - } -} -#[no_mangle] -/// Creates a new tuple which has the same data as `orig` +/// Creates a new CResult_BlindedTailDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C2Tuple_BlindedPayInfoBlindedPathZ_clone(orig: &C2Tuple_BlindedPayInfoBlindedPathZ) -> C2Tuple_BlindedPayInfoBlindedPathZ { Clone::clone(&orig) } -/// Creates a new C2Tuple_BlindedPayInfoBlindedPathZ from the contained elements. -#[no_mangle] -pub extern "C" fn C2Tuple_BlindedPayInfoBlindedPathZ_new(a: crate::lightning::offers::invoice::BlindedPayInfo, b: crate::lightning::blinded_path::BlindedPath) -> C2Tuple_BlindedPayInfoBlindedPathZ { - C2Tuple_BlindedPayInfoBlindedPathZ { a, b, } -} - -#[no_mangle] -/// Frees any resources used by the C2Tuple_BlindedPayInfoBlindedPathZ. -pub extern "C" fn C2Tuple_BlindedPayInfoBlindedPathZ_free(_res: C2Tuple_BlindedPayInfoBlindedPathZ) { } +pub extern "C" fn CResult_BlindedTailDecodeErrorZ_clone(orig: &CResult_BlindedTailDecodeErrorZ) -> CResult_BlindedTailDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_BlindedPayInfoBlindedPathZs of arbitrary size. +/// A dynamically-allocated array of crate::lightning::routing::router::RouteHops of arbitrary size. /// This corresponds to std::vector in C++ -pub struct CVec_C2Tuple_BlindedPayInfoBlindedPathZZ { +pub struct CVec_RouteHopZ { /// The elements in the array. /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::derived::C2Tuple_BlindedPayInfoBlindedPathZ, + pub data: *mut crate::lightning::routing::router::RouteHop, /// The number of elements pointed to by `data`. pub datalen: usize } -impl CVec_C2Tuple_BlindedPayInfoBlindedPathZZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { +impl CVec_RouteHopZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { if self.datalen == 0 { return Vec::new(); } let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); self.data = core::ptr::null_mut(); self.datalen = 0; ret } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_BlindedPayInfoBlindedPathZ] { + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::routing::router::RouteHop] { unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl From> for CVec_C2Tuple_BlindedPayInfoBlindedPathZZ { - fn from(v: Vec) -> Self { +impl From> for CVec_RouteHopZ { + fn from(v: Vec) -> Self { let datalen = v.len(); let data = Box::into_raw(v.into_boxed_slice()); Self { datalen, data: unsafe { (*data).as_mut_ptr() } } @@ -3215,14 +3347,14 @@ impl From> for } #[no_mangle] /// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_C2Tuple_BlindedPayInfoBlindedPathZZ_free(_res: CVec_C2Tuple_BlindedPayInfoBlindedPathZZ) { } -impl Drop for CVec_C2Tuple_BlindedPayInfoBlindedPathZZ { +pub extern "C" fn CVec_RouteHopZ_free(_res: CVec_RouteHopZ) { } +impl Drop for CVec_RouteHopZ { fn drop(&mut self) { if self.datalen == 0 { return; } let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl Clone for CVec_C2Tuple_BlindedPayInfoBlindedPathZZ { +impl Clone for CVec_RouteHopZ { fn clone(&self) -> Self { let mut res = Vec::new(); if self.datalen == 0 { return Self::from(res); } @@ -3231,75 +3363,66 @@ impl Clone for CVec_C2Tuple_BlindedPayInfoBlindedPathZZ { } } #[repr(C)] -/// A dynamically-allocated array of crate::lightning::routing::router::RouteHints of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_RouteHintZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::routing::router::RouteHint, - /// The number of elements pointed to by `data`. - pub datalen: usize +#[derive(Clone)] +/// An enum which can either contain a u32 or not +pub enum COption_u32Z { + /// When we're in this state, this COption_u32Z contains a u32 + Some(u32), + /// When we're in this state, this COption_u32Z contains nothing + None } -impl CVec_RouteHintZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret +impl COption_u32Z { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::routing::router::RouteHint] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() } -} -impl From> for CVec_RouteHintZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + #[allow(unused)] pub(crate) fn take(mut self) -> u32 { + if let Self::Some(v) = self { v } else { unreachable!() } } } #[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_RouteHintZ_free(_res: CVec_RouteHintZ) { } -impl Drop for CVec_RouteHintZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_RouteHintZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } +/// Constructs a new COption_u32Z containing a u32 +pub extern "C" fn COption_u32Z_some(o: u32) -> COption_u32Z { + COption_u32Z::Some(o) +} +#[no_mangle] +/// Constructs a new COption_u32Z containing nothing +pub extern "C" fn COption_u32Z_none() -> COption_u32Z { + COption_u32Z::None } +#[no_mangle] +/// Frees any resources associated with the u32, if we are in the Some state +pub extern "C" fn COption_u32Z_free(_res: COption_u32Z) { } +#[no_mangle] +/// Creates a new COption_u32Z which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_u32Z_clone(orig: &COption_u32Z) -> COption_u32Z { Clone::clone(&orig) } #[repr(C)] -/// A dynamically-allocated array of crate::lightning::routing::router::RouteHintHops of arbitrary size. +/// A dynamically-allocated array of crate::lightning::routing::router::Paths of arbitrary size. /// This corresponds to std::vector in C++ -pub struct CVec_RouteHintHopZ { +pub struct CVec_PathZ { /// The elements in the array. /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::routing::router::RouteHintHop, + pub data: *mut crate::lightning::routing::router::Path, /// The number of elements pointed to by `data`. pub datalen: usize } -impl CVec_RouteHintHopZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { +impl CVec_PathZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { if self.datalen == 0 { return Vec::new(); } let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); self.data = core::ptr::null_mut(); self.datalen = 0; ret } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::routing::router::RouteHintHop] { + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::routing::router::Path] { unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl From> for CVec_RouteHintHopZ { - fn from(v: Vec) -> Self { +impl From> for CVec_PathZ { + fn from(v: Vec) -> Self { let datalen = v.len(); let data = Box::into_raw(v.into_boxed_slice()); Self { datalen, data: unsafe { (*data).as_mut_ptr() } } @@ -3307,14 +3430,14 @@ impl From> for CVec_RouteHi } #[no_mangle] /// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_RouteHintHopZ_free(_res: CVec_RouteHintHopZ) { } -impl Drop for CVec_RouteHintHopZ { +pub extern "C" fn CVec_PathZ_free(_res: CVec_PathZ) { } +impl Drop for CVec_PathZ { fn drop(&mut self) { if self.datalen == 0 { return; } let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl Clone for CVec_RouteHintHopZ { +impl Clone for CVec_PathZ { fn clone(&self) -> Self { let mut res = Vec::new(); if self.datalen == 0 { return Self::from(res); } @@ -3323,41 +3446,41 @@ impl Clone for CVec_RouteHintHopZ { } } #[repr(C)] -/// The contents of CResult_RouteHintDecodeErrorZ -pub union CResult_RouteHintDecodeErrorZPtr { +/// The contents of CResult_RouteDecodeErrorZ +pub union CResult_RouteDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::routing::router::RouteHint, + pub result: *mut crate::lightning::routing::router::Route, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_RouteHintDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::routing::router::RouteHint on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_RouteDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::routing::router::Route on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_RouteHintDecodeErrorZ { - /// The contents of this CResult_RouteHintDecodeErrorZ, accessible via either +pub struct CResult_RouteDecodeErrorZ { + /// The contents of this CResult_RouteDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_RouteHintDecodeErrorZPtr, - /// Whether this CResult_RouteHintDecodeErrorZ represents a success state. + pub contents: CResult_RouteDecodeErrorZPtr, + /// Whether this CResult_RouteDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_RouteHintDecodeErrorZ in the success state. -pub extern "C" fn CResult_RouteHintDecodeErrorZ_ok(o: crate::lightning::routing::router::RouteHint) -> CResult_RouteHintDecodeErrorZ { - CResult_RouteHintDecodeErrorZ { - contents: CResult_RouteHintDecodeErrorZPtr { +/// Creates a new CResult_RouteDecodeErrorZ in the success state. +pub extern "C" fn CResult_RouteDecodeErrorZ_ok(o: crate::lightning::routing::router::Route) -> CResult_RouteDecodeErrorZ { + CResult_RouteDecodeErrorZ { + contents: CResult_RouteDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_RouteHintDecodeErrorZ in the error state. -pub extern "C" fn CResult_RouteHintDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_RouteHintDecodeErrorZ { - CResult_RouteHintDecodeErrorZ { - contents: CResult_RouteHintDecodeErrorZPtr { +/// Creates a new CResult_RouteDecodeErrorZ in the error state. +pub extern "C" fn CResult_RouteDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_RouteDecodeErrorZ { + CResult_RouteDecodeErrorZ { + contents: CResult_RouteDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -3365,13 +3488,13 @@ pub extern "C" fn CResult_RouteHintDecodeErrorZ_err(e: crate::lightning::ln::msg } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_RouteHintDecodeErrorZ_is_ok(o: &CResult_RouteHintDecodeErrorZ) -> bool { +pub extern "C" fn CResult_RouteDecodeErrorZ_is_ok(o: &CResult_RouteDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_RouteHintDecodeErrorZ. -pub extern "C" fn CResult_RouteHintDecodeErrorZ_free(_res: CResult_RouteHintDecodeErrorZ) { } -impl Drop for CResult_RouteHintDecodeErrorZ { +/// Frees any resources used by the CResult_RouteDecodeErrorZ. +pub extern "C" fn CResult_RouteDecodeErrorZ_free(_res: CResult_RouteDecodeErrorZ) { } +impl Drop for CResult_RouteDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -3384,16 +3507,16 @@ impl Drop for CResult_RouteHintDecodeErrorZ { } } } -impl From> for CResult_RouteHintDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_RouteDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_RouteHintDecodeErrorZPtr { result } + CResult_RouteDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_RouteHintDecodeErrorZPtr { err } + CResult_RouteDecodeErrorZPtr { err } }; Self { contents, @@ -3401,59 +3524,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_RouteHintDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_RouteDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_RouteHintDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_RouteDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_RouteHintDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_RouteDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_RouteHintDecodeErrorZ_clone(orig: &CResult_RouteHintDecodeErrorZ) -> CResult_RouteHintDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_RouteDecodeErrorZ_clone(orig: &CResult_RouteDecodeErrorZ) -> CResult_RouteDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_RouteHintHopDecodeErrorZ -pub union CResult_RouteHintHopDecodeErrorZPtr { +/// The contents of CResult_RouteParametersDecodeErrorZ +pub union CResult_RouteParametersDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::routing::router::RouteHintHop, + pub result: *mut crate::lightning::routing::router::RouteParameters, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_RouteHintHopDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::routing::router::RouteHintHop on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_RouteParametersDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::routing::router::RouteParameters on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_RouteHintHopDecodeErrorZ { - /// The contents of this CResult_RouteHintHopDecodeErrorZ, accessible via either +pub struct CResult_RouteParametersDecodeErrorZ { + /// The contents of this CResult_RouteParametersDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_RouteHintHopDecodeErrorZPtr, - /// Whether this CResult_RouteHintHopDecodeErrorZ represents a success state. + pub contents: CResult_RouteParametersDecodeErrorZPtr, + /// Whether this CResult_RouteParametersDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_RouteHintHopDecodeErrorZ in the success state. -pub extern "C" fn CResult_RouteHintHopDecodeErrorZ_ok(o: crate::lightning::routing::router::RouteHintHop) -> CResult_RouteHintHopDecodeErrorZ { - CResult_RouteHintHopDecodeErrorZ { - contents: CResult_RouteHintHopDecodeErrorZPtr { +/// Creates a new CResult_RouteParametersDecodeErrorZ in the success state. +pub extern "C" fn CResult_RouteParametersDecodeErrorZ_ok(o: crate::lightning::routing::router::RouteParameters) -> CResult_RouteParametersDecodeErrorZ { + CResult_RouteParametersDecodeErrorZ { + contents: CResult_RouteParametersDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_RouteHintHopDecodeErrorZ in the error state. -pub extern "C" fn CResult_RouteHintHopDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_RouteHintHopDecodeErrorZ { - CResult_RouteHintHopDecodeErrorZ { - contents: CResult_RouteHintHopDecodeErrorZPtr { +/// Creates a new CResult_RouteParametersDecodeErrorZ in the error state. +pub extern "C" fn CResult_RouteParametersDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_RouteParametersDecodeErrorZ { + CResult_RouteParametersDecodeErrorZ { + contents: CResult_RouteParametersDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -3461,13 +3584,13 @@ pub extern "C" fn CResult_RouteHintHopDecodeErrorZ_err(e: crate::lightning::ln:: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_RouteHintHopDecodeErrorZ_is_ok(o: &CResult_RouteHintHopDecodeErrorZ) -> bool { +pub extern "C" fn CResult_RouteParametersDecodeErrorZ_is_ok(o: &CResult_RouteParametersDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_RouteHintHopDecodeErrorZ. -pub extern "C" fn CResult_RouteHintHopDecodeErrorZ_free(_res: CResult_RouteHintHopDecodeErrorZ) { } -impl Drop for CResult_RouteHintHopDecodeErrorZ { +/// Frees any resources used by the CResult_RouteParametersDecodeErrorZ. +pub extern "C" fn CResult_RouteParametersDecodeErrorZ_free(_res: CResult_RouteParametersDecodeErrorZ) { } +impl Drop for CResult_RouteParametersDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -3480,16 +3603,16 @@ impl Drop for CResult_RouteHintHopDecodeErrorZ { } } } -impl From> for CResult_RouteHintHopDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_RouteParametersDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_RouteHintHopDecodeErrorZPtr { result } + CResult_RouteParametersDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_RouteHintHopDecodeErrorZPtr { err } + CResult_RouteParametersDecodeErrorZPtr { err } }; Self { contents, @@ -3497,47 +3620,47 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_RouteHintHopDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_RouteParametersDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_RouteHintHopDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_RouteParametersDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_RouteHintHopDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_RouteParametersDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_RouteHintHopDecodeErrorZ_clone(orig: &CResult_RouteHintHopDecodeErrorZ) -> CResult_RouteHintHopDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_RouteParametersDecodeErrorZ_clone(orig: &CResult_RouteParametersDecodeErrorZ) -> CResult_RouteParametersDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// A dynamically-allocated array of crate::c_types::PublicKeys of arbitrary size. +/// A dynamically-allocated array of u64s of arbitrary size. /// This corresponds to std::vector in C++ -pub struct CVec_PublicKeyZ { +pub struct CVec_u64Z { /// The elements in the array. /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::PublicKey, + pub data: *mut u64, /// The number of elements pointed to by `data`. pub datalen: usize } -impl CVec_PublicKeyZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { +impl CVec_u64Z { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { if self.datalen == 0 { return Vec::new(); } let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); self.data = core::ptr::null_mut(); self.datalen = 0; ret } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::PublicKey] { + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[u64] { unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl From> for CVec_PublicKeyZ { - fn from(v: Vec) -> Self { +impl From> for CVec_u64Z { + fn from(v: Vec) -> Self { let datalen = v.len(); let data = Box::into_raw(v.into_boxed_slice()); Self { datalen, data: unsafe { (*data).as_mut_ptr() } } @@ -3545,14 +3668,14 @@ impl From> for CVec_PublicKeyZ { } #[no_mangle] /// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_PublicKeyZ_free(_res: CVec_PublicKeyZ) { } -impl Drop for CVec_PublicKeyZ { +pub extern "C" fn CVec_u64Z_free(_res: CVec_u64Z) { } +impl Drop for CVec_u64Z { fn drop(&mut self) { if self.datalen == 0 { return; } let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl Clone for CVec_PublicKeyZ { +impl Clone for CVec_u64Z { fn clone(&self) -> Self { let mut res = Vec::new(); if self.datalen == 0 { return Self::from(res); } @@ -3561,115 +3684,123 @@ impl Clone for CVec_PublicKeyZ { } } #[repr(C)] -/// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple_usizeTransactionZ { - /// The element at position 0 - pub a: usize, - /// The element at position 1 - pub b: crate::c_types::Transaction, +/// The contents of CResult_PaymentParametersDecodeErrorZ +pub union CResult_PaymentParametersDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::routing::router::PaymentParameters, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, } -impl From<(usize, crate::c_types::Transaction)> for C2Tuple_usizeTransactionZ { - fn from (tup: (usize, crate::c_types::Transaction)) -> Self { - Self { - a: tup.0, - b: tup.1, - } - } +#[repr(C)] +/// A CResult_PaymentParametersDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::routing::router::PaymentParameters on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_PaymentParametersDecodeErrorZ { + /// The contents of this CResult_PaymentParametersDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_PaymentParametersDecodeErrorZPtr, + /// Whether this CResult_PaymentParametersDecodeErrorZ represents a success state. + pub result_ok: bool, } -impl C2Tuple_usizeTransactionZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (usize, crate::c_types::Transaction) { - (self.a, self.b) +#[no_mangle] +/// Creates a new CResult_PaymentParametersDecodeErrorZ in the success state. +pub extern "C" fn CResult_PaymentParametersDecodeErrorZ_ok(o: crate::lightning::routing::router::PaymentParameters) -> CResult_PaymentParametersDecodeErrorZ { + CResult_PaymentParametersDecodeErrorZ { + contents: CResult_PaymentParametersDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, } } -impl Clone for C2Tuple_usizeTransactionZ { - fn clone(&self) -> Self { - Self { - a: Clone::clone(&self.a), - b: Clone::clone(&self.b), - } +#[no_mangle] +/// Creates a new CResult_PaymentParametersDecodeErrorZ in the error state. +pub extern "C" fn CResult_PaymentParametersDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_PaymentParametersDecodeErrorZ { + CResult_PaymentParametersDecodeErrorZ { + contents: CResult_PaymentParametersDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, } } +/// Checks if the given object is currently in the success state #[no_mangle] -/// Creates a new tuple which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C2Tuple_usizeTransactionZ_clone(orig: &C2Tuple_usizeTransactionZ) -> C2Tuple_usizeTransactionZ { Clone::clone(&orig) } -/// Creates a new C2Tuple_usizeTransactionZ from the contained elements. -#[no_mangle] -pub extern "C" fn C2Tuple_usizeTransactionZ_new(a: usize, b: crate::c_types::Transaction) -> C2Tuple_usizeTransactionZ { - C2Tuple_usizeTransactionZ { a, b, } +pub extern "C" fn CResult_PaymentParametersDecodeErrorZ_is_ok(o: &CResult_PaymentParametersDecodeErrorZ) -> bool { + o.result_ok } - #[no_mangle] -/// Frees any resources used by the C2Tuple_usizeTransactionZ. -pub extern "C" fn C2Tuple_usizeTransactionZ_free(_res: C2Tuple_usizeTransactionZ) { } -#[repr(C)] -/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_usizeTransactionZs of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_C2Tuple_usizeTransactionZZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::derived::C2Tuple_usizeTransactionZ, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_C2Tuple_usizeTransactionZZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_usizeTransactionZ] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_C2Tuple_usizeTransactionZZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } +/// Frees any resources used by the CResult_PaymentParametersDecodeErrorZ. +pub extern "C" fn CResult_PaymentParametersDecodeErrorZ_free(_res: CResult_PaymentParametersDecodeErrorZ) { } +impl Drop for CResult_PaymentParametersDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } } } -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_C2Tuple_usizeTransactionZZ_free(_res: CVec_C2Tuple_usizeTransactionZZ) { } -impl Drop for CVec_C2Tuple_usizeTransactionZZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; +impl From> for CResult_PaymentParametersDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_PaymentParametersDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_PaymentParametersDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } } } -impl Clone for CVec_C2Tuple_usizeTransactionZZ { +impl Clone for CResult_PaymentParametersDecodeErrorZ { fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) + if self.result_ok { + Self { result_ok: true, contents: CResult_PaymentParametersDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_PaymentParametersDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } } } +#[no_mangle] +/// Creates a new CResult_PaymentParametersDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_PaymentParametersDecodeErrorZ_clone(orig: &CResult_PaymentParametersDecodeErrorZ) -> CResult_PaymentParametersDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] /// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple_TxidBlockHashZ { +pub struct C2Tuple_BlindedPayInfoBlindedPathZ { /// The element at position 0 - pub a: crate::c_types::ThirtyTwoBytes, + pub a: crate::lightning::offers::invoice::BlindedPayInfo, /// The element at position 1 - pub b: crate::c_types::ThirtyTwoBytes, + pub b: crate::lightning::blinded_path::BlindedPath, } -impl From<(crate::c_types::ThirtyTwoBytes, crate::c_types::ThirtyTwoBytes)> for C2Tuple_TxidBlockHashZ { - fn from (tup: (crate::c_types::ThirtyTwoBytes, crate::c_types::ThirtyTwoBytes)) -> Self { +impl From<(crate::lightning::offers::invoice::BlindedPayInfo, crate::lightning::blinded_path::BlindedPath)> for C2Tuple_BlindedPayInfoBlindedPathZ { + fn from (tup: (crate::lightning::offers::invoice::BlindedPayInfo, crate::lightning::blinded_path::BlindedPath)) -> Self { Self { a: tup.0, b: tup.1, } } } -impl C2Tuple_TxidBlockHashZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoBytes, crate::c_types::ThirtyTwoBytes) { +impl C2Tuple_BlindedPayInfoBlindedPathZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::lightning::offers::invoice::BlindedPayInfo, crate::lightning::blinded_path::BlindedPath) { (self.a, self.b) } } -impl Clone for C2Tuple_TxidBlockHashZ { +impl Clone for C2Tuple_BlindedPayInfoBlindedPathZ { fn clone(&self) -> Self { Self { a: Clone::clone(&self.a), @@ -3680,40 +3811,40 @@ impl Clone for C2Tuple_TxidBlockHashZ { #[no_mangle] /// Creates a new tuple which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C2Tuple_TxidBlockHashZ_clone(orig: &C2Tuple_TxidBlockHashZ) -> C2Tuple_TxidBlockHashZ { Clone::clone(&orig) } -/// Creates a new C2Tuple_TxidBlockHashZ from the contained elements. +pub extern "C" fn C2Tuple_BlindedPayInfoBlindedPathZ_clone(orig: &C2Tuple_BlindedPayInfoBlindedPathZ) -> C2Tuple_BlindedPayInfoBlindedPathZ { Clone::clone(&orig) } +/// Creates a new C2Tuple_BlindedPayInfoBlindedPathZ from the contained elements. #[no_mangle] -pub extern "C" fn C2Tuple_TxidBlockHashZ_new(a: crate::c_types::ThirtyTwoBytes, b: crate::c_types::ThirtyTwoBytes) -> C2Tuple_TxidBlockHashZ { - C2Tuple_TxidBlockHashZ { a, b, } +pub extern "C" fn C2Tuple_BlindedPayInfoBlindedPathZ_new(a: crate::lightning::offers::invoice::BlindedPayInfo, b: crate::lightning::blinded_path::BlindedPath) -> C2Tuple_BlindedPayInfoBlindedPathZ { + C2Tuple_BlindedPayInfoBlindedPathZ { a, b, } } #[no_mangle] -/// Frees any resources used by the C2Tuple_TxidBlockHashZ. -pub extern "C" fn C2Tuple_TxidBlockHashZ_free(_res: C2Tuple_TxidBlockHashZ) { } +/// Frees any resources used by the C2Tuple_BlindedPayInfoBlindedPathZ. +pub extern "C" fn C2Tuple_BlindedPayInfoBlindedPathZ_free(_res: C2Tuple_BlindedPayInfoBlindedPathZ) { } #[repr(C)] -/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_TxidBlockHashZs of arbitrary size. +/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_BlindedPayInfoBlindedPathZs of arbitrary size. /// This corresponds to std::vector in C++ -pub struct CVec_C2Tuple_TxidBlockHashZZ { +pub struct CVec_C2Tuple_BlindedPayInfoBlindedPathZZ { /// The elements in the array. /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::derived::C2Tuple_TxidBlockHashZ, + pub data: *mut crate::c_types::derived::C2Tuple_BlindedPayInfoBlindedPathZ, /// The number of elements pointed to by `data`. pub datalen: usize } -impl CVec_C2Tuple_TxidBlockHashZZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { +impl CVec_C2Tuple_BlindedPayInfoBlindedPathZZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { if self.datalen == 0 { return Vec::new(); } let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); self.data = core::ptr::null_mut(); self.datalen = 0; ret } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_TxidBlockHashZ] { + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_BlindedPayInfoBlindedPathZ] { unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl From> for CVec_C2Tuple_TxidBlockHashZZ { - fn from(v: Vec) -> Self { +impl From> for CVec_C2Tuple_BlindedPayInfoBlindedPathZZ { + fn from(v: Vec) -> Self { let datalen = v.len(); let data = Box::into_raw(v.into_boxed_slice()); Self { datalen, data: unsafe { (*data).as_mut_ptr() } } @@ -3721,14 +3852,14 @@ impl From> for CVec_C2Tuple } #[no_mangle] /// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_C2Tuple_TxidBlockHashZZ_free(_res: CVec_C2Tuple_TxidBlockHashZZ) { } -impl Drop for CVec_C2Tuple_TxidBlockHashZZ { +pub extern "C" fn CVec_C2Tuple_BlindedPayInfoBlindedPathZZ_free(_res: CVec_C2Tuple_BlindedPayInfoBlindedPathZZ) { } +impl Drop for CVec_C2Tuple_BlindedPayInfoBlindedPathZZ { fn drop(&mut self) { if self.datalen == 0 { return; } let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl Clone for CVec_C2Tuple_TxidBlockHashZZ { +impl Clone for CVec_C2Tuple_BlindedPayInfoBlindedPathZZ { fn clone(&self) -> Self { let mut res = Vec::new(); if self.datalen == 0 { return Self::from(res); } @@ -3737,29 +3868,29 @@ impl Clone for CVec_C2Tuple_TxidBlockHashZZ { } } #[repr(C)] -/// A dynamically-allocated array of crate::lightning::chain::channelmonitor::MonitorEvents of arbitrary size. +/// A dynamically-allocated array of crate::lightning::routing::router::RouteHints of arbitrary size. /// This corresponds to std::vector in C++ -pub struct CVec_MonitorEventZ { +pub struct CVec_RouteHintZ { /// The elements in the array. /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::chain::channelmonitor::MonitorEvent, + pub data: *mut crate::lightning::routing::router::RouteHint, /// The number of elements pointed to by `data`. pub datalen: usize } -impl CVec_MonitorEventZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { +impl CVec_RouteHintZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { if self.datalen == 0 { return Vec::new(); } let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); self.data = core::ptr::null_mut(); self.datalen = 0; ret } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::chain::channelmonitor::MonitorEvent] { + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::routing::router::RouteHint] { unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl From> for CVec_MonitorEventZ { - fn from(v: Vec) -> Self { +impl From> for CVec_RouteHintZ { + fn from(v: Vec) -> Self { let datalen = v.len(); let data = Box::into_raw(v.into_boxed_slice()); Self { datalen, data: unsafe { (*data).as_mut_ptr() } } @@ -3767,14 +3898,14 @@ impl From> for CVec_M } #[no_mangle] /// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_MonitorEventZ_free(_res: CVec_MonitorEventZ) { } -impl Drop for CVec_MonitorEventZ { +pub extern "C" fn CVec_RouteHintZ_free(_res: CVec_RouteHintZ) { } +impl Drop for CVec_RouteHintZ { fn drop(&mut self) { if self.datalen == 0 { return; } let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl Clone for CVec_MonitorEventZ { +impl Clone for CVec_RouteHintZ { fn clone(&self) -> Self { let mut res = Vec::new(); if self.datalen == 0 { return Self::from(res); } @@ -3783,75 +3914,29 @@ impl Clone for CVec_MonitorEventZ { } } #[repr(C)] -/// A tuple of 3 elements. See the individual fields for the types contained. -pub struct C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ { - /// The element at position 0 - pub a: crate::lightning::chain::transaction::OutPoint, - /// The element at position 1 - pub b: crate::c_types::derived::CVec_MonitorEventZ, - /// The element at position 2 - pub c: crate::c_types::PublicKey, -} -impl From<(crate::lightning::chain::transaction::OutPoint, crate::c_types::derived::CVec_MonitorEventZ, crate::c_types::PublicKey)> for C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ { - fn from (tup: (crate::lightning::chain::transaction::OutPoint, crate::c_types::derived::CVec_MonitorEventZ, crate::c_types::PublicKey)) -> Self { - Self { - a: tup.0, - b: tup.1, - c: tup.2, - } - } -} -impl C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::lightning::chain::transaction::OutPoint, crate::c_types::derived::CVec_MonitorEventZ, crate::c_types::PublicKey) { - (self.a, self.b, self.c) - } -} -impl Clone for C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ { - fn clone(&self) -> Self { - Self { - a: Clone::clone(&self.a), - b: Clone::clone(&self.b), - c: Clone::clone(&self.c), - } - } -} -#[no_mangle] -/// Creates a new tuple which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(orig: &C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ) -> C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ { Clone::clone(&orig) } -/// Creates a new C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ from the contained elements. -#[no_mangle] -pub extern "C" fn C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_new(a: crate::lightning::chain::transaction::OutPoint, b: crate::c_types::derived::CVec_MonitorEventZ, c: crate::c_types::PublicKey) -> C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ { - C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ { a, b, c, } -} - -#[no_mangle] -/// Frees any resources used by the C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ. -pub extern "C" fn C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_free(_res: C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ) { } -#[repr(C)] -/// A dynamically-allocated array of crate::c_types::derived::C3Tuple_OutPointCVec_MonitorEventZPublicKeyZs of arbitrary size. +/// A dynamically-allocated array of crate::lightning::routing::router::RouteHintHops of arbitrary size. /// This corresponds to std::vector in C++ -pub struct CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ { +pub struct CVec_RouteHintHopZ { /// The elements in the array. /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::derived::C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ, + pub data: *mut crate::lightning::routing::router::RouteHintHop, /// The number of elements pointed to by `data`. pub datalen: usize } -impl CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { +impl CVec_RouteHintHopZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { if self.datalen == 0 { return Vec::new(); } let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); self.data = core::ptr::null_mut(); self.datalen = 0; ret } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ] { + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::routing::router::RouteHintHop] { unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl From> for CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ { - fn from(v: Vec) -> Self { +impl From> for CVec_RouteHintHopZ { + fn from(v: Vec) -> Self { let datalen = v.len(); let data = Box::into_raw(v.into_boxed_slice()); Self { datalen, data: unsafe { (*data).as_mut_ptr() } } @@ -3859,14 +3944,14 @@ impl From Self { let mut res = Vec::new(); if self.datalen == 0 { return Self::from(res); } @@ -3875,41 +3960,41 @@ impl Clone for CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ { } } #[repr(C)] -/// The contents of CResult_FixedPenaltyScorerDecodeErrorZ -pub union CResult_FixedPenaltyScorerDecodeErrorZPtr { +/// The contents of CResult_RouteHintDecodeErrorZ +pub union CResult_RouteHintDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::routing::scoring::FixedPenaltyScorer, + pub result: *mut crate::lightning::routing::router::RouteHint, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_FixedPenaltyScorerDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::routing::scoring::FixedPenaltyScorer on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_RouteHintDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::routing::router::RouteHint on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_FixedPenaltyScorerDecodeErrorZ { - /// The contents of this CResult_FixedPenaltyScorerDecodeErrorZ, accessible via either +pub struct CResult_RouteHintDecodeErrorZ { + /// The contents of this CResult_RouteHintDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_FixedPenaltyScorerDecodeErrorZPtr, - /// Whether this CResult_FixedPenaltyScorerDecodeErrorZ represents a success state. + pub contents: CResult_RouteHintDecodeErrorZPtr, + /// Whether this CResult_RouteHintDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_FixedPenaltyScorerDecodeErrorZ in the success state. -pub extern "C" fn CResult_FixedPenaltyScorerDecodeErrorZ_ok(o: crate::lightning::routing::scoring::FixedPenaltyScorer) -> CResult_FixedPenaltyScorerDecodeErrorZ { - CResult_FixedPenaltyScorerDecodeErrorZ { - contents: CResult_FixedPenaltyScorerDecodeErrorZPtr { +/// Creates a new CResult_RouteHintDecodeErrorZ in the success state. +pub extern "C" fn CResult_RouteHintDecodeErrorZ_ok(o: crate::lightning::routing::router::RouteHint) -> CResult_RouteHintDecodeErrorZ { + CResult_RouteHintDecodeErrorZ { + contents: CResult_RouteHintDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_FixedPenaltyScorerDecodeErrorZ in the error state. -pub extern "C" fn CResult_FixedPenaltyScorerDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_FixedPenaltyScorerDecodeErrorZ { - CResult_FixedPenaltyScorerDecodeErrorZ { - contents: CResult_FixedPenaltyScorerDecodeErrorZPtr { +/// Creates a new CResult_RouteHintDecodeErrorZ in the error state. +pub extern "C" fn CResult_RouteHintDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_RouteHintDecodeErrorZ { + CResult_RouteHintDecodeErrorZ { + contents: CResult_RouteHintDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -3917,13 +4002,13 @@ pub extern "C" fn CResult_FixedPenaltyScorerDecodeErrorZ_err(e: crate::lightning } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(o: &CResult_FixedPenaltyScorerDecodeErrorZ) -> bool { +pub extern "C" fn CResult_RouteHintDecodeErrorZ_is_ok(o: &CResult_RouteHintDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_FixedPenaltyScorerDecodeErrorZ. -pub extern "C" fn CResult_FixedPenaltyScorerDecodeErrorZ_free(_res: CResult_FixedPenaltyScorerDecodeErrorZ) { } -impl Drop for CResult_FixedPenaltyScorerDecodeErrorZ { +/// Frees any resources used by the CResult_RouteHintDecodeErrorZ. +pub extern "C" fn CResult_RouteHintDecodeErrorZ_free(_res: CResult_RouteHintDecodeErrorZ) { } +impl Drop for CResult_RouteHintDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -3936,16 +4021,16 @@ impl Drop for CResult_FixedPenaltyScorerDecodeErrorZ { } } } -impl From> for CResult_FixedPenaltyScorerDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_RouteHintDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_FixedPenaltyScorerDecodeErrorZPtr { result } + CResult_RouteHintDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_FixedPenaltyScorerDecodeErrorZPtr { err } + CResult_RouteHintDecodeErrorZPtr { err } }; Self { contents, @@ -3953,223 +4038,261 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_FixedPenaltyScorerDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_RouteHintDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_FixedPenaltyScorerDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_RouteHintDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_FixedPenaltyScorerDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_RouteHintDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_FixedPenaltyScorerDecodeErrorZ_clone(orig: &CResult_FixedPenaltyScorerDecodeErrorZ) -> CResult_FixedPenaltyScorerDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_RouteHintDecodeErrorZ_clone(orig: &CResult_RouteHintDecodeErrorZ) -> CResult_RouteHintDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple_u64u64Z { - /// The element at position 0 - pub a: u64, - /// The element at position 1 - pub b: u64, -} -impl From<(u64, u64)> for C2Tuple_u64u64Z { - fn from (tup: (u64, u64)) -> Self { - Self { - a: tup.0, - b: tup.1, - } - } -} -impl C2Tuple_u64u64Z { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (u64, u64) { - (self.a, self.b) - } -} -impl Clone for C2Tuple_u64u64Z { - fn clone(&self) -> Self { - Self { - a: Clone::clone(&self.a), - b: Clone::clone(&self.b), - } - } -} -#[no_mangle] -/// Creates a new tuple which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C2Tuple_u64u64Z_clone(orig: &C2Tuple_u64u64Z) -> C2Tuple_u64u64Z { Clone::clone(&orig) } -/// Creates a new C2Tuple_u64u64Z from the contained elements. -#[no_mangle] -pub extern "C" fn C2Tuple_u64u64Z_new(a: u64, b: u64) -> C2Tuple_u64u64Z { - C2Tuple_u64u64Z { a, b, } +/// The contents of CResult_RouteHintHopDecodeErrorZ +pub union CResult_RouteHintHopDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::routing::router::RouteHintHop, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, } - -#[no_mangle] -/// Frees any resources used by the C2Tuple_u64u64Z. -pub extern "C" fn C2Tuple_u64u64Z_free(_res: C2Tuple_u64u64Z) { } #[repr(C)] -#[derive(Clone)] -/// An enum which can either contain a crate::c_types::derived::C2Tuple_u64u64Z or not -pub enum COption_C2Tuple_u64u64ZZ { - /// When we're in this state, this COption_C2Tuple_u64u64ZZ contains a crate::c_types::derived::C2Tuple_u64u64Z - Some(crate::c_types::derived::C2Tuple_u64u64Z), - /// When we're in this state, this COption_C2Tuple_u64u64ZZ contains nothing - None +/// A CResult_RouteHintHopDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::routing::router::RouteHintHop on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_RouteHintHopDecodeErrorZ { + /// The contents of this CResult_RouteHintHopDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_RouteHintHopDecodeErrorZPtr, + /// Whether this CResult_RouteHintHopDecodeErrorZ represents a success state. + pub result_ok: bool, } -impl COption_C2Tuple_u64u64ZZ { - #[allow(unused)] pub(crate) fn is_some(&self) -> bool { - if let Self::None = self { false } else { true } - } - #[allow(unused)] pub(crate) fn is_none(&self) -> bool { - !self.is_some() - } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::derived::C2Tuple_u64u64Z { - if let Self::Some(v) = self { v } else { unreachable!() } +#[no_mangle] +/// Creates a new CResult_RouteHintHopDecodeErrorZ in the success state. +pub extern "C" fn CResult_RouteHintHopDecodeErrorZ_ok(o: crate::lightning::routing::router::RouteHintHop) -> CResult_RouteHintHopDecodeErrorZ { + CResult_RouteHintHopDecodeErrorZ { + contents: CResult_RouteHintHopDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, } } #[no_mangle] -/// Constructs a new COption_C2Tuple_u64u64ZZ containing a crate::c_types::derived::C2Tuple_u64u64Z -pub extern "C" fn COption_C2Tuple_u64u64ZZ_some(o: crate::c_types::derived::C2Tuple_u64u64Z) -> COption_C2Tuple_u64u64ZZ { - COption_C2Tuple_u64u64ZZ::Some(o) +/// Creates a new CResult_RouteHintHopDecodeErrorZ in the error state. +pub extern "C" fn CResult_RouteHintHopDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_RouteHintHopDecodeErrorZ { + CResult_RouteHintHopDecodeErrorZ { + contents: CResult_RouteHintHopDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } } +/// Checks if the given object is currently in the success state #[no_mangle] -/// Constructs a new COption_C2Tuple_u64u64ZZ containing nothing -pub extern "C" fn COption_C2Tuple_u64u64ZZ_none() -> COption_C2Tuple_u64u64ZZ { - COption_C2Tuple_u64u64ZZ::None +pub extern "C" fn CResult_RouteHintHopDecodeErrorZ_is_ok(o: &CResult_RouteHintHopDecodeErrorZ) -> bool { + o.result_ok } #[no_mangle] -/// Frees any resources associated with the crate::c_types::derived::C2Tuple_u64u64Z, if we are in the Some state -pub extern "C" fn COption_C2Tuple_u64u64ZZ_free(_res: COption_C2Tuple_u64u64ZZ) { } -#[no_mangle] -/// Creates a new COption_C2Tuple_u64u64ZZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_C2Tuple_u64u64ZZ_clone(orig: &COption_C2Tuple_u64u64ZZ) -> COption_C2Tuple_u64u64ZZ { Clone::clone(&orig) } -#[repr(C)] -/// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple_Z { - /// The element at position 0 - pub a: crate::c_types::EightU16s, - /// The element at position 1 - pub b: crate::c_types::EightU16s, -} -impl From<(crate::c_types::EightU16s, crate::c_types::EightU16s)> for C2Tuple_Z { - fn from (tup: (crate::c_types::EightU16s, crate::c_types::EightU16s)) -> Self { - Self { - a: tup.0, - b: tup.1, +/// Frees any resources used by the CResult_RouteHintHopDecodeErrorZ. +pub extern "C" fn CResult_RouteHintHopDecodeErrorZ_free(_res: CResult_RouteHintHopDecodeErrorZ) { } +impl Drop for CResult_RouteHintHopDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } } } } -impl C2Tuple_Z { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::EightU16s, crate::c_types::EightU16s) { - (self.a, self.b) +impl From> for CResult_RouteHintHopDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_RouteHintHopDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_RouteHintHopDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } } } -impl Clone for C2Tuple_Z { +impl Clone for CResult_RouteHintHopDecodeErrorZ { fn clone(&self) -> Self { - Self { - a: Clone::clone(&self.a), - b: Clone::clone(&self.b), + if self.result_ok { + Self { result_ok: true, contents: CResult_RouteHintHopDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_RouteHintHopDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } } } } #[no_mangle] -/// Creates a new tuple which has the same data as `orig` +/// Creates a new CResult_RouteHintHopDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C2Tuple_Z_clone(orig: &C2Tuple_Z) -> C2Tuple_Z { Clone::clone(&orig) } -/// Creates a new C2Tuple_Z from the contained elements. -#[no_mangle] -pub extern "C" fn C2Tuple_Z_new(a: crate::c_types::EightU16s, b: crate::c_types::EightU16s) -> C2Tuple_Z { - C2Tuple_Z { a, b, } -} - -#[no_mangle] -/// Frees any resources used by the C2Tuple_Z. -pub extern "C" fn C2Tuple_Z_free(_res: C2Tuple_Z) { } +pub extern "C" fn CResult_RouteHintHopDecodeErrorZ_clone(orig: &CResult_RouteHintHopDecodeErrorZ) -> CResult_RouteHintHopDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple__u168_u168Z { - /// The element at position 0 - pub a: crate::c_types::EightU16s, - /// The element at position 1 - pub b: crate::c_types::EightU16s, +/// A dynamically-allocated array of crate::c_types::PublicKeys of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_PublicKeyZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::PublicKey, + /// The number of elements pointed to by `data`. + pub datalen: usize } -impl From<(crate::c_types::EightU16s, crate::c_types::EightU16s)> for C2Tuple__u168_u168Z { - fn from (tup: (crate::c_types::EightU16s, crate::c_types::EightU16s)) -> Self { - Self { - a: tup.0, - b: tup.1, - } +impl CVec_PublicKeyZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret } -} -impl C2Tuple__u168_u168Z { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::EightU16s, crate::c_types::EightU16s) { - (self.a, self.b) + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::PublicKey] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl Clone for C2Tuple__u168_u168Z { - fn clone(&self) -> Self { - Self { - a: Clone::clone(&self.a), - b: Clone::clone(&self.b), - } +impl From> for CVec_PublicKeyZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } } } #[no_mangle] -/// Creates a new tuple which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C2Tuple__u168_u168Z_clone(orig: &C2Tuple__u168_u168Z) -> C2Tuple__u168_u168Z { Clone::clone(&orig) } -/// Creates a new C2Tuple__u168_u168Z from the contained elements. -#[no_mangle] -pub extern "C" fn C2Tuple__u168_u168Z_new(a: crate::c_types::EightU16s, b: crate::c_types::EightU16s) -> C2Tuple__u168_u168Z { - C2Tuple__u168_u168Z { a, b, } +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_PublicKeyZ_free(_res: CVec_PublicKeyZ) { } +impl Drop for CVec_PublicKeyZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_PublicKeyZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } } - -#[no_mangle] -/// Frees any resources used by the C2Tuple__u168_u168Z. -pub extern "C" fn C2Tuple__u168_u168Z_free(_res: C2Tuple__u168_u168Z) { } #[repr(C)] -#[derive(Clone)] -/// An enum which can either contain a crate::c_types::derived::C2Tuple__u168_u168Z or not -pub enum COption_C2Tuple_EightU16sEightU16sZZ { - /// When we're in this state, this COption_C2Tuple_EightU16sEightU16sZZ contains a crate::c_types::derived::C2Tuple__u168_u168Z - Some(crate::c_types::derived::C2Tuple__u168_u168Z), - /// When we're in this state, this COption_C2Tuple_EightU16sEightU16sZZ contains nothing - None +/// The contents of CResult_FixedPenaltyScorerDecodeErrorZ +pub union CResult_FixedPenaltyScorerDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::routing::scoring::FixedPenaltyScorer, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, } -impl COption_C2Tuple_EightU16sEightU16sZZ { - #[allow(unused)] pub(crate) fn is_some(&self) -> bool { - if let Self::None = self { false } else { true } - } - #[allow(unused)] pub(crate) fn is_none(&self) -> bool { - !self.is_some() - } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::derived::C2Tuple__u168_u168Z { - if let Self::Some(v) = self { v } else { unreachable!() } +#[repr(C)] +/// A CResult_FixedPenaltyScorerDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::routing::scoring::FixedPenaltyScorer on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_FixedPenaltyScorerDecodeErrorZ { + /// The contents of this CResult_FixedPenaltyScorerDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_FixedPenaltyScorerDecodeErrorZPtr, + /// Whether this CResult_FixedPenaltyScorerDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_FixedPenaltyScorerDecodeErrorZ in the success state. +pub extern "C" fn CResult_FixedPenaltyScorerDecodeErrorZ_ok(o: crate::lightning::routing::scoring::FixedPenaltyScorer) -> CResult_FixedPenaltyScorerDecodeErrorZ { + CResult_FixedPenaltyScorerDecodeErrorZ { + contents: CResult_FixedPenaltyScorerDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, } } #[no_mangle] -/// Constructs a new COption_C2Tuple_EightU16sEightU16sZZ containing a crate::c_types::derived::C2Tuple__u168_u168Z -pub extern "C" fn COption_C2Tuple_EightU16sEightU16sZZ_some(o: crate::c_types::derived::C2Tuple__u168_u168Z) -> COption_C2Tuple_EightU16sEightU16sZZ { - COption_C2Tuple_EightU16sEightU16sZZ::Some(o) +/// Creates a new CResult_FixedPenaltyScorerDecodeErrorZ in the error state. +pub extern "C" fn CResult_FixedPenaltyScorerDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_FixedPenaltyScorerDecodeErrorZ { + CResult_FixedPenaltyScorerDecodeErrorZ { + contents: CResult_FixedPenaltyScorerDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } } +/// Checks if the given object is currently in the success state #[no_mangle] -/// Constructs a new COption_C2Tuple_EightU16sEightU16sZZ containing nothing -pub extern "C" fn COption_C2Tuple_EightU16sEightU16sZZ_none() -> COption_C2Tuple_EightU16sEightU16sZZ { - COption_C2Tuple_EightU16sEightU16sZZ::None +pub extern "C" fn CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(o: &CResult_FixedPenaltyScorerDecodeErrorZ) -> bool { + o.result_ok } #[no_mangle] -/// Frees any resources associated with the crate::c_types::derived::C2Tuple__u168_u168Z, if we are in the Some state -pub extern "C" fn COption_C2Tuple_EightU16sEightU16sZZ_free(_res: COption_C2Tuple_EightU16sEightU16sZZ) { } +/// Frees any resources used by the CResult_FixedPenaltyScorerDecodeErrorZ. +pub extern "C" fn CResult_FixedPenaltyScorerDecodeErrorZ_free(_res: CResult_FixedPenaltyScorerDecodeErrorZ) { } +impl Drop for CResult_FixedPenaltyScorerDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_FixedPenaltyScorerDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_FixedPenaltyScorerDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_FixedPenaltyScorerDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_FixedPenaltyScorerDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_FixedPenaltyScorerDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_FixedPenaltyScorerDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} #[no_mangle] -/// Creates a new COption_C2Tuple_EightU16sEightU16sZZ which has the same data as `orig` +/// Creates a new CResult_FixedPenaltyScorerDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_C2Tuple_EightU16sEightU16sZZ_clone(orig: &COption_C2Tuple_EightU16sEightU16sZZ) -> COption_C2Tuple_EightU16sEightU16sZZ { Clone::clone(&orig) } +pub extern "C" fn CResult_FixedPenaltyScorerDecodeErrorZ_clone(orig: &CResult_FixedPenaltyScorerDecodeErrorZ) -> CResult_FixedPenaltyScorerDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] /// A dynamically-allocated array of crate::lightning::routing::gossip::NodeIds of arbitrary size. /// This corresponds to std::vector in C++ @@ -4217,216 +4340,241 @@ impl Clone for CVec_NodeIdZ { } } #[repr(C)] -/// The contents of CResult_ProbabilisticScorerDecodeErrorZ -pub union CResult_ProbabilisticScorerDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::routing::scoring::ProbabilisticScorer, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_u64u64Z { + /// The element at position 0 + pub a: u64, + /// The element at position 1 + pub b: u64, } -#[repr(C)] -/// A CResult_ProbabilisticScorerDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::routing::scoring::ProbabilisticScorer on success and a crate::lightning::ln::msgs::DecodeError on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ProbabilisticScorerDecodeErrorZ { - /// The contents of this CResult_ProbabilisticScorerDecodeErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ProbabilisticScorerDecodeErrorZPtr, - /// Whether this CResult_ProbabilisticScorerDecodeErrorZ represents a success state. - pub result_ok: bool, +impl From<(u64, u64)> for C2Tuple_u64u64Z { + fn from (tup: (u64, u64)) -> Self { + Self { + a: tup.0, + b: tup.1, + } + } } -#[no_mangle] -/// Creates a new CResult_ProbabilisticScorerDecodeErrorZ in the success state. -pub extern "C" fn CResult_ProbabilisticScorerDecodeErrorZ_ok(o: crate::lightning::routing::scoring::ProbabilisticScorer) -> CResult_ProbabilisticScorerDecodeErrorZ { - CResult_ProbabilisticScorerDecodeErrorZ { - contents: CResult_ProbabilisticScorerDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, +impl C2Tuple_u64u64Z { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (u64, u64) { + (self.a, self.b) } } -#[no_mangle] -/// Creates a new CResult_ProbabilisticScorerDecodeErrorZ in the error state. -pub extern "C" fn CResult_ProbabilisticScorerDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ProbabilisticScorerDecodeErrorZ { - CResult_ProbabilisticScorerDecodeErrorZ { - contents: CResult_ProbabilisticScorerDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), - }, - result_ok: false, +impl Clone for C2Tuple_u64u64Z { + fn clone(&self) -> Self { + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), + } } } -/// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ProbabilisticScorerDecodeErrorZ_is_ok(o: &CResult_ProbabilisticScorerDecodeErrorZ) -> bool { - o.result_ok +/// Creates a new tuple which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn C2Tuple_u64u64Z_clone(orig: &C2Tuple_u64u64Z) -> C2Tuple_u64u64Z { Clone::clone(&orig) } +/// Creates a new C2Tuple_u64u64Z from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_u64u64Z_new(a: u64, b: u64) -> C2Tuple_u64u64Z { + C2Tuple_u64u64Z { a, b, } } + #[no_mangle] -/// Frees any resources used by the CResult_ProbabilisticScorerDecodeErrorZ. -pub extern "C" fn CResult_ProbabilisticScorerDecodeErrorZ_free(_res: CResult_ProbabilisticScorerDecodeErrorZ) { } -impl Drop for CResult_ProbabilisticScorerDecodeErrorZ { - fn drop(&mut self) { - if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } - } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } - } - } +/// Frees any resources used by the C2Tuple_u64u64Z. +pub extern "C" fn C2Tuple_u64u64Z_free(_res: C2Tuple_u64u64Z) { } +#[repr(C)] +#[derive(Clone)] +/// An enum which can either contain a crate::c_types::derived::C2Tuple_u64u64Z or not +pub enum COption_C2Tuple_u64u64ZZ { + /// When we're in this state, this COption_C2Tuple_u64u64ZZ contains a crate::c_types::derived::C2Tuple_u64u64Z + Some(crate::c_types::derived::C2Tuple_u64u64Z), + /// When we're in this state, this COption_C2Tuple_u64u64ZZ contains nothing + None } -impl From> for CResult_ProbabilisticScorerDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { - let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ProbabilisticScorerDecodeErrorZPtr { result } - } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ProbabilisticScorerDecodeErrorZPtr { err } - }; - Self { - contents, - result_ok: o.result_ok, - } +impl COption_C2Tuple_u64u64ZZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::derived::C2Tuple_u64u64Z { + if let Self::Some(v) = self { v } else { unreachable!() } } } -#[repr(C)] -/// The contents of CResult_InitFeaturesDecodeErrorZ -pub union CResult_InitFeaturesDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::features::InitFeatures, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, -} -#[repr(C)] -/// A CResult_InitFeaturesDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::features::InitFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_InitFeaturesDecodeErrorZ { - /// The contents of this CResult_InitFeaturesDecodeErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_InitFeaturesDecodeErrorZPtr, - /// Whether this CResult_InitFeaturesDecodeErrorZ represents a success state. - pub result_ok: bool, +#[no_mangle] +/// Constructs a new COption_C2Tuple_u64u64ZZ containing a crate::c_types::derived::C2Tuple_u64u64Z +pub extern "C" fn COption_C2Tuple_u64u64ZZ_some(o: crate::c_types::derived::C2Tuple_u64u64Z) -> COption_C2Tuple_u64u64ZZ { + COption_C2Tuple_u64u64ZZ::Some(o) } #[no_mangle] -/// Creates a new CResult_InitFeaturesDecodeErrorZ in the success state. -pub extern "C" fn CResult_InitFeaturesDecodeErrorZ_ok(o: crate::lightning::ln::features::InitFeatures) -> CResult_InitFeaturesDecodeErrorZ { - CResult_InitFeaturesDecodeErrorZ { - contents: CResult_InitFeaturesDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, - } +/// Constructs a new COption_C2Tuple_u64u64ZZ containing nothing +pub extern "C" fn COption_C2Tuple_u64u64ZZ_none() -> COption_C2Tuple_u64u64ZZ { + COption_C2Tuple_u64u64ZZ::None } #[no_mangle] -/// Creates a new CResult_InitFeaturesDecodeErrorZ in the error state. -pub extern "C" fn CResult_InitFeaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_InitFeaturesDecodeErrorZ { - CResult_InitFeaturesDecodeErrorZ { - contents: CResult_InitFeaturesDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), - }, - result_ok: false, +/// Frees any resources associated with the crate::c_types::derived::C2Tuple_u64u64Z, if we are in the Some state +pub extern "C" fn COption_C2Tuple_u64u64ZZ_free(_res: COption_C2Tuple_u64u64ZZ) { } +#[no_mangle] +/// Creates a new COption_C2Tuple_u64u64ZZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_C2Tuple_u64u64ZZ_clone(orig: &COption_C2Tuple_u64u64ZZ) -> COption_C2Tuple_u64u64ZZ { Clone::clone(&orig) } +#[repr(C)] +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_Z { + /// The element at position 0 + pub a: crate::c_types::EightU16s, + /// The element at position 1 + pub b: crate::c_types::EightU16s, +} +impl From<(crate::c_types::EightU16s, crate::c_types::EightU16s)> for C2Tuple_Z { + fn from (tup: (crate::c_types::EightU16s, crate::c_types::EightU16s)) -> Self { + Self { + a: tup.0, + b: tup.1, + } } } -/// Checks if the given object is currently in the success state -#[no_mangle] -pub extern "C" fn CResult_InitFeaturesDecodeErrorZ_is_ok(o: &CResult_InitFeaturesDecodeErrorZ) -> bool { - o.result_ok +impl C2Tuple_Z { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::EightU16s, crate::c_types::EightU16s) { + (self.a, self.b) + } } -#[no_mangle] -/// Frees any resources used by the CResult_InitFeaturesDecodeErrorZ. -pub extern "C" fn CResult_InitFeaturesDecodeErrorZ_free(_res: CResult_InitFeaturesDecodeErrorZ) { } -impl Drop for CResult_InitFeaturesDecodeErrorZ { - fn drop(&mut self) { - if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } - } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } +impl Clone for C2Tuple_Z { + fn clone(&self) -> Self { + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), } } } -impl From> for CResult_InitFeaturesDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { - let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_InitFeaturesDecodeErrorZPtr { result } - } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_InitFeaturesDecodeErrorZPtr { err } - }; +#[no_mangle] +/// Creates a new tuple which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn C2Tuple_Z_clone(orig: &C2Tuple_Z) -> C2Tuple_Z { Clone::clone(&orig) } +/// Creates a new C2Tuple_Z from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_Z_new(a: crate::c_types::EightU16s, b: crate::c_types::EightU16s) -> C2Tuple_Z { + C2Tuple_Z { a, b, } +} + +#[no_mangle] +/// Frees any resources used by the C2Tuple_Z. +pub extern "C" fn C2Tuple_Z_free(_res: C2Tuple_Z) { } +#[repr(C)] +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple__u168_u168Z { + /// The element at position 0 + pub a: crate::c_types::EightU16s, + /// The element at position 1 + pub b: crate::c_types::EightU16s, +} +impl From<(crate::c_types::EightU16s, crate::c_types::EightU16s)> for C2Tuple__u168_u168Z { + fn from (tup: (crate::c_types::EightU16s, crate::c_types::EightU16s)) -> Self { Self { - contents, - result_ok: o.result_ok, + a: tup.0, + b: tup.1, } } } -impl Clone for CResult_InitFeaturesDecodeErrorZ { +impl C2Tuple__u168_u168Z { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::EightU16s, crate::c_types::EightU16s) { + (self.a, self.b) + } +} +impl Clone for C2Tuple__u168_u168Z { fn clone(&self) -> Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_InitFeaturesDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_InitFeaturesDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), } } } #[no_mangle] -/// Creates a new CResult_InitFeaturesDecodeErrorZ which has the same data as `orig` +/// Creates a new tuple which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_InitFeaturesDecodeErrorZ_clone(orig: &CResult_InitFeaturesDecodeErrorZ) -> CResult_InitFeaturesDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn C2Tuple__u168_u168Z_clone(orig: &C2Tuple__u168_u168Z) -> C2Tuple__u168_u168Z { Clone::clone(&orig) } +/// Creates a new C2Tuple__u168_u168Z from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple__u168_u168Z_new(a: crate::c_types::EightU16s, b: crate::c_types::EightU16s) -> C2Tuple__u168_u168Z { + C2Tuple__u168_u168Z { a, b, } +} + +#[no_mangle] +/// Frees any resources used by the C2Tuple__u168_u168Z. +pub extern "C" fn C2Tuple__u168_u168Z_free(_res: C2Tuple__u168_u168Z) { } #[repr(C)] -/// The contents of CResult_ChannelFeaturesDecodeErrorZ -pub union CResult_ChannelFeaturesDecodeErrorZPtr { +#[derive(Clone)] +/// An enum which can either contain a crate::c_types::derived::C2Tuple__u168_u168Z or not +pub enum COption_C2Tuple_EightU16sEightU16sZZ { + /// When we're in this state, this COption_C2Tuple_EightU16sEightU16sZZ contains a crate::c_types::derived::C2Tuple__u168_u168Z + Some(crate::c_types::derived::C2Tuple__u168_u168Z), + /// When we're in this state, this COption_C2Tuple_EightU16sEightU16sZZ contains nothing + None +} +impl COption_C2Tuple_EightU16sEightU16sZZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::derived::C2Tuple__u168_u168Z { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_C2Tuple_EightU16sEightU16sZZ containing a crate::c_types::derived::C2Tuple__u168_u168Z +pub extern "C" fn COption_C2Tuple_EightU16sEightU16sZZ_some(o: crate::c_types::derived::C2Tuple__u168_u168Z) -> COption_C2Tuple_EightU16sEightU16sZZ { + COption_C2Tuple_EightU16sEightU16sZZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_C2Tuple_EightU16sEightU16sZZ containing nothing +pub extern "C" fn COption_C2Tuple_EightU16sEightU16sZZ_none() -> COption_C2Tuple_EightU16sEightU16sZZ { + COption_C2Tuple_EightU16sEightU16sZZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::c_types::derived::C2Tuple__u168_u168Z, if we are in the Some state +pub extern "C" fn COption_C2Tuple_EightU16sEightU16sZZ_free(_res: COption_C2Tuple_EightU16sEightU16sZZ) { } +#[no_mangle] +/// Creates a new COption_C2Tuple_EightU16sEightU16sZZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_C2Tuple_EightU16sEightU16sZZ_clone(orig: &COption_C2Tuple_EightU16sEightU16sZZ) -> COption_C2Tuple_EightU16sEightU16sZZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_ProbabilisticScorerDecodeErrorZ +pub union CResult_ProbabilisticScorerDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::features::ChannelFeatures, + pub result: *mut crate::lightning::routing::scoring::ProbabilisticScorer, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_ChannelFeaturesDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::features::ChannelFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_ProbabilisticScorerDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::routing::scoring::ProbabilisticScorer on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ChannelFeaturesDecodeErrorZ { - /// The contents of this CResult_ChannelFeaturesDecodeErrorZ, accessible via either +pub struct CResult_ProbabilisticScorerDecodeErrorZ { + /// The contents of this CResult_ProbabilisticScorerDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ChannelFeaturesDecodeErrorZPtr, - /// Whether this CResult_ChannelFeaturesDecodeErrorZ represents a success state. + pub contents: CResult_ProbabilisticScorerDecodeErrorZPtr, + /// Whether this CResult_ProbabilisticScorerDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ChannelFeaturesDecodeErrorZ in the success state. -pub extern "C" fn CResult_ChannelFeaturesDecodeErrorZ_ok(o: crate::lightning::ln::features::ChannelFeatures) -> CResult_ChannelFeaturesDecodeErrorZ { - CResult_ChannelFeaturesDecodeErrorZ { - contents: CResult_ChannelFeaturesDecodeErrorZPtr { +/// Creates a new CResult_ProbabilisticScorerDecodeErrorZ in the success state. +pub extern "C" fn CResult_ProbabilisticScorerDecodeErrorZ_ok(o: crate::lightning::routing::scoring::ProbabilisticScorer) -> CResult_ProbabilisticScorerDecodeErrorZ { + CResult_ProbabilisticScorerDecodeErrorZ { + contents: CResult_ProbabilisticScorerDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ChannelFeaturesDecodeErrorZ in the error state. -pub extern "C" fn CResult_ChannelFeaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelFeaturesDecodeErrorZ { - CResult_ChannelFeaturesDecodeErrorZ { - contents: CResult_ChannelFeaturesDecodeErrorZPtr { +/// Creates a new CResult_ProbabilisticScorerDecodeErrorZ in the error state. +pub extern "C" fn CResult_ProbabilisticScorerDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ProbabilisticScorerDecodeErrorZ { + CResult_ProbabilisticScorerDecodeErrorZ { + contents: CResult_ProbabilisticScorerDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -4434,13 +4582,13 @@ pub extern "C" fn CResult_ChannelFeaturesDecodeErrorZ_err(e: crate::lightning::l } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ChannelFeaturesDecodeErrorZ_is_ok(o: &CResult_ChannelFeaturesDecodeErrorZ) -> bool { +pub extern "C" fn CResult_ProbabilisticScorerDecodeErrorZ_is_ok(o: &CResult_ProbabilisticScorerDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_ChannelFeaturesDecodeErrorZ. -pub extern "C" fn CResult_ChannelFeaturesDecodeErrorZ_free(_res: CResult_ChannelFeaturesDecodeErrorZ) { } -impl Drop for CResult_ChannelFeaturesDecodeErrorZ { +/// Frees any resources used by the CResult_ProbabilisticScorerDecodeErrorZ. +pub extern "C" fn CResult_ProbabilisticScorerDecodeErrorZ_free(_res: CResult_ProbabilisticScorerDecodeErrorZ) { } +impl Drop for CResult_ProbabilisticScorerDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -4453,16 +4601,16 @@ impl Drop for CResult_ChannelFeaturesDecodeErrorZ { } } } -impl From> for CResult_ChannelFeaturesDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ProbabilisticScorerDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ChannelFeaturesDecodeErrorZPtr { result } + CResult_ProbabilisticScorerDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ChannelFeaturesDecodeErrorZPtr { err } + CResult_ProbabilisticScorerDecodeErrorZPtr { err } }; Self { contents, @@ -4470,347 +4618,393 @@ impl From for C2Tuple_usizeTransactionZ { + fn from (tup: (usize, crate::c_types::Transaction)) -> Self { + Self { + a: tup.0, + b: tup.1, + } + } +} +impl C2Tuple_usizeTransactionZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (usize, crate::c_types::Transaction) { + (self.a, self.b) + } +} +impl Clone for C2Tuple_usizeTransactionZ { fn clone(&self) -> Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_ChannelFeaturesDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_ChannelFeaturesDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), } } } #[no_mangle] -/// Creates a new CResult_ChannelFeaturesDecodeErrorZ which has the same data as `orig` +/// Creates a new tuple which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ChannelFeaturesDecodeErrorZ_clone(orig: &CResult_ChannelFeaturesDecodeErrorZ) -> CResult_ChannelFeaturesDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn C2Tuple_usizeTransactionZ_clone(orig: &C2Tuple_usizeTransactionZ) -> C2Tuple_usizeTransactionZ { Clone::clone(&orig) } +/// Creates a new C2Tuple_usizeTransactionZ from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_usizeTransactionZ_new(a: usize, b: crate::c_types::Transaction) -> C2Tuple_usizeTransactionZ { + C2Tuple_usizeTransactionZ { a, b, } +} + +#[no_mangle] +/// Frees any resources used by the C2Tuple_usizeTransactionZ. +pub extern "C" fn C2Tuple_usizeTransactionZ_free(_res: C2Tuple_usizeTransactionZ) { } #[repr(C)] -/// The contents of CResult_NodeFeaturesDecodeErrorZ -pub union CResult_NodeFeaturesDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::features::NodeFeatures, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, -} -#[repr(C)] -/// A CResult_NodeFeaturesDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::features::NodeFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_NodeFeaturesDecodeErrorZ { - /// The contents of this CResult_NodeFeaturesDecodeErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_NodeFeaturesDecodeErrorZPtr, - /// Whether this CResult_NodeFeaturesDecodeErrorZ represents a success state. - pub result_ok: bool, +/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_usizeTransactionZs of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_C2Tuple_usizeTransactionZZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::derived::C2Tuple_usizeTransactionZ, + /// The number of elements pointed to by `data`. + pub datalen: usize } -#[no_mangle] -/// Creates a new CResult_NodeFeaturesDecodeErrorZ in the success state. -pub extern "C" fn CResult_NodeFeaturesDecodeErrorZ_ok(o: crate::lightning::ln::features::NodeFeatures) -> CResult_NodeFeaturesDecodeErrorZ { - CResult_NodeFeaturesDecodeErrorZ { - contents: CResult_NodeFeaturesDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, +impl CVec_C2Tuple_usizeTransactionZZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret } -} -#[no_mangle] -/// Creates a new CResult_NodeFeaturesDecodeErrorZ in the error state. -pub extern "C" fn CResult_NodeFeaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_NodeFeaturesDecodeErrorZ { - CResult_NodeFeaturesDecodeErrorZ { - contents: CResult_NodeFeaturesDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), - }, - result_ok: false, + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_usizeTransactionZ] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -/// Checks if the given object is currently in the success state -#[no_mangle] -pub extern "C" fn CResult_NodeFeaturesDecodeErrorZ_is_ok(o: &CResult_NodeFeaturesDecodeErrorZ) -> bool { - o.result_ok +impl From> for CVec_C2Tuple_usizeTransactionZZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } } #[no_mangle] -/// Frees any resources used by the CResult_NodeFeaturesDecodeErrorZ. -pub extern "C" fn CResult_NodeFeaturesDecodeErrorZ_free(_res: CResult_NodeFeaturesDecodeErrorZ) { } -impl Drop for CResult_NodeFeaturesDecodeErrorZ { +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_C2Tuple_usizeTransactionZZ_free(_res: CVec_C2Tuple_usizeTransactionZZ) { } +impl Drop for CVec_C2Tuple_usizeTransactionZZ { fn drop(&mut self) { - if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } - } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } - } - } -} -impl From> for CResult_NodeFeaturesDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { - let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_NodeFeaturesDecodeErrorZPtr { result } - } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_NodeFeaturesDecodeErrorZPtr { err } - }; - Self { - contents, - result_ok: o.result_ok, - } + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl Clone for CResult_NodeFeaturesDecodeErrorZ { +impl Clone for CVec_C2Tuple_usizeTransactionZZ { fn clone(&self) -> Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_NodeFeaturesDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_NodeFeaturesDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } - } + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) } } -#[no_mangle] -/// Creates a new CResult_NodeFeaturesDecodeErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_NodeFeaturesDecodeErrorZ_clone(orig: &CResult_NodeFeaturesDecodeErrorZ) -> CResult_NodeFeaturesDecodeErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// The contents of CResult_InvoiceFeaturesDecodeErrorZ -pub union CResult_InvoiceFeaturesDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::features::InvoiceFeatures, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, -} #[repr(C)] -/// A CResult_InvoiceFeaturesDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::features::InvoiceFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_InvoiceFeaturesDecodeErrorZ { - /// The contents of this CResult_InvoiceFeaturesDecodeErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_InvoiceFeaturesDecodeErrorZPtr, - /// Whether this CResult_InvoiceFeaturesDecodeErrorZ represents a success state. - pub result_ok: bool, +#[derive(Clone)] +/// An enum which can either contain a crate::c_types::ThirtyTwoBytes or not +pub enum COption_BlockHashZ { + /// When we're in this state, this COption_BlockHashZ contains a crate::c_types::ThirtyTwoBytes + Some(crate::c_types::ThirtyTwoBytes), + /// When we're in this state, this COption_BlockHashZ contains nothing + None } -#[no_mangle] -/// Creates a new CResult_InvoiceFeaturesDecodeErrorZ in the success state. -pub extern "C" fn CResult_InvoiceFeaturesDecodeErrorZ_ok(o: crate::lightning::ln::features::InvoiceFeatures) -> CResult_InvoiceFeaturesDecodeErrorZ { - CResult_InvoiceFeaturesDecodeErrorZ { - contents: CResult_InvoiceFeaturesDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, +impl COption_BlockHashZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::ThirtyTwoBytes { + if let Self::Some(v) = self { v } else { unreachable!() } } } #[no_mangle] -/// Creates a new CResult_InvoiceFeaturesDecodeErrorZ in the error state. -pub extern "C" fn CResult_InvoiceFeaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_InvoiceFeaturesDecodeErrorZ { - CResult_InvoiceFeaturesDecodeErrorZ { - contents: CResult_InvoiceFeaturesDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), - }, - result_ok: false, - } +/// Constructs a new COption_BlockHashZ containing a crate::c_types::ThirtyTwoBytes +pub extern "C" fn COption_BlockHashZ_some(o: crate::c_types::ThirtyTwoBytes) -> COption_BlockHashZ { + COption_BlockHashZ::Some(o) } -/// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_InvoiceFeaturesDecodeErrorZ_is_ok(o: &CResult_InvoiceFeaturesDecodeErrorZ) -> bool { - o.result_ok +/// Constructs a new COption_BlockHashZ containing nothing +pub extern "C" fn COption_BlockHashZ_none() -> COption_BlockHashZ { + COption_BlockHashZ::None } #[no_mangle] -/// Frees any resources used by the CResult_InvoiceFeaturesDecodeErrorZ. -pub extern "C" fn CResult_InvoiceFeaturesDecodeErrorZ_free(_res: CResult_InvoiceFeaturesDecodeErrorZ) { } -impl Drop for CResult_InvoiceFeaturesDecodeErrorZ { - fn drop(&mut self) { - if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } - } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } - } - } +/// Frees any resources associated with the crate::c_types::ThirtyTwoBytes, if we are in the Some state +pub extern "C" fn COption_BlockHashZ_free(_res: COption_BlockHashZ) { } +#[no_mangle] +/// Creates a new COption_BlockHashZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_BlockHashZ_clone(orig: &COption_BlockHashZ) -> COption_BlockHashZ { Clone::clone(&orig) } +#[repr(C)] +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_TxidCOption_BlockHashZZ { + /// The element at position 0 + pub a: crate::c_types::ThirtyTwoBytes, + /// The element at position 1 + pub b: crate::c_types::derived::COption_BlockHashZ, } -impl From> for CResult_InvoiceFeaturesDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { - let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_InvoiceFeaturesDecodeErrorZPtr { result } - } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_InvoiceFeaturesDecodeErrorZPtr { err } - }; +impl From<(crate::c_types::ThirtyTwoBytes, crate::c_types::derived::COption_BlockHashZ)> for C2Tuple_TxidCOption_BlockHashZZ { + fn from (tup: (crate::c_types::ThirtyTwoBytes, crate::c_types::derived::COption_BlockHashZ)) -> Self { Self { - contents, - result_ok: o.result_ok, + a: tup.0, + b: tup.1, } } } -impl Clone for CResult_InvoiceFeaturesDecodeErrorZ { +impl C2Tuple_TxidCOption_BlockHashZZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoBytes, crate::c_types::derived::COption_BlockHashZ) { + (self.a, self.b) + } +} +impl Clone for C2Tuple_TxidCOption_BlockHashZZ { fn clone(&self) -> Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_InvoiceFeaturesDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_InvoiceFeaturesDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), } } } #[no_mangle] -/// Creates a new CResult_InvoiceFeaturesDecodeErrorZ which has the same data as `orig` +/// Creates a new tuple which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_InvoiceFeaturesDecodeErrorZ_clone(orig: &CResult_InvoiceFeaturesDecodeErrorZ) -> CResult_InvoiceFeaturesDecodeErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// The contents of CResult_BlindedHopFeaturesDecodeErrorZ -pub union CResult_BlindedHopFeaturesDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::features::BlindedHopFeatures, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, +pub extern "C" fn C2Tuple_TxidCOption_BlockHashZZ_clone(orig: &C2Tuple_TxidCOption_BlockHashZZ) -> C2Tuple_TxidCOption_BlockHashZZ { Clone::clone(&orig) } +/// Creates a new C2Tuple_TxidCOption_BlockHashZZ from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_TxidCOption_BlockHashZZ_new(a: crate::c_types::ThirtyTwoBytes, b: crate::c_types::derived::COption_BlockHashZ) -> C2Tuple_TxidCOption_BlockHashZZ { + C2Tuple_TxidCOption_BlockHashZZ { a, b, } } + +#[no_mangle] +/// Frees any resources used by the C2Tuple_TxidCOption_BlockHashZZ. +pub extern "C" fn C2Tuple_TxidCOption_BlockHashZZ_free(_res: C2Tuple_TxidCOption_BlockHashZZ) { } #[repr(C)] -/// A CResult_BlindedHopFeaturesDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::features::BlindedHopFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_BlindedHopFeaturesDecodeErrorZ { - /// The contents of this CResult_BlindedHopFeaturesDecodeErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_BlindedHopFeaturesDecodeErrorZPtr, - /// Whether this CResult_BlindedHopFeaturesDecodeErrorZ represents a success state. - pub result_ok: bool, +/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_TxidCOption_BlockHashZZs of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_C2Tuple_TxidCOption_BlockHashZZZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::derived::C2Tuple_TxidCOption_BlockHashZZ, + /// The number of elements pointed to by `data`. + pub datalen: usize } -#[no_mangle] -/// Creates a new CResult_BlindedHopFeaturesDecodeErrorZ in the success state. -pub extern "C" fn CResult_BlindedHopFeaturesDecodeErrorZ_ok(o: crate::lightning::ln::features::BlindedHopFeatures) -> CResult_BlindedHopFeaturesDecodeErrorZ { - CResult_BlindedHopFeaturesDecodeErrorZ { - contents: CResult_BlindedHopFeaturesDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, +impl CVec_C2Tuple_TxidCOption_BlockHashZZZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret } -} -#[no_mangle] -/// Creates a new CResult_BlindedHopFeaturesDecodeErrorZ in the error state. -pub extern "C" fn CResult_BlindedHopFeaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_BlindedHopFeaturesDecodeErrorZ { - CResult_BlindedHopFeaturesDecodeErrorZ { - contents: CResult_BlindedHopFeaturesDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), - }, - result_ok: false, + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_TxidCOption_BlockHashZZ] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -/// Checks if the given object is currently in the success state -#[no_mangle] -pub extern "C" fn CResult_BlindedHopFeaturesDecodeErrorZ_is_ok(o: &CResult_BlindedHopFeaturesDecodeErrorZ) -> bool { - o.result_ok +impl From> for CVec_C2Tuple_TxidCOption_BlockHashZZZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } } #[no_mangle] -/// Frees any resources used by the CResult_BlindedHopFeaturesDecodeErrorZ. -pub extern "C" fn CResult_BlindedHopFeaturesDecodeErrorZ_free(_res: CResult_BlindedHopFeaturesDecodeErrorZ) { } -impl Drop for CResult_BlindedHopFeaturesDecodeErrorZ { +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_C2Tuple_TxidCOption_BlockHashZZZ_free(_res: CVec_C2Tuple_TxidCOption_BlockHashZZZ) { } +impl Drop for CVec_C2Tuple_TxidCOption_BlockHashZZZ { fn drop(&mut self) { - if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } - } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } - } + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl From> for CResult_BlindedHopFeaturesDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { - let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_BlindedHopFeaturesDecodeErrorZPtr { result } - } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_BlindedHopFeaturesDecodeErrorZPtr { err } - }; +impl Clone for CVec_C2Tuple_TxidCOption_BlockHashZZZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// A dynamically-allocated array of crate::lightning::chain::channelmonitor::MonitorEvents of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_MonitorEventZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::chain::channelmonitor::MonitorEvent, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_MonitorEventZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::chain::channelmonitor::MonitorEvent] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_MonitorEventZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_MonitorEventZ_free(_res: CVec_MonitorEventZ) { } +impl Drop for CVec_MonitorEventZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_MonitorEventZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// A tuple of 3 elements. See the individual fields for the types contained. +pub struct C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ { + /// The element at position 0 + pub a: crate::lightning::chain::transaction::OutPoint, + /// The element at position 1 + pub b: crate::c_types::derived::CVec_MonitorEventZ, + /// The element at position 2 + pub c: crate::c_types::PublicKey, +} +impl From<(crate::lightning::chain::transaction::OutPoint, crate::c_types::derived::CVec_MonitorEventZ, crate::c_types::PublicKey)> for C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ { + fn from (tup: (crate::lightning::chain::transaction::OutPoint, crate::c_types::derived::CVec_MonitorEventZ, crate::c_types::PublicKey)) -> Self { Self { - contents, - result_ok: o.result_ok, + a: tup.0, + b: tup.1, + c: tup.2, } } } -impl Clone for CResult_BlindedHopFeaturesDecodeErrorZ { +impl C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::lightning::chain::transaction::OutPoint, crate::c_types::derived::CVec_MonitorEventZ, crate::c_types::PublicKey) { + (self.a, self.b, self.c) + } +} +impl Clone for C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ { fn clone(&self) -> Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_BlindedHopFeaturesDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_BlindedHopFeaturesDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), + c: Clone::clone(&self.c), } } } #[no_mangle] -/// Creates a new CResult_BlindedHopFeaturesDecodeErrorZ which has the same data as `orig` +/// Creates a new tuple which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_BlindedHopFeaturesDecodeErrorZ_clone(orig: &CResult_BlindedHopFeaturesDecodeErrorZ) -> CResult_BlindedHopFeaturesDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(orig: &C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ) -> C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ { Clone::clone(&orig) } +/// Creates a new C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ from the contained elements. +#[no_mangle] +pub extern "C" fn C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_new(a: crate::lightning::chain::transaction::OutPoint, b: crate::c_types::derived::CVec_MonitorEventZ, c: crate::c_types::PublicKey) -> C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ { + C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ { a, b, c, } +} + +#[no_mangle] +/// Frees any resources used by the C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ. +pub extern "C" fn C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_free(_res: C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ) { } #[repr(C)] -/// The contents of CResult_ChannelTypeFeaturesDecodeErrorZ -pub union CResult_ChannelTypeFeaturesDecodeErrorZPtr { +/// A dynamically-allocated array of crate::c_types::derived::C3Tuple_OutPointCVec_MonitorEventZPublicKeyZs of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::derived::C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ_free(_res: CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ) { } +impl Drop for CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// The contents of CResult_InitFeaturesDecodeErrorZ +pub union CResult_InitFeaturesDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::features::ChannelTypeFeatures, + pub result: *mut crate::lightning::ln::features::InitFeatures, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_ChannelTypeFeaturesDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::features::ChannelTypeFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_InitFeaturesDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::features::InitFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ChannelTypeFeaturesDecodeErrorZ { - /// The contents of this CResult_ChannelTypeFeaturesDecodeErrorZ, accessible via either +pub struct CResult_InitFeaturesDecodeErrorZ { + /// The contents of this CResult_InitFeaturesDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ChannelTypeFeaturesDecodeErrorZPtr, - /// Whether this CResult_ChannelTypeFeaturesDecodeErrorZ represents a success state. + pub contents: CResult_InitFeaturesDecodeErrorZPtr, + /// Whether this CResult_InitFeaturesDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ChannelTypeFeaturesDecodeErrorZ in the success state. -pub extern "C" fn CResult_ChannelTypeFeaturesDecodeErrorZ_ok(o: crate::lightning::ln::features::ChannelTypeFeatures) -> CResult_ChannelTypeFeaturesDecodeErrorZ { - CResult_ChannelTypeFeaturesDecodeErrorZ { - contents: CResult_ChannelTypeFeaturesDecodeErrorZPtr { +/// Creates a new CResult_InitFeaturesDecodeErrorZ in the success state. +pub extern "C" fn CResult_InitFeaturesDecodeErrorZ_ok(o: crate::lightning::ln::features::InitFeatures) -> CResult_InitFeaturesDecodeErrorZ { + CResult_InitFeaturesDecodeErrorZ { + contents: CResult_InitFeaturesDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ChannelTypeFeaturesDecodeErrorZ in the error state. -pub extern "C" fn CResult_ChannelTypeFeaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelTypeFeaturesDecodeErrorZ { - CResult_ChannelTypeFeaturesDecodeErrorZ { - contents: CResult_ChannelTypeFeaturesDecodeErrorZPtr { +/// Creates a new CResult_InitFeaturesDecodeErrorZ in the error state. +pub extern "C" fn CResult_InitFeaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_InitFeaturesDecodeErrorZ { + CResult_InitFeaturesDecodeErrorZ { + contents: CResult_InitFeaturesDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -4818,13 +5012,13 @@ pub extern "C" fn CResult_ChannelTypeFeaturesDecodeErrorZ_err(e: crate::lightnin } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(o: &CResult_ChannelTypeFeaturesDecodeErrorZ) -> bool { +pub extern "C" fn CResult_InitFeaturesDecodeErrorZ_is_ok(o: &CResult_InitFeaturesDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_ChannelTypeFeaturesDecodeErrorZ. -pub extern "C" fn CResult_ChannelTypeFeaturesDecodeErrorZ_free(_res: CResult_ChannelTypeFeaturesDecodeErrorZ) { } -impl Drop for CResult_ChannelTypeFeaturesDecodeErrorZ { +/// Frees any resources used by the CResult_InitFeaturesDecodeErrorZ. +pub extern "C" fn CResult_InitFeaturesDecodeErrorZ_free(_res: CResult_InitFeaturesDecodeErrorZ) { } +impl Drop for CResult_InitFeaturesDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -4837,16 +5031,16 @@ impl Drop for CResult_ChannelTypeFeaturesDecodeErrorZ { } } } -impl From> for CResult_ChannelTypeFeaturesDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_InitFeaturesDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ChannelTypeFeaturesDecodeErrorZPtr { result } + CResult_InitFeaturesDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ChannelTypeFeaturesDecodeErrorZPtr { err } + CResult_InitFeaturesDecodeErrorZPtr { err } }; Self { contents, @@ -4854,73 +5048,73 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ChannelTypeFeaturesDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_InitFeaturesDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_ChannelTypeFeaturesDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_InitFeaturesDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_ChannelTypeFeaturesDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_InitFeaturesDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ChannelTypeFeaturesDecodeErrorZ_clone(orig: &CResult_ChannelTypeFeaturesDecodeErrorZ) -> CResult_ChannelTypeFeaturesDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_InitFeaturesDecodeErrorZ_clone(orig: &CResult_InitFeaturesDecodeErrorZ) -> CResult_InitFeaturesDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_PaymentPurposeDecodeErrorZ -pub union CResult_PaymentPurposeDecodeErrorZPtr { +/// The contents of CResult_ChannelFeaturesDecodeErrorZ +pub union CResult_ChannelFeaturesDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::events::PaymentPurpose, + pub result: *mut crate::lightning::ln::features::ChannelFeatures, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_PaymentPurposeDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::events::PaymentPurpose on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_ChannelFeaturesDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::features::ChannelFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_PaymentPurposeDecodeErrorZ { - /// The contents of this CResult_PaymentPurposeDecodeErrorZ, accessible via either +pub struct CResult_ChannelFeaturesDecodeErrorZ { + /// The contents of this CResult_ChannelFeaturesDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_PaymentPurposeDecodeErrorZPtr, - /// Whether this CResult_PaymentPurposeDecodeErrorZ represents a success state. + pub contents: CResult_ChannelFeaturesDecodeErrorZPtr, + /// Whether this CResult_ChannelFeaturesDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_PaymentPurposeDecodeErrorZ in the success state. -pub extern "C" fn CResult_PaymentPurposeDecodeErrorZ_ok(o: crate::lightning::events::PaymentPurpose) -> CResult_PaymentPurposeDecodeErrorZ { - CResult_PaymentPurposeDecodeErrorZ { - contents: CResult_PaymentPurposeDecodeErrorZPtr { +/// Creates a new CResult_ChannelFeaturesDecodeErrorZ in the success state. +pub extern "C" fn CResult_ChannelFeaturesDecodeErrorZ_ok(o: crate::lightning::ln::features::ChannelFeatures) -> CResult_ChannelFeaturesDecodeErrorZ { + CResult_ChannelFeaturesDecodeErrorZ { + contents: CResult_ChannelFeaturesDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_PaymentPurposeDecodeErrorZ in the error state. -pub extern "C" fn CResult_PaymentPurposeDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_PaymentPurposeDecodeErrorZ { - CResult_PaymentPurposeDecodeErrorZ { - contents: CResult_PaymentPurposeDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), - }, - result_ok: false, +/// Creates a new CResult_ChannelFeaturesDecodeErrorZ in the error state. +pub extern "C" fn CResult_ChannelFeaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelFeaturesDecodeErrorZ { + CResult_ChannelFeaturesDecodeErrorZ { + contents: CResult_ChannelFeaturesDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_PaymentPurposeDecodeErrorZ_is_ok(o: &CResult_PaymentPurposeDecodeErrorZ) -> bool { +pub extern "C" fn CResult_ChannelFeaturesDecodeErrorZ_is_ok(o: &CResult_ChannelFeaturesDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_PaymentPurposeDecodeErrorZ. -pub extern "C" fn CResult_PaymentPurposeDecodeErrorZ_free(_res: CResult_PaymentPurposeDecodeErrorZ) { } -impl Drop for CResult_PaymentPurposeDecodeErrorZ { +/// Frees any resources used by the CResult_ChannelFeaturesDecodeErrorZ. +pub extern "C" fn CResult_ChannelFeaturesDecodeErrorZ_free(_res: CResult_ChannelFeaturesDecodeErrorZ) { } +impl Drop for CResult_ChannelFeaturesDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -4933,16 +5127,16 @@ impl Drop for CResult_PaymentPurposeDecodeErrorZ { } } } -impl From> for CResult_PaymentPurposeDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ChannelFeaturesDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_PaymentPurposeDecodeErrorZPtr { result } + CResult_ChannelFeaturesDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_PaymentPurposeDecodeErrorZPtr { err } + CResult_ChannelFeaturesDecodeErrorZPtr { err } }; Self { contents, @@ -4950,133 +5144,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_PaymentPurposeDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_ChannelFeaturesDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_PaymentPurposeDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_ChannelFeaturesDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_PaymentPurposeDecodeErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_PaymentPurposeDecodeErrorZ_clone(orig: &CResult_PaymentPurposeDecodeErrorZ) -> CResult_PaymentPurposeDecodeErrorZ { Clone::clone(&orig) } -#[repr(C)] -#[derive(Clone)] -/// An enum which can either contain a crate::lightning::routing::gossip::NetworkUpdate or not -pub enum COption_NetworkUpdateZ { - /// When we're in this state, this COption_NetworkUpdateZ contains a crate::lightning::routing::gossip::NetworkUpdate - Some(crate::lightning::routing::gossip::NetworkUpdate), - /// When we're in this state, this COption_NetworkUpdateZ contains nothing - None -} -impl COption_NetworkUpdateZ { - #[allow(unused)] pub(crate) fn is_some(&self) -> bool { - if let Self::None = self { false } else { true } - } - #[allow(unused)] pub(crate) fn is_none(&self) -> bool { - !self.is_some() - } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::routing::gossip::NetworkUpdate { - if let Self::Some(v) = self { v } else { unreachable!() } - } -} -#[no_mangle] -/// Constructs a new COption_NetworkUpdateZ containing a crate::lightning::routing::gossip::NetworkUpdate -pub extern "C" fn COption_NetworkUpdateZ_some(o: crate::lightning::routing::gossip::NetworkUpdate) -> COption_NetworkUpdateZ { - COption_NetworkUpdateZ::Some(o) -} -#[no_mangle] -/// Constructs a new COption_NetworkUpdateZ containing nothing -pub extern "C" fn COption_NetworkUpdateZ_none() -> COption_NetworkUpdateZ { - COption_NetworkUpdateZ::None -} -#[no_mangle] -/// Frees any resources associated with the crate::lightning::routing::gossip::NetworkUpdate, if we are in the Some state -pub extern "C" fn COption_NetworkUpdateZ_free(_res: COption_NetworkUpdateZ) { } -#[no_mangle] -/// Creates a new COption_NetworkUpdateZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_NetworkUpdateZ_clone(orig: &COption_NetworkUpdateZ) -> COption_NetworkUpdateZ { Clone::clone(&orig) } -#[repr(C)] -#[derive(Clone)] -/// An enum which can either contain a crate::lightning::events::PathFailure or not -pub enum COption_PathFailureZ { - /// When we're in this state, this COption_PathFailureZ contains a crate::lightning::events::PathFailure - Some(crate::lightning::events::PathFailure), - /// When we're in this state, this COption_PathFailureZ contains nothing - None -} -impl COption_PathFailureZ { - #[allow(unused)] pub(crate) fn is_some(&self) -> bool { - if let Self::None = self { false } else { true } - } - #[allow(unused)] pub(crate) fn is_none(&self) -> bool { - !self.is_some() - } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::events::PathFailure { - if let Self::Some(v) = self { v } else { unreachable!() } - } -} -#[no_mangle] -/// Constructs a new COption_PathFailureZ containing a crate::lightning::events::PathFailure -pub extern "C" fn COption_PathFailureZ_some(o: crate::lightning::events::PathFailure) -> COption_PathFailureZ { - COption_PathFailureZ::Some(o) -} -#[no_mangle] -/// Constructs a new COption_PathFailureZ containing nothing -pub extern "C" fn COption_PathFailureZ_none() -> COption_PathFailureZ { - COption_PathFailureZ::None -} -#[no_mangle] -/// Frees any resources associated with the crate::lightning::events::PathFailure, if we are in the Some state -pub extern "C" fn COption_PathFailureZ_free(_res: COption_PathFailureZ) { } -#[no_mangle] -/// Creates a new COption_PathFailureZ which has the same data as `orig` +/// Creates a new CResult_ChannelFeaturesDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_PathFailureZ_clone(orig: &COption_PathFailureZ) -> COption_PathFailureZ { Clone::clone(&orig) } +pub extern "C" fn CResult_ChannelFeaturesDecodeErrorZ_clone(orig: &CResult_ChannelFeaturesDecodeErrorZ) -> CResult_ChannelFeaturesDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_COption_PathFailureZDecodeErrorZ -pub union CResult_COption_PathFailureZDecodeErrorZPtr { +/// The contents of CResult_NodeFeaturesDecodeErrorZ +pub union CResult_NodeFeaturesDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::COption_PathFailureZ, + pub result: *mut crate::lightning::ln::features::NodeFeatures, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_COption_PathFailureZDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::COption_PathFailureZ on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_NodeFeaturesDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::features::NodeFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_COption_PathFailureZDecodeErrorZ { - /// The contents of this CResult_COption_PathFailureZDecodeErrorZ, accessible via either +pub struct CResult_NodeFeaturesDecodeErrorZ { + /// The contents of this CResult_NodeFeaturesDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_COption_PathFailureZDecodeErrorZPtr, - /// Whether this CResult_COption_PathFailureZDecodeErrorZ represents a success state. + pub contents: CResult_NodeFeaturesDecodeErrorZPtr, + /// Whether this CResult_NodeFeaturesDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_COption_PathFailureZDecodeErrorZ in the success state. -pub extern "C" fn CResult_COption_PathFailureZDecodeErrorZ_ok(o: crate::c_types::derived::COption_PathFailureZ) -> CResult_COption_PathFailureZDecodeErrorZ { - CResult_COption_PathFailureZDecodeErrorZ { - contents: CResult_COption_PathFailureZDecodeErrorZPtr { +/// Creates a new CResult_NodeFeaturesDecodeErrorZ in the success state. +pub extern "C" fn CResult_NodeFeaturesDecodeErrorZ_ok(o: crate::lightning::ln::features::NodeFeatures) -> CResult_NodeFeaturesDecodeErrorZ { + CResult_NodeFeaturesDecodeErrorZ { + contents: CResult_NodeFeaturesDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_COption_PathFailureZDecodeErrorZ in the error state. -pub extern "C" fn CResult_COption_PathFailureZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_COption_PathFailureZDecodeErrorZ { - CResult_COption_PathFailureZDecodeErrorZ { - contents: CResult_COption_PathFailureZDecodeErrorZPtr { +/// Creates a new CResult_NodeFeaturesDecodeErrorZ in the error state. +pub extern "C" fn CResult_NodeFeaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_NodeFeaturesDecodeErrorZ { + CResult_NodeFeaturesDecodeErrorZ { + contents: CResult_NodeFeaturesDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -5084,13 +5204,13 @@ pub extern "C" fn CResult_COption_PathFailureZDecodeErrorZ_err(e: crate::lightni } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_COption_PathFailureZDecodeErrorZ_is_ok(o: &CResult_COption_PathFailureZDecodeErrorZ) -> bool { +pub extern "C" fn CResult_NodeFeaturesDecodeErrorZ_is_ok(o: &CResult_NodeFeaturesDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_COption_PathFailureZDecodeErrorZ. -pub extern "C" fn CResult_COption_PathFailureZDecodeErrorZ_free(_res: CResult_COption_PathFailureZDecodeErrorZ) { } -impl Drop for CResult_COption_PathFailureZDecodeErrorZ { +/// Frees any resources used by the CResult_NodeFeaturesDecodeErrorZ. +pub extern "C" fn CResult_NodeFeaturesDecodeErrorZ_free(_res: CResult_NodeFeaturesDecodeErrorZ) { } +impl Drop for CResult_NodeFeaturesDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -5103,16 +5223,16 @@ impl Drop for CResult_COption_PathFailureZDecodeErrorZ { } } } -impl From> for CResult_COption_PathFailureZDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_NodeFeaturesDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_COption_PathFailureZDecodeErrorZPtr { result } + CResult_NodeFeaturesDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_COption_PathFailureZDecodeErrorZPtr { err } + CResult_NodeFeaturesDecodeErrorZPtr { err } }; Self { contents, @@ -5120,96 +5240,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_COption_PathFailureZDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_NodeFeaturesDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_COption_PathFailureZDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_NodeFeaturesDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_COption_PathFailureZDecodeErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_COption_PathFailureZDecodeErrorZ_clone(orig: &CResult_COption_PathFailureZDecodeErrorZ) -> CResult_COption_PathFailureZDecodeErrorZ { Clone::clone(&orig) } -#[repr(C)] -#[derive(Clone)] -/// An enum which can either contain a crate::lightning::events::ClosureReason or not -pub enum COption_ClosureReasonZ { - /// When we're in this state, this COption_ClosureReasonZ contains a crate::lightning::events::ClosureReason - Some(crate::lightning::events::ClosureReason), - /// When we're in this state, this COption_ClosureReasonZ contains nothing - None -} -impl COption_ClosureReasonZ { - #[allow(unused)] pub(crate) fn is_some(&self) -> bool { - if let Self::None = self { false } else { true } - } - #[allow(unused)] pub(crate) fn is_none(&self) -> bool { - !self.is_some() - } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::events::ClosureReason { - if let Self::Some(v) = self { v } else { unreachable!() } - } -} -#[no_mangle] -/// Constructs a new COption_ClosureReasonZ containing a crate::lightning::events::ClosureReason -pub extern "C" fn COption_ClosureReasonZ_some(o: crate::lightning::events::ClosureReason) -> COption_ClosureReasonZ { - COption_ClosureReasonZ::Some(o) -} -#[no_mangle] -/// Constructs a new COption_ClosureReasonZ containing nothing -pub extern "C" fn COption_ClosureReasonZ_none() -> COption_ClosureReasonZ { - COption_ClosureReasonZ::None -} -#[no_mangle] -/// Frees any resources associated with the crate::lightning::events::ClosureReason, if we are in the Some state -pub extern "C" fn COption_ClosureReasonZ_free(_res: COption_ClosureReasonZ) { } -#[no_mangle] -/// Creates a new COption_ClosureReasonZ which has the same data as `orig` +/// Creates a new CResult_NodeFeaturesDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_ClosureReasonZ_clone(orig: &COption_ClosureReasonZ) -> COption_ClosureReasonZ { Clone::clone(&orig) } +pub extern "C" fn CResult_NodeFeaturesDecodeErrorZ_clone(orig: &CResult_NodeFeaturesDecodeErrorZ) -> CResult_NodeFeaturesDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_COption_ClosureReasonZDecodeErrorZ -pub union CResult_COption_ClosureReasonZDecodeErrorZPtr { +/// The contents of CResult_Bolt11InvoiceFeaturesDecodeErrorZ +pub union CResult_Bolt11InvoiceFeaturesDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::COption_ClosureReasonZ, + pub result: *mut crate::lightning::ln::features::Bolt11InvoiceFeatures, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_COption_ClosureReasonZDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::COption_ClosureReasonZ on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_Bolt11InvoiceFeaturesDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::features::Bolt11InvoiceFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_COption_ClosureReasonZDecodeErrorZ { - /// The contents of this CResult_COption_ClosureReasonZDecodeErrorZ, accessible via either +pub struct CResult_Bolt11InvoiceFeaturesDecodeErrorZ { + /// The contents of this CResult_Bolt11InvoiceFeaturesDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_COption_ClosureReasonZDecodeErrorZPtr, - /// Whether this CResult_COption_ClosureReasonZDecodeErrorZ represents a success state. + pub contents: CResult_Bolt11InvoiceFeaturesDecodeErrorZPtr, + /// Whether this CResult_Bolt11InvoiceFeaturesDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_COption_ClosureReasonZDecodeErrorZ in the success state. -pub extern "C" fn CResult_COption_ClosureReasonZDecodeErrorZ_ok(o: crate::c_types::derived::COption_ClosureReasonZ) -> CResult_COption_ClosureReasonZDecodeErrorZ { - CResult_COption_ClosureReasonZDecodeErrorZ { - contents: CResult_COption_ClosureReasonZDecodeErrorZPtr { +/// Creates a new CResult_Bolt11InvoiceFeaturesDecodeErrorZ in the success state. +pub extern "C" fn CResult_Bolt11InvoiceFeaturesDecodeErrorZ_ok(o: crate::lightning::ln::features::Bolt11InvoiceFeatures) -> CResult_Bolt11InvoiceFeaturesDecodeErrorZ { + CResult_Bolt11InvoiceFeaturesDecodeErrorZ { + contents: CResult_Bolt11InvoiceFeaturesDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_COption_ClosureReasonZDecodeErrorZ in the error state. -pub extern "C" fn CResult_COption_ClosureReasonZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_COption_ClosureReasonZDecodeErrorZ { - CResult_COption_ClosureReasonZDecodeErrorZ { - contents: CResult_COption_ClosureReasonZDecodeErrorZPtr { +/// Creates a new CResult_Bolt11InvoiceFeaturesDecodeErrorZ in the error state. +pub extern "C" fn CResult_Bolt11InvoiceFeaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_Bolt11InvoiceFeaturesDecodeErrorZ { + CResult_Bolt11InvoiceFeaturesDecodeErrorZ { + contents: CResult_Bolt11InvoiceFeaturesDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -5217,13 +5300,13 @@ pub extern "C" fn CResult_COption_ClosureReasonZDecodeErrorZ_err(e: crate::light } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(o: &CResult_COption_ClosureReasonZDecodeErrorZ) -> bool { +pub extern "C" fn CResult_Bolt11InvoiceFeaturesDecodeErrorZ_is_ok(o: &CResult_Bolt11InvoiceFeaturesDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_COption_ClosureReasonZDecodeErrorZ. -pub extern "C" fn CResult_COption_ClosureReasonZDecodeErrorZ_free(_res: CResult_COption_ClosureReasonZDecodeErrorZ) { } -impl Drop for CResult_COption_ClosureReasonZDecodeErrorZ { +/// Frees any resources used by the CResult_Bolt11InvoiceFeaturesDecodeErrorZ. +pub extern "C" fn CResult_Bolt11InvoiceFeaturesDecodeErrorZ_free(_res: CResult_Bolt11InvoiceFeaturesDecodeErrorZ) { } +impl Drop for CResult_Bolt11InvoiceFeaturesDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -5236,16 +5319,16 @@ impl Drop for CResult_COption_ClosureReasonZDecodeErrorZ { } } } -impl From> for CResult_COption_ClosureReasonZDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_Bolt11InvoiceFeaturesDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_COption_ClosureReasonZDecodeErrorZPtr { result } + CResult_Bolt11InvoiceFeaturesDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_COption_ClosureReasonZDecodeErrorZPtr { err } + CResult_Bolt11InvoiceFeaturesDecodeErrorZPtr { err } }; Self { contents, @@ -5253,96 +5336,155 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_COption_ClosureReasonZDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_Bolt11InvoiceFeaturesDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_COption_ClosureReasonZDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_Bolt11InvoiceFeaturesDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_COption_ClosureReasonZDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_Bolt11InvoiceFeaturesDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_COption_ClosureReasonZDecodeErrorZ_clone(orig: &CResult_COption_ClosureReasonZDecodeErrorZ) -> CResult_COption_ClosureReasonZDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_Bolt11InvoiceFeaturesDecodeErrorZ_clone(orig: &CResult_Bolt11InvoiceFeaturesDecodeErrorZ) -> CResult_Bolt11InvoiceFeaturesDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -#[derive(Clone)] -/// An enum which can either contain a crate::lightning::events::HTLCDestination or not -pub enum COption_HTLCDestinationZ { - /// When we're in this state, this COption_HTLCDestinationZ contains a crate::lightning::events::HTLCDestination - Some(crate::lightning::events::HTLCDestination), - /// When we're in this state, this COption_HTLCDestinationZ contains nothing - None +/// The contents of CResult_Bolt12InvoiceFeaturesDecodeErrorZ +pub union CResult_Bolt12InvoiceFeaturesDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::features::Bolt12InvoiceFeatures, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, } -impl COption_HTLCDestinationZ { - #[allow(unused)] pub(crate) fn is_some(&self) -> bool { - if let Self::None = self { false } else { true } - } - #[allow(unused)] pub(crate) fn is_none(&self) -> bool { - !self.is_some() - } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::events::HTLCDestination { - if let Self::Some(v) = self { v } else { unreachable!() } +#[repr(C)] +/// A CResult_Bolt12InvoiceFeaturesDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::features::Bolt12InvoiceFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_Bolt12InvoiceFeaturesDecodeErrorZ { + /// The contents of this CResult_Bolt12InvoiceFeaturesDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_Bolt12InvoiceFeaturesDecodeErrorZPtr, + /// Whether this CResult_Bolt12InvoiceFeaturesDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_Bolt12InvoiceFeaturesDecodeErrorZ in the success state. +pub extern "C" fn CResult_Bolt12InvoiceFeaturesDecodeErrorZ_ok(o: crate::lightning::ln::features::Bolt12InvoiceFeatures) -> CResult_Bolt12InvoiceFeaturesDecodeErrorZ { + CResult_Bolt12InvoiceFeaturesDecodeErrorZ { + contents: CResult_Bolt12InvoiceFeaturesDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, } } #[no_mangle] -/// Constructs a new COption_HTLCDestinationZ containing a crate::lightning::events::HTLCDestination -pub extern "C" fn COption_HTLCDestinationZ_some(o: crate::lightning::events::HTLCDestination) -> COption_HTLCDestinationZ { - COption_HTLCDestinationZ::Some(o) +/// Creates a new CResult_Bolt12InvoiceFeaturesDecodeErrorZ in the error state. +pub extern "C" fn CResult_Bolt12InvoiceFeaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_Bolt12InvoiceFeaturesDecodeErrorZ { + CResult_Bolt12InvoiceFeaturesDecodeErrorZ { + contents: CResult_Bolt12InvoiceFeaturesDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } } +/// Checks if the given object is currently in the success state #[no_mangle] -/// Constructs a new COption_HTLCDestinationZ containing nothing -pub extern "C" fn COption_HTLCDestinationZ_none() -> COption_HTLCDestinationZ { - COption_HTLCDestinationZ::None +pub extern "C" fn CResult_Bolt12InvoiceFeaturesDecodeErrorZ_is_ok(o: &CResult_Bolt12InvoiceFeaturesDecodeErrorZ) -> bool { + o.result_ok } #[no_mangle] -/// Frees any resources associated with the crate::lightning::events::HTLCDestination, if we are in the Some state -pub extern "C" fn COption_HTLCDestinationZ_free(_res: COption_HTLCDestinationZ) { } +/// Frees any resources used by the CResult_Bolt12InvoiceFeaturesDecodeErrorZ. +pub extern "C" fn CResult_Bolt12InvoiceFeaturesDecodeErrorZ_free(_res: CResult_Bolt12InvoiceFeaturesDecodeErrorZ) { } +impl Drop for CResult_Bolt12InvoiceFeaturesDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_Bolt12InvoiceFeaturesDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_Bolt12InvoiceFeaturesDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_Bolt12InvoiceFeaturesDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_Bolt12InvoiceFeaturesDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_Bolt12InvoiceFeaturesDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_Bolt12InvoiceFeaturesDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} #[no_mangle] -/// Creates a new COption_HTLCDestinationZ which has the same data as `orig` +/// Creates a new CResult_Bolt12InvoiceFeaturesDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_HTLCDestinationZ_clone(orig: &COption_HTLCDestinationZ) -> COption_HTLCDestinationZ { Clone::clone(&orig) } +pub extern "C" fn CResult_Bolt12InvoiceFeaturesDecodeErrorZ_clone(orig: &CResult_Bolt12InvoiceFeaturesDecodeErrorZ) -> CResult_Bolt12InvoiceFeaturesDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_COption_HTLCDestinationZDecodeErrorZ -pub union CResult_COption_HTLCDestinationZDecodeErrorZPtr { +/// The contents of CResult_BlindedHopFeaturesDecodeErrorZ +pub union CResult_BlindedHopFeaturesDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::COption_HTLCDestinationZ, + pub result: *mut crate::lightning::ln::features::BlindedHopFeatures, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_COption_HTLCDestinationZDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::COption_HTLCDestinationZ on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_BlindedHopFeaturesDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::features::BlindedHopFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_COption_HTLCDestinationZDecodeErrorZ { - /// The contents of this CResult_COption_HTLCDestinationZDecodeErrorZ, accessible via either +pub struct CResult_BlindedHopFeaturesDecodeErrorZ { + /// The contents of this CResult_BlindedHopFeaturesDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_COption_HTLCDestinationZDecodeErrorZPtr, - /// Whether this CResult_COption_HTLCDestinationZDecodeErrorZ represents a success state. + pub contents: CResult_BlindedHopFeaturesDecodeErrorZPtr, + /// Whether this CResult_BlindedHopFeaturesDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_COption_HTLCDestinationZDecodeErrorZ in the success state. -pub extern "C" fn CResult_COption_HTLCDestinationZDecodeErrorZ_ok(o: crate::c_types::derived::COption_HTLCDestinationZ) -> CResult_COption_HTLCDestinationZDecodeErrorZ { - CResult_COption_HTLCDestinationZDecodeErrorZ { - contents: CResult_COption_HTLCDestinationZDecodeErrorZPtr { +/// Creates a new CResult_BlindedHopFeaturesDecodeErrorZ in the success state. +pub extern "C" fn CResult_BlindedHopFeaturesDecodeErrorZ_ok(o: crate::lightning::ln::features::BlindedHopFeatures) -> CResult_BlindedHopFeaturesDecodeErrorZ { + CResult_BlindedHopFeaturesDecodeErrorZ { + contents: CResult_BlindedHopFeaturesDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_COption_HTLCDestinationZDecodeErrorZ in the error state. -pub extern "C" fn CResult_COption_HTLCDestinationZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_COption_HTLCDestinationZDecodeErrorZ { - CResult_COption_HTLCDestinationZDecodeErrorZ { - contents: CResult_COption_HTLCDestinationZDecodeErrorZPtr { +/// Creates a new CResult_BlindedHopFeaturesDecodeErrorZ in the error state. +pub extern "C" fn CResult_BlindedHopFeaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_BlindedHopFeaturesDecodeErrorZ { + CResult_BlindedHopFeaturesDecodeErrorZ { + contents: CResult_BlindedHopFeaturesDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -5350,13 +5492,13 @@ pub extern "C" fn CResult_COption_HTLCDestinationZDecodeErrorZ_err(e: crate::lig } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_COption_HTLCDestinationZDecodeErrorZ_is_ok(o: &CResult_COption_HTLCDestinationZDecodeErrorZ) -> bool { +pub extern "C" fn CResult_BlindedHopFeaturesDecodeErrorZ_is_ok(o: &CResult_BlindedHopFeaturesDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_COption_HTLCDestinationZDecodeErrorZ. -pub extern "C" fn CResult_COption_HTLCDestinationZDecodeErrorZ_free(_res: CResult_COption_HTLCDestinationZDecodeErrorZ) { } -impl Drop for CResult_COption_HTLCDestinationZDecodeErrorZ { +/// Frees any resources used by the CResult_BlindedHopFeaturesDecodeErrorZ. +pub extern "C" fn CResult_BlindedHopFeaturesDecodeErrorZ_free(_res: CResult_BlindedHopFeaturesDecodeErrorZ) { } +impl Drop for CResult_BlindedHopFeaturesDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -5369,16 +5511,16 @@ impl Drop for CResult_COption_HTLCDestinationZDecodeErrorZ { } } } -impl From> for CResult_COption_HTLCDestinationZDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_BlindedHopFeaturesDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_COption_HTLCDestinationZDecodeErrorZPtr { result } + CResult_BlindedHopFeaturesDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_COption_HTLCDestinationZDecodeErrorZPtr { err } + CResult_BlindedHopFeaturesDecodeErrorZPtr { err } }; Self { contents, @@ -5386,59 +5528,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_COption_HTLCDestinationZDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_BlindedHopFeaturesDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_COption_HTLCDestinationZDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_BlindedHopFeaturesDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_COption_HTLCDestinationZDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_BlindedHopFeaturesDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_COption_HTLCDestinationZDecodeErrorZ_clone(orig: &CResult_COption_HTLCDestinationZDecodeErrorZ) -> CResult_COption_HTLCDestinationZDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_BlindedHopFeaturesDecodeErrorZ_clone(orig: &CResult_BlindedHopFeaturesDecodeErrorZ) -> CResult_BlindedHopFeaturesDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_PaymentFailureReasonDecodeErrorZ -pub union CResult_PaymentFailureReasonDecodeErrorZPtr { +/// The contents of CResult_ChannelTypeFeaturesDecodeErrorZ +pub union CResult_ChannelTypeFeaturesDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::events::PaymentFailureReason, + pub result: *mut crate::lightning::ln::features::ChannelTypeFeatures, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_PaymentFailureReasonDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::events::PaymentFailureReason on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_ChannelTypeFeaturesDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::features::ChannelTypeFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_PaymentFailureReasonDecodeErrorZ { - /// The contents of this CResult_PaymentFailureReasonDecodeErrorZ, accessible via either +pub struct CResult_ChannelTypeFeaturesDecodeErrorZ { + /// The contents of this CResult_ChannelTypeFeaturesDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_PaymentFailureReasonDecodeErrorZPtr, - /// Whether this CResult_PaymentFailureReasonDecodeErrorZ represents a success state. + pub contents: CResult_ChannelTypeFeaturesDecodeErrorZPtr, + /// Whether this CResult_ChannelTypeFeaturesDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_PaymentFailureReasonDecodeErrorZ in the success state. -pub extern "C" fn CResult_PaymentFailureReasonDecodeErrorZ_ok(o: crate::lightning::events::PaymentFailureReason) -> CResult_PaymentFailureReasonDecodeErrorZ { - CResult_PaymentFailureReasonDecodeErrorZ { - contents: CResult_PaymentFailureReasonDecodeErrorZPtr { +/// Creates a new CResult_ChannelTypeFeaturesDecodeErrorZ in the success state. +pub extern "C" fn CResult_ChannelTypeFeaturesDecodeErrorZ_ok(o: crate::lightning::ln::features::ChannelTypeFeatures) -> CResult_ChannelTypeFeaturesDecodeErrorZ { + CResult_ChannelTypeFeaturesDecodeErrorZ { + contents: CResult_ChannelTypeFeaturesDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_PaymentFailureReasonDecodeErrorZ in the error state. -pub extern "C" fn CResult_PaymentFailureReasonDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_PaymentFailureReasonDecodeErrorZ { - CResult_PaymentFailureReasonDecodeErrorZ { - contents: CResult_PaymentFailureReasonDecodeErrorZPtr { +/// Creates a new CResult_ChannelTypeFeaturesDecodeErrorZ in the error state. +pub extern "C" fn CResult_ChannelTypeFeaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelTypeFeaturesDecodeErrorZ { + CResult_ChannelTypeFeaturesDecodeErrorZ { + contents: CResult_ChannelTypeFeaturesDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -5446,13 +5588,13 @@ pub extern "C" fn CResult_PaymentFailureReasonDecodeErrorZ_err(e: crate::lightni } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_PaymentFailureReasonDecodeErrorZ_is_ok(o: &CResult_PaymentFailureReasonDecodeErrorZ) -> bool { +pub extern "C" fn CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(o: &CResult_ChannelTypeFeaturesDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_PaymentFailureReasonDecodeErrorZ. -pub extern "C" fn CResult_PaymentFailureReasonDecodeErrorZ_free(_res: CResult_PaymentFailureReasonDecodeErrorZ) { } -impl Drop for CResult_PaymentFailureReasonDecodeErrorZ { +/// Frees any resources used by the CResult_ChannelTypeFeaturesDecodeErrorZ. +pub extern "C" fn CResult_ChannelTypeFeaturesDecodeErrorZ_free(_res: CResult_ChannelTypeFeaturesDecodeErrorZ) { } +impl Drop for CResult_ChannelTypeFeaturesDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -5465,16 +5607,16 @@ impl Drop for CResult_PaymentFailureReasonDecodeErrorZ { } } } -impl From> for CResult_PaymentFailureReasonDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ChannelTypeFeaturesDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_PaymentFailureReasonDecodeErrorZPtr { result } + CResult_ChannelTypeFeaturesDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_PaymentFailureReasonDecodeErrorZPtr { err } + CResult_ChannelTypeFeaturesDecodeErrorZPtr { err } }; Self { contents, @@ -5482,216 +5624,105 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_PaymentFailureReasonDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_ChannelTypeFeaturesDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_PaymentFailureReasonDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_ChannelTypeFeaturesDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_PaymentFailureReasonDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_ChannelTypeFeaturesDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_PaymentFailureReasonDecodeErrorZ_clone(orig: &CResult_PaymentFailureReasonDecodeErrorZ) -> CResult_PaymentFailureReasonDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_ChannelTypeFeaturesDecodeErrorZ_clone(orig: &CResult_ChannelTypeFeaturesDecodeErrorZ) -> CResult_ChannelTypeFeaturesDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -#[derive(Clone)] -/// An enum which can either contain a crate::c_types::U128 or not -pub enum COption_u128Z { - /// When we're in this state, this COption_u128Z contains a crate::c_types::U128 - Some(crate::c_types::U128), - /// When we're in this state, this COption_u128Z contains nothing - None +/// A dynamically-allocated array of crate::c_types::ThirtyTwoBytess of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_ChainHashZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::ThirtyTwoBytes, + /// The number of elements pointed to by `data`. + pub datalen: usize } -impl COption_u128Z { - #[allow(unused)] pub(crate) fn is_some(&self) -> bool { - if let Self::None = self { false } else { true } +impl CVec_ChainHashZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret } - #[allow(unused)] pub(crate) fn is_none(&self) -> bool { - !self.is_some() + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::ThirtyTwoBytes] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::U128 { - if let Self::Some(v) = self { v } else { unreachable!() } +} +impl From> for CVec_ChainHashZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } } } #[no_mangle] -/// Constructs a new COption_u128Z containing a crate::c_types::U128 -pub extern "C" fn COption_u128Z_some(o: crate::c_types::U128) -> COption_u128Z { - COption_u128Z::Some(o) +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_ChainHashZ_free(_res: CVec_ChainHashZ) { } +impl Drop for CVec_ChainHashZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } } -#[no_mangle] -/// Constructs a new COption_u128Z containing nothing -pub extern "C" fn COption_u128Z_none() -> COption_u128Z { - COption_u128Z::None +impl Clone for CVec_ChainHashZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } } -#[no_mangle] -/// Frees any resources associated with the crate::c_types::U128, if we are in the Some state -pub extern "C" fn COption_u128Z_free(_res: COption_u128Z) { } -#[no_mangle] -/// Creates a new COption_u128Z which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_u128Z_clone(orig: &COption_u128Z) -> COption_u128Z { Clone::clone(&orig) } #[repr(C)] -#[derive(Clone)] -/// An enum which can either contain a crate::lightning::events::PaymentFailureReason or not -pub enum COption_PaymentFailureReasonZ { - /// When we're in this state, this COption_PaymentFailureReasonZ contains a crate::lightning::events::PaymentFailureReason - Some(crate::lightning::events::PaymentFailureReason), - /// When we're in this state, this COption_PaymentFailureReasonZ contains nothing - None -} -impl COption_PaymentFailureReasonZ { - #[allow(unused)] pub(crate) fn is_some(&self) -> bool { - if let Self::None = self { false } else { true } - } - #[allow(unused)] pub(crate) fn is_none(&self) -> bool { - !self.is_some() - } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::events::PaymentFailureReason { - if let Self::Some(v) = self { v } else { unreachable!() } - } -} -#[no_mangle] -/// Constructs a new COption_PaymentFailureReasonZ containing a crate::lightning::events::PaymentFailureReason -pub extern "C" fn COption_PaymentFailureReasonZ_some(o: crate::lightning::events::PaymentFailureReason) -> COption_PaymentFailureReasonZ { - COption_PaymentFailureReasonZ::Some(o) -} -#[no_mangle] -/// Constructs a new COption_PaymentFailureReasonZ containing nothing -pub extern "C" fn COption_PaymentFailureReasonZ_none() -> COption_PaymentFailureReasonZ { - COption_PaymentFailureReasonZ::None -} -#[no_mangle] -/// Frees any resources associated with the crate::lightning::events::PaymentFailureReason, if we are in the Some state -pub extern "C" fn COption_PaymentFailureReasonZ_free(_res: COption_PaymentFailureReasonZ) { } -#[no_mangle] -/// Creates a new COption_PaymentFailureReasonZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_PaymentFailureReasonZ_clone(orig: &COption_PaymentFailureReasonZ) -> COption_PaymentFailureReasonZ { Clone::clone(&orig) } -#[repr(C)] -/// A dynamically-allocated array of crate::lightning::chain::keysinterface::SpendableOutputDescriptors of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_SpendableOutputDescriptorZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::chain::keysinterface::SpendableOutputDescriptor, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_SpendableOutputDescriptorZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::chain::keysinterface::SpendableOutputDescriptor] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_SpendableOutputDescriptorZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_SpendableOutputDescriptorZ_free(_res: CVec_SpendableOutputDescriptorZ) { } -impl Drop for CVec_SpendableOutputDescriptorZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_SpendableOutputDescriptorZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} -#[repr(C)] -#[derive(Clone)] -/// An enum which can either contain a crate::lightning::events::Event or not -pub enum COption_EventZ { - /// When we're in this state, this COption_EventZ contains a crate::lightning::events::Event - Some(crate::lightning::events::Event), - /// When we're in this state, this COption_EventZ contains nothing - None -} -impl COption_EventZ { - #[allow(unused)] pub(crate) fn is_some(&self) -> bool { - if let Self::None = self { false } else { true } - } - #[allow(unused)] pub(crate) fn is_none(&self) -> bool { - !self.is_some() - } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::events::Event { - if let Self::Some(v) = self { v } else { unreachable!() } - } -} -#[no_mangle] -/// Constructs a new COption_EventZ containing a crate::lightning::events::Event -pub extern "C" fn COption_EventZ_some(o: crate::lightning::events::Event) -> COption_EventZ { - COption_EventZ::Some(o) -} -#[no_mangle] -/// Constructs a new COption_EventZ containing nothing -pub extern "C" fn COption_EventZ_none() -> COption_EventZ { - COption_EventZ::None -} -#[no_mangle] -/// Frees any resources associated with the crate::lightning::events::Event, if we are in the Some state -pub extern "C" fn COption_EventZ_free(_res: COption_EventZ) { } -#[no_mangle] -/// Creates a new COption_EventZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_EventZ_clone(orig: &COption_EventZ) -> COption_EventZ { Clone::clone(&orig) } -#[repr(C)] -/// The contents of CResult_COption_EventZDecodeErrorZ -pub union CResult_COption_EventZDecodeErrorZPtr { +/// The contents of CResult_OfferBolt12ParseErrorZ +pub union CResult_OfferBolt12ParseErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::COption_EventZ, + pub result: *mut crate::lightning::offers::offer::Offer, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::lightning::offers::parse::Bolt12ParseError, } #[repr(C)] -/// A CResult_COption_EventZDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::COption_EventZ on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_OfferBolt12ParseErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::offers::offer::Offer on success and a crate::lightning::offers::parse::Bolt12ParseError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_COption_EventZDecodeErrorZ { - /// The contents of this CResult_COption_EventZDecodeErrorZ, accessible via either +pub struct CResult_OfferBolt12ParseErrorZ { + /// The contents of this CResult_OfferBolt12ParseErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_COption_EventZDecodeErrorZPtr, - /// Whether this CResult_COption_EventZDecodeErrorZ represents a success state. + pub contents: CResult_OfferBolt12ParseErrorZPtr, + /// Whether this CResult_OfferBolt12ParseErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_COption_EventZDecodeErrorZ in the success state. -pub extern "C" fn CResult_COption_EventZDecodeErrorZ_ok(o: crate::c_types::derived::COption_EventZ) -> CResult_COption_EventZDecodeErrorZ { - CResult_COption_EventZDecodeErrorZ { - contents: CResult_COption_EventZDecodeErrorZPtr { +/// Creates a new CResult_OfferBolt12ParseErrorZ in the success state. +pub extern "C" fn CResult_OfferBolt12ParseErrorZ_ok(o: crate::lightning::offers::offer::Offer) -> CResult_OfferBolt12ParseErrorZ { + CResult_OfferBolt12ParseErrorZ { + contents: CResult_OfferBolt12ParseErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_COption_EventZDecodeErrorZ in the error state. -pub extern "C" fn CResult_COption_EventZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_COption_EventZDecodeErrorZ { - CResult_COption_EventZDecodeErrorZ { - contents: CResult_COption_EventZDecodeErrorZPtr { +/// Creates a new CResult_OfferBolt12ParseErrorZ in the error state. +pub extern "C" fn CResult_OfferBolt12ParseErrorZ_err(e: crate::lightning::offers::parse::Bolt12ParseError) -> CResult_OfferBolt12ParseErrorZ { + CResult_OfferBolt12ParseErrorZ { + contents: CResult_OfferBolt12ParseErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -5699,13 +5730,13 @@ pub extern "C" fn CResult_COption_EventZDecodeErrorZ_err(e: crate::lightning::ln } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_COption_EventZDecodeErrorZ_is_ok(o: &CResult_COption_EventZDecodeErrorZ) -> bool { +pub extern "C" fn CResult_OfferBolt12ParseErrorZ_is_ok(o: &CResult_OfferBolt12ParseErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_COption_EventZDecodeErrorZ. -pub extern "C" fn CResult_COption_EventZDecodeErrorZ_free(_res: CResult_COption_EventZDecodeErrorZ) { } -impl Drop for CResult_COption_EventZDecodeErrorZ { +/// Frees any resources used by the CResult_OfferBolt12ParseErrorZ. +pub extern "C" fn CResult_OfferBolt12ParseErrorZ_free(_res: CResult_OfferBolt12ParseErrorZ) { } +impl Drop for CResult_OfferBolt12ParseErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -5718,16 +5749,16 @@ impl Drop for CResult_COption_EventZDecodeErrorZ { } } } -impl From> for CResult_COption_EventZDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_OfferBolt12ParseErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_COption_EventZDecodeErrorZPtr { result } + CResult_OfferBolt12ParseErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_COption_EventZDecodeErrorZPtr { err } + CResult_OfferBolt12ParseErrorZPtr { err } }; Self { contents, @@ -5735,115 +5766,23 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_COption_EventZDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_OfferBolt12ParseErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_COption_EventZDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_OfferBolt12ParseErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_COption_EventZDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_OfferBolt12ParseErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_COption_EventZDecodeErrorZ_clone(orig: &CResult_COption_EventZDecodeErrorZ) -> CResult_COption_EventZDecodeErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// A dynamically-allocated array of crate::lightning::events::MessageSendEvents of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_MessageSendEventZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::events::MessageSendEvent, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_MessageSendEventZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::events::MessageSendEvent] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_MessageSendEventZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_MessageSendEventZ_free(_res: CVec_MessageSendEventZ) { } -impl Drop for CVec_MessageSendEventZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_MessageSendEventZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} -#[repr(C)] -/// A dynamically-allocated array of crate::c_types::ThirtyTwoBytess of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_ChainHashZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::ThirtyTwoBytes, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_ChainHashZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::ThirtyTwoBytes] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_ChainHashZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_ChainHashZ_free(_res: CVec_ChainHashZ) { } -impl Drop for CVec_ChainHashZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_ChainHashZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} +pub extern "C" fn CResult_OfferBolt12ParseErrorZ_clone(orig: &CResult_OfferBolt12ParseErrorZ) -> CResult_OfferBolt12ParseErrorZ { Clone::clone(&orig) } #[repr(C)] /// The contents of CResult_PublicKeyErrorZ pub union CResult_PublicKeyErrorZPtr { @@ -6037,21 +5976,58 @@ impl Clone for CResult_NodeIdDecodeErrorZ { /// but with all dynamically-allocated buffers duplicated in new buffers. pub extern "C" fn CResult_NodeIdDecodeErrorZ_clone(orig: &CResult_NodeIdDecodeErrorZ) -> CResult_NodeIdDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_COption_NetworkUpdateZDecodeErrorZ -pub union CResult_COption_NetworkUpdateZDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::COption_NetworkUpdateZ, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, +#[derive(Clone)] +/// An enum which can either contain a crate::lightning::routing::gossip::NetworkUpdate or not +pub enum COption_NetworkUpdateZ { + /// When we're in this state, this COption_NetworkUpdateZ contains a crate::lightning::routing::gossip::NetworkUpdate + Some(crate::lightning::routing::gossip::NetworkUpdate), + /// When we're in this state, this COption_NetworkUpdateZ contains nothing + None } -#[repr(C)] -/// A CResult_COption_NetworkUpdateZDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::COption_NetworkUpdateZ on success and a crate::lightning::ln::msgs::DecodeError on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_COption_NetworkUpdateZDecodeErrorZ { - /// The contents of this CResult_COption_NetworkUpdateZDecodeErrorZ, accessible via either +impl COption_NetworkUpdateZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::routing::gossip::NetworkUpdate { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_NetworkUpdateZ containing a crate::lightning::routing::gossip::NetworkUpdate +pub extern "C" fn COption_NetworkUpdateZ_some(o: crate::lightning::routing::gossip::NetworkUpdate) -> COption_NetworkUpdateZ { + COption_NetworkUpdateZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_NetworkUpdateZ containing nothing +pub extern "C" fn COption_NetworkUpdateZ_none() -> COption_NetworkUpdateZ { + COption_NetworkUpdateZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::lightning::routing::gossip::NetworkUpdate, if we are in the Some state +pub extern "C" fn COption_NetworkUpdateZ_free(_res: COption_NetworkUpdateZ) { } +#[no_mangle] +/// Creates a new COption_NetworkUpdateZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_NetworkUpdateZ_clone(orig: &COption_NetworkUpdateZ) -> COption_NetworkUpdateZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_COption_NetworkUpdateZDecodeErrorZ +pub union CResult_COption_NetworkUpdateZDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::c_types::derived::COption_NetworkUpdateZ, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_COption_NetworkUpdateZDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::COption_NetworkUpdateZ on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_COption_NetworkUpdateZDecodeErrorZ { + /// The contents of this CResult_COption_NetworkUpdateZDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. pub contents: CResult_COption_NetworkUpdateZDecodeErrorZPtr, /// Whether this CResult_COption_NetworkUpdateZDecodeErrorZ represents a success state. @@ -6165,6 +6141,98 @@ pub extern "C" fn COption_UtxoLookupZ_none() -> COption_UtxoLookupZ { /// Frees any resources associated with the crate::lightning::routing::utxo::UtxoLookup, if we are in the Some state pub extern "C" fn COption_UtxoLookupZ_free(_res: COption_UtxoLookupZ) { } #[repr(C)] +/// The contents of CResult_NoneLightningErrorZ +pub union CResult_NoneLightningErrorZPtr { + /// Note that this value is always NULL, as there are no contents in the OK variant + pub result: *mut core::ffi::c_void, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::LightningError, +} +#[repr(C)] +/// A CResult_NoneLightningErrorZ represents the result of a fallible operation, +/// containing a () on success and a crate::lightning::ln::msgs::LightningError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_NoneLightningErrorZ { + /// The contents of this CResult_NoneLightningErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_NoneLightningErrorZPtr, + /// Whether this CResult_NoneLightningErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_NoneLightningErrorZ in the success state. +pub extern "C" fn CResult_NoneLightningErrorZ_ok() -> CResult_NoneLightningErrorZ { + CResult_NoneLightningErrorZ { + contents: CResult_NoneLightningErrorZPtr { + result: core::ptr::null_mut(), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_NoneLightningErrorZ in the error state. +pub extern "C" fn CResult_NoneLightningErrorZ_err(e: crate::lightning::ln::msgs::LightningError) -> CResult_NoneLightningErrorZ { + CResult_NoneLightningErrorZ { + contents: CResult_NoneLightningErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_NoneLightningErrorZ_is_ok(o: &CResult_NoneLightningErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_NoneLightningErrorZ. +pub extern "C" fn CResult_NoneLightningErrorZ_free(_res: CResult_NoneLightningErrorZ) { } +impl Drop for CResult_NoneLightningErrorZ { + fn drop(&mut self) { + if self.result_ok { + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_NoneLightningErrorZ { + fn from(mut o: crate::c_types::CResultTempl<(), crate::lightning::ln::msgs::LightningError>) -> Self { + let contents = if o.result_ok { + let _ = unsafe { Box::from_raw(o.contents.result) }; + o.contents.result = core::ptr::null_mut(); + CResult_NoneLightningErrorZPtr { result: core::ptr::null_mut() } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_NoneLightningErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_NoneLightningErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_NoneLightningErrorZPtr { + result: core::ptr::null_mut() + } } + } else { + Self { result_ok: false, contents: CResult_NoneLightningErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_NoneLightningErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_NoneLightningErrorZ_clone(orig: &CResult_NoneLightningErrorZ) -> CResult_NoneLightningErrorZ { Clone::clone(&orig) } +#[repr(C)] /// The contents of CResult_boolLightningErrorZ pub union CResult_boolLightningErrorZPtr { /// A pointer to the contents in the success state. @@ -6344,97 +6412,51 @@ pub extern "C" fn COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ /// but with all dynamically-allocated buffers duplicated in new buffers. pub extern "C" fn COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(orig: &COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ) -> COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_NoneLightningErrorZ -pub union CResult_NoneLightningErrorZPtr { - /// Note that this value is always NULL, as there are no contents in the OK variant - pub result: *mut core::ffi::c_void, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::LightningError, -} -#[repr(C)] -/// A CResult_NoneLightningErrorZ represents the result of a fallible operation, -/// containing a () on success and a crate::lightning::ln::msgs::LightningError on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_NoneLightningErrorZ { - /// The contents of this CResult_NoneLightningErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_NoneLightningErrorZPtr, - /// Whether this CResult_NoneLightningErrorZ represents a success state. - pub result_ok: bool, +/// A dynamically-allocated array of crate::lightning::events::MessageSendEvents of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_MessageSendEventZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::events::MessageSendEvent, + /// The number of elements pointed to by `data`. + pub datalen: usize } -#[no_mangle] -/// Creates a new CResult_NoneLightningErrorZ in the success state. -pub extern "C" fn CResult_NoneLightningErrorZ_ok() -> CResult_NoneLightningErrorZ { - CResult_NoneLightningErrorZ { - contents: CResult_NoneLightningErrorZPtr { - result: core::ptr::null_mut(), - }, - result_ok: true, +impl CVec_MessageSendEventZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret } -} -#[no_mangle] -/// Creates a new CResult_NoneLightningErrorZ in the error state. -pub extern "C" fn CResult_NoneLightningErrorZ_err(e: crate::lightning::ln::msgs::LightningError) -> CResult_NoneLightningErrorZ { - CResult_NoneLightningErrorZ { - contents: CResult_NoneLightningErrorZPtr { - err: Box::into_raw(Box::new(e)), - }, - result_ok: false, + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::events::MessageSendEvent] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -/// Checks if the given object is currently in the success state -#[no_mangle] -pub extern "C" fn CResult_NoneLightningErrorZ_is_ok(o: &CResult_NoneLightningErrorZ) -> bool { - o.result_ok +impl From> for CVec_MessageSendEventZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } } #[no_mangle] -/// Frees any resources used by the CResult_NoneLightningErrorZ. -pub extern "C" fn CResult_NoneLightningErrorZ_free(_res: CResult_NoneLightningErrorZ) { } -impl Drop for CResult_NoneLightningErrorZ { +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_MessageSendEventZ_free(_res: CVec_MessageSendEventZ) { } +impl Drop for CVec_MessageSendEventZ { fn drop(&mut self) { - if self.result_ok { - } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } - } - } -} -impl From> for CResult_NoneLightningErrorZ { - fn from(mut o: crate::c_types::CResultTempl<(), crate::lightning::ln::msgs::LightningError>) -> Self { - let contents = if o.result_ok { - let _ = unsafe { Box::from_raw(o.contents.result) }; - o.contents.result = core::ptr::null_mut(); - CResult_NoneLightningErrorZPtr { result: core::ptr::null_mut() } - } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_NoneLightningErrorZPtr { err } - }; - Self { - contents, - result_ok: o.result_ok, - } + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl Clone for CResult_NoneLightningErrorZ { +impl Clone for CVec_MessageSendEventZ { fn clone(&self) -> Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_NoneLightningErrorZPtr { - result: core::ptr::null_mut() - } } - } else { - Self { result_ok: false, contents: CResult_NoneLightningErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } - } + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) } } -#[no_mangle] -/// Creates a new CResult_NoneLightningErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_NoneLightningErrorZ_clone(orig: &CResult_NoneLightningErrorZ) -> CResult_NoneLightningErrorZ { Clone::clone(&orig) } #[repr(C)] /// The contents of CResult_ChannelUpdateInfoDecodeErrorZ pub union CResult_ChannelUpdateInfoDecodeErrorZPtr { @@ -7174,77 +7196,331 @@ pub extern "C" fn COption_CVec_NetAddressZZ_free(_res: COption_CVec_NetAddressZZ /// but with all dynamically-allocated buffers duplicated in new buffers. pub extern "C" fn COption_CVec_NetAddressZZ_clone(orig: &COption_CVec_NetAddressZZ) -> COption_CVec_NetAddressZZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_DelayedPaymentOutputDescriptorDecodeErrorZ -pub union CResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::chain::keysinterface::DelayedPaymentOutputDescriptor, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, -} +#[derive(Clone)] +/// An enum which can either contain a crate::c_types::ThirtyTwoBytes or not +pub enum COption_PaymentPreimageZ { + /// When we're in this state, this COption_PaymentPreimageZ contains a crate::c_types::ThirtyTwoBytes + Some(crate::c_types::ThirtyTwoBytes), + /// When we're in this state, this COption_PaymentPreimageZ contains nothing + None +} +impl COption_PaymentPreimageZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::ThirtyTwoBytes { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_PaymentPreimageZ containing a crate::c_types::ThirtyTwoBytes +pub extern "C" fn COption_PaymentPreimageZ_some(o: crate::c_types::ThirtyTwoBytes) -> COption_PaymentPreimageZ { + COption_PaymentPreimageZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_PaymentPreimageZ containing nothing +pub extern "C" fn COption_PaymentPreimageZ_none() -> COption_PaymentPreimageZ { + COption_PaymentPreimageZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::c_types::ThirtyTwoBytes, if we are in the Some state +pub extern "C" fn COption_PaymentPreimageZ_free(_res: COption_PaymentPreimageZ) { } +#[no_mangle] +/// Creates a new COption_PaymentPreimageZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_PaymentPreimageZ_clone(orig: &COption_PaymentPreimageZ) -> COption_PaymentPreimageZ { Clone::clone(&orig) } #[repr(C)] -/// A CResult_DelayedPaymentOutputDescriptorDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::chain::keysinterface::DelayedPaymentOutputDescriptor on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A dynamically-allocated array of crate::lightning::ln::chan_utils::HTLCOutputInCommitments of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_HTLCOutputInCommitmentZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::ln::chan_utils::HTLCOutputInCommitment, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_HTLCOutputInCommitmentZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::chan_utils::HTLCOutputInCommitment] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_HTLCOutputInCommitmentZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_HTLCOutputInCommitmentZ_free(_res: CVec_HTLCOutputInCommitmentZ) { } +impl Drop for CVec_HTLCOutputInCommitmentZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_HTLCOutputInCommitmentZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// A dynamically-allocated array of crate::lightning::events::bump_transaction::HTLCDescriptors of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_HTLCDescriptorZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::events::bump_transaction::HTLCDescriptor, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_HTLCDescriptorZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::events::bump_transaction::HTLCDescriptor] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_HTLCDescriptorZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_HTLCDescriptorZ_free(_res: CVec_HTLCDescriptorZ) { } +impl Drop for CVec_HTLCDescriptorZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_HTLCDescriptorZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// A dynamically-allocated array of crate::lightning::events::bump_transaction::Utxos of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_UtxoZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::events::bump_transaction::Utxo, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_UtxoZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::events::bump_transaction::Utxo] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_UtxoZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_UtxoZ_free(_res: CVec_UtxoZ) { } +impl Drop for CVec_UtxoZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_UtxoZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +#[derive(Clone)] +/// An enum which can either contain a crate::c_types::TxOut or not +pub enum COption_TxOutZ { + /// When we're in this state, this COption_TxOutZ contains a crate::c_types::TxOut + Some(crate::c_types::TxOut), + /// When we're in this state, this COption_TxOutZ contains nothing + None +} +impl COption_TxOutZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::TxOut { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_TxOutZ containing a crate::c_types::TxOut +pub extern "C" fn COption_TxOutZ_some(o: crate::c_types::TxOut) -> COption_TxOutZ { + COption_TxOutZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_TxOutZ containing nothing +pub extern "C" fn COption_TxOutZ_none() -> COption_TxOutZ { + COption_TxOutZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::c_types::TxOut, if we are in the Some state +pub extern "C" fn COption_TxOutZ_free(_res: COption_TxOutZ) { } +#[no_mangle] +/// Creates a new COption_TxOutZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_TxOutZ_clone(orig: &COption_TxOutZ) -> COption_TxOutZ { Clone::clone(&orig) } +#[repr(C)] +/// A dynamically-allocated array of crate::lightning::events::bump_transaction::Inputs of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_InputZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::events::bump_transaction::Input, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_InputZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::events::bump_transaction::Input] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_InputZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_InputZ_free(_res: CVec_InputZ) { } +impl Drop for CVec_InputZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_InputZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// The contents of CResult_CoinSelectionNoneZ +pub union CResult_CoinSelectionNoneZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::events::bump_transaction::CoinSelection, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut core::ffi::c_void, +} +#[repr(C)] +/// A CResult_CoinSelectionNoneZ represents the result of a fallible operation, +/// containing a crate::lightning::events::bump_transaction::CoinSelection on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_DelayedPaymentOutputDescriptorDecodeErrorZ { - /// The contents of this CResult_DelayedPaymentOutputDescriptorDecodeErrorZ, accessible via either +pub struct CResult_CoinSelectionNoneZ { + /// The contents of this CResult_CoinSelectionNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr, - /// Whether this CResult_DelayedPaymentOutputDescriptorDecodeErrorZ represents a success state. + pub contents: CResult_CoinSelectionNoneZPtr, + /// Whether this CResult_CoinSelectionNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_DelayedPaymentOutputDescriptorDecodeErrorZ in the success state. -pub extern "C" fn CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o: crate::lightning::chain::keysinterface::DelayedPaymentOutputDescriptor) -> CResult_DelayedPaymentOutputDescriptorDecodeErrorZ { - CResult_DelayedPaymentOutputDescriptorDecodeErrorZ { - contents: CResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr { +/// Creates a new CResult_CoinSelectionNoneZ in the success state. +pub extern "C" fn CResult_CoinSelectionNoneZ_ok(o: crate::lightning::events::bump_transaction::CoinSelection) -> CResult_CoinSelectionNoneZ { + CResult_CoinSelectionNoneZ { + contents: CResult_CoinSelectionNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_DelayedPaymentOutputDescriptorDecodeErrorZ in the error state. -pub extern "C" fn CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_DelayedPaymentOutputDescriptorDecodeErrorZ { - CResult_DelayedPaymentOutputDescriptorDecodeErrorZ { - contents: CResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), +/// Creates a new CResult_CoinSelectionNoneZ in the error state. +pub extern "C" fn CResult_CoinSelectionNoneZ_err() -> CResult_CoinSelectionNoneZ { + CResult_CoinSelectionNoneZ { + contents: CResult_CoinSelectionNoneZPtr { + err: core::ptr::null_mut(), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(o: &CResult_DelayedPaymentOutputDescriptorDecodeErrorZ) -> bool { +pub extern "C" fn CResult_CoinSelectionNoneZ_is_ok(o: &CResult_CoinSelectionNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_DelayedPaymentOutputDescriptorDecodeErrorZ. -pub extern "C" fn CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res: CResult_DelayedPaymentOutputDescriptorDecodeErrorZ) { } -impl Drop for CResult_DelayedPaymentOutputDescriptorDecodeErrorZ { +/// Frees any resources used by the CResult_CoinSelectionNoneZ. +pub extern "C" fn CResult_CoinSelectionNoneZ_free(_res: CResult_CoinSelectionNoneZ) { } +impl Drop for CResult_CoinSelectionNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } } } } -impl From> for CResult_DelayedPaymentOutputDescriptorDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_CoinSelectionNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr { result } + CResult_CoinSelectionNoneZPtr { result } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr { err } + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_CoinSelectionNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -7252,95 +7528,91 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_CoinSelectionNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_CoinSelectionNoneZPtr { + err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_DelayedPaymentOutputDescriptorDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_CoinSelectionNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig: &CResult_DelayedPaymentOutputDescriptorDecodeErrorZ) -> CResult_DelayedPaymentOutputDescriptorDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_CoinSelectionNoneZ_clone(orig: &CResult_CoinSelectionNoneZ) -> CResult_CoinSelectionNoneZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_StaticPaymentOutputDescriptorDecodeErrorZ -pub union CResult_StaticPaymentOutputDescriptorDecodeErrorZPtr { +/// The contents of CResult_CVec_UtxoZNoneZ +pub union CResult_CVec_UtxoZNoneZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::chain::keysinterface::StaticPaymentOutputDescriptor, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub result: *mut crate::c_types::derived::CVec_UtxoZ, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut core::ffi::c_void, } #[repr(C)] -/// A CResult_StaticPaymentOutputDescriptorDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::chain::keysinterface::StaticPaymentOutputDescriptor on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_CVec_UtxoZNoneZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::CVec_UtxoZ on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_StaticPaymentOutputDescriptorDecodeErrorZ { - /// The contents of this CResult_StaticPaymentOutputDescriptorDecodeErrorZ, accessible via either +pub struct CResult_CVec_UtxoZNoneZ { + /// The contents of this CResult_CVec_UtxoZNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_StaticPaymentOutputDescriptorDecodeErrorZPtr, - /// Whether this CResult_StaticPaymentOutputDescriptorDecodeErrorZ represents a success state. + pub contents: CResult_CVec_UtxoZNoneZPtr, + /// Whether this CResult_CVec_UtxoZNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_StaticPaymentOutputDescriptorDecodeErrorZ in the success state. -pub extern "C" fn CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o: crate::lightning::chain::keysinterface::StaticPaymentOutputDescriptor) -> CResult_StaticPaymentOutputDescriptorDecodeErrorZ { - CResult_StaticPaymentOutputDescriptorDecodeErrorZ { - contents: CResult_StaticPaymentOutputDescriptorDecodeErrorZPtr { +/// Creates a new CResult_CVec_UtxoZNoneZ in the success state. +pub extern "C" fn CResult_CVec_UtxoZNoneZ_ok(o: crate::c_types::derived::CVec_UtxoZ) -> CResult_CVec_UtxoZNoneZ { + CResult_CVec_UtxoZNoneZ { + contents: CResult_CVec_UtxoZNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_StaticPaymentOutputDescriptorDecodeErrorZ in the error state. -pub extern "C" fn CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_StaticPaymentOutputDescriptorDecodeErrorZ { - CResult_StaticPaymentOutputDescriptorDecodeErrorZ { - contents: CResult_StaticPaymentOutputDescriptorDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), +/// Creates a new CResult_CVec_UtxoZNoneZ in the error state. +pub extern "C" fn CResult_CVec_UtxoZNoneZ_err() -> CResult_CVec_UtxoZNoneZ { + CResult_CVec_UtxoZNoneZ { + contents: CResult_CVec_UtxoZNoneZPtr { + err: core::ptr::null_mut(), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(o: &CResult_StaticPaymentOutputDescriptorDecodeErrorZ) -> bool { +pub extern "C" fn CResult_CVec_UtxoZNoneZ_is_ok(o: &CResult_CVec_UtxoZNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_StaticPaymentOutputDescriptorDecodeErrorZ. -pub extern "C" fn CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res: CResult_StaticPaymentOutputDescriptorDecodeErrorZ) { } -impl Drop for CResult_StaticPaymentOutputDescriptorDecodeErrorZ { +/// Frees any resources used by the CResult_CVec_UtxoZNoneZ. +pub extern "C" fn CResult_CVec_UtxoZNoneZ_free(_res: CResult_CVec_UtxoZNoneZ) { } +impl Drop for CResult_CVec_UtxoZNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } } } } -impl From> for CResult_StaticPaymentOutputDescriptorDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_CVec_UtxoZNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_StaticPaymentOutputDescriptorDecodeErrorZPtr { result } + CResult_CVec_UtxoZNoneZPtr { result } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_StaticPaymentOutputDescriptorDecodeErrorZPtr { err } + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_CVec_UtxoZNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -7348,59 +7620,170 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_StaticPaymentOutputDescriptorDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_CVec_UtxoZNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_StaticPaymentOutputDescriptorDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_CVec_UtxoZNoneZPtr { + err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_StaticPaymentOutputDescriptorDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_CVec_UtxoZNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig: &CResult_StaticPaymentOutputDescriptorDecodeErrorZ) -> CResult_StaticPaymentOutputDescriptorDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_CVec_UtxoZNoneZ_clone(orig: &CResult_CVec_UtxoZNoneZ) -> CResult_CVec_UtxoZNoneZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_SpendableOutputDescriptorDecodeErrorZ -pub union CResult_SpendableOutputDescriptorDecodeErrorZPtr { +#[derive(Clone)] +/// An enum which can either contain a u16 or not +pub enum COption_u16Z { + /// When we're in this state, this COption_u16Z contains a u16 + Some(u16), + /// When we're in this state, this COption_u16Z contains nothing + None +} +impl COption_u16Z { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> u16 { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_u16Z containing a u16 +pub extern "C" fn COption_u16Z_some(o: u16) -> COption_u16Z { + COption_u16Z::Some(o) +} +#[no_mangle] +/// Constructs a new COption_u16Z containing nothing +pub extern "C" fn COption_u16Z_none() -> COption_u16Z { + COption_u16Z::None +} +#[no_mangle] +/// Frees any resources associated with the u16, if we are in the Some state +pub extern "C" fn COption_u16Z_free(_res: COption_u16Z) { } +#[no_mangle] +/// Creates a new COption_u16Z which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_u16Z_clone(orig: &COption_u16Z) -> COption_u16Z { Clone::clone(&orig) } +#[repr(C)] +#[derive(Clone)] +/// An enum which can either contain a crate::lightning::ln::channelmanager::ChannelShutdownState or not +pub enum COption_ChannelShutdownStateZ { + /// When we're in this state, this COption_ChannelShutdownStateZ contains a crate::lightning::ln::channelmanager::ChannelShutdownState + Some(crate::lightning::ln::channelmanager::ChannelShutdownState), + /// When we're in this state, this COption_ChannelShutdownStateZ contains nothing + None +} +impl COption_ChannelShutdownStateZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::ln::channelmanager::ChannelShutdownState { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_ChannelShutdownStateZ containing a crate::lightning::ln::channelmanager::ChannelShutdownState +pub extern "C" fn COption_ChannelShutdownStateZ_some(o: crate::lightning::ln::channelmanager::ChannelShutdownState) -> COption_ChannelShutdownStateZ { + COption_ChannelShutdownStateZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_ChannelShutdownStateZ containing nothing +pub extern "C" fn COption_ChannelShutdownStateZ_none() -> COption_ChannelShutdownStateZ { + COption_ChannelShutdownStateZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::lightning::ln::channelmanager::ChannelShutdownState, if we are in the Some state +pub extern "C" fn COption_ChannelShutdownStateZ_free(_res: COption_ChannelShutdownStateZ) { } +#[no_mangle] +/// Creates a new COption_ChannelShutdownStateZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_ChannelShutdownStateZ_clone(orig: &COption_ChannelShutdownStateZ) -> COption_ChannelShutdownStateZ { Clone::clone(&orig) } +#[repr(C)] +#[derive(Clone)] +/// An enum which can either contain a crate::c_types::ThirtyTwoBytes or not +pub enum COption_PaymentHashZ { + /// When we're in this state, this COption_PaymentHashZ contains a crate::c_types::ThirtyTwoBytes + Some(crate::c_types::ThirtyTwoBytes), + /// When we're in this state, this COption_PaymentHashZ contains nothing + None +} +impl COption_PaymentHashZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::ThirtyTwoBytes { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_PaymentHashZ containing a crate::c_types::ThirtyTwoBytes +pub extern "C" fn COption_PaymentHashZ_some(o: crate::c_types::ThirtyTwoBytes) -> COption_PaymentHashZ { + COption_PaymentHashZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_PaymentHashZ containing nothing +pub extern "C" fn COption_PaymentHashZ_none() -> COption_PaymentHashZ { + COption_PaymentHashZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::c_types::ThirtyTwoBytes, if we are in the Some state +pub extern "C" fn COption_PaymentHashZ_free(_res: COption_PaymentHashZ) { } +#[no_mangle] +/// Creates a new COption_PaymentHashZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_PaymentHashZ_clone(orig: &COption_PaymentHashZ) -> COption_PaymentHashZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult__u832APIErrorZ +pub union CResult__u832APIErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::chain::keysinterface::SpendableOutputDescriptor, + pub result: *mut crate::c_types::ThirtyTwoBytes, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::lightning::util::errors::APIError, } #[repr(C)] -/// A CResult_SpendableOutputDescriptorDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::chain::keysinterface::SpendableOutputDescriptor on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult__u832APIErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::ThirtyTwoBytes on success and a crate::lightning::util::errors::APIError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_SpendableOutputDescriptorDecodeErrorZ { - /// The contents of this CResult_SpendableOutputDescriptorDecodeErrorZ, accessible via either +pub struct CResult__u832APIErrorZ { + /// The contents of this CResult__u832APIErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_SpendableOutputDescriptorDecodeErrorZPtr, - /// Whether this CResult_SpendableOutputDescriptorDecodeErrorZ represents a success state. + pub contents: CResult__u832APIErrorZPtr, + /// Whether this CResult__u832APIErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_SpendableOutputDescriptorDecodeErrorZ in the success state. -pub extern "C" fn CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o: crate::lightning::chain::keysinterface::SpendableOutputDescriptor) -> CResult_SpendableOutputDescriptorDecodeErrorZ { - CResult_SpendableOutputDescriptorDecodeErrorZ { - contents: CResult_SpendableOutputDescriptorDecodeErrorZPtr { +/// Creates a new CResult__u832APIErrorZ in the success state. +pub extern "C" fn CResult__u832APIErrorZ_ok(o: crate::c_types::ThirtyTwoBytes) -> CResult__u832APIErrorZ { + CResult__u832APIErrorZ { + contents: CResult__u832APIErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_SpendableOutputDescriptorDecodeErrorZ in the error state. -pub extern "C" fn CResult_SpendableOutputDescriptorDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_SpendableOutputDescriptorDecodeErrorZ { - CResult_SpendableOutputDescriptorDecodeErrorZ { - contents: CResult_SpendableOutputDescriptorDecodeErrorZPtr { +/// Creates a new CResult__u832APIErrorZ in the error state. +pub extern "C" fn CResult__u832APIErrorZ_err(e: crate::lightning::util::errors::APIError) -> CResult__u832APIErrorZ { + CResult__u832APIErrorZ { + contents: CResult__u832APIErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -7408,13 +7791,13 @@ pub extern "C" fn CResult_SpendableOutputDescriptorDecodeErrorZ_err(e: crate::li } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(o: &CResult_SpendableOutputDescriptorDecodeErrorZ) -> bool { +pub extern "C" fn CResult__u832APIErrorZ_is_ok(o: &CResult__u832APIErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_SpendableOutputDescriptorDecodeErrorZ. -pub extern "C" fn CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res: CResult_SpendableOutputDescriptorDecodeErrorZ) { } -impl Drop for CResult_SpendableOutputDescriptorDecodeErrorZ { +/// Frees any resources used by the CResult__u832APIErrorZ. +pub extern "C" fn CResult__u832APIErrorZ_free(_res: CResult__u832APIErrorZ) { } +impl Drop for CResult__u832APIErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -7427,16 +7810,16 @@ impl Drop for CResult_SpendableOutputDescriptorDecodeErrorZ { } } } -impl From> for CResult_SpendableOutputDescriptorDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult__u832APIErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_SpendableOutputDescriptorDecodeErrorZPtr { result } + CResult__u832APIErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_SpendableOutputDescriptorDecodeErrorZPtr { err } + CResult__u832APIErrorZPtr { err } }; Self { contents, @@ -7444,47 +7827,47 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_SpendableOutputDescriptorDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult__u832APIErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_SpendableOutputDescriptorDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult__u832APIErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_SpendableOutputDescriptorDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult__u832APIErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig: &CResult_SpendableOutputDescriptorDecodeErrorZ) -> CResult_SpendableOutputDescriptorDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult__u832APIErrorZ_clone(orig: &CResult__u832APIErrorZ) -> CResult__u832APIErrorZ { Clone::clone(&orig) } #[repr(C)] -/// A dynamically-allocated array of crate::c_types::ThirtyTwoBytess of arbitrary size. +/// A dynamically-allocated array of crate::lightning::ln::channelmanager::RecentPaymentDetailss of arbitrary size. /// This corresponds to std::vector in C++ -pub struct CVec_PaymentPreimageZ { +pub struct CVec_RecentPaymentDetailsZ { /// The elements in the array. /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::ThirtyTwoBytes, + pub data: *mut crate::lightning::ln::channelmanager::RecentPaymentDetails, /// The number of elements pointed to by `data`. pub datalen: usize } -impl CVec_PaymentPreimageZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { +impl CVec_RecentPaymentDetailsZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { if self.datalen == 0 { return Vec::new(); } let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); self.data = core::ptr::null_mut(); self.datalen = 0; ret } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::ThirtyTwoBytes] { + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::channelmanager::RecentPaymentDetails] { unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl From> for CVec_PaymentPreimageZ { - fn from(v: Vec) -> Self { +impl From> for CVec_RecentPaymentDetailsZ { + fn from(v: Vec) -> Self { let datalen = v.len(); let data = Box::into_raw(v.into_boxed_slice()); Self { datalen, data: unsafe { (*data).as_mut_ptr() } } @@ -7492,131 +7875,81 @@ impl From> for CVec_PaymentPreimageZ { } #[no_mangle] /// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_PaymentPreimageZ_free(_res: CVec_PaymentPreimageZ) { } -impl Drop for CVec_PaymentPreimageZ { +pub extern "C" fn CVec_RecentPaymentDetailsZ_free(_res: CVec_RecentPaymentDetailsZ) { } +impl Drop for CVec_RecentPaymentDetailsZ { fn drop(&mut self) { if self.datalen == 0 { return; } let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl Clone for CVec_PaymentPreimageZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} -#[repr(C)] -/// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple_SignatureCVec_SignatureZZ { - /// The element at position 0 - pub a: crate::c_types::Signature, - /// The element at position 1 - pub b: crate::c_types::derived::CVec_SignatureZ, -} -impl From<(crate::c_types::Signature, crate::c_types::derived::CVec_SignatureZ)> for C2Tuple_SignatureCVec_SignatureZZ { - fn from (tup: (crate::c_types::Signature, crate::c_types::derived::CVec_SignatureZ)) -> Self { - Self { - a: tup.0, - b: tup.1, - } - } -} -impl C2Tuple_SignatureCVec_SignatureZZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::Signature, crate::c_types::derived::CVec_SignatureZ) { - (self.a, self.b) - } -} -impl Clone for C2Tuple_SignatureCVec_SignatureZZ { - fn clone(&self) -> Self { - Self { - a: Clone::clone(&self.a), - b: Clone::clone(&self.b), - } - } -} -#[no_mangle] -/// Creates a new tuple which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C2Tuple_SignatureCVec_SignatureZZ_clone(orig: &C2Tuple_SignatureCVec_SignatureZZ) -> C2Tuple_SignatureCVec_SignatureZZ { Clone::clone(&orig) } -/// Creates a new C2Tuple_SignatureCVec_SignatureZZ from the contained elements. -#[no_mangle] -pub extern "C" fn C2Tuple_SignatureCVec_SignatureZZ_new(a: crate::c_types::Signature, b: crate::c_types::derived::CVec_SignatureZ) -> C2Tuple_SignatureCVec_SignatureZZ { - C2Tuple_SignatureCVec_SignatureZZ { a, b, } -} - -#[no_mangle] -/// Frees any resources used by the C2Tuple_SignatureCVec_SignatureZZ. -pub extern "C" fn C2Tuple_SignatureCVec_SignatureZZ_free(_res: C2Tuple_SignatureCVec_SignatureZZ) { } #[repr(C)] -/// The contents of CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ -pub union CResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::C2Tuple_SignatureCVec_SignatureZZ, - /// Note that this value is always NULL, as there are no contents in the Err variant - pub err: *mut core::ffi::c_void, +/// The contents of CResult_NonePaymentSendFailureZ +pub union CResult_NonePaymentSendFailureZPtr { + /// Note that this value is always NULL, as there are no contents in the OK variant + pub result: *mut core::ffi::c_void, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::outbound_payment::PaymentSendFailure, } #[repr(C)] -/// A CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::C2Tuple_SignatureCVec_SignatureZZ on success and a () on failure. +/// A CResult_NonePaymentSendFailureZ represents the result of a fallible operation, +/// containing a () on success and a crate::lightning::ln::outbound_payment::PaymentSendFailure on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { - /// The contents of this CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ, accessible via either +pub struct CResult_NonePaymentSendFailureZ { + /// The contents of this CResult_NonePaymentSendFailureZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr, - /// Whether this CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ represents a success state. + pub contents: CResult_NonePaymentSendFailureZPtr, + /// Whether this CResult_NonePaymentSendFailureZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ in the success state. -pub extern "C" fn CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o: crate::c_types::derived::C2Tuple_SignatureCVec_SignatureZZ) -> CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { - CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { - contents: CResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr { - result: Box::into_raw(Box::new(o)), +/// Creates a new CResult_NonePaymentSendFailureZ in the success state. +pub extern "C" fn CResult_NonePaymentSendFailureZ_ok() -> CResult_NonePaymentSendFailureZ { + CResult_NonePaymentSendFailureZ { + contents: CResult_NonePaymentSendFailureZPtr { + result: core::ptr::null_mut(), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ in the error state. -pub extern "C" fn CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err() -> CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { - CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { - contents: CResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr { - err: core::ptr::null_mut(), - }, - result_ok: false, - } -} +/// Creates a new CResult_NonePaymentSendFailureZ in the error state. +pub extern "C" fn CResult_NonePaymentSendFailureZ_err(e: crate::lightning::ln::outbound_payment::PaymentSendFailure) -> CResult_NonePaymentSendFailureZ { + CResult_NonePaymentSendFailureZ { + contents: CResult_NonePaymentSendFailureZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(o: &CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ) -> bool { +pub extern "C" fn CResult_NonePaymentSendFailureZ_is_ok(o: &CResult_NonePaymentSendFailureZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ. -pub extern "C" fn CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res: CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ) { } -impl Drop for CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { +/// Frees any resources used by the CResult_NonePaymentSendFailureZ. +pub extern "C" fn CResult_NonePaymentSendFailureZ_free(_res: CResult_NonePaymentSendFailureZ) { } +impl Drop for CResult_NonePaymentSendFailureZ { fn drop(&mut self) { if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } } } } -impl From> for CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_NonePaymentSendFailureZ { + fn from(mut o: crate::c_types::CResultTempl<(), crate::lightning::ln::outbound_payment::PaymentSendFailure>) -> Self { let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr { result } + let _ = unsafe { Box::from_raw(o.contents.result) }; + o.contents.result = core::ptr::null_mut(); + CResult_NonePaymentSendFailureZPtr { result: core::ptr::null_mut() } } else { - let _ = unsafe { Box::from_raw(o.contents.err) }; - o.contents.err = core::ptr::null_mut(); - CResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr { err: core::ptr::null_mut() } + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_NonePaymentSendFailureZPtr { err } }; Self { contents, @@ -7624,91 +7957,91 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_NonePaymentSendFailureZPtr { + result: core::ptr::null_mut() } } } else { - Self { result_ok: false, contents: CResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr { - err: core::ptr::null_mut() + Self { result_ok: false, contents: CResult_NonePaymentSendFailureZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ which has the same data as `orig` +/// Creates a new CResult_NonePaymentSendFailureZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig: &CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ) -> CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { Clone::clone(&orig) } +pub extern "C" fn CResult_NonePaymentSendFailureZ_clone(orig: &CResult_NonePaymentSendFailureZ) -> CResult_NonePaymentSendFailureZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_SignatureNoneZ -pub union CResult_SignatureNoneZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::Signature, - /// Note that this value is always NULL, as there are no contents in the Err variant - pub err: *mut core::ffi::c_void, +/// The contents of CResult_NoneRetryableSendFailureZ +pub union CResult_NoneRetryableSendFailureZPtr { + /// Note that this value is always NULL, as there are no contents in the OK variant + pub result: *mut core::ffi::c_void, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::outbound_payment::RetryableSendFailure, } #[repr(C)] -/// A CResult_SignatureNoneZ represents the result of a fallible operation, -/// containing a crate::c_types::Signature on success and a () on failure. +/// A CResult_NoneRetryableSendFailureZ represents the result of a fallible operation, +/// containing a () on success and a crate::lightning::ln::outbound_payment::RetryableSendFailure on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_SignatureNoneZ { - /// The contents of this CResult_SignatureNoneZ, accessible via either +pub struct CResult_NoneRetryableSendFailureZ { + /// The contents of this CResult_NoneRetryableSendFailureZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_SignatureNoneZPtr, - /// Whether this CResult_SignatureNoneZ represents a success state. + pub contents: CResult_NoneRetryableSendFailureZPtr, + /// Whether this CResult_NoneRetryableSendFailureZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_SignatureNoneZ in the success state. -pub extern "C" fn CResult_SignatureNoneZ_ok(o: crate::c_types::Signature) -> CResult_SignatureNoneZ { - CResult_SignatureNoneZ { - contents: CResult_SignatureNoneZPtr { - result: Box::into_raw(Box::new(o)), +/// Creates a new CResult_NoneRetryableSendFailureZ in the success state. +pub extern "C" fn CResult_NoneRetryableSendFailureZ_ok() -> CResult_NoneRetryableSendFailureZ { + CResult_NoneRetryableSendFailureZ { + contents: CResult_NoneRetryableSendFailureZPtr { + result: core::ptr::null_mut(), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_SignatureNoneZ in the error state. -pub extern "C" fn CResult_SignatureNoneZ_err() -> CResult_SignatureNoneZ { - CResult_SignatureNoneZ { - contents: CResult_SignatureNoneZPtr { - err: core::ptr::null_mut(), +/// Creates a new CResult_NoneRetryableSendFailureZ in the error state. +pub extern "C" fn CResult_NoneRetryableSendFailureZ_err(e: crate::lightning::ln::outbound_payment::RetryableSendFailure) -> CResult_NoneRetryableSendFailureZ { + CResult_NoneRetryableSendFailureZ { + contents: CResult_NoneRetryableSendFailureZPtr { + err: Box::into_raw(Box::new(e)), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_SignatureNoneZ_is_ok(o: &CResult_SignatureNoneZ) -> bool { +pub extern "C" fn CResult_NoneRetryableSendFailureZ_is_ok(o: &CResult_NoneRetryableSendFailureZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_SignatureNoneZ. -pub extern "C" fn CResult_SignatureNoneZ_free(_res: CResult_SignatureNoneZ) { } -impl Drop for CResult_SignatureNoneZ { +/// Frees any resources used by the CResult_NoneRetryableSendFailureZ. +pub extern "C" fn CResult_NoneRetryableSendFailureZ_free(_res: CResult_NoneRetryableSendFailureZ) { } +impl Drop for CResult_NoneRetryableSendFailureZ { fn drop(&mut self) { if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } } } } -impl From> for CResult_SignatureNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_NoneRetryableSendFailureZ { + fn from(mut o: crate::c_types::CResultTempl<(), crate::lightning::ln::outbound_payment::RetryableSendFailure>) -> Self { let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_SignatureNoneZPtr { result } + let _ = unsafe { Box::from_raw(o.contents.result) }; + o.contents.result = core::ptr::null_mut(); + CResult_NoneRetryableSendFailureZPtr { result: core::ptr::null_mut() } } else { - let _ = unsafe { Box::from_raw(o.contents.err) }; - o.contents.err = core::ptr::null_mut(); - CResult_SignatureNoneZPtr { err: core::ptr::null_mut() } + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_NoneRetryableSendFailureZPtr { err } }; Self { contents, @@ -7716,91 +8049,95 @@ impl From> for CResu } } } -impl Clone for CResult_SignatureNoneZ { +impl Clone for CResult_NoneRetryableSendFailureZ { fn clone(&self) -> Self { if self.result_ok { - Self { result_ok: true, contents: CResult_SignatureNoneZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_NoneRetryableSendFailureZPtr { + result: core::ptr::null_mut() } } } else { - Self { result_ok: false, contents: CResult_SignatureNoneZPtr { - err: core::ptr::null_mut() + Self { result_ok: false, contents: CResult_NoneRetryableSendFailureZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_SignatureNoneZ which has the same data as `orig` +/// Creates a new CResult_NoneRetryableSendFailureZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_SignatureNoneZ_clone(orig: &CResult_SignatureNoneZ) -> CResult_SignatureNoneZ { Clone::clone(&orig) } +pub extern "C" fn CResult_NoneRetryableSendFailureZ_clone(orig: &CResult_NoneRetryableSendFailureZ) -> CResult_NoneRetryableSendFailureZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_PublicKeyNoneZ -pub union CResult_PublicKeyNoneZPtr { +/// The contents of CResult_PaymentHashPaymentSendFailureZ +pub union CResult_PaymentHashPaymentSendFailureZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::PublicKey, - /// Note that this value is always NULL, as there are no contents in the Err variant - pub err: *mut core::ffi::c_void, + pub result: *mut crate::c_types::ThirtyTwoBytes, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::outbound_payment::PaymentSendFailure, } #[repr(C)] -/// A CResult_PublicKeyNoneZ represents the result of a fallible operation, -/// containing a crate::c_types::PublicKey on success and a () on failure. +/// A CResult_PaymentHashPaymentSendFailureZ represents the result of a fallible operation, +/// containing a crate::c_types::ThirtyTwoBytes on success and a crate::lightning::ln::outbound_payment::PaymentSendFailure on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_PublicKeyNoneZ { - /// The contents of this CResult_PublicKeyNoneZ, accessible via either +pub struct CResult_PaymentHashPaymentSendFailureZ { + /// The contents of this CResult_PaymentHashPaymentSendFailureZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_PublicKeyNoneZPtr, - /// Whether this CResult_PublicKeyNoneZ represents a success state. + pub contents: CResult_PaymentHashPaymentSendFailureZPtr, + /// Whether this CResult_PaymentHashPaymentSendFailureZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_PublicKeyNoneZ in the success state. -pub extern "C" fn CResult_PublicKeyNoneZ_ok(o: crate::c_types::PublicKey) -> CResult_PublicKeyNoneZ { - CResult_PublicKeyNoneZ { - contents: CResult_PublicKeyNoneZPtr { +/// Creates a new CResult_PaymentHashPaymentSendFailureZ in the success state. +pub extern "C" fn CResult_PaymentHashPaymentSendFailureZ_ok(o: crate::c_types::ThirtyTwoBytes) -> CResult_PaymentHashPaymentSendFailureZ { + CResult_PaymentHashPaymentSendFailureZ { + contents: CResult_PaymentHashPaymentSendFailureZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_PublicKeyNoneZ in the error state. -pub extern "C" fn CResult_PublicKeyNoneZ_err() -> CResult_PublicKeyNoneZ { - CResult_PublicKeyNoneZ { - contents: CResult_PublicKeyNoneZPtr { - err: core::ptr::null_mut(), +/// Creates a new CResult_PaymentHashPaymentSendFailureZ in the error state. +pub extern "C" fn CResult_PaymentHashPaymentSendFailureZ_err(e: crate::lightning::ln::outbound_payment::PaymentSendFailure) -> CResult_PaymentHashPaymentSendFailureZ { + CResult_PaymentHashPaymentSendFailureZ { + contents: CResult_PaymentHashPaymentSendFailureZPtr { + err: Box::into_raw(Box::new(e)), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_PublicKeyNoneZ_is_ok(o: &CResult_PublicKeyNoneZ) -> bool { +pub extern "C" fn CResult_PaymentHashPaymentSendFailureZ_is_ok(o: &CResult_PaymentHashPaymentSendFailureZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_PublicKeyNoneZ. -pub extern "C" fn CResult_PublicKeyNoneZ_free(_res: CResult_PublicKeyNoneZ) { } -impl Drop for CResult_PublicKeyNoneZ { +/// Frees any resources used by the CResult_PaymentHashPaymentSendFailureZ. +pub extern "C" fn CResult_PaymentHashPaymentSendFailureZ_free(_res: CResult_PaymentHashPaymentSendFailureZ) { } +impl Drop for CResult_PaymentHashPaymentSendFailureZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } } } } -impl From> for CResult_PublicKeyNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_PaymentHashPaymentSendFailureZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_PublicKeyNoneZPtr { result } + CResult_PaymentHashPaymentSendFailureZPtr { result } } else { - let _ = unsafe { Box::from_raw(o.contents.err) }; - o.contents.err = core::ptr::null_mut(); - CResult_PublicKeyNoneZPtr { err: core::ptr::null_mut() } + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_PaymentHashPaymentSendFailureZPtr { err } }; Self { contents, @@ -7808,128 +8145,95 @@ impl From> for CResu } } } -impl Clone for CResult_PublicKeyNoneZ { +impl Clone for CResult_PaymentHashPaymentSendFailureZ { fn clone(&self) -> Self { if self.result_ok { - Self { result_ok: true, contents: CResult_PublicKeyNoneZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_PaymentHashPaymentSendFailureZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_PublicKeyNoneZPtr { - err: core::ptr::null_mut() + Self { result_ok: false, contents: CResult_PaymentHashPaymentSendFailureZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_PublicKeyNoneZ which has the same data as `orig` +/// Creates a new CResult_PaymentHashPaymentSendFailureZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_PublicKeyNoneZ_clone(orig: &CResult_PublicKeyNoneZ) -> CResult_PublicKeyNoneZ { Clone::clone(&orig) } +pub extern "C" fn CResult_PaymentHashPaymentSendFailureZ_clone(orig: &CResult_PaymentHashPaymentSendFailureZ) -> CResult_PaymentHashPaymentSendFailureZ { Clone::clone(&orig) } #[repr(C)] -#[derive(Clone)] -/// An enum which can either contain a crate::c_types::BigEndianScalar or not -pub enum COption_ScalarZ { - /// When we're in this state, this COption_ScalarZ contains a crate::c_types::BigEndianScalar - Some(crate::c_types::BigEndianScalar), - /// When we're in this state, this COption_ScalarZ contains nothing - None +/// The contents of CResult_PaymentHashRetryableSendFailureZ +pub union CResult_PaymentHashRetryableSendFailureZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::c_types::ThirtyTwoBytes, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::outbound_payment::RetryableSendFailure, } -impl COption_ScalarZ { - #[allow(unused)] pub(crate) fn is_some(&self) -> bool { - if let Self::None = self { false } else { true } - } - #[allow(unused)] pub(crate) fn is_none(&self) -> bool { - !self.is_some() - } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::BigEndianScalar { - if let Self::Some(v) = self { v } else { unreachable!() } - } +#[repr(C)] +/// A CResult_PaymentHashRetryableSendFailureZ represents the result of a fallible operation, +/// containing a crate::c_types::ThirtyTwoBytes on success and a crate::lightning::ln::outbound_payment::RetryableSendFailure on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_PaymentHashRetryableSendFailureZ { + /// The contents of this CResult_PaymentHashRetryableSendFailureZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_PaymentHashRetryableSendFailureZPtr, + /// Whether this CResult_PaymentHashRetryableSendFailureZ represents a success state. + pub result_ok: bool, } #[no_mangle] -/// Constructs a new COption_ScalarZ containing a crate::c_types::BigEndianScalar -pub extern "C" fn COption_ScalarZ_some(o: crate::c_types::BigEndianScalar) -> COption_ScalarZ { - COption_ScalarZ::Some(o) -} -#[no_mangle] -/// Constructs a new COption_ScalarZ containing nothing -pub extern "C" fn COption_ScalarZ_none() -> COption_ScalarZ { - COption_ScalarZ::None -} -#[no_mangle] -/// Frees any resources associated with the crate::c_types::BigEndianScalar, if we are in the Some state -pub extern "C" fn COption_ScalarZ_free(_res: COption_ScalarZ) { } -#[no_mangle] -/// Creates a new COption_ScalarZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_ScalarZ_clone(orig: &COption_ScalarZ) -> COption_ScalarZ { Clone::clone(&orig) } -#[repr(C)] -/// The contents of CResult_SharedSecretNoneZ -pub union CResult_SharedSecretNoneZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::ThirtyTwoBytes, - /// Note that this value is always NULL, as there are no contents in the Err variant - pub err: *mut core::ffi::c_void, -} -#[repr(C)] -/// A CResult_SharedSecretNoneZ represents the result of a fallible operation, -/// containing a crate::c_types::ThirtyTwoBytes on success and a () on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_SharedSecretNoneZ { - /// The contents of this CResult_SharedSecretNoneZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_SharedSecretNoneZPtr, - /// Whether this CResult_SharedSecretNoneZ represents a success state. - pub result_ok: bool, -} -#[no_mangle] -/// Creates a new CResult_SharedSecretNoneZ in the success state. -pub extern "C" fn CResult_SharedSecretNoneZ_ok(o: crate::c_types::ThirtyTwoBytes) -> CResult_SharedSecretNoneZ { - CResult_SharedSecretNoneZ { - contents: CResult_SharedSecretNoneZPtr { +/// Creates a new CResult_PaymentHashRetryableSendFailureZ in the success state. +pub extern "C" fn CResult_PaymentHashRetryableSendFailureZ_ok(o: crate::c_types::ThirtyTwoBytes) -> CResult_PaymentHashRetryableSendFailureZ { + CResult_PaymentHashRetryableSendFailureZ { + contents: CResult_PaymentHashRetryableSendFailureZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_SharedSecretNoneZ in the error state. -pub extern "C" fn CResult_SharedSecretNoneZ_err() -> CResult_SharedSecretNoneZ { - CResult_SharedSecretNoneZ { - contents: CResult_SharedSecretNoneZPtr { - err: core::ptr::null_mut(), +/// Creates a new CResult_PaymentHashRetryableSendFailureZ in the error state. +pub extern "C" fn CResult_PaymentHashRetryableSendFailureZ_err(e: crate::lightning::ln::outbound_payment::RetryableSendFailure) -> CResult_PaymentHashRetryableSendFailureZ { + CResult_PaymentHashRetryableSendFailureZ { + contents: CResult_PaymentHashRetryableSendFailureZPtr { + err: Box::into_raw(Box::new(e)), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_SharedSecretNoneZ_is_ok(o: &CResult_SharedSecretNoneZ) -> bool { +pub extern "C" fn CResult_PaymentHashRetryableSendFailureZ_is_ok(o: &CResult_PaymentHashRetryableSendFailureZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_SharedSecretNoneZ. -pub extern "C" fn CResult_SharedSecretNoneZ_free(_res: CResult_SharedSecretNoneZ) { } -impl Drop for CResult_SharedSecretNoneZ { +/// Frees any resources used by the CResult_PaymentHashRetryableSendFailureZ. +pub extern "C" fn CResult_PaymentHashRetryableSendFailureZ_free(_res: CResult_PaymentHashRetryableSendFailureZ) { } +impl Drop for CResult_PaymentHashRetryableSendFailureZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } } } } -impl From> for CResult_SharedSecretNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_PaymentHashRetryableSendFailureZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_SharedSecretNoneZPtr { result } + CResult_PaymentHashRetryableSendFailureZPtr { result } } else { - let _ = unsafe { Box::from_raw(o.contents.err) }; - o.contents.err = core::ptr::null_mut(); - CResult_SharedSecretNoneZPtr { err: core::ptr::null_mut() } + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_PaymentHashRetryableSendFailureZPtr { err } }; Self { contents, @@ -7937,137 +8241,137 @@ impl From> for } } } -impl Clone for CResult_SharedSecretNoneZ { +impl Clone for CResult_PaymentHashRetryableSendFailureZ { fn clone(&self) -> Self { if self.result_ok { - Self { result_ok: true, contents: CResult_SharedSecretNoneZPtr { + Self { result_ok: true, contents: CResult_PaymentHashRetryableSendFailureZPtr { result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_SharedSecretNoneZPtr { - err: core::ptr::null_mut() + Self { result_ok: false, contents: CResult_PaymentHashRetryableSendFailureZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_SharedSecretNoneZ which has the same data as `orig` +/// Creates a new CResult_PaymentHashRetryableSendFailureZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_SharedSecretNoneZ_clone(orig: &CResult_SharedSecretNoneZ) -> CResult_SharedSecretNoneZ { Clone::clone(&orig) } +pub extern "C" fn CResult_PaymentHashRetryableSendFailureZ_clone(orig: &CResult_PaymentHashRetryableSendFailureZ) -> CResult_PaymentHashRetryableSendFailureZ { Clone::clone(&orig) } #[repr(C)] -/// A dynamically-allocated array of crate::c_types::U5s of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_U5Z { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::U5, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_U5Z { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::U5] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_PaymentHashPaymentIdZ { + /// The element at position 0 + pub a: crate::c_types::ThirtyTwoBytes, + /// The element at position 1 + pub b: crate::c_types::ThirtyTwoBytes, } -impl From> for CVec_U5Z { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } +impl From<(crate::c_types::ThirtyTwoBytes, crate::c_types::ThirtyTwoBytes)> for C2Tuple_PaymentHashPaymentIdZ { + fn from (tup: (crate::c_types::ThirtyTwoBytes, crate::c_types::ThirtyTwoBytes)) -> Self { + Self { + a: tup.0, + b: tup.1, + } } } -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_U5Z_free(_res: CVec_U5Z) { } -impl Drop for CVec_U5Z { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; +impl C2Tuple_PaymentHashPaymentIdZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoBytes, crate::c_types::ThirtyTwoBytes) { + (self.a, self.b) } } -impl Clone for CVec_U5Z { +impl Clone for C2Tuple_PaymentHashPaymentIdZ { fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), + } } } +#[no_mangle] +/// Creates a new tuple which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn C2Tuple_PaymentHashPaymentIdZ_clone(orig: &C2Tuple_PaymentHashPaymentIdZ) -> C2Tuple_PaymentHashPaymentIdZ { Clone::clone(&orig) } +/// Creates a new C2Tuple_PaymentHashPaymentIdZ from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_PaymentHashPaymentIdZ_new(a: crate::c_types::ThirtyTwoBytes, b: crate::c_types::ThirtyTwoBytes) -> C2Tuple_PaymentHashPaymentIdZ { + C2Tuple_PaymentHashPaymentIdZ { a, b, } +} + +#[no_mangle] +/// Frees any resources used by the C2Tuple_PaymentHashPaymentIdZ. +pub extern "C" fn C2Tuple_PaymentHashPaymentIdZ_free(_res: C2Tuple_PaymentHashPaymentIdZ) { } #[repr(C)] -/// The contents of CResult_RecoverableSignatureNoneZ -pub union CResult_RecoverableSignatureNoneZPtr { +/// The contents of CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ +pub union CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::RecoverableSignature, - /// Note that this value is always NULL, as there are no contents in the Err variant - pub err: *mut core::ffi::c_void, + pub result: *mut crate::c_types::derived::C2Tuple_PaymentHashPaymentIdZ, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::outbound_payment::PaymentSendFailure, } #[repr(C)] -/// A CResult_RecoverableSignatureNoneZ represents the result of a fallible operation, -/// containing a crate::c_types::RecoverableSignature on success and a () on failure. +/// A CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::C2Tuple_PaymentHashPaymentIdZ on success and a crate::lightning::ln::outbound_payment::PaymentSendFailure on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_RecoverableSignatureNoneZ { - /// The contents of this CResult_RecoverableSignatureNoneZ, accessible via either +pub struct CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ { + /// The contents of this CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_RecoverableSignatureNoneZPtr, - /// Whether this CResult_RecoverableSignatureNoneZ represents a success state. + pub contents: CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZPtr, + /// Whether this CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_RecoverableSignatureNoneZ in the success state. -pub extern "C" fn CResult_RecoverableSignatureNoneZ_ok(o: crate::c_types::RecoverableSignature) -> CResult_RecoverableSignatureNoneZ { - CResult_RecoverableSignatureNoneZ { - contents: CResult_RecoverableSignatureNoneZPtr { +/// Creates a new CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ in the success state. +pub extern "C" fn CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(o: crate::c_types::derived::C2Tuple_PaymentHashPaymentIdZ) -> CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ { + CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ { + contents: CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_RecoverableSignatureNoneZ in the error state. -pub extern "C" fn CResult_RecoverableSignatureNoneZ_err() -> CResult_RecoverableSignatureNoneZ { - CResult_RecoverableSignatureNoneZ { - contents: CResult_RecoverableSignatureNoneZPtr { - err: core::ptr::null_mut(), +/// Creates a new CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ in the error state. +pub extern "C" fn CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(e: crate::lightning::ln::outbound_payment::PaymentSendFailure) -> CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ { + CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ { + contents: CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZPtr { + err: Box::into_raw(Box::new(e)), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_RecoverableSignatureNoneZ_is_ok(o: &CResult_RecoverableSignatureNoneZ) -> bool { +pub extern "C" fn CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(o: &CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_RecoverableSignatureNoneZ. -pub extern "C" fn CResult_RecoverableSignatureNoneZ_free(_res: CResult_RecoverableSignatureNoneZ) { } -impl Drop for CResult_RecoverableSignatureNoneZ { +/// Frees any resources used by the CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ. +pub extern "C" fn CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(_res: CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ) { } +impl Drop for CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } } } } -impl From> for CResult_RecoverableSignatureNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_RecoverableSignatureNoneZPtr { result } + CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZPtr { result } } else { - let _ = unsafe { Box::from_raw(o.contents.err) }; - o.contents.err = core::ptr::null_mut(); - CResult_RecoverableSignatureNoneZPtr { err: core::ptr::null_mut() } + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZPtr { err } }; Self { contents, @@ -8075,126 +8379,47 @@ impl From } } } -impl Clone for CResult_RecoverableSignatureNoneZ { +impl Clone for CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ { fn clone(&self) -> Self { if self.result_ok { - Self { result_ok: true, contents: CResult_RecoverableSignatureNoneZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_RecoverableSignatureNoneZPtr { - err: core::ptr::null_mut() + Self { result_ok: false, contents: CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_RecoverableSignatureNoneZ which has the same data as `orig` +/// Creates a new CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_RecoverableSignatureNoneZ_clone(orig: &CResult_RecoverableSignatureNoneZ) -> CResult_RecoverableSignatureNoneZ { Clone::clone(&orig) } +pub extern "C" fn CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(orig: &CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ) -> CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_WriteableEcdsaChannelSignerDecodeErrorZ -pub union CResult_WriteableEcdsaChannelSignerDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::chain::keysinterface::WriteableEcdsaChannelSigner, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, +/// A dynamically-allocated array of crate::c_types::ThirtyTwoBytess of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_ThirtyTwoBytesZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::ThirtyTwoBytes, + /// The number of elements pointed to by `data`. + pub datalen: usize } -#[repr(C)] -/// A CResult_WriteableEcdsaChannelSignerDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::chain::keysinterface::WriteableEcdsaChannelSigner on success and a crate::lightning::ln::msgs::DecodeError on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_WriteableEcdsaChannelSignerDecodeErrorZ { - /// The contents of this CResult_WriteableEcdsaChannelSignerDecodeErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_WriteableEcdsaChannelSignerDecodeErrorZPtr, - /// Whether this CResult_WriteableEcdsaChannelSignerDecodeErrorZ represents a success state. - pub result_ok: bool, -} -#[no_mangle] -/// Creates a new CResult_WriteableEcdsaChannelSignerDecodeErrorZ in the success state. -pub extern "C" fn CResult_WriteableEcdsaChannelSignerDecodeErrorZ_ok(o: crate::lightning::chain::keysinterface::WriteableEcdsaChannelSigner) -> CResult_WriteableEcdsaChannelSignerDecodeErrorZ { - CResult_WriteableEcdsaChannelSignerDecodeErrorZ { - contents: CResult_WriteableEcdsaChannelSignerDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, - } -} -#[no_mangle] -/// Creates a new CResult_WriteableEcdsaChannelSignerDecodeErrorZ in the error state. -pub extern "C" fn CResult_WriteableEcdsaChannelSignerDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_WriteableEcdsaChannelSignerDecodeErrorZ { - CResult_WriteableEcdsaChannelSignerDecodeErrorZ { - contents: CResult_WriteableEcdsaChannelSignerDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), - }, - result_ok: false, - } -} -/// Checks if the given object is currently in the success state -#[no_mangle] -pub extern "C" fn CResult_WriteableEcdsaChannelSignerDecodeErrorZ_is_ok(o: &CResult_WriteableEcdsaChannelSignerDecodeErrorZ) -> bool { - o.result_ok -} -#[no_mangle] -/// Frees any resources used by the CResult_WriteableEcdsaChannelSignerDecodeErrorZ. -pub extern "C" fn CResult_WriteableEcdsaChannelSignerDecodeErrorZ_free(_res: CResult_WriteableEcdsaChannelSignerDecodeErrorZ) { } -impl Drop for CResult_WriteableEcdsaChannelSignerDecodeErrorZ { - fn drop(&mut self) { - if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } - } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } - } - } -} -impl From> for CResult_WriteableEcdsaChannelSignerDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { - let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_WriteableEcdsaChannelSignerDecodeErrorZPtr { result } - } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_WriteableEcdsaChannelSignerDecodeErrorZPtr { err } - }; - Self { - contents, - result_ok: o.result_ok, - } - } -} -#[repr(C)] -/// A dynamically-allocated array of crate::c_types::derived::CVec_u8Zs of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_CVec_u8ZZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::derived::CVec_u8Z, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_CVec_u8ZZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { +impl CVec_ThirtyTwoBytesZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { if self.datalen == 0 { return Vec::new(); } let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); self.data = core::ptr::null_mut(); self.datalen = 0; ret } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::CVec_u8Z] { + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::ThirtyTwoBytes] { unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl From> for CVec_CVec_u8ZZ { - fn from(v: Vec) -> Self { +impl From> for CVec_ThirtyTwoBytesZ { + fn from(v: Vec) -> Self { let datalen = v.len(); let data = Box::into_raw(v.into_boxed_slice()); Self { datalen, data: unsafe { (*data).as_mut_ptr() } } @@ -8202,14 +8427,14 @@ impl From> for CVec_CVec_u8ZZ { } #[no_mangle] /// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_CVec_u8ZZ_free(_res: CVec_CVec_u8ZZ) { } -impl Drop for CVec_CVec_u8ZZ { +pub extern "C" fn CVec_ThirtyTwoBytesZ_free(_res: CVec_ThirtyTwoBytesZ) { } +impl Drop for CVec_ThirtyTwoBytesZ { fn drop(&mut self) { if self.datalen == 0 { return; } let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl Clone for CVec_CVec_u8ZZ { +impl Clone for CVec_ThirtyTwoBytesZ { fn clone(&self) -> Self { let mut res = Vec::new(); if self.datalen == 0 { return Self::from(res); } @@ -8218,40 +8443,82 @@ impl Clone for CVec_CVec_u8ZZ { } } #[repr(C)] -/// The contents of CResult_CVec_CVec_u8ZZNoneZ -pub union CResult_CVec_CVec_u8ZZNoneZPtr { +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_PaymentHashPaymentSecretZ { + /// The element at position 0 + pub a: crate::c_types::ThirtyTwoBytes, + /// The element at position 1 + pub b: crate::c_types::ThirtyTwoBytes, +} +impl From<(crate::c_types::ThirtyTwoBytes, crate::c_types::ThirtyTwoBytes)> for C2Tuple_PaymentHashPaymentSecretZ { + fn from (tup: (crate::c_types::ThirtyTwoBytes, crate::c_types::ThirtyTwoBytes)) -> Self { + Self { + a: tup.0, + b: tup.1, + } + } +} +impl C2Tuple_PaymentHashPaymentSecretZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoBytes, crate::c_types::ThirtyTwoBytes) { + (self.a, self.b) + } +} +impl Clone for C2Tuple_PaymentHashPaymentSecretZ { + fn clone(&self) -> Self { + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), + } + } +} +#[no_mangle] +/// Creates a new tuple which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn C2Tuple_PaymentHashPaymentSecretZ_clone(orig: &C2Tuple_PaymentHashPaymentSecretZ) -> C2Tuple_PaymentHashPaymentSecretZ { Clone::clone(&orig) } +/// Creates a new C2Tuple_PaymentHashPaymentSecretZ from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_PaymentHashPaymentSecretZ_new(a: crate::c_types::ThirtyTwoBytes, b: crate::c_types::ThirtyTwoBytes) -> C2Tuple_PaymentHashPaymentSecretZ { + C2Tuple_PaymentHashPaymentSecretZ { a, b, } +} + +#[no_mangle] +/// Frees any resources used by the C2Tuple_PaymentHashPaymentSecretZ. +pub extern "C" fn C2Tuple_PaymentHashPaymentSecretZ_free(_res: C2Tuple_PaymentHashPaymentSecretZ) { } +#[repr(C)] +/// The contents of CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ +pub union CResult_C2Tuple_PaymentHashPaymentSecretZNoneZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::CVec_CVec_u8ZZ, + pub result: *mut crate::c_types::derived::C2Tuple_PaymentHashPaymentSecretZ, /// Note that this value is always NULL, as there are no contents in the Err variant pub err: *mut core::ffi::c_void, } #[repr(C)] -/// A CResult_CVec_CVec_u8ZZNoneZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::CVec_CVec_u8ZZ on success and a () on failure. +/// A CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::C2Tuple_PaymentHashPaymentSecretZ on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_CVec_CVec_u8ZZNoneZ { - /// The contents of this CResult_CVec_CVec_u8ZZNoneZ, accessible via either +pub struct CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ { + /// The contents of this CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_CVec_CVec_u8ZZNoneZPtr, - /// Whether this CResult_CVec_CVec_u8ZZNoneZ represents a success state. + pub contents: CResult_C2Tuple_PaymentHashPaymentSecretZNoneZPtr, + /// Whether this CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_CVec_CVec_u8ZZNoneZ in the success state. -pub extern "C" fn CResult_CVec_CVec_u8ZZNoneZ_ok(o: crate::c_types::derived::CVec_CVec_u8ZZ) -> CResult_CVec_CVec_u8ZZNoneZ { - CResult_CVec_CVec_u8ZZNoneZ { - contents: CResult_CVec_CVec_u8ZZNoneZPtr { +/// Creates a new CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ in the success state. +pub extern "C" fn CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(o: crate::c_types::derived::C2Tuple_PaymentHashPaymentSecretZ) -> CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ { + CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ { + contents: CResult_C2Tuple_PaymentHashPaymentSecretZNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_CVec_CVec_u8ZZNoneZ in the error state. -pub extern "C" fn CResult_CVec_CVec_u8ZZNoneZ_err() -> CResult_CVec_CVec_u8ZZNoneZ { - CResult_CVec_CVec_u8ZZNoneZ { - contents: CResult_CVec_CVec_u8ZZNoneZPtr { +/// Creates a new CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ in the error state. +pub extern "C" fn CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err() -> CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ { + CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ { + contents: CResult_C2Tuple_PaymentHashPaymentSecretZNoneZPtr { err: core::ptr::null_mut(), }, result_ok: false, @@ -8259,13 +8526,13 @@ pub extern "C" fn CResult_CVec_CVec_u8ZZNoneZ_err() -> CResult_CVec_CVec_u8ZZNon } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_CVec_CVec_u8ZZNoneZ_is_ok(o: &CResult_CVec_CVec_u8ZZNoneZ) -> bool { +pub extern "C" fn CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(o: &CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_CVec_CVec_u8ZZNoneZ. -pub extern "C" fn CResult_CVec_CVec_u8ZZNoneZ_free(_res: CResult_CVec_CVec_u8ZZNoneZ) { } -impl Drop for CResult_CVec_CVec_u8ZZNoneZ { +/// Frees any resources used by the CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ. +pub extern "C" fn CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(_res: CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ) { } +impl Drop for CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -8275,16 +8542,16 @@ impl Drop for CResult_CVec_CVec_u8ZZNoneZ { } } } -impl From> for CResult_CVec_CVec_u8ZZNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_CVec_CVec_u8ZZNoneZPtr { result } + CResult_C2Tuple_PaymentHashPaymentSecretZNoneZPtr { result } } else { let _ = unsafe { Box::from_raw(o.contents.err) }; o.contents.err = core::ptr::null_mut(); - CResult_CVec_CVec_u8ZZNoneZPtr { err: core::ptr::null_mut() } + CResult_C2Tuple_PaymentHashPaymentSecretZNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -8292,95 +8559,91 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_CVec_CVec_u8ZZNoneZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_C2Tuple_PaymentHashPaymentSecretZNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_CVec_CVec_u8ZZNoneZPtr { + Self { result_ok: false, contents: CResult_C2Tuple_PaymentHashPaymentSecretZNoneZPtr { err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_CVec_CVec_u8ZZNoneZ which has the same data as `orig` +/// Creates a new CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_CVec_CVec_u8ZZNoneZ_clone(orig: &CResult_CVec_CVec_u8ZZNoneZ) -> CResult_CVec_CVec_u8ZZNoneZ { Clone::clone(&orig) } +pub extern "C" fn CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(orig: &CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ) -> CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_InMemorySignerDecodeErrorZ -pub union CResult_InMemorySignerDecodeErrorZPtr { +/// The contents of CResult_PaymentSecretNoneZ +pub union CResult_PaymentSecretNoneZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::chain::keysinterface::InMemorySigner, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub result: *mut crate::c_types::ThirtyTwoBytes, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut core::ffi::c_void, } #[repr(C)] -/// A CResult_InMemorySignerDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::chain::keysinterface::InMemorySigner on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_PaymentSecretNoneZ represents the result of a fallible operation, +/// containing a crate::c_types::ThirtyTwoBytes on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_InMemorySignerDecodeErrorZ { - /// The contents of this CResult_InMemorySignerDecodeErrorZ, accessible via either +pub struct CResult_PaymentSecretNoneZ { + /// The contents of this CResult_PaymentSecretNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_InMemorySignerDecodeErrorZPtr, - /// Whether this CResult_InMemorySignerDecodeErrorZ represents a success state. + pub contents: CResult_PaymentSecretNoneZPtr, + /// Whether this CResult_PaymentSecretNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_InMemorySignerDecodeErrorZ in the success state. -pub extern "C" fn CResult_InMemorySignerDecodeErrorZ_ok(o: crate::lightning::chain::keysinterface::InMemorySigner) -> CResult_InMemorySignerDecodeErrorZ { - CResult_InMemorySignerDecodeErrorZ { - contents: CResult_InMemorySignerDecodeErrorZPtr { +/// Creates a new CResult_PaymentSecretNoneZ in the success state. +pub extern "C" fn CResult_PaymentSecretNoneZ_ok(o: crate::c_types::ThirtyTwoBytes) -> CResult_PaymentSecretNoneZ { + CResult_PaymentSecretNoneZ { + contents: CResult_PaymentSecretNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_InMemorySignerDecodeErrorZ in the error state. -pub extern "C" fn CResult_InMemorySignerDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_InMemorySignerDecodeErrorZ { - CResult_InMemorySignerDecodeErrorZ { - contents: CResult_InMemorySignerDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), +/// Creates a new CResult_PaymentSecretNoneZ in the error state. +pub extern "C" fn CResult_PaymentSecretNoneZ_err() -> CResult_PaymentSecretNoneZ { + CResult_PaymentSecretNoneZ { + contents: CResult_PaymentSecretNoneZPtr { + err: core::ptr::null_mut(), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_InMemorySignerDecodeErrorZ_is_ok(o: &CResult_InMemorySignerDecodeErrorZ) -> bool { +pub extern "C" fn CResult_PaymentSecretNoneZ_is_ok(o: &CResult_PaymentSecretNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_InMemorySignerDecodeErrorZ. -pub extern "C" fn CResult_InMemorySignerDecodeErrorZ_free(_res: CResult_InMemorySignerDecodeErrorZ) { } -impl Drop for CResult_InMemorySignerDecodeErrorZ { +/// Frees any resources used by the CResult_PaymentSecretNoneZ. +pub extern "C" fn CResult_PaymentSecretNoneZ_free(_res: CResult_PaymentSecretNoneZ) { } +impl Drop for CResult_PaymentSecretNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } } } } -impl From> for CResult_InMemorySignerDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_PaymentSecretNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_InMemorySignerDecodeErrorZPtr { result } + CResult_PaymentSecretNoneZPtr { result } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_InMemorySignerDecodeErrorZPtr { err } + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_PaymentSecretNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -8388,137 +8651,95 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_InMemorySignerDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_PaymentSecretNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_InMemorySignerDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_PaymentSecretNoneZPtr { + err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_InMemorySignerDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_PaymentSecretNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_InMemorySignerDecodeErrorZ_clone(orig: &CResult_InMemorySignerDecodeErrorZ) -> CResult_InMemorySignerDecodeErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// A dynamically-allocated array of crate::c_types::TxOuts of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_TxOutZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::TxOut, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_TxOutZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::TxOut] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_TxOutZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_TxOutZ_free(_res: CVec_TxOutZ) { } -impl Drop for CVec_TxOutZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_TxOutZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} +pub extern "C" fn CResult_PaymentSecretNoneZ_clone(orig: &CResult_PaymentSecretNoneZ) -> CResult_PaymentSecretNoneZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_TransactionNoneZ -pub union CResult_TransactionNoneZPtr { +/// The contents of CResult_PaymentPreimageAPIErrorZ +pub union CResult_PaymentPreimageAPIErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::Transaction, - /// Note that this value is always NULL, as there are no contents in the Err variant - pub err: *mut core::ffi::c_void, + pub result: *mut crate::c_types::ThirtyTwoBytes, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::util::errors::APIError, } #[repr(C)] -/// A CResult_TransactionNoneZ represents the result of a fallible operation, -/// containing a crate::c_types::Transaction on success and a () on failure. +/// A CResult_PaymentPreimageAPIErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::ThirtyTwoBytes on success and a crate::lightning::util::errors::APIError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_TransactionNoneZ { - /// The contents of this CResult_TransactionNoneZ, accessible via either +pub struct CResult_PaymentPreimageAPIErrorZ { + /// The contents of this CResult_PaymentPreimageAPIErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_TransactionNoneZPtr, - /// Whether this CResult_TransactionNoneZ represents a success state. + pub contents: CResult_PaymentPreimageAPIErrorZPtr, + /// Whether this CResult_PaymentPreimageAPIErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_TransactionNoneZ in the success state. -pub extern "C" fn CResult_TransactionNoneZ_ok(o: crate::c_types::Transaction) -> CResult_TransactionNoneZ { - CResult_TransactionNoneZ { - contents: CResult_TransactionNoneZPtr { +/// Creates a new CResult_PaymentPreimageAPIErrorZ in the success state. +pub extern "C" fn CResult_PaymentPreimageAPIErrorZ_ok(o: crate::c_types::ThirtyTwoBytes) -> CResult_PaymentPreimageAPIErrorZ { + CResult_PaymentPreimageAPIErrorZ { + contents: CResult_PaymentPreimageAPIErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_TransactionNoneZ in the error state. -pub extern "C" fn CResult_TransactionNoneZ_err() -> CResult_TransactionNoneZ { - CResult_TransactionNoneZ { - contents: CResult_TransactionNoneZPtr { - err: core::ptr::null_mut(), +/// Creates a new CResult_PaymentPreimageAPIErrorZ in the error state. +pub extern "C" fn CResult_PaymentPreimageAPIErrorZ_err(e: crate::lightning::util::errors::APIError) -> CResult_PaymentPreimageAPIErrorZ { + CResult_PaymentPreimageAPIErrorZ { + contents: CResult_PaymentPreimageAPIErrorZPtr { + err: Box::into_raw(Box::new(e)), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_TransactionNoneZ_is_ok(o: &CResult_TransactionNoneZ) -> bool { +pub extern "C" fn CResult_PaymentPreimageAPIErrorZ_is_ok(o: &CResult_PaymentPreimageAPIErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_TransactionNoneZ. -pub extern "C" fn CResult_TransactionNoneZ_free(_res: CResult_TransactionNoneZ) { } -impl Drop for CResult_TransactionNoneZ { +/// Frees any resources used by the CResult_PaymentPreimageAPIErrorZ. +pub extern "C" fn CResult_PaymentPreimageAPIErrorZ_free(_res: CResult_PaymentPreimageAPIErrorZ) { } +impl Drop for CResult_PaymentPreimageAPIErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } } } } -impl From> for CResult_TransactionNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_PaymentPreimageAPIErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_TransactionNoneZPtr { result } + CResult_PaymentPreimageAPIErrorZPtr { result } } else { - let _ = unsafe { Box::from_raw(o.contents.err) }; - o.contents.err = core::ptr::null_mut(); - CResult_TransactionNoneZPtr { err: core::ptr::null_mut() } + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_PaymentPreimageAPIErrorZPtr { err } }; Self { contents, @@ -8526,127 +8747,96 @@ impl From> for CRe } } } -impl Clone for CResult_TransactionNoneZ { +impl Clone for CResult_PaymentPreimageAPIErrorZ { fn clone(&self) -> Self { if self.result_ok { - Self { result_ok: true, contents: CResult_TransactionNoneZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_PaymentPreimageAPIErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_TransactionNoneZPtr { - err: core::ptr::null_mut() + Self { result_ok: false, contents: CResult_PaymentPreimageAPIErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_TransactionNoneZ which has the same data as `orig` +/// Creates a new CResult_PaymentPreimageAPIErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_TransactionNoneZ_clone(orig: &CResult_TransactionNoneZ) -> CResult_TransactionNoneZ { Clone::clone(&orig) } +pub extern "C" fn CResult_PaymentPreimageAPIErrorZ_clone(orig: &CResult_PaymentPreimageAPIErrorZ) -> CResult_PaymentPreimageAPIErrorZ { Clone::clone(&orig) } #[repr(C)] -/// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple_BlockHashChannelMonitorZ { - /// The element at position 0 - pub a: crate::c_types::ThirtyTwoBytes, - /// The element at position 1 - pub b: crate::lightning::chain::channelmonitor::ChannelMonitor, +#[derive(Clone)] +/// An enum which can either contain a crate::c_types::derived::CVec_ChainHashZ or not +pub enum COption_CVec_ChainHashZZ { + /// When we're in this state, this COption_CVec_ChainHashZZ contains a crate::c_types::derived::CVec_ChainHashZ + Some(crate::c_types::derived::CVec_ChainHashZ), + /// When we're in this state, this COption_CVec_ChainHashZZ contains nothing + None } -impl From<(crate::c_types::ThirtyTwoBytes, crate::lightning::chain::channelmonitor::ChannelMonitor)> for C2Tuple_BlockHashChannelMonitorZ { - fn from (tup: (crate::c_types::ThirtyTwoBytes, crate::lightning::chain::channelmonitor::ChannelMonitor)) -> Self { - Self { - a: tup.0, - b: tup.1, - } +impl COption_CVec_ChainHashZZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } } -} -impl C2Tuple_BlockHashChannelMonitorZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoBytes, crate::lightning::chain::channelmonitor::ChannelMonitor) { - (self.a, self.b) + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::derived::CVec_ChainHashZ { + if let Self::Some(v) = self { v } else { unreachable!() } } } -/// Creates a new C2Tuple_BlockHashChannelMonitorZ from the contained elements. #[no_mangle] -pub extern "C" fn C2Tuple_BlockHashChannelMonitorZ_new(a: crate::c_types::ThirtyTwoBytes, b: crate::lightning::chain::channelmonitor::ChannelMonitor) -> C2Tuple_BlockHashChannelMonitorZ { - C2Tuple_BlockHashChannelMonitorZ { a, b, } +/// Constructs a new COption_CVec_ChainHashZZ containing a crate::c_types::derived::CVec_ChainHashZ +pub extern "C" fn COption_CVec_ChainHashZZ_some(o: crate::c_types::derived::CVec_ChainHashZ) -> COption_CVec_ChainHashZZ { + COption_CVec_ChainHashZZ::Some(o) } - #[no_mangle] -/// Frees any resources used by the C2Tuple_BlockHashChannelMonitorZ. -pub extern "C" fn C2Tuple_BlockHashChannelMonitorZ_free(_res: C2Tuple_BlockHashChannelMonitorZ) { } -#[repr(C)] -/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_BlockHashChannelMonitorZs of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_C2Tuple_BlockHashChannelMonitorZZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::derived::C2Tuple_BlockHashChannelMonitorZ, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_C2Tuple_BlockHashChannelMonitorZZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_BlockHashChannelMonitorZ] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_C2Tuple_BlockHashChannelMonitorZZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } +/// Constructs a new COption_CVec_ChainHashZZ containing nothing +pub extern "C" fn COption_CVec_ChainHashZZ_none() -> COption_CVec_ChainHashZZ { + COption_CVec_ChainHashZZ::None } #[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_C2Tuple_BlockHashChannelMonitorZZ_free(_res: CVec_C2Tuple_BlockHashChannelMonitorZZ) { } -impl Drop for CVec_C2Tuple_BlockHashChannelMonitorZZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} +/// Frees any resources associated with the crate::c_types::derived::CVec_ChainHashZ, if we are in the Some state +pub extern "C" fn COption_CVec_ChainHashZZ_free(_res: COption_CVec_ChainHashZZ) { } +#[no_mangle] +/// Creates a new COption_CVec_ChainHashZZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_CVec_ChainHashZZ_clone(orig: &COption_CVec_ChainHashZZ) -> COption_CVec_ChainHashZZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ -pub union CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZPtr { +/// The contents of CResult_CounterpartyForwardingInfoDecodeErrorZ +pub union CResult_CounterpartyForwardingInfoDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::CVec_C2Tuple_BlockHashChannelMonitorZZ, + pub result: *mut crate::lightning::ln::channelmanager::CounterpartyForwardingInfo, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::c_types::IOError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::CVec_C2Tuple_BlockHashChannelMonitorZZ on success and a crate::c_types::IOError on failure. +/// A CResult_CounterpartyForwardingInfoDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::channelmanager::CounterpartyForwardingInfo on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ { - /// The contents of this CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ, accessible via either +pub struct CResult_CounterpartyForwardingInfoDecodeErrorZ { + /// The contents of this CResult_CounterpartyForwardingInfoDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZPtr, - /// Whether this CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ represents a success state. + pub contents: CResult_CounterpartyForwardingInfoDecodeErrorZPtr, + /// Whether this CResult_CounterpartyForwardingInfoDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ in the success state. -pub extern "C" fn CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(o: crate::c_types::derived::CVec_C2Tuple_BlockHashChannelMonitorZZ) -> CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ { - CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ { - contents: CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZPtr { +/// Creates a new CResult_CounterpartyForwardingInfoDecodeErrorZ in the success state. +pub extern "C" fn CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(o: crate::lightning::ln::channelmanager::CounterpartyForwardingInfo) -> CResult_CounterpartyForwardingInfoDecodeErrorZ { + CResult_CounterpartyForwardingInfoDecodeErrorZ { + contents: CResult_CounterpartyForwardingInfoDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ in the error state. -pub extern "C" fn CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(e: crate::c_types::IOError) -> CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ { - CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ { - contents: CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZPtr { +/// Creates a new CResult_CounterpartyForwardingInfoDecodeErrorZ in the error state. +pub extern "C" fn CResult_CounterpartyForwardingInfoDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_CounterpartyForwardingInfoDecodeErrorZ { + CResult_CounterpartyForwardingInfoDecodeErrorZ { + contents: CResult_CounterpartyForwardingInfoDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -8654,13 +8844,13 @@ pub extern "C" fn CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(e: cr } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_is_ok(o: &CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ) -> bool { +pub extern "C" fn CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(o: &CResult_CounterpartyForwardingInfoDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ. -pub extern "C" fn CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res: CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ) { } -impl Drop for CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ { +/// Frees any resources used by the CResult_CounterpartyForwardingInfoDecodeErrorZ. +pub extern "C" fn CResult_CounterpartyForwardingInfoDecodeErrorZ_free(_res: CResult_CounterpartyForwardingInfoDecodeErrorZ) { } +impl Drop for CResult_CounterpartyForwardingInfoDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -8673,16 +8863,16 @@ impl Drop for CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ { } } } -impl From> for CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_CounterpartyForwardingInfoDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZPtr { result } + CResult_CounterpartyForwardingInfoDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZPtr { err } + CResult_CounterpartyForwardingInfoDecodeErrorZPtr { err } }; Self { contents, @@ -8690,79 +8880,59 @@ impl From bool { - if let Self::None = self { false } else { true } - } - #[allow(unused)] pub(crate) fn is_none(&self) -> bool { - !self.is_some() - } - #[allow(unused)] pub(crate) fn take(mut self) -> u16 { - if let Self::Some(v) = self { v } else { unreachable!() } +impl Clone for CResult_CounterpartyForwardingInfoDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_CounterpartyForwardingInfoDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_CounterpartyForwardingInfoDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } } } #[no_mangle] -/// Constructs a new COption_u16Z containing a u16 -pub extern "C" fn COption_u16Z_some(o: u16) -> COption_u16Z { - COption_u16Z::Some(o) -} -#[no_mangle] -/// Constructs a new COption_u16Z containing nothing -pub extern "C" fn COption_u16Z_none() -> COption_u16Z { - COption_u16Z::None -} -#[no_mangle] -/// Frees any resources associated with the u16, if we are in the Some state -pub extern "C" fn COption_u16Z_free(_res: COption_u16Z) { } -#[no_mangle] -/// Creates a new COption_u16Z which has the same data as `orig` +/// Creates a new CResult_CounterpartyForwardingInfoDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_u16Z_clone(orig: &COption_u16Z) -> COption_u16Z { Clone::clone(&orig) } +pub extern "C" fn CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(orig: &CResult_CounterpartyForwardingInfoDecodeErrorZ) -> CResult_CounterpartyForwardingInfoDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult__u832APIErrorZ -pub union CResult__u832APIErrorZPtr { +/// The contents of CResult_ChannelCounterpartyDecodeErrorZ +pub union CResult_ChannelCounterpartyDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::ThirtyTwoBytes, + pub result: *mut crate::lightning::ln::channelmanager::ChannelCounterparty, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::util::errors::APIError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult__u832APIErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::ThirtyTwoBytes on success and a crate::lightning::util::errors::APIError on failure. +/// A CResult_ChannelCounterpartyDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::channelmanager::ChannelCounterparty on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult__u832APIErrorZ { - /// The contents of this CResult__u832APIErrorZ, accessible via either +pub struct CResult_ChannelCounterpartyDecodeErrorZ { + /// The contents of this CResult_ChannelCounterpartyDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult__u832APIErrorZPtr, - /// Whether this CResult__u832APIErrorZ represents a success state. + pub contents: CResult_ChannelCounterpartyDecodeErrorZPtr, + /// Whether this CResult_ChannelCounterpartyDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult__u832APIErrorZ in the success state. -pub extern "C" fn CResult__u832APIErrorZ_ok(o: crate::c_types::ThirtyTwoBytes) -> CResult__u832APIErrorZ { - CResult__u832APIErrorZ { - contents: CResult__u832APIErrorZPtr { +/// Creates a new CResult_ChannelCounterpartyDecodeErrorZ in the success state. +pub extern "C" fn CResult_ChannelCounterpartyDecodeErrorZ_ok(o: crate::lightning::ln::channelmanager::ChannelCounterparty) -> CResult_ChannelCounterpartyDecodeErrorZ { + CResult_ChannelCounterpartyDecodeErrorZ { + contents: CResult_ChannelCounterpartyDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult__u832APIErrorZ in the error state. -pub extern "C" fn CResult__u832APIErrorZ_err(e: crate::lightning::util::errors::APIError) -> CResult__u832APIErrorZ { - CResult__u832APIErrorZ { - contents: CResult__u832APIErrorZPtr { +/// Creates a new CResult_ChannelCounterpartyDecodeErrorZ in the error state. +pub extern "C" fn CResult_ChannelCounterpartyDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelCounterpartyDecodeErrorZ { + CResult_ChannelCounterpartyDecodeErrorZ { + contents: CResult_ChannelCounterpartyDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -8770,13 +8940,13 @@ pub extern "C" fn CResult__u832APIErrorZ_err(e: crate::lightning::util::errors:: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult__u832APIErrorZ_is_ok(o: &CResult__u832APIErrorZ) -> bool { +pub extern "C" fn CResult_ChannelCounterpartyDecodeErrorZ_is_ok(o: &CResult_ChannelCounterpartyDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult__u832APIErrorZ. -pub extern "C" fn CResult__u832APIErrorZ_free(_res: CResult__u832APIErrorZ) { } -impl Drop for CResult__u832APIErrorZ { +/// Frees any resources used by the CResult_ChannelCounterpartyDecodeErrorZ. +pub extern "C" fn CResult_ChannelCounterpartyDecodeErrorZ_free(_res: CResult_ChannelCounterpartyDecodeErrorZ) { } +impl Drop for CResult_ChannelCounterpartyDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -8789,16 +8959,16 @@ impl Drop for CResult__u832APIErrorZ { } } } -impl From> for CResult__u832APIErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ChannelCounterpartyDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult__u832APIErrorZPtr { result } + CResult_ChannelCounterpartyDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult__u832APIErrorZPtr { err } + CResult_ChannelCounterpartyDecodeErrorZPtr { err } }; Self { contents, @@ -8806,96 +8976,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult__u832APIErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_ChannelCounterpartyDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult__u832APIErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_ChannelCounterpartyDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult__u832APIErrorZ which has the same data as `orig` +/// Creates a new CResult_ChannelCounterpartyDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult__u832APIErrorZ_clone(orig: &CResult__u832APIErrorZ) -> CResult__u832APIErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// A dynamically-allocated array of crate::lightning::ln::channelmanager::RecentPaymentDetailss of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_RecentPaymentDetailsZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::ln::channelmanager::RecentPaymentDetails, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_RecentPaymentDetailsZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::channelmanager::RecentPaymentDetails] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_RecentPaymentDetailsZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_RecentPaymentDetailsZ_free(_res: CVec_RecentPaymentDetailsZ) { } -impl Drop for CVec_RecentPaymentDetailsZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} +pub extern "C" fn CResult_ChannelCounterpartyDecodeErrorZ_clone(orig: &CResult_ChannelCounterpartyDecodeErrorZ) -> CResult_ChannelCounterpartyDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_NonePaymentSendFailureZ -pub union CResult_NonePaymentSendFailureZPtr { - /// Note that this value is always NULL, as there are no contents in the OK variant - pub result: *mut core::ffi::c_void, +/// The contents of CResult_ChannelDetailsDecodeErrorZ +pub union CResult_ChannelDetailsDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::channelmanager::ChannelDetails, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::outbound_payment::PaymentSendFailure, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_NonePaymentSendFailureZ represents the result of a fallible operation, -/// containing a () on success and a crate::lightning::ln::outbound_payment::PaymentSendFailure on failure. +/// A CResult_ChannelDetailsDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::channelmanager::ChannelDetails on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_NonePaymentSendFailureZ { - /// The contents of this CResult_NonePaymentSendFailureZ, accessible via either +pub struct CResult_ChannelDetailsDecodeErrorZ { + /// The contents of this CResult_ChannelDetailsDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_NonePaymentSendFailureZPtr, - /// Whether this CResult_NonePaymentSendFailureZ represents a success state. + pub contents: CResult_ChannelDetailsDecodeErrorZPtr, + /// Whether this CResult_ChannelDetailsDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_NonePaymentSendFailureZ in the success state. -pub extern "C" fn CResult_NonePaymentSendFailureZ_ok() -> CResult_NonePaymentSendFailureZ { - CResult_NonePaymentSendFailureZ { - contents: CResult_NonePaymentSendFailureZPtr { - result: core::ptr::null_mut(), +/// Creates a new CResult_ChannelDetailsDecodeErrorZ in the success state. +pub extern "C" fn CResult_ChannelDetailsDecodeErrorZ_ok(o: crate::lightning::ln::channelmanager::ChannelDetails) -> CResult_ChannelDetailsDecodeErrorZ { + CResult_ChannelDetailsDecodeErrorZ { + contents: CResult_ChannelDetailsDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_NonePaymentSendFailureZ in the error state. -pub extern "C" fn CResult_NonePaymentSendFailureZ_err(e: crate::lightning::ln::outbound_payment::PaymentSendFailure) -> CResult_NonePaymentSendFailureZ { - CResult_NonePaymentSendFailureZ { - contents: CResult_NonePaymentSendFailureZPtr { +/// Creates a new CResult_ChannelDetailsDecodeErrorZ in the error state. +pub extern "C" fn CResult_ChannelDetailsDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelDetailsDecodeErrorZ { + CResult_ChannelDetailsDecodeErrorZ { + contents: CResult_ChannelDetailsDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -8903,15 +9036,18 @@ pub extern "C" fn CResult_NonePaymentSendFailureZ_err(e: crate::lightning::ln::o } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_NonePaymentSendFailureZ_is_ok(o: &CResult_NonePaymentSendFailureZ) -> bool { +pub extern "C" fn CResult_ChannelDetailsDecodeErrorZ_is_ok(o: &CResult_ChannelDetailsDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_NonePaymentSendFailureZ. -pub extern "C" fn CResult_NonePaymentSendFailureZ_free(_res: CResult_NonePaymentSendFailureZ) { } -impl Drop for CResult_NonePaymentSendFailureZ { +/// Frees any resources used by the CResult_ChannelDetailsDecodeErrorZ. +pub extern "C" fn CResult_ChannelDetailsDecodeErrorZ_free(_res: CResult_ChannelDetailsDecodeErrorZ) { } +impl Drop for CResult_ChannelDetailsDecodeErrorZ { fn drop(&mut self) { if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } } else { if unsafe { !(self.contents.err as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.err) }; @@ -8919,16 +9055,16 @@ impl Drop for CResult_NonePaymentSendFailureZ { } } } -impl From> for CResult_NonePaymentSendFailureZ { - fn from(mut o: crate::c_types::CResultTempl<(), crate::lightning::ln::outbound_payment::PaymentSendFailure>) -> Self { +impl From> for CResult_ChannelDetailsDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { - let _ = unsafe { Box::from_raw(o.contents.result) }; - o.contents.result = core::ptr::null_mut(); - CResult_NonePaymentSendFailureZPtr { result: core::ptr::null_mut() } + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_ChannelDetailsDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_NonePaymentSendFailureZPtr { err } + CResult_ChannelDetailsDecodeErrorZPtr { err } }; Self { contents, @@ -8936,58 +9072,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_NonePaymentSendFailureZPtr { - result: core::ptr::null_mut() + Self { result_ok: true, contents: CResult_ChannelDetailsDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_NonePaymentSendFailureZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_ChannelDetailsDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_NonePaymentSendFailureZ which has the same data as `orig` +/// Creates a new CResult_ChannelDetailsDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_NonePaymentSendFailureZ_clone(orig: &CResult_NonePaymentSendFailureZ) -> CResult_NonePaymentSendFailureZ { Clone::clone(&orig) } +pub extern "C" fn CResult_ChannelDetailsDecodeErrorZ_clone(orig: &CResult_ChannelDetailsDecodeErrorZ) -> CResult_ChannelDetailsDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_NoneRetryableSendFailureZ -pub union CResult_NoneRetryableSendFailureZPtr { - /// Note that this value is always NULL, as there are no contents in the OK variant - pub result: *mut core::ffi::c_void, +/// The contents of CResult_PhantomRouteHintsDecodeErrorZ +pub union CResult_PhantomRouteHintsDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::channelmanager::PhantomRouteHints, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::outbound_payment::RetryableSendFailure, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_NoneRetryableSendFailureZ represents the result of a fallible operation, -/// containing a () on success and a crate::lightning::ln::outbound_payment::RetryableSendFailure on failure. +/// A CResult_PhantomRouteHintsDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::channelmanager::PhantomRouteHints on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_NoneRetryableSendFailureZ { - /// The contents of this CResult_NoneRetryableSendFailureZ, accessible via either +pub struct CResult_PhantomRouteHintsDecodeErrorZ { + /// The contents of this CResult_PhantomRouteHintsDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_NoneRetryableSendFailureZPtr, - /// Whether this CResult_NoneRetryableSendFailureZ represents a success state. + pub contents: CResult_PhantomRouteHintsDecodeErrorZPtr, + /// Whether this CResult_PhantomRouteHintsDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_NoneRetryableSendFailureZ in the success state. -pub extern "C" fn CResult_NoneRetryableSendFailureZ_ok() -> CResult_NoneRetryableSendFailureZ { - CResult_NoneRetryableSendFailureZ { - contents: CResult_NoneRetryableSendFailureZPtr { - result: core::ptr::null_mut(), - }, - result_ok: true, - } -} +/// Creates a new CResult_PhantomRouteHintsDecodeErrorZ in the success state. +pub extern "C" fn CResult_PhantomRouteHintsDecodeErrorZ_ok(o: crate::lightning::ln::channelmanager::PhantomRouteHints) -> CResult_PhantomRouteHintsDecodeErrorZ { + CResult_PhantomRouteHintsDecodeErrorZ { + contents: CResult_PhantomRouteHintsDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} #[no_mangle] -/// Creates a new CResult_NoneRetryableSendFailureZ in the error state. -pub extern "C" fn CResult_NoneRetryableSendFailureZ_err(e: crate::lightning::ln::outbound_payment::RetryableSendFailure) -> CResult_NoneRetryableSendFailureZ { - CResult_NoneRetryableSendFailureZ { - contents: CResult_NoneRetryableSendFailureZPtr { +/// Creates a new CResult_PhantomRouteHintsDecodeErrorZ in the error state. +pub extern "C" fn CResult_PhantomRouteHintsDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_PhantomRouteHintsDecodeErrorZ { + CResult_PhantomRouteHintsDecodeErrorZ { + contents: CResult_PhantomRouteHintsDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -8995,15 +9132,18 @@ pub extern "C" fn CResult_NoneRetryableSendFailureZ_err(e: crate::lightning::ln: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_NoneRetryableSendFailureZ_is_ok(o: &CResult_NoneRetryableSendFailureZ) -> bool { +pub extern "C" fn CResult_PhantomRouteHintsDecodeErrorZ_is_ok(o: &CResult_PhantomRouteHintsDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_NoneRetryableSendFailureZ. -pub extern "C" fn CResult_NoneRetryableSendFailureZ_free(_res: CResult_NoneRetryableSendFailureZ) { } -impl Drop for CResult_NoneRetryableSendFailureZ { +/// Frees any resources used by the CResult_PhantomRouteHintsDecodeErrorZ. +pub extern "C" fn CResult_PhantomRouteHintsDecodeErrorZ_free(_res: CResult_PhantomRouteHintsDecodeErrorZ) { } +impl Drop for CResult_PhantomRouteHintsDecodeErrorZ { fn drop(&mut self) { if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } } else { if unsafe { !(self.contents.err as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.err) }; @@ -9011,16 +9151,16 @@ impl Drop for CResult_NoneRetryableSendFailureZ { } } } -impl From> for CResult_NoneRetryableSendFailureZ { - fn from(mut o: crate::c_types::CResultTempl<(), crate::lightning::ln::outbound_payment::RetryableSendFailure>) -> Self { +impl From> for CResult_PhantomRouteHintsDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { - let _ = unsafe { Box::from_raw(o.contents.result) }; - o.contents.result = core::ptr::null_mut(); - CResult_NoneRetryableSendFailureZPtr { result: core::ptr::null_mut() } + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_PhantomRouteHintsDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_NoneRetryableSendFailureZPtr { err } + CResult_PhantomRouteHintsDecodeErrorZPtr { err } }; Self { contents, @@ -9028,59 +9168,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_NoneRetryableSendFailureZPtr { - result: core::ptr::null_mut() + Self { result_ok: true, contents: CResult_PhantomRouteHintsDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_NoneRetryableSendFailureZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_PhantomRouteHintsDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_NoneRetryableSendFailureZ which has the same data as `orig` +/// Creates a new CResult_PhantomRouteHintsDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_NoneRetryableSendFailureZ_clone(orig: &CResult_NoneRetryableSendFailureZ) -> CResult_NoneRetryableSendFailureZ { Clone::clone(&orig) } +pub extern "C" fn CResult_PhantomRouteHintsDecodeErrorZ_clone(orig: &CResult_PhantomRouteHintsDecodeErrorZ) -> CResult_PhantomRouteHintsDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_PaymentHashPaymentSendFailureZ -pub union CResult_PaymentHashPaymentSendFailureZPtr { +/// The contents of CResult_ChannelShutdownStateDecodeErrorZ +pub union CResult_ChannelShutdownStateDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::ThirtyTwoBytes, + pub result: *mut crate::lightning::ln::channelmanager::ChannelShutdownState, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::outbound_payment::PaymentSendFailure, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_PaymentHashPaymentSendFailureZ represents the result of a fallible operation, -/// containing a crate::c_types::ThirtyTwoBytes on success and a crate::lightning::ln::outbound_payment::PaymentSendFailure on failure. +/// A CResult_ChannelShutdownStateDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::channelmanager::ChannelShutdownState on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_PaymentHashPaymentSendFailureZ { - /// The contents of this CResult_PaymentHashPaymentSendFailureZ, accessible via either +pub struct CResult_ChannelShutdownStateDecodeErrorZ { + /// The contents of this CResult_ChannelShutdownStateDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_PaymentHashPaymentSendFailureZPtr, - /// Whether this CResult_PaymentHashPaymentSendFailureZ represents a success state. + pub contents: CResult_ChannelShutdownStateDecodeErrorZPtr, + /// Whether this CResult_ChannelShutdownStateDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_PaymentHashPaymentSendFailureZ in the success state. -pub extern "C" fn CResult_PaymentHashPaymentSendFailureZ_ok(o: crate::c_types::ThirtyTwoBytes) -> CResult_PaymentHashPaymentSendFailureZ { - CResult_PaymentHashPaymentSendFailureZ { - contents: CResult_PaymentHashPaymentSendFailureZPtr { +/// Creates a new CResult_ChannelShutdownStateDecodeErrorZ in the success state. +pub extern "C" fn CResult_ChannelShutdownStateDecodeErrorZ_ok(o: crate::lightning::ln::channelmanager::ChannelShutdownState) -> CResult_ChannelShutdownStateDecodeErrorZ { + CResult_ChannelShutdownStateDecodeErrorZ { + contents: CResult_ChannelShutdownStateDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_PaymentHashPaymentSendFailureZ in the error state. -pub extern "C" fn CResult_PaymentHashPaymentSendFailureZ_err(e: crate::lightning::ln::outbound_payment::PaymentSendFailure) -> CResult_PaymentHashPaymentSendFailureZ { - CResult_PaymentHashPaymentSendFailureZ { - contents: CResult_PaymentHashPaymentSendFailureZPtr { +/// Creates a new CResult_ChannelShutdownStateDecodeErrorZ in the error state. +pub extern "C" fn CResult_ChannelShutdownStateDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelShutdownStateDecodeErrorZ { + CResult_ChannelShutdownStateDecodeErrorZ { + contents: CResult_ChannelShutdownStateDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -9088,13 +9228,13 @@ pub extern "C" fn CResult_PaymentHashPaymentSendFailureZ_err(e: crate::lightning } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_PaymentHashPaymentSendFailureZ_is_ok(o: &CResult_PaymentHashPaymentSendFailureZ) -> bool { +pub extern "C" fn CResult_ChannelShutdownStateDecodeErrorZ_is_ok(o: &CResult_ChannelShutdownStateDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_PaymentHashPaymentSendFailureZ. -pub extern "C" fn CResult_PaymentHashPaymentSendFailureZ_free(_res: CResult_PaymentHashPaymentSendFailureZ) { } -impl Drop for CResult_PaymentHashPaymentSendFailureZ { +/// Frees any resources used by the CResult_ChannelShutdownStateDecodeErrorZ. +pub extern "C" fn CResult_ChannelShutdownStateDecodeErrorZ_free(_res: CResult_ChannelShutdownStateDecodeErrorZ) { } +impl Drop for CResult_ChannelShutdownStateDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -9107,16 +9247,16 @@ impl Drop for CResult_PaymentHashPaymentSendFailureZ { } } } -impl From> for CResult_PaymentHashPaymentSendFailureZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ChannelShutdownStateDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_PaymentHashPaymentSendFailureZPtr { result } + CResult_ChannelShutdownStateDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_PaymentHashPaymentSendFailureZPtr { err } + CResult_ChannelShutdownStateDecodeErrorZPtr { err } }; Self { contents, @@ -9124,59 +9264,127 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_PaymentHashPaymentSendFailureZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_ChannelShutdownStateDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_PaymentHashPaymentSendFailureZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_ChannelShutdownStateDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_PaymentHashPaymentSendFailureZ which has the same data as `orig` +/// Creates a new CResult_ChannelShutdownStateDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_PaymentHashPaymentSendFailureZ_clone(orig: &CResult_PaymentHashPaymentSendFailureZ) -> CResult_PaymentHashPaymentSendFailureZ { Clone::clone(&orig) } +pub extern "C" fn CResult_ChannelShutdownStateDecodeErrorZ_clone(orig: &CResult_ChannelShutdownStateDecodeErrorZ) -> CResult_ChannelShutdownStateDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_PaymentHashRetryableSendFailureZ -pub union CResult_PaymentHashRetryableSendFailureZPtr { +/// A dynamically-allocated array of crate::lightning::chain::channelmonitor::ChannelMonitors of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_ChannelMonitorZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::chain::channelmonitor::ChannelMonitor, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_ChannelMonitorZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::chain::channelmonitor::ChannelMonitor] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_ChannelMonitorZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_ChannelMonitorZ_free(_res: CVec_ChannelMonitorZ) { } +impl Drop for CVec_ChannelMonitorZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +#[repr(C)] +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_BlockHashChannelManagerZ { + /// The element at position 0 + pub a: crate::c_types::ThirtyTwoBytes, + /// The element at position 1 + pub b: crate::lightning::ln::channelmanager::ChannelManager, +} +impl From<(crate::c_types::ThirtyTwoBytes, crate::lightning::ln::channelmanager::ChannelManager)> for C2Tuple_BlockHashChannelManagerZ { + fn from (tup: (crate::c_types::ThirtyTwoBytes, crate::lightning::ln::channelmanager::ChannelManager)) -> Self { + Self { + a: tup.0, + b: tup.1, + } + } +} +impl C2Tuple_BlockHashChannelManagerZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoBytes, crate::lightning::ln::channelmanager::ChannelManager) { + (self.a, self.b) + } +} +/// Creates a new C2Tuple_BlockHashChannelManagerZ from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_BlockHashChannelManagerZ_new(a: crate::c_types::ThirtyTwoBytes, b: crate::lightning::ln::channelmanager::ChannelManager) -> C2Tuple_BlockHashChannelManagerZ { + C2Tuple_BlockHashChannelManagerZ { a, b, } +} + +#[no_mangle] +/// Frees any resources used by the C2Tuple_BlockHashChannelManagerZ. +pub extern "C" fn C2Tuple_BlockHashChannelManagerZ_free(_res: C2Tuple_BlockHashChannelManagerZ) { } +#[repr(C)] +/// The contents of CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ +pub union CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::ThirtyTwoBytes, + pub result: *mut crate::c_types::derived::C2Tuple_BlockHashChannelManagerZ, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::outbound_payment::RetryableSendFailure, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_PaymentHashRetryableSendFailureZ represents the result of a fallible operation, -/// containing a crate::c_types::ThirtyTwoBytes on success and a crate::lightning::ln::outbound_payment::RetryableSendFailure on failure. +/// A CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::C2Tuple_BlockHashChannelManagerZ on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_PaymentHashRetryableSendFailureZ { - /// The contents of this CResult_PaymentHashRetryableSendFailureZ, accessible via either +pub struct CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ { + /// The contents of this CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_PaymentHashRetryableSendFailureZPtr, - /// Whether this CResult_PaymentHashRetryableSendFailureZ represents a success state. + pub contents: CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr, + /// Whether this CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_PaymentHashRetryableSendFailureZ in the success state. -pub extern "C" fn CResult_PaymentHashRetryableSendFailureZ_ok(o: crate::c_types::ThirtyTwoBytes) -> CResult_PaymentHashRetryableSendFailureZ { - CResult_PaymentHashRetryableSendFailureZ { - contents: CResult_PaymentHashRetryableSendFailureZPtr { +/// Creates a new CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ in the success state. +pub extern "C" fn CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o: crate::c_types::derived::C2Tuple_BlockHashChannelManagerZ) -> CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ { + CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ { + contents: CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_PaymentHashRetryableSendFailureZ in the error state. -pub extern "C" fn CResult_PaymentHashRetryableSendFailureZ_err(e: crate::lightning::ln::outbound_payment::RetryableSendFailure) -> CResult_PaymentHashRetryableSendFailureZ { - CResult_PaymentHashRetryableSendFailureZ { - contents: CResult_PaymentHashRetryableSendFailureZPtr { +/// Creates a new CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ in the error state. +pub extern "C" fn CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ { + CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ { + contents: CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -9184,13 +9392,13 @@ pub extern "C" fn CResult_PaymentHashRetryableSendFailureZ_err(e: crate::lightni } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_PaymentHashRetryableSendFailureZ_is_ok(o: &CResult_PaymentHashRetryableSendFailureZ) -> bool { +pub extern "C" fn CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(o: &CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_PaymentHashRetryableSendFailureZ. -pub extern "C" fn CResult_PaymentHashRetryableSendFailureZ_free(_res: CResult_PaymentHashRetryableSendFailureZ) { } -impl Drop for CResult_PaymentHashRetryableSendFailureZ { +/// Frees any resources used by the CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ. +pub extern "C" fn CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res: CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ) { } +impl Drop for CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -9203,16 +9411,16 @@ impl Drop for CResult_PaymentHashRetryableSendFailureZ { } } } -impl From> for CResult_PaymentHashRetryableSendFailureZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_PaymentHashRetryableSendFailureZPtr { result } + CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_PaymentHashRetryableSendFailureZPtr { err } + CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr { err } }; Self { contents, @@ -9220,101 +9428,42 @@ impl From Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_PaymentHashRetryableSendFailureZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_PaymentHashRetryableSendFailureZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } - } - } -} -#[no_mangle] -/// Creates a new CResult_PaymentHashRetryableSendFailureZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_PaymentHashRetryableSendFailureZ_clone(orig: &CResult_PaymentHashRetryableSendFailureZ) -> CResult_PaymentHashRetryableSendFailureZ { Clone::clone(&orig) } #[repr(C)] -/// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple_PaymentHashPaymentIdZ { - /// The element at position 0 - pub a: crate::c_types::ThirtyTwoBytes, - /// The element at position 1 - pub b: crate::c_types::ThirtyTwoBytes, +/// The contents of CResult_MaxDustHTLCExposureDecodeErrorZ +pub union CResult_MaxDustHTLCExposureDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::util::config::MaxDustHTLCExposure, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, } -impl From<(crate::c_types::ThirtyTwoBytes, crate::c_types::ThirtyTwoBytes)> for C2Tuple_PaymentHashPaymentIdZ { - fn from (tup: (crate::c_types::ThirtyTwoBytes, crate::c_types::ThirtyTwoBytes)) -> Self { - Self { - a: tup.0, - b: tup.1, - } - } +#[repr(C)] +/// A CResult_MaxDustHTLCExposureDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::util::config::MaxDustHTLCExposure on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_MaxDustHTLCExposureDecodeErrorZ { + /// The contents of this CResult_MaxDustHTLCExposureDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_MaxDustHTLCExposureDecodeErrorZPtr, + /// Whether this CResult_MaxDustHTLCExposureDecodeErrorZ represents a success state. + pub result_ok: bool, } -impl C2Tuple_PaymentHashPaymentIdZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoBytes, crate::c_types::ThirtyTwoBytes) { - (self.a, self.b) - } -} -impl Clone for C2Tuple_PaymentHashPaymentIdZ { - fn clone(&self) -> Self { - Self { - a: Clone::clone(&self.a), - b: Clone::clone(&self.b), - } - } -} -#[no_mangle] -/// Creates a new tuple which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C2Tuple_PaymentHashPaymentIdZ_clone(orig: &C2Tuple_PaymentHashPaymentIdZ) -> C2Tuple_PaymentHashPaymentIdZ { Clone::clone(&orig) } -/// Creates a new C2Tuple_PaymentHashPaymentIdZ from the contained elements. -#[no_mangle] -pub extern "C" fn C2Tuple_PaymentHashPaymentIdZ_new(a: crate::c_types::ThirtyTwoBytes, b: crate::c_types::ThirtyTwoBytes) -> C2Tuple_PaymentHashPaymentIdZ { - C2Tuple_PaymentHashPaymentIdZ { a, b, } -} - -#[no_mangle] -/// Frees any resources used by the C2Tuple_PaymentHashPaymentIdZ. -pub extern "C" fn C2Tuple_PaymentHashPaymentIdZ_free(_res: C2Tuple_PaymentHashPaymentIdZ) { } -#[repr(C)] -/// The contents of CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ -pub union CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::C2Tuple_PaymentHashPaymentIdZ, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::outbound_payment::PaymentSendFailure, -} -#[repr(C)] -/// A CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::C2Tuple_PaymentHashPaymentIdZ on success and a crate::lightning::ln::outbound_payment::PaymentSendFailure on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ { - /// The contents of this CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZPtr, - /// Whether this CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ represents a success state. - pub result_ok: bool, -} -#[no_mangle] -/// Creates a new CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ in the success state. -pub extern "C" fn CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(o: crate::c_types::derived::C2Tuple_PaymentHashPaymentIdZ) -> CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ { - CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ { - contents: CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, +#[no_mangle] +/// Creates a new CResult_MaxDustHTLCExposureDecodeErrorZ in the success state. +pub extern "C" fn CResult_MaxDustHTLCExposureDecodeErrorZ_ok(o: crate::lightning::util::config::MaxDustHTLCExposure) -> CResult_MaxDustHTLCExposureDecodeErrorZ { + CResult_MaxDustHTLCExposureDecodeErrorZ { + contents: CResult_MaxDustHTLCExposureDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, } } #[no_mangle] -/// Creates a new CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ in the error state. -pub extern "C" fn CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(e: crate::lightning::ln::outbound_payment::PaymentSendFailure) -> CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ { - CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ { - contents: CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZPtr { +/// Creates a new CResult_MaxDustHTLCExposureDecodeErrorZ in the error state. +pub extern "C" fn CResult_MaxDustHTLCExposureDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_MaxDustHTLCExposureDecodeErrorZ { + CResult_MaxDustHTLCExposureDecodeErrorZ { + contents: CResult_MaxDustHTLCExposureDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -9322,13 +9471,13 @@ pub extern "C" fn CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(e } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(o: &CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ) -> bool { +pub extern "C" fn CResult_MaxDustHTLCExposureDecodeErrorZ_is_ok(o: &CResult_MaxDustHTLCExposureDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ. -pub extern "C" fn CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(_res: CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ) { } -impl Drop for CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ { +/// Frees any resources used by the CResult_MaxDustHTLCExposureDecodeErrorZ. +pub extern "C" fn CResult_MaxDustHTLCExposureDecodeErrorZ_free(_res: CResult_MaxDustHTLCExposureDecodeErrorZ) { } +impl Drop for CResult_MaxDustHTLCExposureDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -9341,16 +9490,16 @@ impl Drop for CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ { } } } -impl From> for CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_MaxDustHTLCExposureDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZPtr { result } + CResult_MaxDustHTLCExposureDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZPtr { err } + CResult_MaxDustHTLCExposureDecodeErrorZPtr { err } }; Self { contents, @@ -9358,179 +9507,95 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_MaxDustHTLCExposureDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_MaxDustHTLCExposureDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(orig: &CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ) -> CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ { Clone::clone(&orig) } -#[repr(C)] -/// A dynamically-allocated array of crate::c_types::ThirtyTwoBytess of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_ThirtyTwoBytesZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::ThirtyTwoBytes, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_ThirtyTwoBytesZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::ThirtyTwoBytes] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_ThirtyTwoBytesZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_ThirtyTwoBytesZ_free(_res: CVec_ThirtyTwoBytesZ) { } -impl Drop for CVec_ThirtyTwoBytesZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_ThirtyTwoBytesZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} -#[repr(C)] -/// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple_PaymentHashPaymentSecretZ { - /// The element at position 0 - pub a: crate::c_types::ThirtyTwoBytes, - /// The element at position 1 - pub b: crate::c_types::ThirtyTwoBytes, -} -impl From<(crate::c_types::ThirtyTwoBytes, crate::c_types::ThirtyTwoBytes)> for C2Tuple_PaymentHashPaymentSecretZ { - fn from (tup: (crate::c_types::ThirtyTwoBytes, crate::c_types::ThirtyTwoBytes)) -> Self { - Self { - a: tup.0, - b: tup.1, - } - } -} -impl C2Tuple_PaymentHashPaymentSecretZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoBytes, crate::c_types::ThirtyTwoBytes) { - (self.a, self.b) - } -} -impl Clone for C2Tuple_PaymentHashPaymentSecretZ { - fn clone(&self) -> Self { - Self { - a: Clone::clone(&self.a), - b: Clone::clone(&self.b), - } - } -} -#[no_mangle] -/// Creates a new tuple which has the same data as `orig` +/// Creates a new CResult_MaxDustHTLCExposureDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C2Tuple_PaymentHashPaymentSecretZ_clone(orig: &C2Tuple_PaymentHashPaymentSecretZ) -> C2Tuple_PaymentHashPaymentSecretZ { Clone::clone(&orig) } -/// Creates a new C2Tuple_PaymentHashPaymentSecretZ from the contained elements. -#[no_mangle] -pub extern "C" fn C2Tuple_PaymentHashPaymentSecretZ_new(a: crate::c_types::ThirtyTwoBytes, b: crate::c_types::ThirtyTwoBytes) -> C2Tuple_PaymentHashPaymentSecretZ { - C2Tuple_PaymentHashPaymentSecretZ { a, b, } -} - -#[no_mangle] -/// Frees any resources used by the C2Tuple_PaymentHashPaymentSecretZ. -pub extern "C" fn C2Tuple_PaymentHashPaymentSecretZ_free(_res: C2Tuple_PaymentHashPaymentSecretZ) { } +pub extern "C" fn CResult_MaxDustHTLCExposureDecodeErrorZ_clone(orig: &CResult_MaxDustHTLCExposureDecodeErrorZ) -> CResult_MaxDustHTLCExposureDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ -pub union CResult_C2Tuple_PaymentHashPaymentSecretZNoneZPtr { +/// The contents of CResult_ChannelConfigDecodeErrorZ +pub union CResult_ChannelConfigDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::C2Tuple_PaymentHashPaymentSecretZ, - /// Note that this value is always NULL, as there are no contents in the Err variant - pub err: *mut core::ffi::c_void, + pub result: *mut crate::lightning::util::config::ChannelConfig, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::C2Tuple_PaymentHashPaymentSecretZ on success and a () on failure. +/// A CResult_ChannelConfigDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::util::config::ChannelConfig on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ { - /// The contents of this CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ, accessible via either +pub struct CResult_ChannelConfigDecodeErrorZ { + /// The contents of this CResult_ChannelConfigDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_C2Tuple_PaymentHashPaymentSecretZNoneZPtr, - /// Whether this CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ represents a success state. + pub contents: CResult_ChannelConfigDecodeErrorZPtr, + /// Whether this CResult_ChannelConfigDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ in the success state. -pub extern "C" fn CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(o: crate::c_types::derived::C2Tuple_PaymentHashPaymentSecretZ) -> CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ { - CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ { - contents: CResult_C2Tuple_PaymentHashPaymentSecretZNoneZPtr { +/// Creates a new CResult_ChannelConfigDecodeErrorZ in the success state. +pub extern "C" fn CResult_ChannelConfigDecodeErrorZ_ok(o: crate::lightning::util::config::ChannelConfig) -> CResult_ChannelConfigDecodeErrorZ { + CResult_ChannelConfigDecodeErrorZ { + contents: CResult_ChannelConfigDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ in the error state. -pub extern "C" fn CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err() -> CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ { - CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ { - contents: CResult_C2Tuple_PaymentHashPaymentSecretZNoneZPtr { - err: core::ptr::null_mut(), +/// Creates a new CResult_ChannelConfigDecodeErrorZ in the error state. +pub extern "C" fn CResult_ChannelConfigDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelConfigDecodeErrorZ { + CResult_ChannelConfigDecodeErrorZ { + contents: CResult_ChannelConfigDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(o: &CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ) -> bool { +pub extern "C" fn CResult_ChannelConfigDecodeErrorZ_is_ok(o: &CResult_ChannelConfigDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ. -pub extern "C" fn CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(_res: CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ) { } -impl Drop for CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ { +/// Frees any resources used by the CResult_ChannelConfigDecodeErrorZ. +pub extern "C" fn CResult_ChannelConfigDecodeErrorZ_free(_res: CResult_ChannelConfigDecodeErrorZ) { } +impl Drop for CResult_ChannelConfigDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } } } } -impl From> for CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ChannelConfigDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_C2Tuple_PaymentHashPaymentSecretZNoneZPtr { result } + CResult_ChannelConfigDecodeErrorZPtr { result } } else { - let _ = unsafe { Box::from_raw(o.contents.err) }; - o.contents.err = core::ptr::null_mut(); - CResult_C2Tuple_PaymentHashPaymentSecretZNoneZPtr { err: core::ptr::null_mut() } + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_ChannelConfigDecodeErrorZPtr { err } }; Self { contents, @@ -9538,59 +9603,133 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_C2Tuple_PaymentHashPaymentSecretZNoneZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_ChannelConfigDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_C2Tuple_PaymentHashPaymentSecretZNoneZPtr { - err: core::ptr::null_mut() + Self { result_ok: false, contents: CResult_ChannelConfigDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ which has the same data as `orig` +/// Creates a new CResult_ChannelConfigDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(orig: &CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ) -> CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ { Clone::clone(&orig) } -#[repr(C)] -/// The contents of CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ -pub union CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::C2Tuple_PaymentHashPaymentSecretZ, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::util::errors::APIError, -} +pub extern "C" fn CResult_ChannelConfigDecodeErrorZ_clone(orig: &CResult_ChannelConfigDecodeErrorZ) -> CResult_ChannelConfigDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// A CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::C2Tuple_PaymentHashPaymentSecretZ on success and a crate::lightning::util::errors::APIError on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ { - /// The contents of this CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZPtr, - /// Whether this CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ represents a success state. - pub result_ok: bool, +#[derive(Clone)] +/// An enum which can either contain a crate::lightning::util::config::MaxDustHTLCExposure or not +pub enum COption_MaxDustHTLCExposureZ { + /// When we're in this state, this COption_MaxDustHTLCExposureZ contains a crate::lightning::util::config::MaxDustHTLCExposure + Some(crate::lightning::util::config::MaxDustHTLCExposure), + /// When we're in this state, this COption_MaxDustHTLCExposureZ contains nothing + None } -#[no_mangle] -/// Creates a new CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ in the success state. -pub extern "C" fn CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(o: crate::c_types::derived::C2Tuple_PaymentHashPaymentSecretZ) -> CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ { - CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ { - contents: CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, +impl COption_MaxDustHTLCExposureZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::util::config::MaxDustHTLCExposure { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_MaxDustHTLCExposureZ containing a crate::lightning::util::config::MaxDustHTLCExposure +pub extern "C" fn COption_MaxDustHTLCExposureZ_some(o: crate::lightning::util::config::MaxDustHTLCExposure) -> COption_MaxDustHTLCExposureZ { + COption_MaxDustHTLCExposureZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_MaxDustHTLCExposureZ containing nothing +pub extern "C" fn COption_MaxDustHTLCExposureZ_none() -> COption_MaxDustHTLCExposureZ { + COption_MaxDustHTLCExposureZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::lightning::util::config::MaxDustHTLCExposure, if we are in the Some state +pub extern "C" fn COption_MaxDustHTLCExposureZ_free(_res: COption_MaxDustHTLCExposureZ) { } +#[no_mangle] +/// Creates a new COption_MaxDustHTLCExposureZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_MaxDustHTLCExposureZ_clone(orig: &COption_MaxDustHTLCExposureZ) -> COption_MaxDustHTLCExposureZ { Clone::clone(&orig) } +#[repr(C)] +#[derive(Clone)] +/// An enum which can either contain a crate::lightning::util::errors::APIError or not +pub enum COption_APIErrorZ { + /// When we're in this state, this COption_APIErrorZ contains a crate::lightning::util::errors::APIError + Some(crate::lightning::util::errors::APIError), + /// When we're in this state, this COption_APIErrorZ contains nothing + None +} +impl COption_APIErrorZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::util::errors::APIError { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_APIErrorZ containing a crate::lightning::util::errors::APIError +pub extern "C" fn COption_APIErrorZ_some(o: crate::lightning::util::errors::APIError) -> COption_APIErrorZ { + COption_APIErrorZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_APIErrorZ containing nothing +pub extern "C" fn COption_APIErrorZ_none() -> COption_APIErrorZ { + COption_APIErrorZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::lightning::util::errors::APIError, if we are in the Some state +pub extern "C" fn COption_APIErrorZ_free(_res: COption_APIErrorZ) { } +#[no_mangle] +/// Creates a new COption_APIErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_APIErrorZ_clone(orig: &COption_APIErrorZ) -> COption_APIErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_COption_APIErrorZDecodeErrorZ +pub union CResult_COption_APIErrorZDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::c_types::derived::COption_APIErrorZ, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_COption_APIErrorZDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::COption_APIErrorZ on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_COption_APIErrorZDecodeErrorZ { + /// The contents of this CResult_COption_APIErrorZDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_COption_APIErrorZDecodeErrorZPtr, + /// Whether this CResult_COption_APIErrorZDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_COption_APIErrorZDecodeErrorZ in the success state. +pub extern "C" fn CResult_COption_APIErrorZDecodeErrorZ_ok(o: crate::c_types::derived::COption_APIErrorZ) -> CResult_COption_APIErrorZDecodeErrorZ { + CResult_COption_APIErrorZDecodeErrorZ { + contents: CResult_COption_APIErrorZDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, } } #[no_mangle] -/// Creates a new CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ in the error state. -pub extern "C" fn CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(e: crate::lightning::util::errors::APIError) -> CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ { - CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ { - contents: CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZPtr { +/// Creates a new CResult_COption_APIErrorZDecodeErrorZ in the error state. +pub extern "C" fn CResult_COption_APIErrorZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_COption_APIErrorZDecodeErrorZ { + CResult_COption_APIErrorZDecodeErrorZ { + contents: CResult_COption_APIErrorZDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -9598,13 +9737,13 @@ pub extern "C" fn CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(e: crat } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok(o: &CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ) -> bool { +pub extern "C" fn CResult_COption_APIErrorZDecodeErrorZ_is_ok(o: &CResult_COption_APIErrorZDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ. -pub extern "C" fn CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(_res: CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ) { } -impl Drop for CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ { +/// Frees any resources used by the CResult_COption_APIErrorZDecodeErrorZ. +pub extern "C" fn CResult_COption_APIErrorZDecodeErrorZ_free(_res: CResult_COption_APIErrorZDecodeErrorZ) { } +impl Drop for CResult_COption_APIErrorZDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -9617,16 +9756,16 @@ impl Drop for CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ { } } } -impl From> for CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_COption_APIErrorZDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZPtr { result } + CResult_COption_APIErrorZDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZPtr { err } + CResult_COption_APIErrorZDecodeErrorZPtr { err } }; Self { contents, @@ -9634,91 +9773,95 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_COption_APIErrorZDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_COption_APIErrorZDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ which has the same data as `orig` +/// Creates a new CResult_COption_APIErrorZDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(orig: &CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ) -> CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_COption_APIErrorZDecodeErrorZ_clone(orig: &CResult_COption_APIErrorZDecodeErrorZ) -> CResult_COption_APIErrorZDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_PaymentSecretNoneZ -pub union CResult_PaymentSecretNoneZPtr { +/// The contents of CResult_ChannelMonitorUpdateDecodeErrorZ +pub union CResult_ChannelMonitorUpdateDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::ThirtyTwoBytes, - /// Note that this value is always NULL, as there are no contents in the Err variant - pub err: *mut core::ffi::c_void, + pub result: *mut crate::lightning::chain::channelmonitor::ChannelMonitorUpdate, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_PaymentSecretNoneZ represents the result of a fallible operation, -/// containing a crate::c_types::ThirtyTwoBytes on success and a () on failure. +/// A CResult_ChannelMonitorUpdateDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::chain::channelmonitor::ChannelMonitorUpdate on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_PaymentSecretNoneZ { - /// The contents of this CResult_PaymentSecretNoneZ, accessible via either +pub struct CResult_ChannelMonitorUpdateDecodeErrorZ { + /// The contents of this CResult_ChannelMonitorUpdateDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_PaymentSecretNoneZPtr, - /// Whether this CResult_PaymentSecretNoneZ represents a success state. + pub contents: CResult_ChannelMonitorUpdateDecodeErrorZPtr, + /// Whether this CResult_ChannelMonitorUpdateDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_PaymentSecretNoneZ in the success state. -pub extern "C" fn CResult_PaymentSecretNoneZ_ok(o: crate::c_types::ThirtyTwoBytes) -> CResult_PaymentSecretNoneZ { - CResult_PaymentSecretNoneZ { - contents: CResult_PaymentSecretNoneZPtr { +/// Creates a new CResult_ChannelMonitorUpdateDecodeErrorZ in the success state. +pub extern "C" fn CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o: crate::lightning::chain::channelmonitor::ChannelMonitorUpdate) -> CResult_ChannelMonitorUpdateDecodeErrorZ { + CResult_ChannelMonitorUpdateDecodeErrorZ { + contents: CResult_ChannelMonitorUpdateDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_PaymentSecretNoneZ in the error state. -pub extern "C" fn CResult_PaymentSecretNoneZ_err() -> CResult_PaymentSecretNoneZ { - CResult_PaymentSecretNoneZ { - contents: CResult_PaymentSecretNoneZPtr { - err: core::ptr::null_mut(), +/// Creates a new CResult_ChannelMonitorUpdateDecodeErrorZ in the error state. +pub extern "C" fn CResult_ChannelMonitorUpdateDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelMonitorUpdateDecodeErrorZ { + CResult_ChannelMonitorUpdateDecodeErrorZ { + contents: CResult_ChannelMonitorUpdateDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_PaymentSecretNoneZ_is_ok(o: &CResult_PaymentSecretNoneZ) -> bool { +pub extern "C" fn CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(o: &CResult_ChannelMonitorUpdateDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_PaymentSecretNoneZ. -pub extern "C" fn CResult_PaymentSecretNoneZ_free(_res: CResult_PaymentSecretNoneZ) { } -impl Drop for CResult_PaymentSecretNoneZ { +/// Frees any resources used by the CResult_ChannelMonitorUpdateDecodeErrorZ. +pub extern "C" fn CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res: CResult_ChannelMonitorUpdateDecodeErrorZ) { } +impl Drop for CResult_ChannelMonitorUpdateDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } } } } -impl From> for CResult_PaymentSecretNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ChannelMonitorUpdateDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_PaymentSecretNoneZPtr { result } + CResult_ChannelMonitorUpdateDecodeErrorZPtr { result } } else { - let _ = unsafe { Box::from_raw(o.contents.err) }; - o.contents.err = core::ptr::null_mut(); - CResult_PaymentSecretNoneZPtr { err: core::ptr::null_mut() } + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_ChannelMonitorUpdateDecodeErrorZPtr { err } }; Self { contents, @@ -9726,59 +9869,96 @@ impl From> for } } } -impl Clone for CResult_PaymentSecretNoneZ { +impl Clone for CResult_ChannelMonitorUpdateDecodeErrorZ { fn clone(&self) -> Self { if self.result_ok { - Self { result_ok: true, contents: CResult_PaymentSecretNoneZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_ChannelMonitorUpdateDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_PaymentSecretNoneZPtr { - err: core::ptr::null_mut() + Self { result_ok: false, contents: CResult_ChannelMonitorUpdateDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_PaymentSecretNoneZ which has the same data as `orig` +/// Creates a new CResult_ChannelMonitorUpdateDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_PaymentSecretNoneZ_clone(orig: &CResult_PaymentSecretNoneZ) -> CResult_PaymentSecretNoneZ { Clone::clone(&orig) } +pub extern "C" fn CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig: &CResult_ChannelMonitorUpdateDecodeErrorZ) -> CResult_ChannelMonitorUpdateDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +#[derive(Clone)] +/// An enum which can either contain a crate::lightning::chain::channelmonitor::MonitorEvent or not +pub enum COption_MonitorEventZ { + /// When we're in this state, this COption_MonitorEventZ contains a crate::lightning::chain::channelmonitor::MonitorEvent + Some(crate::lightning::chain::channelmonitor::MonitorEvent), + /// When we're in this state, this COption_MonitorEventZ contains nothing + None +} +impl COption_MonitorEventZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::chain::channelmonitor::MonitorEvent { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_MonitorEventZ containing a crate::lightning::chain::channelmonitor::MonitorEvent +pub extern "C" fn COption_MonitorEventZ_some(o: crate::lightning::chain::channelmonitor::MonitorEvent) -> COption_MonitorEventZ { + COption_MonitorEventZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_MonitorEventZ containing nothing +pub extern "C" fn COption_MonitorEventZ_none() -> COption_MonitorEventZ { + COption_MonitorEventZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::lightning::chain::channelmonitor::MonitorEvent, if we are in the Some state +pub extern "C" fn COption_MonitorEventZ_free(_res: COption_MonitorEventZ) { } +#[no_mangle] +/// Creates a new COption_MonitorEventZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_MonitorEventZ_clone(orig: &COption_MonitorEventZ) -> COption_MonitorEventZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_PaymentSecretAPIErrorZ -pub union CResult_PaymentSecretAPIErrorZPtr { +/// The contents of CResult_COption_MonitorEventZDecodeErrorZ +pub union CResult_COption_MonitorEventZDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::ThirtyTwoBytes, + pub result: *mut crate::c_types::derived::COption_MonitorEventZ, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::util::errors::APIError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_PaymentSecretAPIErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::ThirtyTwoBytes on success and a crate::lightning::util::errors::APIError on failure. +/// A CResult_COption_MonitorEventZDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::COption_MonitorEventZ on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_PaymentSecretAPIErrorZ { - /// The contents of this CResult_PaymentSecretAPIErrorZ, accessible via either +pub struct CResult_COption_MonitorEventZDecodeErrorZ { + /// The contents of this CResult_COption_MonitorEventZDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_PaymentSecretAPIErrorZPtr, - /// Whether this CResult_PaymentSecretAPIErrorZ represents a success state. + pub contents: CResult_COption_MonitorEventZDecodeErrorZPtr, + /// Whether this CResult_COption_MonitorEventZDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_PaymentSecretAPIErrorZ in the success state. -pub extern "C" fn CResult_PaymentSecretAPIErrorZ_ok(o: crate::c_types::ThirtyTwoBytes) -> CResult_PaymentSecretAPIErrorZ { - CResult_PaymentSecretAPIErrorZ { - contents: CResult_PaymentSecretAPIErrorZPtr { +/// Creates a new CResult_COption_MonitorEventZDecodeErrorZ in the success state. +pub extern "C" fn CResult_COption_MonitorEventZDecodeErrorZ_ok(o: crate::c_types::derived::COption_MonitorEventZ) -> CResult_COption_MonitorEventZDecodeErrorZ { + CResult_COption_MonitorEventZDecodeErrorZ { + contents: CResult_COption_MonitorEventZDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_PaymentSecretAPIErrorZ in the error state. -pub extern "C" fn CResult_PaymentSecretAPIErrorZ_err(e: crate::lightning::util::errors::APIError) -> CResult_PaymentSecretAPIErrorZ { - CResult_PaymentSecretAPIErrorZ { - contents: CResult_PaymentSecretAPIErrorZPtr { +/// Creates a new CResult_COption_MonitorEventZDecodeErrorZ in the error state. +pub extern "C" fn CResult_COption_MonitorEventZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_COption_MonitorEventZDecodeErrorZ { + CResult_COption_MonitorEventZDecodeErrorZ { + contents: CResult_COption_MonitorEventZDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -9786,13 +9966,13 @@ pub extern "C" fn CResult_PaymentSecretAPIErrorZ_err(e: crate::lightning::util:: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_PaymentSecretAPIErrorZ_is_ok(o: &CResult_PaymentSecretAPIErrorZ) -> bool { +pub extern "C" fn CResult_COption_MonitorEventZDecodeErrorZ_is_ok(o: &CResult_COption_MonitorEventZDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_PaymentSecretAPIErrorZ. -pub extern "C" fn CResult_PaymentSecretAPIErrorZ_free(_res: CResult_PaymentSecretAPIErrorZ) { } -impl Drop for CResult_PaymentSecretAPIErrorZ { +/// Frees any resources used by the CResult_COption_MonitorEventZDecodeErrorZ. +pub extern "C" fn CResult_COption_MonitorEventZDecodeErrorZ_free(_res: CResult_COption_MonitorEventZDecodeErrorZ) { } +impl Drop for CResult_COption_MonitorEventZDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -9805,16 +9985,16 @@ impl Drop for CResult_PaymentSecretAPIErrorZ { } } } -impl From> for CResult_PaymentSecretAPIErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_COption_MonitorEventZDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_PaymentSecretAPIErrorZPtr { result } + CResult_COption_MonitorEventZDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_PaymentSecretAPIErrorZPtr { err } + CResult_COption_MonitorEventZDecodeErrorZPtr { err } }; Self { contents, @@ -9822,59 +10002,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_PaymentSecretAPIErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_COption_MonitorEventZDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_PaymentSecretAPIErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_COption_MonitorEventZDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_PaymentSecretAPIErrorZ which has the same data as `orig` +/// Creates a new CResult_COption_MonitorEventZDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_PaymentSecretAPIErrorZ_clone(orig: &CResult_PaymentSecretAPIErrorZ) -> CResult_PaymentSecretAPIErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_COption_MonitorEventZDecodeErrorZ_clone(orig: &CResult_COption_MonitorEventZDecodeErrorZ) -> CResult_COption_MonitorEventZDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_PaymentPreimageAPIErrorZ -pub union CResult_PaymentPreimageAPIErrorZPtr { +/// The contents of CResult_HTLCUpdateDecodeErrorZ +pub union CResult_HTLCUpdateDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::ThirtyTwoBytes, + pub result: *mut crate::lightning::chain::channelmonitor::HTLCUpdate, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::util::errors::APIError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_PaymentPreimageAPIErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::ThirtyTwoBytes on success and a crate::lightning::util::errors::APIError on failure. +/// A CResult_HTLCUpdateDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::chain::channelmonitor::HTLCUpdate on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_PaymentPreimageAPIErrorZ { - /// The contents of this CResult_PaymentPreimageAPIErrorZ, accessible via either +pub struct CResult_HTLCUpdateDecodeErrorZ { + /// The contents of this CResult_HTLCUpdateDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_PaymentPreimageAPIErrorZPtr, - /// Whether this CResult_PaymentPreimageAPIErrorZ represents a success state. + pub contents: CResult_HTLCUpdateDecodeErrorZPtr, + /// Whether this CResult_HTLCUpdateDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_PaymentPreimageAPIErrorZ in the success state. -pub extern "C" fn CResult_PaymentPreimageAPIErrorZ_ok(o: crate::c_types::ThirtyTwoBytes) -> CResult_PaymentPreimageAPIErrorZ { - CResult_PaymentPreimageAPIErrorZ { - contents: CResult_PaymentPreimageAPIErrorZPtr { +/// Creates a new CResult_HTLCUpdateDecodeErrorZ in the success state. +pub extern "C" fn CResult_HTLCUpdateDecodeErrorZ_ok(o: crate::lightning::chain::channelmonitor::HTLCUpdate) -> CResult_HTLCUpdateDecodeErrorZ { + CResult_HTLCUpdateDecodeErrorZ { + contents: CResult_HTLCUpdateDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_PaymentPreimageAPIErrorZ in the error state. -pub extern "C" fn CResult_PaymentPreimageAPIErrorZ_err(e: crate::lightning::util::errors::APIError) -> CResult_PaymentPreimageAPIErrorZ { - CResult_PaymentPreimageAPIErrorZ { - contents: CResult_PaymentPreimageAPIErrorZPtr { +/// Creates a new CResult_HTLCUpdateDecodeErrorZ in the error state. +pub extern "C" fn CResult_HTLCUpdateDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_HTLCUpdateDecodeErrorZ { + CResult_HTLCUpdateDecodeErrorZ { + contents: CResult_HTLCUpdateDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -9882,13 +10062,13 @@ pub extern "C" fn CResult_PaymentPreimageAPIErrorZ_err(e: crate::lightning::util } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_PaymentPreimageAPIErrorZ_is_ok(o: &CResult_PaymentPreimageAPIErrorZ) -> bool { +pub extern "C" fn CResult_HTLCUpdateDecodeErrorZ_is_ok(o: &CResult_HTLCUpdateDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_PaymentPreimageAPIErrorZ. -pub extern "C" fn CResult_PaymentPreimageAPIErrorZ_free(_res: CResult_PaymentPreimageAPIErrorZ) { } -impl Drop for CResult_PaymentPreimageAPIErrorZ { +/// Frees any resources used by the CResult_HTLCUpdateDecodeErrorZ. +pub extern "C" fn CResult_HTLCUpdateDecodeErrorZ_free(_res: CResult_HTLCUpdateDecodeErrorZ) { } +impl Drop for CResult_HTLCUpdateDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -9901,16 +10081,16 @@ impl Drop for CResult_PaymentPreimageAPIErrorZ { } } } -impl From> for CResult_PaymentPreimageAPIErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_HTLCUpdateDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_PaymentPreimageAPIErrorZPtr { result } + CResult_HTLCUpdateDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_PaymentPreimageAPIErrorZPtr { err } + CResult_HTLCUpdateDecodeErrorZPtr { err } }; Self { contents, @@ -9918,431 +10098,353 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_PaymentPreimageAPIErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_HTLCUpdateDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_PaymentPreimageAPIErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_HTLCUpdateDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_PaymentPreimageAPIErrorZ which has the same data as `orig` +/// Creates a new CResult_HTLCUpdateDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_PaymentPreimageAPIErrorZ_clone(orig: &CResult_PaymentPreimageAPIErrorZ) -> CResult_PaymentPreimageAPIErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_HTLCUpdateDecodeErrorZ_clone(orig: &CResult_HTLCUpdateDecodeErrorZ) -> CResult_HTLCUpdateDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_CounterpartyForwardingInfoDecodeErrorZ -pub union CResult_CounterpartyForwardingInfoDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::channelmanager::CounterpartyForwardingInfo, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_OutPointScriptZ { + /// The element at position 0 + pub a: crate::lightning::chain::transaction::OutPoint, + /// The element at position 1 + pub b: crate::c_types::derived::CVec_u8Z, } -#[repr(C)] -/// A CResult_CounterpartyForwardingInfoDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::channelmanager::CounterpartyForwardingInfo on success and a crate::lightning::ln::msgs::DecodeError on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_CounterpartyForwardingInfoDecodeErrorZ { - /// The contents of this CResult_CounterpartyForwardingInfoDecodeErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_CounterpartyForwardingInfoDecodeErrorZPtr, - /// Whether this CResult_CounterpartyForwardingInfoDecodeErrorZ represents a success state. - pub result_ok: bool, +impl From<(crate::lightning::chain::transaction::OutPoint, crate::c_types::derived::CVec_u8Z)> for C2Tuple_OutPointScriptZ { + fn from (tup: (crate::lightning::chain::transaction::OutPoint, crate::c_types::derived::CVec_u8Z)) -> Self { + Self { + a: tup.0, + b: tup.1, + } + } } -#[no_mangle] -/// Creates a new CResult_CounterpartyForwardingInfoDecodeErrorZ in the success state. -pub extern "C" fn CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(o: crate::lightning::ln::channelmanager::CounterpartyForwardingInfo) -> CResult_CounterpartyForwardingInfoDecodeErrorZ { - CResult_CounterpartyForwardingInfoDecodeErrorZ { - contents: CResult_CounterpartyForwardingInfoDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, +impl C2Tuple_OutPointScriptZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::lightning::chain::transaction::OutPoint, crate::c_types::derived::CVec_u8Z) { + (self.a, self.b) } } -#[no_mangle] -/// Creates a new CResult_CounterpartyForwardingInfoDecodeErrorZ in the error state. -pub extern "C" fn CResult_CounterpartyForwardingInfoDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_CounterpartyForwardingInfoDecodeErrorZ { - CResult_CounterpartyForwardingInfoDecodeErrorZ { - contents: CResult_CounterpartyForwardingInfoDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), - }, - result_ok: false, +impl Clone for C2Tuple_OutPointScriptZ { + fn clone(&self) -> Self { + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), + } } } -/// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(o: &CResult_CounterpartyForwardingInfoDecodeErrorZ) -> bool { - o.result_ok +/// Creates a new tuple which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn C2Tuple_OutPointScriptZ_clone(orig: &C2Tuple_OutPointScriptZ) -> C2Tuple_OutPointScriptZ { Clone::clone(&orig) } +/// Creates a new C2Tuple_OutPointScriptZ from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_OutPointScriptZ_new(a: crate::lightning::chain::transaction::OutPoint, b: crate::c_types::derived::CVec_u8Z) -> C2Tuple_OutPointScriptZ { + C2Tuple_OutPointScriptZ { a, b, } } + #[no_mangle] -/// Frees any resources used by the CResult_CounterpartyForwardingInfoDecodeErrorZ. -pub extern "C" fn CResult_CounterpartyForwardingInfoDecodeErrorZ_free(_res: CResult_CounterpartyForwardingInfoDecodeErrorZ) { } -impl Drop for CResult_CounterpartyForwardingInfoDecodeErrorZ { - fn drop(&mut self) { - if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } - } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } - } - } +/// Frees any resources used by the C2Tuple_OutPointScriptZ. +pub extern "C" fn C2Tuple_OutPointScriptZ_free(_res: C2Tuple_OutPointScriptZ) { } +#[repr(C)] +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_u32ScriptZ { + /// The element at position 0 + pub a: u32, + /// The element at position 1 + pub b: crate::c_types::derived::CVec_u8Z, } -impl From> for CResult_CounterpartyForwardingInfoDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { - let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_CounterpartyForwardingInfoDecodeErrorZPtr { result } - } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_CounterpartyForwardingInfoDecodeErrorZPtr { err } - }; +impl From<(u32, crate::c_types::derived::CVec_u8Z)> for C2Tuple_u32ScriptZ { + fn from (tup: (u32, crate::c_types::derived::CVec_u8Z)) -> Self { Self { - contents, - result_ok: o.result_ok, + a: tup.0, + b: tup.1, } } } -impl Clone for CResult_CounterpartyForwardingInfoDecodeErrorZ { +impl C2Tuple_u32ScriptZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (u32, crate::c_types::derived::CVec_u8Z) { + (self.a, self.b) + } +} +impl Clone for C2Tuple_u32ScriptZ { fn clone(&self) -> Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_CounterpartyForwardingInfoDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_CounterpartyForwardingInfoDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), } } } #[no_mangle] -/// Creates a new CResult_CounterpartyForwardingInfoDecodeErrorZ which has the same data as `orig` +/// Creates a new tuple which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(orig: &CResult_CounterpartyForwardingInfoDecodeErrorZ) -> CResult_CounterpartyForwardingInfoDecodeErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// The contents of CResult_ChannelCounterpartyDecodeErrorZ -pub union CResult_ChannelCounterpartyDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::channelmanager::ChannelCounterparty, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, +pub extern "C" fn C2Tuple_u32ScriptZ_clone(orig: &C2Tuple_u32ScriptZ) -> C2Tuple_u32ScriptZ { Clone::clone(&orig) } +/// Creates a new C2Tuple_u32ScriptZ from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_u32ScriptZ_new(a: u32, b: crate::c_types::derived::CVec_u8Z) -> C2Tuple_u32ScriptZ { + C2Tuple_u32ScriptZ { a, b, } } + +#[no_mangle] +/// Frees any resources used by the C2Tuple_u32ScriptZ. +pub extern "C" fn C2Tuple_u32ScriptZ_free(_res: C2Tuple_u32ScriptZ) { } #[repr(C)] -/// A CResult_ChannelCounterpartyDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::channelmanager::ChannelCounterparty on success and a crate::lightning::ln::msgs::DecodeError on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ChannelCounterpartyDecodeErrorZ { - /// The contents of this CResult_ChannelCounterpartyDecodeErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ChannelCounterpartyDecodeErrorZPtr, - /// Whether this CResult_ChannelCounterpartyDecodeErrorZ represents a success state. - pub result_ok: bool, +/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_u32ScriptZs of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_C2Tuple_u32ScriptZZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::derived::C2Tuple_u32ScriptZ, + /// The number of elements pointed to by `data`. + pub datalen: usize } -#[no_mangle] -/// Creates a new CResult_ChannelCounterpartyDecodeErrorZ in the success state. -pub extern "C" fn CResult_ChannelCounterpartyDecodeErrorZ_ok(o: crate::lightning::ln::channelmanager::ChannelCounterparty) -> CResult_ChannelCounterpartyDecodeErrorZ { - CResult_ChannelCounterpartyDecodeErrorZ { - contents: CResult_ChannelCounterpartyDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, +impl CVec_C2Tuple_u32ScriptZZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret } -} -#[no_mangle] -/// Creates a new CResult_ChannelCounterpartyDecodeErrorZ in the error state. -pub extern "C" fn CResult_ChannelCounterpartyDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelCounterpartyDecodeErrorZ { - CResult_ChannelCounterpartyDecodeErrorZ { - contents: CResult_ChannelCounterpartyDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), - }, - result_ok: false, + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_u32ScriptZ] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -/// Checks if the given object is currently in the success state -#[no_mangle] -pub extern "C" fn CResult_ChannelCounterpartyDecodeErrorZ_is_ok(o: &CResult_ChannelCounterpartyDecodeErrorZ) -> bool { - o.result_ok +impl From> for CVec_C2Tuple_u32ScriptZZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } } #[no_mangle] -/// Frees any resources used by the CResult_ChannelCounterpartyDecodeErrorZ. -pub extern "C" fn CResult_ChannelCounterpartyDecodeErrorZ_free(_res: CResult_ChannelCounterpartyDecodeErrorZ) { } -impl Drop for CResult_ChannelCounterpartyDecodeErrorZ { +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_C2Tuple_u32ScriptZZ_free(_res: CVec_C2Tuple_u32ScriptZZ) { } +impl Drop for CVec_C2Tuple_u32ScriptZZ { fn drop(&mut self) { - if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } - } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } - } + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl From> for CResult_ChannelCounterpartyDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { - let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ChannelCounterpartyDecodeErrorZPtr { result } - } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ChannelCounterpartyDecodeErrorZPtr { err } - }; +impl Clone for CVec_C2Tuple_u32ScriptZZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ { + /// The element at position 0 + pub a: crate::c_types::ThirtyTwoBytes, + /// The element at position 1 + pub b: crate::c_types::derived::CVec_C2Tuple_u32ScriptZZ, +} +impl From<(crate::c_types::ThirtyTwoBytes, crate::c_types::derived::CVec_C2Tuple_u32ScriptZZ)> for C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ { + fn from (tup: (crate::c_types::ThirtyTwoBytes, crate::c_types::derived::CVec_C2Tuple_u32ScriptZZ)) -> Self { Self { - contents, - result_ok: o.result_ok, + a: tup.0, + b: tup.1, } } } -impl Clone for CResult_ChannelCounterpartyDecodeErrorZ { +impl C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoBytes, crate::c_types::derived::CVec_C2Tuple_u32ScriptZZ) { + (self.a, self.b) + } +} +impl Clone for C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ { fn clone(&self) -> Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_ChannelCounterpartyDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_ChannelCounterpartyDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), } } } #[no_mangle] -/// Creates a new CResult_ChannelCounterpartyDecodeErrorZ which has the same data as `orig` +/// Creates a new tuple which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ChannelCounterpartyDecodeErrorZ_clone(orig: &CResult_ChannelCounterpartyDecodeErrorZ) -> CResult_ChannelCounterpartyDecodeErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// The contents of CResult_ChannelDetailsDecodeErrorZ -pub union CResult_ChannelDetailsDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::channelmanager::ChannelDetails, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, +pub extern "C" fn C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig: &C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ) -> C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ { Clone::clone(&orig) } +/// Creates a new C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a: crate::c_types::ThirtyTwoBytes, b: crate::c_types::derived::CVec_C2Tuple_u32ScriptZZ) -> C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ { + C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ { a, b, } } + +#[no_mangle] +/// Frees any resources used by the C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ. +pub extern "C" fn C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res: C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ) { } #[repr(C)] -/// A CResult_ChannelDetailsDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::channelmanager::ChannelDetails on success and a crate::lightning::ln::msgs::DecodeError on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ChannelDetailsDecodeErrorZ { - /// The contents of this CResult_ChannelDetailsDecodeErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ChannelDetailsDecodeErrorZPtr, - /// Whether this CResult_ChannelDetailsDecodeErrorZ represents a success state. - pub result_ok: bool, +/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZs of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ, + /// The number of elements pointed to by `data`. + pub datalen: usize } -#[no_mangle] -/// Creates a new CResult_ChannelDetailsDecodeErrorZ in the success state. -pub extern "C" fn CResult_ChannelDetailsDecodeErrorZ_ok(o: crate::lightning::ln::channelmanager::ChannelDetails) -> CResult_ChannelDetailsDecodeErrorZ { - CResult_ChannelDetailsDecodeErrorZ { - contents: CResult_ChannelDetailsDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, +impl CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret } -} -#[no_mangle] -/// Creates a new CResult_ChannelDetailsDecodeErrorZ in the error state. -pub extern "C" fn CResult_ChannelDetailsDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelDetailsDecodeErrorZ { - CResult_ChannelDetailsDecodeErrorZ { - contents: CResult_ChannelDetailsDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), - }, - result_ok: false, + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -/// Checks if the given object is currently in the success state -#[no_mangle] -pub extern "C" fn CResult_ChannelDetailsDecodeErrorZ_is_ok(o: &CResult_ChannelDetailsDecodeErrorZ) -> bool { - o.result_ok +impl From> for CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } } #[no_mangle] -/// Frees any resources used by the CResult_ChannelDetailsDecodeErrorZ. -pub extern "C" fn CResult_ChannelDetailsDecodeErrorZ_free(_res: CResult_ChannelDetailsDecodeErrorZ) { } -impl Drop for CResult_ChannelDetailsDecodeErrorZ { +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res: CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ) { } +impl Drop for CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ { fn drop(&mut self) { - if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } - } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } - } - } -} -impl From> for CResult_ChannelDetailsDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { - let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ChannelDetailsDecodeErrorZPtr { result } - } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ChannelDetailsDecodeErrorZPtr { err } - }; - Self { - contents, - result_ok: o.result_ok, - } + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl Clone for CResult_ChannelDetailsDecodeErrorZ { +impl Clone for CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ { fn clone(&self) -> Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_ChannelDetailsDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_ChannelDetailsDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } - } + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) } } -#[no_mangle] -/// Creates a new CResult_ChannelDetailsDecodeErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ChannelDetailsDecodeErrorZ_clone(orig: &CResult_ChannelDetailsDecodeErrorZ) -> CResult_ChannelDetailsDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_PhantomRouteHintsDecodeErrorZ -pub union CResult_PhantomRouteHintsDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::channelmanager::PhantomRouteHints, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, +/// A dynamically-allocated array of crate::c_types::Transactions of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_TransactionZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::Transaction, + /// The number of elements pointed to by `data`. + pub datalen: usize } -#[repr(C)] -/// A CResult_PhantomRouteHintsDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::channelmanager::PhantomRouteHints on success and a crate::lightning::ln::msgs::DecodeError on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_PhantomRouteHintsDecodeErrorZ { - /// The contents of this CResult_PhantomRouteHintsDecodeErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_PhantomRouteHintsDecodeErrorZPtr, - /// Whether this CResult_PhantomRouteHintsDecodeErrorZ represents a success state. - pub result_ok: bool, +impl CVec_TransactionZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::Transaction] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } } -#[no_mangle] -/// Creates a new CResult_PhantomRouteHintsDecodeErrorZ in the success state. -pub extern "C" fn CResult_PhantomRouteHintsDecodeErrorZ_ok(o: crate::lightning::ln::channelmanager::PhantomRouteHints) -> CResult_PhantomRouteHintsDecodeErrorZ { - CResult_PhantomRouteHintsDecodeErrorZ { - contents: CResult_PhantomRouteHintsDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, +impl From> for CVec_TransactionZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } } } #[no_mangle] -/// Creates a new CResult_PhantomRouteHintsDecodeErrorZ in the error state. -pub extern "C" fn CResult_PhantomRouteHintsDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_PhantomRouteHintsDecodeErrorZ { - CResult_PhantomRouteHintsDecodeErrorZ { - contents: CResult_PhantomRouteHintsDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), - }, - result_ok: false, +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_TransactionZ_free(_res: CVec_TransactionZ) { } +impl Drop for CVec_TransactionZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -/// Checks if the given object is currently in the success state -#[no_mangle] -pub extern "C" fn CResult_PhantomRouteHintsDecodeErrorZ_is_ok(o: &CResult_PhantomRouteHintsDecodeErrorZ) -> bool { - o.result_ok -} -#[no_mangle] -/// Frees any resources used by the CResult_PhantomRouteHintsDecodeErrorZ. -pub extern "C" fn CResult_PhantomRouteHintsDecodeErrorZ_free(_res: CResult_PhantomRouteHintsDecodeErrorZ) { } -impl Drop for CResult_PhantomRouteHintsDecodeErrorZ { - fn drop(&mut self) { - if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } - } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } - } +impl Clone for CVec_TransactionZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) } } -impl From> for CResult_PhantomRouteHintsDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { - let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_PhantomRouteHintsDecodeErrorZPtr { result } - } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_PhantomRouteHintsDecodeErrorZPtr { err } - }; +#[repr(C)] +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_u32TxOutZ { + /// The element at position 0 + pub a: u32, + /// The element at position 1 + pub b: crate::c_types::TxOut, +} +impl From<(u32, crate::c_types::TxOut)> for C2Tuple_u32TxOutZ { + fn from (tup: (u32, crate::c_types::TxOut)) -> Self { Self { - contents, - result_ok: o.result_ok, + a: tup.0, + b: tup.1, } } } -impl Clone for CResult_PhantomRouteHintsDecodeErrorZ { +impl C2Tuple_u32TxOutZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (u32, crate::c_types::TxOut) { + (self.a, self.b) + } +} +impl Clone for C2Tuple_u32TxOutZ { fn clone(&self) -> Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_PhantomRouteHintsDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_PhantomRouteHintsDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), } } } #[no_mangle] -/// Creates a new CResult_PhantomRouteHintsDecodeErrorZ which has the same data as `orig` +/// Creates a new tuple which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_PhantomRouteHintsDecodeErrorZ_clone(orig: &CResult_PhantomRouteHintsDecodeErrorZ) -> CResult_PhantomRouteHintsDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn C2Tuple_u32TxOutZ_clone(orig: &C2Tuple_u32TxOutZ) -> C2Tuple_u32TxOutZ { Clone::clone(&orig) } +/// Creates a new C2Tuple_u32TxOutZ from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_u32TxOutZ_new(a: u32, b: crate::c_types::TxOut) -> C2Tuple_u32TxOutZ { + C2Tuple_u32TxOutZ { a, b, } +} + +#[no_mangle] +/// Frees any resources used by the C2Tuple_u32TxOutZ. +pub extern "C" fn C2Tuple_u32TxOutZ_free(_res: C2Tuple_u32TxOutZ) { } #[repr(C)] -/// A dynamically-allocated array of crate::lightning::chain::channelmonitor::ChannelMonitors of arbitrary size. +/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_u32TxOutZs of arbitrary size. /// This corresponds to std::vector in C++ -pub struct CVec_ChannelMonitorZ { +pub struct CVec_C2Tuple_u32TxOutZZ { /// The elements in the array. /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::chain::channelmonitor::ChannelMonitor, + pub data: *mut crate::c_types::derived::C2Tuple_u32TxOutZ, /// The number of elements pointed to by `data`. pub datalen: usize } -impl CVec_ChannelMonitorZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { +impl CVec_C2Tuple_u32TxOutZZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { if self.datalen == 0 { return Vec::new(); } let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); self.data = core::ptr::null_mut(); self.datalen = 0; ret } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::chain::channelmonitor::ChannelMonitor] { + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_u32TxOutZ] { unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl From> for CVec_ChannelMonitorZ { - fn from(v: Vec) -> Self { +impl From> for CVec_C2Tuple_u32TxOutZZ { + fn from(v: Vec) -> Self { let datalen = v.len(); let data = Box::into_raw(v.into_boxed_slice()); Self { datalen, data: unsafe { (*data).as_mut_ptr() } } @@ -10350,158 +10452,221 @@ impl From> for CVec } #[no_mangle] /// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_ChannelMonitorZ_free(_res: CVec_ChannelMonitorZ) { } -impl Drop for CVec_ChannelMonitorZ { +pub extern "C" fn CVec_C2Tuple_u32TxOutZZ_free(_res: CVec_C2Tuple_u32TxOutZZ) { } +impl Drop for CVec_C2Tuple_u32TxOutZZ { fn drop(&mut self) { if self.datalen == 0 { return; } let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } +impl Clone for CVec_C2Tuple_u32TxOutZZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} #[repr(C)] /// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple_BlockHashChannelManagerZ { +pub struct C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ { /// The element at position 0 pub a: crate::c_types::ThirtyTwoBytes, /// The element at position 1 - pub b: crate::lightning::ln::channelmanager::ChannelManager, + pub b: crate::c_types::derived::CVec_C2Tuple_u32TxOutZZ, } -impl From<(crate::c_types::ThirtyTwoBytes, crate::lightning::ln::channelmanager::ChannelManager)> for C2Tuple_BlockHashChannelManagerZ { - fn from (tup: (crate::c_types::ThirtyTwoBytes, crate::lightning::ln::channelmanager::ChannelManager)) -> Self { +impl From<(crate::c_types::ThirtyTwoBytes, crate::c_types::derived::CVec_C2Tuple_u32TxOutZZ)> for C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ { + fn from (tup: (crate::c_types::ThirtyTwoBytes, crate::c_types::derived::CVec_C2Tuple_u32TxOutZZ)) -> Self { Self { a: tup.0, b: tup.1, } } } -impl C2Tuple_BlockHashChannelManagerZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoBytes, crate::lightning::ln::channelmanager::ChannelManager) { +impl C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoBytes, crate::c_types::derived::CVec_C2Tuple_u32TxOutZZ) { (self.a, self.b) } } -/// Creates a new C2Tuple_BlockHashChannelManagerZ from the contained elements. +impl Clone for C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ { + fn clone(&self) -> Self { + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), + } + } +} #[no_mangle] -pub extern "C" fn C2Tuple_BlockHashChannelManagerZ_new(a: crate::c_types::ThirtyTwoBytes, b: crate::lightning::ln::channelmanager::ChannelManager) -> C2Tuple_BlockHashChannelManagerZ { - C2Tuple_BlockHashChannelManagerZ { a, b, } +/// Creates a new tuple which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig: &C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ) -> C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ { Clone::clone(&orig) } +/// Creates a new C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a: crate::c_types::ThirtyTwoBytes, b: crate::c_types::derived::CVec_C2Tuple_u32TxOutZZ) -> C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ { + C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ { a, b, } } #[no_mangle] -/// Frees any resources used by the C2Tuple_BlockHashChannelManagerZ. -pub extern "C" fn C2Tuple_BlockHashChannelManagerZ_free(_res: C2Tuple_BlockHashChannelManagerZ) { } -#[repr(C)] -/// The contents of CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ -pub union CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::C2Tuple_BlockHashChannelManagerZ, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, -} +/// Frees any resources used by the C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ. +pub extern "C" fn C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res: C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ) { } #[repr(C)] -/// A CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::C2Tuple_BlockHashChannelManagerZ on success and a crate::lightning::ln::msgs::DecodeError on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ { - /// The contents of this CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr, - /// Whether this CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ represents a success state. - pub result_ok: bool, +/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZs of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_TransactionOutputsZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ, + /// The number of elements pointed to by `data`. + pub datalen: usize } -#[no_mangle] -/// Creates a new CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ in the success state. -pub extern "C" fn CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o: crate::c_types::derived::C2Tuple_BlockHashChannelManagerZ) -> CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ { - CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ { - contents: CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, +impl CVec_TransactionOutputsZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret } -} -#[no_mangle] -/// Creates a new CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ in the error state. -pub extern "C" fn CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ { - CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ { - contents: CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), - }, - result_ok: false, + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -/// Checks if the given object is currently in the success state -#[no_mangle] -pub extern "C" fn CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(o: &CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ) -> bool { - o.result_ok +impl From> for CVec_TransactionOutputsZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } } #[no_mangle] -/// Frees any resources used by the CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ. -pub extern "C" fn CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res: CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ) { } -impl Drop for CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ { +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_TransactionOutputsZ_free(_res: CVec_TransactionOutputsZ) { } +impl Drop for CVec_TransactionOutputsZ { fn drop(&mut self) { - if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } - } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } - } + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl From> for CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { - let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr { result } - } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr { err } - }; - Self { - contents, - result_ok: o.result_ok, - } +impl Clone for CVec_TransactionOutputsZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) } } #[repr(C)] -/// The contents of CResult_ChannelConfigDecodeErrorZ -pub union CResult_ChannelConfigDecodeErrorZPtr { +/// A dynamically-allocated array of crate::lightning::chain::channelmonitor::Balances of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_BalanceZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::chain::channelmonitor::Balance, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_BalanceZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::chain::channelmonitor::Balance] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_BalanceZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_BalanceZ_free(_res: CVec_BalanceZ) { } +impl Drop for CVec_BalanceZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_BalanceZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_BlockHashChannelMonitorZ { + /// The element at position 0 + pub a: crate::c_types::ThirtyTwoBytes, + /// The element at position 1 + pub b: crate::lightning::chain::channelmonitor::ChannelMonitor, +} +impl From<(crate::c_types::ThirtyTwoBytes, crate::lightning::chain::channelmonitor::ChannelMonitor)> for C2Tuple_BlockHashChannelMonitorZ { + fn from (tup: (crate::c_types::ThirtyTwoBytes, crate::lightning::chain::channelmonitor::ChannelMonitor)) -> Self { + Self { + a: tup.0, + b: tup.1, + } + } +} +impl C2Tuple_BlockHashChannelMonitorZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoBytes, crate::lightning::chain::channelmonitor::ChannelMonitor) { + (self.a, self.b) + } +} +/// Creates a new C2Tuple_BlockHashChannelMonitorZ from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_BlockHashChannelMonitorZ_new(a: crate::c_types::ThirtyTwoBytes, b: crate::lightning::chain::channelmonitor::ChannelMonitor) -> C2Tuple_BlockHashChannelMonitorZ { + C2Tuple_BlockHashChannelMonitorZ { a, b, } +} + +#[no_mangle] +/// Frees any resources used by the C2Tuple_BlockHashChannelMonitorZ. +pub extern "C" fn C2Tuple_BlockHashChannelMonitorZ_free(_res: C2Tuple_BlockHashChannelMonitorZ) { } +#[repr(C)] +/// The contents of CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ +pub union CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::util::config::ChannelConfig, + pub result: *mut crate::c_types::derived::C2Tuple_BlockHashChannelMonitorZ, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_ChannelConfigDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::util::config::ChannelConfig on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::C2Tuple_BlockHashChannelMonitorZ on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ChannelConfigDecodeErrorZ { - /// The contents of this CResult_ChannelConfigDecodeErrorZ, accessible via either +pub struct CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ { + /// The contents of this CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ChannelConfigDecodeErrorZPtr, - /// Whether this CResult_ChannelConfigDecodeErrorZ represents a success state. + pub contents: CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr, + /// Whether this CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ChannelConfigDecodeErrorZ in the success state. -pub extern "C" fn CResult_ChannelConfigDecodeErrorZ_ok(o: crate::lightning::util::config::ChannelConfig) -> CResult_ChannelConfigDecodeErrorZ { - CResult_ChannelConfigDecodeErrorZ { - contents: CResult_ChannelConfigDecodeErrorZPtr { +/// Creates a new CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ in the success state. +pub extern "C" fn CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o: crate::c_types::derived::C2Tuple_BlockHashChannelMonitorZ) -> CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ { + CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ { + contents: CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ChannelConfigDecodeErrorZ in the error state. -pub extern "C" fn CResult_ChannelConfigDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelConfigDecodeErrorZ { - CResult_ChannelConfigDecodeErrorZ { - contents: CResult_ChannelConfigDecodeErrorZPtr { +/// Creates a new CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ in the error state. +pub extern "C" fn CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ { + CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ { + contents: CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -10509,13 +10674,13 @@ pub extern "C" fn CResult_ChannelConfigDecodeErrorZ_err(e: crate::lightning::ln: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ChannelConfigDecodeErrorZ_is_ok(o: &CResult_ChannelConfigDecodeErrorZ) -> bool { +pub extern "C" fn CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(o: &CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_ChannelConfigDecodeErrorZ. -pub extern "C" fn CResult_ChannelConfigDecodeErrorZ_free(_res: CResult_ChannelConfigDecodeErrorZ) { } -impl Drop for CResult_ChannelConfigDecodeErrorZ { +/// Frees any resources used by the CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ. +pub extern "C" fn CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res: CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ) { } +impl Drop for CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -10528,16 +10693,16 @@ impl Drop for CResult_ChannelConfigDecodeErrorZ { } } } -impl From> for CResult_ChannelConfigDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ChannelConfigDecodeErrorZPtr { result } + CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ChannelConfigDecodeErrorZPtr { err } + CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr { err } }; Self { contents, @@ -10545,288 +10710,179 @@ impl From Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_ChannelConfigDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_ChannelConfigDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } +#[repr(C)] +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_PublicKeyTypeZ { + /// The element at position 0 + pub a: crate::c_types::PublicKey, + /// The element at position 1 + pub b: crate::lightning::ln::wire::Type, +} +impl From<(crate::c_types::PublicKey, crate::lightning::ln::wire::Type)> for C2Tuple_PublicKeyTypeZ { + fn from (tup: (crate::c_types::PublicKey, crate::lightning::ln::wire::Type)) -> Self { + Self { + a: tup.0, + b: tup.1, } } } +impl C2Tuple_PublicKeyTypeZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::PublicKey, crate::lightning::ln::wire::Type) { + (self.a, self.b) + } +} +/// Creates a new C2Tuple_PublicKeyTypeZ from the contained elements. #[no_mangle] -/// Creates a new CResult_ChannelConfigDecodeErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ChannelConfigDecodeErrorZ_clone(orig: &CResult_ChannelConfigDecodeErrorZ) -> CResult_ChannelConfigDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn C2Tuple_PublicKeyTypeZ_new(a: crate::c_types::PublicKey, b: crate::lightning::ln::wire::Type) -> C2Tuple_PublicKeyTypeZ { + C2Tuple_PublicKeyTypeZ { a, b, } +} + +#[no_mangle] +/// Frees any resources used by the C2Tuple_PublicKeyTypeZ. +pub extern "C" fn C2Tuple_PublicKeyTypeZ_free(_res: C2Tuple_PublicKeyTypeZ) { } +#[repr(C)] +/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_PublicKeyTypeZs of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_C2Tuple_PublicKeyTypeZZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::derived::C2Tuple_PublicKeyTypeZ, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_C2Tuple_PublicKeyTypeZZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_PublicKeyTypeZ] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_C2Tuple_PublicKeyTypeZZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_C2Tuple_PublicKeyTypeZZ_free(_res: CVec_C2Tuple_PublicKeyTypeZZ) { } +impl Drop for CVec_C2Tuple_PublicKeyTypeZZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} #[repr(C)] #[derive(Clone)] -/// An enum which can either contain a crate::lightning::util::errors::APIError or not -pub enum COption_APIErrorZ { - /// When we're in this state, this COption_APIErrorZ contains a crate::lightning::util::errors::APIError - Some(crate::lightning::util::errors::APIError), - /// When we're in this state, this COption_APIErrorZ contains nothing +/// An enum which can either contain a crate::lightning::onion_message::offers::OffersMessage or not +pub enum COption_OffersMessageZ { + /// When we're in this state, this COption_OffersMessageZ contains a crate::lightning::onion_message::offers::OffersMessage + Some(crate::lightning::onion_message::offers::OffersMessage), + /// When we're in this state, this COption_OffersMessageZ contains nothing None } -impl COption_APIErrorZ { +impl COption_OffersMessageZ { #[allow(unused)] pub(crate) fn is_some(&self) -> bool { if let Self::None = self { false } else { true } } #[allow(unused)] pub(crate) fn is_none(&self) -> bool { !self.is_some() } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::util::errors::APIError { + #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::onion_message::offers::OffersMessage { if let Self::Some(v) = self { v } else { unreachable!() } } } #[no_mangle] -/// Constructs a new COption_APIErrorZ containing a crate::lightning::util::errors::APIError -pub extern "C" fn COption_APIErrorZ_some(o: crate::lightning::util::errors::APIError) -> COption_APIErrorZ { - COption_APIErrorZ::Some(o) +/// Constructs a new COption_OffersMessageZ containing a crate::lightning::onion_message::offers::OffersMessage +pub extern "C" fn COption_OffersMessageZ_some(o: crate::lightning::onion_message::offers::OffersMessage) -> COption_OffersMessageZ { + COption_OffersMessageZ::Some(o) } #[no_mangle] -/// Constructs a new COption_APIErrorZ containing nothing -pub extern "C" fn COption_APIErrorZ_none() -> COption_APIErrorZ { - COption_APIErrorZ::None +/// Constructs a new COption_OffersMessageZ containing nothing +pub extern "C" fn COption_OffersMessageZ_none() -> COption_OffersMessageZ { + COption_OffersMessageZ::None } #[no_mangle] -/// Frees any resources associated with the crate::lightning::util::errors::APIError, if we are in the Some state -pub extern "C" fn COption_APIErrorZ_free(_res: COption_APIErrorZ) { } +/// Frees any resources associated with the crate::lightning::onion_message::offers::OffersMessage, if we are in the Some state +pub extern "C" fn COption_OffersMessageZ_free(_res: COption_OffersMessageZ) { } #[no_mangle] -/// Creates a new COption_APIErrorZ which has the same data as `orig` +/// Creates a new COption_OffersMessageZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_APIErrorZ_clone(orig: &COption_APIErrorZ) -> COption_APIErrorZ { Clone::clone(&orig) } +pub extern "C" fn COption_OffersMessageZ_clone(orig: &COption_OffersMessageZ) -> COption_OffersMessageZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_COption_APIErrorZDecodeErrorZ -pub union CResult_COption_APIErrorZDecodeErrorZPtr { +/// An enum which can either contain a crate::lightning::onion_message::packet::CustomOnionMessageContents or not +pub enum COption_CustomOnionMessageContentsZ { + /// When we're in this state, this COption_CustomOnionMessageContentsZ contains a crate::lightning::onion_message::packet::CustomOnionMessageContents + Some(crate::lightning::onion_message::packet::CustomOnionMessageContents), + /// When we're in this state, this COption_CustomOnionMessageContentsZ contains nothing + None +} +impl COption_CustomOnionMessageContentsZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::onion_message::packet::CustomOnionMessageContents { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_CustomOnionMessageContentsZ containing a crate::lightning::onion_message::packet::CustomOnionMessageContents +pub extern "C" fn COption_CustomOnionMessageContentsZ_some(o: crate::lightning::onion_message::packet::CustomOnionMessageContents) -> COption_CustomOnionMessageContentsZ { + COption_CustomOnionMessageContentsZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_CustomOnionMessageContentsZ containing nothing +pub extern "C" fn COption_CustomOnionMessageContentsZ_none() -> COption_CustomOnionMessageContentsZ { + COption_CustomOnionMessageContentsZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::lightning::onion_message::packet::CustomOnionMessageContents, if we are in the Some state +pub extern "C" fn COption_CustomOnionMessageContentsZ_free(_res: COption_CustomOnionMessageContentsZ) { } +#[repr(C)] +/// The contents of CResult_COption_CustomOnionMessageContentsZDecodeErrorZ +pub union CResult_COption_CustomOnionMessageContentsZDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::COption_APIErrorZ, + pub result: *mut crate::c_types::derived::COption_CustomOnionMessageContentsZ, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_COption_APIErrorZDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::COption_APIErrorZ on success and a crate::lightning::ln::msgs::DecodeError on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_COption_APIErrorZDecodeErrorZ { - /// The contents of this CResult_COption_APIErrorZDecodeErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_COption_APIErrorZDecodeErrorZPtr, - /// Whether this CResult_COption_APIErrorZDecodeErrorZ represents a success state. - pub result_ok: bool, -} -#[no_mangle] -/// Creates a new CResult_COption_APIErrorZDecodeErrorZ in the success state. -pub extern "C" fn CResult_COption_APIErrorZDecodeErrorZ_ok(o: crate::c_types::derived::COption_APIErrorZ) -> CResult_COption_APIErrorZDecodeErrorZ { - CResult_COption_APIErrorZDecodeErrorZ { - contents: CResult_COption_APIErrorZDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, - } -} -#[no_mangle] -/// Creates a new CResult_COption_APIErrorZDecodeErrorZ in the error state. -pub extern "C" fn CResult_COption_APIErrorZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_COption_APIErrorZDecodeErrorZ { - CResult_COption_APIErrorZDecodeErrorZ { - contents: CResult_COption_APIErrorZDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), - }, - result_ok: false, - } -} -/// Checks if the given object is currently in the success state -#[no_mangle] -pub extern "C" fn CResult_COption_APIErrorZDecodeErrorZ_is_ok(o: &CResult_COption_APIErrorZDecodeErrorZ) -> bool { - o.result_ok -} -#[no_mangle] -/// Frees any resources used by the CResult_COption_APIErrorZDecodeErrorZ. -pub extern "C" fn CResult_COption_APIErrorZDecodeErrorZ_free(_res: CResult_COption_APIErrorZDecodeErrorZ) { } -impl Drop for CResult_COption_APIErrorZDecodeErrorZ { - fn drop(&mut self) { - if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } - } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } - } - } -} -impl From> for CResult_COption_APIErrorZDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { - let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_COption_APIErrorZDecodeErrorZPtr { result } - } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_COption_APIErrorZDecodeErrorZPtr { err } - }; - Self { - contents, - result_ok: o.result_ok, - } - } -} -impl Clone for CResult_COption_APIErrorZDecodeErrorZ { - fn clone(&self) -> Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_COption_APIErrorZDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_COption_APIErrorZDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } - } - } -} -#[no_mangle] -/// Creates a new CResult_COption_APIErrorZDecodeErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_COption_APIErrorZDecodeErrorZ_clone(orig: &CResult_COption_APIErrorZDecodeErrorZ) -> CResult_COption_APIErrorZDecodeErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// The contents of CResult_UntrustedStringDecodeErrorZ -pub union CResult_UntrustedStringDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::util::string::UntrustedString, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, -} -#[repr(C)] -/// A CResult_UntrustedStringDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::util::string::UntrustedString on success and a crate::lightning::ln::msgs::DecodeError on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_UntrustedStringDecodeErrorZ { - /// The contents of this CResult_UntrustedStringDecodeErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_UntrustedStringDecodeErrorZPtr, - /// Whether this CResult_UntrustedStringDecodeErrorZ represents a success state. - pub result_ok: bool, -} -#[no_mangle] -/// Creates a new CResult_UntrustedStringDecodeErrorZ in the success state. -pub extern "C" fn CResult_UntrustedStringDecodeErrorZ_ok(o: crate::lightning::util::string::UntrustedString) -> CResult_UntrustedStringDecodeErrorZ { - CResult_UntrustedStringDecodeErrorZ { - contents: CResult_UntrustedStringDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, - } -} -#[no_mangle] -/// Creates a new CResult_UntrustedStringDecodeErrorZ in the error state. -pub extern "C" fn CResult_UntrustedStringDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_UntrustedStringDecodeErrorZ { - CResult_UntrustedStringDecodeErrorZ { - contents: CResult_UntrustedStringDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), - }, - result_ok: false, - } -} -/// Checks if the given object is currently in the success state -#[no_mangle] -pub extern "C" fn CResult_UntrustedStringDecodeErrorZ_is_ok(o: &CResult_UntrustedStringDecodeErrorZ) -> bool { - o.result_ok -} -#[no_mangle] -/// Frees any resources used by the CResult_UntrustedStringDecodeErrorZ. -pub extern "C" fn CResult_UntrustedStringDecodeErrorZ_free(_res: CResult_UntrustedStringDecodeErrorZ) { } -impl Drop for CResult_UntrustedStringDecodeErrorZ { - fn drop(&mut self) { - if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } - } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } - } - } -} -impl From> for CResult_UntrustedStringDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { - let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_UntrustedStringDecodeErrorZPtr { result } - } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_UntrustedStringDecodeErrorZPtr { err } - }; - Self { - contents, - result_ok: o.result_ok, - } - } -} -impl Clone for CResult_UntrustedStringDecodeErrorZ { - fn clone(&self) -> Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_UntrustedStringDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_UntrustedStringDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } - } - } -} -#[no_mangle] -/// Creates a new CResult_UntrustedStringDecodeErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_UntrustedStringDecodeErrorZ_clone(orig: &CResult_UntrustedStringDecodeErrorZ) -> CResult_UntrustedStringDecodeErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// The contents of CResult_OutPointDecodeErrorZ -pub union CResult_OutPointDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::chain::transaction::OutPoint, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, -} -#[repr(C)] -/// A CResult_OutPointDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::chain::transaction::OutPoint on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_COption_CustomOnionMessageContentsZDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::COption_CustomOnionMessageContentsZ on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_OutPointDecodeErrorZ { - /// The contents of this CResult_OutPointDecodeErrorZ, accessible via either +pub struct CResult_COption_CustomOnionMessageContentsZDecodeErrorZ { + /// The contents of this CResult_COption_CustomOnionMessageContentsZDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_OutPointDecodeErrorZPtr, - /// Whether this CResult_OutPointDecodeErrorZ represents a success state. + pub contents: CResult_COption_CustomOnionMessageContentsZDecodeErrorZPtr, + /// Whether this CResult_COption_CustomOnionMessageContentsZDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_OutPointDecodeErrorZ in the success state. -pub extern "C" fn CResult_OutPointDecodeErrorZ_ok(o: crate::lightning::chain::transaction::OutPoint) -> CResult_OutPointDecodeErrorZ { - CResult_OutPointDecodeErrorZ { - contents: CResult_OutPointDecodeErrorZPtr { +/// Creates a new CResult_COption_CustomOnionMessageContentsZDecodeErrorZ in the success state. +pub extern "C" fn CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_ok(o: crate::c_types::derived::COption_CustomOnionMessageContentsZ) -> CResult_COption_CustomOnionMessageContentsZDecodeErrorZ { + CResult_COption_CustomOnionMessageContentsZDecodeErrorZ { + contents: CResult_COption_CustomOnionMessageContentsZDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_OutPointDecodeErrorZ in the error state. -pub extern "C" fn CResult_OutPointDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_OutPointDecodeErrorZ { - CResult_OutPointDecodeErrorZ { - contents: CResult_OutPointDecodeErrorZPtr { +/// Creates a new CResult_COption_CustomOnionMessageContentsZDecodeErrorZ in the error state. +pub extern "C" fn CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_COption_CustomOnionMessageContentsZDecodeErrorZ { + CResult_COption_CustomOnionMessageContentsZDecodeErrorZ { + contents: CResult_COption_CustomOnionMessageContentsZDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -10834,13 +10890,13 @@ pub extern "C" fn CResult_OutPointDecodeErrorZ_err(e: crate::lightning::ln::msgs } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_OutPointDecodeErrorZ_is_ok(o: &CResult_OutPointDecodeErrorZ) -> bool { +pub extern "C" fn CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_is_ok(o: &CResult_COption_CustomOnionMessageContentsZDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_OutPointDecodeErrorZ. -pub extern "C" fn CResult_OutPointDecodeErrorZ_free(_res: CResult_OutPointDecodeErrorZ) { } -impl Drop for CResult_OutPointDecodeErrorZ { +/// Frees any resources used by the CResult_COption_CustomOnionMessageContentsZDecodeErrorZ. +pub extern "C" fn CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_free(_res: CResult_COption_CustomOnionMessageContentsZDecodeErrorZ) { } +impl Drop for CResult_COption_CustomOnionMessageContentsZDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -10853,16 +10909,16 @@ impl Drop for CResult_OutPointDecodeErrorZ { } } } -impl From> for CResult_OutPointDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_COption_CustomOnionMessageContentsZDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_OutPointDecodeErrorZPtr { result } + CResult_COption_CustomOnionMessageContentsZDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_OutPointDecodeErrorZPtr { err } + CResult_COption_CustomOnionMessageContentsZDecodeErrorZPtr { err } }; Self { contents, @@ -10870,23 +10926,6 @@ impl From Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_OutPointDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_OutPointDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } - } - } -} -#[no_mangle] -/// Creates a new CResult_OutPointDecodeErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_OutPointDecodeErrorZ_clone(orig: &CResult_OutPointDecodeErrorZ) -> CResult_OutPointDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] /// An enum which can either contain a crate::lightning::ln::wire::Type or not pub enum COption_TypeZ { @@ -10999,41 +11038,166 @@ impl From bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::ln::msgs::NetAddress { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_NetAddressZ containing a crate::lightning::ln::msgs::NetAddress +pub extern "C" fn COption_NetAddressZ_some(o: crate::lightning::ln::msgs::NetAddress) -> COption_NetAddressZ { + COption_NetAddressZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_NetAddressZ containing nothing +pub extern "C" fn COption_NetAddressZ_none() -> COption_NetAddressZ { + COption_NetAddressZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::lightning::ln::msgs::NetAddress, if we are in the Some state +pub extern "C" fn COption_NetAddressZ_free(_res: COption_NetAddressZ) { } +#[no_mangle] +/// Creates a new COption_NetAddressZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_NetAddressZ_clone(orig: &COption_NetAddressZ) -> COption_NetAddressZ { Clone::clone(&orig) } +#[repr(C)] +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_PublicKeyCOption_NetAddressZZ { + /// The element at position 0 + pub a: crate::c_types::PublicKey, + /// The element at position 1 + pub b: crate::c_types::derived::COption_NetAddressZ, +} +impl From<(crate::c_types::PublicKey, crate::c_types::derived::COption_NetAddressZ)> for C2Tuple_PublicKeyCOption_NetAddressZZ { + fn from (tup: (crate::c_types::PublicKey, crate::c_types::derived::COption_NetAddressZ)) -> Self { + Self { + a: tup.0, + b: tup.1, + } + } +} +impl C2Tuple_PublicKeyCOption_NetAddressZZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::PublicKey, crate::c_types::derived::COption_NetAddressZ) { + (self.a, self.b) + } +} +impl Clone for C2Tuple_PublicKeyCOption_NetAddressZZ { + fn clone(&self) -> Self { + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), + } + } +} +#[no_mangle] +/// Creates a new tuple which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn C2Tuple_PublicKeyCOption_NetAddressZZ_clone(orig: &C2Tuple_PublicKeyCOption_NetAddressZZ) -> C2Tuple_PublicKeyCOption_NetAddressZZ { Clone::clone(&orig) } +/// Creates a new C2Tuple_PublicKeyCOption_NetAddressZZ from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_PublicKeyCOption_NetAddressZZ_new(a: crate::c_types::PublicKey, b: crate::c_types::derived::COption_NetAddressZ) -> C2Tuple_PublicKeyCOption_NetAddressZZ { + C2Tuple_PublicKeyCOption_NetAddressZZ { a, b, } +} + +#[no_mangle] +/// Frees any resources used by the C2Tuple_PublicKeyCOption_NetAddressZZ. +pub extern "C" fn C2Tuple_PublicKeyCOption_NetAddressZZ_free(_res: C2Tuple_PublicKeyCOption_NetAddressZZ) { } +#[repr(C)] +/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_PublicKeyCOption_NetAddressZZs of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::derived::C2Tuple_PublicKeyCOption_NetAddressZZ, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_PublicKeyCOption_NetAddressZZ] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ_free(_res: CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ) { } +impl Drop for CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// The contents of CResult_CVec_u8ZPeerHandleErrorZ +pub union CResult_CVec_u8ZPeerHandleErrorZPtr { + /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::ThirtyTwoBytes, + pub result: *mut crate::c_types::derived::CVec_u8Z, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning_invoice::payment::PaymentError, + pub err: *mut crate::lightning::ln::peer_handler::PeerHandleError, } #[repr(C)] -/// A CResult_PaymentIdPaymentErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::ThirtyTwoBytes on success and a crate::lightning_invoice::payment::PaymentError on failure. +/// A CResult_CVec_u8ZPeerHandleErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::CVec_u8Z on success and a crate::lightning::ln::peer_handler::PeerHandleError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_PaymentIdPaymentErrorZ { - /// The contents of this CResult_PaymentIdPaymentErrorZ, accessible via either +pub struct CResult_CVec_u8ZPeerHandleErrorZ { + /// The contents of this CResult_CVec_u8ZPeerHandleErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_PaymentIdPaymentErrorZPtr, - /// Whether this CResult_PaymentIdPaymentErrorZ represents a success state. + pub contents: CResult_CVec_u8ZPeerHandleErrorZPtr, + /// Whether this CResult_CVec_u8ZPeerHandleErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_PaymentIdPaymentErrorZ in the success state. -pub extern "C" fn CResult_PaymentIdPaymentErrorZ_ok(o: crate::c_types::ThirtyTwoBytes) -> CResult_PaymentIdPaymentErrorZ { - CResult_PaymentIdPaymentErrorZ { - contents: CResult_PaymentIdPaymentErrorZPtr { +/// Creates a new CResult_CVec_u8ZPeerHandleErrorZ in the success state. +pub extern "C" fn CResult_CVec_u8ZPeerHandleErrorZ_ok(o: crate::c_types::derived::CVec_u8Z) -> CResult_CVec_u8ZPeerHandleErrorZ { + CResult_CVec_u8ZPeerHandleErrorZ { + contents: CResult_CVec_u8ZPeerHandleErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_PaymentIdPaymentErrorZ in the error state. -pub extern "C" fn CResult_PaymentIdPaymentErrorZ_err(e: crate::lightning_invoice::payment::PaymentError) -> CResult_PaymentIdPaymentErrorZ { - CResult_PaymentIdPaymentErrorZ { - contents: CResult_PaymentIdPaymentErrorZPtr { +/// Creates a new CResult_CVec_u8ZPeerHandleErrorZ in the error state. +pub extern "C" fn CResult_CVec_u8ZPeerHandleErrorZ_err(e: crate::lightning::ln::peer_handler::PeerHandleError) -> CResult_CVec_u8ZPeerHandleErrorZ { + CResult_CVec_u8ZPeerHandleErrorZ { + contents: CResult_CVec_u8ZPeerHandleErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -11041,13 +11205,13 @@ pub extern "C" fn CResult_PaymentIdPaymentErrorZ_err(e: crate::lightning_invoice } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_PaymentIdPaymentErrorZ_is_ok(o: &CResult_PaymentIdPaymentErrorZ) -> bool { +pub extern "C" fn CResult_CVec_u8ZPeerHandleErrorZ_is_ok(o: &CResult_CVec_u8ZPeerHandleErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_PaymentIdPaymentErrorZ. -pub extern "C" fn CResult_PaymentIdPaymentErrorZ_free(_res: CResult_PaymentIdPaymentErrorZ) { } -impl Drop for CResult_PaymentIdPaymentErrorZ { +/// Frees any resources used by the CResult_CVec_u8ZPeerHandleErrorZ. +pub extern "C" fn CResult_CVec_u8ZPeerHandleErrorZ_free(_res: CResult_CVec_u8ZPeerHandleErrorZ) { } +impl Drop for CResult_CVec_u8ZPeerHandleErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -11060,16 +11224,16 @@ impl Drop for CResult_PaymentIdPaymentErrorZ { } } } -impl From> for CResult_PaymentIdPaymentErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_CVec_u8ZPeerHandleErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_PaymentIdPaymentErrorZPtr { result } + CResult_CVec_u8ZPeerHandleErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_PaymentIdPaymentErrorZPtr { err } + CResult_CVec_u8ZPeerHandleErrorZPtr { err } }; Self { contents, @@ -11077,58 +11241,58 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_PaymentIdPaymentErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_CVec_u8ZPeerHandleErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_PaymentIdPaymentErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_CVec_u8ZPeerHandleErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_PaymentIdPaymentErrorZ which has the same data as `orig` +/// Creates a new CResult_CVec_u8ZPeerHandleErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_PaymentIdPaymentErrorZ_clone(orig: &CResult_PaymentIdPaymentErrorZ) -> CResult_PaymentIdPaymentErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_CVec_u8ZPeerHandleErrorZ_clone(orig: &CResult_CVec_u8ZPeerHandleErrorZ) -> CResult_CVec_u8ZPeerHandleErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_NonePaymentErrorZ -pub union CResult_NonePaymentErrorZPtr { +/// The contents of CResult_NonePeerHandleErrorZ +pub union CResult_NonePeerHandleErrorZPtr { /// Note that this value is always NULL, as there are no contents in the OK variant pub result: *mut core::ffi::c_void, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning_invoice::payment::PaymentError, + pub err: *mut crate::lightning::ln::peer_handler::PeerHandleError, } #[repr(C)] -/// A CResult_NonePaymentErrorZ represents the result of a fallible operation, -/// containing a () on success and a crate::lightning_invoice::payment::PaymentError on failure. +/// A CResult_NonePeerHandleErrorZ represents the result of a fallible operation, +/// containing a () on success and a crate::lightning::ln::peer_handler::PeerHandleError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_NonePaymentErrorZ { - /// The contents of this CResult_NonePaymentErrorZ, accessible via either +pub struct CResult_NonePeerHandleErrorZ { + /// The contents of this CResult_NonePeerHandleErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_NonePaymentErrorZPtr, - /// Whether this CResult_NonePaymentErrorZ represents a success state. + pub contents: CResult_NonePeerHandleErrorZPtr, + /// Whether this CResult_NonePeerHandleErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_NonePaymentErrorZ in the success state. -pub extern "C" fn CResult_NonePaymentErrorZ_ok() -> CResult_NonePaymentErrorZ { - CResult_NonePaymentErrorZ { - contents: CResult_NonePaymentErrorZPtr { +/// Creates a new CResult_NonePeerHandleErrorZ in the success state. +pub extern "C" fn CResult_NonePeerHandleErrorZ_ok() -> CResult_NonePeerHandleErrorZ { + CResult_NonePeerHandleErrorZ { + contents: CResult_NonePeerHandleErrorZPtr { result: core::ptr::null_mut(), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_NonePaymentErrorZ in the error state. -pub extern "C" fn CResult_NonePaymentErrorZ_err(e: crate::lightning_invoice::payment::PaymentError) -> CResult_NonePaymentErrorZ { - CResult_NonePaymentErrorZ { - contents: CResult_NonePaymentErrorZPtr { +/// Creates a new CResult_NonePeerHandleErrorZ in the error state. +pub extern "C" fn CResult_NonePeerHandleErrorZ_err(e: crate::lightning::ln::peer_handler::PeerHandleError) -> CResult_NonePeerHandleErrorZ { + CResult_NonePeerHandleErrorZ { + contents: CResult_NonePeerHandleErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -11136,13 +11300,13 @@ pub extern "C" fn CResult_NonePaymentErrorZ_err(e: crate::lightning_invoice::pay } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_NonePaymentErrorZ_is_ok(o: &CResult_NonePaymentErrorZ) -> bool { +pub extern "C" fn CResult_NonePeerHandleErrorZ_is_ok(o: &CResult_NonePeerHandleErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_NonePaymentErrorZ. -pub extern "C" fn CResult_NonePaymentErrorZ_free(_res: CResult_NonePaymentErrorZ) { } -impl Drop for CResult_NonePaymentErrorZ { +/// Frees any resources used by the CResult_NonePeerHandleErrorZ. +pub extern "C" fn CResult_NonePeerHandleErrorZ_free(_res: CResult_NonePeerHandleErrorZ) { } +impl Drop for CResult_NonePeerHandleErrorZ { fn drop(&mut self) { if self.result_ok { } else { @@ -11152,16 +11316,16 @@ impl Drop for CResult_NonePaymentErrorZ { } } } -impl From> for CResult_NonePaymentErrorZ { - fn from(mut o: crate::c_types::CResultTempl<(), crate::lightning_invoice::payment::PaymentError>) -> Self { +impl From> for CResult_NonePeerHandleErrorZ { + fn from(mut o: crate::c_types::CResultTempl<(), crate::lightning::ln::peer_handler::PeerHandleError>) -> Self { let contents = if o.result_ok { let _ = unsafe { Box::from_raw(o.contents.result) }; o.contents.result = core::ptr::null_mut(); - CResult_NonePaymentErrorZPtr { result: core::ptr::null_mut() } + CResult_NonePeerHandleErrorZPtr { result: core::ptr::null_mut() } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_NonePaymentErrorZPtr { err } + CResult_NonePeerHandleErrorZPtr { err } }; Self { contents, @@ -11169,59 +11333,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_NonePaymentErrorZPtr { + Self { result_ok: true, contents: CResult_NonePeerHandleErrorZPtr { result: core::ptr::null_mut() } } } else { - Self { result_ok: false, contents: CResult_NonePaymentErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_NonePeerHandleErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_NonePaymentErrorZ which has the same data as `orig` +/// Creates a new CResult_NonePeerHandleErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_NonePaymentErrorZ_clone(orig: &CResult_NonePaymentErrorZ) -> CResult_NonePaymentErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_NonePeerHandleErrorZ_clone(orig: &CResult_NonePeerHandleErrorZ) -> CResult_NonePeerHandleErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_StringErrorZ -pub union CResult_StringErrorZPtr { +/// The contents of CResult_boolPeerHandleErrorZ +pub union CResult_boolPeerHandleErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::Str, + pub result: *mut bool, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::c_types::Secp256k1Error, + pub err: *mut crate::lightning::ln::peer_handler::PeerHandleError, } #[repr(C)] -/// A CResult_StringErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::Str on success and a crate::c_types::Secp256k1Error on failure. +/// A CResult_boolPeerHandleErrorZ represents the result of a fallible operation, +/// containing a bool on success and a crate::lightning::ln::peer_handler::PeerHandleError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_StringErrorZ { - /// The contents of this CResult_StringErrorZ, accessible via either +pub struct CResult_boolPeerHandleErrorZ { + /// The contents of this CResult_boolPeerHandleErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_StringErrorZPtr, - /// Whether this CResult_StringErrorZ represents a success state. + pub contents: CResult_boolPeerHandleErrorZPtr, + /// Whether this CResult_boolPeerHandleErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_StringErrorZ in the success state. -pub extern "C" fn CResult_StringErrorZ_ok(o: crate::c_types::Str) -> CResult_StringErrorZ { - CResult_StringErrorZ { - contents: CResult_StringErrorZPtr { +/// Creates a new CResult_boolPeerHandleErrorZ in the success state. +pub extern "C" fn CResult_boolPeerHandleErrorZ_ok(o: bool) -> CResult_boolPeerHandleErrorZ { + CResult_boolPeerHandleErrorZ { + contents: CResult_boolPeerHandleErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_StringErrorZ in the error state. -pub extern "C" fn CResult_StringErrorZ_err(e: crate::c_types::Secp256k1Error) -> CResult_StringErrorZ { - CResult_StringErrorZ { - contents: CResult_StringErrorZPtr { +/// Creates a new CResult_boolPeerHandleErrorZ in the error state. +pub extern "C" fn CResult_boolPeerHandleErrorZ_err(e: crate::lightning::ln::peer_handler::PeerHandleError) -> CResult_boolPeerHandleErrorZ { + CResult_boolPeerHandleErrorZ { + contents: CResult_boolPeerHandleErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -11229,13 +11393,13 @@ pub extern "C" fn CResult_StringErrorZ_err(e: crate::c_types::Secp256k1Error) -> } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_StringErrorZ_is_ok(o: &CResult_StringErrorZ) -> bool { +pub extern "C" fn CResult_boolPeerHandleErrorZ_is_ok(o: &CResult_boolPeerHandleErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_StringErrorZ. -pub extern "C" fn CResult_StringErrorZ_free(_res: CResult_StringErrorZ) { } -impl Drop for CResult_StringErrorZ { +/// Frees any resources used by the CResult_boolPeerHandleErrorZ. +pub extern "C" fn CResult_boolPeerHandleErrorZ_free(_res: CResult_boolPeerHandleErrorZ) { } +impl Drop for CResult_boolPeerHandleErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -11248,16 +11412,16 @@ impl Drop for CResult_StringErrorZ { } } } -impl From> for CResult_StringErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_boolPeerHandleErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_StringErrorZPtr { result } + CResult_boolPeerHandleErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_StringErrorZPtr { err } + CResult_boolPeerHandleErrorZPtr { err } }; Self { contents, @@ -11265,59 +11429,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_StringErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_boolPeerHandleErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_StringErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_boolPeerHandleErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_StringErrorZ which has the same data as `orig` +/// Creates a new CResult_boolPeerHandleErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_StringErrorZ_clone(orig: &CResult_StringErrorZ) -> CResult_StringErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_boolPeerHandleErrorZ_clone(orig: &CResult_boolPeerHandleErrorZ) -> CResult_boolPeerHandleErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_ChannelMonitorUpdateDecodeErrorZ -pub union CResult_ChannelMonitorUpdateDecodeErrorZPtr { +/// The contents of CResult_u32GraphSyncErrorZ +pub union CResult_u32GraphSyncErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::chain::channelmonitor::ChannelMonitorUpdate, + pub result: *mut u32, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::lightning_rapid_gossip_sync::error::GraphSyncError, } #[repr(C)] -/// A CResult_ChannelMonitorUpdateDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::chain::channelmonitor::ChannelMonitorUpdate on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_u32GraphSyncErrorZ represents the result of a fallible operation, +/// containing a u32 on success and a crate::lightning_rapid_gossip_sync::error::GraphSyncError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ChannelMonitorUpdateDecodeErrorZ { - /// The contents of this CResult_ChannelMonitorUpdateDecodeErrorZ, accessible via either +pub struct CResult_u32GraphSyncErrorZ { + /// The contents of this CResult_u32GraphSyncErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ChannelMonitorUpdateDecodeErrorZPtr, - /// Whether this CResult_ChannelMonitorUpdateDecodeErrorZ represents a success state. + pub contents: CResult_u32GraphSyncErrorZPtr, + /// Whether this CResult_u32GraphSyncErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ChannelMonitorUpdateDecodeErrorZ in the success state. -pub extern "C" fn CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o: crate::lightning::chain::channelmonitor::ChannelMonitorUpdate) -> CResult_ChannelMonitorUpdateDecodeErrorZ { - CResult_ChannelMonitorUpdateDecodeErrorZ { - contents: CResult_ChannelMonitorUpdateDecodeErrorZPtr { +/// Creates a new CResult_u32GraphSyncErrorZ in the success state. +pub extern "C" fn CResult_u32GraphSyncErrorZ_ok(o: u32) -> CResult_u32GraphSyncErrorZ { + CResult_u32GraphSyncErrorZ { + contents: CResult_u32GraphSyncErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ChannelMonitorUpdateDecodeErrorZ in the error state. -pub extern "C" fn CResult_ChannelMonitorUpdateDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelMonitorUpdateDecodeErrorZ { - CResult_ChannelMonitorUpdateDecodeErrorZ { - contents: CResult_ChannelMonitorUpdateDecodeErrorZPtr { +/// Creates a new CResult_u32GraphSyncErrorZ in the error state. +pub extern "C" fn CResult_u32GraphSyncErrorZ_err(e: crate::lightning_rapid_gossip_sync::error::GraphSyncError) -> CResult_u32GraphSyncErrorZ { + CResult_u32GraphSyncErrorZ { + contents: CResult_u32GraphSyncErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -11325,13 +11489,13 @@ pub extern "C" fn CResult_ChannelMonitorUpdateDecodeErrorZ_err(e: crate::lightni } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(o: &CResult_ChannelMonitorUpdateDecodeErrorZ) -> bool { +pub extern "C" fn CResult_u32GraphSyncErrorZ_is_ok(o: &CResult_u32GraphSyncErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_ChannelMonitorUpdateDecodeErrorZ. -pub extern "C" fn CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res: CResult_ChannelMonitorUpdateDecodeErrorZ) { } -impl Drop for CResult_ChannelMonitorUpdateDecodeErrorZ { +/// Frees any resources used by the CResult_u32GraphSyncErrorZ. +pub extern "C" fn CResult_u32GraphSyncErrorZ_free(_res: CResult_u32GraphSyncErrorZ) { } +impl Drop for CResult_u32GraphSyncErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -11344,16 +11508,16 @@ impl Drop for CResult_ChannelMonitorUpdateDecodeErrorZ { } } } -impl From> for CResult_ChannelMonitorUpdateDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_u32GraphSyncErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ChannelMonitorUpdateDecodeErrorZPtr { result } + CResult_u32GraphSyncErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ChannelMonitorUpdateDecodeErrorZPtr { err } + CResult_u32GraphSyncErrorZPtr { err } }; Self { contents, @@ -11361,132 +11525,111 @@ impl From Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_ChannelMonitorUpdateDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_ChannelMonitorUpdateDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } - } - } -} -#[no_mangle] -/// Creates a new CResult_ChannelMonitorUpdateDecodeErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig: &CResult_ChannelMonitorUpdateDecodeErrorZ) -> CResult_ChannelMonitorUpdateDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] #[derive(Clone)] -/// An enum which can either contain a crate::lightning::chain::channelmonitor::MonitorEvent or not -pub enum COption_MonitorEventZ { - /// When we're in this state, this COption_MonitorEventZ contains a crate::lightning::chain::channelmonitor::MonitorEvent - Some(crate::lightning::chain::channelmonitor::MonitorEvent), - /// When we're in this state, this COption_MonitorEventZ contains nothing +/// An enum which can either contain a crate::c_types::SecretKey or not +pub enum COption_KeyPairZ { + /// When we're in this state, this COption_KeyPairZ contains a crate::c_types::SecretKey + Some(crate::c_types::SecretKey), + /// When we're in this state, this COption_KeyPairZ contains nothing None } -impl COption_MonitorEventZ { +impl COption_KeyPairZ { #[allow(unused)] pub(crate) fn is_some(&self) -> bool { if let Self::None = self { false } else { true } } #[allow(unused)] pub(crate) fn is_none(&self) -> bool { !self.is_some() } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::chain::channelmonitor::MonitorEvent { + #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::SecretKey { if let Self::Some(v) = self { v } else { unreachable!() } } } #[no_mangle] -/// Constructs a new COption_MonitorEventZ containing a crate::lightning::chain::channelmonitor::MonitorEvent -pub extern "C" fn COption_MonitorEventZ_some(o: crate::lightning::chain::channelmonitor::MonitorEvent) -> COption_MonitorEventZ { - COption_MonitorEventZ::Some(o) +/// Constructs a new COption_KeyPairZ containing a crate::c_types::SecretKey +pub extern "C" fn COption_KeyPairZ_some(o: crate::c_types::SecretKey) -> COption_KeyPairZ { + COption_KeyPairZ::Some(o) } #[no_mangle] -/// Constructs a new COption_MonitorEventZ containing nothing -pub extern "C" fn COption_MonitorEventZ_none() -> COption_MonitorEventZ { - COption_MonitorEventZ::None +/// Constructs a new COption_KeyPairZ containing nothing +pub extern "C" fn COption_KeyPairZ_none() -> COption_KeyPairZ { + COption_KeyPairZ::None } #[no_mangle] -/// Frees any resources associated with the crate::lightning::chain::channelmonitor::MonitorEvent, if we are in the Some state -pub extern "C" fn COption_MonitorEventZ_free(_res: COption_MonitorEventZ) { } +/// Frees any resources associated with the crate::c_types::SecretKey, if we are in the Some state +pub extern "C" fn COption_KeyPairZ_free(_res: COption_KeyPairZ) { } #[no_mangle] -/// Creates a new COption_MonitorEventZ which has the same data as `orig` +/// Creates a new COption_KeyPairZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_MonitorEventZ_clone(orig: &COption_MonitorEventZ) -> COption_MonitorEventZ { Clone::clone(&orig) } +pub extern "C" fn COption_KeyPairZ_clone(orig: &COption_KeyPairZ) -> COption_KeyPairZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_COption_MonitorEventZDecodeErrorZ -pub union CResult_COption_MonitorEventZDecodeErrorZPtr { +/// The contents of CResult_COption_KeyPairZNoneZ +pub union CResult_COption_KeyPairZNoneZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::COption_MonitorEventZ, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub result: *mut crate::c_types::derived::COption_KeyPairZ, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut core::ffi::c_void, } #[repr(C)] -/// A CResult_COption_MonitorEventZDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::COption_MonitorEventZ on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_COption_KeyPairZNoneZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::COption_KeyPairZ on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_COption_MonitorEventZDecodeErrorZ { - /// The contents of this CResult_COption_MonitorEventZDecodeErrorZ, accessible via either +pub struct CResult_COption_KeyPairZNoneZ { + /// The contents of this CResult_COption_KeyPairZNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_COption_MonitorEventZDecodeErrorZPtr, - /// Whether this CResult_COption_MonitorEventZDecodeErrorZ represents a success state. + pub contents: CResult_COption_KeyPairZNoneZPtr, + /// Whether this CResult_COption_KeyPairZNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_COption_MonitorEventZDecodeErrorZ in the success state. -pub extern "C" fn CResult_COption_MonitorEventZDecodeErrorZ_ok(o: crate::c_types::derived::COption_MonitorEventZ) -> CResult_COption_MonitorEventZDecodeErrorZ { - CResult_COption_MonitorEventZDecodeErrorZ { - contents: CResult_COption_MonitorEventZDecodeErrorZPtr { +/// Creates a new CResult_COption_KeyPairZNoneZ in the success state. +pub extern "C" fn CResult_COption_KeyPairZNoneZ_ok(o: crate::c_types::derived::COption_KeyPairZ) -> CResult_COption_KeyPairZNoneZ { + CResult_COption_KeyPairZNoneZ { + contents: CResult_COption_KeyPairZNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_COption_MonitorEventZDecodeErrorZ in the error state. -pub extern "C" fn CResult_COption_MonitorEventZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_COption_MonitorEventZDecodeErrorZ { - CResult_COption_MonitorEventZDecodeErrorZ { - contents: CResult_COption_MonitorEventZDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), +/// Creates a new CResult_COption_KeyPairZNoneZ in the error state. +pub extern "C" fn CResult_COption_KeyPairZNoneZ_err() -> CResult_COption_KeyPairZNoneZ { + CResult_COption_KeyPairZNoneZ { + contents: CResult_COption_KeyPairZNoneZPtr { + err: core::ptr::null_mut(), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_COption_MonitorEventZDecodeErrorZ_is_ok(o: &CResult_COption_MonitorEventZDecodeErrorZ) -> bool { +pub extern "C" fn CResult_COption_KeyPairZNoneZ_is_ok(o: &CResult_COption_KeyPairZNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_COption_MonitorEventZDecodeErrorZ. -pub extern "C" fn CResult_COption_MonitorEventZDecodeErrorZ_free(_res: CResult_COption_MonitorEventZDecodeErrorZ) { } -impl Drop for CResult_COption_MonitorEventZDecodeErrorZ { +/// Frees any resources used by the CResult_COption_KeyPairZNoneZ. +pub extern "C" fn CResult_COption_KeyPairZNoneZ_free(_res: CResult_COption_KeyPairZNoneZ) { } +impl Drop for CResult_COption_KeyPairZNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } } } } -impl From> for CResult_COption_MonitorEventZDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_COption_KeyPairZNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_COption_MonitorEventZDecodeErrorZPtr { result } + CResult_COption_KeyPairZNoneZPtr { result } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_COption_MonitorEventZDecodeErrorZPtr { err } + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_COption_KeyPairZNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -11494,227 +11637,113 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_COption_MonitorEventZDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_COption_KeyPairZNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_COption_MonitorEventZDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_COption_KeyPairZNoneZPtr { + err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_COption_MonitorEventZDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_COption_KeyPairZNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_COption_MonitorEventZDecodeErrorZ_clone(orig: &CResult_COption_MonitorEventZDecodeErrorZ) -> CResult_COption_MonitorEventZDecodeErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// The contents of CResult_HTLCUpdateDecodeErrorZ -pub union CResult_HTLCUpdateDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::chain::channelmonitor::HTLCUpdate, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, -} +pub extern "C" fn CResult_COption_KeyPairZNoneZ_clone(orig: &CResult_COption_KeyPairZNoneZ) -> CResult_COption_KeyPairZNoneZ { Clone::clone(&orig) } #[repr(C)] -/// A CResult_HTLCUpdateDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::chain::channelmonitor::HTLCUpdate on success and a crate::lightning::ln::msgs::DecodeError on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_HTLCUpdateDecodeErrorZ { - /// The contents of this CResult_HTLCUpdateDecodeErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_HTLCUpdateDecodeErrorZPtr, - /// Whether this CResult_HTLCUpdateDecodeErrorZ represents a success state. - pub result_ok: bool, +#[derive(Clone)] +/// An enum which can either contain a crate::c_types::derived::CVec_u8Z or not +pub enum COption_ScriptZ { + /// When we're in this state, this COption_ScriptZ contains a crate::c_types::derived::CVec_u8Z + Some(crate::c_types::derived::CVec_u8Z), + /// When we're in this state, this COption_ScriptZ contains nothing + None } -#[no_mangle] -/// Creates a new CResult_HTLCUpdateDecodeErrorZ in the success state. -pub extern "C" fn CResult_HTLCUpdateDecodeErrorZ_ok(o: crate::lightning::chain::channelmonitor::HTLCUpdate) -> CResult_HTLCUpdateDecodeErrorZ { - CResult_HTLCUpdateDecodeErrorZ { - contents: CResult_HTLCUpdateDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, +impl COption_ScriptZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::derived::CVec_u8Z { + if let Self::Some(v) = self { v } else { unreachable!() } } } #[no_mangle] -/// Creates a new CResult_HTLCUpdateDecodeErrorZ in the error state. -pub extern "C" fn CResult_HTLCUpdateDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_HTLCUpdateDecodeErrorZ { - CResult_HTLCUpdateDecodeErrorZ { - contents: CResult_HTLCUpdateDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), - }, - result_ok: false, - } +/// Constructs a new COption_ScriptZ containing a crate::c_types::derived::CVec_u8Z +pub extern "C" fn COption_ScriptZ_some(o: crate::c_types::derived::CVec_u8Z) -> COption_ScriptZ { + COption_ScriptZ::Some(o) } -/// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_HTLCUpdateDecodeErrorZ_is_ok(o: &CResult_HTLCUpdateDecodeErrorZ) -> bool { - o.result_ok +/// Constructs a new COption_ScriptZ containing nothing +pub extern "C" fn COption_ScriptZ_none() -> COption_ScriptZ { + COption_ScriptZ::None } #[no_mangle] -/// Frees any resources used by the CResult_HTLCUpdateDecodeErrorZ. -pub extern "C" fn CResult_HTLCUpdateDecodeErrorZ_free(_res: CResult_HTLCUpdateDecodeErrorZ) { } -impl Drop for CResult_HTLCUpdateDecodeErrorZ { - fn drop(&mut self) { - if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } - } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } - } - } -} -impl From> for CResult_HTLCUpdateDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { - let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_HTLCUpdateDecodeErrorZPtr { result } - } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_HTLCUpdateDecodeErrorZPtr { err } - }; - Self { - contents, - result_ok: o.result_ok, - } - } -} -impl Clone for CResult_HTLCUpdateDecodeErrorZ { - fn clone(&self) -> Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_HTLCUpdateDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_HTLCUpdateDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } - } - } -} +/// Frees any resources associated with the crate::c_types::derived::CVec_u8Z, if we are in the Some state +pub extern "C" fn COption_ScriptZ_free(_res: COption_ScriptZ) { } #[no_mangle] -/// Creates a new CResult_HTLCUpdateDecodeErrorZ which has the same data as `orig` +/// Creates a new COption_ScriptZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_HTLCUpdateDecodeErrorZ_clone(orig: &CResult_HTLCUpdateDecodeErrorZ) -> CResult_HTLCUpdateDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn COption_ScriptZ_clone(orig: &COption_ScriptZ) -> COption_ScriptZ { Clone::clone(&orig) } #[repr(C)] -/// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple_OutPointScriptZ { - /// The element at position 0 - pub a: crate::lightning::chain::transaction::OutPoint, - /// The element at position 1 - pub b: crate::c_types::derived::CVec_u8Z, -} -impl From<(crate::lightning::chain::transaction::OutPoint, crate::c_types::derived::CVec_u8Z)> for C2Tuple_OutPointScriptZ { - fn from (tup: (crate::lightning::chain::transaction::OutPoint, crate::c_types::derived::CVec_u8Z)) -> Self { - Self { - a: tup.0, - b: tup.1, - } - } +/// An enum which can either contain a or not +pub enum COption_NoneZ { + /// When we're in this state, this COption_NoneZ contains a + Some, + /// When we're in this state, this COption_NoneZ contains nothing + None } -impl C2Tuple_OutPointScriptZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::lightning::chain::transaction::OutPoint, crate::c_types::derived::CVec_u8Z) { - (self.a, self.b) +impl COption_NoneZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } } -} -impl Clone for C2Tuple_OutPointScriptZ { - fn clone(&self) -> Self { - Self { - a: Clone::clone(&self.a), - b: Clone::clone(&self.b), - } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() } } #[no_mangle] -/// Creates a new tuple which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C2Tuple_OutPointScriptZ_clone(orig: &C2Tuple_OutPointScriptZ) -> C2Tuple_OutPointScriptZ { Clone::clone(&orig) } -/// Creates a new C2Tuple_OutPointScriptZ from the contained elements. -#[no_mangle] -pub extern "C" fn C2Tuple_OutPointScriptZ_new(a: crate::lightning::chain::transaction::OutPoint, b: crate::c_types::derived::CVec_u8Z) -> C2Tuple_OutPointScriptZ { - C2Tuple_OutPointScriptZ { a, b, } -} - -#[no_mangle] -/// Frees any resources used by the C2Tuple_OutPointScriptZ. -pub extern "C" fn C2Tuple_OutPointScriptZ_free(_res: C2Tuple_OutPointScriptZ) { } -#[repr(C)] -/// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple_u32ScriptZ { - /// The element at position 0 - pub a: u32, - /// The element at position 1 - pub b: crate::c_types::derived::CVec_u8Z, -} -impl From<(u32, crate::c_types::derived::CVec_u8Z)> for C2Tuple_u32ScriptZ { - fn from (tup: (u32, crate::c_types::derived::CVec_u8Z)) -> Self { - Self { - a: tup.0, - b: tup.1, - } - } -} -impl C2Tuple_u32ScriptZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (u32, crate::c_types::derived::CVec_u8Z) { - (self.a, self.b) - } -} -impl Clone for C2Tuple_u32ScriptZ { - fn clone(&self) -> Self { - Self { - a: Clone::clone(&self.a), - b: Clone::clone(&self.b), - } - } +/// Constructs a new COption_NoneZ containing a +pub extern "C" fn COption_NoneZ_some() -> COption_NoneZ { + COption_NoneZ::Some } #[no_mangle] -/// Creates a new tuple which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C2Tuple_u32ScriptZ_clone(orig: &C2Tuple_u32ScriptZ) -> C2Tuple_u32ScriptZ { Clone::clone(&orig) } -/// Creates a new C2Tuple_u32ScriptZ from the contained elements. -#[no_mangle] -pub extern "C" fn C2Tuple_u32ScriptZ_new(a: u32, b: crate::c_types::derived::CVec_u8Z) -> C2Tuple_u32ScriptZ { - C2Tuple_u32ScriptZ { a, b, } +/// Constructs a new COption_NoneZ containing nothing +pub extern "C" fn COption_NoneZ_none() -> COption_NoneZ { + COption_NoneZ::None } - #[no_mangle] -/// Frees any resources used by the C2Tuple_u32ScriptZ. -pub extern "C" fn C2Tuple_u32ScriptZ_free(_res: C2Tuple_u32ScriptZ) { } +/// Frees any resources associated with the , if we are in the Some state +pub extern "C" fn COption_NoneZ_free(_res: COption_NoneZ) { } #[repr(C)] -/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_u32ScriptZs of arbitrary size. +/// A dynamically-allocated array of crate::c_types::Witnesss of arbitrary size. /// This corresponds to std::vector in C++ -pub struct CVec_C2Tuple_u32ScriptZZ { +pub struct CVec_WitnessZ { /// The elements in the array. /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::derived::C2Tuple_u32ScriptZ, + pub data: *mut crate::c_types::Witness, /// The number of elements pointed to by `data`. pub datalen: usize } -impl CVec_C2Tuple_u32ScriptZZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { +impl CVec_WitnessZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { if self.datalen == 0 { return Vec::new(); } let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); self.data = core::ptr::null_mut(); self.datalen = 0; ret } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_u32ScriptZ] { + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::Witness] { unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl From> for CVec_C2Tuple_u32ScriptZZ { - fn from(v: Vec) -> Self { +impl From> for CVec_WitnessZ { + fn from(v: Vec) -> Self { let datalen = v.len(); let data = Box::into_raw(v.into_boxed_slice()); Self { datalen, data: unsafe { (*data).as_mut_ptr() } } @@ -11722,14 +11751,14 @@ impl From> for CVec_C2Tuple_u32 } #[no_mangle] /// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_C2Tuple_u32ScriptZZ_free(_res: CVec_C2Tuple_u32ScriptZZ) { } -impl Drop for CVec_C2Tuple_u32ScriptZZ { +pub extern "C" fn CVec_WitnessZ_free(_res: CVec_WitnessZ) { } +impl Drop for CVec_WitnessZ { fn drop(&mut self) { if self.datalen == 0 { return; } let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl Clone for CVec_C2Tuple_u32ScriptZZ { +impl Clone for CVec_WitnessZ { fn clone(&self) -> Self { let mut res = Vec::new(); if self.datalen == 0 { return Self::from(res); } @@ -11738,163 +11767,199 @@ impl Clone for CVec_C2Tuple_u32ScriptZZ { } } #[repr(C)] -/// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ { - /// The element at position 0 - pub a: crate::c_types::ThirtyTwoBytes, - /// The element at position 1 - pub b: crate::c_types::derived::CVec_C2Tuple_u32ScriptZZ, +#[derive(Clone)] +/// An enum which can either contain a i64 or not +pub enum COption_i64Z { + /// When we're in this state, this COption_i64Z contains a i64 + Some(i64), + /// When we're in this state, this COption_i64Z contains nothing + None } -impl From<(crate::c_types::ThirtyTwoBytes, crate::c_types::derived::CVec_C2Tuple_u32ScriptZZ)> for C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ { - fn from (tup: (crate::c_types::ThirtyTwoBytes, crate::c_types::derived::CVec_C2Tuple_u32ScriptZZ)) -> Self { - Self { - a: tup.0, - b: tup.1, - } +impl COption_i64Z { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } } -} -impl C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoBytes, crate::c_types::derived::CVec_C2Tuple_u32ScriptZZ) { - (self.a, self.b) + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() } -} -impl Clone for C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ { - fn clone(&self) -> Self { - Self { - a: Clone::clone(&self.a), - b: Clone::clone(&self.b), - } + #[allow(unused)] pub(crate) fn take(mut self) -> i64 { + if let Self::Some(v) = self { v } else { unreachable!() } } } #[no_mangle] -/// Creates a new tuple which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig: &C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ) -> C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ { Clone::clone(&orig) } -/// Creates a new C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ from the contained elements. +/// Constructs a new COption_i64Z containing a i64 +pub extern "C" fn COption_i64Z_some(o: i64) -> COption_i64Z { + COption_i64Z::Some(o) +} #[no_mangle] -pub extern "C" fn C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a: crate::c_types::ThirtyTwoBytes, b: crate::c_types::derived::CVec_C2Tuple_u32ScriptZZ) -> C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ { - C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ { a, b, } +/// Constructs a new COption_i64Z containing nothing +pub extern "C" fn COption_i64Z_none() -> COption_i64Z { + COption_i64Z::None } - #[no_mangle] -/// Frees any resources used by the C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ. -pub extern "C" fn C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res: C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ) { } +/// Frees any resources associated with the i64, if we are in the Some state +pub extern "C" fn COption_i64Z_free(_res: COption_i64Z) { } +#[no_mangle] +/// Creates a new COption_i64Z which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_i64Z_clone(orig: &COption_i64Z) -> COption_i64Z { Clone::clone(&orig) } #[repr(C)] -/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZs of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ, - /// The number of elements pointed to by `data`. - pub datalen: usize +#[derive(Clone)] +/// An enum which can either contain a crate::c_types::ThirtyTwoBytes or not +pub enum COption_TxidZ { + /// When we're in this state, this COption_TxidZ contains a crate::c_types::ThirtyTwoBytes + Some(crate::c_types::ThirtyTwoBytes), + /// When we're in this state, this COption_TxidZ contains nothing + None } -impl CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret +impl COption_TxidZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() } -} -impl From> for CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::ThirtyTwoBytes { + if let Self::Some(v) = self { v } else { unreachable!() } } } #[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res: CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ) { } -impl Drop for CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } +/// Constructs a new COption_TxidZ containing a crate::c_types::ThirtyTwoBytes +pub extern "C" fn COption_TxidZ_some(o: crate::c_types::ThirtyTwoBytes) -> COption_TxidZ { + COption_TxidZ::Some(o) } -impl Clone for CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } +#[no_mangle] +/// Constructs a new COption_TxidZ containing nothing +pub extern "C" fn COption_TxidZ_none() -> COption_TxidZ { + COption_TxidZ::None } +#[no_mangle] +/// Frees any resources associated with the crate::c_types::ThirtyTwoBytes, if we are in the Some state +pub extern "C" fn COption_TxidZ_free(_res: COption_TxidZ) { } +#[no_mangle] +/// Creates a new COption_TxidZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_TxidZ_clone(orig: &COption_TxidZ) -> COption_TxidZ { Clone::clone(&orig) } #[repr(C)] -/// A dynamically-allocated array of crate::lightning::events::Events of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_EventZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::events::Event, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_EventZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::events::Event] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } +/// The contents of CResult_NetAddressDecodeErrorZ +pub union CResult_NetAddressDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::NetAddress, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, } -impl From> for CVec_EventZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } +#[repr(C)] +/// A CResult_NetAddressDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::NetAddress on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_NetAddressDecodeErrorZ { + /// The contents of this CResult_NetAddressDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_NetAddressDecodeErrorZPtr, + /// Whether this CResult_NetAddressDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_NetAddressDecodeErrorZ in the success state. +pub extern "C" fn CResult_NetAddressDecodeErrorZ_ok(o: crate::lightning::ln::msgs::NetAddress) -> CResult_NetAddressDecodeErrorZ { + CResult_NetAddressDecodeErrorZ { + contents: CResult_NetAddressDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, } } #[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_EventZ_free(_res: CVec_EventZ) { } -impl Drop for CVec_EventZ { +/// Creates a new CResult_NetAddressDecodeErrorZ in the error state. +pub extern "C" fn CResult_NetAddressDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_NetAddressDecodeErrorZ { + CResult_NetAddressDecodeErrorZ { + contents: CResult_NetAddressDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_NetAddressDecodeErrorZ_is_ok(o: &CResult_NetAddressDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_NetAddressDecodeErrorZ. +pub extern "C" fn CResult_NetAddressDecodeErrorZ_free(_res: CResult_NetAddressDecodeErrorZ) { } +impl Drop for CResult_NetAddressDecodeErrorZ { fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_NetAddressDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_NetAddressDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_NetAddressDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } } } -impl Clone for CVec_EventZ { +impl Clone for CResult_NetAddressDecodeErrorZ { fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) + if self.result_ok { + Self { result_ok: true, contents: CResult_NetAddressDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_NetAddressDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } } } +#[no_mangle] +/// Creates a new CResult_NetAddressDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_NetAddressDecodeErrorZ_clone(orig: &CResult_NetAddressDecodeErrorZ) -> CResult_NetAddressDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// A dynamically-allocated array of crate::c_types::Transactions of arbitrary size. +/// A dynamically-allocated array of crate::lightning::ln::msgs::UpdateAddHTLCs of arbitrary size. /// This corresponds to std::vector in C++ -pub struct CVec_TransactionZ { +pub struct CVec_UpdateAddHTLCZ { /// The elements in the array. /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::Transaction, + pub data: *mut crate::lightning::ln::msgs::UpdateAddHTLC, /// The number of elements pointed to by `data`. pub datalen: usize } -impl CVec_TransactionZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { +impl CVec_UpdateAddHTLCZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { if self.datalen == 0 { return Vec::new(); } let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); self.data = core::ptr::null_mut(); self.datalen = 0; ret } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::Transaction] { + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::msgs::UpdateAddHTLC] { unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl From> for CVec_TransactionZ { - fn from(v: Vec) -> Self { +impl From> for CVec_UpdateAddHTLCZ { + fn from(v: Vec) -> Self { let datalen = v.len(); let data = Box::into_raw(v.into_boxed_slice()); Self { datalen, data: unsafe { (*data).as_mut_ptr() } } @@ -11902,14 +11967,14 @@ impl From> for CVec_TransactionZ { } #[no_mangle] /// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_TransactionZ_free(_res: CVec_TransactionZ) { } -impl Drop for CVec_TransactionZ { +pub extern "C" fn CVec_UpdateAddHTLCZ_free(_res: CVec_UpdateAddHTLCZ) { } +impl Drop for CVec_UpdateAddHTLCZ { fn drop(&mut self) { if self.datalen == 0 { return; } let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl Clone for CVec_TransactionZ { +impl Clone for CVec_UpdateAddHTLCZ { fn clone(&self) -> Self { let mut res = Vec::new(); if self.datalen == 0 { return Self::from(res); } @@ -11918,71 +11983,29 @@ impl Clone for CVec_TransactionZ { } } #[repr(C)] -/// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple_u32TxOutZ { - /// The element at position 0 - pub a: u32, - /// The element at position 1 - pub b: crate::c_types::TxOut, -} -impl From<(u32, crate::c_types::TxOut)> for C2Tuple_u32TxOutZ { - fn from (tup: (u32, crate::c_types::TxOut)) -> Self { - Self { - a: tup.0, - b: tup.1, - } - } -} -impl C2Tuple_u32TxOutZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (u32, crate::c_types::TxOut) { - (self.a, self.b) - } -} -impl Clone for C2Tuple_u32TxOutZ { - fn clone(&self) -> Self { - Self { - a: Clone::clone(&self.a), - b: Clone::clone(&self.b), - } - } -} -#[no_mangle] -/// Creates a new tuple which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C2Tuple_u32TxOutZ_clone(orig: &C2Tuple_u32TxOutZ) -> C2Tuple_u32TxOutZ { Clone::clone(&orig) } -/// Creates a new C2Tuple_u32TxOutZ from the contained elements. -#[no_mangle] -pub extern "C" fn C2Tuple_u32TxOutZ_new(a: u32, b: crate::c_types::TxOut) -> C2Tuple_u32TxOutZ { - C2Tuple_u32TxOutZ { a, b, } -} - -#[no_mangle] -/// Frees any resources used by the C2Tuple_u32TxOutZ. -pub extern "C" fn C2Tuple_u32TxOutZ_free(_res: C2Tuple_u32TxOutZ) { } -#[repr(C)] -/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_u32TxOutZs of arbitrary size. +/// A dynamically-allocated array of crate::lightning::ln::msgs::UpdateFulfillHTLCs of arbitrary size. /// This corresponds to std::vector in C++ -pub struct CVec_C2Tuple_u32TxOutZZ { +pub struct CVec_UpdateFulfillHTLCZ { /// The elements in the array. /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::derived::C2Tuple_u32TxOutZ, + pub data: *mut crate::lightning::ln::msgs::UpdateFulfillHTLC, /// The number of elements pointed to by `data`. pub datalen: usize } -impl CVec_C2Tuple_u32TxOutZZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { +impl CVec_UpdateFulfillHTLCZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { if self.datalen == 0 { return Vec::new(); } let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); self.data = core::ptr::null_mut(); self.datalen = 0; ret } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_u32TxOutZ] { + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::msgs::UpdateFulfillHTLC] { unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl From> for CVec_C2Tuple_u32TxOutZZ { - fn from(v: Vec) -> Self { +impl From> for CVec_UpdateFulfillHTLCZ { + fn from(v: Vec) -> Self { let datalen = v.len(); let data = Box::into_raw(v.into_boxed_slice()); Self { datalen, data: unsafe { (*data).as_mut_ptr() } } @@ -11990,14 +12013,14 @@ impl From> for CVec_C2Tuple_u32T } #[no_mangle] /// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_C2Tuple_u32TxOutZZ_free(_res: CVec_C2Tuple_u32TxOutZZ) { } -impl Drop for CVec_C2Tuple_u32TxOutZZ { +pub extern "C" fn CVec_UpdateFulfillHTLCZ_free(_res: CVec_UpdateFulfillHTLCZ) { } +impl Drop for CVec_UpdateFulfillHTLCZ { fn drop(&mut self) { if self.datalen == 0 { return; } let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl Clone for CVec_C2Tuple_u32TxOutZZ { +impl Clone for CVec_UpdateFulfillHTLCZ { fn clone(&self) -> Self { let mut res = Vec::new(); if self.datalen == 0 { return Self::from(res); } @@ -12006,71 +12029,29 @@ impl Clone for CVec_C2Tuple_u32TxOutZZ { } } #[repr(C)] -/// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ { - /// The element at position 0 - pub a: crate::c_types::ThirtyTwoBytes, - /// The element at position 1 - pub b: crate::c_types::derived::CVec_C2Tuple_u32TxOutZZ, -} -impl From<(crate::c_types::ThirtyTwoBytes, crate::c_types::derived::CVec_C2Tuple_u32TxOutZZ)> for C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ { - fn from (tup: (crate::c_types::ThirtyTwoBytes, crate::c_types::derived::CVec_C2Tuple_u32TxOutZZ)) -> Self { - Self { - a: tup.0, - b: tup.1, - } - } -} -impl C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoBytes, crate::c_types::derived::CVec_C2Tuple_u32TxOutZZ) { - (self.a, self.b) - } -} -impl Clone for C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ { - fn clone(&self) -> Self { - Self { - a: Clone::clone(&self.a), - b: Clone::clone(&self.b), - } - } -} -#[no_mangle] -/// Creates a new tuple which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig: &C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ) -> C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ { Clone::clone(&orig) } -/// Creates a new C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ from the contained elements. -#[no_mangle] -pub extern "C" fn C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a: crate::c_types::ThirtyTwoBytes, b: crate::c_types::derived::CVec_C2Tuple_u32TxOutZZ) -> C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ { - C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ { a, b, } -} - -#[no_mangle] -/// Frees any resources used by the C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ. -pub extern "C" fn C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res: C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ) { } -#[repr(C)] -/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZs of arbitrary size. +/// A dynamically-allocated array of crate::lightning::ln::msgs::UpdateFailHTLCs of arbitrary size. /// This corresponds to std::vector in C++ -pub struct CVec_TransactionOutputsZ { +pub struct CVec_UpdateFailHTLCZ { /// The elements in the array. /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ, + pub data: *mut crate::lightning::ln::msgs::UpdateFailHTLC, /// The number of elements pointed to by `data`. pub datalen: usize } -impl CVec_TransactionOutputsZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { +impl CVec_UpdateFailHTLCZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { if self.datalen == 0 { return Vec::new(); } let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); self.data = core::ptr::null_mut(); self.datalen = 0; ret } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ] { + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::msgs::UpdateFailHTLC] { unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl From> for CVec_TransactionOutputsZ { - fn from(v: Vec) -> Self { +impl From> for CVec_UpdateFailHTLCZ { + fn from(v: Vec) -> Self { let datalen = v.len(); let data = Box::into_raw(v.into_boxed_slice()); Self { datalen, data: unsafe { (*data).as_mut_ptr() } } @@ -12078,14 +12059,14 @@ impl From> fo } #[no_mangle] /// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_TransactionOutputsZ_free(_res: CVec_TransactionOutputsZ) { } -impl Drop for CVec_TransactionOutputsZ { +pub extern "C" fn CVec_UpdateFailHTLCZ_free(_res: CVec_UpdateFailHTLCZ) { } +impl Drop for CVec_UpdateFailHTLCZ { fn drop(&mut self) { if self.datalen == 0 { return; } let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl Clone for CVec_TransactionOutputsZ { +impl Clone for CVec_UpdateFailHTLCZ { fn clone(&self) -> Self { let mut res = Vec::new(); if self.datalen == 0 { return Self::from(res); } @@ -12094,87 +12075,3447 @@ impl Clone for CVec_TransactionOutputsZ { } } #[repr(C)] -/// A dynamically-allocated array of crate::lightning::chain::channelmonitor::Balances of arbitrary size. +/// A dynamically-allocated array of crate::lightning::ln::msgs::UpdateFailMalformedHTLCs of arbitrary size. /// This corresponds to std::vector in C++ -pub struct CVec_BalanceZ { +pub struct CVec_UpdateFailMalformedHTLCZ { /// The elements in the array. /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::chain::channelmonitor::Balance, + pub data: *mut crate::lightning::ln::msgs::UpdateFailMalformedHTLC, /// The number of elements pointed to by `data`. pub datalen: usize } -impl CVec_BalanceZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { +impl CVec_UpdateFailMalformedHTLCZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { if self.datalen == 0 { return Vec::new(); } let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); self.data = core::ptr::null_mut(); self.datalen = 0; ret } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::chain::channelmonitor::Balance] { + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::msgs::UpdateFailMalformedHTLC] { unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl From> for CVec_BalanceZ { - fn from(v: Vec) -> Self { +impl From> for CVec_UpdateFailMalformedHTLCZ { + fn from(v: Vec) -> Self { let datalen = v.len(); let data = Box::into_raw(v.into_boxed_slice()); Self { datalen, data: unsafe { (*data).as_mut_ptr() } } } } -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_BalanceZ_free(_res: CVec_BalanceZ) { } -impl Drop for CVec_BalanceZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_UpdateFailMalformedHTLCZ_free(_res: CVec_UpdateFailMalformedHTLCZ) { } +impl Drop for CVec_UpdateFailMalformedHTLCZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_UpdateFailMalformedHTLCZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// The contents of CResult_AcceptChannelDecodeErrorZ +pub union CResult_AcceptChannelDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::AcceptChannel, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_AcceptChannelDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::AcceptChannel on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_AcceptChannelDecodeErrorZ { + /// The contents of this CResult_AcceptChannelDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_AcceptChannelDecodeErrorZPtr, + /// Whether this CResult_AcceptChannelDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_AcceptChannelDecodeErrorZ in the success state. +pub extern "C" fn CResult_AcceptChannelDecodeErrorZ_ok(o: crate::lightning::ln::msgs::AcceptChannel) -> CResult_AcceptChannelDecodeErrorZ { + CResult_AcceptChannelDecodeErrorZ { + contents: CResult_AcceptChannelDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_AcceptChannelDecodeErrorZ in the error state. +pub extern "C" fn CResult_AcceptChannelDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_AcceptChannelDecodeErrorZ { + CResult_AcceptChannelDecodeErrorZ { + contents: CResult_AcceptChannelDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_AcceptChannelDecodeErrorZ_is_ok(o: &CResult_AcceptChannelDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_AcceptChannelDecodeErrorZ. +pub extern "C" fn CResult_AcceptChannelDecodeErrorZ_free(_res: CResult_AcceptChannelDecodeErrorZ) { } +impl Drop for CResult_AcceptChannelDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_AcceptChannelDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_AcceptChannelDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_AcceptChannelDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_AcceptChannelDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_AcceptChannelDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_AcceptChannelDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_AcceptChannelDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_AcceptChannelDecodeErrorZ_clone(orig: &CResult_AcceptChannelDecodeErrorZ) -> CResult_AcceptChannelDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_AcceptChannelV2DecodeErrorZ +pub union CResult_AcceptChannelV2DecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::AcceptChannelV2, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_AcceptChannelV2DecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::AcceptChannelV2 on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_AcceptChannelV2DecodeErrorZ { + /// The contents of this CResult_AcceptChannelV2DecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_AcceptChannelV2DecodeErrorZPtr, + /// Whether this CResult_AcceptChannelV2DecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_AcceptChannelV2DecodeErrorZ in the success state. +pub extern "C" fn CResult_AcceptChannelV2DecodeErrorZ_ok(o: crate::lightning::ln::msgs::AcceptChannelV2) -> CResult_AcceptChannelV2DecodeErrorZ { + CResult_AcceptChannelV2DecodeErrorZ { + contents: CResult_AcceptChannelV2DecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_AcceptChannelV2DecodeErrorZ in the error state. +pub extern "C" fn CResult_AcceptChannelV2DecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_AcceptChannelV2DecodeErrorZ { + CResult_AcceptChannelV2DecodeErrorZ { + contents: CResult_AcceptChannelV2DecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_AcceptChannelV2DecodeErrorZ_is_ok(o: &CResult_AcceptChannelV2DecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_AcceptChannelV2DecodeErrorZ. +pub extern "C" fn CResult_AcceptChannelV2DecodeErrorZ_free(_res: CResult_AcceptChannelV2DecodeErrorZ) { } +impl Drop for CResult_AcceptChannelV2DecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_AcceptChannelV2DecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_AcceptChannelV2DecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_AcceptChannelV2DecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_AcceptChannelV2DecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_AcceptChannelV2DecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_AcceptChannelV2DecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_AcceptChannelV2DecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_AcceptChannelV2DecodeErrorZ_clone(orig: &CResult_AcceptChannelV2DecodeErrorZ) -> CResult_AcceptChannelV2DecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_TxAddInputDecodeErrorZ +pub union CResult_TxAddInputDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::TxAddInput, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_TxAddInputDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::TxAddInput on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_TxAddInputDecodeErrorZ { + /// The contents of this CResult_TxAddInputDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_TxAddInputDecodeErrorZPtr, + /// Whether this CResult_TxAddInputDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_TxAddInputDecodeErrorZ in the success state. +pub extern "C" fn CResult_TxAddInputDecodeErrorZ_ok(o: crate::lightning::ln::msgs::TxAddInput) -> CResult_TxAddInputDecodeErrorZ { + CResult_TxAddInputDecodeErrorZ { + contents: CResult_TxAddInputDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_TxAddInputDecodeErrorZ in the error state. +pub extern "C" fn CResult_TxAddInputDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_TxAddInputDecodeErrorZ { + CResult_TxAddInputDecodeErrorZ { + contents: CResult_TxAddInputDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_TxAddInputDecodeErrorZ_is_ok(o: &CResult_TxAddInputDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_TxAddInputDecodeErrorZ. +pub extern "C" fn CResult_TxAddInputDecodeErrorZ_free(_res: CResult_TxAddInputDecodeErrorZ) { } +impl Drop for CResult_TxAddInputDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_TxAddInputDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_TxAddInputDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_TxAddInputDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_TxAddInputDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_TxAddInputDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_TxAddInputDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_TxAddInputDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_TxAddInputDecodeErrorZ_clone(orig: &CResult_TxAddInputDecodeErrorZ) -> CResult_TxAddInputDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_TxAddOutputDecodeErrorZ +pub union CResult_TxAddOutputDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::TxAddOutput, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_TxAddOutputDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::TxAddOutput on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_TxAddOutputDecodeErrorZ { + /// The contents of this CResult_TxAddOutputDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_TxAddOutputDecodeErrorZPtr, + /// Whether this CResult_TxAddOutputDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_TxAddOutputDecodeErrorZ in the success state. +pub extern "C" fn CResult_TxAddOutputDecodeErrorZ_ok(o: crate::lightning::ln::msgs::TxAddOutput) -> CResult_TxAddOutputDecodeErrorZ { + CResult_TxAddOutputDecodeErrorZ { + contents: CResult_TxAddOutputDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_TxAddOutputDecodeErrorZ in the error state. +pub extern "C" fn CResult_TxAddOutputDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_TxAddOutputDecodeErrorZ { + CResult_TxAddOutputDecodeErrorZ { + contents: CResult_TxAddOutputDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_TxAddOutputDecodeErrorZ_is_ok(o: &CResult_TxAddOutputDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_TxAddOutputDecodeErrorZ. +pub extern "C" fn CResult_TxAddOutputDecodeErrorZ_free(_res: CResult_TxAddOutputDecodeErrorZ) { } +impl Drop for CResult_TxAddOutputDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_TxAddOutputDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_TxAddOutputDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_TxAddOutputDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_TxAddOutputDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_TxAddOutputDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_TxAddOutputDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_TxAddOutputDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_TxAddOutputDecodeErrorZ_clone(orig: &CResult_TxAddOutputDecodeErrorZ) -> CResult_TxAddOutputDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_TxRemoveInputDecodeErrorZ +pub union CResult_TxRemoveInputDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::TxRemoveInput, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_TxRemoveInputDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::TxRemoveInput on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_TxRemoveInputDecodeErrorZ { + /// The contents of this CResult_TxRemoveInputDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_TxRemoveInputDecodeErrorZPtr, + /// Whether this CResult_TxRemoveInputDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_TxRemoveInputDecodeErrorZ in the success state. +pub extern "C" fn CResult_TxRemoveInputDecodeErrorZ_ok(o: crate::lightning::ln::msgs::TxRemoveInput) -> CResult_TxRemoveInputDecodeErrorZ { + CResult_TxRemoveInputDecodeErrorZ { + contents: CResult_TxRemoveInputDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_TxRemoveInputDecodeErrorZ in the error state. +pub extern "C" fn CResult_TxRemoveInputDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_TxRemoveInputDecodeErrorZ { + CResult_TxRemoveInputDecodeErrorZ { + contents: CResult_TxRemoveInputDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_TxRemoveInputDecodeErrorZ_is_ok(o: &CResult_TxRemoveInputDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_TxRemoveInputDecodeErrorZ. +pub extern "C" fn CResult_TxRemoveInputDecodeErrorZ_free(_res: CResult_TxRemoveInputDecodeErrorZ) { } +impl Drop for CResult_TxRemoveInputDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_TxRemoveInputDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_TxRemoveInputDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_TxRemoveInputDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_TxRemoveInputDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_TxRemoveInputDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_TxRemoveInputDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_TxRemoveInputDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_TxRemoveInputDecodeErrorZ_clone(orig: &CResult_TxRemoveInputDecodeErrorZ) -> CResult_TxRemoveInputDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_TxRemoveOutputDecodeErrorZ +pub union CResult_TxRemoveOutputDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::TxRemoveOutput, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_TxRemoveOutputDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::TxRemoveOutput on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_TxRemoveOutputDecodeErrorZ { + /// The contents of this CResult_TxRemoveOutputDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_TxRemoveOutputDecodeErrorZPtr, + /// Whether this CResult_TxRemoveOutputDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_TxRemoveOutputDecodeErrorZ in the success state. +pub extern "C" fn CResult_TxRemoveOutputDecodeErrorZ_ok(o: crate::lightning::ln::msgs::TxRemoveOutput) -> CResult_TxRemoveOutputDecodeErrorZ { + CResult_TxRemoveOutputDecodeErrorZ { + contents: CResult_TxRemoveOutputDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_TxRemoveOutputDecodeErrorZ in the error state. +pub extern "C" fn CResult_TxRemoveOutputDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_TxRemoveOutputDecodeErrorZ { + CResult_TxRemoveOutputDecodeErrorZ { + contents: CResult_TxRemoveOutputDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_TxRemoveOutputDecodeErrorZ_is_ok(o: &CResult_TxRemoveOutputDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_TxRemoveOutputDecodeErrorZ. +pub extern "C" fn CResult_TxRemoveOutputDecodeErrorZ_free(_res: CResult_TxRemoveOutputDecodeErrorZ) { } +impl Drop for CResult_TxRemoveOutputDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_TxRemoveOutputDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_TxRemoveOutputDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_TxRemoveOutputDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_TxRemoveOutputDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_TxRemoveOutputDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_TxRemoveOutputDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_TxRemoveOutputDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_TxRemoveOutputDecodeErrorZ_clone(orig: &CResult_TxRemoveOutputDecodeErrorZ) -> CResult_TxRemoveOutputDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_TxCompleteDecodeErrorZ +pub union CResult_TxCompleteDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::TxComplete, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_TxCompleteDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::TxComplete on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_TxCompleteDecodeErrorZ { + /// The contents of this CResult_TxCompleteDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_TxCompleteDecodeErrorZPtr, + /// Whether this CResult_TxCompleteDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_TxCompleteDecodeErrorZ in the success state. +pub extern "C" fn CResult_TxCompleteDecodeErrorZ_ok(o: crate::lightning::ln::msgs::TxComplete) -> CResult_TxCompleteDecodeErrorZ { + CResult_TxCompleteDecodeErrorZ { + contents: CResult_TxCompleteDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_TxCompleteDecodeErrorZ in the error state. +pub extern "C" fn CResult_TxCompleteDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_TxCompleteDecodeErrorZ { + CResult_TxCompleteDecodeErrorZ { + contents: CResult_TxCompleteDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_TxCompleteDecodeErrorZ_is_ok(o: &CResult_TxCompleteDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_TxCompleteDecodeErrorZ. +pub extern "C" fn CResult_TxCompleteDecodeErrorZ_free(_res: CResult_TxCompleteDecodeErrorZ) { } +impl Drop for CResult_TxCompleteDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_TxCompleteDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_TxCompleteDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_TxCompleteDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_TxCompleteDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_TxCompleteDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_TxCompleteDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_TxCompleteDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_TxCompleteDecodeErrorZ_clone(orig: &CResult_TxCompleteDecodeErrorZ) -> CResult_TxCompleteDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_TxSignaturesDecodeErrorZ +pub union CResult_TxSignaturesDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::TxSignatures, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_TxSignaturesDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::TxSignatures on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_TxSignaturesDecodeErrorZ { + /// The contents of this CResult_TxSignaturesDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_TxSignaturesDecodeErrorZPtr, + /// Whether this CResult_TxSignaturesDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_TxSignaturesDecodeErrorZ in the success state. +pub extern "C" fn CResult_TxSignaturesDecodeErrorZ_ok(o: crate::lightning::ln::msgs::TxSignatures) -> CResult_TxSignaturesDecodeErrorZ { + CResult_TxSignaturesDecodeErrorZ { + contents: CResult_TxSignaturesDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_TxSignaturesDecodeErrorZ in the error state. +pub extern "C" fn CResult_TxSignaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_TxSignaturesDecodeErrorZ { + CResult_TxSignaturesDecodeErrorZ { + contents: CResult_TxSignaturesDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_TxSignaturesDecodeErrorZ_is_ok(o: &CResult_TxSignaturesDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_TxSignaturesDecodeErrorZ. +pub extern "C" fn CResult_TxSignaturesDecodeErrorZ_free(_res: CResult_TxSignaturesDecodeErrorZ) { } +impl Drop for CResult_TxSignaturesDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_TxSignaturesDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_TxSignaturesDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_TxSignaturesDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_TxSignaturesDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_TxSignaturesDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_TxSignaturesDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_TxSignaturesDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_TxSignaturesDecodeErrorZ_clone(orig: &CResult_TxSignaturesDecodeErrorZ) -> CResult_TxSignaturesDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_TxInitRbfDecodeErrorZ +pub union CResult_TxInitRbfDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::TxInitRbf, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_TxInitRbfDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::TxInitRbf on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_TxInitRbfDecodeErrorZ { + /// The contents of this CResult_TxInitRbfDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_TxInitRbfDecodeErrorZPtr, + /// Whether this CResult_TxInitRbfDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_TxInitRbfDecodeErrorZ in the success state. +pub extern "C" fn CResult_TxInitRbfDecodeErrorZ_ok(o: crate::lightning::ln::msgs::TxInitRbf) -> CResult_TxInitRbfDecodeErrorZ { + CResult_TxInitRbfDecodeErrorZ { + contents: CResult_TxInitRbfDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_TxInitRbfDecodeErrorZ in the error state. +pub extern "C" fn CResult_TxInitRbfDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_TxInitRbfDecodeErrorZ { + CResult_TxInitRbfDecodeErrorZ { + contents: CResult_TxInitRbfDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_TxInitRbfDecodeErrorZ_is_ok(o: &CResult_TxInitRbfDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_TxInitRbfDecodeErrorZ. +pub extern "C" fn CResult_TxInitRbfDecodeErrorZ_free(_res: CResult_TxInitRbfDecodeErrorZ) { } +impl Drop for CResult_TxInitRbfDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_TxInitRbfDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_TxInitRbfDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_TxInitRbfDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_TxInitRbfDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_TxInitRbfDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_TxInitRbfDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_TxInitRbfDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_TxInitRbfDecodeErrorZ_clone(orig: &CResult_TxInitRbfDecodeErrorZ) -> CResult_TxInitRbfDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_TxAckRbfDecodeErrorZ +pub union CResult_TxAckRbfDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::TxAckRbf, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_TxAckRbfDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::TxAckRbf on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_TxAckRbfDecodeErrorZ { + /// The contents of this CResult_TxAckRbfDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_TxAckRbfDecodeErrorZPtr, + /// Whether this CResult_TxAckRbfDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_TxAckRbfDecodeErrorZ in the success state. +pub extern "C" fn CResult_TxAckRbfDecodeErrorZ_ok(o: crate::lightning::ln::msgs::TxAckRbf) -> CResult_TxAckRbfDecodeErrorZ { + CResult_TxAckRbfDecodeErrorZ { + contents: CResult_TxAckRbfDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_TxAckRbfDecodeErrorZ in the error state. +pub extern "C" fn CResult_TxAckRbfDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_TxAckRbfDecodeErrorZ { + CResult_TxAckRbfDecodeErrorZ { + contents: CResult_TxAckRbfDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_TxAckRbfDecodeErrorZ_is_ok(o: &CResult_TxAckRbfDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_TxAckRbfDecodeErrorZ. +pub extern "C" fn CResult_TxAckRbfDecodeErrorZ_free(_res: CResult_TxAckRbfDecodeErrorZ) { } +impl Drop for CResult_TxAckRbfDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_TxAckRbfDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_TxAckRbfDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_TxAckRbfDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_TxAckRbfDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_TxAckRbfDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_TxAckRbfDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_TxAckRbfDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_TxAckRbfDecodeErrorZ_clone(orig: &CResult_TxAckRbfDecodeErrorZ) -> CResult_TxAckRbfDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_TxAbortDecodeErrorZ +pub union CResult_TxAbortDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::TxAbort, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_TxAbortDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::TxAbort on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_TxAbortDecodeErrorZ { + /// The contents of this CResult_TxAbortDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_TxAbortDecodeErrorZPtr, + /// Whether this CResult_TxAbortDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_TxAbortDecodeErrorZ in the success state. +pub extern "C" fn CResult_TxAbortDecodeErrorZ_ok(o: crate::lightning::ln::msgs::TxAbort) -> CResult_TxAbortDecodeErrorZ { + CResult_TxAbortDecodeErrorZ { + contents: CResult_TxAbortDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_TxAbortDecodeErrorZ in the error state. +pub extern "C" fn CResult_TxAbortDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_TxAbortDecodeErrorZ { + CResult_TxAbortDecodeErrorZ { + contents: CResult_TxAbortDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_TxAbortDecodeErrorZ_is_ok(o: &CResult_TxAbortDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_TxAbortDecodeErrorZ. +pub extern "C" fn CResult_TxAbortDecodeErrorZ_free(_res: CResult_TxAbortDecodeErrorZ) { } +impl Drop for CResult_TxAbortDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_TxAbortDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_TxAbortDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_TxAbortDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_TxAbortDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_TxAbortDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_TxAbortDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_TxAbortDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_TxAbortDecodeErrorZ_clone(orig: &CResult_TxAbortDecodeErrorZ) -> CResult_TxAbortDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_AnnouncementSignaturesDecodeErrorZ +pub union CResult_AnnouncementSignaturesDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::AnnouncementSignatures, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_AnnouncementSignaturesDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::AnnouncementSignatures on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_AnnouncementSignaturesDecodeErrorZ { + /// The contents of this CResult_AnnouncementSignaturesDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_AnnouncementSignaturesDecodeErrorZPtr, + /// Whether this CResult_AnnouncementSignaturesDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_AnnouncementSignaturesDecodeErrorZ in the success state. +pub extern "C" fn CResult_AnnouncementSignaturesDecodeErrorZ_ok(o: crate::lightning::ln::msgs::AnnouncementSignatures) -> CResult_AnnouncementSignaturesDecodeErrorZ { + CResult_AnnouncementSignaturesDecodeErrorZ { + contents: CResult_AnnouncementSignaturesDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_AnnouncementSignaturesDecodeErrorZ in the error state. +pub extern "C" fn CResult_AnnouncementSignaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_AnnouncementSignaturesDecodeErrorZ { + CResult_AnnouncementSignaturesDecodeErrorZ { + contents: CResult_AnnouncementSignaturesDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(o: &CResult_AnnouncementSignaturesDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_AnnouncementSignaturesDecodeErrorZ. +pub extern "C" fn CResult_AnnouncementSignaturesDecodeErrorZ_free(_res: CResult_AnnouncementSignaturesDecodeErrorZ) { } +impl Drop for CResult_AnnouncementSignaturesDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_AnnouncementSignaturesDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_AnnouncementSignaturesDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_AnnouncementSignaturesDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_AnnouncementSignaturesDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_AnnouncementSignaturesDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_AnnouncementSignaturesDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_AnnouncementSignaturesDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig: &CResult_AnnouncementSignaturesDecodeErrorZ) -> CResult_AnnouncementSignaturesDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_ChannelReestablishDecodeErrorZ +pub union CResult_ChannelReestablishDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::ChannelReestablish, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_ChannelReestablishDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::ChannelReestablish on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_ChannelReestablishDecodeErrorZ { + /// The contents of this CResult_ChannelReestablishDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_ChannelReestablishDecodeErrorZPtr, + /// Whether this CResult_ChannelReestablishDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_ChannelReestablishDecodeErrorZ in the success state. +pub extern "C" fn CResult_ChannelReestablishDecodeErrorZ_ok(o: crate::lightning::ln::msgs::ChannelReestablish) -> CResult_ChannelReestablishDecodeErrorZ { + CResult_ChannelReestablishDecodeErrorZ { + contents: CResult_ChannelReestablishDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_ChannelReestablishDecodeErrorZ in the error state. +pub extern "C" fn CResult_ChannelReestablishDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelReestablishDecodeErrorZ { + CResult_ChannelReestablishDecodeErrorZ { + contents: CResult_ChannelReestablishDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_ChannelReestablishDecodeErrorZ_is_ok(o: &CResult_ChannelReestablishDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_ChannelReestablishDecodeErrorZ. +pub extern "C" fn CResult_ChannelReestablishDecodeErrorZ_free(_res: CResult_ChannelReestablishDecodeErrorZ) { } +impl Drop for CResult_ChannelReestablishDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_ChannelReestablishDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_ChannelReestablishDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_ChannelReestablishDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_ChannelReestablishDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_ChannelReestablishDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_ChannelReestablishDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_ChannelReestablishDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_ChannelReestablishDecodeErrorZ_clone(orig: &CResult_ChannelReestablishDecodeErrorZ) -> CResult_ChannelReestablishDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_ClosingSignedDecodeErrorZ +pub union CResult_ClosingSignedDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::ClosingSigned, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_ClosingSignedDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::ClosingSigned on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_ClosingSignedDecodeErrorZ { + /// The contents of this CResult_ClosingSignedDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_ClosingSignedDecodeErrorZPtr, + /// Whether this CResult_ClosingSignedDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_ClosingSignedDecodeErrorZ in the success state. +pub extern "C" fn CResult_ClosingSignedDecodeErrorZ_ok(o: crate::lightning::ln::msgs::ClosingSigned) -> CResult_ClosingSignedDecodeErrorZ { + CResult_ClosingSignedDecodeErrorZ { + contents: CResult_ClosingSignedDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_ClosingSignedDecodeErrorZ in the error state. +pub extern "C" fn CResult_ClosingSignedDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ClosingSignedDecodeErrorZ { + CResult_ClosingSignedDecodeErrorZ { + contents: CResult_ClosingSignedDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_ClosingSignedDecodeErrorZ_is_ok(o: &CResult_ClosingSignedDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_ClosingSignedDecodeErrorZ. +pub extern "C" fn CResult_ClosingSignedDecodeErrorZ_free(_res: CResult_ClosingSignedDecodeErrorZ) { } +impl Drop for CResult_ClosingSignedDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_ClosingSignedDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_ClosingSignedDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_ClosingSignedDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_ClosingSignedDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_ClosingSignedDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_ClosingSignedDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_ClosingSignedDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_ClosingSignedDecodeErrorZ_clone(orig: &CResult_ClosingSignedDecodeErrorZ) -> CResult_ClosingSignedDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_ClosingSignedFeeRangeDecodeErrorZ +pub union CResult_ClosingSignedFeeRangeDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::ClosingSignedFeeRange, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_ClosingSignedFeeRangeDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::ClosingSignedFeeRange on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_ClosingSignedFeeRangeDecodeErrorZ { + /// The contents of this CResult_ClosingSignedFeeRangeDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_ClosingSignedFeeRangeDecodeErrorZPtr, + /// Whether this CResult_ClosingSignedFeeRangeDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_ClosingSignedFeeRangeDecodeErrorZ in the success state. +pub extern "C" fn CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(o: crate::lightning::ln::msgs::ClosingSignedFeeRange) -> CResult_ClosingSignedFeeRangeDecodeErrorZ { + CResult_ClosingSignedFeeRangeDecodeErrorZ { + contents: CResult_ClosingSignedFeeRangeDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_ClosingSignedFeeRangeDecodeErrorZ in the error state. +pub extern "C" fn CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ClosingSignedFeeRangeDecodeErrorZ { + CResult_ClosingSignedFeeRangeDecodeErrorZ { + contents: CResult_ClosingSignedFeeRangeDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(o: &CResult_ClosingSignedFeeRangeDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_ClosingSignedFeeRangeDecodeErrorZ. +pub extern "C" fn CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res: CResult_ClosingSignedFeeRangeDecodeErrorZ) { } +impl Drop for CResult_ClosingSignedFeeRangeDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_ClosingSignedFeeRangeDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_ClosingSignedFeeRangeDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_ClosingSignedFeeRangeDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_ClosingSignedFeeRangeDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_ClosingSignedFeeRangeDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_ClosingSignedFeeRangeDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_ClosingSignedFeeRangeDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(orig: &CResult_ClosingSignedFeeRangeDecodeErrorZ) -> CResult_ClosingSignedFeeRangeDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_CommitmentSignedDecodeErrorZ +pub union CResult_CommitmentSignedDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::CommitmentSigned, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_CommitmentSignedDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::CommitmentSigned on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_CommitmentSignedDecodeErrorZ { + /// The contents of this CResult_CommitmentSignedDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_CommitmentSignedDecodeErrorZPtr, + /// Whether this CResult_CommitmentSignedDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_CommitmentSignedDecodeErrorZ in the success state. +pub extern "C" fn CResult_CommitmentSignedDecodeErrorZ_ok(o: crate::lightning::ln::msgs::CommitmentSigned) -> CResult_CommitmentSignedDecodeErrorZ { + CResult_CommitmentSignedDecodeErrorZ { + contents: CResult_CommitmentSignedDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_CommitmentSignedDecodeErrorZ in the error state. +pub extern "C" fn CResult_CommitmentSignedDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_CommitmentSignedDecodeErrorZ { + CResult_CommitmentSignedDecodeErrorZ { + contents: CResult_CommitmentSignedDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_CommitmentSignedDecodeErrorZ_is_ok(o: &CResult_CommitmentSignedDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_CommitmentSignedDecodeErrorZ. +pub extern "C" fn CResult_CommitmentSignedDecodeErrorZ_free(_res: CResult_CommitmentSignedDecodeErrorZ) { } +impl Drop for CResult_CommitmentSignedDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_CommitmentSignedDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_CommitmentSignedDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_CommitmentSignedDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_CommitmentSignedDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_CommitmentSignedDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_CommitmentSignedDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_CommitmentSignedDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_CommitmentSignedDecodeErrorZ_clone(orig: &CResult_CommitmentSignedDecodeErrorZ) -> CResult_CommitmentSignedDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_FundingCreatedDecodeErrorZ +pub union CResult_FundingCreatedDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::FundingCreated, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_FundingCreatedDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::FundingCreated on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_FundingCreatedDecodeErrorZ { + /// The contents of this CResult_FundingCreatedDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_FundingCreatedDecodeErrorZPtr, + /// Whether this CResult_FundingCreatedDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_FundingCreatedDecodeErrorZ in the success state. +pub extern "C" fn CResult_FundingCreatedDecodeErrorZ_ok(o: crate::lightning::ln::msgs::FundingCreated) -> CResult_FundingCreatedDecodeErrorZ { + CResult_FundingCreatedDecodeErrorZ { + contents: CResult_FundingCreatedDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_FundingCreatedDecodeErrorZ in the error state. +pub extern "C" fn CResult_FundingCreatedDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_FundingCreatedDecodeErrorZ { + CResult_FundingCreatedDecodeErrorZ { + contents: CResult_FundingCreatedDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_FundingCreatedDecodeErrorZ_is_ok(o: &CResult_FundingCreatedDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_FundingCreatedDecodeErrorZ. +pub extern "C" fn CResult_FundingCreatedDecodeErrorZ_free(_res: CResult_FundingCreatedDecodeErrorZ) { } +impl Drop for CResult_FundingCreatedDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_FundingCreatedDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_FundingCreatedDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_FundingCreatedDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_FundingCreatedDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_FundingCreatedDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_FundingCreatedDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_FundingCreatedDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_FundingCreatedDecodeErrorZ_clone(orig: &CResult_FundingCreatedDecodeErrorZ) -> CResult_FundingCreatedDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_FundingSignedDecodeErrorZ +pub union CResult_FundingSignedDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::FundingSigned, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_FundingSignedDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::FundingSigned on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_FundingSignedDecodeErrorZ { + /// The contents of this CResult_FundingSignedDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_FundingSignedDecodeErrorZPtr, + /// Whether this CResult_FundingSignedDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_FundingSignedDecodeErrorZ in the success state. +pub extern "C" fn CResult_FundingSignedDecodeErrorZ_ok(o: crate::lightning::ln::msgs::FundingSigned) -> CResult_FundingSignedDecodeErrorZ { + CResult_FundingSignedDecodeErrorZ { + contents: CResult_FundingSignedDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_FundingSignedDecodeErrorZ in the error state. +pub extern "C" fn CResult_FundingSignedDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_FundingSignedDecodeErrorZ { + CResult_FundingSignedDecodeErrorZ { + contents: CResult_FundingSignedDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_FundingSignedDecodeErrorZ_is_ok(o: &CResult_FundingSignedDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_FundingSignedDecodeErrorZ. +pub extern "C" fn CResult_FundingSignedDecodeErrorZ_free(_res: CResult_FundingSignedDecodeErrorZ) { } +impl Drop for CResult_FundingSignedDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_FundingSignedDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_FundingSignedDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_FundingSignedDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_FundingSignedDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_FundingSignedDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_FundingSignedDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_FundingSignedDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_FundingSignedDecodeErrorZ_clone(orig: &CResult_FundingSignedDecodeErrorZ) -> CResult_FundingSignedDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_ChannelReadyDecodeErrorZ +pub union CResult_ChannelReadyDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::ChannelReady, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_ChannelReadyDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::ChannelReady on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_ChannelReadyDecodeErrorZ { + /// The contents of this CResult_ChannelReadyDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_ChannelReadyDecodeErrorZPtr, + /// Whether this CResult_ChannelReadyDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_ChannelReadyDecodeErrorZ in the success state. +pub extern "C" fn CResult_ChannelReadyDecodeErrorZ_ok(o: crate::lightning::ln::msgs::ChannelReady) -> CResult_ChannelReadyDecodeErrorZ { + CResult_ChannelReadyDecodeErrorZ { + contents: CResult_ChannelReadyDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_ChannelReadyDecodeErrorZ in the error state. +pub extern "C" fn CResult_ChannelReadyDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelReadyDecodeErrorZ { + CResult_ChannelReadyDecodeErrorZ { + contents: CResult_ChannelReadyDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_ChannelReadyDecodeErrorZ_is_ok(o: &CResult_ChannelReadyDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_ChannelReadyDecodeErrorZ. +pub extern "C" fn CResult_ChannelReadyDecodeErrorZ_free(_res: CResult_ChannelReadyDecodeErrorZ) { } +impl Drop for CResult_ChannelReadyDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_ChannelReadyDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_ChannelReadyDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_ChannelReadyDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_ChannelReadyDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_ChannelReadyDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_ChannelReadyDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_ChannelReadyDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_ChannelReadyDecodeErrorZ_clone(orig: &CResult_ChannelReadyDecodeErrorZ) -> CResult_ChannelReadyDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_InitDecodeErrorZ +pub union CResult_InitDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::Init, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_InitDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::Init on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_InitDecodeErrorZ { + /// The contents of this CResult_InitDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_InitDecodeErrorZPtr, + /// Whether this CResult_InitDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_InitDecodeErrorZ in the success state. +pub extern "C" fn CResult_InitDecodeErrorZ_ok(o: crate::lightning::ln::msgs::Init) -> CResult_InitDecodeErrorZ { + CResult_InitDecodeErrorZ { + contents: CResult_InitDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_InitDecodeErrorZ in the error state. +pub extern "C" fn CResult_InitDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_InitDecodeErrorZ { + CResult_InitDecodeErrorZ { + contents: CResult_InitDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_InitDecodeErrorZ_is_ok(o: &CResult_InitDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_InitDecodeErrorZ. +pub extern "C" fn CResult_InitDecodeErrorZ_free(_res: CResult_InitDecodeErrorZ) { } +impl Drop for CResult_InitDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_InitDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_InitDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_InitDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_InitDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_InitDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_InitDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_InitDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_InitDecodeErrorZ_clone(orig: &CResult_InitDecodeErrorZ) -> CResult_InitDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_OpenChannelDecodeErrorZ +pub union CResult_OpenChannelDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::OpenChannel, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_OpenChannelDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::OpenChannel on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_OpenChannelDecodeErrorZ { + /// The contents of this CResult_OpenChannelDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_OpenChannelDecodeErrorZPtr, + /// Whether this CResult_OpenChannelDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_OpenChannelDecodeErrorZ in the success state. +pub extern "C" fn CResult_OpenChannelDecodeErrorZ_ok(o: crate::lightning::ln::msgs::OpenChannel) -> CResult_OpenChannelDecodeErrorZ { + CResult_OpenChannelDecodeErrorZ { + contents: CResult_OpenChannelDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_OpenChannelDecodeErrorZ in the error state. +pub extern "C" fn CResult_OpenChannelDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_OpenChannelDecodeErrorZ { + CResult_OpenChannelDecodeErrorZ { + contents: CResult_OpenChannelDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_OpenChannelDecodeErrorZ_is_ok(o: &CResult_OpenChannelDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_OpenChannelDecodeErrorZ. +pub extern "C" fn CResult_OpenChannelDecodeErrorZ_free(_res: CResult_OpenChannelDecodeErrorZ) { } +impl Drop for CResult_OpenChannelDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_OpenChannelDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_OpenChannelDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_OpenChannelDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_OpenChannelDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_OpenChannelDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_OpenChannelDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_OpenChannelDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_OpenChannelDecodeErrorZ_clone(orig: &CResult_OpenChannelDecodeErrorZ) -> CResult_OpenChannelDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_OpenChannelV2DecodeErrorZ +pub union CResult_OpenChannelV2DecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::OpenChannelV2, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_OpenChannelV2DecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::OpenChannelV2 on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_OpenChannelV2DecodeErrorZ { + /// The contents of this CResult_OpenChannelV2DecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_OpenChannelV2DecodeErrorZPtr, + /// Whether this CResult_OpenChannelV2DecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_OpenChannelV2DecodeErrorZ in the success state. +pub extern "C" fn CResult_OpenChannelV2DecodeErrorZ_ok(o: crate::lightning::ln::msgs::OpenChannelV2) -> CResult_OpenChannelV2DecodeErrorZ { + CResult_OpenChannelV2DecodeErrorZ { + contents: CResult_OpenChannelV2DecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_OpenChannelV2DecodeErrorZ in the error state. +pub extern "C" fn CResult_OpenChannelV2DecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_OpenChannelV2DecodeErrorZ { + CResult_OpenChannelV2DecodeErrorZ { + contents: CResult_OpenChannelV2DecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_OpenChannelV2DecodeErrorZ_is_ok(o: &CResult_OpenChannelV2DecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_OpenChannelV2DecodeErrorZ. +pub extern "C" fn CResult_OpenChannelV2DecodeErrorZ_free(_res: CResult_OpenChannelV2DecodeErrorZ) { } +impl Drop for CResult_OpenChannelV2DecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_OpenChannelV2DecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_OpenChannelV2DecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_OpenChannelV2DecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_OpenChannelV2DecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_OpenChannelV2DecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_OpenChannelV2DecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_OpenChannelV2DecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_OpenChannelV2DecodeErrorZ_clone(orig: &CResult_OpenChannelV2DecodeErrorZ) -> CResult_OpenChannelV2DecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_RevokeAndACKDecodeErrorZ +pub union CResult_RevokeAndACKDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::RevokeAndACK, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_RevokeAndACKDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::RevokeAndACK on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_RevokeAndACKDecodeErrorZ { + /// The contents of this CResult_RevokeAndACKDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_RevokeAndACKDecodeErrorZPtr, + /// Whether this CResult_RevokeAndACKDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_RevokeAndACKDecodeErrorZ in the success state. +pub extern "C" fn CResult_RevokeAndACKDecodeErrorZ_ok(o: crate::lightning::ln::msgs::RevokeAndACK) -> CResult_RevokeAndACKDecodeErrorZ { + CResult_RevokeAndACKDecodeErrorZ { + contents: CResult_RevokeAndACKDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_RevokeAndACKDecodeErrorZ in the error state. +pub extern "C" fn CResult_RevokeAndACKDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_RevokeAndACKDecodeErrorZ { + CResult_RevokeAndACKDecodeErrorZ { + contents: CResult_RevokeAndACKDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_RevokeAndACKDecodeErrorZ_is_ok(o: &CResult_RevokeAndACKDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_RevokeAndACKDecodeErrorZ. +pub extern "C" fn CResult_RevokeAndACKDecodeErrorZ_free(_res: CResult_RevokeAndACKDecodeErrorZ) { } +impl Drop for CResult_RevokeAndACKDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_RevokeAndACKDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_RevokeAndACKDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_RevokeAndACKDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_RevokeAndACKDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_RevokeAndACKDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_RevokeAndACKDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_RevokeAndACKDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_RevokeAndACKDecodeErrorZ_clone(orig: &CResult_RevokeAndACKDecodeErrorZ) -> CResult_RevokeAndACKDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_ShutdownDecodeErrorZ +pub union CResult_ShutdownDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::Shutdown, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_ShutdownDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::Shutdown on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_ShutdownDecodeErrorZ { + /// The contents of this CResult_ShutdownDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_ShutdownDecodeErrorZPtr, + /// Whether this CResult_ShutdownDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_ShutdownDecodeErrorZ in the success state. +pub extern "C" fn CResult_ShutdownDecodeErrorZ_ok(o: crate::lightning::ln::msgs::Shutdown) -> CResult_ShutdownDecodeErrorZ { + CResult_ShutdownDecodeErrorZ { + contents: CResult_ShutdownDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_ShutdownDecodeErrorZ in the error state. +pub extern "C" fn CResult_ShutdownDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ShutdownDecodeErrorZ { + CResult_ShutdownDecodeErrorZ { + contents: CResult_ShutdownDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_ShutdownDecodeErrorZ_is_ok(o: &CResult_ShutdownDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_ShutdownDecodeErrorZ. +pub extern "C" fn CResult_ShutdownDecodeErrorZ_free(_res: CResult_ShutdownDecodeErrorZ) { } +impl Drop for CResult_ShutdownDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_ShutdownDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_ShutdownDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_ShutdownDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_ShutdownDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_ShutdownDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_ShutdownDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_ShutdownDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_ShutdownDecodeErrorZ_clone(orig: &CResult_ShutdownDecodeErrorZ) -> CResult_ShutdownDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_UpdateFailHTLCDecodeErrorZ +pub union CResult_UpdateFailHTLCDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::UpdateFailHTLC, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_UpdateFailHTLCDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::UpdateFailHTLC on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_UpdateFailHTLCDecodeErrorZ { + /// The contents of this CResult_UpdateFailHTLCDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_UpdateFailHTLCDecodeErrorZPtr, + /// Whether this CResult_UpdateFailHTLCDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_UpdateFailHTLCDecodeErrorZ in the success state. +pub extern "C" fn CResult_UpdateFailHTLCDecodeErrorZ_ok(o: crate::lightning::ln::msgs::UpdateFailHTLC) -> CResult_UpdateFailHTLCDecodeErrorZ { + CResult_UpdateFailHTLCDecodeErrorZ { + contents: CResult_UpdateFailHTLCDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_UpdateFailHTLCDecodeErrorZ in the error state. +pub extern "C" fn CResult_UpdateFailHTLCDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_UpdateFailHTLCDecodeErrorZ { + CResult_UpdateFailHTLCDecodeErrorZ { + contents: CResult_UpdateFailHTLCDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_UpdateFailHTLCDecodeErrorZ_is_ok(o: &CResult_UpdateFailHTLCDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_UpdateFailHTLCDecodeErrorZ. +pub extern "C" fn CResult_UpdateFailHTLCDecodeErrorZ_free(_res: CResult_UpdateFailHTLCDecodeErrorZ) { } +impl Drop for CResult_UpdateFailHTLCDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_UpdateFailHTLCDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_UpdateFailHTLCDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_UpdateFailHTLCDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_UpdateFailHTLCDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_UpdateFailHTLCDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_UpdateFailHTLCDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_UpdateFailHTLCDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_UpdateFailHTLCDecodeErrorZ_clone(orig: &CResult_UpdateFailHTLCDecodeErrorZ) -> CResult_UpdateFailHTLCDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_UpdateFailMalformedHTLCDecodeErrorZ +pub union CResult_UpdateFailMalformedHTLCDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::UpdateFailMalformedHTLC, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_UpdateFailMalformedHTLCDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::UpdateFailMalformedHTLC on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_UpdateFailMalformedHTLCDecodeErrorZ { + /// The contents of this CResult_UpdateFailMalformedHTLCDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_UpdateFailMalformedHTLCDecodeErrorZPtr, + /// Whether this CResult_UpdateFailMalformedHTLCDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_UpdateFailMalformedHTLCDecodeErrorZ in the success state. +pub extern "C" fn CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o: crate::lightning::ln::msgs::UpdateFailMalformedHTLC) -> CResult_UpdateFailMalformedHTLCDecodeErrorZ { + CResult_UpdateFailMalformedHTLCDecodeErrorZ { + contents: CResult_UpdateFailMalformedHTLCDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_UpdateFailMalformedHTLCDecodeErrorZ in the error state. +pub extern "C" fn CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_UpdateFailMalformedHTLCDecodeErrorZ { + CResult_UpdateFailMalformedHTLCDecodeErrorZ { + contents: CResult_UpdateFailMalformedHTLCDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(o: &CResult_UpdateFailMalformedHTLCDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_UpdateFailMalformedHTLCDecodeErrorZ. +pub extern "C" fn CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res: CResult_UpdateFailMalformedHTLCDecodeErrorZ) { } +impl Drop for CResult_UpdateFailMalformedHTLCDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_UpdateFailMalformedHTLCDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_UpdateFailMalformedHTLCDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_UpdateFailMalformedHTLCDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_UpdateFailMalformedHTLCDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_UpdateFailMalformedHTLCDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_UpdateFailMalformedHTLCDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_UpdateFailMalformedHTLCDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig: &CResult_UpdateFailMalformedHTLCDecodeErrorZ) -> CResult_UpdateFailMalformedHTLCDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_UpdateFeeDecodeErrorZ +pub union CResult_UpdateFeeDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::UpdateFee, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_UpdateFeeDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::UpdateFee on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_UpdateFeeDecodeErrorZ { + /// The contents of this CResult_UpdateFeeDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_UpdateFeeDecodeErrorZPtr, + /// Whether this CResult_UpdateFeeDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_UpdateFeeDecodeErrorZ in the success state. +pub extern "C" fn CResult_UpdateFeeDecodeErrorZ_ok(o: crate::lightning::ln::msgs::UpdateFee) -> CResult_UpdateFeeDecodeErrorZ { + CResult_UpdateFeeDecodeErrorZ { + contents: CResult_UpdateFeeDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_UpdateFeeDecodeErrorZ in the error state. +pub extern "C" fn CResult_UpdateFeeDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_UpdateFeeDecodeErrorZ { + CResult_UpdateFeeDecodeErrorZ { + contents: CResult_UpdateFeeDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_UpdateFeeDecodeErrorZ_is_ok(o: &CResult_UpdateFeeDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_UpdateFeeDecodeErrorZ. +pub extern "C" fn CResult_UpdateFeeDecodeErrorZ_free(_res: CResult_UpdateFeeDecodeErrorZ) { } +impl Drop for CResult_UpdateFeeDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_UpdateFeeDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_UpdateFeeDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_UpdateFeeDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_UpdateFeeDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_UpdateFeeDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_UpdateFeeDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_UpdateFeeDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_UpdateFeeDecodeErrorZ_clone(orig: &CResult_UpdateFeeDecodeErrorZ) -> CResult_UpdateFeeDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_UpdateFulfillHTLCDecodeErrorZ +pub union CResult_UpdateFulfillHTLCDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::UpdateFulfillHTLC, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_UpdateFulfillHTLCDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::UpdateFulfillHTLC on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_UpdateFulfillHTLCDecodeErrorZ { + /// The contents of this CResult_UpdateFulfillHTLCDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_UpdateFulfillHTLCDecodeErrorZPtr, + /// Whether this CResult_UpdateFulfillHTLCDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_UpdateFulfillHTLCDecodeErrorZ in the success state. +pub extern "C" fn CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o: crate::lightning::ln::msgs::UpdateFulfillHTLC) -> CResult_UpdateFulfillHTLCDecodeErrorZ { + CResult_UpdateFulfillHTLCDecodeErrorZ { + contents: CResult_UpdateFulfillHTLCDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_UpdateFulfillHTLCDecodeErrorZ in the error state. +pub extern "C" fn CResult_UpdateFulfillHTLCDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_UpdateFulfillHTLCDecodeErrorZ { + CResult_UpdateFulfillHTLCDecodeErrorZ { + contents: CResult_UpdateFulfillHTLCDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(o: &CResult_UpdateFulfillHTLCDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_UpdateFulfillHTLCDecodeErrorZ. +pub extern "C" fn CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res: CResult_UpdateFulfillHTLCDecodeErrorZ) { } +impl Drop for CResult_UpdateFulfillHTLCDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_UpdateFulfillHTLCDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_UpdateFulfillHTLCDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_UpdateFulfillHTLCDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_UpdateFulfillHTLCDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_UpdateFulfillHTLCDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_UpdateFulfillHTLCDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_UpdateFulfillHTLCDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig: &CResult_UpdateFulfillHTLCDecodeErrorZ) -> CResult_UpdateFulfillHTLCDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_UpdateAddHTLCDecodeErrorZ +pub union CResult_UpdateAddHTLCDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::UpdateAddHTLC, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_UpdateAddHTLCDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::UpdateAddHTLC on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_UpdateAddHTLCDecodeErrorZ { + /// The contents of this CResult_UpdateAddHTLCDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_UpdateAddHTLCDecodeErrorZPtr, + /// Whether this CResult_UpdateAddHTLCDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_UpdateAddHTLCDecodeErrorZ in the success state. +pub extern "C" fn CResult_UpdateAddHTLCDecodeErrorZ_ok(o: crate::lightning::ln::msgs::UpdateAddHTLC) -> CResult_UpdateAddHTLCDecodeErrorZ { + CResult_UpdateAddHTLCDecodeErrorZ { + contents: CResult_UpdateAddHTLCDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_UpdateAddHTLCDecodeErrorZ in the error state. +pub extern "C" fn CResult_UpdateAddHTLCDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_UpdateAddHTLCDecodeErrorZ { + CResult_UpdateAddHTLCDecodeErrorZ { + contents: CResult_UpdateAddHTLCDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_UpdateAddHTLCDecodeErrorZ_is_ok(o: &CResult_UpdateAddHTLCDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_UpdateAddHTLCDecodeErrorZ. +pub extern "C" fn CResult_UpdateAddHTLCDecodeErrorZ_free(_res: CResult_UpdateAddHTLCDecodeErrorZ) { } +impl Drop for CResult_UpdateAddHTLCDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_UpdateAddHTLCDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_UpdateAddHTLCDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_UpdateAddHTLCDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_UpdateAddHTLCDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_UpdateAddHTLCDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_UpdateAddHTLCDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_UpdateAddHTLCDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_UpdateAddHTLCDecodeErrorZ_clone(orig: &CResult_UpdateAddHTLCDecodeErrorZ) -> CResult_UpdateAddHTLCDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_OnionMessageDecodeErrorZ +pub union CResult_OnionMessageDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::OnionMessage, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_OnionMessageDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::OnionMessage on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_OnionMessageDecodeErrorZ { + /// The contents of this CResult_OnionMessageDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_OnionMessageDecodeErrorZPtr, + /// Whether this CResult_OnionMessageDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_OnionMessageDecodeErrorZ in the success state. +pub extern "C" fn CResult_OnionMessageDecodeErrorZ_ok(o: crate::lightning::ln::msgs::OnionMessage) -> CResult_OnionMessageDecodeErrorZ { + CResult_OnionMessageDecodeErrorZ { + contents: CResult_OnionMessageDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_OnionMessageDecodeErrorZ in the error state. +pub extern "C" fn CResult_OnionMessageDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_OnionMessageDecodeErrorZ { + CResult_OnionMessageDecodeErrorZ { + contents: CResult_OnionMessageDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_OnionMessageDecodeErrorZ_is_ok(o: &CResult_OnionMessageDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_OnionMessageDecodeErrorZ. +pub extern "C" fn CResult_OnionMessageDecodeErrorZ_free(_res: CResult_OnionMessageDecodeErrorZ) { } +impl Drop for CResult_OnionMessageDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_OnionMessageDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_OnionMessageDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_OnionMessageDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_OnionMessageDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_OnionMessageDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_OnionMessageDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_OnionMessageDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_OnionMessageDecodeErrorZ_clone(orig: &CResult_OnionMessageDecodeErrorZ) -> CResult_OnionMessageDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_PingDecodeErrorZ +pub union CResult_PingDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::Ping, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_PingDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::Ping on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_PingDecodeErrorZ { + /// The contents of this CResult_PingDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_PingDecodeErrorZPtr, + /// Whether this CResult_PingDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_PingDecodeErrorZ in the success state. +pub extern "C" fn CResult_PingDecodeErrorZ_ok(o: crate::lightning::ln::msgs::Ping) -> CResult_PingDecodeErrorZ { + CResult_PingDecodeErrorZ { + contents: CResult_PingDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_PingDecodeErrorZ in the error state. +pub extern "C" fn CResult_PingDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_PingDecodeErrorZ { + CResult_PingDecodeErrorZ { + contents: CResult_PingDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_PingDecodeErrorZ_is_ok(o: &CResult_PingDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_PingDecodeErrorZ. +pub extern "C" fn CResult_PingDecodeErrorZ_free(_res: CResult_PingDecodeErrorZ) { } +impl Drop for CResult_PingDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_PingDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_PingDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_PingDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_PingDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_PingDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_PingDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_PingDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_PingDecodeErrorZ_clone(orig: &CResult_PingDecodeErrorZ) -> CResult_PingDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_PongDecodeErrorZ +pub union CResult_PongDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::Pong, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_PongDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::Pong on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_PongDecodeErrorZ { + /// The contents of this CResult_PongDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_PongDecodeErrorZPtr, + /// Whether this CResult_PongDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_PongDecodeErrorZ in the success state. +pub extern "C" fn CResult_PongDecodeErrorZ_ok(o: crate::lightning::ln::msgs::Pong) -> CResult_PongDecodeErrorZ { + CResult_PongDecodeErrorZ { + contents: CResult_PongDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_PongDecodeErrorZ in the error state. +pub extern "C" fn CResult_PongDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_PongDecodeErrorZ { + CResult_PongDecodeErrorZ { + contents: CResult_PongDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_PongDecodeErrorZ_is_ok(o: &CResult_PongDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_PongDecodeErrorZ. +pub extern "C" fn CResult_PongDecodeErrorZ_free(_res: CResult_PongDecodeErrorZ) { } +impl Drop for CResult_PongDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_PongDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_PongDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_PongDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_PongDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_PongDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_PongDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_PongDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_PongDecodeErrorZ_clone(orig: &CResult_PongDecodeErrorZ) -> CResult_PongDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_UnsignedChannelAnnouncementDecodeErrorZ +pub union CResult_UnsignedChannelAnnouncementDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::UnsignedChannelAnnouncement, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_UnsignedChannelAnnouncementDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::UnsignedChannelAnnouncement on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_UnsignedChannelAnnouncementDecodeErrorZ { + /// The contents of this CResult_UnsignedChannelAnnouncementDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_UnsignedChannelAnnouncementDecodeErrorZPtr, + /// Whether this CResult_UnsignedChannelAnnouncementDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_UnsignedChannelAnnouncementDecodeErrorZ in the success state. +pub extern "C" fn CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o: crate::lightning::ln::msgs::UnsignedChannelAnnouncement) -> CResult_UnsignedChannelAnnouncementDecodeErrorZ { + CResult_UnsignedChannelAnnouncementDecodeErrorZ { + contents: CResult_UnsignedChannelAnnouncementDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_UnsignedChannelAnnouncementDecodeErrorZ in the error state. +pub extern "C" fn CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_UnsignedChannelAnnouncementDecodeErrorZ { + CResult_UnsignedChannelAnnouncementDecodeErrorZ { + contents: CResult_UnsignedChannelAnnouncementDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(o: &CResult_UnsignedChannelAnnouncementDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_UnsignedChannelAnnouncementDecodeErrorZ. +pub extern "C" fn CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res: CResult_UnsignedChannelAnnouncementDecodeErrorZ) { } +impl Drop for CResult_UnsignedChannelAnnouncementDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_UnsignedChannelAnnouncementDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_UnsignedChannelAnnouncementDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_UnsignedChannelAnnouncementDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_UnsignedChannelAnnouncementDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_UnsignedChannelAnnouncementDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_UnsignedChannelAnnouncementDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_UnsignedChannelAnnouncementDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig: &CResult_UnsignedChannelAnnouncementDecodeErrorZ) -> CResult_UnsignedChannelAnnouncementDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_ChannelAnnouncementDecodeErrorZ +pub union CResult_ChannelAnnouncementDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::ChannelAnnouncement, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_ChannelAnnouncementDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::ChannelAnnouncement on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_ChannelAnnouncementDecodeErrorZ { + /// The contents of this CResult_ChannelAnnouncementDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_ChannelAnnouncementDecodeErrorZPtr, + /// Whether this CResult_ChannelAnnouncementDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_ChannelAnnouncementDecodeErrorZ in the success state. +pub extern "C" fn CResult_ChannelAnnouncementDecodeErrorZ_ok(o: crate::lightning::ln::msgs::ChannelAnnouncement) -> CResult_ChannelAnnouncementDecodeErrorZ { + CResult_ChannelAnnouncementDecodeErrorZ { + contents: CResult_ChannelAnnouncementDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_ChannelAnnouncementDecodeErrorZ in the error state. +pub extern "C" fn CResult_ChannelAnnouncementDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelAnnouncementDecodeErrorZ { + CResult_ChannelAnnouncementDecodeErrorZ { + contents: CResult_ChannelAnnouncementDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_ChannelAnnouncementDecodeErrorZ_is_ok(o: &CResult_ChannelAnnouncementDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_ChannelAnnouncementDecodeErrorZ. +pub extern "C" fn CResult_ChannelAnnouncementDecodeErrorZ_free(_res: CResult_ChannelAnnouncementDecodeErrorZ) { } +impl Drop for CResult_ChannelAnnouncementDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_ChannelAnnouncementDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_ChannelAnnouncementDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_ChannelAnnouncementDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_ChannelAnnouncementDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_ChannelAnnouncementDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_ChannelAnnouncementDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_ChannelAnnouncementDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_ChannelAnnouncementDecodeErrorZ_clone(orig: &CResult_ChannelAnnouncementDecodeErrorZ) -> CResult_ChannelAnnouncementDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_UnsignedChannelUpdateDecodeErrorZ +pub union CResult_UnsignedChannelUpdateDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::UnsignedChannelUpdate, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_UnsignedChannelUpdateDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::UnsignedChannelUpdate on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_UnsignedChannelUpdateDecodeErrorZ { + /// The contents of this CResult_UnsignedChannelUpdateDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_UnsignedChannelUpdateDecodeErrorZPtr, + /// Whether this CResult_UnsignedChannelUpdateDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_UnsignedChannelUpdateDecodeErrorZ in the success state. +pub extern "C" fn CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o: crate::lightning::ln::msgs::UnsignedChannelUpdate) -> CResult_UnsignedChannelUpdateDecodeErrorZ { + CResult_UnsignedChannelUpdateDecodeErrorZ { + contents: CResult_UnsignedChannelUpdateDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_UnsignedChannelUpdateDecodeErrorZ in the error state. +pub extern "C" fn CResult_UnsignedChannelUpdateDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_UnsignedChannelUpdateDecodeErrorZ { + CResult_UnsignedChannelUpdateDecodeErrorZ { + contents: CResult_UnsignedChannelUpdateDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(o: &CResult_UnsignedChannelUpdateDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_UnsignedChannelUpdateDecodeErrorZ. +pub extern "C" fn CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res: CResult_UnsignedChannelUpdateDecodeErrorZ) { } +impl Drop for CResult_UnsignedChannelUpdateDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_UnsignedChannelUpdateDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_UnsignedChannelUpdateDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_UnsignedChannelUpdateDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } } } -impl Clone for CVec_BalanceZ { +impl Clone for CResult_UnsignedChannelUpdateDecodeErrorZ { fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) + if self.result_ok { + Self { result_ok: true, contents: CResult_UnsignedChannelUpdateDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_UnsignedChannelUpdateDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } } } +#[no_mangle] +/// Creates a new CResult_UnsignedChannelUpdateDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig: &CResult_UnsignedChannelUpdateDecodeErrorZ) -> CResult_UnsignedChannelUpdateDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ -pub union CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr { +/// The contents of CResult_ChannelUpdateDecodeErrorZ +pub union CResult_ChannelUpdateDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::C2Tuple_BlockHashChannelMonitorZ, + pub result: *mut crate::lightning::ln::msgs::ChannelUpdate, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::C2Tuple_BlockHashChannelMonitorZ on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_ChannelUpdateDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::ChannelUpdate on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ { - /// The contents of this CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ, accessible via either +pub struct CResult_ChannelUpdateDecodeErrorZ { + /// The contents of this CResult_ChannelUpdateDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr, - /// Whether this CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ represents a success state. + pub contents: CResult_ChannelUpdateDecodeErrorZPtr, + /// Whether this CResult_ChannelUpdateDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ in the success state. -pub extern "C" fn CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o: crate::c_types::derived::C2Tuple_BlockHashChannelMonitorZ) -> CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ { - CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ { - contents: CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr { +/// Creates a new CResult_ChannelUpdateDecodeErrorZ in the success state. +pub extern "C" fn CResult_ChannelUpdateDecodeErrorZ_ok(o: crate::lightning::ln::msgs::ChannelUpdate) -> CResult_ChannelUpdateDecodeErrorZ { + CResult_ChannelUpdateDecodeErrorZ { + contents: CResult_ChannelUpdateDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ in the error state. -pub extern "C" fn CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ { - CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ { - contents: CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr { +/// Creates a new CResult_ChannelUpdateDecodeErrorZ in the error state. +pub extern "C" fn CResult_ChannelUpdateDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelUpdateDecodeErrorZ { + CResult_ChannelUpdateDecodeErrorZ { + contents: CResult_ChannelUpdateDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -12182,13 +15523,13 @@ pub extern "C" fn CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e: cr } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(o: &CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ) -> bool { +pub extern "C" fn CResult_ChannelUpdateDecodeErrorZ_is_ok(o: &CResult_ChannelUpdateDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ. -pub extern "C" fn CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res: CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ) { } -impl Drop for CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ { +/// Frees any resources used by the CResult_ChannelUpdateDecodeErrorZ. +pub extern "C" fn CResult_ChannelUpdateDecodeErrorZ_free(_res: CResult_ChannelUpdateDecodeErrorZ) { } +impl Drop for CResult_ChannelUpdateDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -12201,16 +15542,16 @@ impl Drop for CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ { } } } -impl From> for CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ChannelUpdateDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr { result } + CResult_ChannelUpdateDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr { err } + CResult_ChannelUpdateDecodeErrorZPtr { err } }; Self { contents, @@ -12218,142 +15559,155 @@ impl From for C2Tuple_PublicKeyTypeZ { - fn from (tup: (crate::c_types::PublicKey, crate::lightning::ln::wire::Type)) -> Self { - Self { - a: tup.0, - b: tup.1, +impl Clone for CResult_ChannelUpdateDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_ChannelUpdateDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_ChannelUpdateDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } } } } -impl C2Tuple_PublicKeyTypeZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::PublicKey, crate::lightning::ln::wire::Type) { - (self.a, self.b) - } -} -/// Creates a new C2Tuple_PublicKeyTypeZ from the contained elements. #[no_mangle] -pub extern "C" fn C2Tuple_PublicKeyTypeZ_new(a: crate::c_types::PublicKey, b: crate::lightning::ln::wire::Type) -> C2Tuple_PublicKeyTypeZ { - C2Tuple_PublicKeyTypeZ { a, b, } +/// Creates a new CResult_ChannelUpdateDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_ChannelUpdateDecodeErrorZ_clone(orig: &CResult_ChannelUpdateDecodeErrorZ) -> CResult_ChannelUpdateDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_ErrorMessageDecodeErrorZ +pub union CResult_ErrorMessageDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::ErrorMessage, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, } - -#[no_mangle] -/// Frees any resources used by the C2Tuple_PublicKeyTypeZ. -pub extern "C" fn C2Tuple_PublicKeyTypeZ_free(_res: C2Tuple_PublicKeyTypeZ) { } #[repr(C)] -/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_PublicKeyTypeZs of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_C2Tuple_PublicKeyTypeZZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::derived::C2Tuple_PublicKeyTypeZ, - /// The number of elements pointed to by `data`. - pub datalen: usize +/// A CResult_ErrorMessageDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::ErrorMessage on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_ErrorMessageDecodeErrorZ { + /// The contents of this CResult_ErrorMessageDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_ErrorMessageDecodeErrorZPtr, + /// Whether this CResult_ErrorMessageDecodeErrorZ represents a success state. + pub result_ok: bool, } -impl CVec_C2Tuple_PublicKeyTypeZZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_PublicKeyTypeZ] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } +#[no_mangle] +/// Creates a new CResult_ErrorMessageDecodeErrorZ in the success state. +pub extern "C" fn CResult_ErrorMessageDecodeErrorZ_ok(o: crate::lightning::ln::msgs::ErrorMessage) -> CResult_ErrorMessageDecodeErrorZ { + CResult_ErrorMessageDecodeErrorZ { + contents: CResult_ErrorMessageDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, } } -impl From> for CVec_C2Tuple_PublicKeyTypeZZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } +#[no_mangle] +/// Creates a new CResult_ErrorMessageDecodeErrorZ in the error state. +pub extern "C" fn CResult_ErrorMessageDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ErrorMessageDecodeErrorZ { + CResult_ErrorMessageDecodeErrorZ { + contents: CResult_ErrorMessageDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, } } +/// Checks if the given object is currently in the success state #[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_C2Tuple_PublicKeyTypeZZ_free(_res: CVec_C2Tuple_PublicKeyTypeZZ) { } -impl Drop for CVec_C2Tuple_PublicKeyTypeZZ { +pub extern "C" fn CResult_ErrorMessageDecodeErrorZ_is_ok(o: &CResult_ErrorMessageDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_ErrorMessageDecodeErrorZ. +pub extern "C" fn CResult_ErrorMessageDecodeErrorZ_free(_res: CResult_ErrorMessageDecodeErrorZ) { } +impl Drop for CResult_ErrorMessageDecodeErrorZ { fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } } } -#[repr(C)] -/// An enum which can either contain a crate::lightning::onion_message::packet::CustomOnionMessageContents or not -pub enum COption_CustomOnionMessageContentsZ { - /// When we're in this state, this COption_CustomOnionMessageContentsZ contains a crate::lightning::onion_message::packet::CustomOnionMessageContents - Some(crate::lightning::onion_message::packet::CustomOnionMessageContents), - /// When we're in this state, this COption_CustomOnionMessageContentsZ contains nothing - None -} -impl COption_CustomOnionMessageContentsZ { - #[allow(unused)] pub(crate) fn is_some(&self) -> bool { - if let Self::None = self { false } else { true } - } - #[allow(unused)] pub(crate) fn is_none(&self) -> bool { - !self.is_some() - } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::onion_message::packet::CustomOnionMessageContents { - if let Self::Some(v) = self { v } else { unreachable!() } +impl From> for CResult_ErrorMessageDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_ErrorMessageDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_ErrorMessageDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } } } -#[no_mangle] -/// Constructs a new COption_CustomOnionMessageContentsZ containing a crate::lightning::onion_message::packet::CustomOnionMessageContents -pub extern "C" fn COption_CustomOnionMessageContentsZ_some(o: crate::lightning::onion_message::packet::CustomOnionMessageContents) -> COption_CustomOnionMessageContentsZ { - COption_CustomOnionMessageContentsZ::Some(o) -} -#[no_mangle] -/// Constructs a new COption_CustomOnionMessageContentsZ containing nothing -pub extern "C" fn COption_CustomOnionMessageContentsZ_none() -> COption_CustomOnionMessageContentsZ { - COption_CustomOnionMessageContentsZ::None +impl Clone for CResult_ErrorMessageDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_ErrorMessageDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_ErrorMessageDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } } #[no_mangle] -/// Frees any resources associated with the crate::lightning::onion_message::packet::CustomOnionMessageContents, if we are in the Some state -pub extern "C" fn COption_CustomOnionMessageContentsZ_free(_res: COption_CustomOnionMessageContentsZ) { } +/// Creates a new CResult_ErrorMessageDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_ErrorMessageDecodeErrorZ_clone(orig: &CResult_ErrorMessageDecodeErrorZ) -> CResult_ErrorMessageDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_COption_CustomOnionMessageContentsZDecodeErrorZ -pub union CResult_COption_CustomOnionMessageContentsZDecodeErrorZPtr { +/// The contents of CResult_WarningMessageDecodeErrorZ +pub union CResult_WarningMessageDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::COption_CustomOnionMessageContentsZ, + pub result: *mut crate::lightning::ln::msgs::WarningMessage, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_COption_CustomOnionMessageContentsZDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::COption_CustomOnionMessageContentsZ on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_WarningMessageDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::WarningMessage on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_COption_CustomOnionMessageContentsZDecodeErrorZ { - /// The contents of this CResult_COption_CustomOnionMessageContentsZDecodeErrorZ, accessible via either +pub struct CResult_WarningMessageDecodeErrorZ { + /// The contents of this CResult_WarningMessageDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_COption_CustomOnionMessageContentsZDecodeErrorZPtr, - /// Whether this CResult_COption_CustomOnionMessageContentsZDecodeErrorZ represents a success state. + pub contents: CResult_WarningMessageDecodeErrorZPtr, + /// Whether this CResult_WarningMessageDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_COption_CustomOnionMessageContentsZDecodeErrorZ in the success state. -pub extern "C" fn CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_ok(o: crate::c_types::derived::COption_CustomOnionMessageContentsZ) -> CResult_COption_CustomOnionMessageContentsZDecodeErrorZ { - CResult_COption_CustomOnionMessageContentsZDecodeErrorZ { - contents: CResult_COption_CustomOnionMessageContentsZDecodeErrorZPtr { +/// Creates a new CResult_WarningMessageDecodeErrorZ in the success state. +pub extern "C" fn CResult_WarningMessageDecodeErrorZ_ok(o: crate::lightning::ln::msgs::WarningMessage) -> CResult_WarningMessageDecodeErrorZ { + CResult_WarningMessageDecodeErrorZ { + contents: CResult_WarningMessageDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_COption_CustomOnionMessageContentsZDecodeErrorZ in the error state. -pub extern "C" fn CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_COption_CustomOnionMessageContentsZDecodeErrorZ { - CResult_COption_CustomOnionMessageContentsZDecodeErrorZ { - contents: CResult_COption_CustomOnionMessageContentsZDecodeErrorZPtr { +/// Creates a new CResult_WarningMessageDecodeErrorZ in the error state. +pub extern "C" fn CResult_WarningMessageDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_WarningMessageDecodeErrorZ { + CResult_WarningMessageDecodeErrorZ { + contents: CResult_WarningMessageDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -12361,13 +15715,13 @@ pub extern "C" fn CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_err(e: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_is_ok(o: &CResult_COption_CustomOnionMessageContentsZDecodeErrorZ) -> bool { +pub extern "C" fn CResult_WarningMessageDecodeErrorZ_is_ok(o: &CResult_WarningMessageDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_COption_CustomOnionMessageContentsZDecodeErrorZ. -pub extern "C" fn CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_free(_res: CResult_COption_CustomOnionMessageContentsZDecodeErrorZ) { } -impl Drop for CResult_COption_CustomOnionMessageContentsZDecodeErrorZ { +/// Frees any resources used by the CResult_WarningMessageDecodeErrorZ. +pub extern "C" fn CResult_WarningMessageDecodeErrorZ_free(_res: CResult_WarningMessageDecodeErrorZ) { } +impl Drop for CResult_WarningMessageDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -12380,16 +15734,16 @@ impl Drop for CResult_COption_CustomOnionMessageContentsZDecodeErrorZ { } } } -impl From> for CResult_COption_CustomOnionMessageContentsZDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_WarningMessageDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_COption_CustomOnionMessageContentsZDecodeErrorZPtr { result } + CResult_WarningMessageDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_COption_CustomOnionMessageContentsZDecodeErrorZPtr { err } + CResult_WarningMessageDecodeErrorZPtr { err } }; Self { contents, @@ -12397,167 +15751,155 @@ impl From bool { - if let Self::None = self { false } else { true } - } - #[allow(unused)] pub(crate) fn is_none(&self) -> bool { - !self.is_some() - } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::ln::msgs::NetAddress { - if let Self::Some(v) = self { v } else { unreachable!() } +impl Clone for CResult_WarningMessageDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_WarningMessageDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_WarningMessageDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } } } #[no_mangle] -/// Constructs a new COption_NetAddressZ containing a crate::lightning::ln::msgs::NetAddress -pub extern "C" fn COption_NetAddressZ_some(o: crate::lightning::ln::msgs::NetAddress) -> COption_NetAddressZ { - COption_NetAddressZ::Some(o) -} -#[no_mangle] -/// Constructs a new COption_NetAddressZ containing nothing -pub extern "C" fn COption_NetAddressZ_none() -> COption_NetAddressZ { - COption_NetAddressZ::None -} -#[no_mangle] -/// Frees any resources associated with the crate::lightning::ln::msgs::NetAddress, if we are in the Some state -pub extern "C" fn COption_NetAddressZ_free(_res: COption_NetAddressZ) { } -#[no_mangle] -/// Creates a new COption_NetAddressZ which has the same data as `orig` +/// Creates a new CResult_WarningMessageDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_NetAddressZ_clone(orig: &COption_NetAddressZ) -> COption_NetAddressZ { Clone::clone(&orig) } +pub extern "C" fn CResult_WarningMessageDecodeErrorZ_clone(orig: &CResult_WarningMessageDecodeErrorZ) -> CResult_WarningMessageDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple_PublicKeyCOption_NetAddressZZ { - /// The element at position 0 - pub a: crate::c_types::PublicKey, - /// The element at position 1 - pub b: crate::c_types::derived::COption_NetAddressZ, +/// The contents of CResult_UnsignedNodeAnnouncementDecodeErrorZ +pub union CResult_UnsignedNodeAnnouncementDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::UnsignedNodeAnnouncement, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, } -impl From<(crate::c_types::PublicKey, crate::c_types::derived::COption_NetAddressZ)> for C2Tuple_PublicKeyCOption_NetAddressZZ { - fn from (tup: (crate::c_types::PublicKey, crate::c_types::derived::COption_NetAddressZ)) -> Self { - Self { - a: tup.0, - b: tup.1, - } - } +#[repr(C)] +/// A CResult_UnsignedNodeAnnouncementDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::UnsignedNodeAnnouncement on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_UnsignedNodeAnnouncementDecodeErrorZ { + /// The contents of this CResult_UnsignedNodeAnnouncementDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_UnsignedNodeAnnouncementDecodeErrorZPtr, + /// Whether this CResult_UnsignedNodeAnnouncementDecodeErrorZ represents a success state. + pub result_ok: bool, } -impl C2Tuple_PublicKeyCOption_NetAddressZZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::PublicKey, crate::c_types::derived::COption_NetAddressZ) { - (self.a, self.b) +#[no_mangle] +/// Creates a new CResult_UnsignedNodeAnnouncementDecodeErrorZ in the success state. +pub extern "C" fn CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> CResult_UnsignedNodeAnnouncementDecodeErrorZ { + CResult_UnsignedNodeAnnouncementDecodeErrorZ { + contents: CResult_UnsignedNodeAnnouncementDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, } } -impl Clone for C2Tuple_PublicKeyCOption_NetAddressZZ { - fn clone(&self) -> Self { - Self { - a: Clone::clone(&self.a), - b: Clone::clone(&self.b), - } +#[no_mangle] +/// Creates a new CResult_UnsignedNodeAnnouncementDecodeErrorZ in the error state. +pub extern "C" fn CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_UnsignedNodeAnnouncementDecodeErrorZ { + CResult_UnsignedNodeAnnouncementDecodeErrorZ { + contents: CResult_UnsignedNodeAnnouncementDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, } } +/// Checks if the given object is currently in the success state #[no_mangle] -/// Creates a new tuple which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C2Tuple_PublicKeyCOption_NetAddressZZ_clone(orig: &C2Tuple_PublicKeyCOption_NetAddressZZ) -> C2Tuple_PublicKeyCOption_NetAddressZZ { Clone::clone(&orig) } -/// Creates a new C2Tuple_PublicKeyCOption_NetAddressZZ from the contained elements. -#[no_mangle] -pub extern "C" fn C2Tuple_PublicKeyCOption_NetAddressZZ_new(a: crate::c_types::PublicKey, b: crate::c_types::derived::COption_NetAddressZ) -> C2Tuple_PublicKeyCOption_NetAddressZZ { - C2Tuple_PublicKeyCOption_NetAddressZZ { a, b, } +pub extern "C" fn CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(o: &CResult_UnsignedNodeAnnouncementDecodeErrorZ) -> bool { + o.result_ok } - #[no_mangle] -/// Frees any resources used by the C2Tuple_PublicKeyCOption_NetAddressZZ. -pub extern "C" fn C2Tuple_PublicKeyCOption_NetAddressZZ_free(_res: C2Tuple_PublicKeyCOption_NetAddressZZ) { } -#[repr(C)] -/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_PublicKeyCOption_NetAddressZZs of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::derived::C2Tuple_PublicKeyCOption_NetAddressZZ, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_PublicKeyCOption_NetAddressZZ] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } +/// Frees any resources used by the CResult_UnsignedNodeAnnouncementDecodeErrorZ. +pub extern "C" fn CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res: CResult_UnsignedNodeAnnouncementDecodeErrorZ) { } +impl Drop for CResult_UnsignedNodeAnnouncementDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } } } -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ_free(_res: CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ) { } -impl Drop for CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; +impl From> for CResult_UnsignedNodeAnnouncementDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_UnsignedNodeAnnouncementDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_UnsignedNodeAnnouncementDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } } } -impl Clone for CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ { +impl Clone for CResult_UnsignedNodeAnnouncementDecodeErrorZ { fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) + if self.result_ok { + Self { result_ok: true, contents: CResult_UnsignedNodeAnnouncementDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_UnsignedNodeAnnouncementDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } } } +#[no_mangle] +/// Creates a new CResult_UnsignedNodeAnnouncementDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig: &CResult_UnsignedNodeAnnouncementDecodeErrorZ) -> CResult_UnsignedNodeAnnouncementDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_CVec_u8ZPeerHandleErrorZ -pub union CResult_CVec_u8ZPeerHandleErrorZPtr { +/// The contents of CResult_NodeAnnouncementDecodeErrorZ +pub union CResult_NodeAnnouncementDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::CVec_u8Z, + pub result: *mut crate::lightning::ln::msgs::NodeAnnouncement, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::peer_handler::PeerHandleError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_CVec_u8ZPeerHandleErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::CVec_u8Z on success and a crate::lightning::ln::peer_handler::PeerHandleError on failure. +/// A CResult_NodeAnnouncementDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::NodeAnnouncement on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_CVec_u8ZPeerHandleErrorZ { - /// The contents of this CResult_CVec_u8ZPeerHandleErrorZ, accessible via either +pub struct CResult_NodeAnnouncementDecodeErrorZ { + /// The contents of this CResult_NodeAnnouncementDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_CVec_u8ZPeerHandleErrorZPtr, - /// Whether this CResult_CVec_u8ZPeerHandleErrorZ represents a success state. + pub contents: CResult_NodeAnnouncementDecodeErrorZPtr, + /// Whether this CResult_NodeAnnouncementDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_CVec_u8ZPeerHandleErrorZ in the success state. -pub extern "C" fn CResult_CVec_u8ZPeerHandleErrorZ_ok(o: crate::c_types::derived::CVec_u8Z) -> CResult_CVec_u8ZPeerHandleErrorZ { - CResult_CVec_u8ZPeerHandleErrorZ { - contents: CResult_CVec_u8ZPeerHandleErrorZPtr { +/// Creates a new CResult_NodeAnnouncementDecodeErrorZ in the success state. +pub extern "C" fn CResult_NodeAnnouncementDecodeErrorZ_ok(o: crate::lightning::ln::msgs::NodeAnnouncement) -> CResult_NodeAnnouncementDecodeErrorZ { + CResult_NodeAnnouncementDecodeErrorZ { + contents: CResult_NodeAnnouncementDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_CVec_u8ZPeerHandleErrorZ in the error state. -pub extern "C" fn CResult_CVec_u8ZPeerHandleErrorZ_err(e: crate::lightning::ln::peer_handler::PeerHandleError) -> CResult_CVec_u8ZPeerHandleErrorZ { - CResult_CVec_u8ZPeerHandleErrorZ { - contents: CResult_CVec_u8ZPeerHandleErrorZPtr { +/// Creates a new CResult_NodeAnnouncementDecodeErrorZ in the error state. +pub extern "C" fn CResult_NodeAnnouncementDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_NodeAnnouncementDecodeErrorZ { + CResult_NodeAnnouncementDecodeErrorZ { + contents: CResult_NodeAnnouncementDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -12565,13 +15907,13 @@ pub extern "C" fn CResult_CVec_u8ZPeerHandleErrorZ_err(e: crate::lightning::ln:: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_CVec_u8ZPeerHandleErrorZ_is_ok(o: &CResult_CVec_u8ZPeerHandleErrorZ) -> bool { +pub extern "C" fn CResult_NodeAnnouncementDecodeErrorZ_is_ok(o: &CResult_NodeAnnouncementDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_CVec_u8ZPeerHandleErrorZ. -pub extern "C" fn CResult_CVec_u8ZPeerHandleErrorZ_free(_res: CResult_CVec_u8ZPeerHandleErrorZ) { } -impl Drop for CResult_CVec_u8ZPeerHandleErrorZ { +/// Frees any resources used by the CResult_NodeAnnouncementDecodeErrorZ. +pub extern "C" fn CResult_NodeAnnouncementDecodeErrorZ_free(_res: CResult_NodeAnnouncementDecodeErrorZ) { } +impl Drop for CResult_NodeAnnouncementDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -12584,16 +15926,16 @@ impl Drop for CResult_CVec_u8ZPeerHandleErrorZ { } } } -impl From> for CResult_CVec_u8ZPeerHandleErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_NodeAnnouncementDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_CVec_u8ZPeerHandleErrorZPtr { result } + CResult_NodeAnnouncementDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_CVec_u8ZPeerHandleErrorZPtr { err } + CResult_NodeAnnouncementDecodeErrorZPtr { err } }; Self { contents, @@ -12601,58 +15943,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_CVec_u8ZPeerHandleErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_NodeAnnouncementDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_CVec_u8ZPeerHandleErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_NodeAnnouncementDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_CVec_u8ZPeerHandleErrorZ which has the same data as `orig` +/// Creates a new CResult_NodeAnnouncementDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_CVec_u8ZPeerHandleErrorZ_clone(orig: &CResult_CVec_u8ZPeerHandleErrorZ) -> CResult_CVec_u8ZPeerHandleErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_NodeAnnouncementDecodeErrorZ_clone(orig: &CResult_NodeAnnouncementDecodeErrorZ) -> CResult_NodeAnnouncementDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_NonePeerHandleErrorZ -pub union CResult_NonePeerHandleErrorZPtr { - /// Note that this value is always NULL, as there are no contents in the OK variant - pub result: *mut core::ffi::c_void, +/// The contents of CResult_QueryShortChannelIdsDecodeErrorZ +pub union CResult_QueryShortChannelIdsDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::QueryShortChannelIds, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::peer_handler::PeerHandleError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_NonePeerHandleErrorZ represents the result of a fallible operation, -/// containing a () on success and a crate::lightning::ln::peer_handler::PeerHandleError on failure. +/// A CResult_QueryShortChannelIdsDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::QueryShortChannelIds on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_NonePeerHandleErrorZ { - /// The contents of this CResult_NonePeerHandleErrorZ, accessible via either +pub struct CResult_QueryShortChannelIdsDecodeErrorZ { + /// The contents of this CResult_QueryShortChannelIdsDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_NonePeerHandleErrorZPtr, - /// Whether this CResult_NonePeerHandleErrorZ represents a success state. + pub contents: CResult_QueryShortChannelIdsDecodeErrorZPtr, + /// Whether this CResult_QueryShortChannelIdsDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_NonePeerHandleErrorZ in the success state. -pub extern "C" fn CResult_NonePeerHandleErrorZ_ok() -> CResult_NonePeerHandleErrorZ { - CResult_NonePeerHandleErrorZ { - contents: CResult_NonePeerHandleErrorZPtr { - result: core::ptr::null_mut(), +/// Creates a new CResult_QueryShortChannelIdsDecodeErrorZ in the success state. +pub extern "C" fn CResult_QueryShortChannelIdsDecodeErrorZ_ok(o: crate::lightning::ln::msgs::QueryShortChannelIds) -> CResult_QueryShortChannelIdsDecodeErrorZ { + CResult_QueryShortChannelIdsDecodeErrorZ { + contents: CResult_QueryShortChannelIdsDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_NonePeerHandleErrorZ in the error state. -pub extern "C" fn CResult_NonePeerHandleErrorZ_err(e: crate::lightning::ln::peer_handler::PeerHandleError) -> CResult_NonePeerHandleErrorZ { - CResult_NonePeerHandleErrorZ { - contents: CResult_NonePeerHandleErrorZPtr { +/// Creates a new CResult_QueryShortChannelIdsDecodeErrorZ in the error state. +pub extern "C" fn CResult_QueryShortChannelIdsDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_QueryShortChannelIdsDecodeErrorZ { + CResult_QueryShortChannelIdsDecodeErrorZ { + contents: CResult_QueryShortChannelIdsDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -12660,15 +16003,18 @@ pub extern "C" fn CResult_NonePeerHandleErrorZ_err(e: crate::lightning::ln::peer } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_NonePeerHandleErrorZ_is_ok(o: &CResult_NonePeerHandleErrorZ) -> bool { +pub extern "C" fn CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(o: &CResult_QueryShortChannelIdsDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_NonePeerHandleErrorZ. -pub extern "C" fn CResult_NonePeerHandleErrorZ_free(_res: CResult_NonePeerHandleErrorZ) { } -impl Drop for CResult_NonePeerHandleErrorZ { +/// Frees any resources used by the CResult_QueryShortChannelIdsDecodeErrorZ. +pub extern "C" fn CResult_QueryShortChannelIdsDecodeErrorZ_free(_res: CResult_QueryShortChannelIdsDecodeErrorZ) { } +impl Drop for CResult_QueryShortChannelIdsDecodeErrorZ { fn drop(&mut self) { if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } } else { if unsafe { !(self.contents.err as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.err) }; @@ -12676,16 +16022,16 @@ impl Drop for CResult_NonePeerHandleErrorZ { } } } -impl From> for CResult_NonePeerHandleErrorZ { - fn from(mut o: crate::c_types::CResultTempl<(), crate::lightning::ln::peer_handler::PeerHandleError>) -> Self { +impl From> for CResult_QueryShortChannelIdsDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { - let _ = unsafe { Box::from_raw(o.contents.result) }; - o.contents.result = core::ptr::null_mut(); - CResult_NonePeerHandleErrorZPtr { result: core::ptr::null_mut() } + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_QueryShortChannelIdsDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_NonePeerHandleErrorZPtr { err } + CResult_QueryShortChannelIdsDecodeErrorZPtr { err } }; Self { contents, @@ -12693,59 +16039,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_NonePeerHandleErrorZPtr { - result: core::ptr::null_mut() + Self { result_ok: true, contents: CResult_QueryShortChannelIdsDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_NonePeerHandleErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_QueryShortChannelIdsDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_NonePeerHandleErrorZ which has the same data as `orig` +/// Creates a new CResult_QueryShortChannelIdsDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_NonePeerHandleErrorZ_clone(orig: &CResult_NonePeerHandleErrorZ) -> CResult_NonePeerHandleErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig: &CResult_QueryShortChannelIdsDecodeErrorZ) -> CResult_QueryShortChannelIdsDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_boolPeerHandleErrorZ -pub union CResult_boolPeerHandleErrorZPtr { +/// The contents of CResult_ReplyShortChannelIdsEndDecodeErrorZ +pub union CResult_ReplyShortChannelIdsEndDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut bool, + pub result: *mut crate::lightning::ln::msgs::ReplyShortChannelIdsEnd, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::peer_handler::PeerHandleError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_boolPeerHandleErrorZ represents the result of a fallible operation, -/// containing a bool on success and a crate::lightning::ln::peer_handler::PeerHandleError on failure. +/// A CResult_ReplyShortChannelIdsEndDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::ReplyShortChannelIdsEnd on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_boolPeerHandleErrorZ { - /// The contents of this CResult_boolPeerHandleErrorZ, accessible via either +pub struct CResult_ReplyShortChannelIdsEndDecodeErrorZ { + /// The contents of this CResult_ReplyShortChannelIdsEndDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_boolPeerHandleErrorZPtr, - /// Whether this CResult_boolPeerHandleErrorZ represents a success state. + pub contents: CResult_ReplyShortChannelIdsEndDecodeErrorZPtr, + /// Whether this CResult_ReplyShortChannelIdsEndDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_boolPeerHandleErrorZ in the success state. -pub extern "C" fn CResult_boolPeerHandleErrorZ_ok(o: bool) -> CResult_boolPeerHandleErrorZ { - CResult_boolPeerHandleErrorZ { - contents: CResult_boolPeerHandleErrorZPtr { +/// Creates a new CResult_ReplyShortChannelIdsEndDecodeErrorZ in the success state. +pub extern "C" fn CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o: crate::lightning::ln::msgs::ReplyShortChannelIdsEnd) -> CResult_ReplyShortChannelIdsEndDecodeErrorZ { + CResult_ReplyShortChannelIdsEndDecodeErrorZ { + contents: CResult_ReplyShortChannelIdsEndDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_boolPeerHandleErrorZ in the error state. -pub extern "C" fn CResult_boolPeerHandleErrorZ_err(e: crate::lightning::ln::peer_handler::PeerHandleError) -> CResult_boolPeerHandleErrorZ { - CResult_boolPeerHandleErrorZ { - contents: CResult_boolPeerHandleErrorZPtr { +/// Creates a new CResult_ReplyShortChannelIdsEndDecodeErrorZ in the error state. +pub extern "C" fn CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ReplyShortChannelIdsEndDecodeErrorZ { + CResult_ReplyShortChannelIdsEndDecodeErrorZ { + contents: CResult_ReplyShortChannelIdsEndDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -12753,13 +16099,13 @@ pub extern "C" fn CResult_boolPeerHandleErrorZ_err(e: crate::lightning::ln::peer } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_boolPeerHandleErrorZ_is_ok(o: &CResult_boolPeerHandleErrorZ) -> bool { +pub extern "C" fn CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(o: &CResult_ReplyShortChannelIdsEndDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_boolPeerHandleErrorZ. -pub extern "C" fn CResult_boolPeerHandleErrorZ_free(_res: CResult_boolPeerHandleErrorZ) { } -impl Drop for CResult_boolPeerHandleErrorZ { +/// Frees any resources used by the CResult_ReplyShortChannelIdsEndDecodeErrorZ. +pub extern "C" fn CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res: CResult_ReplyShortChannelIdsEndDecodeErrorZ) { } +impl Drop for CResult_ReplyShortChannelIdsEndDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -12772,16 +16118,16 @@ impl Drop for CResult_boolPeerHandleErrorZ { } } } -impl From> for CResult_boolPeerHandleErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ReplyShortChannelIdsEndDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_boolPeerHandleErrorZPtr { result } + CResult_ReplyShortChannelIdsEndDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_boolPeerHandleErrorZPtr { err } + CResult_ReplyShortChannelIdsEndDecodeErrorZPtr { err } }; Self { contents, @@ -12789,59 +16135,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_boolPeerHandleErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_ReplyShortChannelIdsEndDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_boolPeerHandleErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_ReplyShortChannelIdsEndDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_boolPeerHandleErrorZ which has the same data as `orig` +/// Creates a new CResult_ReplyShortChannelIdsEndDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_boolPeerHandleErrorZ_clone(orig: &CResult_boolPeerHandleErrorZ) -> CResult_boolPeerHandleErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig: &CResult_ReplyShortChannelIdsEndDecodeErrorZ) -> CResult_ReplyShortChannelIdsEndDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_TxOutUtxoLookupErrorZ -pub union CResult_TxOutUtxoLookupErrorZPtr { +/// The contents of CResult_QueryChannelRangeDecodeErrorZ +pub union CResult_QueryChannelRangeDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::TxOut, + pub result: *mut crate::lightning::ln::msgs::QueryChannelRange, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::routing::utxo::UtxoLookupError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_TxOutUtxoLookupErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::TxOut on success and a crate::lightning::routing::utxo::UtxoLookupError on failure. +/// A CResult_QueryChannelRangeDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::QueryChannelRange on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_TxOutUtxoLookupErrorZ { - /// The contents of this CResult_TxOutUtxoLookupErrorZ, accessible via either +pub struct CResult_QueryChannelRangeDecodeErrorZ { + /// The contents of this CResult_QueryChannelRangeDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_TxOutUtxoLookupErrorZPtr, - /// Whether this CResult_TxOutUtxoLookupErrorZ represents a success state. + pub contents: CResult_QueryChannelRangeDecodeErrorZPtr, + /// Whether this CResult_QueryChannelRangeDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_TxOutUtxoLookupErrorZ in the success state. -pub extern "C" fn CResult_TxOutUtxoLookupErrorZ_ok(o: crate::c_types::TxOut) -> CResult_TxOutUtxoLookupErrorZ { - CResult_TxOutUtxoLookupErrorZ { - contents: CResult_TxOutUtxoLookupErrorZPtr { +/// Creates a new CResult_QueryChannelRangeDecodeErrorZ in the success state. +pub extern "C" fn CResult_QueryChannelRangeDecodeErrorZ_ok(o: crate::lightning::ln::msgs::QueryChannelRange) -> CResult_QueryChannelRangeDecodeErrorZ { + CResult_QueryChannelRangeDecodeErrorZ { + contents: CResult_QueryChannelRangeDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_TxOutUtxoLookupErrorZ in the error state. -pub extern "C" fn CResult_TxOutUtxoLookupErrorZ_err(e: crate::lightning::routing::utxo::UtxoLookupError) -> CResult_TxOutUtxoLookupErrorZ { - CResult_TxOutUtxoLookupErrorZ { - contents: CResult_TxOutUtxoLookupErrorZPtr { +/// Creates a new CResult_QueryChannelRangeDecodeErrorZ in the error state. +pub extern "C" fn CResult_QueryChannelRangeDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_QueryChannelRangeDecodeErrorZ { + CResult_QueryChannelRangeDecodeErrorZ { + contents: CResult_QueryChannelRangeDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -12849,13 +16195,13 @@ pub extern "C" fn CResult_TxOutUtxoLookupErrorZ_err(e: crate::lightning::routing } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_TxOutUtxoLookupErrorZ_is_ok(o: &CResult_TxOutUtxoLookupErrorZ) -> bool { +pub extern "C" fn CResult_QueryChannelRangeDecodeErrorZ_is_ok(o: &CResult_QueryChannelRangeDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_TxOutUtxoLookupErrorZ. -pub extern "C" fn CResult_TxOutUtxoLookupErrorZ_free(_res: CResult_TxOutUtxoLookupErrorZ) { } -impl Drop for CResult_TxOutUtxoLookupErrorZ { +/// Frees any resources used by the CResult_QueryChannelRangeDecodeErrorZ. +pub extern "C" fn CResult_QueryChannelRangeDecodeErrorZ_free(_res: CResult_QueryChannelRangeDecodeErrorZ) { } +impl Drop for CResult_QueryChannelRangeDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -12868,16 +16214,16 @@ impl Drop for CResult_TxOutUtxoLookupErrorZ { } } } -impl From> for CResult_TxOutUtxoLookupErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_QueryChannelRangeDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_TxOutUtxoLookupErrorZPtr { result } + CResult_QueryChannelRangeDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_TxOutUtxoLookupErrorZPtr { err } + CResult_QueryChannelRangeDecodeErrorZPtr { err } }; Self { contents, @@ -12885,58 +16231,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_TxOutUtxoLookupErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_QueryChannelRangeDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_TxOutUtxoLookupErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_QueryChannelRangeDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_TxOutUtxoLookupErrorZ which has the same data as `orig` +/// Creates a new CResult_QueryChannelRangeDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_TxOutUtxoLookupErrorZ_clone(orig: &CResult_TxOutUtxoLookupErrorZ) -> CResult_TxOutUtxoLookupErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_QueryChannelRangeDecodeErrorZ_clone(orig: &CResult_QueryChannelRangeDecodeErrorZ) -> CResult_QueryChannelRangeDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_NoneSendErrorZ -pub union CResult_NoneSendErrorZPtr { - /// Note that this value is always NULL, as there are no contents in the OK variant - pub result: *mut core::ffi::c_void, +/// The contents of CResult_ReplyChannelRangeDecodeErrorZ +pub union CResult_ReplyChannelRangeDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::ReplyChannelRange, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::onion_message::messenger::SendError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_NoneSendErrorZ represents the result of a fallible operation, -/// containing a () on success and a crate::lightning::onion_message::messenger::SendError on failure. +/// A CResult_ReplyChannelRangeDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::ReplyChannelRange on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_NoneSendErrorZ { - /// The contents of this CResult_NoneSendErrorZ, accessible via either +pub struct CResult_ReplyChannelRangeDecodeErrorZ { + /// The contents of this CResult_ReplyChannelRangeDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_NoneSendErrorZPtr, - /// Whether this CResult_NoneSendErrorZ represents a success state. + pub contents: CResult_ReplyChannelRangeDecodeErrorZPtr, + /// Whether this CResult_ReplyChannelRangeDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_NoneSendErrorZ in the success state. -pub extern "C" fn CResult_NoneSendErrorZ_ok() -> CResult_NoneSendErrorZ { - CResult_NoneSendErrorZ { - contents: CResult_NoneSendErrorZPtr { - result: core::ptr::null_mut(), +/// Creates a new CResult_ReplyChannelRangeDecodeErrorZ in the success state. +pub extern "C" fn CResult_ReplyChannelRangeDecodeErrorZ_ok(o: crate::lightning::ln::msgs::ReplyChannelRange) -> CResult_ReplyChannelRangeDecodeErrorZ { + CResult_ReplyChannelRangeDecodeErrorZ { + contents: CResult_ReplyChannelRangeDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_NoneSendErrorZ in the error state. -pub extern "C" fn CResult_NoneSendErrorZ_err(e: crate::lightning::onion_message::messenger::SendError) -> CResult_NoneSendErrorZ { - CResult_NoneSendErrorZ { - contents: CResult_NoneSendErrorZPtr { +/// Creates a new CResult_ReplyChannelRangeDecodeErrorZ in the error state. +pub extern "C" fn CResult_ReplyChannelRangeDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ReplyChannelRangeDecodeErrorZ { + CResult_ReplyChannelRangeDecodeErrorZ { + contents: CResult_ReplyChannelRangeDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -12944,15 +16291,18 @@ pub extern "C" fn CResult_NoneSendErrorZ_err(e: crate::lightning::onion_message: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_NoneSendErrorZ_is_ok(o: &CResult_NoneSendErrorZ) -> bool { +pub extern "C" fn CResult_ReplyChannelRangeDecodeErrorZ_is_ok(o: &CResult_ReplyChannelRangeDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_NoneSendErrorZ. -pub extern "C" fn CResult_NoneSendErrorZ_free(_res: CResult_NoneSendErrorZ) { } -impl Drop for CResult_NoneSendErrorZ { +/// Frees any resources used by the CResult_ReplyChannelRangeDecodeErrorZ. +pub extern "C" fn CResult_ReplyChannelRangeDecodeErrorZ_free(_res: CResult_ReplyChannelRangeDecodeErrorZ) { } +impl Drop for CResult_ReplyChannelRangeDecodeErrorZ { fn drop(&mut self) { if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } } else { if unsafe { !(self.contents.err as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.err) }; @@ -12960,16 +16310,16 @@ impl Drop for CResult_NoneSendErrorZ { } } } -impl From> for CResult_NoneSendErrorZ { - fn from(mut o: crate::c_types::CResultTempl<(), crate::lightning::onion_message::messenger::SendError>) -> Self { +impl From> for CResult_ReplyChannelRangeDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { - let _ = unsafe { Box::from_raw(o.contents.result) }; - o.contents.result = core::ptr::null_mut(); - CResult_NoneSendErrorZPtr { result: core::ptr::null_mut() } + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_ReplyChannelRangeDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_NoneSendErrorZPtr { err } + CResult_ReplyChannelRangeDecodeErrorZPtr { err } }; Self { contents, @@ -12977,74 +16327,95 @@ impl From Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_ReplyChannelRangeDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_ReplyChannelRangeDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_ReplyChannelRangeDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_ReplyChannelRangeDecodeErrorZ_clone(orig: &CResult_ReplyChannelRangeDecodeErrorZ) -> CResult_ReplyChannelRangeDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_BlindedPathNoneZ -pub union CResult_BlindedPathNoneZPtr { +/// The contents of CResult_GossipTimestampFilterDecodeErrorZ +pub union CResult_GossipTimestampFilterDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::blinded_path::BlindedPath, - /// Note that this value is always NULL, as there are no contents in the Err variant - pub err: *mut core::ffi::c_void, + pub result: *mut crate::lightning::ln::msgs::GossipTimestampFilter, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_BlindedPathNoneZ represents the result of a fallible operation, -/// containing a crate::lightning::blinded_path::BlindedPath on success and a () on failure. +/// A CResult_GossipTimestampFilterDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::GossipTimestampFilter on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_BlindedPathNoneZ { - /// The contents of this CResult_BlindedPathNoneZ, accessible via either +pub struct CResult_GossipTimestampFilterDecodeErrorZ { + /// The contents of this CResult_GossipTimestampFilterDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_BlindedPathNoneZPtr, - /// Whether this CResult_BlindedPathNoneZ represents a success state. + pub contents: CResult_GossipTimestampFilterDecodeErrorZPtr, + /// Whether this CResult_GossipTimestampFilterDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_BlindedPathNoneZ in the success state. -pub extern "C" fn CResult_BlindedPathNoneZ_ok(o: crate::lightning::blinded_path::BlindedPath) -> CResult_BlindedPathNoneZ { - CResult_BlindedPathNoneZ { - contents: CResult_BlindedPathNoneZPtr { +/// Creates a new CResult_GossipTimestampFilterDecodeErrorZ in the success state. +pub extern "C" fn CResult_GossipTimestampFilterDecodeErrorZ_ok(o: crate::lightning::ln::msgs::GossipTimestampFilter) -> CResult_GossipTimestampFilterDecodeErrorZ { + CResult_GossipTimestampFilterDecodeErrorZ { + contents: CResult_GossipTimestampFilterDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_BlindedPathNoneZ in the error state. -pub extern "C" fn CResult_BlindedPathNoneZ_err() -> CResult_BlindedPathNoneZ { - CResult_BlindedPathNoneZ { - contents: CResult_BlindedPathNoneZPtr { - err: core::ptr::null_mut(), +/// Creates a new CResult_GossipTimestampFilterDecodeErrorZ in the error state. +pub extern "C" fn CResult_GossipTimestampFilterDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_GossipTimestampFilterDecodeErrorZ { + CResult_GossipTimestampFilterDecodeErrorZ { + contents: CResult_GossipTimestampFilterDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_BlindedPathNoneZ_is_ok(o: &CResult_BlindedPathNoneZ) -> bool { +pub extern "C" fn CResult_GossipTimestampFilterDecodeErrorZ_is_ok(o: &CResult_GossipTimestampFilterDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_BlindedPathNoneZ. -pub extern "C" fn CResult_BlindedPathNoneZ_free(_res: CResult_BlindedPathNoneZ) { } -impl Drop for CResult_BlindedPathNoneZ { +/// Frees any resources used by the CResult_GossipTimestampFilterDecodeErrorZ. +pub extern "C" fn CResult_GossipTimestampFilterDecodeErrorZ_free(_res: CResult_GossipTimestampFilterDecodeErrorZ) { } +impl Drop for CResult_GossipTimestampFilterDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } } } } -impl From> for CResult_BlindedPathNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_GossipTimestampFilterDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_BlindedPathNoneZPtr { result } + CResult_GossipTimestampFilterDecodeErrorZPtr { result } } else { - let _ = unsafe { Box::from_raw(o.contents.err) }; - o.contents.err = core::ptr::null_mut(); - CResult_BlindedPathNoneZPtr { err: core::ptr::null_mut() } + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_GossipTimestampFilterDecodeErrorZPtr { err } }; Self { contents, @@ -13052,59 +16423,105 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_BlindedPathNoneZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_GossipTimestampFilterDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_BlindedPathNoneZPtr { - err: core::ptr::null_mut() + Self { result_ok: false, contents: CResult_GossipTimestampFilterDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_BlindedPathNoneZ which has the same data as `orig` +/// Creates a new CResult_GossipTimestampFilterDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_BlindedPathNoneZ_clone(orig: &CResult_BlindedPathNoneZ) -> CResult_BlindedPathNoneZ { Clone::clone(&orig) } +pub extern "C" fn CResult_GossipTimestampFilterDecodeErrorZ_clone(orig: &CResult_GossipTimestampFilterDecodeErrorZ) -> CResult_GossipTimestampFilterDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_BlindedPathDecodeErrorZ -pub union CResult_BlindedPathDecodeErrorZPtr { +/// A dynamically-allocated array of crate::lightning::ln::channelmanager::PhantomRouteHintss of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_PhantomRouteHintsZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::ln::channelmanager::PhantomRouteHints, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_PhantomRouteHintsZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::channelmanager::PhantomRouteHints] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_PhantomRouteHintsZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_PhantomRouteHintsZ_free(_res: CVec_PhantomRouteHintsZ) { } +impl Drop for CVec_PhantomRouteHintsZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_PhantomRouteHintsZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// The contents of CResult_Bolt11InvoiceSignOrCreationErrorZ +pub union CResult_Bolt11InvoiceSignOrCreationErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::blinded_path::BlindedPath, + pub result: *mut crate::lightning_invoice::Bolt11Invoice, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::lightning_invoice::SignOrCreationError, } #[repr(C)] -/// A CResult_BlindedPathDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::blinded_path::BlindedPath on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_Bolt11InvoiceSignOrCreationErrorZ represents the result of a fallible operation, +/// containing a crate::lightning_invoice::Bolt11Invoice on success and a crate::lightning_invoice::SignOrCreationError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_BlindedPathDecodeErrorZ { - /// The contents of this CResult_BlindedPathDecodeErrorZ, accessible via either +pub struct CResult_Bolt11InvoiceSignOrCreationErrorZ { + /// The contents of this CResult_Bolt11InvoiceSignOrCreationErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_BlindedPathDecodeErrorZPtr, - /// Whether this CResult_BlindedPathDecodeErrorZ represents a success state. + pub contents: CResult_Bolt11InvoiceSignOrCreationErrorZPtr, + /// Whether this CResult_Bolt11InvoiceSignOrCreationErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_BlindedPathDecodeErrorZ in the success state. -pub extern "C" fn CResult_BlindedPathDecodeErrorZ_ok(o: crate::lightning::blinded_path::BlindedPath) -> CResult_BlindedPathDecodeErrorZ { - CResult_BlindedPathDecodeErrorZ { - contents: CResult_BlindedPathDecodeErrorZPtr { +/// Creates a new CResult_Bolt11InvoiceSignOrCreationErrorZ in the success state. +pub extern "C" fn CResult_Bolt11InvoiceSignOrCreationErrorZ_ok(o: crate::lightning_invoice::Bolt11Invoice) -> CResult_Bolt11InvoiceSignOrCreationErrorZ { + CResult_Bolt11InvoiceSignOrCreationErrorZ { + contents: CResult_Bolt11InvoiceSignOrCreationErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } -#[no_mangle] -/// Creates a new CResult_BlindedPathDecodeErrorZ in the error state. -pub extern "C" fn CResult_BlindedPathDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_BlindedPathDecodeErrorZ { - CResult_BlindedPathDecodeErrorZ { - contents: CResult_BlindedPathDecodeErrorZPtr { +#[no_mangle] +/// Creates a new CResult_Bolt11InvoiceSignOrCreationErrorZ in the error state. +pub extern "C" fn CResult_Bolt11InvoiceSignOrCreationErrorZ_err(e: crate::lightning_invoice::SignOrCreationError) -> CResult_Bolt11InvoiceSignOrCreationErrorZ { + CResult_Bolt11InvoiceSignOrCreationErrorZ { + contents: CResult_Bolt11InvoiceSignOrCreationErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -13112,13 +16529,13 @@ pub extern "C" fn CResult_BlindedPathDecodeErrorZ_err(e: crate::lightning::ln::m } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_BlindedPathDecodeErrorZ_is_ok(o: &CResult_BlindedPathDecodeErrorZ) -> bool { +pub extern "C" fn CResult_Bolt11InvoiceSignOrCreationErrorZ_is_ok(o: &CResult_Bolt11InvoiceSignOrCreationErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_BlindedPathDecodeErrorZ. -pub extern "C" fn CResult_BlindedPathDecodeErrorZ_free(_res: CResult_BlindedPathDecodeErrorZ) { } -impl Drop for CResult_BlindedPathDecodeErrorZ { +/// Frees any resources used by the CResult_Bolt11InvoiceSignOrCreationErrorZ. +pub extern "C" fn CResult_Bolt11InvoiceSignOrCreationErrorZ_free(_res: CResult_Bolt11InvoiceSignOrCreationErrorZ) { } +impl Drop for CResult_Bolt11InvoiceSignOrCreationErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -13131,16 +16548,16 @@ impl Drop for CResult_BlindedPathDecodeErrorZ { } } } -impl From> for CResult_BlindedPathDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_Bolt11InvoiceSignOrCreationErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_BlindedPathDecodeErrorZPtr { result } + CResult_Bolt11InvoiceSignOrCreationErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_BlindedPathDecodeErrorZPtr { err } + CResult_Bolt11InvoiceSignOrCreationErrorZPtr { err } }; Self { contents, @@ -13148,59 +16565,105 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_BlindedPathDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_Bolt11InvoiceSignOrCreationErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_BlindedPathDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_Bolt11InvoiceSignOrCreationErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_BlindedPathDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_Bolt11InvoiceSignOrCreationErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_BlindedPathDecodeErrorZ_clone(orig: &CResult_BlindedPathDecodeErrorZ) -> CResult_BlindedPathDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_Bolt11InvoiceSignOrCreationErrorZ_clone(orig: &CResult_Bolt11InvoiceSignOrCreationErrorZ) -> CResult_Bolt11InvoiceSignOrCreationErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_BlindedHopDecodeErrorZ -pub union CResult_BlindedHopDecodeErrorZPtr { +/// A dynamically-allocated array of crate::lightning::util::wakers::Futures of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_FutureZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::util::wakers::Future, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_FutureZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::util::wakers::Future] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_FutureZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_FutureZ_free(_res: CVec_FutureZ) { } +impl Drop for CVec_FutureZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_FutureZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// The contents of CResult_OffersMessageDecodeErrorZ +pub union CResult_OffersMessageDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::blinded_path::BlindedHop, + pub result: *mut crate::lightning::onion_message::offers::OffersMessage, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_BlindedHopDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::blinded_path::BlindedHop on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_OffersMessageDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::onion_message::offers::OffersMessage on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_BlindedHopDecodeErrorZ { - /// The contents of this CResult_BlindedHopDecodeErrorZ, accessible via either +pub struct CResult_OffersMessageDecodeErrorZ { + /// The contents of this CResult_OffersMessageDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_BlindedHopDecodeErrorZPtr, - /// Whether this CResult_BlindedHopDecodeErrorZ represents a success state. + pub contents: CResult_OffersMessageDecodeErrorZPtr, + /// Whether this CResult_OffersMessageDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_BlindedHopDecodeErrorZ in the success state. -pub extern "C" fn CResult_BlindedHopDecodeErrorZ_ok(o: crate::lightning::blinded_path::BlindedHop) -> CResult_BlindedHopDecodeErrorZ { - CResult_BlindedHopDecodeErrorZ { - contents: CResult_BlindedHopDecodeErrorZPtr { +/// Creates a new CResult_OffersMessageDecodeErrorZ in the success state. +pub extern "C" fn CResult_OffersMessageDecodeErrorZ_ok(o: crate::lightning::onion_message::offers::OffersMessage) -> CResult_OffersMessageDecodeErrorZ { + CResult_OffersMessageDecodeErrorZ { + contents: CResult_OffersMessageDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_BlindedHopDecodeErrorZ in the error state. -pub extern "C" fn CResult_BlindedHopDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_BlindedHopDecodeErrorZ { - CResult_BlindedHopDecodeErrorZ { - contents: CResult_BlindedHopDecodeErrorZPtr { +/// Creates a new CResult_OffersMessageDecodeErrorZ in the error state. +pub extern "C" fn CResult_OffersMessageDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_OffersMessageDecodeErrorZ { + CResult_OffersMessageDecodeErrorZ { + contents: CResult_OffersMessageDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -13208,13 +16671,13 @@ pub extern "C" fn CResult_BlindedHopDecodeErrorZ_err(e: crate::lightning::ln::ms } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_BlindedHopDecodeErrorZ_is_ok(o: &CResult_BlindedHopDecodeErrorZ) -> bool { +pub extern "C" fn CResult_OffersMessageDecodeErrorZ_is_ok(o: &CResult_OffersMessageDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_BlindedHopDecodeErrorZ. -pub extern "C" fn CResult_BlindedHopDecodeErrorZ_free(_res: CResult_BlindedHopDecodeErrorZ) { } -impl Drop for CResult_BlindedHopDecodeErrorZ { +/// Frees any resources used by the CResult_OffersMessageDecodeErrorZ. +pub extern "C" fn CResult_OffersMessageDecodeErrorZ_free(_res: CResult_OffersMessageDecodeErrorZ) { } +impl Drop for CResult_OffersMessageDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -13227,16 +16690,16 @@ impl Drop for CResult_BlindedHopDecodeErrorZ { } } } -impl From> for CResult_BlindedHopDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_OffersMessageDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_BlindedHopDecodeErrorZPtr { result } + CResult_OffersMessageDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_BlindedHopDecodeErrorZPtr { err } + CResult_OffersMessageDecodeErrorZPtr { err } }; Self { contents, @@ -13244,59 +16707,91 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_BlindedHopDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_OffersMessageDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_BlindedHopDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_OffersMessageDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_BlindedHopDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_OffersMessageDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_BlindedHopDecodeErrorZ_clone(orig: &CResult_BlindedHopDecodeErrorZ) -> CResult_BlindedHopDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_OffersMessageDecodeErrorZ_clone(orig: &CResult_OffersMessageDecodeErrorZ) -> CResult_OffersMessageDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// An enum which can either contain a crate::lightning::ln::chan_utils::HTLCClaim or not +pub enum COption_HTLCClaimZ { + /// When we're in this state, this COption_HTLCClaimZ contains a crate::lightning::ln::chan_utils::HTLCClaim + Some(crate::lightning::ln::chan_utils::HTLCClaim), + /// When we're in this state, this COption_HTLCClaimZ contains nothing + None +} +impl COption_HTLCClaimZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::ln::chan_utils::HTLCClaim { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_HTLCClaimZ containing a crate::lightning::ln::chan_utils::HTLCClaim +pub extern "C" fn COption_HTLCClaimZ_some(o: crate::lightning::ln::chan_utils::HTLCClaim) -> COption_HTLCClaimZ { + COption_HTLCClaimZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_HTLCClaimZ containing nothing +pub extern "C" fn COption_HTLCClaimZ_none() -> COption_HTLCClaimZ { + COption_HTLCClaimZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::lightning::ln::chan_utils::HTLCClaim, if we are in the Some state +pub extern "C" fn COption_HTLCClaimZ_free(_res: COption_HTLCClaimZ) { } #[repr(C)] -/// The contents of CResult_SiPrefixParseErrorZ -pub union CResult_SiPrefixParseErrorZPtr { +/// The contents of CResult_CounterpartyCommitmentSecretsDecodeErrorZ +pub union CResult_CounterpartyCommitmentSecretsDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning_invoice::SiPrefix, + pub result: *mut crate::lightning::ln::chan_utils::CounterpartyCommitmentSecrets, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning_invoice::ParseError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_SiPrefixParseErrorZ represents the result of a fallible operation, -/// containing a crate::lightning_invoice::SiPrefix on success and a crate::lightning_invoice::ParseError on failure. +/// A CResult_CounterpartyCommitmentSecretsDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::chan_utils::CounterpartyCommitmentSecrets on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_SiPrefixParseErrorZ { - /// The contents of this CResult_SiPrefixParseErrorZ, accessible via either +pub struct CResult_CounterpartyCommitmentSecretsDecodeErrorZ { + /// The contents of this CResult_CounterpartyCommitmentSecretsDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_SiPrefixParseErrorZPtr, - /// Whether this CResult_SiPrefixParseErrorZ represents a success state. + pub contents: CResult_CounterpartyCommitmentSecretsDecodeErrorZPtr, + /// Whether this CResult_CounterpartyCommitmentSecretsDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_SiPrefixParseErrorZ in the success state. -pub extern "C" fn CResult_SiPrefixParseErrorZ_ok(o: crate::lightning_invoice::SiPrefix) -> CResult_SiPrefixParseErrorZ { - CResult_SiPrefixParseErrorZ { - contents: CResult_SiPrefixParseErrorZPtr { +/// Creates a new CResult_CounterpartyCommitmentSecretsDecodeErrorZ in the success state. +pub extern "C" fn CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok(o: crate::lightning::ln::chan_utils::CounterpartyCommitmentSecrets) -> CResult_CounterpartyCommitmentSecretsDecodeErrorZ { + CResult_CounterpartyCommitmentSecretsDecodeErrorZ { + contents: CResult_CounterpartyCommitmentSecretsDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_SiPrefixParseErrorZ in the error state. -pub extern "C" fn CResult_SiPrefixParseErrorZ_err(e: crate::lightning_invoice::ParseError) -> CResult_SiPrefixParseErrorZ { - CResult_SiPrefixParseErrorZ { - contents: CResult_SiPrefixParseErrorZPtr { +/// Creates a new CResult_CounterpartyCommitmentSecretsDecodeErrorZ in the error state. +pub extern "C" fn CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_CounterpartyCommitmentSecretsDecodeErrorZ { + CResult_CounterpartyCommitmentSecretsDecodeErrorZ { + contents: CResult_CounterpartyCommitmentSecretsDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -13304,13 +16799,13 @@ pub extern "C" fn CResult_SiPrefixParseErrorZ_err(e: crate::lightning_invoice::P } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_SiPrefixParseErrorZ_is_ok(o: &CResult_SiPrefixParseErrorZ) -> bool { +pub extern "C" fn CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok(o: &CResult_CounterpartyCommitmentSecretsDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_SiPrefixParseErrorZ. -pub extern "C" fn CResult_SiPrefixParseErrorZ_free(_res: CResult_SiPrefixParseErrorZ) { } -impl Drop for CResult_SiPrefixParseErrorZ { +/// Frees any resources used by the CResult_CounterpartyCommitmentSecretsDecodeErrorZ. +pub extern "C" fn CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free(_res: CResult_CounterpartyCommitmentSecretsDecodeErrorZ) { } +impl Drop for CResult_CounterpartyCommitmentSecretsDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -13323,16 +16818,16 @@ impl Drop for CResult_SiPrefixParseErrorZ { } } } -impl From> for CResult_SiPrefixParseErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_CounterpartyCommitmentSecretsDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_SiPrefixParseErrorZPtr { result } + CResult_CounterpartyCommitmentSecretsDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_SiPrefixParseErrorZPtr { err } + CResult_CounterpartyCommitmentSecretsDecodeErrorZPtr { err } }; Self { contents, @@ -13340,59 +16835,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_SiPrefixParseErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_CounterpartyCommitmentSecretsDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_SiPrefixParseErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_CounterpartyCommitmentSecretsDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_SiPrefixParseErrorZ which has the same data as `orig` +/// Creates a new CResult_CounterpartyCommitmentSecretsDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_SiPrefixParseErrorZ_clone(orig: &CResult_SiPrefixParseErrorZ) -> CResult_SiPrefixParseErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(orig: &CResult_CounterpartyCommitmentSecretsDecodeErrorZ) -> CResult_CounterpartyCommitmentSecretsDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_InvoiceParseOrSemanticErrorZ -pub union CResult_InvoiceParseOrSemanticErrorZPtr { +/// The contents of CResult_TxCreationKeysDecodeErrorZ +pub union CResult_TxCreationKeysDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning_invoice::Invoice, + pub result: *mut crate::lightning::ln::chan_utils::TxCreationKeys, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning_invoice::ParseOrSemanticError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_InvoiceParseOrSemanticErrorZ represents the result of a fallible operation, -/// containing a crate::lightning_invoice::Invoice on success and a crate::lightning_invoice::ParseOrSemanticError on failure. +/// A CResult_TxCreationKeysDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::chan_utils::TxCreationKeys on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_InvoiceParseOrSemanticErrorZ { - /// The contents of this CResult_InvoiceParseOrSemanticErrorZ, accessible via either +pub struct CResult_TxCreationKeysDecodeErrorZ { + /// The contents of this CResult_TxCreationKeysDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_InvoiceParseOrSemanticErrorZPtr, - /// Whether this CResult_InvoiceParseOrSemanticErrorZ represents a success state. + pub contents: CResult_TxCreationKeysDecodeErrorZPtr, + /// Whether this CResult_TxCreationKeysDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_InvoiceParseOrSemanticErrorZ in the success state. -pub extern "C" fn CResult_InvoiceParseOrSemanticErrorZ_ok(o: crate::lightning_invoice::Invoice) -> CResult_InvoiceParseOrSemanticErrorZ { - CResult_InvoiceParseOrSemanticErrorZ { - contents: CResult_InvoiceParseOrSemanticErrorZPtr { +/// Creates a new CResult_TxCreationKeysDecodeErrorZ in the success state. +pub extern "C" fn CResult_TxCreationKeysDecodeErrorZ_ok(o: crate::lightning::ln::chan_utils::TxCreationKeys) -> CResult_TxCreationKeysDecodeErrorZ { + CResult_TxCreationKeysDecodeErrorZ { + contents: CResult_TxCreationKeysDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_InvoiceParseOrSemanticErrorZ in the error state. -pub extern "C" fn CResult_InvoiceParseOrSemanticErrorZ_err(e: crate::lightning_invoice::ParseOrSemanticError) -> CResult_InvoiceParseOrSemanticErrorZ { - CResult_InvoiceParseOrSemanticErrorZ { - contents: CResult_InvoiceParseOrSemanticErrorZPtr { +/// Creates a new CResult_TxCreationKeysDecodeErrorZ in the error state. +pub extern "C" fn CResult_TxCreationKeysDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_TxCreationKeysDecodeErrorZ { + CResult_TxCreationKeysDecodeErrorZ { + contents: CResult_TxCreationKeysDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -13400,13 +16895,13 @@ pub extern "C" fn CResult_InvoiceParseOrSemanticErrorZ_err(e: crate::lightning_i } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_InvoiceParseOrSemanticErrorZ_is_ok(o: &CResult_InvoiceParseOrSemanticErrorZ) -> bool { +pub extern "C" fn CResult_TxCreationKeysDecodeErrorZ_is_ok(o: &CResult_TxCreationKeysDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_InvoiceParseOrSemanticErrorZ. -pub extern "C" fn CResult_InvoiceParseOrSemanticErrorZ_free(_res: CResult_InvoiceParseOrSemanticErrorZ) { } -impl Drop for CResult_InvoiceParseOrSemanticErrorZ { +/// Frees any resources used by the CResult_TxCreationKeysDecodeErrorZ. +pub extern "C" fn CResult_TxCreationKeysDecodeErrorZ_free(_res: CResult_TxCreationKeysDecodeErrorZ) { } +impl Drop for CResult_TxCreationKeysDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -13419,16 +16914,16 @@ impl Drop for CResult_InvoiceParseOrSemanticErrorZ { } } } -impl From> for CResult_InvoiceParseOrSemanticErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_TxCreationKeysDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_InvoiceParseOrSemanticErrorZPtr { result } + CResult_TxCreationKeysDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_InvoiceParseOrSemanticErrorZPtr { err } + CResult_TxCreationKeysDecodeErrorZPtr { err } }; Self { contents, @@ -13436,59 +16931,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_InvoiceParseOrSemanticErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_TxCreationKeysDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_InvoiceParseOrSemanticErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_TxCreationKeysDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_InvoiceParseOrSemanticErrorZ which has the same data as `orig` +/// Creates a new CResult_TxCreationKeysDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_InvoiceParseOrSemanticErrorZ_clone(orig: &CResult_InvoiceParseOrSemanticErrorZ) -> CResult_InvoiceParseOrSemanticErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_TxCreationKeysDecodeErrorZ_clone(orig: &CResult_TxCreationKeysDecodeErrorZ) -> CResult_TxCreationKeysDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_SignedRawInvoiceParseErrorZ -pub union CResult_SignedRawInvoiceParseErrorZPtr { +/// The contents of CResult_ChannelPublicKeysDecodeErrorZ +pub union CResult_ChannelPublicKeysDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning_invoice::SignedRawInvoice, + pub result: *mut crate::lightning::ln::chan_utils::ChannelPublicKeys, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning_invoice::ParseError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_SignedRawInvoiceParseErrorZ represents the result of a fallible operation, -/// containing a crate::lightning_invoice::SignedRawInvoice on success and a crate::lightning_invoice::ParseError on failure. +/// A CResult_ChannelPublicKeysDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::chan_utils::ChannelPublicKeys on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_SignedRawInvoiceParseErrorZ { - /// The contents of this CResult_SignedRawInvoiceParseErrorZ, accessible via either +pub struct CResult_ChannelPublicKeysDecodeErrorZ { + /// The contents of this CResult_ChannelPublicKeysDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_SignedRawInvoiceParseErrorZPtr, - /// Whether this CResult_SignedRawInvoiceParseErrorZ represents a success state. + pub contents: CResult_ChannelPublicKeysDecodeErrorZPtr, + /// Whether this CResult_ChannelPublicKeysDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_SignedRawInvoiceParseErrorZ in the success state. -pub extern "C" fn CResult_SignedRawInvoiceParseErrorZ_ok(o: crate::lightning_invoice::SignedRawInvoice) -> CResult_SignedRawInvoiceParseErrorZ { - CResult_SignedRawInvoiceParseErrorZ { - contents: CResult_SignedRawInvoiceParseErrorZPtr { +/// Creates a new CResult_ChannelPublicKeysDecodeErrorZ in the success state. +pub extern "C" fn CResult_ChannelPublicKeysDecodeErrorZ_ok(o: crate::lightning::ln::chan_utils::ChannelPublicKeys) -> CResult_ChannelPublicKeysDecodeErrorZ { + CResult_ChannelPublicKeysDecodeErrorZ { + contents: CResult_ChannelPublicKeysDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_SignedRawInvoiceParseErrorZ in the error state. -pub extern "C" fn CResult_SignedRawInvoiceParseErrorZ_err(e: crate::lightning_invoice::ParseError) -> CResult_SignedRawInvoiceParseErrorZ { - CResult_SignedRawInvoiceParseErrorZ { - contents: CResult_SignedRawInvoiceParseErrorZPtr { +/// Creates a new CResult_ChannelPublicKeysDecodeErrorZ in the error state. +pub extern "C" fn CResult_ChannelPublicKeysDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelPublicKeysDecodeErrorZ { + CResult_ChannelPublicKeysDecodeErrorZ { + contents: CResult_ChannelPublicKeysDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -13496,13 +16991,13 @@ pub extern "C" fn CResult_SignedRawInvoiceParseErrorZ_err(e: crate::lightning_in } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_SignedRawInvoiceParseErrorZ_is_ok(o: &CResult_SignedRawInvoiceParseErrorZ) -> bool { +pub extern "C" fn CResult_ChannelPublicKeysDecodeErrorZ_is_ok(o: &CResult_ChannelPublicKeysDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_SignedRawInvoiceParseErrorZ. -pub extern "C" fn CResult_SignedRawInvoiceParseErrorZ_free(_res: CResult_SignedRawInvoiceParseErrorZ) { } -impl Drop for CResult_SignedRawInvoiceParseErrorZ { +/// Frees any resources used by the CResult_ChannelPublicKeysDecodeErrorZ. +pub extern "C" fn CResult_ChannelPublicKeysDecodeErrorZ_free(_res: CResult_ChannelPublicKeysDecodeErrorZ) { } +impl Drop for CResult_ChannelPublicKeysDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -13511,126 +17006,80 @@ impl Drop for CResult_SignedRawInvoiceParseErrorZ { } else { if unsafe { !(self.contents.err as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.err) }; - } - } - } -} -impl From> for CResult_SignedRawInvoiceParseErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { - let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_SignedRawInvoiceParseErrorZPtr { result } - } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_SignedRawInvoiceParseErrorZPtr { err } - }; - Self { - contents, - result_ok: o.result_ok, - } - } -} -impl Clone for CResult_SignedRawInvoiceParseErrorZ { - fn clone(&self) -> Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_SignedRawInvoiceParseErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_SignedRawInvoiceParseErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } - } - } -} -#[no_mangle] -/// Creates a new CResult_SignedRawInvoiceParseErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_SignedRawInvoiceParseErrorZ_clone(orig: &CResult_SignedRawInvoiceParseErrorZ) -> CResult_SignedRawInvoiceParseErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// A tuple of 3 elements. See the individual fields for the types contained. -pub struct C3Tuple_RawInvoice_u832InvoiceSignatureZ { - /// The element at position 0 - pub a: crate::lightning_invoice::RawInvoice, - /// The element at position 1 - pub b: crate::c_types::ThirtyTwoBytes, - /// The element at position 2 - pub c: crate::lightning_invoice::InvoiceSignature, -} -impl From<(crate::lightning_invoice::RawInvoice, crate::c_types::ThirtyTwoBytes, crate::lightning_invoice::InvoiceSignature)> for C3Tuple_RawInvoice_u832InvoiceSignatureZ { - fn from (tup: (crate::lightning_invoice::RawInvoice, crate::c_types::ThirtyTwoBytes, crate::lightning_invoice::InvoiceSignature)) -> Self { - Self { - a: tup.0, - b: tup.1, - c: tup.2, + } } } } -impl C3Tuple_RawInvoice_u832InvoiceSignatureZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::lightning_invoice::RawInvoice, crate::c_types::ThirtyTwoBytes, crate::lightning_invoice::InvoiceSignature) { - (self.a, self.b, self.c) +impl From> for CResult_ChannelPublicKeysDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_ChannelPublicKeysDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_ChannelPublicKeysDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } } } -impl Clone for C3Tuple_RawInvoice_u832InvoiceSignatureZ { +impl Clone for CResult_ChannelPublicKeysDecodeErrorZ { fn clone(&self) -> Self { - Self { - a: Clone::clone(&self.a), - b: Clone::clone(&self.b), - c: Clone::clone(&self.c), + if self.result_ok { + Self { result_ok: true, contents: CResult_ChannelPublicKeysDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_ChannelPublicKeysDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } } } } #[no_mangle] -/// Creates a new tuple which has the same data as `orig` +/// Creates a new CResult_ChannelPublicKeysDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig: &C3Tuple_RawInvoice_u832InvoiceSignatureZ) -> C3Tuple_RawInvoice_u832InvoiceSignatureZ { Clone::clone(&orig) } -/// Creates a new C3Tuple_RawInvoice_u832InvoiceSignatureZ from the contained elements. -#[no_mangle] -pub extern "C" fn C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a: crate::lightning_invoice::RawInvoice, b: crate::c_types::ThirtyTwoBytes, c: crate::lightning_invoice::InvoiceSignature) -> C3Tuple_RawInvoice_u832InvoiceSignatureZ { - C3Tuple_RawInvoice_u832InvoiceSignatureZ { a, b, c, } -} - -#[no_mangle] -/// Frees any resources used by the C3Tuple_RawInvoice_u832InvoiceSignatureZ. -pub extern "C" fn C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res: C3Tuple_RawInvoice_u832InvoiceSignatureZ) { } +pub extern "C" fn CResult_ChannelPublicKeysDecodeErrorZ_clone(orig: &CResult_ChannelPublicKeysDecodeErrorZ) -> CResult_ChannelPublicKeysDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_PayeePubKeyErrorZ -pub union CResult_PayeePubKeyErrorZPtr { +/// The contents of CResult_HTLCOutputInCommitmentDecodeErrorZ +pub union CResult_HTLCOutputInCommitmentDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning_invoice::PayeePubKey, + pub result: *mut crate::lightning::ln::chan_utils::HTLCOutputInCommitment, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::c_types::Secp256k1Error, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_PayeePubKeyErrorZ represents the result of a fallible operation, -/// containing a crate::lightning_invoice::PayeePubKey on success and a crate::c_types::Secp256k1Error on failure. +/// A CResult_HTLCOutputInCommitmentDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::chan_utils::HTLCOutputInCommitment on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_PayeePubKeyErrorZ { - /// The contents of this CResult_PayeePubKeyErrorZ, accessible via either +pub struct CResult_HTLCOutputInCommitmentDecodeErrorZ { + /// The contents of this CResult_HTLCOutputInCommitmentDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_PayeePubKeyErrorZPtr, - /// Whether this CResult_PayeePubKeyErrorZ represents a success state. + pub contents: CResult_HTLCOutputInCommitmentDecodeErrorZPtr, + /// Whether this CResult_HTLCOutputInCommitmentDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_PayeePubKeyErrorZ in the success state. -pub extern "C" fn CResult_PayeePubKeyErrorZ_ok(o: crate::lightning_invoice::PayeePubKey) -> CResult_PayeePubKeyErrorZ { - CResult_PayeePubKeyErrorZ { - contents: CResult_PayeePubKeyErrorZPtr { +/// Creates a new CResult_HTLCOutputInCommitmentDecodeErrorZ in the success state. +pub extern "C" fn CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o: crate::lightning::ln::chan_utils::HTLCOutputInCommitment) -> CResult_HTLCOutputInCommitmentDecodeErrorZ { + CResult_HTLCOutputInCommitmentDecodeErrorZ { + contents: CResult_HTLCOutputInCommitmentDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_PayeePubKeyErrorZ in the error state. -pub extern "C" fn CResult_PayeePubKeyErrorZ_err(e: crate::c_types::Secp256k1Error) -> CResult_PayeePubKeyErrorZ { - CResult_PayeePubKeyErrorZ { - contents: CResult_PayeePubKeyErrorZPtr { +/// Creates a new CResult_HTLCOutputInCommitmentDecodeErrorZ in the error state. +pub extern "C" fn CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_HTLCOutputInCommitmentDecodeErrorZ { + CResult_HTLCOutputInCommitmentDecodeErrorZ { + contents: CResult_HTLCOutputInCommitmentDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -13638,13 +17087,13 @@ pub extern "C" fn CResult_PayeePubKeyErrorZ_err(e: crate::c_types::Secp256k1Erro } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_PayeePubKeyErrorZ_is_ok(o: &CResult_PayeePubKeyErrorZ) -> bool { +pub extern "C" fn CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(o: &CResult_HTLCOutputInCommitmentDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_PayeePubKeyErrorZ. -pub extern "C" fn CResult_PayeePubKeyErrorZ_free(_res: CResult_PayeePubKeyErrorZ) { } -impl Drop for CResult_PayeePubKeyErrorZ { +/// Frees any resources used by the CResult_HTLCOutputInCommitmentDecodeErrorZ. +pub extern "C" fn CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res: CResult_HTLCOutputInCommitmentDecodeErrorZ) { } +impl Drop for CResult_HTLCOutputInCommitmentDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -13657,16 +17106,16 @@ impl Drop for CResult_PayeePubKeyErrorZ { } } } -impl From> for CResult_PayeePubKeyErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_HTLCOutputInCommitmentDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_PayeePubKeyErrorZPtr { result } + CResult_HTLCOutputInCommitmentDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_PayeePubKeyErrorZPtr { err } + CResult_HTLCOutputInCommitmentDecodeErrorZPtr { err } }; Self { contents, @@ -13674,105 +17123,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_PayeePubKeyErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_HTLCOutputInCommitmentDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_PayeePubKeyErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_HTLCOutputInCommitmentDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_PayeePubKeyErrorZ which has the same data as `orig` +/// Creates a new CResult_HTLCOutputInCommitmentDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_PayeePubKeyErrorZ_clone(orig: &CResult_PayeePubKeyErrorZ) -> CResult_PayeePubKeyErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// A dynamically-allocated array of crate::lightning_invoice::PrivateRoutes of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_PrivateRouteZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning_invoice::PrivateRoute, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_PrivateRouteZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning_invoice::PrivateRoute] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_PrivateRouteZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_PrivateRouteZ_free(_res: CVec_PrivateRouteZ) { } -impl Drop for CVec_PrivateRouteZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_PrivateRouteZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} +pub extern "C" fn CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig: &CResult_HTLCOutputInCommitmentDecodeErrorZ) -> CResult_HTLCOutputInCommitmentDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_PositiveTimestampCreationErrorZ -pub union CResult_PositiveTimestampCreationErrorZPtr { +/// The contents of CResult_CounterpartyChannelTransactionParametersDecodeErrorZ +pub union CResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning_invoice::PositiveTimestamp, + pub result: *mut crate::lightning::ln::chan_utils::CounterpartyChannelTransactionParameters, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning_invoice::CreationError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_PositiveTimestampCreationErrorZ represents the result of a fallible operation, -/// containing a crate::lightning_invoice::PositiveTimestamp on success and a crate::lightning_invoice::CreationError on failure. +/// A CResult_CounterpartyChannelTransactionParametersDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::chan_utils::CounterpartyChannelTransactionParameters on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_PositiveTimestampCreationErrorZ { - /// The contents of this CResult_PositiveTimestampCreationErrorZ, accessible via either +pub struct CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { + /// The contents of this CResult_CounterpartyChannelTransactionParametersDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_PositiveTimestampCreationErrorZPtr, - /// Whether this CResult_PositiveTimestampCreationErrorZ represents a success state. + pub contents: CResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr, + /// Whether this CResult_CounterpartyChannelTransactionParametersDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_PositiveTimestampCreationErrorZ in the success state. -pub extern "C" fn CResult_PositiveTimestampCreationErrorZ_ok(o: crate::lightning_invoice::PositiveTimestamp) -> CResult_PositiveTimestampCreationErrorZ { - CResult_PositiveTimestampCreationErrorZ { - contents: CResult_PositiveTimestampCreationErrorZPtr { +/// Creates a new CResult_CounterpartyChannelTransactionParametersDecodeErrorZ in the success state. +pub extern "C" fn CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o: crate::lightning::ln::chan_utils::CounterpartyChannelTransactionParameters) -> CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { + CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { + contents: CResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_PositiveTimestampCreationErrorZ in the error state. -pub extern "C" fn CResult_PositiveTimestampCreationErrorZ_err(e: crate::lightning_invoice::CreationError) -> CResult_PositiveTimestampCreationErrorZ { - CResult_PositiveTimestampCreationErrorZ { - contents: CResult_PositiveTimestampCreationErrorZPtr { +/// Creates a new CResult_CounterpartyChannelTransactionParametersDecodeErrorZ in the error state. +pub extern "C" fn CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { + CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { + contents: CResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -13780,13 +17183,13 @@ pub extern "C" fn CResult_PositiveTimestampCreationErrorZ_err(e: crate::lightnin } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_PositiveTimestampCreationErrorZ_is_ok(o: &CResult_PositiveTimestampCreationErrorZ) -> bool { +pub extern "C" fn CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(o: &CResult_CounterpartyChannelTransactionParametersDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_PositiveTimestampCreationErrorZ. -pub extern "C" fn CResult_PositiveTimestampCreationErrorZ_free(_res: CResult_PositiveTimestampCreationErrorZ) { } -impl Drop for CResult_PositiveTimestampCreationErrorZ { +/// Frees any resources used by the CResult_CounterpartyChannelTransactionParametersDecodeErrorZ. +pub extern "C" fn CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res: CResult_CounterpartyChannelTransactionParametersDecodeErrorZ) { } +impl Drop for CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -13799,16 +17202,16 @@ impl Drop for CResult_PositiveTimestampCreationErrorZ { } } } -impl From> for CResult_PositiveTimestampCreationErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_PositiveTimestampCreationErrorZPtr { result } + CResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_PositiveTimestampCreationErrorZPtr { err } + CResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr { err } }; Self { contents, @@ -13816,58 +17219,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_PositiveTimestampCreationErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_PositiveTimestampCreationErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_PositiveTimestampCreationErrorZ which has the same data as `orig` +/// Creates a new CResult_CounterpartyChannelTransactionParametersDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_PositiveTimestampCreationErrorZ_clone(orig: &CResult_PositiveTimestampCreationErrorZ) -> CResult_PositiveTimestampCreationErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig: &CResult_CounterpartyChannelTransactionParametersDecodeErrorZ) -> CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_NoneSemanticErrorZ -pub union CResult_NoneSemanticErrorZPtr { - /// Note that this value is always NULL, as there are no contents in the OK variant - pub result: *mut core::ffi::c_void, +/// The contents of CResult_ChannelTransactionParametersDecodeErrorZ +pub union CResult_ChannelTransactionParametersDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::chan_utils::ChannelTransactionParameters, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning_invoice::SemanticError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_NoneSemanticErrorZ represents the result of a fallible operation, -/// containing a () on success and a crate::lightning_invoice::SemanticError on failure. +/// A CResult_ChannelTransactionParametersDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::chan_utils::ChannelTransactionParameters on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_NoneSemanticErrorZ { - /// The contents of this CResult_NoneSemanticErrorZ, accessible via either +pub struct CResult_ChannelTransactionParametersDecodeErrorZ { + /// The contents of this CResult_ChannelTransactionParametersDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_NoneSemanticErrorZPtr, - /// Whether this CResult_NoneSemanticErrorZ represents a success state. + pub contents: CResult_ChannelTransactionParametersDecodeErrorZPtr, + /// Whether this CResult_ChannelTransactionParametersDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_NoneSemanticErrorZ in the success state. -pub extern "C" fn CResult_NoneSemanticErrorZ_ok() -> CResult_NoneSemanticErrorZ { - CResult_NoneSemanticErrorZ { - contents: CResult_NoneSemanticErrorZPtr { - result: core::ptr::null_mut(), +/// Creates a new CResult_ChannelTransactionParametersDecodeErrorZ in the success state. +pub extern "C" fn CResult_ChannelTransactionParametersDecodeErrorZ_ok(o: crate::lightning::ln::chan_utils::ChannelTransactionParameters) -> CResult_ChannelTransactionParametersDecodeErrorZ { + CResult_ChannelTransactionParametersDecodeErrorZ { + contents: CResult_ChannelTransactionParametersDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_NoneSemanticErrorZ in the error state. -pub extern "C" fn CResult_NoneSemanticErrorZ_err(e: crate::lightning_invoice::SemanticError) -> CResult_NoneSemanticErrorZ { - CResult_NoneSemanticErrorZ { - contents: CResult_NoneSemanticErrorZPtr { +/// Creates a new CResult_ChannelTransactionParametersDecodeErrorZ in the error state. +pub extern "C" fn CResult_ChannelTransactionParametersDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelTransactionParametersDecodeErrorZ { + CResult_ChannelTransactionParametersDecodeErrorZ { + contents: CResult_ChannelTransactionParametersDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -13875,15 +17279,18 @@ pub extern "C" fn CResult_NoneSemanticErrorZ_err(e: crate::lightning_invoice::Se } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_NoneSemanticErrorZ_is_ok(o: &CResult_NoneSemanticErrorZ) -> bool { +pub extern "C" fn CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(o: &CResult_ChannelTransactionParametersDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_NoneSemanticErrorZ. -pub extern "C" fn CResult_NoneSemanticErrorZ_free(_res: CResult_NoneSemanticErrorZ) { } -impl Drop for CResult_NoneSemanticErrorZ { +/// Frees any resources used by the CResult_ChannelTransactionParametersDecodeErrorZ. +pub extern "C" fn CResult_ChannelTransactionParametersDecodeErrorZ_free(_res: CResult_ChannelTransactionParametersDecodeErrorZ) { } +impl Drop for CResult_ChannelTransactionParametersDecodeErrorZ { fn drop(&mut self) { if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } } else { if unsafe { !(self.contents.err as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.err) }; @@ -13891,16 +17298,16 @@ impl Drop for CResult_NoneSemanticErrorZ { } } } -impl From> for CResult_NoneSemanticErrorZ { - fn from(mut o: crate::c_types::CResultTempl<(), crate::lightning_invoice::SemanticError>) -> Self { +impl From> for CResult_ChannelTransactionParametersDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { - let _ = unsafe { Box::from_raw(o.contents.result) }; - o.contents.result = core::ptr::null_mut(); - CResult_NoneSemanticErrorZPtr { result: core::ptr::null_mut() } + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_ChannelTransactionParametersDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_NoneSemanticErrorZPtr { err } + CResult_ChannelTransactionParametersDecodeErrorZPtr { err } }; Self { contents, @@ -13908,59 +17315,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_NoneSemanticErrorZPtr { - result: core::ptr::null_mut() + Self { result_ok: true, contents: CResult_ChannelTransactionParametersDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_NoneSemanticErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_ChannelTransactionParametersDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_NoneSemanticErrorZ which has the same data as `orig` +/// Creates a new CResult_ChannelTransactionParametersDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_NoneSemanticErrorZ_clone(orig: &CResult_NoneSemanticErrorZ) -> CResult_NoneSemanticErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig: &CResult_ChannelTransactionParametersDecodeErrorZ) -> CResult_ChannelTransactionParametersDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_InvoiceSemanticErrorZ -pub union CResult_InvoiceSemanticErrorZPtr { +/// The contents of CResult_HolderCommitmentTransactionDecodeErrorZ +pub union CResult_HolderCommitmentTransactionDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning_invoice::Invoice, + pub result: *mut crate::lightning::ln::chan_utils::HolderCommitmentTransaction, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning_invoice::SemanticError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_InvoiceSemanticErrorZ represents the result of a fallible operation, -/// containing a crate::lightning_invoice::Invoice on success and a crate::lightning_invoice::SemanticError on failure. +/// A CResult_HolderCommitmentTransactionDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::chan_utils::HolderCommitmentTransaction on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_InvoiceSemanticErrorZ { - /// The contents of this CResult_InvoiceSemanticErrorZ, accessible via either +pub struct CResult_HolderCommitmentTransactionDecodeErrorZ { + /// The contents of this CResult_HolderCommitmentTransactionDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_InvoiceSemanticErrorZPtr, - /// Whether this CResult_InvoiceSemanticErrorZ represents a success state. + pub contents: CResult_HolderCommitmentTransactionDecodeErrorZPtr, + /// Whether this CResult_HolderCommitmentTransactionDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_InvoiceSemanticErrorZ in the success state. -pub extern "C" fn CResult_InvoiceSemanticErrorZ_ok(o: crate::lightning_invoice::Invoice) -> CResult_InvoiceSemanticErrorZ { - CResult_InvoiceSemanticErrorZ { - contents: CResult_InvoiceSemanticErrorZPtr { +/// Creates a new CResult_HolderCommitmentTransactionDecodeErrorZ in the success state. +pub extern "C" fn CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o: crate::lightning::ln::chan_utils::HolderCommitmentTransaction) -> CResult_HolderCommitmentTransactionDecodeErrorZ { + CResult_HolderCommitmentTransactionDecodeErrorZ { + contents: CResult_HolderCommitmentTransactionDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_InvoiceSemanticErrorZ in the error state. -pub extern "C" fn CResult_InvoiceSemanticErrorZ_err(e: crate::lightning_invoice::SemanticError) -> CResult_InvoiceSemanticErrorZ { - CResult_InvoiceSemanticErrorZ { - contents: CResult_InvoiceSemanticErrorZPtr { +/// Creates a new CResult_HolderCommitmentTransactionDecodeErrorZ in the error state. +pub extern "C" fn CResult_HolderCommitmentTransactionDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_HolderCommitmentTransactionDecodeErrorZ { + CResult_HolderCommitmentTransactionDecodeErrorZ { + contents: CResult_HolderCommitmentTransactionDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -13968,13 +17375,13 @@ pub extern "C" fn CResult_InvoiceSemanticErrorZ_err(e: crate::lightning_invoice: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_InvoiceSemanticErrorZ_is_ok(o: &CResult_InvoiceSemanticErrorZ) -> bool { +pub extern "C" fn CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(o: &CResult_HolderCommitmentTransactionDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_InvoiceSemanticErrorZ. -pub extern "C" fn CResult_InvoiceSemanticErrorZ_free(_res: CResult_InvoiceSemanticErrorZ) { } -impl Drop for CResult_InvoiceSemanticErrorZ { +/// Frees any resources used by the CResult_HolderCommitmentTransactionDecodeErrorZ. +pub extern "C" fn CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res: CResult_HolderCommitmentTransactionDecodeErrorZ) { } +impl Drop for CResult_HolderCommitmentTransactionDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -13987,16 +17394,16 @@ impl Drop for CResult_InvoiceSemanticErrorZ { } } } -impl From> for CResult_InvoiceSemanticErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_HolderCommitmentTransactionDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_InvoiceSemanticErrorZPtr { result } + CResult_HolderCommitmentTransactionDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_InvoiceSemanticErrorZPtr { err } + CResult_HolderCommitmentTransactionDecodeErrorZPtr { err } }; Self { contents, @@ -14004,105 +17411,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_InvoiceSemanticErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_HolderCommitmentTransactionDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_InvoiceSemanticErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_HolderCommitmentTransactionDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_InvoiceSemanticErrorZ which has the same data as `orig` +/// Creates a new CResult_HolderCommitmentTransactionDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_InvoiceSemanticErrorZ_clone(orig: &CResult_InvoiceSemanticErrorZ) -> CResult_InvoiceSemanticErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// A dynamically-allocated array of crate::c_types::Strs of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_AddressZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::Str, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_AddressZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::Str] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_AddressZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_AddressZ_free(_res: CVec_AddressZ) { } -impl Drop for CVec_AddressZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_AddressZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} +pub extern "C" fn CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig: &CResult_HolderCommitmentTransactionDecodeErrorZ) -> CResult_HolderCommitmentTransactionDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_DescriptionCreationErrorZ -pub union CResult_DescriptionCreationErrorZPtr { +/// The contents of CResult_BuiltCommitmentTransactionDecodeErrorZ +pub union CResult_BuiltCommitmentTransactionDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning_invoice::Description, + pub result: *mut crate::lightning::ln::chan_utils::BuiltCommitmentTransaction, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning_invoice::CreationError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_DescriptionCreationErrorZ represents the result of a fallible operation, -/// containing a crate::lightning_invoice::Description on success and a crate::lightning_invoice::CreationError on failure. +/// A CResult_BuiltCommitmentTransactionDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::chan_utils::BuiltCommitmentTransaction on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_DescriptionCreationErrorZ { - /// The contents of this CResult_DescriptionCreationErrorZ, accessible via either +pub struct CResult_BuiltCommitmentTransactionDecodeErrorZ { + /// The contents of this CResult_BuiltCommitmentTransactionDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_DescriptionCreationErrorZPtr, - /// Whether this CResult_DescriptionCreationErrorZ represents a success state. + pub contents: CResult_BuiltCommitmentTransactionDecodeErrorZPtr, + /// Whether this CResult_BuiltCommitmentTransactionDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_DescriptionCreationErrorZ in the success state. -pub extern "C" fn CResult_DescriptionCreationErrorZ_ok(o: crate::lightning_invoice::Description) -> CResult_DescriptionCreationErrorZ { - CResult_DescriptionCreationErrorZ { - contents: CResult_DescriptionCreationErrorZPtr { +/// Creates a new CResult_BuiltCommitmentTransactionDecodeErrorZ in the success state. +pub extern "C" fn CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o: crate::lightning::ln::chan_utils::BuiltCommitmentTransaction) -> CResult_BuiltCommitmentTransactionDecodeErrorZ { + CResult_BuiltCommitmentTransactionDecodeErrorZ { + contents: CResult_BuiltCommitmentTransactionDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_DescriptionCreationErrorZ in the error state. -pub extern "C" fn CResult_DescriptionCreationErrorZ_err(e: crate::lightning_invoice::CreationError) -> CResult_DescriptionCreationErrorZ { - CResult_DescriptionCreationErrorZ { - contents: CResult_DescriptionCreationErrorZPtr { +/// Creates a new CResult_BuiltCommitmentTransactionDecodeErrorZ in the error state. +pub extern "C" fn CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_BuiltCommitmentTransactionDecodeErrorZ { + CResult_BuiltCommitmentTransactionDecodeErrorZ { + contents: CResult_BuiltCommitmentTransactionDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -14110,13 +17471,13 @@ pub extern "C" fn CResult_DescriptionCreationErrorZ_err(e: crate::lightning_invo } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_DescriptionCreationErrorZ_is_ok(o: &CResult_DescriptionCreationErrorZ) -> bool { +pub extern "C" fn CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(o: &CResult_BuiltCommitmentTransactionDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_DescriptionCreationErrorZ. -pub extern "C" fn CResult_DescriptionCreationErrorZ_free(_res: CResult_DescriptionCreationErrorZ) { } -impl Drop for CResult_DescriptionCreationErrorZ { +/// Frees any resources used by the CResult_BuiltCommitmentTransactionDecodeErrorZ. +pub extern "C" fn CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res: CResult_BuiltCommitmentTransactionDecodeErrorZ) { } +impl Drop for CResult_BuiltCommitmentTransactionDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -14129,16 +17490,16 @@ impl Drop for CResult_DescriptionCreationErrorZ { } } } -impl From> for CResult_DescriptionCreationErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_BuiltCommitmentTransactionDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_DescriptionCreationErrorZPtr { result } + CResult_BuiltCommitmentTransactionDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_DescriptionCreationErrorZPtr { err } + CResult_BuiltCommitmentTransactionDecodeErrorZPtr { err } }; Self { contents, @@ -14146,95 +17507,91 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_DescriptionCreationErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_BuiltCommitmentTransactionDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_DescriptionCreationErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_BuiltCommitmentTransactionDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_DescriptionCreationErrorZ which has the same data as `orig` +/// Creates a new CResult_BuiltCommitmentTransactionDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_DescriptionCreationErrorZ_clone(orig: &CResult_DescriptionCreationErrorZ) -> CResult_DescriptionCreationErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig: &CResult_BuiltCommitmentTransactionDecodeErrorZ) -> CResult_BuiltCommitmentTransactionDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_PrivateRouteCreationErrorZ -pub union CResult_PrivateRouteCreationErrorZPtr { +/// The contents of CResult_TrustedClosingTransactionNoneZ +pub union CResult_TrustedClosingTransactionNoneZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning_invoice::PrivateRoute, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning_invoice::CreationError, + pub result: *mut crate::lightning::ln::chan_utils::TrustedClosingTransaction, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut core::ffi::c_void, } #[repr(C)] -/// A CResult_PrivateRouteCreationErrorZ represents the result of a fallible operation, -/// containing a crate::lightning_invoice::PrivateRoute on success and a crate::lightning_invoice::CreationError on failure. +/// A CResult_TrustedClosingTransactionNoneZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::chan_utils::TrustedClosingTransaction on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_PrivateRouteCreationErrorZ { - /// The contents of this CResult_PrivateRouteCreationErrorZ, accessible via either +pub struct CResult_TrustedClosingTransactionNoneZ { + /// The contents of this CResult_TrustedClosingTransactionNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_PrivateRouteCreationErrorZPtr, - /// Whether this CResult_PrivateRouteCreationErrorZ represents a success state. + pub contents: CResult_TrustedClosingTransactionNoneZPtr, + /// Whether this CResult_TrustedClosingTransactionNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_PrivateRouteCreationErrorZ in the success state. -pub extern "C" fn CResult_PrivateRouteCreationErrorZ_ok(o: crate::lightning_invoice::PrivateRoute) -> CResult_PrivateRouteCreationErrorZ { - CResult_PrivateRouteCreationErrorZ { - contents: CResult_PrivateRouteCreationErrorZPtr { +/// Creates a new CResult_TrustedClosingTransactionNoneZ in the success state. +pub extern "C" fn CResult_TrustedClosingTransactionNoneZ_ok(o: crate::lightning::ln::chan_utils::TrustedClosingTransaction) -> CResult_TrustedClosingTransactionNoneZ { + CResult_TrustedClosingTransactionNoneZ { + contents: CResult_TrustedClosingTransactionNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_PrivateRouteCreationErrorZ in the error state. -pub extern "C" fn CResult_PrivateRouteCreationErrorZ_err(e: crate::lightning_invoice::CreationError) -> CResult_PrivateRouteCreationErrorZ { - CResult_PrivateRouteCreationErrorZ { - contents: CResult_PrivateRouteCreationErrorZPtr { - err: Box::into_raw(Box::new(e)), +/// Creates a new CResult_TrustedClosingTransactionNoneZ in the error state. +pub extern "C" fn CResult_TrustedClosingTransactionNoneZ_err() -> CResult_TrustedClosingTransactionNoneZ { + CResult_TrustedClosingTransactionNoneZ { + contents: CResult_TrustedClosingTransactionNoneZPtr { + err: core::ptr::null_mut(), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_PrivateRouteCreationErrorZ_is_ok(o: &CResult_PrivateRouteCreationErrorZ) -> bool { +pub extern "C" fn CResult_TrustedClosingTransactionNoneZ_is_ok(o: &CResult_TrustedClosingTransactionNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_PrivateRouteCreationErrorZ. -pub extern "C" fn CResult_PrivateRouteCreationErrorZ_free(_res: CResult_PrivateRouteCreationErrorZ) { } -impl Drop for CResult_PrivateRouteCreationErrorZ { +/// Frees any resources used by the CResult_TrustedClosingTransactionNoneZ. +pub extern "C" fn CResult_TrustedClosingTransactionNoneZ_free(_res: CResult_TrustedClosingTransactionNoneZ) { } +impl Drop for CResult_TrustedClosingTransactionNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } } } } -impl From> for CResult_PrivateRouteCreationErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_TrustedClosingTransactionNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_PrivateRouteCreationErrorZPtr { result } + CResult_TrustedClosingTransactionNoneZPtr { result } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_PrivateRouteCreationErrorZPtr { err } + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_TrustedClosingTransactionNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -14242,59 +17599,42 @@ impl From Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_PrivateRouteCreationErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_PrivateRouteCreationErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } - } - } -} -#[no_mangle] -/// Creates a new CResult_PrivateRouteCreationErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_PrivateRouteCreationErrorZ_clone(orig: &CResult_PrivateRouteCreationErrorZ) -> CResult_PrivateRouteCreationErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_NetAddressDecodeErrorZ -pub union CResult_NetAddressDecodeErrorZPtr { +/// The contents of CResult_CommitmentTransactionDecodeErrorZ +pub union CResult_CommitmentTransactionDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::NetAddress, + pub result: *mut crate::lightning::ln::chan_utils::CommitmentTransaction, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_NetAddressDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::NetAddress on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_CommitmentTransactionDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::chan_utils::CommitmentTransaction on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_NetAddressDecodeErrorZ { - /// The contents of this CResult_NetAddressDecodeErrorZ, accessible via either +pub struct CResult_CommitmentTransactionDecodeErrorZ { + /// The contents of this CResult_CommitmentTransactionDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_NetAddressDecodeErrorZPtr, - /// Whether this CResult_NetAddressDecodeErrorZ represents a success state. + pub contents: CResult_CommitmentTransactionDecodeErrorZPtr, + /// Whether this CResult_CommitmentTransactionDecodeErrorZ represents a success state. pub result_ok: bool, -} -#[no_mangle] -/// Creates a new CResult_NetAddressDecodeErrorZ in the success state. -pub extern "C" fn CResult_NetAddressDecodeErrorZ_ok(o: crate::lightning::ln::msgs::NetAddress) -> CResult_NetAddressDecodeErrorZ { - CResult_NetAddressDecodeErrorZ { - contents: CResult_NetAddressDecodeErrorZPtr { +} +#[no_mangle] +/// Creates a new CResult_CommitmentTransactionDecodeErrorZ in the success state. +pub extern "C" fn CResult_CommitmentTransactionDecodeErrorZ_ok(o: crate::lightning::ln::chan_utils::CommitmentTransaction) -> CResult_CommitmentTransactionDecodeErrorZ { + CResult_CommitmentTransactionDecodeErrorZ { + contents: CResult_CommitmentTransactionDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_NetAddressDecodeErrorZ in the error state. -pub extern "C" fn CResult_NetAddressDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_NetAddressDecodeErrorZ { - CResult_NetAddressDecodeErrorZ { - contents: CResult_NetAddressDecodeErrorZPtr { +/// Creates a new CResult_CommitmentTransactionDecodeErrorZ in the error state. +pub extern "C" fn CResult_CommitmentTransactionDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_CommitmentTransactionDecodeErrorZ { + CResult_CommitmentTransactionDecodeErrorZ { + contents: CResult_CommitmentTransactionDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -14302,13 +17642,13 @@ pub extern "C" fn CResult_NetAddressDecodeErrorZ_err(e: crate::lightning::ln::ms } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_NetAddressDecodeErrorZ_is_ok(o: &CResult_NetAddressDecodeErrorZ) -> bool { +pub extern "C" fn CResult_CommitmentTransactionDecodeErrorZ_is_ok(o: &CResult_CommitmentTransactionDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_NetAddressDecodeErrorZ. -pub extern "C" fn CResult_NetAddressDecodeErrorZ_free(_res: CResult_NetAddressDecodeErrorZ) { } -impl Drop for CResult_NetAddressDecodeErrorZ { +/// Frees any resources used by the CResult_CommitmentTransactionDecodeErrorZ. +pub extern "C" fn CResult_CommitmentTransactionDecodeErrorZ_free(_res: CResult_CommitmentTransactionDecodeErrorZ) { } +impl Drop for CResult_CommitmentTransactionDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -14321,16 +17661,16 @@ impl Drop for CResult_NetAddressDecodeErrorZ { } } } -impl From> for CResult_NetAddressDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_CommitmentTransactionDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_NetAddressDecodeErrorZPtr { result } + CResult_CommitmentTransactionDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_NetAddressDecodeErrorZPtr { err } + CResult_CommitmentTransactionDecodeErrorZPtr { err } }; Self { contents, @@ -14338,279 +17678,166 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_NetAddressDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_CommitmentTransactionDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_NetAddressDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_CommitmentTransactionDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_NetAddressDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_CommitmentTransactionDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_NetAddressDecodeErrorZ_clone(orig: &CResult_NetAddressDecodeErrorZ) -> CResult_NetAddressDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_CommitmentTransactionDecodeErrorZ_clone(orig: &CResult_CommitmentTransactionDecodeErrorZ) -> CResult_CommitmentTransactionDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// A dynamically-allocated array of crate::lightning::ln::msgs::UpdateAddHTLCs of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_UpdateAddHTLCZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::ln::msgs::UpdateAddHTLC, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_UpdateAddHTLCZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::msgs::UpdateAddHTLC] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_UpdateAddHTLCZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_UpdateAddHTLCZ_free(_res: CVec_UpdateAddHTLCZ) { } -impl Drop for CVec_UpdateAddHTLCZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_UpdateAddHTLCZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } +/// The contents of CResult_TrustedCommitmentTransactionNoneZ +pub union CResult_TrustedCommitmentTransactionNoneZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::chan_utils::TrustedCommitmentTransaction, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut core::ffi::c_void, } #[repr(C)] -/// A dynamically-allocated array of crate::lightning::ln::msgs::UpdateFulfillHTLCs of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_UpdateFulfillHTLCZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::ln::msgs::UpdateFulfillHTLC, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_UpdateFulfillHTLCZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::msgs::UpdateFulfillHTLC] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_UpdateFulfillHTLCZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } +/// A CResult_TrustedCommitmentTransactionNoneZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::chan_utils::TrustedCommitmentTransaction on success and a () on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_TrustedCommitmentTransactionNoneZ { + /// The contents of this CResult_TrustedCommitmentTransactionNoneZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_TrustedCommitmentTransactionNoneZPtr, + /// Whether this CResult_TrustedCommitmentTransactionNoneZ represents a success state. + pub result_ok: bool, } #[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_UpdateFulfillHTLCZ_free(_res: CVec_UpdateFulfillHTLCZ) { } -impl Drop for CVec_UpdateFulfillHTLCZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_UpdateFulfillHTLCZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} -#[repr(C)] -/// A dynamically-allocated array of crate::lightning::ln::msgs::UpdateFailHTLCs of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_UpdateFailHTLCZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::ln::msgs::UpdateFailHTLC, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_UpdateFailHTLCZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::msgs::UpdateFailHTLC] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_UpdateFailHTLCZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } +/// Creates a new CResult_TrustedCommitmentTransactionNoneZ in the success state. +pub extern "C" fn CResult_TrustedCommitmentTransactionNoneZ_ok(o: crate::lightning::ln::chan_utils::TrustedCommitmentTransaction) -> CResult_TrustedCommitmentTransactionNoneZ { + CResult_TrustedCommitmentTransactionNoneZ { + contents: CResult_TrustedCommitmentTransactionNoneZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, } } #[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_UpdateFailHTLCZ_free(_res: CVec_UpdateFailHTLCZ) { } -impl Drop for CVec_UpdateFailHTLCZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_UpdateFailHTLCZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} -#[repr(C)] -/// A dynamically-allocated array of crate::lightning::ln::msgs::UpdateFailMalformedHTLCs of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_UpdateFailMalformedHTLCZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::ln::msgs::UpdateFailMalformedHTLC, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_UpdateFailMalformedHTLCZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::msgs::UpdateFailMalformedHTLC] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } +/// Creates a new CResult_TrustedCommitmentTransactionNoneZ in the error state. +pub extern "C" fn CResult_TrustedCommitmentTransactionNoneZ_err() -> CResult_TrustedCommitmentTransactionNoneZ { + CResult_TrustedCommitmentTransactionNoneZ { + contents: CResult_TrustedCommitmentTransactionNoneZPtr { + err: core::ptr::null_mut(), + }, + result_ok: false, } } -impl From> for CVec_UpdateFailMalformedHTLCZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_TrustedCommitmentTransactionNoneZ_is_ok(o: &CResult_TrustedCommitmentTransactionNoneZ) -> bool { + o.result_ok } #[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_UpdateFailMalformedHTLCZ_free(_res: CVec_UpdateFailMalformedHTLCZ) { } -impl Drop for CVec_UpdateFailMalformedHTLCZ { +/// Frees any resources used by the CResult_TrustedCommitmentTransactionNoneZ. +pub extern "C" fn CResult_TrustedCommitmentTransactionNoneZ_free(_res: CResult_TrustedCommitmentTransactionNoneZ) { } +impl Drop for CResult_TrustedCommitmentTransactionNoneZ { fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + } } } -impl Clone for CVec_UpdateFailMalformedHTLCZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) +impl From> for CResult_TrustedCommitmentTransactionNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_TrustedCommitmentTransactionNoneZPtr { result } + } else { + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_TrustedCommitmentTransactionNoneZPtr { err: core::ptr::null_mut() } + }; + Self { + contents, + result_ok: o.result_ok, + } } } #[repr(C)] -/// The contents of CResult_AcceptChannelDecodeErrorZ -pub union CResult_AcceptChannelDecodeErrorZPtr { +/// The contents of CResult_CVec_SignatureZNoneZ +pub union CResult_CVec_SignatureZNoneZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::AcceptChannel, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub result: *mut crate::c_types::derived::CVec_SignatureZ, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut core::ffi::c_void, } #[repr(C)] -/// A CResult_AcceptChannelDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::AcceptChannel on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_CVec_SignatureZNoneZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::CVec_SignatureZ on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_AcceptChannelDecodeErrorZ { - /// The contents of this CResult_AcceptChannelDecodeErrorZ, accessible via either +pub struct CResult_CVec_SignatureZNoneZ { + /// The contents of this CResult_CVec_SignatureZNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_AcceptChannelDecodeErrorZPtr, - /// Whether this CResult_AcceptChannelDecodeErrorZ represents a success state. + pub contents: CResult_CVec_SignatureZNoneZPtr, + /// Whether this CResult_CVec_SignatureZNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_AcceptChannelDecodeErrorZ in the success state. -pub extern "C" fn CResult_AcceptChannelDecodeErrorZ_ok(o: crate::lightning::ln::msgs::AcceptChannel) -> CResult_AcceptChannelDecodeErrorZ { - CResult_AcceptChannelDecodeErrorZ { - contents: CResult_AcceptChannelDecodeErrorZPtr { +/// Creates a new CResult_CVec_SignatureZNoneZ in the success state. +pub extern "C" fn CResult_CVec_SignatureZNoneZ_ok(o: crate::c_types::derived::CVec_SignatureZ) -> CResult_CVec_SignatureZNoneZ { + CResult_CVec_SignatureZNoneZ { + contents: CResult_CVec_SignatureZNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_AcceptChannelDecodeErrorZ in the error state. -pub extern "C" fn CResult_AcceptChannelDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_AcceptChannelDecodeErrorZ { - CResult_AcceptChannelDecodeErrorZ { - contents: CResult_AcceptChannelDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), +/// Creates a new CResult_CVec_SignatureZNoneZ in the error state. +pub extern "C" fn CResult_CVec_SignatureZNoneZ_err() -> CResult_CVec_SignatureZNoneZ { + CResult_CVec_SignatureZNoneZ { + contents: CResult_CVec_SignatureZNoneZPtr { + err: core::ptr::null_mut(), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_AcceptChannelDecodeErrorZ_is_ok(o: &CResult_AcceptChannelDecodeErrorZ) -> bool { +pub extern "C" fn CResult_CVec_SignatureZNoneZ_is_ok(o: &CResult_CVec_SignatureZNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_AcceptChannelDecodeErrorZ. -pub extern "C" fn CResult_AcceptChannelDecodeErrorZ_free(_res: CResult_AcceptChannelDecodeErrorZ) { } -impl Drop for CResult_AcceptChannelDecodeErrorZ { +/// Frees any resources used by the CResult_CVec_SignatureZNoneZ. +pub extern "C" fn CResult_CVec_SignatureZNoneZ_free(_res: CResult_CVec_SignatureZNoneZ) { } +impl Drop for CResult_CVec_SignatureZNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } } } } -impl From> for CResult_AcceptChannelDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_CVec_SignatureZNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_AcceptChannelDecodeErrorZPtr { result } + CResult_CVec_SignatureZNoneZPtr { result } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_AcceptChannelDecodeErrorZPtr { err } + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_CVec_SignatureZNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -14618,59 +17845,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_AcceptChannelDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_CVec_SignatureZNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_AcceptChannelDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_CVec_SignatureZNoneZPtr { + err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_AcceptChannelDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_CVec_SignatureZNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_AcceptChannelDecodeErrorZ_clone(orig: &CResult_AcceptChannelDecodeErrorZ) -> CResult_AcceptChannelDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_CVec_SignatureZNoneZ_clone(orig: &CResult_CVec_SignatureZNoneZ) -> CResult_CVec_SignatureZNoneZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_AnnouncementSignaturesDecodeErrorZ -pub union CResult_AnnouncementSignaturesDecodeErrorZPtr { +/// The contents of CResult_ShutdownScriptDecodeErrorZ +pub union CResult_ShutdownScriptDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::AnnouncementSignatures, + pub result: *mut crate::lightning::ln::script::ShutdownScript, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_AnnouncementSignaturesDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::AnnouncementSignatures on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_ShutdownScriptDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::script::ShutdownScript on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_AnnouncementSignaturesDecodeErrorZ { - /// The contents of this CResult_AnnouncementSignaturesDecodeErrorZ, accessible via either +pub struct CResult_ShutdownScriptDecodeErrorZ { + /// The contents of this CResult_ShutdownScriptDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_AnnouncementSignaturesDecodeErrorZPtr, - /// Whether this CResult_AnnouncementSignaturesDecodeErrorZ represents a success state. + pub contents: CResult_ShutdownScriptDecodeErrorZPtr, + /// Whether this CResult_ShutdownScriptDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_AnnouncementSignaturesDecodeErrorZ in the success state. -pub extern "C" fn CResult_AnnouncementSignaturesDecodeErrorZ_ok(o: crate::lightning::ln::msgs::AnnouncementSignatures) -> CResult_AnnouncementSignaturesDecodeErrorZ { - CResult_AnnouncementSignaturesDecodeErrorZ { - contents: CResult_AnnouncementSignaturesDecodeErrorZPtr { +/// Creates a new CResult_ShutdownScriptDecodeErrorZ in the success state. +pub extern "C" fn CResult_ShutdownScriptDecodeErrorZ_ok(o: crate::lightning::ln::script::ShutdownScript) -> CResult_ShutdownScriptDecodeErrorZ { + CResult_ShutdownScriptDecodeErrorZ { + contents: CResult_ShutdownScriptDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_AnnouncementSignaturesDecodeErrorZ in the error state. -pub extern "C" fn CResult_AnnouncementSignaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_AnnouncementSignaturesDecodeErrorZ { - CResult_AnnouncementSignaturesDecodeErrorZ { - contents: CResult_AnnouncementSignaturesDecodeErrorZPtr { +/// Creates a new CResult_ShutdownScriptDecodeErrorZ in the error state. +pub extern "C" fn CResult_ShutdownScriptDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ShutdownScriptDecodeErrorZ { + CResult_ShutdownScriptDecodeErrorZ { + contents: CResult_ShutdownScriptDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -14678,13 +17905,13 @@ pub extern "C" fn CResult_AnnouncementSignaturesDecodeErrorZ_err(e: crate::light } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(o: &CResult_AnnouncementSignaturesDecodeErrorZ) -> bool { +pub extern "C" fn CResult_ShutdownScriptDecodeErrorZ_is_ok(o: &CResult_ShutdownScriptDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_AnnouncementSignaturesDecodeErrorZ. -pub extern "C" fn CResult_AnnouncementSignaturesDecodeErrorZ_free(_res: CResult_AnnouncementSignaturesDecodeErrorZ) { } -impl Drop for CResult_AnnouncementSignaturesDecodeErrorZ { +/// Frees any resources used by the CResult_ShutdownScriptDecodeErrorZ. +pub extern "C" fn CResult_ShutdownScriptDecodeErrorZ_free(_res: CResult_ShutdownScriptDecodeErrorZ) { } +impl Drop for CResult_ShutdownScriptDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -14697,16 +17924,16 @@ impl Drop for CResult_AnnouncementSignaturesDecodeErrorZ { } } } -impl From> for CResult_AnnouncementSignaturesDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ShutdownScriptDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_AnnouncementSignaturesDecodeErrorZPtr { result } + CResult_ShutdownScriptDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_AnnouncementSignaturesDecodeErrorZPtr { err } + CResult_ShutdownScriptDecodeErrorZPtr { err } }; Self { contents, @@ -14714,59 +17941,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_AnnouncementSignaturesDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_ShutdownScriptDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_AnnouncementSignaturesDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_ShutdownScriptDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_AnnouncementSignaturesDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_ShutdownScriptDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig: &CResult_AnnouncementSignaturesDecodeErrorZ) -> CResult_AnnouncementSignaturesDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_ShutdownScriptDecodeErrorZ_clone(orig: &CResult_ShutdownScriptDecodeErrorZ) -> CResult_ShutdownScriptDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_ChannelReestablishDecodeErrorZ -pub union CResult_ChannelReestablishDecodeErrorZPtr { +/// The contents of CResult_ShutdownScriptInvalidShutdownScriptZ +pub union CResult_ShutdownScriptInvalidShutdownScriptZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::ChannelReestablish, + pub result: *mut crate::lightning::ln::script::ShutdownScript, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::lightning::ln::script::InvalidShutdownScript, } #[repr(C)] -/// A CResult_ChannelReestablishDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::ChannelReestablish on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_ShutdownScriptInvalidShutdownScriptZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::script::ShutdownScript on success and a crate::lightning::ln::script::InvalidShutdownScript on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ChannelReestablishDecodeErrorZ { - /// The contents of this CResult_ChannelReestablishDecodeErrorZ, accessible via either +pub struct CResult_ShutdownScriptInvalidShutdownScriptZ { + /// The contents of this CResult_ShutdownScriptInvalidShutdownScriptZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ChannelReestablishDecodeErrorZPtr, - /// Whether this CResult_ChannelReestablishDecodeErrorZ represents a success state. + pub contents: CResult_ShutdownScriptInvalidShutdownScriptZPtr, + /// Whether this CResult_ShutdownScriptInvalidShutdownScriptZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ChannelReestablishDecodeErrorZ in the success state. -pub extern "C" fn CResult_ChannelReestablishDecodeErrorZ_ok(o: crate::lightning::ln::msgs::ChannelReestablish) -> CResult_ChannelReestablishDecodeErrorZ { - CResult_ChannelReestablishDecodeErrorZ { - contents: CResult_ChannelReestablishDecodeErrorZPtr { +/// Creates a new CResult_ShutdownScriptInvalidShutdownScriptZ in the success state. +pub extern "C" fn CResult_ShutdownScriptInvalidShutdownScriptZ_ok(o: crate::lightning::ln::script::ShutdownScript) -> CResult_ShutdownScriptInvalidShutdownScriptZ { + CResult_ShutdownScriptInvalidShutdownScriptZ { + contents: CResult_ShutdownScriptInvalidShutdownScriptZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ChannelReestablishDecodeErrorZ in the error state. -pub extern "C" fn CResult_ChannelReestablishDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelReestablishDecodeErrorZ { - CResult_ChannelReestablishDecodeErrorZ { - contents: CResult_ChannelReestablishDecodeErrorZPtr { +/// Creates a new CResult_ShutdownScriptInvalidShutdownScriptZ in the error state. +pub extern "C" fn CResult_ShutdownScriptInvalidShutdownScriptZ_err(e: crate::lightning::ln::script::InvalidShutdownScript) -> CResult_ShutdownScriptInvalidShutdownScriptZ { + CResult_ShutdownScriptInvalidShutdownScriptZ { + contents: CResult_ShutdownScriptInvalidShutdownScriptZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -14774,13 +18001,13 @@ pub extern "C" fn CResult_ChannelReestablishDecodeErrorZ_err(e: crate::lightning } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ChannelReestablishDecodeErrorZ_is_ok(o: &CResult_ChannelReestablishDecodeErrorZ) -> bool { +pub extern "C" fn CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(o: &CResult_ShutdownScriptInvalidShutdownScriptZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_ChannelReestablishDecodeErrorZ. -pub extern "C" fn CResult_ChannelReestablishDecodeErrorZ_free(_res: CResult_ChannelReestablishDecodeErrorZ) { } -impl Drop for CResult_ChannelReestablishDecodeErrorZ { +/// Frees any resources used by the CResult_ShutdownScriptInvalidShutdownScriptZ. +pub extern "C" fn CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res: CResult_ShutdownScriptInvalidShutdownScriptZ) { } +impl Drop for CResult_ShutdownScriptInvalidShutdownScriptZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -14793,16 +18020,16 @@ impl Drop for CResult_ChannelReestablishDecodeErrorZ { } } } -impl From> for CResult_ChannelReestablishDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ShutdownScriptInvalidShutdownScriptZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ChannelReestablishDecodeErrorZPtr { result } + CResult_ShutdownScriptInvalidShutdownScriptZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ChannelReestablishDecodeErrorZPtr { err } + CResult_ShutdownScriptInvalidShutdownScriptZPtr { err } }; Self { contents, @@ -14810,59 +18037,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ChannelReestablishDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_ShutdownScriptInvalidShutdownScriptZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_ChannelReestablishDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_ShutdownScriptInvalidShutdownScriptZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_ChannelReestablishDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_ShutdownScriptInvalidShutdownScriptZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ChannelReestablishDecodeErrorZ_clone(orig: &CResult_ChannelReestablishDecodeErrorZ) -> CResult_ChannelReestablishDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_ShutdownScriptInvalidShutdownScriptZ_clone(orig: &CResult_ShutdownScriptInvalidShutdownScriptZ) -> CResult_ShutdownScriptInvalidShutdownScriptZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_ClosingSignedDecodeErrorZ -pub union CResult_ClosingSignedDecodeErrorZPtr { +/// The contents of CResult_PaymentPurposeDecodeErrorZ +pub union CResult_PaymentPurposeDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::ClosingSigned, + pub result: *mut crate::lightning::events::PaymentPurpose, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_ClosingSignedDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::ClosingSigned on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_PaymentPurposeDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::events::PaymentPurpose on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ClosingSignedDecodeErrorZ { - /// The contents of this CResult_ClosingSignedDecodeErrorZ, accessible via either +pub struct CResult_PaymentPurposeDecodeErrorZ { + /// The contents of this CResult_PaymentPurposeDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ClosingSignedDecodeErrorZPtr, - /// Whether this CResult_ClosingSignedDecodeErrorZ represents a success state. + pub contents: CResult_PaymentPurposeDecodeErrorZPtr, + /// Whether this CResult_PaymentPurposeDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ClosingSignedDecodeErrorZ in the success state. -pub extern "C" fn CResult_ClosingSignedDecodeErrorZ_ok(o: crate::lightning::ln::msgs::ClosingSigned) -> CResult_ClosingSignedDecodeErrorZ { - CResult_ClosingSignedDecodeErrorZ { - contents: CResult_ClosingSignedDecodeErrorZPtr { +/// Creates a new CResult_PaymentPurposeDecodeErrorZ in the success state. +pub extern "C" fn CResult_PaymentPurposeDecodeErrorZ_ok(o: crate::lightning::events::PaymentPurpose) -> CResult_PaymentPurposeDecodeErrorZ { + CResult_PaymentPurposeDecodeErrorZ { + contents: CResult_PaymentPurposeDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ClosingSignedDecodeErrorZ in the error state. -pub extern "C" fn CResult_ClosingSignedDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ClosingSignedDecodeErrorZ { - CResult_ClosingSignedDecodeErrorZ { - contents: CResult_ClosingSignedDecodeErrorZPtr { +/// Creates a new CResult_PaymentPurposeDecodeErrorZ in the error state. +pub extern "C" fn CResult_PaymentPurposeDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_PaymentPurposeDecodeErrorZ { + CResult_PaymentPurposeDecodeErrorZ { + contents: CResult_PaymentPurposeDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -14870,13 +18097,13 @@ pub extern "C" fn CResult_ClosingSignedDecodeErrorZ_err(e: crate::lightning::ln: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ClosingSignedDecodeErrorZ_is_ok(o: &CResult_ClosingSignedDecodeErrorZ) -> bool { +pub extern "C" fn CResult_PaymentPurposeDecodeErrorZ_is_ok(o: &CResult_PaymentPurposeDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_ClosingSignedDecodeErrorZ. -pub extern "C" fn CResult_ClosingSignedDecodeErrorZ_free(_res: CResult_ClosingSignedDecodeErrorZ) { } -impl Drop for CResult_ClosingSignedDecodeErrorZ { +/// Frees any resources used by the CResult_PaymentPurposeDecodeErrorZ. +pub extern "C" fn CResult_PaymentPurposeDecodeErrorZ_free(_res: CResult_PaymentPurposeDecodeErrorZ) { } +impl Drop for CResult_PaymentPurposeDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -14889,16 +18116,16 @@ impl Drop for CResult_ClosingSignedDecodeErrorZ { } } } -impl From> for CResult_ClosingSignedDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_PaymentPurposeDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ClosingSignedDecodeErrorZPtr { result } + CResult_PaymentPurposeDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ClosingSignedDecodeErrorZPtr { err } + CResult_PaymentPurposeDecodeErrorZPtr { err } }; Self { contents, @@ -14906,59 +18133,96 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ClosingSignedDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_PaymentPurposeDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_ClosingSignedDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_PaymentPurposeDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_ClosingSignedDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_PaymentPurposeDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ClosingSignedDecodeErrorZ_clone(orig: &CResult_ClosingSignedDecodeErrorZ) -> CResult_ClosingSignedDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_PaymentPurposeDecodeErrorZ_clone(orig: &CResult_PaymentPurposeDecodeErrorZ) -> CResult_PaymentPurposeDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_ClosingSignedFeeRangeDecodeErrorZ -pub union CResult_ClosingSignedFeeRangeDecodeErrorZPtr { +#[derive(Clone)] +/// An enum which can either contain a crate::lightning::events::PathFailure or not +pub enum COption_PathFailureZ { + /// When we're in this state, this COption_PathFailureZ contains a crate::lightning::events::PathFailure + Some(crate::lightning::events::PathFailure), + /// When we're in this state, this COption_PathFailureZ contains nothing + None +} +impl COption_PathFailureZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::events::PathFailure { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_PathFailureZ containing a crate::lightning::events::PathFailure +pub extern "C" fn COption_PathFailureZ_some(o: crate::lightning::events::PathFailure) -> COption_PathFailureZ { + COption_PathFailureZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_PathFailureZ containing nothing +pub extern "C" fn COption_PathFailureZ_none() -> COption_PathFailureZ { + COption_PathFailureZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::lightning::events::PathFailure, if we are in the Some state +pub extern "C" fn COption_PathFailureZ_free(_res: COption_PathFailureZ) { } +#[no_mangle] +/// Creates a new COption_PathFailureZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_PathFailureZ_clone(orig: &COption_PathFailureZ) -> COption_PathFailureZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_COption_PathFailureZDecodeErrorZ +pub union CResult_COption_PathFailureZDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::ClosingSignedFeeRange, + pub result: *mut crate::c_types::derived::COption_PathFailureZ, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_ClosingSignedFeeRangeDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::ClosingSignedFeeRange on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_COption_PathFailureZDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::COption_PathFailureZ on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ClosingSignedFeeRangeDecodeErrorZ { - /// The contents of this CResult_ClosingSignedFeeRangeDecodeErrorZ, accessible via either +pub struct CResult_COption_PathFailureZDecodeErrorZ { + /// The contents of this CResult_COption_PathFailureZDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ClosingSignedFeeRangeDecodeErrorZPtr, - /// Whether this CResult_ClosingSignedFeeRangeDecodeErrorZ represents a success state. + pub contents: CResult_COption_PathFailureZDecodeErrorZPtr, + /// Whether this CResult_COption_PathFailureZDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ClosingSignedFeeRangeDecodeErrorZ in the success state. -pub extern "C" fn CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(o: crate::lightning::ln::msgs::ClosingSignedFeeRange) -> CResult_ClosingSignedFeeRangeDecodeErrorZ { - CResult_ClosingSignedFeeRangeDecodeErrorZ { - contents: CResult_ClosingSignedFeeRangeDecodeErrorZPtr { +/// Creates a new CResult_COption_PathFailureZDecodeErrorZ in the success state. +pub extern "C" fn CResult_COption_PathFailureZDecodeErrorZ_ok(o: crate::c_types::derived::COption_PathFailureZ) -> CResult_COption_PathFailureZDecodeErrorZ { + CResult_COption_PathFailureZDecodeErrorZ { + contents: CResult_COption_PathFailureZDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ClosingSignedFeeRangeDecodeErrorZ in the error state. -pub extern "C" fn CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ClosingSignedFeeRangeDecodeErrorZ { - CResult_ClosingSignedFeeRangeDecodeErrorZ { - contents: CResult_ClosingSignedFeeRangeDecodeErrorZPtr { +/// Creates a new CResult_COption_PathFailureZDecodeErrorZ in the error state. +pub extern "C" fn CResult_COption_PathFailureZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_COption_PathFailureZDecodeErrorZ { + CResult_COption_PathFailureZDecodeErrorZ { + contents: CResult_COption_PathFailureZDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -14966,13 +18230,13 @@ pub extern "C" fn CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e: crate::lightn } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(o: &CResult_ClosingSignedFeeRangeDecodeErrorZ) -> bool { +pub extern "C" fn CResult_COption_PathFailureZDecodeErrorZ_is_ok(o: &CResult_COption_PathFailureZDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_ClosingSignedFeeRangeDecodeErrorZ. -pub extern "C" fn CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res: CResult_ClosingSignedFeeRangeDecodeErrorZ) { } -impl Drop for CResult_ClosingSignedFeeRangeDecodeErrorZ { +/// Frees any resources used by the CResult_COption_PathFailureZDecodeErrorZ. +pub extern "C" fn CResult_COption_PathFailureZDecodeErrorZ_free(_res: CResult_COption_PathFailureZDecodeErrorZ) { } +impl Drop for CResult_COption_PathFailureZDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -14985,16 +18249,16 @@ impl Drop for CResult_ClosingSignedFeeRangeDecodeErrorZ { } } } -impl From> for CResult_ClosingSignedFeeRangeDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_COption_PathFailureZDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ClosingSignedFeeRangeDecodeErrorZPtr { result } + CResult_COption_PathFailureZDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ClosingSignedFeeRangeDecodeErrorZPtr { err } + CResult_COption_PathFailureZDecodeErrorZPtr { err } }; Self { contents, @@ -15002,59 +18266,96 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ClosingSignedFeeRangeDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_COption_PathFailureZDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_ClosingSignedFeeRangeDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_COption_PathFailureZDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_ClosingSignedFeeRangeDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_COption_PathFailureZDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(orig: &CResult_ClosingSignedFeeRangeDecodeErrorZ) -> CResult_ClosingSignedFeeRangeDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_COption_PathFailureZDecodeErrorZ_clone(orig: &CResult_COption_PathFailureZDecodeErrorZ) -> CResult_COption_PathFailureZDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_CommitmentSignedDecodeErrorZ -pub union CResult_CommitmentSignedDecodeErrorZPtr { +#[derive(Clone)] +/// An enum which can either contain a crate::lightning::events::ClosureReason or not +pub enum COption_ClosureReasonZ { + /// When we're in this state, this COption_ClosureReasonZ contains a crate::lightning::events::ClosureReason + Some(crate::lightning::events::ClosureReason), + /// When we're in this state, this COption_ClosureReasonZ contains nothing + None +} +impl COption_ClosureReasonZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::events::ClosureReason { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_ClosureReasonZ containing a crate::lightning::events::ClosureReason +pub extern "C" fn COption_ClosureReasonZ_some(o: crate::lightning::events::ClosureReason) -> COption_ClosureReasonZ { + COption_ClosureReasonZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_ClosureReasonZ containing nothing +pub extern "C" fn COption_ClosureReasonZ_none() -> COption_ClosureReasonZ { + COption_ClosureReasonZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::lightning::events::ClosureReason, if we are in the Some state +pub extern "C" fn COption_ClosureReasonZ_free(_res: COption_ClosureReasonZ) { } +#[no_mangle] +/// Creates a new COption_ClosureReasonZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_ClosureReasonZ_clone(orig: &COption_ClosureReasonZ) -> COption_ClosureReasonZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_COption_ClosureReasonZDecodeErrorZ +pub union CResult_COption_ClosureReasonZDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::CommitmentSigned, + pub result: *mut crate::c_types::derived::COption_ClosureReasonZ, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_CommitmentSignedDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::CommitmentSigned on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_COption_ClosureReasonZDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::COption_ClosureReasonZ on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_CommitmentSignedDecodeErrorZ { - /// The contents of this CResult_CommitmentSignedDecodeErrorZ, accessible via either +pub struct CResult_COption_ClosureReasonZDecodeErrorZ { + /// The contents of this CResult_COption_ClosureReasonZDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_CommitmentSignedDecodeErrorZPtr, - /// Whether this CResult_CommitmentSignedDecodeErrorZ represents a success state. + pub contents: CResult_COption_ClosureReasonZDecodeErrorZPtr, + /// Whether this CResult_COption_ClosureReasonZDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_CommitmentSignedDecodeErrorZ in the success state. -pub extern "C" fn CResult_CommitmentSignedDecodeErrorZ_ok(o: crate::lightning::ln::msgs::CommitmentSigned) -> CResult_CommitmentSignedDecodeErrorZ { - CResult_CommitmentSignedDecodeErrorZ { - contents: CResult_CommitmentSignedDecodeErrorZPtr { +/// Creates a new CResult_COption_ClosureReasonZDecodeErrorZ in the success state. +pub extern "C" fn CResult_COption_ClosureReasonZDecodeErrorZ_ok(o: crate::c_types::derived::COption_ClosureReasonZ) -> CResult_COption_ClosureReasonZDecodeErrorZ { + CResult_COption_ClosureReasonZDecodeErrorZ { + contents: CResult_COption_ClosureReasonZDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_CommitmentSignedDecodeErrorZ in the error state. -pub extern "C" fn CResult_CommitmentSignedDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_CommitmentSignedDecodeErrorZ { - CResult_CommitmentSignedDecodeErrorZ { - contents: CResult_CommitmentSignedDecodeErrorZPtr { +/// Creates a new CResult_COption_ClosureReasonZDecodeErrorZ in the error state. +pub extern "C" fn CResult_COption_ClosureReasonZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_COption_ClosureReasonZDecodeErrorZ { + CResult_COption_ClosureReasonZDecodeErrorZ { + contents: CResult_COption_ClosureReasonZDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -15062,13 +18363,13 @@ pub extern "C" fn CResult_CommitmentSignedDecodeErrorZ_err(e: crate::lightning:: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_CommitmentSignedDecodeErrorZ_is_ok(o: &CResult_CommitmentSignedDecodeErrorZ) -> bool { +pub extern "C" fn CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(o: &CResult_COption_ClosureReasonZDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_CommitmentSignedDecodeErrorZ. -pub extern "C" fn CResult_CommitmentSignedDecodeErrorZ_free(_res: CResult_CommitmentSignedDecodeErrorZ) { } -impl Drop for CResult_CommitmentSignedDecodeErrorZ { +/// Frees any resources used by the CResult_COption_ClosureReasonZDecodeErrorZ. +pub extern "C" fn CResult_COption_ClosureReasonZDecodeErrorZ_free(_res: CResult_COption_ClosureReasonZDecodeErrorZ) { } +impl Drop for CResult_COption_ClosureReasonZDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -15081,16 +18382,16 @@ impl Drop for CResult_CommitmentSignedDecodeErrorZ { } } } -impl From> for CResult_CommitmentSignedDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_COption_ClosureReasonZDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_CommitmentSignedDecodeErrorZPtr { result } + CResult_COption_ClosureReasonZDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_CommitmentSignedDecodeErrorZPtr { err } + CResult_COption_ClosureReasonZDecodeErrorZPtr { err } }; Self { contents, @@ -15098,59 +18399,96 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_CommitmentSignedDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_COption_ClosureReasonZDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_CommitmentSignedDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_COption_ClosureReasonZDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_CommitmentSignedDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_COption_ClosureReasonZDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_COption_ClosureReasonZDecodeErrorZ_clone(orig: &CResult_COption_ClosureReasonZDecodeErrorZ) -> CResult_COption_ClosureReasonZDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +#[derive(Clone)] +/// An enum which can either contain a crate::lightning::events::HTLCDestination or not +pub enum COption_HTLCDestinationZ { + /// When we're in this state, this COption_HTLCDestinationZ contains a crate::lightning::events::HTLCDestination + Some(crate::lightning::events::HTLCDestination), + /// When we're in this state, this COption_HTLCDestinationZ contains nothing + None +} +impl COption_HTLCDestinationZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::events::HTLCDestination { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_HTLCDestinationZ containing a crate::lightning::events::HTLCDestination +pub extern "C" fn COption_HTLCDestinationZ_some(o: crate::lightning::events::HTLCDestination) -> COption_HTLCDestinationZ { + COption_HTLCDestinationZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_HTLCDestinationZ containing nothing +pub extern "C" fn COption_HTLCDestinationZ_none() -> COption_HTLCDestinationZ { + COption_HTLCDestinationZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::lightning::events::HTLCDestination, if we are in the Some state +pub extern "C" fn COption_HTLCDestinationZ_free(_res: COption_HTLCDestinationZ) { } +#[no_mangle] +/// Creates a new COption_HTLCDestinationZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_CommitmentSignedDecodeErrorZ_clone(orig: &CResult_CommitmentSignedDecodeErrorZ) -> CResult_CommitmentSignedDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn COption_HTLCDestinationZ_clone(orig: &COption_HTLCDestinationZ) -> COption_HTLCDestinationZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_FundingCreatedDecodeErrorZ -pub union CResult_FundingCreatedDecodeErrorZPtr { +/// The contents of CResult_COption_HTLCDestinationZDecodeErrorZ +pub union CResult_COption_HTLCDestinationZDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::FundingCreated, + pub result: *mut crate::c_types::derived::COption_HTLCDestinationZ, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_FundingCreatedDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::FundingCreated on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_COption_HTLCDestinationZDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::COption_HTLCDestinationZ on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_FundingCreatedDecodeErrorZ { - /// The contents of this CResult_FundingCreatedDecodeErrorZ, accessible via either +pub struct CResult_COption_HTLCDestinationZDecodeErrorZ { + /// The contents of this CResult_COption_HTLCDestinationZDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_FundingCreatedDecodeErrorZPtr, - /// Whether this CResult_FundingCreatedDecodeErrorZ represents a success state. + pub contents: CResult_COption_HTLCDestinationZDecodeErrorZPtr, + /// Whether this CResult_COption_HTLCDestinationZDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_FundingCreatedDecodeErrorZ in the success state. -pub extern "C" fn CResult_FundingCreatedDecodeErrorZ_ok(o: crate::lightning::ln::msgs::FundingCreated) -> CResult_FundingCreatedDecodeErrorZ { - CResult_FundingCreatedDecodeErrorZ { - contents: CResult_FundingCreatedDecodeErrorZPtr { +/// Creates a new CResult_COption_HTLCDestinationZDecodeErrorZ in the success state. +pub extern "C" fn CResult_COption_HTLCDestinationZDecodeErrorZ_ok(o: crate::c_types::derived::COption_HTLCDestinationZ) -> CResult_COption_HTLCDestinationZDecodeErrorZ { + CResult_COption_HTLCDestinationZDecodeErrorZ { + contents: CResult_COption_HTLCDestinationZDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_FundingCreatedDecodeErrorZ in the error state. -pub extern "C" fn CResult_FundingCreatedDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_FundingCreatedDecodeErrorZ { - CResult_FundingCreatedDecodeErrorZ { - contents: CResult_FundingCreatedDecodeErrorZPtr { +/// Creates a new CResult_COption_HTLCDestinationZDecodeErrorZ in the error state. +pub extern "C" fn CResult_COption_HTLCDestinationZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_COption_HTLCDestinationZDecodeErrorZ { + CResult_COption_HTLCDestinationZDecodeErrorZ { + contents: CResult_COption_HTLCDestinationZDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -15158,13 +18496,13 @@ pub extern "C" fn CResult_FundingCreatedDecodeErrorZ_err(e: crate::lightning::ln } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_FundingCreatedDecodeErrorZ_is_ok(o: &CResult_FundingCreatedDecodeErrorZ) -> bool { +pub extern "C" fn CResult_COption_HTLCDestinationZDecodeErrorZ_is_ok(o: &CResult_COption_HTLCDestinationZDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_FundingCreatedDecodeErrorZ. -pub extern "C" fn CResult_FundingCreatedDecodeErrorZ_free(_res: CResult_FundingCreatedDecodeErrorZ) { } -impl Drop for CResult_FundingCreatedDecodeErrorZ { +/// Frees any resources used by the CResult_COption_HTLCDestinationZDecodeErrorZ. +pub extern "C" fn CResult_COption_HTLCDestinationZDecodeErrorZ_free(_res: CResult_COption_HTLCDestinationZDecodeErrorZ) { } +impl Drop for CResult_COption_HTLCDestinationZDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -15177,16 +18515,16 @@ impl Drop for CResult_FundingCreatedDecodeErrorZ { } } } -impl From> for CResult_FundingCreatedDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_COption_HTLCDestinationZDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_FundingCreatedDecodeErrorZPtr { result } + CResult_COption_HTLCDestinationZDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_FundingCreatedDecodeErrorZPtr { err } + CResult_COption_HTLCDestinationZDecodeErrorZPtr { err } }; Self { contents, @@ -15194,59 +18532,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_FundingCreatedDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_COption_HTLCDestinationZDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_FundingCreatedDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_COption_HTLCDestinationZDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_FundingCreatedDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_COption_HTLCDestinationZDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_FundingCreatedDecodeErrorZ_clone(orig: &CResult_FundingCreatedDecodeErrorZ) -> CResult_FundingCreatedDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_COption_HTLCDestinationZDecodeErrorZ_clone(orig: &CResult_COption_HTLCDestinationZDecodeErrorZ) -> CResult_COption_HTLCDestinationZDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_FundingSignedDecodeErrorZ -pub union CResult_FundingSignedDecodeErrorZPtr { +/// The contents of CResult_PaymentFailureReasonDecodeErrorZ +pub union CResult_PaymentFailureReasonDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::FundingSigned, + pub result: *mut crate::lightning::events::PaymentFailureReason, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_FundingSignedDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::FundingSigned on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_PaymentFailureReasonDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::events::PaymentFailureReason on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_FundingSignedDecodeErrorZ { - /// The contents of this CResult_FundingSignedDecodeErrorZ, accessible via either +pub struct CResult_PaymentFailureReasonDecodeErrorZ { + /// The contents of this CResult_PaymentFailureReasonDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_FundingSignedDecodeErrorZPtr, - /// Whether this CResult_FundingSignedDecodeErrorZ represents a success state. + pub contents: CResult_PaymentFailureReasonDecodeErrorZPtr, + /// Whether this CResult_PaymentFailureReasonDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_FundingSignedDecodeErrorZ in the success state. -pub extern "C" fn CResult_FundingSignedDecodeErrorZ_ok(o: crate::lightning::ln::msgs::FundingSigned) -> CResult_FundingSignedDecodeErrorZ { - CResult_FundingSignedDecodeErrorZ { - contents: CResult_FundingSignedDecodeErrorZPtr { +/// Creates a new CResult_PaymentFailureReasonDecodeErrorZ in the success state. +pub extern "C" fn CResult_PaymentFailureReasonDecodeErrorZ_ok(o: crate::lightning::events::PaymentFailureReason) -> CResult_PaymentFailureReasonDecodeErrorZ { + CResult_PaymentFailureReasonDecodeErrorZ { + contents: CResult_PaymentFailureReasonDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_FundingSignedDecodeErrorZ in the error state. -pub extern "C" fn CResult_FundingSignedDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_FundingSignedDecodeErrorZ { - CResult_FundingSignedDecodeErrorZ { - contents: CResult_FundingSignedDecodeErrorZPtr { +/// Creates a new CResult_PaymentFailureReasonDecodeErrorZ in the error state. +pub extern "C" fn CResult_PaymentFailureReasonDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_PaymentFailureReasonDecodeErrorZ { + CResult_PaymentFailureReasonDecodeErrorZ { + contents: CResult_PaymentFailureReasonDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -15254,13 +18592,13 @@ pub extern "C" fn CResult_FundingSignedDecodeErrorZ_err(e: crate::lightning::ln: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_FundingSignedDecodeErrorZ_is_ok(o: &CResult_FundingSignedDecodeErrorZ) -> bool { +pub extern "C" fn CResult_PaymentFailureReasonDecodeErrorZ_is_ok(o: &CResult_PaymentFailureReasonDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_FundingSignedDecodeErrorZ. -pub extern "C" fn CResult_FundingSignedDecodeErrorZ_free(_res: CResult_FundingSignedDecodeErrorZ) { } -impl Drop for CResult_FundingSignedDecodeErrorZ { +/// Frees any resources used by the CResult_PaymentFailureReasonDecodeErrorZ. +pub extern "C" fn CResult_PaymentFailureReasonDecodeErrorZ_free(_res: CResult_PaymentFailureReasonDecodeErrorZ) { } +impl Drop for CResult_PaymentFailureReasonDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -15273,16 +18611,16 @@ impl Drop for CResult_FundingSignedDecodeErrorZ { } } } -impl From> for CResult_FundingSignedDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_PaymentFailureReasonDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_FundingSignedDecodeErrorZPtr { result } + CResult_PaymentFailureReasonDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_FundingSignedDecodeErrorZPtr { err } + CResult_PaymentFailureReasonDecodeErrorZPtr { err } }; Self { contents, @@ -15290,59 +18628,207 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_FundingSignedDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_PaymentFailureReasonDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_FundingSignedDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_PaymentFailureReasonDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_FundingSignedDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_PaymentFailureReasonDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_FundingSignedDecodeErrorZ_clone(orig: &CResult_FundingSignedDecodeErrorZ) -> CResult_FundingSignedDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_PaymentFailureReasonDecodeErrorZ_clone(orig: &CResult_PaymentFailureReasonDecodeErrorZ) -> CResult_PaymentFailureReasonDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +#[derive(Clone)] +/// An enum which can either contain a crate::c_types::U128 or not +pub enum COption_u128Z { + /// When we're in this state, this COption_u128Z contains a crate::c_types::U128 + Some(crate::c_types::U128), + /// When we're in this state, this COption_u128Z contains nothing + None +} +impl COption_u128Z { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::U128 { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_u128Z containing a crate::c_types::U128 +pub extern "C" fn COption_u128Z_some(o: crate::c_types::U128) -> COption_u128Z { + COption_u128Z::Some(o) +} +#[no_mangle] +/// Constructs a new COption_u128Z containing nothing +pub extern "C" fn COption_u128Z_none() -> COption_u128Z { + COption_u128Z::None +} +#[no_mangle] +/// Frees any resources associated with the crate::c_types::U128, if we are in the Some state +pub extern "C" fn COption_u128Z_free(_res: COption_u128Z) { } +#[no_mangle] +/// Creates a new COption_u128Z which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_u128Z_clone(orig: &COption_u128Z) -> COption_u128Z { Clone::clone(&orig) } +#[repr(C)] +#[derive(Clone)] +/// An enum which can either contain a crate::c_types::ThirtyTwoBytes or not +pub enum COption_PaymentIdZ { + /// When we're in this state, this COption_PaymentIdZ contains a crate::c_types::ThirtyTwoBytes + Some(crate::c_types::ThirtyTwoBytes), + /// When we're in this state, this COption_PaymentIdZ contains nothing + None +} +impl COption_PaymentIdZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::ThirtyTwoBytes { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_PaymentIdZ containing a crate::c_types::ThirtyTwoBytes +pub extern "C" fn COption_PaymentIdZ_some(o: crate::c_types::ThirtyTwoBytes) -> COption_PaymentIdZ { + COption_PaymentIdZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_PaymentIdZ containing nothing +pub extern "C" fn COption_PaymentIdZ_none() -> COption_PaymentIdZ { + COption_PaymentIdZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::c_types::ThirtyTwoBytes, if we are in the Some state +pub extern "C" fn COption_PaymentIdZ_free(_res: COption_PaymentIdZ) { } +#[no_mangle] +/// Creates a new COption_PaymentIdZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_PaymentIdZ_clone(orig: &COption_PaymentIdZ) -> COption_PaymentIdZ { Clone::clone(&orig) } +#[repr(C)] +#[derive(Clone)] +/// An enum which can either contain a crate::lightning::events::PaymentFailureReason or not +pub enum COption_PaymentFailureReasonZ { + /// When we're in this state, this COption_PaymentFailureReasonZ contains a crate::lightning::events::PaymentFailureReason + Some(crate::lightning::events::PaymentFailureReason), + /// When we're in this state, this COption_PaymentFailureReasonZ contains nothing + None +} +impl COption_PaymentFailureReasonZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::events::PaymentFailureReason { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_PaymentFailureReasonZ containing a crate::lightning::events::PaymentFailureReason +pub extern "C" fn COption_PaymentFailureReasonZ_some(o: crate::lightning::events::PaymentFailureReason) -> COption_PaymentFailureReasonZ { + COption_PaymentFailureReasonZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_PaymentFailureReasonZ containing nothing +pub extern "C" fn COption_PaymentFailureReasonZ_none() -> COption_PaymentFailureReasonZ { + COption_PaymentFailureReasonZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::lightning::events::PaymentFailureReason, if we are in the Some state +pub extern "C" fn COption_PaymentFailureReasonZ_free(_res: COption_PaymentFailureReasonZ) { } +#[no_mangle] +/// Creates a new COption_PaymentFailureReasonZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_PaymentFailureReasonZ_clone(orig: &COption_PaymentFailureReasonZ) -> COption_PaymentFailureReasonZ { Clone::clone(&orig) } +#[repr(C)] +#[derive(Clone)] +/// An enum which can either contain a crate::lightning::events::Event or not +pub enum COption_EventZ { + /// When we're in this state, this COption_EventZ contains a crate::lightning::events::Event + Some(crate::lightning::events::Event), + /// When we're in this state, this COption_EventZ contains nothing + None +} +impl COption_EventZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::events::Event { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_EventZ containing a crate::lightning::events::Event +pub extern "C" fn COption_EventZ_some(o: crate::lightning::events::Event) -> COption_EventZ { + COption_EventZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_EventZ containing nothing +pub extern "C" fn COption_EventZ_none() -> COption_EventZ { + COption_EventZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::lightning::events::Event, if we are in the Some state +pub extern "C" fn COption_EventZ_free(_res: COption_EventZ) { } +#[no_mangle] +/// Creates a new COption_EventZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_EventZ_clone(orig: &COption_EventZ) -> COption_EventZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_ChannelReadyDecodeErrorZ -pub union CResult_ChannelReadyDecodeErrorZPtr { +/// The contents of CResult_COption_EventZDecodeErrorZ +pub union CResult_COption_EventZDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::ChannelReady, + pub result: *mut crate::c_types::derived::COption_EventZ, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_ChannelReadyDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::ChannelReady on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_COption_EventZDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::COption_EventZ on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ChannelReadyDecodeErrorZ { - /// The contents of this CResult_ChannelReadyDecodeErrorZ, accessible via either +pub struct CResult_COption_EventZDecodeErrorZ { + /// The contents of this CResult_COption_EventZDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ChannelReadyDecodeErrorZPtr, - /// Whether this CResult_ChannelReadyDecodeErrorZ represents a success state. + pub contents: CResult_COption_EventZDecodeErrorZPtr, + /// Whether this CResult_COption_EventZDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ChannelReadyDecodeErrorZ in the success state. -pub extern "C" fn CResult_ChannelReadyDecodeErrorZ_ok(o: crate::lightning::ln::msgs::ChannelReady) -> CResult_ChannelReadyDecodeErrorZ { - CResult_ChannelReadyDecodeErrorZ { - contents: CResult_ChannelReadyDecodeErrorZPtr { +/// Creates a new CResult_COption_EventZDecodeErrorZ in the success state. +pub extern "C" fn CResult_COption_EventZDecodeErrorZ_ok(o: crate::c_types::derived::COption_EventZ) -> CResult_COption_EventZDecodeErrorZ { + CResult_COption_EventZDecodeErrorZ { + contents: CResult_COption_EventZDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ChannelReadyDecodeErrorZ in the error state. -pub extern "C" fn CResult_ChannelReadyDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelReadyDecodeErrorZ { - CResult_ChannelReadyDecodeErrorZ { - contents: CResult_ChannelReadyDecodeErrorZPtr { +/// Creates a new CResult_COption_EventZDecodeErrorZ in the error state. +pub extern "C" fn CResult_COption_EventZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_COption_EventZDecodeErrorZ { + CResult_COption_EventZDecodeErrorZ { + contents: CResult_COption_EventZDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -15350,13 +18836,13 @@ pub extern "C" fn CResult_ChannelReadyDecodeErrorZ_err(e: crate::lightning::ln:: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ChannelReadyDecodeErrorZ_is_ok(o: &CResult_ChannelReadyDecodeErrorZ) -> bool { +pub extern "C" fn CResult_COption_EventZDecodeErrorZ_is_ok(o: &CResult_COption_EventZDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_ChannelReadyDecodeErrorZ. -pub extern "C" fn CResult_ChannelReadyDecodeErrorZ_free(_res: CResult_ChannelReadyDecodeErrorZ) { } -impl Drop for CResult_ChannelReadyDecodeErrorZ { +/// Frees any resources used by the CResult_COption_EventZDecodeErrorZ. +pub extern "C" fn CResult_COption_EventZDecodeErrorZ_free(_res: CResult_COption_EventZDecodeErrorZ) { } +impl Drop for CResult_COption_EventZDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -15369,16 +18855,16 @@ impl Drop for CResult_ChannelReadyDecodeErrorZ { } } } -impl From> for CResult_ChannelReadyDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_COption_EventZDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ChannelReadyDecodeErrorZPtr { result } + CResult_COption_EventZDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ChannelReadyDecodeErrorZPtr { err } + CResult_COption_EventZDecodeErrorZPtr { err } }; Self { contents, @@ -15386,59 +18872,97 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ChannelReadyDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_COption_EventZDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_ChannelReadyDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_COption_EventZDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_ChannelReadyDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_COption_EventZDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ChannelReadyDecodeErrorZ_clone(orig: &CResult_ChannelReadyDecodeErrorZ) -> CResult_ChannelReadyDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_COption_EventZDecodeErrorZ_clone(orig: &CResult_COption_EventZDecodeErrorZ) -> CResult_COption_EventZDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_InitDecodeErrorZ -pub union CResult_InitDecodeErrorZPtr { +/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_BlockHashChannelMonitorZs of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_C2Tuple_BlockHashChannelMonitorZZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::derived::C2Tuple_BlockHashChannelMonitorZ, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_C2Tuple_BlockHashChannelMonitorZZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_BlockHashChannelMonitorZ] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_C2Tuple_BlockHashChannelMonitorZZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_C2Tuple_BlockHashChannelMonitorZZ_free(_res: CVec_C2Tuple_BlockHashChannelMonitorZZ) { } +impl Drop for CVec_C2Tuple_BlockHashChannelMonitorZZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +#[repr(C)] +/// The contents of CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ +pub union CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::Init, + pub result: *mut crate::c_types::derived::CVec_C2Tuple_BlockHashChannelMonitorZZ, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::c_types::IOError, } #[repr(C)] -/// A CResult_InitDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::Init on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::CVec_C2Tuple_BlockHashChannelMonitorZZ on success and a crate::c_types::IOError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_InitDecodeErrorZ { - /// The contents of this CResult_InitDecodeErrorZ, accessible via either +pub struct CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ { + /// The contents of this CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_InitDecodeErrorZPtr, - /// Whether this CResult_InitDecodeErrorZ represents a success state. + pub contents: CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZPtr, + /// Whether this CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_InitDecodeErrorZ in the success state. -pub extern "C" fn CResult_InitDecodeErrorZ_ok(o: crate::lightning::ln::msgs::Init) -> CResult_InitDecodeErrorZ { - CResult_InitDecodeErrorZ { - contents: CResult_InitDecodeErrorZPtr { +/// Creates a new CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ in the success state. +pub extern "C" fn CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(o: crate::c_types::derived::CVec_C2Tuple_BlockHashChannelMonitorZZ) -> CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ { + CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ { + contents: CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_InitDecodeErrorZ in the error state. -pub extern "C" fn CResult_InitDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_InitDecodeErrorZ { - CResult_InitDecodeErrorZ { - contents: CResult_InitDecodeErrorZPtr { +/// Creates a new CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ in the error state. +pub extern "C" fn CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(e: crate::c_types::IOError) -> CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ { + CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ { + contents: CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -15446,13 +18970,13 @@ pub extern "C" fn CResult_InitDecodeErrorZ_err(e: crate::lightning::ln::msgs::De } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_InitDecodeErrorZ_is_ok(o: &CResult_InitDecodeErrorZ) -> bool { +pub extern "C" fn CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_is_ok(o: &CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_InitDecodeErrorZ. -pub extern "C" fn CResult_InitDecodeErrorZ_free(_res: CResult_InitDecodeErrorZ) { } -impl Drop for CResult_InitDecodeErrorZ { +/// Frees any resources used by the CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ. +pub extern "C" fn CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res: CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ) { } +impl Drop for CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -15465,16 +18989,16 @@ impl Drop for CResult_InitDecodeErrorZ { } } } -impl From> for CResult_InitDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_InitDecodeErrorZPtr { result } + CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_InitDecodeErrorZPtr { err } + CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZPtr { err } }; Self { contents, @@ -15482,59 +19006,42 @@ impl From Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_InitDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_InitDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } - } - } -} -#[no_mangle] -/// Creates a new CResult_InitDecodeErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_InitDecodeErrorZ_clone(orig: &CResult_InitDecodeErrorZ) -> CResult_InitDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_OpenChannelDecodeErrorZ -pub union CResult_OpenChannelDecodeErrorZPtr { +/// The contents of CResult_SiPrefixBolt11ParseErrorZ +pub union CResult_SiPrefixBolt11ParseErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::OpenChannel, + pub result: *mut crate::lightning_invoice::SiPrefix, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::lightning_invoice::Bolt11ParseError, } #[repr(C)] -/// A CResult_OpenChannelDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::OpenChannel on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_SiPrefixBolt11ParseErrorZ represents the result of a fallible operation, +/// containing a crate::lightning_invoice::SiPrefix on success and a crate::lightning_invoice::Bolt11ParseError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_OpenChannelDecodeErrorZ { - /// The contents of this CResult_OpenChannelDecodeErrorZ, accessible via either +pub struct CResult_SiPrefixBolt11ParseErrorZ { + /// The contents of this CResult_SiPrefixBolt11ParseErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_OpenChannelDecodeErrorZPtr, - /// Whether this CResult_OpenChannelDecodeErrorZ represents a success state. + pub contents: CResult_SiPrefixBolt11ParseErrorZPtr, + /// Whether this CResult_SiPrefixBolt11ParseErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_OpenChannelDecodeErrorZ in the success state. -pub extern "C" fn CResult_OpenChannelDecodeErrorZ_ok(o: crate::lightning::ln::msgs::OpenChannel) -> CResult_OpenChannelDecodeErrorZ { - CResult_OpenChannelDecodeErrorZ { - contents: CResult_OpenChannelDecodeErrorZPtr { +/// Creates a new CResult_SiPrefixBolt11ParseErrorZ in the success state. +pub extern "C" fn CResult_SiPrefixBolt11ParseErrorZ_ok(o: crate::lightning_invoice::SiPrefix) -> CResult_SiPrefixBolt11ParseErrorZ { + CResult_SiPrefixBolt11ParseErrorZ { + contents: CResult_SiPrefixBolt11ParseErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_OpenChannelDecodeErrorZ in the error state. -pub extern "C" fn CResult_OpenChannelDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_OpenChannelDecodeErrorZ { - CResult_OpenChannelDecodeErrorZ { - contents: CResult_OpenChannelDecodeErrorZPtr { +/// Creates a new CResult_SiPrefixBolt11ParseErrorZ in the error state. +pub extern "C" fn CResult_SiPrefixBolt11ParseErrorZ_err(e: crate::lightning_invoice::Bolt11ParseError) -> CResult_SiPrefixBolt11ParseErrorZ { + CResult_SiPrefixBolt11ParseErrorZ { + contents: CResult_SiPrefixBolt11ParseErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -15542,13 +19049,13 @@ pub extern "C" fn CResult_OpenChannelDecodeErrorZ_err(e: crate::lightning::ln::m } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_OpenChannelDecodeErrorZ_is_ok(o: &CResult_OpenChannelDecodeErrorZ) -> bool { +pub extern "C" fn CResult_SiPrefixBolt11ParseErrorZ_is_ok(o: &CResult_SiPrefixBolt11ParseErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_OpenChannelDecodeErrorZ. -pub extern "C" fn CResult_OpenChannelDecodeErrorZ_free(_res: CResult_OpenChannelDecodeErrorZ) { } -impl Drop for CResult_OpenChannelDecodeErrorZ { +/// Frees any resources used by the CResult_SiPrefixBolt11ParseErrorZ. +pub extern "C" fn CResult_SiPrefixBolt11ParseErrorZ_free(_res: CResult_SiPrefixBolt11ParseErrorZ) { } +impl Drop for CResult_SiPrefixBolt11ParseErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -15561,16 +19068,16 @@ impl Drop for CResult_OpenChannelDecodeErrorZ { } } } -impl From> for CResult_OpenChannelDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_SiPrefixBolt11ParseErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_OpenChannelDecodeErrorZPtr { result } + CResult_SiPrefixBolt11ParseErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_OpenChannelDecodeErrorZPtr { err } + CResult_SiPrefixBolt11ParseErrorZPtr { err } }; Self { contents, @@ -15578,59 +19085,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_OpenChannelDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_SiPrefixBolt11ParseErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_OpenChannelDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_SiPrefixBolt11ParseErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_OpenChannelDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_SiPrefixBolt11ParseErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_OpenChannelDecodeErrorZ_clone(orig: &CResult_OpenChannelDecodeErrorZ) -> CResult_OpenChannelDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_SiPrefixBolt11ParseErrorZ_clone(orig: &CResult_SiPrefixBolt11ParseErrorZ) -> CResult_SiPrefixBolt11ParseErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_RevokeAndACKDecodeErrorZ -pub union CResult_RevokeAndACKDecodeErrorZPtr { +/// The contents of CResult_Bolt11InvoiceParseOrSemanticErrorZ +pub union CResult_Bolt11InvoiceParseOrSemanticErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::RevokeAndACK, + pub result: *mut crate::lightning_invoice::Bolt11Invoice, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::lightning_invoice::ParseOrSemanticError, } #[repr(C)] -/// A CResult_RevokeAndACKDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::RevokeAndACK on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_Bolt11InvoiceParseOrSemanticErrorZ represents the result of a fallible operation, +/// containing a crate::lightning_invoice::Bolt11Invoice on success and a crate::lightning_invoice::ParseOrSemanticError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_RevokeAndACKDecodeErrorZ { - /// The contents of this CResult_RevokeAndACKDecodeErrorZ, accessible via either +pub struct CResult_Bolt11InvoiceParseOrSemanticErrorZ { + /// The contents of this CResult_Bolt11InvoiceParseOrSemanticErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_RevokeAndACKDecodeErrorZPtr, - /// Whether this CResult_RevokeAndACKDecodeErrorZ represents a success state. + pub contents: CResult_Bolt11InvoiceParseOrSemanticErrorZPtr, + /// Whether this CResult_Bolt11InvoiceParseOrSemanticErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_RevokeAndACKDecodeErrorZ in the success state. -pub extern "C" fn CResult_RevokeAndACKDecodeErrorZ_ok(o: crate::lightning::ln::msgs::RevokeAndACK) -> CResult_RevokeAndACKDecodeErrorZ { - CResult_RevokeAndACKDecodeErrorZ { - contents: CResult_RevokeAndACKDecodeErrorZPtr { +/// Creates a new CResult_Bolt11InvoiceParseOrSemanticErrorZ in the success state. +pub extern "C" fn CResult_Bolt11InvoiceParseOrSemanticErrorZ_ok(o: crate::lightning_invoice::Bolt11Invoice) -> CResult_Bolt11InvoiceParseOrSemanticErrorZ { + CResult_Bolt11InvoiceParseOrSemanticErrorZ { + contents: CResult_Bolt11InvoiceParseOrSemanticErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_RevokeAndACKDecodeErrorZ in the error state. -pub extern "C" fn CResult_RevokeAndACKDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_RevokeAndACKDecodeErrorZ { - CResult_RevokeAndACKDecodeErrorZ { - contents: CResult_RevokeAndACKDecodeErrorZPtr { +/// Creates a new CResult_Bolt11InvoiceParseOrSemanticErrorZ in the error state. +pub extern "C" fn CResult_Bolt11InvoiceParseOrSemanticErrorZ_err(e: crate::lightning_invoice::ParseOrSemanticError) -> CResult_Bolt11InvoiceParseOrSemanticErrorZ { + CResult_Bolt11InvoiceParseOrSemanticErrorZ { + contents: CResult_Bolt11InvoiceParseOrSemanticErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -15638,13 +19145,13 @@ pub extern "C" fn CResult_RevokeAndACKDecodeErrorZ_err(e: crate::lightning::ln:: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_RevokeAndACKDecodeErrorZ_is_ok(o: &CResult_RevokeAndACKDecodeErrorZ) -> bool { +pub extern "C" fn CResult_Bolt11InvoiceParseOrSemanticErrorZ_is_ok(o: &CResult_Bolt11InvoiceParseOrSemanticErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_RevokeAndACKDecodeErrorZ. -pub extern "C" fn CResult_RevokeAndACKDecodeErrorZ_free(_res: CResult_RevokeAndACKDecodeErrorZ) { } -impl Drop for CResult_RevokeAndACKDecodeErrorZ { +/// Frees any resources used by the CResult_Bolt11InvoiceParseOrSemanticErrorZ. +pub extern "C" fn CResult_Bolt11InvoiceParseOrSemanticErrorZ_free(_res: CResult_Bolt11InvoiceParseOrSemanticErrorZ) { } +impl Drop for CResult_Bolt11InvoiceParseOrSemanticErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -15657,16 +19164,16 @@ impl Drop for CResult_RevokeAndACKDecodeErrorZ { } } } -impl From> for CResult_RevokeAndACKDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_Bolt11InvoiceParseOrSemanticErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_RevokeAndACKDecodeErrorZPtr { result } + CResult_Bolt11InvoiceParseOrSemanticErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_RevokeAndACKDecodeErrorZPtr { err } + CResult_Bolt11InvoiceParseOrSemanticErrorZPtr { err } }; Self { contents, @@ -15674,59 +19181,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_RevokeAndACKDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_Bolt11InvoiceParseOrSemanticErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_RevokeAndACKDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_Bolt11InvoiceParseOrSemanticErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_RevokeAndACKDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_Bolt11InvoiceParseOrSemanticErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_RevokeAndACKDecodeErrorZ_clone(orig: &CResult_RevokeAndACKDecodeErrorZ) -> CResult_RevokeAndACKDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_Bolt11InvoiceParseOrSemanticErrorZ_clone(orig: &CResult_Bolt11InvoiceParseOrSemanticErrorZ) -> CResult_Bolt11InvoiceParseOrSemanticErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_ShutdownDecodeErrorZ -pub union CResult_ShutdownDecodeErrorZPtr { +/// The contents of CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ +pub union CResult_SignedRawBolt11InvoiceBolt11ParseErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::Shutdown, + pub result: *mut crate::lightning_invoice::SignedRawBolt11Invoice, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::lightning_invoice::Bolt11ParseError, } #[repr(C)] -/// A CResult_ShutdownDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::Shutdown on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ represents the result of a fallible operation, +/// containing a crate::lightning_invoice::SignedRawBolt11Invoice on success and a crate::lightning_invoice::Bolt11ParseError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ShutdownDecodeErrorZ { - /// The contents of this CResult_ShutdownDecodeErrorZ, accessible via either +pub struct CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ { + /// The contents of this CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ShutdownDecodeErrorZPtr, - /// Whether this CResult_ShutdownDecodeErrorZ represents a success state. + pub contents: CResult_SignedRawBolt11InvoiceBolt11ParseErrorZPtr, + /// Whether this CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ represents a success state. pub result_ok: bool, -} -#[no_mangle] -/// Creates a new CResult_ShutdownDecodeErrorZ in the success state. -pub extern "C" fn CResult_ShutdownDecodeErrorZ_ok(o: crate::lightning::ln::msgs::Shutdown) -> CResult_ShutdownDecodeErrorZ { - CResult_ShutdownDecodeErrorZ { - contents: CResult_ShutdownDecodeErrorZPtr { +} +#[no_mangle] +/// Creates a new CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ in the success state. +pub extern "C" fn CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_ok(o: crate::lightning_invoice::SignedRawBolt11Invoice) -> CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ { + CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ { + contents: CResult_SignedRawBolt11InvoiceBolt11ParseErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ShutdownDecodeErrorZ in the error state. -pub extern "C" fn CResult_ShutdownDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ShutdownDecodeErrorZ { - CResult_ShutdownDecodeErrorZ { - contents: CResult_ShutdownDecodeErrorZPtr { +/// Creates a new CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ in the error state. +pub extern "C" fn CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_err(e: crate::lightning_invoice::Bolt11ParseError) -> CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ { + CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ { + contents: CResult_SignedRawBolt11InvoiceBolt11ParseErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -15734,13 +19241,13 @@ pub extern "C" fn CResult_ShutdownDecodeErrorZ_err(e: crate::lightning::ln::msgs } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ShutdownDecodeErrorZ_is_ok(o: &CResult_ShutdownDecodeErrorZ) -> bool { +pub extern "C" fn CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_is_ok(o: &CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_ShutdownDecodeErrorZ. -pub extern "C" fn CResult_ShutdownDecodeErrorZ_free(_res: CResult_ShutdownDecodeErrorZ) { } -impl Drop for CResult_ShutdownDecodeErrorZ { +/// Frees any resources used by the CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ. +pub extern "C" fn CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_free(_res: CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ) { } +impl Drop for CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -15753,16 +19260,16 @@ impl Drop for CResult_ShutdownDecodeErrorZ { } } } -impl From> for CResult_ShutdownDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ShutdownDecodeErrorZPtr { result } + CResult_SignedRawBolt11InvoiceBolt11ParseErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ShutdownDecodeErrorZPtr { err } + CResult_SignedRawBolt11InvoiceBolt11ParseErrorZPtr { err } }; Self { contents, @@ -15770,59 +19277,105 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ShutdownDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_SignedRawBolt11InvoiceBolt11ParseErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_ShutdownDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_SignedRawBolt11InvoiceBolt11ParseErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_ShutdownDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ShutdownDecodeErrorZ_clone(orig: &CResult_ShutdownDecodeErrorZ) -> CResult_ShutdownDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_clone(orig: &CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ) -> CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_UpdateFailHTLCDecodeErrorZ -pub union CResult_UpdateFailHTLCDecodeErrorZPtr { +/// A tuple of 3 elements. See the individual fields for the types contained. +pub struct C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ { + /// The element at position 0 + pub a: crate::lightning_invoice::RawBolt11Invoice, + /// The element at position 1 + pub b: crate::c_types::ThirtyTwoBytes, + /// The element at position 2 + pub c: crate::lightning_invoice::Bolt11InvoiceSignature, +} +impl From<(crate::lightning_invoice::RawBolt11Invoice, crate::c_types::ThirtyTwoBytes, crate::lightning_invoice::Bolt11InvoiceSignature)> for C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ { + fn from (tup: (crate::lightning_invoice::RawBolt11Invoice, crate::c_types::ThirtyTwoBytes, crate::lightning_invoice::Bolt11InvoiceSignature)) -> Self { + Self { + a: tup.0, + b: tup.1, + c: tup.2, + } + } +} +impl C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::lightning_invoice::RawBolt11Invoice, crate::c_types::ThirtyTwoBytes, crate::lightning_invoice::Bolt11InvoiceSignature) { + (self.a, self.b, self.c) + } +} +impl Clone for C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ { + fn clone(&self) -> Self { + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), + c: Clone::clone(&self.c), + } + } +} +#[no_mangle] +/// Creates a new tuple which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ_clone(orig: &C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ) -> C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ { Clone::clone(&orig) } +/// Creates a new C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ from the contained elements. +#[no_mangle] +pub extern "C" fn C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ_new(a: crate::lightning_invoice::RawBolt11Invoice, b: crate::c_types::ThirtyTwoBytes, c: crate::lightning_invoice::Bolt11InvoiceSignature) -> C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ { + C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ { a, b, c, } +} + +#[no_mangle] +/// Frees any resources used by the C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ. +pub extern "C" fn C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ_free(_res: C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ) { } +#[repr(C)] +/// The contents of CResult_PayeePubKeyErrorZ +pub union CResult_PayeePubKeyErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::UpdateFailHTLC, + pub result: *mut crate::lightning_invoice::PayeePubKey, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::c_types::Secp256k1Error, } #[repr(C)] -/// A CResult_UpdateFailHTLCDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::UpdateFailHTLC on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_PayeePubKeyErrorZ represents the result of a fallible operation, +/// containing a crate::lightning_invoice::PayeePubKey on success and a crate::c_types::Secp256k1Error on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_UpdateFailHTLCDecodeErrorZ { - /// The contents of this CResult_UpdateFailHTLCDecodeErrorZ, accessible via either +pub struct CResult_PayeePubKeyErrorZ { + /// The contents of this CResult_PayeePubKeyErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_UpdateFailHTLCDecodeErrorZPtr, - /// Whether this CResult_UpdateFailHTLCDecodeErrorZ represents a success state. + pub contents: CResult_PayeePubKeyErrorZPtr, + /// Whether this CResult_PayeePubKeyErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_UpdateFailHTLCDecodeErrorZ in the success state. -pub extern "C" fn CResult_UpdateFailHTLCDecodeErrorZ_ok(o: crate::lightning::ln::msgs::UpdateFailHTLC) -> CResult_UpdateFailHTLCDecodeErrorZ { - CResult_UpdateFailHTLCDecodeErrorZ { - contents: CResult_UpdateFailHTLCDecodeErrorZPtr { +/// Creates a new CResult_PayeePubKeyErrorZ in the success state. +pub extern "C" fn CResult_PayeePubKeyErrorZ_ok(o: crate::lightning_invoice::PayeePubKey) -> CResult_PayeePubKeyErrorZ { + CResult_PayeePubKeyErrorZ { + contents: CResult_PayeePubKeyErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_UpdateFailHTLCDecodeErrorZ in the error state. -pub extern "C" fn CResult_UpdateFailHTLCDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_UpdateFailHTLCDecodeErrorZ { - CResult_UpdateFailHTLCDecodeErrorZ { - contents: CResult_UpdateFailHTLCDecodeErrorZPtr { +/// Creates a new CResult_PayeePubKeyErrorZ in the error state. +pub extern "C" fn CResult_PayeePubKeyErrorZ_err(e: crate::c_types::Secp256k1Error) -> CResult_PayeePubKeyErrorZ { + CResult_PayeePubKeyErrorZ { + contents: CResult_PayeePubKeyErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -15830,13 +19383,13 @@ pub extern "C" fn CResult_UpdateFailHTLCDecodeErrorZ_err(e: crate::lightning::ln } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_UpdateFailHTLCDecodeErrorZ_is_ok(o: &CResult_UpdateFailHTLCDecodeErrorZ) -> bool { +pub extern "C" fn CResult_PayeePubKeyErrorZ_is_ok(o: &CResult_PayeePubKeyErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_UpdateFailHTLCDecodeErrorZ. -pub extern "C" fn CResult_UpdateFailHTLCDecodeErrorZ_free(_res: CResult_UpdateFailHTLCDecodeErrorZ) { } -impl Drop for CResult_UpdateFailHTLCDecodeErrorZ { +/// Frees any resources used by the CResult_PayeePubKeyErrorZ. +pub extern "C" fn CResult_PayeePubKeyErrorZ_free(_res: CResult_PayeePubKeyErrorZ) { } +impl Drop for CResult_PayeePubKeyErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -15849,16 +19402,16 @@ impl Drop for CResult_UpdateFailHTLCDecodeErrorZ { } } } -impl From> for CResult_UpdateFailHTLCDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_PayeePubKeyErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_UpdateFailHTLCDecodeErrorZPtr { result } + CResult_PayeePubKeyErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_UpdateFailHTLCDecodeErrorZPtr { err } + CResult_PayeePubKeyErrorZPtr { err } }; Self { contents, @@ -15866,59 +19419,105 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_UpdateFailHTLCDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_PayeePubKeyErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_UpdateFailHTLCDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_PayeePubKeyErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_UpdateFailHTLCDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_PayeePubKeyErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_UpdateFailHTLCDecodeErrorZ_clone(orig: &CResult_UpdateFailHTLCDecodeErrorZ) -> CResult_UpdateFailHTLCDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_PayeePubKeyErrorZ_clone(orig: &CResult_PayeePubKeyErrorZ) -> CResult_PayeePubKeyErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_UpdateFailMalformedHTLCDecodeErrorZ -pub union CResult_UpdateFailMalformedHTLCDecodeErrorZPtr { +/// A dynamically-allocated array of crate::lightning_invoice::PrivateRoutes of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_PrivateRouteZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning_invoice::PrivateRoute, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_PrivateRouteZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning_invoice::PrivateRoute] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_PrivateRouteZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_PrivateRouteZ_free(_res: CVec_PrivateRouteZ) { } +impl Drop for CVec_PrivateRouteZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_PrivateRouteZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// The contents of CResult_PositiveTimestampCreationErrorZ +pub union CResult_PositiveTimestampCreationErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::UpdateFailMalformedHTLC, + pub result: *mut crate::lightning_invoice::PositiveTimestamp, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::lightning_invoice::CreationError, } #[repr(C)] -/// A CResult_UpdateFailMalformedHTLCDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::UpdateFailMalformedHTLC on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_PositiveTimestampCreationErrorZ represents the result of a fallible operation, +/// containing a crate::lightning_invoice::PositiveTimestamp on success and a crate::lightning_invoice::CreationError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_UpdateFailMalformedHTLCDecodeErrorZ { - /// The contents of this CResult_UpdateFailMalformedHTLCDecodeErrorZ, accessible via either +pub struct CResult_PositiveTimestampCreationErrorZ { + /// The contents of this CResult_PositiveTimestampCreationErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_UpdateFailMalformedHTLCDecodeErrorZPtr, - /// Whether this CResult_UpdateFailMalformedHTLCDecodeErrorZ represents a success state. + pub contents: CResult_PositiveTimestampCreationErrorZPtr, + /// Whether this CResult_PositiveTimestampCreationErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_UpdateFailMalformedHTLCDecodeErrorZ in the success state. -pub extern "C" fn CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o: crate::lightning::ln::msgs::UpdateFailMalformedHTLC) -> CResult_UpdateFailMalformedHTLCDecodeErrorZ { - CResult_UpdateFailMalformedHTLCDecodeErrorZ { - contents: CResult_UpdateFailMalformedHTLCDecodeErrorZPtr { +/// Creates a new CResult_PositiveTimestampCreationErrorZ in the success state. +pub extern "C" fn CResult_PositiveTimestampCreationErrorZ_ok(o: crate::lightning_invoice::PositiveTimestamp) -> CResult_PositiveTimestampCreationErrorZ { + CResult_PositiveTimestampCreationErrorZ { + contents: CResult_PositiveTimestampCreationErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_UpdateFailMalformedHTLCDecodeErrorZ in the error state. -pub extern "C" fn CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_UpdateFailMalformedHTLCDecodeErrorZ { - CResult_UpdateFailMalformedHTLCDecodeErrorZ { - contents: CResult_UpdateFailMalformedHTLCDecodeErrorZPtr { +/// Creates a new CResult_PositiveTimestampCreationErrorZ in the error state. +pub extern "C" fn CResult_PositiveTimestampCreationErrorZ_err(e: crate::lightning_invoice::CreationError) -> CResult_PositiveTimestampCreationErrorZ { + CResult_PositiveTimestampCreationErrorZ { + contents: CResult_PositiveTimestampCreationErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -15926,13 +19525,13 @@ pub extern "C" fn CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e: crate::ligh } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(o: &CResult_UpdateFailMalformedHTLCDecodeErrorZ) -> bool { +pub extern "C" fn CResult_PositiveTimestampCreationErrorZ_is_ok(o: &CResult_PositiveTimestampCreationErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_UpdateFailMalformedHTLCDecodeErrorZ. -pub extern "C" fn CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res: CResult_UpdateFailMalformedHTLCDecodeErrorZ) { } -impl Drop for CResult_UpdateFailMalformedHTLCDecodeErrorZ { +/// Frees any resources used by the CResult_PositiveTimestampCreationErrorZ. +pub extern "C" fn CResult_PositiveTimestampCreationErrorZ_free(_res: CResult_PositiveTimestampCreationErrorZ) { } +impl Drop for CResult_PositiveTimestampCreationErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -15945,16 +19544,16 @@ impl Drop for CResult_UpdateFailMalformedHTLCDecodeErrorZ { } } } -impl From> for CResult_UpdateFailMalformedHTLCDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_PositiveTimestampCreationErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_UpdateFailMalformedHTLCDecodeErrorZPtr { result } + CResult_PositiveTimestampCreationErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_UpdateFailMalformedHTLCDecodeErrorZPtr { err } + CResult_PositiveTimestampCreationErrorZPtr { err } }; Self { contents, @@ -15962,59 +19561,58 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_UpdateFailMalformedHTLCDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_PositiveTimestampCreationErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_UpdateFailMalformedHTLCDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_PositiveTimestampCreationErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_UpdateFailMalformedHTLCDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_PositiveTimestampCreationErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig: &CResult_UpdateFailMalformedHTLCDecodeErrorZ) -> CResult_UpdateFailMalformedHTLCDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_PositiveTimestampCreationErrorZ_clone(orig: &CResult_PositiveTimestampCreationErrorZ) -> CResult_PositiveTimestampCreationErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_UpdateFeeDecodeErrorZ -pub union CResult_UpdateFeeDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::UpdateFee, +/// The contents of CResult_NoneBolt11SemanticErrorZ +pub union CResult_NoneBolt11SemanticErrorZPtr { + /// Note that this value is always NULL, as there are no contents in the OK variant + pub result: *mut core::ffi::c_void, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::lightning_invoice::Bolt11SemanticError, } #[repr(C)] -/// A CResult_UpdateFeeDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::UpdateFee on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_NoneBolt11SemanticErrorZ represents the result of a fallible operation, +/// containing a () on success and a crate::lightning_invoice::Bolt11SemanticError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_UpdateFeeDecodeErrorZ { - /// The contents of this CResult_UpdateFeeDecodeErrorZ, accessible via either +pub struct CResult_NoneBolt11SemanticErrorZ { + /// The contents of this CResult_NoneBolt11SemanticErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_UpdateFeeDecodeErrorZPtr, - /// Whether this CResult_UpdateFeeDecodeErrorZ represents a success state. + pub contents: CResult_NoneBolt11SemanticErrorZPtr, + /// Whether this CResult_NoneBolt11SemanticErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_UpdateFeeDecodeErrorZ in the success state. -pub extern "C" fn CResult_UpdateFeeDecodeErrorZ_ok(o: crate::lightning::ln::msgs::UpdateFee) -> CResult_UpdateFeeDecodeErrorZ { - CResult_UpdateFeeDecodeErrorZ { - contents: CResult_UpdateFeeDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), +/// Creates a new CResult_NoneBolt11SemanticErrorZ in the success state. +pub extern "C" fn CResult_NoneBolt11SemanticErrorZ_ok() -> CResult_NoneBolt11SemanticErrorZ { + CResult_NoneBolt11SemanticErrorZ { + contents: CResult_NoneBolt11SemanticErrorZPtr { + result: core::ptr::null_mut(), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_UpdateFeeDecodeErrorZ in the error state. -pub extern "C" fn CResult_UpdateFeeDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_UpdateFeeDecodeErrorZ { - CResult_UpdateFeeDecodeErrorZ { - contents: CResult_UpdateFeeDecodeErrorZPtr { +/// Creates a new CResult_NoneBolt11SemanticErrorZ in the error state. +pub extern "C" fn CResult_NoneBolt11SemanticErrorZ_err(e: crate::lightning_invoice::Bolt11SemanticError) -> CResult_NoneBolt11SemanticErrorZ { + CResult_NoneBolt11SemanticErrorZ { + contents: CResult_NoneBolt11SemanticErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -16022,18 +19620,15 @@ pub extern "C" fn CResult_UpdateFeeDecodeErrorZ_err(e: crate::lightning::ln::msg } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_UpdateFeeDecodeErrorZ_is_ok(o: &CResult_UpdateFeeDecodeErrorZ) -> bool { +pub extern "C" fn CResult_NoneBolt11SemanticErrorZ_is_ok(o: &CResult_NoneBolt11SemanticErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_UpdateFeeDecodeErrorZ. -pub extern "C" fn CResult_UpdateFeeDecodeErrorZ_free(_res: CResult_UpdateFeeDecodeErrorZ) { } -impl Drop for CResult_UpdateFeeDecodeErrorZ { +/// Frees any resources used by the CResult_NoneBolt11SemanticErrorZ. +pub extern "C" fn CResult_NoneBolt11SemanticErrorZ_free(_res: CResult_NoneBolt11SemanticErrorZ) { } +impl Drop for CResult_NoneBolt11SemanticErrorZ { fn drop(&mut self) { if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } } else { if unsafe { !(self.contents.err as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.err) }; @@ -16041,16 +19636,16 @@ impl Drop for CResult_UpdateFeeDecodeErrorZ { } } } -impl From> for CResult_UpdateFeeDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_NoneBolt11SemanticErrorZ { + fn from(mut o: crate::c_types::CResultTempl<(), crate::lightning_invoice::Bolt11SemanticError>) -> Self { let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_UpdateFeeDecodeErrorZPtr { result } + let _ = unsafe { Box::from_raw(o.contents.result) }; + o.contents.result = core::ptr::null_mut(); + CResult_NoneBolt11SemanticErrorZPtr { result: core::ptr::null_mut() } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_UpdateFeeDecodeErrorZPtr { err } + CResult_NoneBolt11SemanticErrorZPtr { err } }; Self { contents, @@ -16058,59 +19653,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_UpdateFeeDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_NoneBolt11SemanticErrorZPtr { + result: core::ptr::null_mut() } } } else { - Self { result_ok: false, contents: CResult_UpdateFeeDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_NoneBolt11SemanticErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_UpdateFeeDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_NoneBolt11SemanticErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_UpdateFeeDecodeErrorZ_clone(orig: &CResult_UpdateFeeDecodeErrorZ) -> CResult_UpdateFeeDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_NoneBolt11SemanticErrorZ_clone(orig: &CResult_NoneBolt11SemanticErrorZ) -> CResult_NoneBolt11SemanticErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_UpdateFulfillHTLCDecodeErrorZ -pub union CResult_UpdateFulfillHTLCDecodeErrorZPtr { +/// The contents of CResult_Bolt11InvoiceBolt11SemanticErrorZ +pub union CResult_Bolt11InvoiceBolt11SemanticErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::UpdateFulfillHTLC, + pub result: *mut crate::lightning_invoice::Bolt11Invoice, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::lightning_invoice::Bolt11SemanticError, } #[repr(C)] -/// A CResult_UpdateFulfillHTLCDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::UpdateFulfillHTLC on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_Bolt11InvoiceBolt11SemanticErrorZ represents the result of a fallible operation, +/// containing a crate::lightning_invoice::Bolt11Invoice on success and a crate::lightning_invoice::Bolt11SemanticError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_UpdateFulfillHTLCDecodeErrorZ { - /// The contents of this CResult_UpdateFulfillHTLCDecodeErrorZ, accessible via either +pub struct CResult_Bolt11InvoiceBolt11SemanticErrorZ { + /// The contents of this CResult_Bolt11InvoiceBolt11SemanticErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_UpdateFulfillHTLCDecodeErrorZPtr, - /// Whether this CResult_UpdateFulfillHTLCDecodeErrorZ represents a success state. + pub contents: CResult_Bolt11InvoiceBolt11SemanticErrorZPtr, + /// Whether this CResult_Bolt11InvoiceBolt11SemanticErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_UpdateFulfillHTLCDecodeErrorZ in the success state. -pub extern "C" fn CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o: crate::lightning::ln::msgs::UpdateFulfillHTLC) -> CResult_UpdateFulfillHTLCDecodeErrorZ { - CResult_UpdateFulfillHTLCDecodeErrorZ { - contents: CResult_UpdateFulfillHTLCDecodeErrorZPtr { +/// Creates a new CResult_Bolt11InvoiceBolt11SemanticErrorZ in the success state. +pub extern "C" fn CResult_Bolt11InvoiceBolt11SemanticErrorZ_ok(o: crate::lightning_invoice::Bolt11Invoice) -> CResult_Bolt11InvoiceBolt11SemanticErrorZ { + CResult_Bolt11InvoiceBolt11SemanticErrorZ { + contents: CResult_Bolt11InvoiceBolt11SemanticErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_UpdateFulfillHTLCDecodeErrorZ in the error state. -pub extern "C" fn CResult_UpdateFulfillHTLCDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_UpdateFulfillHTLCDecodeErrorZ { - CResult_UpdateFulfillHTLCDecodeErrorZ { - contents: CResult_UpdateFulfillHTLCDecodeErrorZPtr { +/// Creates a new CResult_Bolt11InvoiceBolt11SemanticErrorZ in the error state. +pub extern "C" fn CResult_Bolt11InvoiceBolt11SemanticErrorZ_err(e: crate::lightning_invoice::Bolt11SemanticError) -> CResult_Bolt11InvoiceBolt11SemanticErrorZ { + CResult_Bolt11InvoiceBolt11SemanticErrorZ { + contents: CResult_Bolt11InvoiceBolt11SemanticErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -16118,13 +19713,13 @@ pub extern "C" fn CResult_UpdateFulfillHTLCDecodeErrorZ_err(e: crate::lightning: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(o: &CResult_UpdateFulfillHTLCDecodeErrorZ) -> bool { +pub extern "C" fn CResult_Bolt11InvoiceBolt11SemanticErrorZ_is_ok(o: &CResult_Bolt11InvoiceBolt11SemanticErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_UpdateFulfillHTLCDecodeErrorZ. -pub extern "C" fn CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res: CResult_UpdateFulfillHTLCDecodeErrorZ) { } -impl Drop for CResult_UpdateFulfillHTLCDecodeErrorZ { +/// Frees any resources used by the CResult_Bolt11InvoiceBolt11SemanticErrorZ. +pub extern "C" fn CResult_Bolt11InvoiceBolt11SemanticErrorZ_free(_res: CResult_Bolt11InvoiceBolt11SemanticErrorZ) { } +impl Drop for CResult_Bolt11InvoiceBolt11SemanticErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -16137,16 +19732,16 @@ impl Drop for CResult_UpdateFulfillHTLCDecodeErrorZ { } } } -impl From> for CResult_UpdateFulfillHTLCDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_Bolt11InvoiceBolt11SemanticErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_UpdateFulfillHTLCDecodeErrorZPtr { result } + CResult_Bolt11InvoiceBolt11SemanticErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_UpdateFulfillHTLCDecodeErrorZPtr { err } + CResult_Bolt11InvoiceBolt11SemanticErrorZPtr { err } }; Self { contents, @@ -16154,59 +19749,105 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_UpdateFulfillHTLCDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_Bolt11InvoiceBolt11SemanticErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_UpdateFulfillHTLCDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_Bolt11InvoiceBolt11SemanticErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_UpdateFulfillHTLCDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_Bolt11InvoiceBolt11SemanticErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig: &CResult_UpdateFulfillHTLCDecodeErrorZ) -> CResult_UpdateFulfillHTLCDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_Bolt11InvoiceBolt11SemanticErrorZ_clone(orig: &CResult_Bolt11InvoiceBolt11SemanticErrorZ) -> CResult_Bolt11InvoiceBolt11SemanticErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_UpdateAddHTLCDecodeErrorZ -pub union CResult_UpdateAddHTLCDecodeErrorZPtr { +/// A dynamically-allocated array of crate::c_types::Strs of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_AddressZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::Str, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_AddressZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::Str] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_AddressZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_AddressZ_free(_res: CVec_AddressZ) { } +impl Drop for CVec_AddressZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_AddressZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// The contents of CResult_DescriptionCreationErrorZ +pub union CResult_DescriptionCreationErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::UpdateAddHTLC, + pub result: *mut crate::lightning_invoice::Description, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::lightning_invoice::CreationError, } #[repr(C)] -/// A CResult_UpdateAddHTLCDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::UpdateAddHTLC on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_DescriptionCreationErrorZ represents the result of a fallible operation, +/// containing a crate::lightning_invoice::Description on success and a crate::lightning_invoice::CreationError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_UpdateAddHTLCDecodeErrorZ { - /// The contents of this CResult_UpdateAddHTLCDecodeErrorZ, accessible via either +pub struct CResult_DescriptionCreationErrorZ { + /// The contents of this CResult_DescriptionCreationErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_UpdateAddHTLCDecodeErrorZPtr, - /// Whether this CResult_UpdateAddHTLCDecodeErrorZ represents a success state. + pub contents: CResult_DescriptionCreationErrorZPtr, + /// Whether this CResult_DescriptionCreationErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_UpdateAddHTLCDecodeErrorZ in the success state. -pub extern "C" fn CResult_UpdateAddHTLCDecodeErrorZ_ok(o: crate::lightning::ln::msgs::UpdateAddHTLC) -> CResult_UpdateAddHTLCDecodeErrorZ { - CResult_UpdateAddHTLCDecodeErrorZ { - contents: CResult_UpdateAddHTLCDecodeErrorZPtr { +/// Creates a new CResult_DescriptionCreationErrorZ in the success state. +pub extern "C" fn CResult_DescriptionCreationErrorZ_ok(o: crate::lightning_invoice::Description) -> CResult_DescriptionCreationErrorZ { + CResult_DescriptionCreationErrorZ { + contents: CResult_DescriptionCreationErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_UpdateAddHTLCDecodeErrorZ in the error state. -pub extern "C" fn CResult_UpdateAddHTLCDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_UpdateAddHTLCDecodeErrorZ { - CResult_UpdateAddHTLCDecodeErrorZ { - contents: CResult_UpdateAddHTLCDecodeErrorZPtr { +/// Creates a new CResult_DescriptionCreationErrorZ in the error state. +pub extern "C" fn CResult_DescriptionCreationErrorZ_err(e: crate::lightning_invoice::CreationError) -> CResult_DescriptionCreationErrorZ { + CResult_DescriptionCreationErrorZ { + contents: CResult_DescriptionCreationErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -16214,13 +19855,13 @@ pub extern "C" fn CResult_UpdateAddHTLCDecodeErrorZ_err(e: crate::lightning::ln: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_UpdateAddHTLCDecodeErrorZ_is_ok(o: &CResult_UpdateAddHTLCDecodeErrorZ) -> bool { +pub extern "C" fn CResult_DescriptionCreationErrorZ_is_ok(o: &CResult_DescriptionCreationErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_UpdateAddHTLCDecodeErrorZ. -pub extern "C" fn CResult_UpdateAddHTLCDecodeErrorZ_free(_res: CResult_UpdateAddHTLCDecodeErrorZ) { } -impl Drop for CResult_UpdateAddHTLCDecodeErrorZ { +/// Frees any resources used by the CResult_DescriptionCreationErrorZ. +pub extern "C" fn CResult_DescriptionCreationErrorZ_free(_res: CResult_DescriptionCreationErrorZ) { } +impl Drop for CResult_DescriptionCreationErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -16233,16 +19874,16 @@ impl Drop for CResult_UpdateAddHTLCDecodeErrorZ { } } } -impl From> for CResult_UpdateAddHTLCDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_DescriptionCreationErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_UpdateAddHTLCDecodeErrorZPtr { result } + CResult_DescriptionCreationErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_UpdateAddHTLCDecodeErrorZPtr { err } + CResult_DescriptionCreationErrorZPtr { err } }; Self { contents, @@ -16250,59 +19891,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_UpdateAddHTLCDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_DescriptionCreationErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_UpdateAddHTLCDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_DescriptionCreationErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_UpdateAddHTLCDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_DescriptionCreationErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_UpdateAddHTLCDecodeErrorZ_clone(orig: &CResult_UpdateAddHTLCDecodeErrorZ) -> CResult_UpdateAddHTLCDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_DescriptionCreationErrorZ_clone(orig: &CResult_DescriptionCreationErrorZ) -> CResult_DescriptionCreationErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_OnionMessageDecodeErrorZ -pub union CResult_OnionMessageDecodeErrorZPtr { +/// The contents of CResult_PrivateRouteCreationErrorZ +pub union CResult_PrivateRouteCreationErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::OnionMessage, + pub result: *mut crate::lightning_invoice::PrivateRoute, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::lightning_invoice::CreationError, } #[repr(C)] -/// A CResult_OnionMessageDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::OnionMessage on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_PrivateRouteCreationErrorZ represents the result of a fallible operation, +/// containing a crate::lightning_invoice::PrivateRoute on success and a crate::lightning_invoice::CreationError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_OnionMessageDecodeErrorZ { - /// The contents of this CResult_OnionMessageDecodeErrorZ, accessible via either +pub struct CResult_PrivateRouteCreationErrorZ { + /// The contents of this CResult_PrivateRouteCreationErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_OnionMessageDecodeErrorZPtr, - /// Whether this CResult_OnionMessageDecodeErrorZ represents a success state. + pub contents: CResult_PrivateRouteCreationErrorZPtr, + /// Whether this CResult_PrivateRouteCreationErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_OnionMessageDecodeErrorZ in the success state. -pub extern "C" fn CResult_OnionMessageDecodeErrorZ_ok(o: crate::lightning::ln::msgs::OnionMessage) -> CResult_OnionMessageDecodeErrorZ { - CResult_OnionMessageDecodeErrorZ { - contents: CResult_OnionMessageDecodeErrorZPtr { +/// Creates a new CResult_PrivateRouteCreationErrorZ in the success state. +pub extern "C" fn CResult_PrivateRouteCreationErrorZ_ok(o: crate::lightning_invoice::PrivateRoute) -> CResult_PrivateRouteCreationErrorZ { + CResult_PrivateRouteCreationErrorZ { + contents: CResult_PrivateRouteCreationErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_OnionMessageDecodeErrorZ in the error state. -pub extern "C" fn CResult_OnionMessageDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_OnionMessageDecodeErrorZ { - CResult_OnionMessageDecodeErrorZ { - contents: CResult_OnionMessageDecodeErrorZPtr { +/// Creates a new CResult_PrivateRouteCreationErrorZ in the error state. +pub extern "C" fn CResult_PrivateRouteCreationErrorZ_err(e: crate::lightning_invoice::CreationError) -> CResult_PrivateRouteCreationErrorZ { + CResult_PrivateRouteCreationErrorZ { + contents: CResult_PrivateRouteCreationErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -16310,13 +19951,13 @@ pub extern "C" fn CResult_OnionMessageDecodeErrorZ_err(e: crate::lightning::ln:: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_OnionMessageDecodeErrorZ_is_ok(o: &CResult_OnionMessageDecodeErrorZ) -> bool { +pub extern "C" fn CResult_PrivateRouteCreationErrorZ_is_ok(o: &CResult_PrivateRouteCreationErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_OnionMessageDecodeErrorZ. -pub extern "C" fn CResult_OnionMessageDecodeErrorZ_free(_res: CResult_OnionMessageDecodeErrorZ) { } -impl Drop for CResult_OnionMessageDecodeErrorZ { +/// Frees any resources used by the CResult_PrivateRouteCreationErrorZ. +pub extern "C" fn CResult_PrivateRouteCreationErrorZ_free(_res: CResult_PrivateRouteCreationErrorZ) { } +impl Drop for CResult_PrivateRouteCreationErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -16329,16 +19970,16 @@ impl Drop for CResult_OnionMessageDecodeErrorZ { } } } -impl From> for CResult_OnionMessageDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_PrivateRouteCreationErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_OnionMessageDecodeErrorZPtr { result } + CResult_PrivateRouteCreationErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_OnionMessageDecodeErrorZPtr { err } + CResult_PrivateRouteCreationErrorZPtr { err } }; Self { contents, @@ -16346,59 +19987,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_OnionMessageDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_PrivateRouteCreationErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_OnionMessageDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_PrivateRouteCreationErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_OnionMessageDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_PrivateRouteCreationErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_OnionMessageDecodeErrorZ_clone(orig: &CResult_OnionMessageDecodeErrorZ) -> CResult_OnionMessageDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_PrivateRouteCreationErrorZ_clone(orig: &CResult_PrivateRouteCreationErrorZ) -> CResult_PrivateRouteCreationErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_PingDecodeErrorZ -pub union CResult_PingDecodeErrorZPtr { +/// The contents of CResult_OutPointDecodeErrorZ +pub union CResult_OutPointDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::Ping, + pub result: *mut crate::lightning::chain::transaction::OutPoint, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_PingDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::Ping on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_OutPointDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::chain::transaction::OutPoint on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_PingDecodeErrorZ { - /// The contents of this CResult_PingDecodeErrorZ, accessible via either +pub struct CResult_OutPointDecodeErrorZ { + /// The contents of this CResult_OutPointDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_PingDecodeErrorZPtr, - /// Whether this CResult_PingDecodeErrorZ represents a success state. + pub contents: CResult_OutPointDecodeErrorZPtr, + /// Whether this CResult_OutPointDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_PingDecodeErrorZ in the success state. -pub extern "C" fn CResult_PingDecodeErrorZ_ok(o: crate::lightning::ln::msgs::Ping) -> CResult_PingDecodeErrorZ { - CResult_PingDecodeErrorZ { - contents: CResult_PingDecodeErrorZPtr { +/// Creates a new CResult_OutPointDecodeErrorZ in the success state. +pub extern "C" fn CResult_OutPointDecodeErrorZ_ok(o: crate::lightning::chain::transaction::OutPoint) -> CResult_OutPointDecodeErrorZ { + CResult_OutPointDecodeErrorZ { + contents: CResult_OutPointDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_PingDecodeErrorZ in the error state. -pub extern "C" fn CResult_PingDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_PingDecodeErrorZ { - CResult_PingDecodeErrorZ { - contents: CResult_PingDecodeErrorZPtr { +/// Creates a new CResult_OutPointDecodeErrorZ in the error state. +pub extern "C" fn CResult_OutPointDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_OutPointDecodeErrorZ { + CResult_OutPointDecodeErrorZ { + contents: CResult_OutPointDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -16406,13 +20047,13 @@ pub extern "C" fn CResult_PingDecodeErrorZ_err(e: crate::lightning::ln::msgs::De } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_PingDecodeErrorZ_is_ok(o: &CResult_PingDecodeErrorZ) -> bool { +pub extern "C" fn CResult_OutPointDecodeErrorZ_is_ok(o: &CResult_OutPointDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_PingDecodeErrorZ. -pub extern "C" fn CResult_PingDecodeErrorZ_free(_res: CResult_PingDecodeErrorZ) { } -impl Drop for CResult_PingDecodeErrorZ { +/// Frees any resources used by the CResult_OutPointDecodeErrorZ. +pub extern "C" fn CResult_OutPointDecodeErrorZ_free(_res: CResult_OutPointDecodeErrorZ) { } +impl Drop for CResult_OutPointDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -16425,16 +20066,16 @@ impl Drop for CResult_PingDecodeErrorZ { } } } -impl From> for CResult_PingDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_OutPointDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_PingDecodeErrorZPtr { result } + CResult_OutPointDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_PingDecodeErrorZPtr { err } + CResult_OutPointDecodeErrorZPtr { err } }; Self { contents, @@ -16442,59 +20083,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_PingDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_OutPointDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_PingDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_OutPointDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_PingDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_OutPointDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_PingDecodeErrorZ_clone(orig: &CResult_PingDecodeErrorZ) -> CResult_PingDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_OutPointDecodeErrorZ_clone(orig: &CResult_OutPointDecodeErrorZ) -> CResult_OutPointDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_PongDecodeErrorZ -pub union CResult_PongDecodeErrorZPtr { +/// The contents of CResult_BigSizeDecodeErrorZ +pub union CResult_BigSizeDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::Pong, + pub result: *mut crate::lightning::util::ser::BigSize, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_PongDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::Pong on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_BigSizeDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::util::ser::BigSize on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_PongDecodeErrorZ { - /// The contents of this CResult_PongDecodeErrorZ, accessible via either +pub struct CResult_BigSizeDecodeErrorZ { + /// The contents of this CResult_BigSizeDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_PongDecodeErrorZPtr, - /// Whether this CResult_PongDecodeErrorZ represents a success state. + pub contents: CResult_BigSizeDecodeErrorZPtr, + /// Whether this CResult_BigSizeDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_PongDecodeErrorZ in the success state. -pub extern "C" fn CResult_PongDecodeErrorZ_ok(o: crate::lightning::ln::msgs::Pong) -> CResult_PongDecodeErrorZ { - CResult_PongDecodeErrorZ { - contents: CResult_PongDecodeErrorZPtr { +/// Creates a new CResult_BigSizeDecodeErrorZ in the success state. +pub extern "C" fn CResult_BigSizeDecodeErrorZ_ok(o: crate::lightning::util::ser::BigSize) -> CResult_BigSizeDecodeErrorZ { + CResult_BigSizeDecodeErrorZ { + contents: CResult_BigSizeDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_PongDecodeErrorZ in the error state. -pub extern "C" fn CResult_PongDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_PongDecodeErrorZ { - CResult_PongDecodeErrorZ { - contents: CResult_PongDecodeErrorZPtr { +/// Creates a new CResult_BigSizeDecodeErrorZ in the error state. +pub extern "C" fn CResult_BigSizeDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_BigSizeDecodeErrorZ { + CResult_BigSizeDecodeErrorZ { + contents: CResult_BigSizeDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -16502,13 +20143,13 @@ pub extern "C" fn CResult_PongDecodeErrorZ_err(e: crate::lightning::ln::msgs::De } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_PongDecodeErrorZ_is_ok(o: &CResult_PongDecodeErrorZ) -> bool { +pub extern "C" fn CResult_BigSizeDecodeErrorZ_is_ok(o: &CResult_BigSizeDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_PongDecodeErrorZ. -pub extern "C" fn CResult_PongDecodeErrorZ_free(_res: CResult_PongDecodeErrorZ) { } -impl Drop for CResult_PongDecodeErrorZ { +/// Frees any resources used by the CResult_BigSizeDecodeErrorZ. +pub extern "C" fn CResult_BigSizeDecodeErrorZ_free(_res: CResult_BigSizeDecodeErrorZ) { } +impl Drop for CResult_BigSizeDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -16521,16 +20162,16 @@ impl Drop for CResult_PongDecodeErrorZ { } } } -impl From> for CResult_PongDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_BigSizeDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_PongDecodeErrorZPtr { result } + CResult_BigSizeDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_PongDecodeErrorZPtr { err } + CResult_BigSizeDecodeErrorZPtr { err } }; Self { contents, @@ -16538,59 +20179,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_PongDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_BigSizeDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_PongDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_BigSizeDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_PongDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_BigSizeDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_PongDecodeErrorZ_clone(orig: &CResult_PongDecodeErrorZ) -> CResult_PongDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_BigSizeDecodeErrorZ_clone(orig: &CResult_BigSizeDecodeErrorZ) -> CResult_BigSizeDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_UnsignedChannelAnnouncementDecodeErrorZ -pub union CResult_UnsignedChannelAnnouncementDecodeErrorZPtr { +/// The contents of CResult_HostnameDecodeErrorZ +pub union CResult_HostnameDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::UnsignedChannelAnnouncement, + pub result: *mut crate::lightning::util::ser::Hostname, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_UnsignedChannelAnnouncementDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::UnsignedChannelAnnouncement on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_HostnameDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::util::ser::Hostname on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_UnsignedChannelAnnouncementDecodeErrorZ { - /// The contents of this CResult_UnsignedChannelAnnouncementDecodeErrorZ, accessible via either +pub struct CResult_HostnameDecodeErrorZ { + /// The contents of this CResult_HostnameDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_UnsignedChannelAnnouncementDecodeErrorZPtr, - /// Whether this CResult_UnsignedChannelAnnouncementDecodeErrorZ represents a success state. + pub contents: CResult_HostnameDecodeErrorZPtr, + /// Whether this CResult_HostnameDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_UnsignedChannelAnnouncementDecodeErrorZ in the success state. -pub extern "C" fn CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o: crate::lightning::ln::msgs::UnsignedChannelAnnouncement) -> CResult_UnsignedChannelAnnouncementDecodeErrorZ { - CResult_UnsignedChannelAnnouncementDecodeErrorZ { - contents: CResult_UnsignedChannelAnnouncementDecodeErrorZPtr { +/// Creates a new CResult_HostnameDecodeErrorZ in the success state. +pub extern "C" fn CResult_HostnameDecodeErrorZ_ok(o: crate::lightning::util::ser::Hostname) -> CResult_HostnameDecodeErrorZ { + CResult_HostnameDecodeErrorZ { + contents: CResult_HostnameDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_UnsignedChannelAnnouncementDecodeErrorZ in the error state. -pub extern "C" fn CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_UnsignedChannelAnnouncementDecodeErrorZ { - CResult_UnsignedChannelAnnouncementDecodeErrorZ { - contents: CResult_UnsignedChannelAnnouncementDecodeErrorZPtr { +/// Creates a new CResult_HostnameDecodeErrorZ in the error state. +pub extern "C" fn CResult_HostnameDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_HostnameDecodeErrorZ { + CResult_HostnameDecodeErrorZ { + contents: CResult_HostnameDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -16598,13 +20239,13 @@ pub extern "C" fn CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e: crate:: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(o: &CResult_UnsignedChannelAnnouncementDecodeErrorZ) -> bool { +pub extern "C" fn CResult_HostnameDecodeErrorZ_is_ok(o: &CResult_HostnameDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_UnsignedChannelAnnouncementDecodeErrorZ. -pub extern "C" fn CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res: CResult_UnsignedChannelAnnouncementDecodeErrorZ) { } -impl Drop for CResult_UnsignedChannelAnnouncementDecodeErrorZ { +/// Frees any resources used by the CResult_HostnameDecodeErrorZ. +pub extern "C" fn CResult_HostnameDecodeErrorZ_free(_res: CResult_HostnameDecodeErrorZ) { } +impl Drop for CResult_HostnameDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -16617,16 +20258,16 @@ impl Drop for CResult_UnsignedChannelAnnouncementDecodeErrorZ { } } } -impl From> for CResult_UnsignedChannelAnnouncementDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_HostnameDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_UnsignedChannelAnnouncementDecodeErrorZPtr { result } + CResult_HostnameDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_UnsignedChannelAnnouncementDecodeErrorZPtr { err } + CResult_HostnameDecodeErrorZPtr { err } }; Self { contents, @@ -16634,95 +20275,91 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_UnsignedChannelAnnouncementDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_HostnameDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_UnsignedChannelAnnouncementDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_HostnameDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_UnsignedChannelAnnouncementDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_HostnameDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig: &CResult_UnsignedChannelAnnouncementDecodeErrorZ) -> CResult_UnsignedChannelAnnouncementDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_HostnameDecodeErrorZ_clone(orig: &CResult_HostnameDecodeErrorZ) -> CResult_HostnameDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_ChannelAnnouncementDecodeErrorZ -pub union CResult_ChannelAnnouncementDecodeErrorZPtr { +/// The contents of CResult_TransactionU16LenLimitedNoneZ +pub union CResult_TransactionU16LenLimitedNoneZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::ChannelAnnouncement, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub result: *mut crate::lightning::util::ser::TransactionU16LenLimited, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut core::ffi::c_void, } #[repr(C)] -/// A CResult_ChannelAnnouncementDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::ChannelAnnouncement on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_TransactionU16LenLimitedNoneZ represents the result of a fallible operation, +/// containing a crate::lightning::util::ser::TransactionU16LenLimited on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ChannelAnnouncementDecodeErrorZ { - /// The contents of this CResult_ChannelAnnouncementDecodeErrorZ, accessible via either +pub struct CResult_TransactionU16LenLimitedNoneZ { + /// The contents of this CResult_TransactionU16LenLimitedNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ChannelAnnouncementDecodeErrorZPtr, - /// Whether this CResult_ChannelAnnouncementDecodeErrorZ represents a success state. + pub contents: CResult_TransactionU16LenLimitedNoneZPtr, + /// Whether this CResult_TransactionU16LenLimitedNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ChannelAnnouncementDecodeErrorZ in the success state. -pub extern "C" fn CResult_ChannelAnnouncementDecodeErrorZ_ok(o: crate::lightning::ln::msgs::ChannelAnnouncement) -> CResult_ChannelAnnouncementDecodeErrorZ { - CResult_ChannelAnnouncementDecodeErrorZ { - contents: CResult_ChannelAnnouncementDecodeErrorZPtr { +/// Creates a new CResult_TransactionU16LenLimitedNoneZ in the success state. +pub extern "C" fn CResult_TransactionU16LenLimitedNoneZ_ok(o: crate::lightning::util::ser::TransactionU16LenLimited) -> CResult_TransactionU16LenLimitedNoneZ { + CResult_TransactionU16LenLimitedNoneZ { + contents: CResult_TransactionU16LenLimitedNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ChannelAnnouncementDecodeErrorZ in the error state. -pub extern "C" fn CResult_ChannelAnnouncementDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelAnnouncementDecodeErrorZ { - CResult_ChannelAnnouncementDecodeErrorZ { - contents: CResult_ChannelAnnouncementDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), +/// Creates a new CResult_TransactionU16LenLimitedNoneZ in the error state. +pub extern "C" fn CResult_TransactionU16LenLimitedNoneZ_err() -> CResult_TransactionU16LenLimitedNoneZ { + CResult_TransactionU16LenLimitedNoneZ { + contents: CResult_TransactionU16LenLimitedNoneZPtr { + err: core::ptr::null_mut(), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ChannelAnnouncementDecodeErrorZ_is_ok(o: &CResult_ChannelAnnouncementDecodeErrorZ) -> bool { +pub extern "C" fn CResult_TransactionU16LenLimitedNoneZ_is_ok(o: &CResult_TransactionU16LenLimitedNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_ChannelAnnouncementDecodeErrorZ. -pub extern "C" fn CResult_ChannelAnnouncementDecodeErrorZ_free(_res: CResult_ChannelAnnouncementDecodeErrorZ) { } -impl Drop for CResult_ChannelAnnouncementDecodeErrorZ { +/// Frees any resources used by the CResult_TransactionU16LenLimitedNoneZ. +pub extern "C" fn CResult_TransactionU16LenLimitedNoneZ_free(_res: CResult_TransactionU16LenLimitedNoneZ) { } +impl Drop for CResult_TransactionU16LenLimitedNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } } } } -impl From> for CResult_ChannelAnnouncementDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_TransactionU16LenLimitedNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ChannelAnnouncementDecodeErrorZPtr { result } + CResult_TransactionU16LenLimitedNoneZPtr { result } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ChannelAnnouncementDecodeErrorZPtr { err } + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_TransactionU16LenLimitedNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -16730,59 +20367,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ChannelAnnouncementDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_TransactionU16LenLimitedNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_ChannelAnnouncementDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_TransactionU16LenLimitedNoneZPtr { + err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_ChannelAnnouncementDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_TransactionU16LenLimitedNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ChannelAnnouncementDecodeErrorZ_clone(orig: &CResult_ChannelAnnouncementDecodeErrorZ) -> CResult_ChannelAnnouncementDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_TransactionU16LenLimitedNoneZ_clone(orig: &CResult_TransactionU16LenLimitedNoneZ) -> CResult_TransactionU16LenLimitedNoneZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_UnsignedChannelUpdateDecodeErrorZ -pub union CResult_UnsignedChannelUpdateDecodeErrorZPtr { +/// The contents of CResult_TransactionU16LenLimitedDecodeErrorZ +pub union CResult_TransactionU16LenLimitedDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::UnsignedChannelUpdate, + pub result: *mut crate::lightning::util::ser::TransactionU16LenLimited, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_UnsignedChannelUpdateDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::UnsignedChannelUpdate on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_TransactionU16LenLimitedDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::util::ser::TransactionU16LenLimited on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_UnsignedChannelUpdateDecodeErrorZ { - /// The contents of this CResult_UnsignedChannelUpdateDecodeErrorZ, accessible via either +pub struct CResult_TransactionU16LenLimitedDecodeErrorZ { + /// The contents of this CResult_TransactionU16LenLimitedDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_UnsignedChannelUpdateDecodeErrorZPtr, - /// Whether this CResult_UnsignedChannelUpdateDecodeErrorZ represents a success state. + pub contents: CResult_TransactionU16LenLimitedDecodeErrorZPtr, + /// Whether this CResult_TransactionU16LenLimitedDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_UnsignedChannelUpdateDecodeErrorZ in the success state. -pub extern "C" fn CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o: crate::lightning::ln::msgs::UnsignedChannelUpdate) -> CResult_UnsignedChannelUpdateDecodeErrorZ { - CResult_UnsignedChannelUpdateDecodeErrorZ { - contents: CResult_UnsignedChannelUpdateDecodeErrorZPtr { +/// Creates a new CResult_TransactionU16LenLimitedDecodeErrorZ in the success state. +pub extern "C" fn CResult_TransactionU16LenLimitedDecodeErrorZ_ok(o: crate::lightning::util::ser::TransactionU16LenLimited) -> CResult_TransactionU16LenLimitedDecodeErrorZ { + CResult_TransactionU16LenLimitedDecodeErrorZ { + contents: CResult_TransactionU16LenLimitedDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_UnsignedChannelUpdateDecodeErrorZ in the error state. -pub extern "C" fn CResult_UnsignedChannelUpdateDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_UnsignedChannelUpdateDecodeErrorZ { - CResult_UnsignedChannelUpdateDecodeErrorZ { - contents: CResult_UnsignedChannelUpdateDecodeErrorZPtr { +/// Creates a new CResult_TransactionU16LenLimitedDecodeErrorZ in the error state. +pub extern "C" fn CResult_TransactionU16LenLimitedDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_TransactionU16LenLimitedDecodeErrorZ { + CResult_TransactionU16LenLimitedDecodeErrorZ { + contents: CResult_TransactionU16LenLimitedDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -16790,13 +20427,13 @@ pub extern "C" fn CResult_UnsignedChannelUpdateDecodeErrorZ_err(e: crate::lightn } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(o: &CResult_UnsignedChannelUpdateDecodeErrorZ) -> bool { +pub extern "C" fn CResult_TransactionU16LenLimitedDecodeErrorZ_is_ok(o: &CResult_TransactionU16LenLimitedDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_UnsignedChannelUpdateDecodeErrorZ. -pub extern "C" fn CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res: CResult_UnsignedChannelUpdateDecodeErrorZ) { } -impl Drop for CResult_UnsignedChannelUpdateDecodeErrorZ { +/// Frees any resources used by the CResult_TransactionU16LenLimitedDecodeErrorZ. +pub extern "C" fn CResult_TransactionU16LenLimitedDecodeErrorZ_free(_res: CResult_TransactionU16LenLimitedDecodeErrorZ) { } +impl Drop for CResult_TransactionU16LenLimitedDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -16809,16 +20446,16 @@ impl Drop for CResult_UnsignedChannelUpdateDecodeErrorZ { } } } -impl From> for CResult_UnsignedChannelUpdateDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_TransactionU16LenLimitedDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_UnsignedChannelUpdateDecodeErrorZPtr { result } + CResult_TransactionU16LenLimitedDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_UnsignedChannelUpdateDecodeErrorZPtr { err } + CResult_TransactionU16LenLimitedDecodeErrorZPtr { err } }; Self { contents, @@ -16826,59 +20463,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_UnsignedChannelUpdateDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_TransactionU16LenLimitedDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_UnsignedChannelUpdateDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_TransactionU16LenLimitedDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_UnsignedChannelUpdateDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_TransactionU16LenLimitedDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig: &CResult_UnsignedChannelUpdateDecodeErrorZ) -> CResult_UnsignedChannelUpdateDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_TransactionU16LenLimitedDecodeErrorZ_clone(orig: &CResult_TransactionU16LenLimitedDecodeErrorZ) -> CResult_TransactionU16LenLimitedDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_ChannelUpdateDecodeErrorZ -pub union CResult_ChannelUpdateDecodeErrorZPtr { +/// The contents of CResult_UntrustedStringDecodeErrorZ +pub union CResult_UntrustedStringDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::ChannelUpdate, + pub result: *mut crate::lightning::util::string::UntrustedString, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_ChannelUpdateDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::ChannelUpdate on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_UntrustedStringDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::util::string::UntrustedString on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ChannelUpdateDecodeErrorZ { - /// The contents of this CResult_ChannelUpdateDecodeErrorZ, accessible via either +pub struct CResult_UntrustedStringDecodeErrorZ { + /// The contents of this CResult_UntrustedStringDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ChannelUpdateDecodeErrorZPtr, - /// Whether this CResult_ChannelUpdateDecodeErrorZ represents a success state. + pub contents: CResult_UntrustedStringDecodeErrorZPtr, + /// Whether this CResult_UntrustedStringDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ChannelUpdateDecodeErrorZ in the success state. -pub extern "C" fn CResult_ChannelUpdateDecodeErrorZ_ok(o: crate::lightning::ln::msgs::ChannelUpdate) -> CResult_ChannelUpdateDecodeErrorZ { - CResult_ChannelUpdateDecodeErrorZ { - contents: CResult_ChannelUpdateDecodeErrorZPtr { +/// Creates a new CResult_UntrustedStringDecodeErrorZ in the success state. +pub extern "C" fn CResult_UntrustedStringDecodeErrorZ_ok(o: crate::lightning::util::string::UntrustedString) -> CResult_UntrustedStringDecodeErrorZ { + CResult_UntrustedStringDecodeErrorZ { + contents: CResult_UntrustedStringDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ChannelUpdateDecodeErrorZ in the error state. -pub extern "C" fn CResult_ChannelUpdateDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelUpdateDecodeErrorZ { - CResult_ChannelUpdateDecodeErrorZ { - contents: CResult_ChannelUpdateDecodeErrorZPtr { +/// Creates a new CResult_UntrustedStringDecodeErrorZ in the error state. +pub extern "C" fn CResult_UntrustedStringDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_UntrustedStringDecodeErrorZ { + CResult_UntrustedStringDecodeErrorZ { + contents: CResult_UntrustedStringDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -16886,13 +20523,13 @@ pub extern "C" fn CResult_ChannelUpdateDecodeErrorZ_err(e: crate::lightning::ln: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ChannelUpdateDecodeErrorZ_is_ok(o: &CResult_ChannelUpdateDecodeErrorZ) -> bool { +pub extern "C" fn CResult_UntrustedStringDecodeErrorZ_is_ok(o: &CResult_UntrustedStringDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_ChannelUpdateDecodeErrorZ. -pub extern "C" fn CResult_ChannelUpdateDecodeErrorZ_free(_res: CResult_ChannelUpdateDecodeErrorZ) { } -impl Drop for CResult_ChannelUpdateDecodeErrorZ { +/// Frees any resources used by the CResult_UntrustedStringDecodeErrorZ. +pub extern "C" fn CResult_UntrustedStringDecodeErrorZ_free(_res: CResult_UntrustedStringDecodeErrorZ) { } +impl Drop for CResult_UntrustedStringDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -16905,16 +20542,16 @@ impl Drop for CResult_ChannelUpdateDecodeErrorZ { } } } -impl From> for CResult_ChannelUpdateDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_UntrustedStringDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ChannelUpdateDecodeErrorZPtr { result } + CResult_UntrustedStringDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ChannelUpdateDecodeErrorZPtr { err } + CResult_UntrustedStringDecodeErrorZPtr { err } }; Self { contents, @@ -16922,59 +20559,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ChannelUpdateDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_UntrustedStringDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_ChannelUpdateDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_UntrustedStringDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_ChannelUpdateDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_UntrustedStringDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ChannelUpdateDecodeErrorZ_clone(orig: &CResult_ChannelUpdateDecodeErrorZ) -> CResult_ChannelUpdateDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_UntrustedStringDecodeErrorZ_clone(orig: &CResult_UntrustedStringDecodeErrorZ) -> CResult_UntrustedStringDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_ErrorMessageDecodeErrorZ -pub union CResult_ErrorMessageDecodeErrorZPtr { +/// The contents of CResult_PaymentIdPaymentErrorZ +pub union CResult_PaymentIdPaymentErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::ErrorMessage, + pub result: *mut crate::c_types::ThirtyTwoBytes, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::lightning_invoice::payment::PaymentError, } #[repr(C)] -/// A CResult_ErrorMessageDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::ErrorMessage on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_PaymentIdPaymentErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::ThirtyTwoBytes on success and a crate::lightning_invoice::payment::PaymentError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ErrorMessageDecodeErrorZ { - /// The contents of this CResult_ErrorMessageDecodeErrorZ, accessible via either +pub struct CResult_PaymentIdPaymentErrorZ { + /// The contents of this CResult_PaymentIdPaymentErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ErrorMessageDecodeErrorZPtr, - /// Whether this CResult_ErrorMessageDecodeErrorZ represents a success state. + pub contents: CResult_PaymentIdPaymentErrorZPtr, + /// Whether this CResult_PaymentIdPaymentErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ErrorMessageDecodeErrorZ in the success state. -pub extern "C" fn CResult_ErrorMessageDecodeErrorZ_ok(o: crate::lightning::ln::msgs::ErrorMessage) -> CResult_ErrorMessageDecodeErrorZ { - CResult_ErrorMessageDecodeErrorZ { - contents: CResult_ErrorMessageDecodeErrorZPtr { +/// Creates a new CResult_PaymentIdPaymentErrorZ in the success state. +pub extern "C" fn CResult_PaymentIdPaymentErrorZ_ok(o: crate::c_types::ThirtyTwoBytes) -> CResult_PaymentIdPaymentErrorZ { + CResult_PaymentIdPaymentErrorZ { + contents: CResult_PaymentIdPaymentErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ErrorMessageDecodeErrorZ in the error state. -pub extern "C" fn CResult_ErrorMessageDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ErrorMessageDecodeErrorZ { - CResult_ErrorMessageDecodeErrorZ { - contents: CResult_ErrorMessageDecodeErrorZPtr { +/// Creates a new CResult_PaymentIdPaymentErrorZ in the error state. +pub extern "C" fn CResult_PaymentIdPaymentErrorZ_err(e: crate::lightning_invoice::payment::PaymentError) -> CResult_PaymentIdPaymentErrorZ { + CResult_PaymentIdPaymentErrorZ { + contents: CResult_PaymentIdPaymentErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -16982,13 +20619,13 @@ pub extern "C" fn CResult_ErrorMessageDecodeErrorZ_err(e: crate::lightning::ln:: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ErrorMessageDecodeErrorZ_is_ok(o: &CResult_ErrorMessageDecodeErrorZ) -> bool { +pub extern "C" fn CResult_PaymentIdPaymentErrorZ_is_ok(o: &CResult_PaymentIdPaymentErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_ErrorMessageDecodeErrorZ. -pub extern "C" fn CResult_ErrorMessageDecodeErrorZ_free(_res: CResult_ErrorMessageDecodeErrorZ) { } -impl Drop for CResult_ErrorMessageDecodeErrorZ { +/// Frees any resources used by the CResult_PaymentIdPaymentErrorZ. +pub extern "C" fn CResult_PaymentIdPaymentErrorZ_free(_res: CResult_PaymentIdPaymentErrorZ) { } +impl Drop for CResult_PaymentIdPaymentErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -17001,16 +20638,16 @@ impl Drop for CResult_ErrorMessageDecodeErrorZ { } } } -impl From> for CResult_ErrorMessageDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_PaymentIdPaymentErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ErrorMessageDecodeErrorZPtr { result } + CResult_PaymentIdPaymentErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ErrorMessageDecodeErrorZPtr { err } + CResult_PaymentIdPaymentErrorZPtr { err } }; Self { contents, @@ -17018,59 +20655,58 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ErrorMessageDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_PaymentIdPaymentErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_ErrorMessageDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_PaymentIdPaymentErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_ErrorMessageDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_PaymentIdPaymentErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ErrorMessageDecodeErrorZ_clone(orig: &CResult_ErrorMessageDecodeErrorZ) -> CResult_ErrorMessageDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_PaymentIdPaymentErrorZ_clone(orig: &CResult_PaymentIdPaymentErrorZ) -> CResult_PaymentIdPaymentErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_WarningMessageDecodeErrorZ -pub union CResult_WarningMessageDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::WarningMessage, +/// The contents of CResult_NonePaymentErrorZ +pub union CResult_NonePaymentErrorZPtr { + /// Note that this value is always NULL, as there are no contents in the OK variant + pub result: *mut core::ffi::c_void, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::lightning_invoice::payment::PaymentError, } #[repr(C)] -/// A CResult_WarningMessageDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::WarningMessage on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_NonePaymentErrorZ represents the result of a fallible operation, +/// containing a () on success and a crate::lightning_invoice::payment::PaymentError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_WarningMessageDecodeErrorZ { - /// The contents of this CResult_WarningMessageDecodeErrorZ, accessible via either +pub struct CResult_NonePaymentErrorZ { + /// The contents of this CResult_NonePaymentErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_WarningMessageDecodeErrorZPtr, - /// Whether this CResult_WarningMessageDecodeErrorZ represents a success state. + pub contents: CResult_NonePaymentErrorZPtr, + /// Whether this CResult_NonePaymentErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_WarningMessageDecodeErrorZ in the success state. -pub extern "C" fn CResult_WarningMessageDecodeErrorZ_ok(o: crate::lightning::ln::msgs::WarningMessage) -> CResult_WarningMessageDecodeErrorZ { - CResult_WarningMessageDecodeErrorZ { - contents: CResult_WarningMessageDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), +/// Creates a new CResult_NonePaymentErrorZ in the success state. +pub extern "C" fn CResult_NonePaymentErrorZ_ok() -> CResult_NonePaymentErrorZ { + CResult_NonePaymentErrorZ { + contents: CResult_NonePaymentErrorZPtr { + result: core::ptr::null_mut(), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_WarningMessageDecodeErrorZ in the error state. -pub extern "C" fn CResult_WarningMessageDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_WarningMessageDecodeErrorZ { - CResult_WarningMessageDecodeErrorZ { - contents: CResult_WarningMessageDecodeErrorZPtr { +/// Creates a new CResult_NonePaymentErrorZ in the error state. +pub extern "C" fn CResult_NonePaymentErrorZ_err(e: crate::lightning_invoice::payment::PaymentError) -> CResult_NonePaymentErrorZ { + CResult_NonePaymentErrorZ { + contents: CResult_NonePaymentErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -17078,18 +20714,15 @@ pub extern "C" fn CResult_WarningMessageDecodeErrorZ_err(e: crate::lightning::ln } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_WarningMessageDecodeErrorZ_is_ok(o: &CResult_WarningMessageDecodeErrorZ) -> bool { +pub extern "C" fn CResult_NonePaymentErrorZ_is_ok(o: &CResult_NonePaymentErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_WarningMessageDecodeErrorZ. -pub extern "C" fn CResult_WarningMessageDecodeErrorZ_free(_res: CResult_WarningMessageDecodeErrorZ) { } -impl Drop for CResult_WarningMessageDecodeErrorZ { +/// Frees any resources used by the CResult_NonePaymentErrorZ. +pub extern "C" fn CResult_NonePaymentErrorZ_free(_res: CResult_NonePaymentErrorZ) { } +impl Drop for CResult_NonePaymentErrorZ { fn drop(&mut self) { if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } } else { if unsafe { !(self.contents.err as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.err) }; @@ -17097,16 +20730,16 @@ impl Drop for CResult_WarningMessageDecodeErrorZ { } } } -impl From> for CResult_WarningMessageDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_NonePaymentErrorZ { + fn from(mut o: crate::c_types::CResultTempl<(), crate::lightning_invoice::payment::PaymentError>) -> Self { let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_WarningMessageDecodeErrorZPtr { result } + let _ = unsafe { Box::from_raw(o.contents.result) }; + o.contents.result = core::ptr::null_mut(); + CResult_NonePaymentErrorZPtr { result: core::ptr::null_mut() } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_WarningMessageDecodeErrorZPtr { err } + CResult_NonePaymentErrorZPtr { err } }; Self { contents, @@ -17114,59 +20747,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_WarningMessageDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_NonePaymentErrorZPtr { + result: core::ptr::null_mut() } } } else { - Self { result_ok: false, contents: CResult_WarningMessageDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_NonePaymentErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_WarningMessageDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_NonePaymentErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_WarningMessageDecodeErrorZ_clone(orig: &CResult_WarningMessageDecodeErrorZ) -> CResult_WarningMessageDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_NonePaymentErrorZ_clone(orig: &CResult_NonePaymentErrorZ) -> CResult_NonePaymentErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_UnsignedNodeAnnouncementDecodeErrorZ -pub union CResult_UnsignedNodeAnnouncementDecodeErrorZPtr { +/// The contents of CResult_StringErrorZ +pub union CResult_StringErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::UnsignedNodeAnnouncement, + pub result: *mut crate::c_types::Str, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::c_types::Secp256k1Error, } #[repr(C)] -/// A CResult_UnsignedNodeAnnouncementDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::UnsignedNodeAnnouncement on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_StringErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::Str on success and a crate::c_types::Secp256k1Error on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_UnsignedNodeAnnouncementDecodeErrorZ { - /// The contents of this CResult_UnsignedNodeAnnouncementDecodeErrorZ, accessible via either +pub struct CResult_StringErrorZ { + /// The contents of this CResult_StringErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_UnsignedNodeAnnouncementDecodeErrorZPtr, - /// Whether this CResult_UnsignedNodeAnnouncementDecodeErrorZ represents a success state. + pub contents: CResult_StringErrorZPtr, + /// Whether this CResult_StringErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_UnsignedNodeAnnouncementDecodeErrorZ in the success state. -pub extern "C" fn CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> CResult_UnsignedNodeAnnouncementDecodeErrorZ { - CResult_UnsignedNodeAnnouncementDecodeErrorZ { - contents: CResult_UnsignedNodeAnnouncementDecodeErrorZPtr { +/// Creates a new CResult_StringErrorZ in the success state. +pub extern "C" fn CResult_StringErrorZ_ok(o: crate::c_types::Str) -> CResult_StringErrorZ { + CResult_StringErrorZ { + contents: CResult_StringErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_UnsignedNodeAnnouncementDecodeErrorZ in the error state. -pub extern "C" fn CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_UnsignedNodeAnnouncementDecodeErrorZ { - CResult_UnsignedNodeAnnouncementDecodeErrorZ { - contents: CResult_UnsignedNodeAnnouncementDecodeErrorZPtr { +/// Creates a new CResult_StringErrorZ in the error state. +pub extern "C" fn CResult_StringErrorZ_err(e: crate::c_types::Secp256k1Error) -> CResult_StringErrorZ { + CResult_StringErrorZ { + contents: CResult_StringErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -17174,13 +20807,13 @@ pub extern "C" fn CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e: crate::lig } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(o: &CResult_UnsignedNodeAnnouncementDecodeErrorZ) -> bool { +pub extern "C" fn CResult_StringErrorZ_is_ok(o: &CResult_StringErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_UnsignedNodeAnnouncementDecodeErrorZ. -pub extern "C" fn CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res: CResult_UnsignedNodeAnnouncementDecodeErrorZ) { } -impl Drop for CResult_UnsignedNodeAnnouncementDecodeErrorZ { +/// Frees any resources used by the CResult_StringErrorZ. +pub extern "C" fn CResult_StringErrorZ_free(_res: CResult_StringErrorZ) { } +impl Drop for CResult_StringErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -17193,16 +20826,16 @@ impl Drop for CResult_UnsignedNodeAnnouncementDecodeErrorZ { } } } -impl From> for CResult_UnsignedNodeAnnouncementDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_StringErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_UnsignedNodeAnnouncementDecodeErrorZPtr { result } + CResult_StringErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_UnsignedNodeAnnouncementDecodeErrorZPtr { err } + CResult_StringErrorZPtr { err } }; Self { contents, @@ -17210,59 +20843,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_UnsignedNodeAnnouncementDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_StringErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_UnsignedNodeAnnouncementDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_StringErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_UnsignedNodeAnnouncementDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_StringErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig: &CResult_UnsignedNodeAnnouncementDecodeErrorZ) -> CResult_UnsignedNodeAnnouncementDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_StringErrorZ_clone(orig: &CResult_StringErrorZ) -> CResult_StringErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_NodeAnnouncementDecodeErrorZ -pub union CResult_NodeAnnouncementDecodeErrorZPtr { +/// The contents of CResult_TxOutUtxoLookupErrorZ +pub union CResult_TxOutUtxoLookupErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::NodeAnnouncement, + pub result: *mut crate::c_types::TxOut, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::lightning::routing::utxo::UtxoLookupError, } #[repr(C)] -/// A CResult_NodeAnnouncementDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::NodeAnnouncement on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_TxOutUtxoLookupErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::TxOut on success and a crate::lightning::routing::utxo::UtxoLookupError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_NodeAnnouncementDecodeErrorZ { - /// The contents of this CResult_NodeAnnouncementDecodeErrorZ, accessible via either +pub struct CResult_TxOutUtxoLookupErrorZ { + /// The contents of this CResult_TxOutUtxoLookupErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_NodeAnnouncementDecodeErrorZPtr, - /// Whether this CResult_NodeAnnouncementDecodeErrorZ represents a success state. + pub contents: CResult_TxOutUtxoLookupErrorZPtr, + /// Whether this CResult_TxOutUtxoLookupErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_NodeAnnouncementDecodeErrorZ in the success state. -pub extern "C" fn CResult_NodeAnnouncementDecodeErrorZ_ok(o: crate::lightning::ln::msgs::NodeAnnouncement) -> CResult_NodeAnnouncementDecodeErrorZ { - CResult_NodeAnnouncementDecodeErrorZ { - contents: CResult_NodeAnnouncementDecodeErrorZPtr { +/// Creates a new CResult_TxOutUtxoLookupErrorZ in the success state. +pub extern "C" fn CResult_TxOutUtxoLookupErrorZ_ok(o: crate::c_types::TxOut) -> CResult_TxOutUtxoLookupErrorZ { + CResult_TxOutUtxoLookupErrorZ { + contents: CResult_TxOutUtxoLookupErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_NodeAnnouncementDecodeErrorZ in the error state. -pub extern "C" fn CResult_NodeAnnouncementDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_NodeAnnouncementDecodeErrorZ { - CResult_NodeAnnouncementDecodeErrorZ { - contents: CResult_NodeAnnouncementDecodeErrorZPtr { +/// Creates a new CResult_TxOutUtxoLookupErrorZ in the error state. +pub extern "C" fn CResult_TxOutUtxoLookupErrorZ_err(e: crate::lightning::routing::utxo::UtxoLookupError) -> CResult_TxOutUtxoLookupErrorZ { + CResult_TxOutUtxoLookupErrorZ { + contents: CResult_TxOutUtxoLookupErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -17270,13 +20903,13 @@ pub extern "C" fn CResult_NodeAnnouncementDecodeErrorZ_err(e: crate::lightning:: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_NodeAnnouncementDecodeErrorZ_is_ok(o: &CResult_NodeAnnouncementDecodeErrorZ) -> bool { +pub extern "C" fn CResult_TxOutUtxoLookupErrorZ_is_ok(o: &CResult_TxOutUtxoLookupErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_NodeAnnouncementDecodeErrorZ. -pub extern "C" fn CResult_NodeAnnouncementDecodeErrorZ_free(_res: CResult_NodeAnnouncementDecodeErrorZ) { } -impl Drop for CResult_NodeAnnouncementDecodeErrorZ { +/// Frees any resources used by the CResult_TxOutUtxoLookupErrorZ. +pub extern "C" fn CResult_TxOutUtxoLookupErrorZ_free(_res: CResult_TxOutUtxoLookupErrorZ) { } +impl Drop for CResult_TxOutUtxoLookupErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -17289,16 +20922,16 @@ impl Drop for CResult_NodeAnnouncementDecodeErrorZ { } } } -impl From> for CResult_NodeAnnouncementDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_TxOutUtxoLookupErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_NodeAnnouncementDecodeErrorZPtr { result } + CResult_TxOutUtxoLookupErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_NodeAnnouncementDecodeErrorZPtr { err } + CResult_TxOutUtxoLookupErrorZPtr { err } }; Self { contents, @@ -17306,95 +20939,91 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_NodeAnnouncementDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_TxOutUtxoLookupErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_NodeAnnouncementDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_TxOutUtxoLookupErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_NodeAnnouncementDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_TxOutUtxoLookupErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_NodeAnnouncementDecodeErrorZ_clone(orig: &CResult_NodeAnnouncementDecodeErrorZ) -> CResult_NodeAnnouncementDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_TxOutUtxoLookupErrorZ_clone(orig: &CResult_TxOutUtxoLookupErrorZ) -> CResult_TxOutUtxoLookupErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_QueryShortChannelIdsDecodeErrorZ -pub union CResult_QueryShortChannelIdsDecodeErrorZPtr { +/// The contents of CResult_OnionMessagePathNoneZ +pub union CResult_OnionMessagePathNoneZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::QueryShortChannelIds, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub result: *mut crate::lightning::onion_message::messenger::OnionMessagePath, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut core::ffi::c_void, } #[repr(C)] -/// A CResult_QueryShortChannelIdsDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::QueryShortChannelIds on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_OnionMessagePathNoneZ represents the result of a fallible operation, +/// containing a crate::lightning::onion_message::messenger::OnionMessagePath on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_QueryShortChannelIdsDecodeErrorZ { - /// The contents of this CResult_QueryShortChannelIdsDecodeErrorZ, accessible via either +pub struct CResult_OnionMessagePathNoneZ { + /// The contents of this CResult_OnionMessagePathNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_QueryShortChannelIdsDecodeErrorZPtr, - /// Whether this CResult_QueryShortChannelIdsDecodeErrorZ represents a success state. + pub contents: CResult_OnionMessagePathNoneZPtr, + /// Whether this CResult_OnionMessagePathNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_QueryShortChannelIdsDecodeErrorZ in the success state. -pub extern "C" fn CResult_QueryShortChannelIdsDecodeErrorZ_ok(o: crate::lightning::ln::msgs::QueryShortChannelIds) -> CResult_QueryShortChannelIdsDecodeErrorZ { - CResult_QueryShortChannelIdsDecodeErrorZ { - contents: CResult_QueryShortChannelIdsDecodeErrorZPtr { +/// Creates a new CResult_OnionMessagePathNoneZ in the success state. +pub extern "C" fn CResult_OnionMessagePathNoneZ_ok(o: crate::lightning::onion_message::messenger::OnionMessagePath) -> CResult_OnionMessagePathNoneZ { + CResult_OnionMessagePathNoneZ { + contents: CResult_OnionMessagePathNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_QueryShortChannelIdsDecodeErrorZ in the error state. -pub extern "C" fn CResult_QueryShortChannelIdsDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_QueryShortChannelIdsDecodeErrorZ { - CResult_QueryShortChannelIdsDecodeErrorZ { - contents: CResult_QueryShortChannelIdsDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), +/// Creates a new CResult_OnionMessagePathNoneZ in the error state. +pub extern "C" fn CResult_OnionMessagePathNoneZ_err() -> CResult_OnionMessagePathNoneZ { + CResult_OnionMessagePathNoneZ { + contents: CResult_OnionMessagePathNoneZPtr { + err: core::ptr::null_mut(), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(o: &CResult_QueryShortChannelIdsDecodeErrorZ) -> bool { +pub extern "C" fn CResult_OnionMessagePathNoneZ_is_ok(o: &CResult_OnionMessagePathNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_QueryShortChannelIdsDecodeErrorZ. -pub extern "C" fn CResult_QueryShortChannelIdsDecodeErrorZ_free(_res: CResult_QueryShortChannelIdsDecodeErrorZ) { } -impl Drop for CResult_QueryShortChannelIdsDecodeErrorZ { +/// Frees any resources used by the CResult_OnionMessagePathNoneZ. +pub extern "C" fn CResult_OnionMessagePathNoneZ_free(_res: CResult_OnionMessagePathNoneZ) { } +impl Drop for CResult_OnionMessagePathNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } } } } -impl From> for CResult_QueryShortChannelIdsDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_OnionMessagePathNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_QueryShortChannelIdsDecodeErrorZPtr { result } + CResult_OnionMessagePathNoneZPtr { result } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_QueryShortChannelIdsDecodeErrorZPtr { err } + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_OnionMessagePathNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -17402,59 +21031,58 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_QueryShortChannelIdsDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_OnionMessagePathNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_QueryShortChannelIdsDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_OnionMessagePathNoneZPtr { + err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_QueryShortChannelIdsDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_OnionMessagePathNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig: &CResult_QueryShortChannelIdsDecodeErrorZ) -> CResult_QueryShortChannelIdsDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_OnionMessagePathNoneZ_clone(orig: &CResult_OnionMessagePathNoneZ) -> CResult_OnionMessagePathNoneZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_ReplyShortChannelIdsEndDecodeErrorZ -pub union CResult_ReplyShortChannelIdsEndDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::ReplyShortChannelIdsEnd, +/// The contents of CResult_NoneSendErrorZ +pub union CResult_NoneSendErrorZPtr { + /// Note that this value is always NULL, as there are no contents in the OK variant + pub result: *mut core::ffi::c_void, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::lightning::onion_message::messenger::SendError, } #[repr(C)] -/// A CResult_ReplyShortChannelIdsEndDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::ReplyShortChannelIdsEnd on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_NoneSendErrorZ represents the result of a fallible operation, +/// containing a () on success and a crate::lightning::onion_message::messenger::SendError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ReplyShortChannelIdsEndDecodeErrorZ { - /// The contents of this CResult_ReplyShortChannelIdsEndDecodeErrorZ, accessible via either +pub struct CResult_NoneSendErrorZ { + /// The contents of this CResult_NoneSendErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ReplyShortChannelIdsEndDecodeErrorZPtr, - /// Whether this CResult_ReplyShortChannelIdsEndDecodeErrorZ represents a success state. + pub contents: CResult_NoneSendErrorZPtr, + /// Whether this CResult_NoneSendErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ReplyShortChannelIdsEndDecodeErrorZ in the success state. -pub extern "C" fn CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o: crate::lightning::ln::msgs::ReplyShortChannelIdsEnd) -> CResult_ReplyShortChannelIdsEndDecodeErrorZ { - CResult_ReplyShortChannelIdsEndDecodeErrorZ { - contents: CResult_ReplyShortChannelIdsEndDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), +/// Creates a new CResult_NoneSendErrorZ in the success state. +pub extern "C" fn CResult_NoneSendErrorZ_ok() -> CResult_NoneSendErrorZ { + CResult_NoneSendErrorZ { + contents: CResult_NoneSendErrorZPtr { + result: core::ptr::null_mut(), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ReplyShortChannelIdsEndDecodeErrorZ in the error state. -pub extern "C" fn CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ReplyShortChannelIdsEndDecodeErrorZ { - CResult_ReplyShortChannelIdsEndDecodeErrorZ { - contents: CResult_ReplyShortChannelIdsEndDecodeErrorZPtr { +/// Creates a new CResult_NoneSendErrorZ in the error state. +pub extern "C" fn CResult_NoneSendErrorZ_err(e: crate::lightning::onion_message::messenger::SendError) -> CResult_NoneSendErrorZ { + CResult_NoneSendErrorZ { + contents: CResult_NoneSendErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -17462,18 +21090,15 @@ pub extern "C" fn CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e: crate::ligh } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(o: &CResult_ReplyShortChannelIdsEndDecodeErrorZ) -> bool { +pub extern "C" fn CResult_NoneSendErrorZ_is_ok(o: &CResult_NoneSendErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_ReplyShortChannelIdsEndDecodeErrorZ. -pub extern "C" fn CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res: CResult_ReplyShortChannelIdsEndDecodeErrorZ) { } -impl Drop for CResult_ReplyShortChannelIdsEndDecodeErrorZ { +/// Frees any resources used by the CResult_NoneSendErrorZ. +pub extern "C" fn CResult_NoneSendErrorZ_free(_res: CResult_NoneSendErrorZ) { } +impl Drop for CResult_NoneSendErrorZ { fn drop(&mut self) { if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } } else { if unsafe { !(self.contents.err as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.err) }; @@ -17481,16 +21106,16 @@ impl Drop for CResult_ReplyShortChannelIdsEndDecodeErrorZ { } } } -impl From> for CResult_ReplyShortChannelIdsEndDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_NoneSendErrorZ { + fn from(mut o: crate::c_types::CResultTempl<(), crate::lightning::onion_message::messenger::SendError>) -> Self { let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ReplyShortChannelIdsEndDecodeErrorZPtr { result } + let _ = unsafe { Box::from_raw(o.contents.result) }; + o.contents.result = core::ptr::null_mut(); + CResult_NoneSendErrorZPtr { result: core::ptr::null_mut() } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ReplyShortChannelIdsEndDecodeErrorZPtr { err } + CResult_NoneSendErrorZPtr { err } }; Self { contents, @@ -17498,95 +21123,74 @@ impl From Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_ReplyShortChannelIdsEndDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_ReplyShortChannelIdsEndDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } - } - } -} -#[no_mangle] -/// Creates a new CResult_ReplyShortChannelIdsEndDecodeErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig: &CResult_ReplyShortChannelIdsEndDecodeErrorZ) -> CResult_ReplyShortChannelIdsEndDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_QueryChannelRangeDecodeErrorZ -pub union CResult_QueryChannelRangeDecodeErrorZPtr { +/// The contents of CResult_BlindedPathNoneZ +pub union CResult_BlindedPathNoneZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::QueryChannelRange, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub result: *mut crate::lightning::blinded_path::BlindedPath, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut core::ffi::c_void, } #[repr(C)] -/// A CResult_QueryChannelRangeDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::QueryChannelRange on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_BlindedPathNoneZ represents the result of a fallible operation, +/// containing a crate::lightning::blinded_path::BlindedPath on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_QueryChannelRangeDecodeErrorZ { - /// The contents of this CResult_QueryChannelRangeDecodeErrorZ, accessible via either +pub struct CResult_BlindedPathNoneZ { + /// The contents of this CResult_BlindedPathNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_QueryChannelRangeDecodeErrorZPtr, - /// Whether this CResult_QueryChannelRangeDecodeErrorZ represents a success state. + pub contents: CResult_BlindedPathNoneZPtr, + /// Whether this CResult_BlindedPathNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_QueryChannelRangeDecodeErrorZ in the success state. -pub extern "C" fn CResult_QueryChannelRangeDecodeErrorZ_ok(o: crate::lightning::ln::msgs::QueryChannelRange) -> CResult_QueryChannelRangeDecodeErrorZ { - CResult_QueryChannelRangeDecodeErrorZ { - contents: CResult_QueryChannelRangeDecodeErrorZPtr { +/// Creates a new CResult_BlindedPathNoneZ in the success state. +pub extern "C" fn CResult_BlindedPathNoneZ_ok(o: crate::lightning::blinded_path::BlindedPath) -> CResult_BlindedPathNoneZ { + CResult_BlindedPathNoneZ { + contents: CResult_BlindedPathNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_QueryChannelRangeDecodeErrorZ in the error state. -pub extern "C" fn CResult_QueryChannelRangeDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_QueryChannelRangeDecodeErrorZ { - CResult_QueryChannelRangeDecodeErrorZ { - contents: CResult_QueryChannelRangeDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), +/// Creates a new CResult_BlindedPathNoneZ in the error state. +pub extern "C" fn CResult_BlindedPathNoneZ_err() -> CResult_BlindedPathNoneZ { + CResult_BlindedPathNoneZ { + contents: CResult_BlindedPathNoneZPtr { + err: core::ptr::null_mut(), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_QueryChannelRangeDecodeErrorZ_is_ok(o: &CResult_QueryChannelRangeDecodeErrorZ) -> bool { +pub extern "C" fn CResult_BlindedPathNoneZ_is_ok(o: &CResult_BlindedPathNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_QueryChannelRangeDecodeErrorZ. -pub extern "C" fn CResult_QueryChannelRangeDecodeErrorZ_free(_res: CResult_QueryChannelRangeDecodeErrorZ) { } -impl Drop for CResult_QueryChannelRangeDecodeErrorZ { +/// Frees any resources used by the CResult_BlindedPathNoneZ. +pub extern "C" fn CResult_BlindedPathNoneZ_free(_res: CResult_BlindedPathNoneZ) { } +impl Drop for CResult_BlindedPathNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } } } } -impl From> for CResult_QueryChannelRangeDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_BlindedPathNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_QueryChannelRangeDecodeErrorZPtr { result } + CResult_BlindedPathNoneZPtr { result } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_QueryChannelRangeDecodeErrorZPtr { err } + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_BlindedPathNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -17594,59 +21198,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_QueryChannelRangeDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_BlindedPathNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_QueryChannelRangeDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_BlindedPathNoneZPtr { + err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_QueryChannelRangeDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_BlindedPathNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_QueryChannelRangeDecodeErrorZ_clone(orig: &CResult_QueryChannelRangeDecodeErrorZ) -> CResult_QueryChannelRangeDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_BlindedPathNoneZ_clone(orig: &CResult_BlindedPathNoneZ) -> CResult_BlindedPathNoneZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_ReplyChannelRangeDecodeErrorZ -pub union CResult_ReplyChannelRangeDecodeErrorZPtr { +/// The contents of CResult_BlindedPathDecodeErrorZ +pub union CResult_BlindedPathDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::ReplyChannelRange, + pub result: *mut crate::lightning::blinded_path::BlindedPath, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_ReplyChannelRangeDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::ReplyChannelRange on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_BlindedPathDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::blinded_path::BlindedPath on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ReplyChannelRangeDecodeErrorZ { - /// The contents of this CResult_ReplyChannelRangeDecodeErrorZ, accessible via either +pub struct CResult_BlindedPathDecodeErrorZ { + /// The contents of this CResult_BlindedPathDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ReplyChannelRangeDecodeErrorZPtr, - /// Whether this CResult_ReplyChannelRangeDecodeErrorZ represents a success state. + pub contents: CResult_BlindedPathDecodeErrorZPtr, + /// Whether this CResult_BlindedPathDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ReplyChannelRangeDecodeErrorZ in the success state. -pub extern "C" fn CResult_ReplyChannelRangeDecodeErrorZ_ok(o: crate::lightning::ln::msgs::ReplyChannelRange) -> CResult_ReplyChannelRangeDecodeErrorZ { - CResult_ReplyChannelRangeDecodeErrorZ { - contents: CResult_ReplyChannelRangeDecodeErrorZPtr { +/// Creates a new CResult_BlindedPathDecodeErrorZ in the success state. +pub extern "C" fn CResult_BlindedPathDecodeErrorZ_ok(o: crate::lightning::blinded_path::BlindedPath) -> CResult_BlindedPathDecodeErrorZ { + CResult_BlindedPathDecodeErrorZ { + contents: CResult_BlindedPathDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ReplyChannelRangeDecodeErrorZ in the error state. -pub extern "C" fn CResult_ReplyChannelRangeDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ReplyChannelRangeDecodeErrorZ { - CResult_ReplyChannelRangeDecodeErrorZ { - contents: CResult_ReplyChannelRangeDecodeErrorZPtr { +/// Creates a new CResult_BlindedPathDecodeErrorZ in the error state. +pub extern "C" fn CResult_BlindedPathDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_BlindedPathDecodeErrorZ { + CResult_BlindedPathDecodeErrorZ { + contents: CResult_BlindedPathDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -17654,13 +21258,13 @@ pub extern "C" fn CResult_ReplyChannelRangeDecodeErrorZ_err(e: crate::lightning: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ReplyChannelRangeDecodeErrorZ_is_ok(o: &CResult_ReplyChannelRangeDecodeErrorZ) -> bool { +pub extern "C" fn CResult_BlindedPathDecodeErrorZ_is_ok(o: &CResult_BlindedPathDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_ReplyChannelRangeDecodeErrorZ. -pub extern "C" fn CResult_ReplyChannelRangeDecodeErrorZ_free(_res: CResult_ReplyChannelRangeDecodeErrorZ) { } -impl Drop for CResult_ReplyChannelRangeDecodeErrorZ { +/// Frees any resources used by the CResult_BlindedPathDecodeErrorZ. +pub extern "C" fn CResult_BlindedPathDecodeErrorZ_free(_res: CResult_BlindedPathDecodeErrorZ) { } +impl Drop for CResult_BlindedPathDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -17672,17 +21276,17 @@ impl Drop for CResult_ReplyChannelRangeDecodeErrorZ { } } } -} -impl From> for CResult_ReplyChannelRangeDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +} +impl From> for CResult_BlindedPathDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ReplyChannelRangeDecodeErrorZPtr { result } + CResult_BlindedPathDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ReplyChannelRangeDecodeErrorZPtr { err } + CResult_BlindedPathDecodeErrorZPtr { err } }; Self { contents, @@ -17690,59 +21294,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ReplyChannelRangeDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_BlindedPathDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_ReplyChannelRangeDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_BlindedPathDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_ReplyChannelRangeDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_BlindedPathDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ReplyChannelRangeDecodeErrorZ_clone(orig: &CResult_ReplyChannelRangeDecodeErrorZ) -> CResult_ReplyChannelRangeDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_BlindedPathDecodeErrorZ_clone(orig: &CResult_BlindedPathDecodeErrorZ) -> CResult_BlindedPathDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_GossipTimestampFilterDecodeErrorZ -pub union CResult_GossipTimestampFilterDecodeErrorZPtr { +/// The contents of CResult_BlindedHopDecodeErrorZ +pub union CResult_BlindedHopDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::GossipTimestampFilter, + pub result: *mut crate::lightning::blinded_path::BlindedHop, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_GossipTimestampFilterDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::GossipTimestampFilter on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_BlindedHopDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::blinded_path::BlindedHop on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_GossipTimestampFilterDecodeErrorZ { - /// The contents of this CResult_GossipTimestampFilterDecodeErrorZ, accessible via either +pub struct CResult_BlindedHopDecodeErrorZ { + /// The contents of this CResult_BlindedHopDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_GossipTimestampFilterDecodeErrorZPtr, - /// Whether this CResult_GossipTimestampFilterDecodeErrorZ represents a success state. + pub contents: CResult_BlindedHopDecodeErrorZPtr, + /// Whether this CResult_BlindedHopDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_GossipTimestampFilterDecodeErrorZ in the success state. -pub extern "C" fn CResult_GossipTimestampFilterDecodeErrorZ_ok(o: crate::lightning::ln::msgs::GossipTimestampFilter) -> CResult_GossipTimestampFilterDecodeErrorZ { - CResult_GossipTimestampFilterDecodeErrorZ { - contents: CResult_GossipTimestampFilterDecodeErrorZPtr { +/// Creates a new CResult_BlindedHopDecodeErrorZ in the success state. +pub extern "C" fn CResult_BlindedHopDecodeErrorZ_ok(o: crate::lightning::blinded_path::BlindedHop) -> CResult_BlindedHopDecodeErrorZ { + CResult_BlindedHopDecodeErrorZ { + contents: CResult_BlindedHopDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_GossipTimestampFilterDecodeErrorZ in the error state. -pub extern "C" fn CResult_GossipTimestampFilterDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_GossipTimestampFilterDecodeErrorZ { - CResult_GossipTimestampFilterDecodeErrorZ { - contents: CResult_GossipTimestampFilterDecodeErrorZPtr { +/// Creates a new CResult_BlindedHopDecodeErrorZ in the error state. +pub extern "C" fn CResult_BlindedHopDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_BlindedHopDecodeErrorZ { + CResult_BlindedHopDecodeErrorZ { + contents: CResult_BlindedHopDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -17750,13 +21354,13 @@ pub extern "C" fn CResult_GossipTimestampFilterDecodeErrorZ_err(e: crate::lightn } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_GossipTimestampFilterDecodeErrorZ_is_ok(o: &CResult_GossipTimestampFilterDecodeErrorZ) -> bool { +pub extern "C" fn CResult_BlindedHopDecodeErrorZ_is_ok(o: &CResult_BlindedHopDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_GossipTimestampFilterDecodeErrorZ. -pub extern "C" fn CResult_GossipTimestampFilterDecodeErrorZ_free(_res: CResult_GossipTimestampFilterDecodeErrorZ) { } -impl Drop for CResult_GossipTimestampFilterDecodeErrorZ { +/// Frees any resources used by the CResult_BlindedHopDecodeErrorZ. +pub extern "C" fn CResult_BlindedHopDecodeErrorZ_free(_res: CResult_BlindedHopDecodeErrorZ) { } +impl Drop for CResult_BlindedHopDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -17769,16 +21373,16 @@ impl Drop for CResult_GossipTimestampFilterDecodeErrorZ { } } } -impl From> for CResult_GossipTimestampFilterDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_BlindedHopDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_GossipTimestampFilterDecodeErrorZPtr { result } + CResult_BlindedHopDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_GossipTimestampFilterDecodeErrorZPtr { err } + CResult_BlindedHopDecodeErrorZPtr { err } }; Self { contents, @@ -17786,105 +21390,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_GossipTimestampFilterDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_BlindedHopDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_GossipTimestampFilterDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_BlindedHopDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_GossipTimestampFilterDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_BlindedHopDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_GossipTimestampFilterDecodeErrorZ_clone(orig: &CResult_GossipTimestampFilterDecodeErrorZ) -> CResult_GossipTimestampFilterDecodeErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// A dynamically-allocated array of crate::lightning::ln::channelmanager::PhantomRouteHintss of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_PhantomRouteHintsZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::ln::channelmanager::PhantomRouteHints, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_PhantomRouteHintsZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::channelmanager::PhantomRouteHints] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_PhantomRouteHintsZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_PhantomRouteHintsZ_free(_res: CVec_PhantomRouteHintsZ) { } -impl Drop for CVec_PhantomRouteHintsZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_PhantomRouteHintsZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} +pub extern "C" fn CResult_BlindedHopDecodeErrorZ_clone(orig: &CResult_BlindedHopDecodeErrorZ) -> CResult_BlindedHopDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_InvoiceSignOrCreationErrorZ -pub union CResult_InvoiceSignOrCreationErrorZPtr { +/// The contents of CResult_InvoiceErrorDecodeErrorZ +pub union CResult_InvoiceErrorDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning_invoice::Invoice, + pub result: *mut crate::lightning::offers::invoice_error::InvoiceError, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning_invoice::SignOrCreationError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_InvoiceSignOrCreationErrorZ represents the result of a fallible operation, -/// containing a crate::lightning_invoice::Invoice on success and a crate::lightning_invoice::SignOrCreationError on failure. +/// A CResult_InvoiceErrorDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::offers::invoice_error::InvoiceError on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_InvoiceSignOrCreationErrorZ { - /// The contents of this CResult_InvoiceSignOrCreationErrorZ, accessible via either +pub struct CResult_InvoiceErrorDecodeErrorZ { + /// The contents of this CResult_InvoiceErrorDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_InvoiceSignOrCreationErrorZPtr, - /// Whether this CResult_InvoiceSignOrCreationErrorZ represents a success state. + pub contents: CResult_InvoiceErrorDecodeErrorZPtr, + /// Whether this CResult_InvoiceErrorDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_InvoiceSignOrCreationErrorZ in the success state. -pub extern "C" fn CResult_InvoiceSignOrCreationErrorZ_ok(o: crate::lightning_invoice::Invoice) -> CResult_InvoiceSignOrCreationErrorZ { - CResult_InvoiceSignOrCreationErrorZ { - contents: CResult_InvoiceSignOrCreationErrorZPtr { +/// Creates a new CResult_InvoiceErrorDecodeErrorZ in the success state. +pub extern "C" fn CResult_InvoiceErrorDecodeErrorZ_ok(o: crate::lightning::offers::invoice_error::InvoiceError) -> CResult_InvoiceErrorDecodeErrorZ { + CResult_InvoiceErrorDecodeErrorZ { + contents: CResult_InvoiceErrorDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_InvoiceSignOrCreationErrorZ in the error state. -pub extern "C" fn CResult_InvoiceSignOrCreationErrorZ_err(e: crate::lightning_invoice::SignOrCreationError) -> CResult_InvoiceSignOrCreationErrorZ { - CResult_InvoiceSignOrCreationErrorZ { - contents: CResult_InvoiceSignOrCreationErrorZPtr { +/// Creates a new CResult_InvoiceErrorDecodeErrorZ in the error state. +pub extern "C" fn CResult_InvoiceErrorDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_InvoiceErrorDecodeErrorZ { + CResult_InvoiceErrorDecodeErrorZ { + contents: CResult_InvoiceErrorDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -17892,13 +21450,13 @@ pub extern "C" fn CResult_InvoiceSignOrCreationErrorZ_err(e: crate::lightning_in } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_InvoiceSignOrCreationErrorZ_is_ok(o: &CResult_InvoiceSignOrCreationErrorZ) -> bool { +pub extern "C" fn CResult_InvoiceErrorDecodeErrorZ_is_ok(o: &CResult_InvoiceErrorDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_InvoiceSignOrCreationErrorZ. -pub extern "C" fn CResult_InvoiceSignOrCreationErrorZ_free(_res: CResult_InvoiceSignOrCreationErrorZ) { } -impl Drop for CResult_InvoiceSignOrCreationErrorZ { +/// Frees any resources used by the CResult_InvoiceErrorDecodeErrorZ. +pub extern "C" fn CResult_InvoiceErrorDecodeErrorZ_free(_res: CResult_InvoiceErrorDecodeErrorZ) { } +impl Drop for CResult_InvoiceErrorDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -17911,16 +21469,16 @@ impl Drop for CResult_InvoiceSignOrCreationErrorZ { } } } -impl From> for CResult_InvoiceSignOrCreationErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_InvoiceErrorDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_InvoiceSignOrCreationErrorZPtr { result } + CResult_InvoiceErrorDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_InvoiceSignOrCreationErrorZPtr { err } + CResult_InvoiceErrorDecodeErrorZPtr { err } }; Self { contents, @@ -17928,69 +21486,23 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_InvoiceSignOrCreationErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_InvoiceErrorDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_InvoiceSignOrCreationErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_InvoiceErrorDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_InvoiceSignOrCreationErrorZ which has the same data as `orig` +/// Creates a new CResult_InvoiceErrorDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_InvoiceSignOrCreationErrorZ_clone(orig: &CResult_InvoiceSignOrCreationErrorZ) -> CResult_InvoiceSignOrCreationErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// A dynamically-allocated array of crate::lightning::util::wakers::Futures of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_FutureZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::util::wakers::Future, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_FutureZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::util::wakers::Future] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_FutureZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_FutureZ_free(_res: CVec_FutureZ) { } -impl Drop for CVec_FutureZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_FutureZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} +pub extern "C" fn CResult_InvoiceErrorDecodeErrorZ_clone(orig: &CResult_InvoiceErrorDecodeErrorZ) -> CResult_InvoiceErrorDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] /// An enum which can either contain a crate::lightning::chain::Filter or not pub enum COption_FilterZ { @@ -18278,82 +21790,3 @@ impl Clone for CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ { Self::from(res) } } -#[repr(C)] -/// The contents of CResult_u32GraphSyncErrorZ -pub union CResult_u32GraphSyncErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut u32, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning_rapid_gossip_sync::error::GraphSyncError, -} -#[repr(C)] -/// A CResult_u32GraphSyncErrorZ represents the result of a fallible operation, -/// containing a u32 on success and a crate::lightning_rapid_gossip_sync::error::GraphSyncError on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_u32GraphSyncErrorZ { - /// The contents of this CResult_u32GraphSyncErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_u32GraphSyncErrorZPtr, - /// Whether this CResult_u32GraphSyncErrorZ represents a success state. - pub result_ok: bool, -} -#[no_mangle] -/// Creates a new CResult_u32GraphSyncErrorZ in the success state. -pub extern "C" fn CResult_u32GraphSyncErrorZ_ok(o: u32) -> CResult_u32GraphSyncErrorZ { - CResult_u32GraphSyncErrorZ { - contents: CResult_u32GraphSyncErrorZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, - } -} -#[no_mangle] -/// Creates a new CResult_u32GraphSyncErrorZ in the error state. -pub extern "C" fn CResult_u32GraphSyncErrorZ_err(e: crate::lightning_rapid_gossip_sync::error::GraphSyncError) -> CResult_u32GraphSyncErrorZ { - CResult_u32GraphSyncErrorZ { - contents: CResult_u32GraphSyncErrorZPtr { - err: Box::into_raw(Box::new(e)), - }, - result_ok: false, - } -} -/// Checks if the given object is currently in the success state -#[no_mangle] -pub extern "C" fn CResult_u32GraphSyncErrorZ_is_ok(o: &CResult_u32GraphSyncErrorZ) -> bool { - o.result_ok -} -#[no_mangle] -/// Frees any resources used by the CResult_u32GraphSyncErrorZ. -pub extern "C" fn CResult_u32GraphSyncErrorZ_free(_res: CResult_u32GraphSyncErrorZ) { } -impl Drop for CResult_u32GraphSyncErrorZ { - fn drop(&mut self) { - if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } - } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } - } - } -} -impl From> for CResult_u32GraphSyncErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { - let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_u32GraphSyncErrorZPtr { result } - } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_u32GraphSyncErrorZPtr { err } - }; - Self { - contents, - result_ok: o.result_ok, - } - } -} diff --git a/lightning-c-bindings/src/lightning/blinded_path.rs b/lightning-c-bindings/src/lightning/blinded_path.rs index febf2228..1972ae83 100644 --- a/lightning-c-bindings/src/lightning/blinded_path.rs +++ b/lightning-c-bindings/src/lightning/blinded_path.rs @@ -213,7 +213,7 @@ pub extern "C" fn BlindedHop_eq(a: &BlindedHop, b: &BlindedHop) -> bool { /// Errors if less than two hops are provided or if `node_pk`(s) are invalid. #[must_use] #[no_mangle] -pub extern "C" fn BlindedPath_new_for_message(mut node_pks: crate::c_types::derived::CVec_PublicKeyZ, entropy_source: &crate::lightning::chain::keysinterface::EntropySource) -> crate::c_types::derived::CResult_BlindedPathNoneZ { +pub extern "C" fn BlindedPath_new_for_message(mut node_pks: crate::c_types::derived::CVec_PublicKeyZ, entropy_source: &crate::lightning::sign::EntropySource) -> crate::c_types::derived::CResult_BlindedPathNoneZ { let mut local_node_pks = Vec::new(); for mut item in node_pks.into_rust().drain(..) { local_node_pks.push( { item.into_rust() }); }; let mut ret = lightning::blinded_path::BlindedPath::new_for_message(&local_node_pks[..], entropy_source, secp256k1::global::SECP256K1); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::blinded_path::BlindedPath { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; diff --git a/lightning-c-bindings/src/lightning/chain/chaininterface.rs b/lightning-c-bindings/src/lightning/chain/chaininterface.rs index 687262be..e27203a8 100644 --- a/lightning-c-bindings/src/lightning/chain/chaininterface.rs +++ b/lightning-c-bindings/src/lightning/chain/chaininterface.rs @@ -26,8 +26,20 @@ pub struct BroadcasterInterface { /// An opaque pointer which is passed to your function implementations as an argument. /// This has no meaning in the LDK, and can be NULL or any other value. pub this_arg: *mut c_void, - /// Sends a transaction out to (hopefully) be mined. - pub broadcast_transaction: extern "C" fn (this_arg: *const c_void, tx: crate::c_types::Transaction), + /// Sends a list of transactions out to (hopefully) be mined. + /// This only needs to handle the actual broadcasting of transactions, LDK will automatically + /// rebroadcast transactions that haven't made it into a block. + /// + /// In some cases LDK may attempt to broadcast a transaction which double-spends another + /// and this isn't a bug and can be safely ignored. + /// + /// If more than one transaction is given, these transactions should be considered to be a + /// package and broadcast together. Some of the transactions may or may not depend on each other, + /// be sure to manage both cases correctly. + /// + /// Bitcoin transaction packages are defined in BIP 331 and here: + /// https://github.com/bitcoin/bitcoin/blob/master/doc/policy/packages.md + pub broadcast_transactions: extern "C" fn (this_arg: *const c_void, txs: crate::c_types::derived::CVec_TransactionZ), /// Frees any resources associated with this object given its this_arg pointer. /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. pub free: Option, @@ -38,15 +50,16 @@ unsafe impl Sync for BroadcasterInterface {} pub(crate) extern "C" fn BroadcasterInterface_clone_fields(orig: &BroadcasterInterface) -> BroadcasterInterface { BroadcasterInterface { this_arg: orig.this_arg, - broadcast_transaction: Clone::clone(&orig.broadcast_transaction), + broadcast_transactions: Clone::clone(&orig.broadcast_transactions), free: Clone::clone(&orig.free), } } use lightning::chain::chaininterface::BroadcasterInterface as rustBroadcasterInterface; impl rustBroadcasterInterface for BroadcasterInterface { - fn broadcast_transaction(&self, mut tx: &bitcoin::blockdata::transaction::Transaction) { - (self.broadcast_transaction)(self.this_arg, crate::c_types::Transaction::from_bitcoin(tx)) + fn broadcast_transactions(&self, mut txs: &[&bitcoin::blockdata::transaction::Transaction]) { + let mut local_txs = Vec::new(); for item in txs.iter() { local_txs.push( { crate::c_types::Transaction::from_bitcoin((*item)) }); }; + (self.broadcast_transactions)(self.this_arg, local_txs.into()) } } @@ -68,17 +81,26 @@ impl Drop for BroadcasterInterface { } } } -/// An enum that represents the speed at which we want a transaction to confirm used for feerate +/// An enum that represents the priority at which we want a transaction to confirm used for feerate /// estimation. #[derive(Clone)] #[must_use] #[repr(C)] pub enum ConfirmationTarget { - /// We are happy with this transaction confirming slowly when feerate drops some. + /// We'd like a transaction to confirm in the future, but don't want to commit most of the fees + /// required to do so yet. The remaining fees will come via a Child-Pays-For-Parent (CPFP) fee + /// bump of the transaction. + /// + /// The feerate returned should be the absolute minimum feerate required to enter most node + /// mempools across the network. Note that if you are not able to obtain this feerate estimate, + /// you should likely use the furthest-out estimate allowed by your fee estimator. + MempoolMinimum, + /// We are happy with a transaction confirming slowly, at least within a day or so worth of + /// blocks. Background, - /// We'd like this transaction to confirm without major delay, but 12-18 blocks is fine. + /// We'd like a transaction to confirm without major delayed, i.e., within the next 12-24 blocks. Normal, - /// We'd like this transaction to confirm in the next few blocks. + /// We'd like a transaction to confirm in the next few blocks. HighPriority, } use lightning::chain::chaininterface::ConfirmationTarget as ConfirmationTargetImport; @@ -88,6 +110,7 @@ impl ConfirmationTarget { #[allow(unused)] pub(crate) fn to_native(&self) -> nativeConfirmationTarget { match self { + ConfirmationTarget::MempoolMinimum => nativeConfirmationTarget::MempoolMinimum, ConfirmationTarget::Background => nativeConfirmationTarget::Background, ConfirmationTarget::Normal => nativeConfirmationTarget::Normal, ConfirmationTarget::HighPriority => nativeConfirmationTarget::HighPriority, @@ -96,6 +119,7 @@ impl ConfirmationTarget { #[allow(unused)] pub(crate) fn into_native(self) -> nativeConfirmationTarget { match self { + ConfirmationTarget::MempoolMinimum => nativeConfirmationTarget::MempoolMinimum, ConfirmationTarget::Background => nativeConfirmationTarget::Background, ConfirmationTarget::Normal => nativeConfirmationTarget::Normal, ConfirmationTarget::HighPriority => nativeConfirmationTarget::HighPriority, @@ -104,6 +128,7 @@ impl ConfirmationTarget { #[allow(unused)] pub(crate) fn from_native(native: &nativeConfirmationTarget) -> Self { match native { + nativeConfirmationTarget::MempoolMinimum => ConfirmationTarget::MempoolMinimum, nativeConfirmationTarget::Background => ConfirmationTarget::Background, nativeConfirmationTarget::Normal => ConfirmationTarget::Normal, nativeConfirmationTarget::HighPriority => ConfirmationTarget::HighPriority, @@ -112,6 +137,7 @@ impl ConfirmationTarget { #[allow(unused)] pub(crate) fn native_into(native: nativeConfirmationTarget) -> Self { match native { + nativeConfirmationTarget::MempoolMinimum => ConfirmationTarget::MempoolMinimum, nativeConfirmationTarget::Background => ConfirmationTarget::Background, nativeConfirmationTarget::Normal => ConfirmationTarget::Normal, nativeConfirmationTarget::HighPriority => ConfirmationTarget::HighPriority, @@ -124,6 +150,10 @@ pub extern "C" fn ConfirmationTarget_clone(orig: &ConfirmationTarget) -> Confirm orig.clone() } #[no_mangle] +/// Utility method to constructs a new MempoolMinimum-variant ConfirmationTarget +pub extern "C" fn ConfirmationTarget_mempool_minimum() -> ConfirmationTarget { + ConfirmationTarget::MempoolMinimum} +#[no_mangle] /// Utility method to constructs a new Background-variant ConfirmationTarget pub extern "C" fn ConfirmationTarget_background() -> ConfirmationTarget { ConfirmationTarget::Background} @@ -153,6 +183,11 @@ pub extern "C" fn ConfirmationTarget_eq(a: &ConfirmationTarget, b: &Confirmation /// A trait which should be implemented to provide feerate information on a number of time /// horizons. /// +/// If access to a local mempool is not feasible, feerate estimates should be fetched from a set of +/// third-parties hosting them. Note that this enables them to affect the propagation of your +/// pre-signed transactions at any time and therefore endangers the safety of channels funds. It +/// should be considered carefully as a deployment. +/// /// Note that all of the functions implemented here *must* be reentrant-safe (obviously - they're /// called from inside the library in response to chain events, P2P events, or timer events). #[repr(C)] @@ -168,7 +203,6 @@ pub struct FeeEstimator { /// The following unit conversions can be used to convert to sats/KW: /// * satoshis-per-byte * 250 /// * satoshis-per-kbyte / 4 - #[must_use] pub get_est_sat_per_1000_weight: extern "C" fn (this_arg: *const c_void, confirmation_target: crate::lightning::chain::chaininterface::ConfirmationTarget) -> u32, /// Frees any resources associated with this object given its this_arg pointer. /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. diff --git a/lightning-c-bindings/src/lightning/chain/chainmonitor.rs b/lightning-c-bindings/src/lightning/chain/chainmonitor.rs index f6a97a30..4bdccab4 100644 --- a/lightning-c-bindings/src/lightning/chain/chainmonitor.rs +++ b/lightning-c-bindings/src/lightning/chain/chainmonitor.rs @@ -159,7 +159,6 @@ pub struct Persist { /// /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager /// [`Writeable::write`]: crate::util::ser::Writeable::write - #[must_use] pub persist_new_channel: extern "C" fn (this_arg: *const c_void, channel_id: crate::lightning::chain::transaction::OutPoint, data: &crate::lightning::chain::channelmonitor::ChannelMonitor, update_id: crate::lightning::chain::chainmonitor::MonitorUpdateId) -> crate::lightning::chain::ChannelMonitorUpdateStatus, /// Update one channel's data. The provided [`ChannelMonitor`] has already applied the given /// update. @@ -196,7 +195,6 @@ pub struct Persist { /// [`Writeable::write`]: crate::util::ser::Writeable::write /// /// Note that update (or a relevant inner pointer) may be NULL or all-0s to represent None - #[must_use] pub update_persisted_channel: extern "C" fn (this_arg: *const c_void, channel_id: crate::lightning::chain::transaction::OutPoint, update: crate::lightning::chain::channelmonitor::ChannelMonitorUpdate, data: &crate::lightning::chain::channelmonitor::ChannelMonitor, update_id: crate::lightning::chain::chainmonitor::MonitorUpdateId) -> crate::lightning::chain::ChannelMonitorUpdateStatus, /// Frees any resources associated with this object given its this_arg pointer. /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. @@ -215,12 +213,12 @@ pub(crate) extern "C" fn Persist_clone_fields(orig: &Persist) -> Persist { } use lightning::chain::chainmonitor::Persist as rustPersist; -impl rustPersist for Persist { - fn persist_new_channel(&self, mut channel_id: lightning::chain::transaction::OutPoint, mut data: &lightning::chain::channelmonitor::ChannelMonitor, mut update_id: lightning::chain::chainmonitor::MonitorUpdateId) -> lightning::chain::ChannelMonitorUpdateStatus { +impl rustPersist for Persist { + fn persist_new_channel(&self, mut channel_id: lightning::chain::transaction::OutPoint, mut data: &lightning::chain::channelmonitor::ChannelMonitor, mut update_id: lightning::chain::chainmonitor::MonitorUpdateId) -> lightning::chain::ChannelMonitorUpdateStatus { let mut ret = (self.persist_new_channel)(self.this_arg, crate::lightning::chain::transaction::OutPoint { inner: ObjOps::heap_alloc(channel_id), is_owned: true }, &crate::lightning::chain::channelmonitor::ChannelMonitor { inner: unsafe { ObjOps::nonnull_ptr_to_inner((data as *const lightning::chain::channelmonitor::ChannelMonitor<_, >) as *mut _) }, is_owned: false }, crate::lightning::chain::chainmonitor::MonitorUpdateId { inner: ObjOps::heap_alloc(update_id), is_owned: true }); ret.into_native() } - fn update_persisted_channel(&self, mut channel_id: lightning::chain::transaction::OutPoint, mut update: Option<&lightning::chain::channelmonitor::ChannelMonitorUpdate>, mut data: &lightning::chain::channelmonitor::ChannelMonitor, mut update_id: lightning::chain::chainmonitor::MonitorUpdateId) -> lightning::chain::ChannelMonitorUpdateStatus { + fn update_persisted_channel(&self, mut channel_id: lightning::chain::transaction::OutPoint, mut update: Option<&lightning::chain::channelmonitor::ChannelMonitorUpdate>, mut data: &lightning::chain::channelmonitor::ChannelMonitor, mut update_id: lightning::chain::chainmonitor::MonitorUpdateId) -> lightning::chain::ChannelMonitorUpdateStatus { let mut local_update = crate::lightning::chain::channelmonitor::ChannelMonitorUpdate { inner: unsafe { (if update.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (update.unwrap()) }) } as *const lightning::chain::channelmonitor::ChannelMonitorUpdate<>) as *mut _ }, is_owned: false }; let mut ret = (self.update_persisted_channel)(self.this_arg, crate::lightning::chain::transaction::OutPoint { inner: ObjOps::heap_alloc(channel_id), is_owned: true }, local_update, &crate::lightning::chain::channelmonitor::ChannelMonitor { inner: unsafe { ObjOps::nonnull_ptr_to_inner((data as *const lightning::chain::channelmonitor::ChannelMonitor<_, >) as *mut _) }, is_owned: false }, crate::lightning::chain::chainmonitor::MonitorUpdateId { inner: ObjOps::heap_alloc(update_id), is_owned: true }); ret.into_native() @@ -247,7 +245,7 @@ impl Drop for Persist { } use lightning::chain::chainmonitor::LockedChannelMonitor as nativeLockedChannelMonitorImport; -pub(crate) type nativeLockedChannelMonitor = nativeLockedChannelMonitorImport<'static, crate::lightning::chain::keysinterface::WriteableEcdsaChannelSigner>; +pub(crate) type nativeLockedChannelMonitor = nativeLockedChannelMonitorImport<'static, crate::lightning::sign::WriteableEcdsaChannelSigner>; /// A read-only reference to a current ChannelMonitor. /// @@ -301,7 +299,7 @@ impl LockedChannelMonitor { } use lightning::chain::chainmonitor::ChainMonitor as nativeChainMonitorImport; -pub(crate) type nativeChainMonitor = nativeChainMonitorImport; +pub(crate) type nativeChainMonitor = nativeChainMonitorImport; /// An implementation of [`chain::Watch`] for monitoring channels. /// @@ -547,9 +545,9 @@ extern "C" fn ChainMonitor_Confirm_best_block_updated(this_arg: *const c_void, h >::best_block_updated(unsafe { &mut *(this_arg as *mut nativeChainMonitor) }, &::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), height) } #[must_use] -extern "C" fn ChainMonitor_Confirm_get_relevant_txids(this_arg: *const c_void) -> crate::c_types::derived::CVec_C2Tuple_TxidBlockHashZZ { +extern "C" fn ChainMonitor_Confirm_get_relevant_txids(this_arg: *const c_void) -> crate::c_types::derived::CVec_C2Tuple_TxidCOption_BlockHashZZZ { let mut ret = >::get_relevant_txids(unsafe { &mut *(this_arg as *mut nativeChainMonitor) }, ); - let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item; let mut local_orig_ret_0_1 = if orig_ret_0_1.is_none() { crate::c_types::ThirtyTwoBytes::null() } else { { crate::c_types::ThirtyTwoBytes { data: (orig_ret_0_1.unwrap()).into_inner() } } }; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0.into_inner() }, local_orig_ret_0_1).into(); local_ret_0 }); }; + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item; let mut local_orig_ret_0_1 = if orig_ret_0_1.is_none() { crate::c_types::derived::COption_BlockHashZ::None } else { crate::c_types::derived::COption_BlockHashZ::Some( { crate::c_types::ThirtyTwoBytes { data: orig_ret_0_1.unwrap().into_inner() } }) }; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0.into_inner() }, local_orig_ret_0_1).into(); local_ret_0 }); }; local_ret.into() } diff --git a/lightning-c-bindings/src/lightning/chain/channelmonitor.rs b/lightning-c-bindings/src/lightning/chain/channelmonitor.rs index dbe2932b..276fcda7 100644 --- a/lightning-c-bindings/src/lightning/chain/channelmonitor.rs +++ b/lightning-c-bindings/src/lightning/chain/channelmonitor.rs @@ -525,6 +525,10 @@ pub enum Balance { /// The height at which the counterparty may be able to claim the balance if we have not /// done so. timeout_height: u32, + /// The payment hash that locks this HTLC. + payment_hash: crate::c_types::ThirtyTwoBytes, + /// The preimage that can be used to claim this HTLC. + payment_preimage: crate::c_types::ThirtyTwoBytes, }, /// HTLCs which we sent to our counterparty which are claimable after a timeout (less on-chain /// fees) if the counterparty does not know the preimage for the HTLCs. These are somewhat @@ -536,6 +540,8 @@ pub enum Balance { /// The height at which we will be able to claim the balance if our counterparty has not /// done so. claimable_height: u32, + /// The payment hash whose preimage our counterparty needs to claim this HTLC. + payment_hash: crate::c_types::ThirtyTwoBytes, }, /// HTLCs which we received from our counterparty which are claimable with a preimage which we /// do not currently have. This will only be claimable if we receive the preimage from the node @@ -547,6 +553,8 @@ pub enum Balance { /// The height at which our counterparty will be able to claim the balance if we have not /// yet received the preimage and claimed it ourselves. expiry_height: u32, + /// The payment hash whose preimage we need to claim this HTLC. + payment_hash: crate::c_types::ThirtyTwoBytes, }, /// The channel has been closed, and our counterparty broadcasted a revoked commitment /// transaction. @@ -582,28 +590,36 @@ impl Balance { confirmation_height: confirmation_height_nonref, } }, - Balance::ContentiousClaimable {ref claimable_amount_satoshis, ref timeout_height, } => { + Balance::ContentiousClaimable {ref claimable_amount_satoshis, ref timeout_height, ref payment_hash, ref payment_preimage, } => { let mut claimable_amount_satoshis_nonref = Clone::clone(claimable_amount_satoshis); let mut timeout_height_nonref = Clone::clone(timeout_height); + let mut payment_hash_nonref = Clone::clone(payment_hash); + let mut payment_preimage_nonref = Clone::clone(payment_preimage); nativeBalance::ContentiousClaimable { claimable_amount_satoshis: claimable_amount_satoshis_nonref, timeout_height: timeout_height_nonref, + payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data), + payment_preimage: ::lightning::ln::PaymentPreimage(payment_preimage_nonref.data), } }, - Balance::MaybeTimeoutClaimableHTLC {ref claimable_amount_satoshis, ref claimable_height, } => { + Balance::MaybeTimeoutClaimableHTLC {ref claimable_amount_satoshis, ref claimable_height, ref payment_hash, } => { let mut claimable_amount_satoshis_nonref = Clone::clone(claimable_amount_satoshis); let mut claimable_height_nonref = Clone::clone(claimable_height); + let mut payment_hash_nonref = Clone::clone(payment_hash); nativeBalance::MaybeTimeoutClaimableHTLC { claimable_amount_satoshis: claimable_amount_satoshis_nonref, claimable_height: claimable_height_nonref, + payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data), } }, - Balance::MaybePreimageClaimableHTLC {ref claimable_amount_satoshis, ref expiry_height, } => { + Balance::MaybePreimageClaimableHTLC {ref claimable_amount_satoshis, ref expiry_height, ref payment_hash, } => { let mut claimable_amount_satoshis_nonref = Clone::clone(claimable_amount_satoshis); let mut expiry_height_nonref = Clone::clone(expiry_height); + let mut payment_hash_nonref = Clone::clone(payment_hash); nativeBalance::MaybePreimageClaimableHTLC { claimable_amount_satoshis: claimable_amount_satoshis_nonref, expiry_height: expiry_height_nonref, + payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data), } }, Balance::CounterpartyRevokedOutputClaimable {ref claimable_amount_satoshis, } => { @@ -628,22 +644,26 @@ impl Balance { confirmation_height: confirmation_height, } }, - Balance::ContentiousClaimable {mut claimable_amount_satoshis, mut timeout_height, } => { + Balance::ContentiousClaimable {mut claimable_amount_satoshis, mut timeout_height, mut payment_hash, mut payment_preimage, } => { nativeBalance::ContentiousClaimable { claimable_amount_satoshis: claimable_amount_satoshis, timeout_height: timeout_height, + payment_hash: ::lightning::ln::PaymentHash(payment_hash.data), + payment_preimage: ::lightning::ln::PaymentPreimage(payment_preimage.data), } }, - Balance::MaybeTimeoutClaimableHTLC {mut claimable_amount_satoshis, mut claimable_height, } => { + Balance::MaybeTimeoutClaimableHTLC {mut claimable_amount_satoshis, mut claimable_height, mut payment_hash, } => { nativeBalance::MaybeTimeoutClaimableHTLC { claimable_amount_satoshis: claimable_amount_satoshis, claimable_height: claimable_height, + payment_hash: ::lightning::ln::PaymentHash(payment_hash.data), } }, - Balance::MaybePreimageClaimableHTLC {mut claimable_amount_satoshis, mut expiry_height, } => { + Balance::MaybePreimageClaimableHTLC {mut claimable_amount_satoshis, mut expiry_height, mut payment_hash, } => { nativeBalance::MaybePreimageClaimableHTLC { claimable_amount_satoshis: claimable_amount_satoshis, expiry_height: expiry_height, + payment_hash: ::lightning::ln::PaymentHash(payment_hash.data), } }, Balance::CounterpartyRevokedOutputClaimable {mut claimable_amount_satoshis, } => { @@ -670,28 +690,36 @@ impl Balance { confirmation_height: confirmation_height_nonref, } }, - nativeBalance::ContentiousClaimable {ref claimable_amount_satoshis, ref timeout_height, } => { + nativeBalance::ContentiousClaimable {ref claimable_amount_satoshis, ref timeout_height, ref payment_hash, ref payment_preimage, } => { let mut claimable_amount_satoshis_nonref = Clone::clone(claimable_amount_satoshis); let mut timeout_height_nonref = Clone::clone(timeout_height); + let mut payment_hash_nonref = Clone::clone(payment_hash); + let mut payment_preimage_nonref = Clone::clone(payment_preimage); Balance::ContentiousClaimable { claimable_amount_satoshis: claimable_amount_satoshis_nonref, timeout_height: timeout_height_nonref, + payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 }, + payment_preimage: crate::c_types::ThirtyTwoBytes { data: payment_preimage_nonref.0 }, } }, - nativeBalance::MaybeTimeoutClaimableHTLC {ref claimable_amount_satoshis, ref claimable_height, } => { + nativeBalance::MaybeTimeoutClaimableHTLC {ref claimable_amount_satoshis, ref claimable_height, ref payment_hash, } => { let mut claimable_amount_satoshis_nonref = Clone::clone(claimable_amount_satoshis); let mut claimable_height_nonref = Clone::clone(claimable_height); + let mut payment_hash_nonref = Clone::clone(payment_hash); Balance::MaybeTimeoutClaimableHTLC { claimable_amount_satoshis: claimable_amount_satoshis_nonref, claimable_height: claimable_height_nonref, + payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 }, } }, - nativeBalance::MaybePreimageClaimableHTLC {ref claimable_amount_satoshis, ref expiry_height, } => { + nativeBalance::MaybePreimageClaimableHTLC {ref claimable_amount_satoshis, ref expiry_height, ref payment_hash, } => { let mut claimable_amount_satoshis_nonref = Clone::clone(claimable_amount_satoshis); let mut expiry_height_nonref = Clone::clone(expiry_height); + let mut payment_hash_nonref = Clone::clone(payment_hash); Balance::MaybePreimageClaimableHTLC { claimable_amount_satoshis: claimable_amount_satoshis_nonref, expiry_height: expiry_height_nonref, + payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 }, } }, nativeBalance::CounterpartyRevokedOutputClaimable {ref claimable_amount_satoshis, } => { @@ -716,22 +744,26 @@ impl Balance { confirmation_height: confirmation_height, } }, - nativeBalance::ContentiousClaimable {mut claimable_amount_satoshis, mut timeout_height, } => { + nativeBalance::ContentiousClaimable {mut claimable_amount_satoshis, mut timeout_height, mut payment_hash, mut payment_preimage, } => { Balance::ContentiousClaimable { claimable_amount_satoshis: claimable_amount_satoshis, timeout_height: timeout_height, + payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 }, + payment_preimage: crate::c_types::ThirtyTwoBytes { data: payment_preimage.0 }, } }, - nativeBalance::MaybeTimeoutClaimableHTLC {mut claimable_amount_satoshis, mut claimable_height, } => { + nativeBalance::MaybeTimeoutClaimableHTLC {mut claimable_amount_satoshis, mut claimable_height, mut payment_hash, } => { Balance::MaybeTimeoutClaimableHTLC { claimable_amount_satoshis: claimable_amount_satoshis, claimable_height: claimable_height, + payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 }, } }, - nativeBalance::MaybePreimageClaimableHTLC {mut claimable_amount_satoshis, mut expiry_height, } => { + nativeBalance::MaybePreimageClaimableHTLC {mut claimable_amount_satoshis, mut expiry_height, mut payment_hash, } => { Balance::MaybePreimageClaimableHTLC { claimable_amount_satoshis: claimable_amount_satoshis, expiry_height: expiry_height, + payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 }, } }, nativeBalance::CounterpartyRevokedOutputClaimable {mut claimable_amount_satoshis, } => { @@ -767,26 +799,30 @@ pub extern "C" fn Balance_claimable_awaiting_confirmations(claimable_amount_sato } #[no_mangle] /// Utility method to constructs a new ContentiousClaimable-variant Balance -pub extern "C" fn Balance_contentious_claimable(claimable_amount_satoshis: u64, timeout_height: u32) -> Balance { +pub extern "C" fn Balance_contentious_claimable(claimable_amount_satoshis: u64, timeout_height: u32, payment_hash: crate::c_types::ThirtyTwoBytes, payment_preimage: crate::c_types::ThirtyTwoBytes) -> Balance { Balance::ContentiousClaimable { claimable_amount_satoshis, timeout_height, + payment_hash, + payment_preimage, } } #[no_mangle] /// Utility method to constructs a new MaybeTimeoutClaimableHTLC-variant Balance -pub extern "C" fn Balance_maybe_timeout_claimable_htlc(claimable_amount_satoshis: u64, claimable_height: u32) -> Balance { +pub extern "C" fn Balance_maybe_timeout_claimable_htlc(claimable_amount_satoshis: u64, claimable_height: u32, payment_hash: crate::c_types::ThirtyTwoBytes) -> Balance { Balance::MaybeTimeoutClaimableHTLC { claimable_amount_satoshis, claimable_height, + payment_hash, } } #[no_mangle] /// Utility method to constructs a new MaybePreimageClaimableHTLC-variant Balance -pub extern "C" fn Balance_maybe_preimage_claimable_htlc(claimable_amount_satoshis: u64, expiry_height: u32) -> Balance { +pub extern "C" fn Balance_maybe_preimage_claimable_htlc(claimable_amount_satoshis: u64, expiry_height: u32, payment_hash: crate::c_types::ThirtyTwoBytes) -> Balance { Balance::MaybePreimageClaimableHTLC { claimable_amount_satoshis, expiry_height, + payment_hash, } } #[no_mangle] @@ -802,9 +838,22 @@ pub extern "C" fn Balance_counterparty_revoked_output_claimable(claimable_amount pub extern "C" fn Balance_eq(a: &Balance, b: &Balance) -> bool { if &a.to_native() == &b.to_native() { true } else { false } } +/// The amount claimable, in satoshis. This excludes balances that we are unsure if we are able +/// to claim, this is because we are waiting for a preimage or for a timeout to expire. For more +/// information on these balances see [`Balance::MaybeTimeoutClaimableHTLC`] and +/// [`Balance::MaybePreimageClaimableHTLC`]. +/// +/// On-chain fees required to claim the balance are not included in this amount. +#[must_use] +#[no_mangle] +pub extern "C" fn Balance_claimable_amount_satoshis(this_arg: &crate::lightning::chain::channelmonitor::Balance) -> u64 { + let mut ret = this_arg.to_native().claimable_amount_satoshis(); + ret +} + use lightning::chain::channelmonitor::ChannelMonitor as nativeChannelMonitorImport; -pub(crate) type nativeChannelMonitor = nativeChannelMonitorImport; +pub(crate) type nativeChannelMonitor = nativeChannelMonitorImport; /// A ChannelMonitor handles chain events (blocks connected and disconnected) and generates /// on-chain transactions to ensure no loss of funds occurs. @@ -812,11 +861,6 @@ pub(crate) type nativeChannelMonitor = nativeChannelMonitorImport crate::c_types::derived::CVec_EventZ { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_and_clear_pending_events(); - let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::events::Event::native_into(item) }); }; - local_ret.into() +pub extern "C" fn ChannelMonitor_process_pending_events(this_arg: &crate::lightning::chain::channelmonitor::ChannelMonitor, handler: &crate::lightning::events::EventHandler) { + unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.process_pending_events(handler) } /// Gets the `node_id` of the counterparty for this channel. @@ -1004,7 +1050,7 @@ pub extern "C" fn ChannelMonitor_get_latest_holder_commitment_txn(this_arg: &cra pub extern "C" fn ChannelMonitor_block_connected(this_arg: &crate::lightning::chain::channelmonitor::ChannelMonitor, header: *const [u8; 80], mut txdata: crate::c_types::derived::CVec_C2Tuple_usizeTransactionZZ, mut height: u32, mut broadcaster: crate::lightning::chain::chaininterface::BroadcasterInterface, mut fee_estimator: crate::lightning::chain::chaininterface::FeeEstimator, mut logger: crate::lightning::util::logger::Logger) -> crate::c_types::derived::CVec_TransactionOutputsZ { let mut local_txdata = Vec::new(); for mut item in txdata.into_rust().drain(..) { local_txdata.push( { let (mut orig_txdata_0_0, mut orig_txdata_0_1) = item.to_rust(); let mut local_txdata_0 = (orig_txdata_0_0, orig_txdata_0_1.into_bitcoin()); local_txdata_0 }); }; let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.block_connected(&::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), &local_txdata.iter().map(|(a, b)| (*a, b)).collect::>()[..], height, broadcaster, fee_estimator, logger); - let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item; let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.drain(..) { local_orig_ret_0_1.push( { let (mut orig_orig_ret_0_1_0_0, mut orig_orig_ret_0_1_0_1) = item; let mut local_orig_ret_0_1_0 = (orig_orig_ret_0_1_0_0, crate::c_types::TxOut::from_rust(orig_orig_ret_0_1_0_1)).into(); local_orig_ret_0_1_0 }); }; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0.into_inner() }, local_orig_ret_0_1.into()).into(); local_ret_0 }); }; + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item; let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.drain(..) { local_orig_ret_0_1.push( { let (mut orig_orig_ret_0_1_0_0, mut orig_orig_ret_0_1_0_1) = item; let mut local_orig_ret_0_1_0 = (orig_orig_ret_0_1_0_0, crate::c_types::TxOut::from_rust(&orig_orig_ret_0_1_0_1)).into(); local_orig_ret_0_1_0 }); }; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0.into_inner() }, local_orig_ret_0_1.into()).into(); local_ret_0 }); }; local_ret.into() } @@ -1027,7 +1073,7 @@ pub extern "C" fn ChannelMonitor_block_disconnected(this_arg: &crate::lightning: pub extern "C" fn ChannelMonitor_transactions_confirmed(this_arg: &crate::lightning::chain::channelmonitor::ChannelMonitor, header: *const [u8; 80], mut txdata: crate::c_types::derived::CVec_C2Tuple_usizeTransactionZZ, mut height: u32, mut broadcaster: crate::lightning::chain::chaininterface::BroadcasterInterface, mut fee_estimator: crate::lightning::chain::chaininterface::FeeEstimator, mut logger: crate::lightning::util::logger::Logger) -> crate::c_types::derived::CVec_TransactionOutputsZ { let mut local_txdata = Vec::new(); for mut item in txdata.into_rust().drain(..) { local_txdata.push( { let (mut orig_txdata_0_0, mut orig_txdata_0_1) = item.to_rust(); let mut local_txdata_0 = (orig_txdata_0_0, orig_txdata_0_1.into_bitcoin()); local_txdata_0 }); }; let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.transactions_confirmed(&::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), &local_txdata.iter().map(|(a, b)| (*a, b)).collect::>()[..], height, broadcaster, fee_estimator, logger); - let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item; let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.drain(..) { local_orig_ret_0_1.push( { let (mut orig_orig_ret_0_1_0_0, mut orig_orig_ret_0_1_0_1) = item; let mut local_orig_ret_0_1_0 = (orig_orig_ret_0_1_0_0, crate::c_types::TxOut::from_rust(orig_orig_ret_0_1_0_1)).into(); local_orig_ret_0_1_0 }); }; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0.into_inner() }, local_orig_ret_0_1.into()).into(); local_ret_0 }); }; + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item; let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.drain(..) { local_orig_ret_0_1.push( { let (mut orig_orig_ret_0_1_0_0, mut orig_orig_ret_0_1_0_1) = item; let mut local_orig_ret_0_1_0 = (orig_orig_ret_0_1_0_0, crate::c_types::TxOut::from_rust(&orig_orig_ret_0_1_0_1)).into(); local_orig_ret_0_1_0 }); }; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0.into_inner() }, local_orig_ret_0_1.into()).into(); local_ret_0 }); }; local_ret.into() } @@ -1053,16 +1099,16 @@ pub extern "C" fn ChannelMonitor_transaction_unconfirmed(this_arg: &crate::light #[no_mangle] pub extern "C" fn ChannelMonitor_best_block_updated(this_arg: &crate::lightning::chain::channelmonitor::ChannelMonitor, header: *const [u8; 80], mut height: u32, mut broadcaster: crate::lightning::chain::chaininterface::BroadcasterInterface, mut fee_estimator: crate::lightning::chain::chaininterface::FeeEstimator, mut logger: crate::lightning::util::logger::Logger) -> crate::c_types::derived::CVec_TransactionOutputsZ { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.best_block_updated(&::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), height, broadcaster, fee_estimator, logger); - let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item; let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.drain(..) { local_orig_ret_0_1.push( { let (mut orig_orig_ret_0_1_0_0, mut orig_orig_ret_0_1_0_1) = item; let mut local_orig_ret_0_1_0 = (orig_orig_ret_0_1_0_0, crate::c_types::TxOut::from_rust(orig_orig_ret_0_1_0_1)).into(); local_orig_ret_0_1_0 }); }; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0.into_inner() }, local_orig_ret_0_1.into()).into(); local_ret_0 }); }; + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item; let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.drain(..) { local_orig_ret_0_1.push( { let (mut orig_orig_ret_0_1_0_0, mut orig_orig_ret_0_1_0_1) = item; let mut local_orig_ret_0_1_0 = (orig_orig_ret_0_1_0_0, crate::c_types::TxOut::from_rust(&orig_orig_ret_0_1_0_1)).into(); local_orig_ret_0_1_0 }); }; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0.into_inner() }, local_orig_ret_0_1.into()).into(); local_ret_0 }); }; local_ret.into() } /// Returns the set of txids that should be monitored for re-organization out of the chain. #[must_use] #[no_mangle] -pub extern "C" fn ChannelMonitor_get_relevant_txids(this_arg: &crate::lightning::chain::channelmonitor::ChannelMonitor) -> crate::c_types::derived::CVec_C2Tuple_TxidBlockHashZZ { +pub extern "C" fn ChannelMonitor_get_relevant_txids(this_arg: &crate::lightning::chain::channelmonitor::ChannelMonitor) -> crate::c_types::derived::CVec_C2Tuple_TxidCOption_BlockHashZZZ { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_relevant_txids(); - let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item; let mut local_orig_ret_0_1 = if orig_ret_0_1.is_none() { crate::c_types::ThirtyTwoBytes::null() } else { { crate::c_types::ThirtyTwoBytes { data: (orig_ret_0_1.unwrap()).into_inner() } } }; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0.into_inner() }, local_orig_ret_0_1).into(); local_ret_0 }); }; + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item; let mut local_orig_ret_0_1 = if orig_ret_0_1.is_none() { crate::c_types::derived::COption_BlockHashZ::None } else { crate::c_types::derived::COption_BlockHashZ::Some( { crate::c_types::ThirtyTwoBytes { data: orig_ret_0_1.unwrap().into_inner() } }) }; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0.into_inner() }, local_orig_ret_0_1).into(); local_ret_0 }); }; local_ret.into() } @@ -1110,11 +1156,11 @@ pub extern "C" fn ChannelMonitor_get_claimable_balances(this_arg: &crate::lightn #[no_mangle] /// Read a C2Tuple_BlockHashChannelMonitorZ from a byte array, created by C2Tuple_BlockHashChannelMonitorZ_write -pub extern "C" fn C2Tuple_BlockHashChannelMonitorZ_read(ser: crate::c_types::u8slice, arg_a: &crate::lightning::chain::keysinterface::EntropySource, arg_b: &crate::lightning::chain::keysinterface::SignerProvider) -> crate::c_types::derived::CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ { +pub extern "C" fn C2Tuple_BlockHashChannelMonitorZ_read(ser: crate::c_types::u8slice, arg_a: &crate::lightning::sign::EntropySource, arg_b: &crate::lightning::sign::SignerProvider) -> crate::c_types::derived::CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ { let arg_a_conv = arg_a; let arg_b_conv = arg_b; let arg_conv = (arg_a_conv, arg_b_conv); - let res: Result<(bitcoin::hash_types::BlockHash, lightning::chain::channelmonitor::ChannelMonitor), lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj_arg(ser, arg_conv); + let res: Result<(bitcoin::hash_types::BlockHash, lightning::chain::channelmonitor::ChannelMonitor), lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj_arg(ser, arg_conv); let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_res_0_0, mut orig_res_0_1) = o; let mut local_res_0 = (crate::c_types::ThirtyTwoBytes { data: orig_res_0_0.into_inner() }, crate::lightning::chain::channelmonitor::ChannelMonitor { inner: ObjOps::heap_alloc(orig_res_0_1), is_owned: true }).into(); local_res_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; local_res } diff --git a/lightning-c-bindings/src/lightning/chain/keysinterface.rs b/lightning-c-bindings/src/lightning/chain/keysinterface.rs deleted file mode 100644 index acfb4407..00000000 --- a/lightning-c-bindings/src/lightning/chain/keysinterface.rs +++ /dev/null @@ -1,2485 +0,0 @@ -// This file is Copyright its original authors, visible in version control -// history and in the source files from which this was generated. -// -// This file is licensed under the license available in the LICENSE or LICENSE.md -// file in the root of this repository or, if no such file exists, the same -// license as that which applies to the original source files from which this -// source was automatically generated. - -//! Provides keys to LDK and defines some useful objects describing spendable on-chain outputs. -//! -//! The provided output descriptors follow a custom LDK data format and are currently not fully -//! compatible with Bitcoin Core output descriptors. - -use alloc::str::FromStr; -use core::ffi::c_void; -use core::convert::Infallible; -use bitcoin::hashes::Hash; -use crate::c_types::*; -#[cfg(feature="no-std")] -use alloc::{vec::Vec, boxed::Box}; - - -use lightning::chain::keysinterface::DelayedPaymentOutputDescriptor as nativeDelayedPaymentOutputDescriptorImport; -pub(crate) type nativeDelayedPaymentOutputDescriptor = nativeDelayedPaymentOutputDescriptorImport; - -/// Information about a spendable output to a P2WSH script. -/// -/// See [`SpendableOutputDescriptor::DelayedPaymentOutput`] for more details on how to spend this. -#[must_use] -#[repr(C)] -pub struct DelayedPaymentOutputDescriptor { - /// A pointer to the opaque Rust object. - - /// Nearly everywhere, inner must be non-null, however in places where - /// the Rust equivalent takes an Option, it may be set to null to indicate None. - pub inner: *mut nativeDelayedPaymentOutputDescriptor, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for DelayedPaymentOutputDescriptor { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeDelayedPaymentOutputDescriptor>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; - } - } -} -/// Frees any resources used by the DelayedPaymentOutputDescriptor, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn DelayedPaymentOutputDescriptor_free(this_obj: DelayedPaymentOutputDescriptor) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn DelayedPaymentOutputDescriptor_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeDelayedPaymentOutputDescriptor) }; -} -#[allow(unused)] -impl DelayedPaymentOutputDescriptor { - pub(crate) fn get_native_ref(&self) -> &'static nativeDelayedPaymentOutputDescriptor { - unsafe { &*ObjOps::untweak_ptr(self.inner) } - } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeDelayedPaymentOutputDescriptor { - unsafe { &mut *ObjOps::untweak_ptr(self.inner) } - } - /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy - pub(crate) fn take_inner(mut self) -> *mut nativeDelayedPaymentOutputDescriptor { - assert!(self.is_owned); - let ret = ObjOps::untweak_ptr(self.inner); - self.inner = core::ptr::null_mut(); - ret - } -} -/// The outpoint which is spendable. -#[no_mangle] -pub extern "C" fn DelayedPaymentOutputDescriptor_get_outpoint(this_ptr: &DelayedPaymentOutputDescriptor) -> crate::lightning::chain::transaction::OutPoint { - let mut inner_val = &mut this_ptr.get_native_mut_ref().outpoint; - crate::lightning::chain::transaction::OutPoint { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::chain::transaction::OutPoint<>) as *mut _) }, is_owned: false } -} -/// The outpoint which is spendable. -#[no_mangle] -pub extern "C" fn DelayedPaymentOutputDescriptor_set_outpoint(this_ptr: &mut DelayedPaymentOutputDescriptor, mut val: crate::lightning::chain::transaction::OutPoint) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.outpoint = *unsafe { Box::from_raw(val.take_inner()) }; -} -/// Per commitment point to derive the delayed payment key by key holder. -#[no_mangle] -pub extern "C" fn DelayedPaymentOutputDescriptor_get_per_commitment_point(this_ptr: &DelayedPaymentOutputDescriptor) -> crate::c_types::PublicKey { - let mut inner_val = &mut this_ptr.get_native_mut_ref().per_commitment_point; - crate::c_types::PublicKey::from_rust(&inner_val) -} -/// Per commitment point to derive the delayed payment key by key holder. -#[no_mangle] -pub extern "C" fn DelayedPaymentOutputDescriptor_set_per_commitment_point(this_ptr: &mut DelayedPaymentOutputDescriptor, mut val: crate::c_types::PublicKey) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.per_commitment_point = val.into_rust(); -} -/// The `nSequence` value which must be set in the spending input to satisfy the `OP_CSV` in -/// the witness_script. -#[no_mangle] -pub extern "C" fn DelayedPaymentOutputDescriptor_get_to_self_delay(this_ptr: &DelayedPaymentOutputDescriptor) -> u16 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay; - *inner_val -} -/// The `nSequence` value which must be set in the spending input to satisfy the `OP_CSV` in -/// the witness_script. -#[no_mangle] -pub extern "C" fn DelayedPaymentOutputDescriptor_set_to_self_delay(this_ptr: &mut DelayedPaymentOutputDescriptor, mut val: u16) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val; -} -/// The output which is referenced by the given outpoint. -/// -/// Returns a copy of the field. -#[no_mangle] -pub extern "C" fn DelayedPaymentOutputDescriptor_get_output(this_ptr: &DelayedPaymentOutputDescriptor) -> crate::c_types::TxOut { - let mut inner_val = this_ptr.get_native_mut_ref().output.clone(); - crate::c_types::TxOut::from_rust(inner_val) -} -/// The output which is referenced by the given outpoint. -#[no_mangle] -pub extern "C" fn DelayedPaymentOutputDescriptor_set_output(this_ptr: &mut DelayedPaymentOutputDescriptor, mut val: crate::c_types::TxOut) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.output = val.into_rust(); -} -/// The revocation point specific to the commitment transaction which was broadcast. Used to -/// derive the witnessScript for this output. -#[no_mangle] -pub extern "C" fn DelayedPaymentOutputDescriptor_get_revocation_pubkey(this_ptr: &DelayedPaymentOutputDescriptor) -> crate::c_types::PublicKey { - let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_pubkey; - crate::c_types::PublicKey::from_rust(&inner_val) -} -/// The revocation point specific to the commitment transaction which was broadcast. Used to -/// derive the witnessScript for this output. -#[no_mangle] -pub extern "C" fn DelayedPaymentOutputDescriptor_set_revocation_pubkey(this_ptr: &mut DelayedPaymentOutputDescriptor, mut val: crate::c_types::PublicKey) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_pubkey = val.into_rust(); -} -/// Arbitrary identification information returned by a call to [`ChannelSigner::channel_keys_id`]. -/// This may be useful in re-deriving keys used in the channel to spend the output. -#[no_mangle] -pub extern "C" fn DelayedPaymentOutputDescriptor_get_channel_keys_id(this_ptr: &DelayedPaymentOutputDescriptor) -> *const [u8; 32] { - let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_keys_id; - inner_val -} -/// Arbitrary identification information returned by a call to [`ChannelSigner::channel_keys_id`]. -/// This may be useful in re-deriving keys used in the channel to spend the output. -#[no_mangle] -pub extern "C" fn DelayedPaymentOutputDescriptor_set_channel_keys_id(this_ptr: &mut DelayedPaymentOutputDescriptor, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_keys_id = val.data; -} -/// The value of the channel which this output originated from, possibly indirectly. -#[no_mangle] -pub extern "C" fn DelayedPaymentOutputDescriptor_get_channel_value_satoshis(this_ptr: &DelayedPaymentOutputDescriptor) -> u64 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_value_satoshis; - *inner_val -} -/// The value of the channel which this output originated from, possibly indirectly. -#[no_mangle] -pub extern "C" fn DelayedPaymentOutputDescriptor_set_channel_value_satoshis(this_ptr: &mut DelayedPaymentOutputDescriptor, mut val: u64) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_value_satoshis = val; -} -/// Constructs a new DelayedPaymentOutputDescriptor given each field -#[must_use] -#[no_mangle] -pub extern "C" fn DelayedPaymentOutputDescriptor_new(mut outpoint_arg: crate::lightning::chain::transaction::OutPoint, mut per_commitment_point_arg: crate::c_types::PublicKey, mut to_self_delay_arg: u16, mut output_arg: crate::c_types::TxOut, mut revocation_pubkey_arg: crate::c_types::PublicKey, mut channel_keys_id_arg: crate::c_types::ThirtyTwoBytes, mut channel_value_satoshis_arg: u64) -> DelayedPaymentOutputDescriptor { - DelayedPaymentOutputDescriptor { inner: ObjOps::heap_alloc(nativeDelayedPaymentOutputDescriptor { - outpoint: *unsafe { Box::from_raw(outpoint_arg.take_inner()) }, - per_commitment_point: per_commitment_point_arg.into_rust(), - to_self_delay: to_self_delay_arg, - output: output_arg.into_rust(), - revocation_pubkey: revocation_pubkey_arg.into_rust(), - channel_keys_id: channel_keys_id_arg.data, - channel_value_satoshis: channel_value_satoshis_arg, - }), is_owned: true } -} -impl Clone for DelayedPaymentOutputDescriptor { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeDelayedPaymentOutputDescriptor>::is_null(self.inner) { core::ptr::null_mut() } else { - ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, - is_owned: true, - } - } -} -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn DelayedPaymentOutputDescriptor_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeDelayedPaymentOutputDescriptor)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the DelayedPaymentOutputDescriptor -pub extern "C" fn DelayedPaymentOutputDescriptor_clone(orig: &DelayedPaymentOutputDescriptor) -> DelayedPaymentOutputDescriptor { - orig.clone() -} -/// Checks if two DelayedPaymentOutputDescriptors contain equal inner contents. -/// This ignores pointers and is_owned flags and looks at the values in fields. -/// Two objects with NULL inner values will be considered "equal" here. -#[no_mangle] -pub extern "C" fn DelayedPaymentOutputDescriptor_eq(a: &DelayedPaymentOutputDescriptor, b: &DelayedPaymentOutputDescriptor) -> bool { - if a.inner == b.inner { return true; } - if a.inner.is_null() || b.inner.is_null() { return false; } - if a.get_native_ref() == b.get_native_ref() { true } else { false } -} -#[no_mangle] -/// Serialize the DelayedPaymentOutputDescriptor object into a byte array which can be read by DelayedPaymentOutputDescriptor_read -pub extern "C" fn DelayedPaymentOutputDescriptor_write(obj: &crate::lightning::chain::keysinterface::DelayedPaymentOutputDescriptor) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) -} -#[no_mangle] -pub(crate) extern "C" fn DelayedPaymentOutputDescriptor_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeDelayedPaymentOutputDescriptor) }) -} -#[no_mangle] -/// Read a DelayedPaymentOutputDescriptor from a byte array, created by DelayedPaymentOutputDescriptor_write -pub extern "C" fn DelayedPaymentOutputDescriptor_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_DelayedPaymentOutputDescriptorDecodeErrorZ { - let res: Result = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::chain::keysinterface::DelayedPaymentOutputDescriptor { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; - local_res -} - -use lightning::chain::keysinterface::StaticPaymentOutputDescriptor as nativeStaticPaymentOutputDescriptorImport; -pub(crate) type nativeStaticPaymentOutputDescriptor = nativeStaticPaymentOutputDescriptorImport; - -/// Information about a spendable output to our \"payment key\". -/// -/// See [`SpendableOutputDescriptor::StaticPaymentOutput`] for more details on how to spend this. -#[must_use] -#[repr(C)] -pub struct StaticPaymentOutputDescriptor { - /// A pointer to the opaque Rust object. - - /// Nearly everywhere, inner must be non-null, however in places where - /// the Rust equivalent takes an Option, it may be set to null to indicate None. - pub inner: *mut nativeStaticPaymentOutputDescriptor, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for StaticPaymentOutputDescriptor { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeStaticPaymentOutputDescriptor>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; - } - } -} -/// Frees any resources used by the StaticPaymentOutputDescriptor, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn StaticPaymentOutputDescriptor_free(this_obj: StaticPaymentOutputDescriptor) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn StaticPaymentOutputDescriptor_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeStaticPaymentOutputDescriptor) }; -} -#[allow(unused)] -impl StaticPaymentOutputDescriptor { - pub(crate) fn get_native_ref(&self) -> &'static nativeStaticPaymentOutputDescriptor { - unsafe { &*ObjOps::untweak_ptr(self.inner) } - } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeStaticPaymentOutputDescriptor { - unsafe { &mut *ObjOps::untweak_ptr(self.inner) } - } - /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy - pub(crate) fn take_inner(mut self) -> *mut nativeStaticPaymentOutputDescriptor { - assert!(self.is_owned); - let ret = ObjOps::untweak_ptr(self.inner); - self.inner = core::ptr::null_mut(); - ret - } -} -/// The outpoint which is spendable. -#[no_mangle] -pub extern "C" fn StaticPaymentOutputDescriptor_get_outpoint(this_ptr: &StaticPaymentOutputDescriptor) -> crate::lightning::chain::transaction::OutPoint { - let mut inner_val = &mut this_ptr.get_native_mut_ref().outpoint; - crate::lightning::chain::transaction::OutPoint { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::chain::transaction::OutPoint<>) as *mut _) }, is_owned: false } -} -/// The outpoint which is spendable. -#[no_mangle] -pub extern "C" fn StaticPaymentOutputDescriptor_set_outpoint(this_ptr: &mut StaticPaymentOutputDescriptor, mut val: crate::lightning::chain::transaction::OutPoint) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.outpoint = *unsafe { Box::from_raw(val.take_inner()) }; -} -/// The output which is referenced by the given outpoint. -/// -/// Returns a copy of the field. -#[no_mangle] -pub extern "C" fn StaticPaymentOutputDescriptor_get_output(this_ptr: &StaticPaymentOutputDescriptor) -> crate::c_types::TxOut { - let mut inner_val = this_ptr.get_native_mut_ref().output.clone(); - crate::c_types::TxOut::from_rust(inner_val) -} -/// The output which is referenced by the given outpoint. -#[no_mangle] -pub extern "C" fn StaticPaymentOutputDescriptor_set_output(this_ptr: &mut StaticPaymentOutputDescriptor, mut val: crate::c_types::TxOut) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.output = val.into_rust(); -} -/// Arbitrary identification information returned by a call to [`ChannelSigner::channel_keys_id`]. -/// This may be useful in re-deriving keys used in the channel to spend the output. -#[no_mangle] -pub extern "C" fn StaticPaymentOutputDescriptor_get_channel_keys_id(this_ptr: &StaticPaymentOutputDescriptor) -> *const [u8; 32] { - let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_keys_id; - inner_val -} -/// Arbitrary identification information returned by a call to [`ChannelSigner::channel_keys_id`]. -/// This may be useful in re-deriving keys used in the channel to spend the output. -#[no_mangle] -pub extern "C" fn StaticPaymentOutputDescriptor_set_channel_keys_id(this_ptr: &mut StaticPaymentOutputDescriptor, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_keys_id = val.data; -} -/// The value of the channel which this transactions spends. -#[no_mangle] -pub extern "C" fn StaticPaymentOutputDescriptor_get_channel_value_satoshis(this_ptr: &StaticPaymentOutputDescriptor) -> u64 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_value_satoshis; - *inner_val -} -/// The value of the channel which this transactions spends. -#[no_mangle] -pub extern "C" fn StaticPaymentOutputDescriptor_set_channel_value_satoshis(this_ptr: &mut StaticPaymentOutputDescriptor, mut val: u64) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_value_satoshis = val; -} -/// Constructs a new StaticPaymentOutputDescriptor given each field -#[must_use] -#[no_mangle] -pub extern "C" fn StaticPaymentOutputDescriptor_new(mut outpoint_arg: crate::lightning::chain::transaction::OutPoint, mut output_arg: crate::c_types::TxOut, mut channel_keys_id_arg: crate::c_types::ThirtyTwoBytes, mut channel_value_satoshis_arg: u64) -> StaticPaymentOutputDescriptor { - StaticPaymentOutputDescriptor { inner: ObjOps::heap_alloc(nativeStaticPaymentOutputDescriptor { - outpoint: *unsafe { Box::from_raw(outpoint_arg.take_inner()) }, - output: output_arg.into_rust(), - channel_keys_id: channel_keys_id_arg.data, - channel_value_satoshis: channel_value_satoshis_arg, - }), is_owned: true } -} -impl Clone for StaticPaymentOutputDescriptor { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeStaticPaymentOutputDescriptor>::is_null(self.inner) { core::ptr::null_mut() } else { - ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, - is_owned: true, - } - } -} -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn StaticPaymentOutputDescriptor_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeStaticPaymentOutputDescriptor)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the StaticPaymentOutputDescriptor -pub extern "C" fn StaticPaymentOutputDescriptor_clone(orig: &StaticPaymentOutputDescriptor) -> StaticPaymentOutputDescriptor { - orig.clone() -} -/// Checks if two StaticPaymentOutputDescriptors contain equal inner contents. -/// This ignores pointers and is_owned flags and looks at the values in fields. -/// Two objects with NULL inner values will be considered "equal" here. -#[no_mangle] -pub extern "C" fn StaticPaymentOutputDescriptor_eq(a: &StaticPaymentOutputDescriptor, b: &StaticPaymentOutputDescriptor) -> bool { - if a.inner == b.inner { return true; } - if a.inner.is_null() || b.inner.is_null() { return false; } - if a.get_native_ref() == b.get_native_ref() { true } else { false } -} -#[no_mangle] -/// Serialize the StaticPaymentOutputDescriptor object into a byte array which can be read by StaticPaymentOutputDescriptor_read -pub extern "C" fn StaticPaymentOutputDescriptor_write(obj: &crate::lightning::chain::keysinterface::StaticPaymentOutputDescriptor) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) -} -#[no_mangle] -pub(crate) extern "C" fn StaticPaymentOutputDescriptor_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeStaticPaymentOutputDescriptor) }) -} -#[no_mangle] -/// Read a StaticPaymentOutputDescriptor from a byte array, created by StaticPaymentOutputDescriptor_write -pub extern "C" fn StaticPaymentOutputDescriptor_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_StaticPaymentOutputDescriptorDecodeErrorZ { - let res: Result = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::chain::keysinterface::StaticPaymentOutputDescriptor { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; - local_res -} -/// Describes the necessary information to spend a spendable output. -/// -/// When on-chain outputs are created by LDK (which our counterparty is not able to claim at any -/// point in the future) a [`SpendableOutputs`] event is generated which you must track and be able -/// to spend on-chain. The information needed to do this is provided in this enum, including the -/// outpoint describing which `txid` and output `index` is available, the full output which exists -/// at that `txid`/`index`, and any keys or other information required to sign. -/// -/// [`SpendableOutputs`]: crate::events::Event::SpendableOutputs -#[derive(Clone)] -#[must_use] -#[repr(C)] -pub enum SpendableOutputDescriptor { - /// An output to a script which was provided via [`SignerProvider`] directly, either from - /// [`get_destination_script`] or [`get_shutdown_scriptpubkey`], thus you should already - /// know how to spend it. No secret keys are provided as LDK was never given any key. - /// These may include outputs from a transaction punishing our counterparty or claiming an HTLC - /// on-chain using the payment preimage or after it has timed out. - /// - /// [`get_shutdown_scriptpubkey`]: SignerProvider::get_shutdown_scriptpubkey - /// [`get_destination_script`]: SignerProvider::get_shutdown_scriptpubkey - StaticOutput { - /// The outpoint which is spendable. - outpoint: crate::lightning::chain::transaction::OutPoint, - /// The output which is referenced by the given outpoint. - output: crate::c_types::TxOut, - }, - /// An output to a P2WSH script which can be spent with a single signature after an `OP_CSV` - /// delay. - /// - /// The witness in the spending input should be: - /// ```bitcoin - /// (MINIMALIF standard rule) - /// ``` - /// - /// Note that the `nSequence` field in the spending input must be set to - /// [`DelayedPaymentOutputDescriptor::to_self_delay`] (which means the transaction is not - /// broadcastable until at least [`DelayedPaymentOutputDescriptor::to_self_delay`] blocks after - /// the outpoint confirms, see [BIP - /// 68](https://github.com/bitcoin/bips/blob/master/bip-0068.mediawiki)). Also note that LDK - /// won't generate a [`SpendableOutputDescriptor`] until the corresponding block height - /// is reached. - /// - /// These are generally the result of a \"revocable\" output to us, spendable only by us unless - /// it is an output from an old state which we broadcast (which should never happen). - /// - /// To derive the delayed payment key which is used to sign this input, you must pass the - /// holder [`InMemorySigner::delayed_payment_base_key`] (i.e., the private key which corresponds to the - /// [`ChannelPublicKeys::delayed_payment_basepoint`] in [`ChannelSigner::pubkeys`]) and the provided - /// [`DelayedPaymentOutputDescriptor::per_commitment_point`] to [`chan_utils::derive_private_key`]. The public key can be - /// generated without the secret key using [`chan_utils::derive_public_key`] and only the - /// [`ChannelPublicKeys::delayed_payment_basepoint`] which appears in [`ChannelSigner::pubkeys`]. - /// - /// To derive the [`DelayedPaymentOutputDescriptor::revocation_pubkey`] provided here (which is - /// used in the witness script generation), you must pass the counterparty - /// [`ChannelPublicKeys::revocation_basepoint`] (which appears in the call to - /// [`ChannelSigner::provide_channel_parameters`]) and the provided - /// [`DelayedPaymentOutputDescriptor::per_commitment_point`] to - /// [`chan_utils::derive_public_revocation_key`]. - /// - /// The witness script which is hashed and included in the output `script_pubkey` may be - /// regenerated by passing the [`DelayedPaymentOutputDescriptor::revocation_pubkey`] (derived - /// as explained above), our delayed payment pubkey (derived as explained above), and the - /// [`DelayedPaymentOutputDescriptor::to_self_delay`] contained here to - /// [`chan_utils::get_revokeable_redeemscript`]. - DelayedPaymentOutput( - crate::lightning::chain::keysinterface::DelayedPaymentOutputDescriptor), - /// An output to a P2WPKH, spendable exclusively by our payment key (i.e., the private key - /// which corresponds to the `payment_point` in [`ChannelSigner::pubkeys`]). The witness - /// in the spending input is, thus, simply: - /// ```bitcoin - /// - /// ``` - /// - /// These are generally the result of our counterparty having broadcast the current state, - /// allowing us to claim the non-HTLC-encumbered outputs immediately. - StaticPaymentOutput( - crate::lightning::chain::keysinterface::StaticPaymentOutputDescriptor), -} -use lightning::chain::keysinterface::SpendableOutputDescriptor as SpendableOutputDescriptorImport; -pub(crate) type nativeSpendableOutputDescriptor = SpendableOutputDescriptorImport; - -impl SpendableOutputDescriptor { - #[allow(unused)] - pub(crate) fn to_native(&self) -> nativeSpendableOutputDescriptor { - match self { - SpendableOutputDescriptor::StaticOutput {ref outpoint, ref output, } => { - let mut outpoint_nonref = Clone::clone(outpoint); - let mut output_nonref = Clone::clone(output); - nativeSpendableOutputDescriptor::StaticOutput { - outpoint: *unsafe { Box::from_raw(outpoint_nonref.take_inner()) }, - output: output_nonref.into_rust(), - } - }, - SpendableOutputDescriptor::DelayedPaymentOutput (ref a, ) => { - let mut a_nonref = Clone::clone(a); - nativeSpendableOutputDescriptor::DelayedPaymentOutput ( - *unsafe { Box::from_raw(a_nonref.take_inner()) }, - ) - }, - SpendableOutputDescriptor::StaticPaymentOutput (ref a, ) => { - let mut a_nonref = Clone::clone(a); - nativeSpendableOutputDescriptor::StaticPaymentOutput ( - *unsafe { Box::from_raw(a_nonref.take_inner()) }, - ) - }, - } - } - #[allow(unused)] - pub(crate) fn into_native(self) -> nativeSpendableOutputDescriptor { - match self { - SpendableOutputDescriptor::StaticOutput {mut outpoint, mut output, } => { - nativeSpendableOutputDescriptor::StaticOutput { - outpoint: *unsafe { Box::from_raw(outpoint.take_inner()) }, - output: output.into_rust(), - } - }, - SpendableOutputDescriptor::DelayedPaymentOutput (mut a, ) => { - nativeSpendableOutputDescriptor::DelayedPaymentOutput ( - *unsafe { Box::from_raw(a.take_inner()) }, - ) - }, - SpendableOutputDescriptor::StaticPaymentOutput (mut a, ) => { - nativeSpendableOutputDescriptor::StaticPaymentOutput ( - *unsafe { Box::from_raw(a.take_inner()) }, - ) - }, - } - } - #[allow(unused)] - pub(crate) fn from_native(native: &nativeSpendableOutputDescriptor) -> Self { - match native { - nativeSpendableOutputDescriptor::StaticOutput {ref outpoint, ref output, } => { - let mut outpoint_nonref = Clone::clone(outpoint); - let mut output_nonref = Clone::clone(output); - SpendableOutputDescriptor::StaticOutput { - outpoint: crate::lightning::chain::transaction::OutPoint { inner: ObjOps::heap_alloc(outpoint_nonref), is_owned: true }, - output: crate::c_types::TxOut::from_rust(output_nonref), - } - }, - nativeSpendableOutputDescriptor::DelayedPaymentOutput (ref a, ) => { - let mut a_nonref = Clone::clone(a); - SpendableOutputDescriptor::DelayedPaymentOutput ( - crate::lightning::chain::keysinterface::DelayedPaymentOutputDescriptor { inner: ObjOps::heap_alloc(a_nonref), is_owned: true }, - ) - }, - nativeSpendableOutputDescriptor::StaticPaymentOutput (ref a, ) => { - let mut a_nonref = Clone::clone(a); - SpendableOutputDescriptor::StaticPaymentOutput ( - crate::lightning::chain::keysinterface::StaticPaymentOutputDescriptor { inner: ObjOps::heap_alloc(a_nonref), is_owned: true }, - ) - }, - } - } - #[allow(unused)] - pub(crate) fn native_into(native: nativeSpendableOutputDescriptor) -> Self { - match native { - nativeSpendableOutputDescriptor::StaticOutput {mut outpoint, mut output, } => { - SpendableOutputDescriptor::StaticOutput { - outpoint: crate::lightning::chain::transaction::OutPoint { inner: ObjOps::heap_alloc(outpoint), is_owned: true }, - output: crate::c_types::TxOut::from_rust(output), - } - }, - nativeSpendableOutputDescriptor::DelayedPaymentOutput (mut a, ) => { - SpendableOutputDescriptor::DelayedPaymentOutput ( - crate::lightning::chain::keysinterface::DelayedPaymentOutputDescriptor { inner: ObjOps::heap_alloc(a), is_owned: true }, - ) - }, - nativeSpendableOutputDescriptor::StaticPaymentOutput (mut a, ) => { - SpendableOutputDescriptor::StaticPaymentOutput ( - crate::lightning::chain::keysinterface::StaticPaymentOutputDescriptor { inner: ObjOps::heap_alloc(a), is_owned: true }, - ) - }, - } - } -} -/// Frees any resources used by the SpendableOutputDescriptor -#[no_mangle] -pub extern "C" fn SpendableOutputDescriptor_free(this_ptr: SpendableOutputDescriptor) { } -/// Creates a copy of the SpendableOutputDescriptor -#[no_mangle] -pub extern "C" fn SpendableOutputDescriptor_clone(orig: &SpendableOutputDescriptor) -> SpendableOutputDescriptor { - orig.clone() -} -#[no_mangle] -/// Utility method to constructs a new StaticOutput-variant SpendableOutputDescriptor -pub extern "C" fn SpendableOutputDescriptor_static_output(outpoint: crate::lightning::chain::transaction::OutPoint, output: crate::c_types::TxOut) -> SpendableOutputDescriptor { - SpendableOutputDescriptor::StaticOutput { - outpoint, - output, - } -} -#[no_mangle] -/// Utility method to constructs a new DelayedPaymentOutput-variant SpendableOutputDescriptor -pub extern "C" fn SpendableOutputDescriptor_delayed_payment_output(a: crate::lightning::chain::keysinterface::DelayedPaymentOutputDescriptor) -> SpendableOutputDescriptor { - SpendableOutputDescriptor::DelayedPaymentOutput(a, ) -} -#[no_mangle] -/// Utility method to constructs a new StaticPaymentOutput-variant SpendableOutputDescriptor -pub extern "C" fn SpendableOutputDescriptor_static_payment_output(a: crate::lightning::chain::keysinterface::StaticPaymentOutputDescriptor) -> SpendableOutputDescriptor { - SpendableOutputDescriptor::StaticPaymentOutput(a, ) -} -/// Checks if two SpendableOutputDescriptors contain equal inner contents. -/// This ignores pointers and is_owned flags and looks at the values in fields. -#[no_mangle] -pub extern "C" fn SpendableOutputDescriptor_eq(a: &SpendableOutputDescriptor, b: &SpendableOutputDescriptor) -> bool { - if &a.to_native() == &b.to_native() { true } else { false } -} -#[no_mangle] -/// Serialize the SpendableOutputDescriptor object into a byte array which can be read by SpendableOutputDescriptor_read -pub extern "C" fn SpendableOutputDescriptor_write(obj: &crate::lightning::chain::keysinterface::SpendableOutputDescriptor) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(&unsafe { &*obj }.to_native()) -} -#[no_mangle] -/// Read a SpendableOutputDescriptor from a byte array, created by SpendableOutputDescriptor_write -pub extern "C" fn SpendableOutputDescriptor_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_SpendableOutputDescriptorDecodeErrorZ { - let res: Result = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::chain::keysinterface::SpendableOutputDescriptor::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; - local_res -} -/// A trait to handle Lightning channel key material without concretizing the channel type or -/// the signature mechanism. -#[repr(C)] -pub struct ChannelSigner { - /// An opaque pointer which is passed to your function implementations as an argument. - /// This has no meaning in the LDK, and can be NULL or any other value. - pub this_arg: *mut c_void, - /// Gets the per-commitment point for a specific commitment number - /// - /// Note that the commitment number starts at `(1 << 48) - 1` and counts backwards. - #[must_use] - pub get_per_commitment_point: extern "C" fn (this_arg: *const c_void, idx: u64) -> crate::c_types::PublicKey, - /// Gets the commitment secret for a specific commitment number as part of the revocation process - /// - /// An external signer implementation should error here if the commitment was already signed - /// and should refuse to sign it in the future. - /// - /// May be called more than once for the same index. - /// - /// Note that the commitment number starts at `(1 << 48) - 1` and counts backwards. - #[must_use] - pub release_commitment_secret: extern "C" fn (this_arg: *const c_void, idx: u64) -> crate::c_types::ThirtyTwoBytes, - /// Validate the counterparty's signatures on the holder commitment transaction and HTLCs. - /// - /// This is required in order for the signer to make sure that releasing a commitment - /// secret won't leave us without a broadcastable holder transaction. - /// Policy checks should be implemented in this function, including checking the amount - /// sent to us and checking the HTLCs. - /// - /// The preimages of outgoing HTLCs that were fulfilled since the last commitment are provided. - /// A validating signer should ensure that an HTLC output is removed only when the matching - /// preimage is provided, or when the value to holder is restored. - /// - /// Note that all the relevant preimages will be provided, but there may also be additional - /// irrelevant or duplicate preimages. - #[must_use] - pub validate_holder_commitment: extern "C" fn (this_arg: *const c_void, holder_tx: &crate::lightning::ln::chan_utils::HolderCommitmentTransaction, preimages: crate::c_types::derived::CVec_PaymentPreimageZ) -> crate::c_types::derived::CResult_NoneNoneZ, - /// Returns the holder's channel public keys and basepoints. - pub pubkeys: core::cell::UnsafeCell, - /// Fill in the pubkeys field as a reference to it will be given to Rust after this returns - /// Note that this takes a pointer to this object, not the this_ptr like other methods do - /// This function pointer may be NULL if pubkeys is filled in when this object is created and never needs updating. - pub set_pubkeys: Option, - /// Returns an arbitrary identifier describing the set of keys which are provided back to you in - /// some [`SpendableOutputDescriptor`] types. This should be sufficient to identify this - /// [`EcdsaChannelSigner`] object uniquely and lookup or re-derive its keys. - #[must_use] - pub channel_keys_id: extern "C" fn (this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes, - /// Set the counterparty static channel data, including basepoints, - /// `counterparty_selected`/`holder_selected_contest_delay` and funding outpoint. - /// - /// This data is static, and will never change for a channel once set. For a given [`ChannelSigner`] - /// instance, LDK will call this method exactly once - either immediately after construction - /// (not including if done via [`SignerProvider::read_chan_signer`]) or when the funding - /// information has been generated. - /// - /// channel_parameters.is_populated() MUST be true. - pub provide_channel_parameters: extern "C" fn (this_arg: *mut c_void, channel_parameters: &crate::lightning::ln::chan_utils::ChannelTransactionParameters), - /// Frees any resources associated with this object given its this_arg pointer. - /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. - pub free: Option, -} -unsafe impl Send for ChannelSigner {} -unsafe impl Sync for ChannelSigner {} -#[no_mangle] -pub(crate) extern "C" fn ChannelSigner_clone_fields(orig: &ChannelSigner) -> ChannelSigner { - ChannelSigner { - this_arg: orig.this_arg, - get_per_commitment_point: Clone::clone(&orig.get_per_commitment_point), - release_commitment_secret: Clone::clone(&orig.release_commitment_secret), - validate_holder_commitment: Clone::clone(&orig.validate_holder_commitment), - pubkeys: Clone::clone(unsafe { &*core::cell::UnsafeCell::get(&orig.pubkeys)}).into(), - set_pubkeys: Clone::clone(&orig.set_pubkeys), - channel_keys_id: Clone::clone(&orig.channel_keys_id), - provide_channel_parameters: Clone::clone(&orig.provide_channel_parameters), - free: Clone::clone(&orig.free), - } -} - -use lightning::chain::keysinterface::ChannelSigner as rustChannelSigner; -impl rustChannelSigner for ChannelSigner { - fn get_per_commitment_point(&self, mut idx: u64, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> bitcoin::secp256k1::PublicKey { - let mut ret = (self.get_per_commitment_point)(self.this_arg, idx); - ret.into_rust() - } - fn release_commitment_secret(&self, mut idx: u64) -> [u8; 32] { - let mut ret = (self.release_commitment_secret)(self.this_arg, idx); - ret.data - } - fn validate_holder_commitment(&self, mut holder_tx: &lightning::ln::chan_utils::HolderCommitmentTransaction, mut preimages: Vec) -> Result<(), ()> { - let mut local_preimages = Vec::new(); for mut item in preimages.drain(..) { local_preimages.push( { crate::c_types::ThirtyTwoBytes { data: item.0 } }); }; - let mut ret = (self.validate_holder_commitment)(self.this_arg, &crate::lightning::ln::chan_utils::HolderCommitmentTransaction { inner: unsafe { ObjOps::nonnull_ptr_to_inner((holder_tx as *const lightning::ln::chan_utils::HolderCommitmentTransaction<>) as *mut _) }, is_owned: false }, local_preimages.into()); - let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; - local_ret - } - fn pubkeys(&self) -> &lightning::ln::chan_utils::ChannelPublicKeys { - if let Some(f) = self.set_pubkeys { - (f)(&self); - } - unsafe { &*self.pubkeys.get() }.get_native_ref() - } - fn channel_keys_id(&self) -> [u8; 32] { - let mut ret = (self.channel_keys_id)(self.this_arg); - ret.data - } - fn provide_channel_parameters(&mut self, mut channel_parameters: &lightning::ln::chan_utils::ChannelTransactionParameters) { - (self.provide_channel_parameters)(self.this_arg, &crate::lightning::ln::chan_utils::ChannelTransactionParameters { inner: unsafe { ObjOps::nonnull_ptr_to_inner((channel_parameters as *const lightning::ln::chan_utils::ChannelTransactionParameters<>) as *mut _) }, is_owned: false }) - } -} - -// We're essentially a pointer already, or at least a set of pointers, so allow us to be used -// directly as a Deref trait in higher-level structs: -impl core::ops::Deref for ChannelSigner { - type Target = Self; - fn deref(&self) -> &Self { - self - } -} -/// Calls the free function if one is set -#[no_mangle] -pub extern "C" fn ChannelSigner_free(this_ptr: ChannelSigner) { } -impl Drop for ChannelSigner { - fn drop(&mut self) { - if let Some(f) = self.free { - f(self.this_arg); - } - } -} -/// A trait to sign Lightning channel transactions as described in -/// [BOLT 3](https://github.com/lightning/bolts/blob/master/03-transactions.md). -/// -/// Signing services could be implemented on a hardware wallet and should implement signing -/// policies in order to be secure. Please refer to the [VLS Policy -/// Controls](https://gitlab.com/lightning-signer/validating-lightning-signer/-/blob/main/docs/policy-controls.md) -/// for an example of such policies. -#[repr(C)] -pub struct EcdsaChannelSigner { - /// An opaque pointer which is passed to your function implementations as an argument. - /// This has no meaning in the LDK, and can be NULL or any other value. - pub this_arg: *mut c_void, - /// Create a signature for a counterparty's commitment transaction and associated HTLC transactions. - /// - /// Note that if signing fails or is rejected, the channel will be force-closed. - /// - /// Policy checks should be implemented in this function, including checking the amount - /// sent to us and checking the HTLCs. - /// - /// The preimages of outgoing HTLCs that were fulfilled since the last commitment are provided. - /// A validating signer should ensure that an HTLC output is removed only when the matching - /// preimage is provided, or when the value to holder is restored. - /// - /// Note that all the relevant preimages will be provided, but there may also be additional - /// irrelevant or duplicate preimages. - #[must_use] - pub sign_counterparty_commitment: extern "C" fn (this_arg: *const c_void, commitment_tx: &crate::lightning::ln::chan_utils::CommitmentTransaction, preimages: crate::c_types::derived::CVec_PaymentPreimageZ) -> crate::c_types::derived::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ, - /// Validate the counterparty's revocation. - /// - /// This is required in order for the signer to make sure that the state has moved - /// forward and it is safe to sign the next counterparty commitment. - #[must_use] - pub validate_counterparty_revocation: extern "C" fn (this_arg: *const c_void, idx: u64, secret: *const [u8; 32]) -> crate::c_types::derived::CResult_NoneNoneZ, - /// Creates a signature for a holder's commitment transaction and its claiming HTLC transactions. - /// - /// This will be called - /// - with a non-revoked `commitment_tx`. - /// - with the latest `commitment_tx` when we initiate a force-close. - /// - with the previous `commitment_tx`, just to get claiming HTLC - /// signatures, if we are reacting to a [`ChannelMonitor`] - /// [replica](https://github.com/lightningdevkit/rust-lightning/blob/main/GLOSSARY.md#monitor-replicas) - /// that decided to broadcast before it had been updated to the latest `commitment_tx`. - /// - /// This may be called multiple times for the same transaction. - /// - /// An external signer implementation should check that the commitment has not been revoked. - /// - /// [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor - #[must_use] - pub sign_holder_commitment_and_htlcs: extern "C" fn (this_arg: *const c_void, commitment_tx: &crate::lightning::ln::chan_utils::HolderCommitmentTransaction) -> crate::c_types::derived::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ, - /// Create a signature for the given input in a transaction spending an HTLC transaction output - /// or a commitment transaction `to_local` output when our counterparty broadcasts an old state. - /// - /// A justice transaction may claim multiple outputs at the same time if timelocks are - /// similar, but only a signature for the input at index `input` should be signed for here. - /// It may be called multiple times for same output(s) if a fee-bump is needed with regards - /// to an upcoming timelock expiration. - /// - /// Amount is value of the output spent by this input, committed to in the BIP 143 signature. - /// - /// `per_commitment_key` is revocation secret which was provided by our counterparty when they - /// revoked the state which they eventually broadcast. It's not a _holder_ secret key and does - /// not allow the spending of any funds by itself (you need our holder `revocation_secret` to do - /// so). - #[must_use] - pub sign_justice_revoked_output: extern "C" fn (this_arg: *const c_void, justice_tx: crate::c_types::Transaction, input: usize, amount: u64, per_commitment_key: *const [u8; 32]) -> crate::c_types::derived::CResult_SignatureNoneZ, - /// Create a signature for the given input in a transaction spending a commitment transaction - /// HTLC output when our counterparty broadcasts an old state. - /// - /// A justice transaction may claim multiple outputs at the same time if timelocks are - /// similar, but only a signature for the input at index `input` should be signed for here. - /// It may be called multiple times for same output(s) if a fee-bump is needed with regards - /// to an upcoming timelock expiration. - /// - /// `amount` is the value of the output spent by this input, committed to in the BIP 143 - /// signature. - /// - /// `per_commitment_key` is revocation secret which was provided by our counterparty when they - /// revoked the state which they eventually broadcast. It's not a _holder_ secret key and does - /// not allow the spending of any funds by itself (you need our holder revocation_secret to do - /// so). - /// - /// `htlc` holds HTLC elements (hash, timelock), thus changing the format of the witness script - /// (which is committed to in the BIP 143 signatures). - #[must_use] - pub sign_justice_revoked_htlc: extern "C" fn (this_arg: *const c_void, justice_tx: crate::c_types::Transaction, input: usize, amount: u64, per_commitment_key: *const [u8; 32], htlc: &crate::lightning::ln::chan_utils::HTLCOutputInCommitment) -> crate::c_types::derived::CResult_SignatureNoneZ, - /// Create a signature for a claiming transaction for a HTLC output on a counterparty's commitment - /// transaction, either offered or received. - /// - /// Such a transaction may claim multiples offered outputs at same time if we know the - /// preimage for each when we create it, but only the input at index `input` should be - /// signed for here. It may be called multiple times for same output(s) if a fee-bump is - /// needed with regards to an upcoming timelock expiration. - /// - /// `witness_script` is either an offered or received script as defined in BOLT3 for HTLC - /// outputs. - /// - /// `amount` is value of the output spent by this input, committed to in the BIP 143 signature. - /// - /// `per_commitment_point` is the dynamic point corresponding to the channel state - /// detected onchain. It has been generated by our counterparty and is used to derive - /// channel state keys, which are then included in the witness script and committed to in the - /// BIP 143 signature. - #[must_use] - pub sign_counterparty_htlc_transaction: extern "C" fn (this_arg: *const c_void, htlc_tx: crate::c_types::Transaction, input: usize, amount: u64, per_commitment_point: crate::c_types::PublicKey, htlc: &crate::lightning::ln::chan_utils::HTLCOutputInCommitment) -> crate::c_types::derived::CResult_SignatureNoneZ, - /// Create a signature for a (proposed) closing transaction. - /// - /// Note that, due to rounding, there may be one \"missing\" satoshi, and either party may have - /// chosen to forgo their output as dust. - #[must_use] - pub sign_closing_transaction: extern "C" fn (this_arg: *const c_void, closing_tx: &crate::lightning::ln::chan_utils::ClosingTransaction) -> crate::c_types::derived::CResult_SignatureNoneZ, - /// Computes the signature for a commitment transaction's anchor output used as an - /// input within `anchor_tx`, which spends the commitment transaction, at index `input`. - #[must_use] - pub sign_holder_anchor_input: extern "C" fn (this_arg: *const c_void, anchor_tx: crate::c_types::Transaction, input: usize) -> crate::c_types::derived::CResult_SignatureNoneZ, - /// Signs a channel announcement message with our funding key proving it comes from one of the - /// channel participants. - /// - /// Channel announcements also require a signature from each node's network key. Our node - /// signature is computed through [`NodeSigner::sign_gossip_message`]. - /// - /// Note that if this fails or is rejected, the channel will not be publicly announced and - /// our counterparty may (though likely will not) close the channel on us for violating the - /// protocol. - #[must_use] - pub sign_channel_announcement_with_funding_key: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::UnsignedChannelAnnouncement) -> crate::c_types::derived::CResult_SignatureNoneZ, - /// Implementation of ChannelSigner for this object. - pub ChannelSigner: crate::lightning::chain::keysinterface::ChannelSigner, - /// Frees any resources associated with this object given its this_arg pointer. - /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. - pub free: Option, -} -unsafe impl Send for EcdsaChannelSigner {} -unsafe impl Sync for EcdsaChannelSigner {} -#[no_mangle] -pub(crate) extern "C" fn EcdsaChannelSigner_clone_fields(orig: &EcdsaChannelSigner) -> EcdsaChannelSigner { - EcdsaChannelSigner { - this_arg: orig.this_arg, - sign_counterparty_commitment: Clone::clone(&orig.sign_counterparty_commitment), - validate_counterparty_revocation: Clone::clone(&orig.validate_counterparty_revocation), - sign_holder_commitment_and_htlcs: Clone::clone(&orig.sign_holder_commitment_and_htlcs), - sign_justice_revoked_output: Clone::clone(&orig.sign_justice_revoked_output), - sign_justice_revoked_htlc: Clone::clone(&orig.sign_justice_revoked_htlc), - sign_counterparty_htlc_transaction: Clone::clone(&orig.sign_counterparty_htlc_transaction), - sign_closing_transaction: Clone::clone(&orig.sign_closing_transaction), - sign_holder_anchor_input: Clone::clone(&orig.sign_holder_anchor_input), - sign_channel_announcement_with_funding_key: Clone::clone(&orig.sign_channel_announcement_with_funding_key), - ChannelSigner: crate::lightning::chain::keysinterface::ChannelSigner_clone_fields(&orig.ChannelSigner), - free: Clone::clone(&orig.free), - } -} -impl lightning::chain::keysinterface::ChannelSigner for EcdsaChannelSigner { - fn get_per_commitment_point(&self, mut idx: u64, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> bitcoin::secp256k1::PublicKey { - let mut ret = (self.ChannelSigner.get_per_commitment_point)(self.ChannelSigner.this_arg, idx); - ret.into_rust() - } - fn release_commitment_secret(&self, mut idx: u64) -> [u8; 32] { - let mut ret = (self.ChannelSigner.release_commitment_secret)(self.ChannelSigner.this_arg, idx); - ret.data - } - fn validate_holder_commitment(&self, mut holder_tx: &lightning::ln::chan_utils::HolderCommitmentTransaction, mut preimages: Vec) -> Result<(), ()> { - let mut local_preimages = Vec::new(); for mut item in preimages.drain(..) { local_preimages.push( { crate::c_types::ThirtyTwoBytes { data: item.0 } }); }; - let mut ret = (self.ChannelSigner.validate_holder_commitment)(self.ChannelSigner.this_arg, &crate::lightning::ln::chan_utils::HolderCommitmentTransaction { inner: unsafe { ObjOps::nonnull_ptr_to_inner((holder_tx as *const lightning::ln::chan_utils::HolderCommitmentTransaction<>) as *mut _) }, is_owned: false }, local_preimages.into()); - let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; - local_ret - } - fn pubkeys(&self) -> &lightning::ln::chan_utils::ChannelPublicKeys { - if let Some(f) = self.ChannelSigner.set_pubkeys { - (f)(&self.ChannelSigner); - } - unsafe { &*self.ChannelSigner.pubkeys.get() }.get_native_ref() - } - fn channel_keys_id(&self) -> [u8; 32] { - let mut ret = (self.ChannelSigner.channel_keys_id)(self.ChannelSigner.this_arg); - ret.data - } - fn provide_channel_parameters(&mut self, mut channel_parameters: &lightning::ln::chan_utils::ChannelTransactionParameters) { - (self.ChannelSigner.provide_channel_parameters)(self.ChannelSigner.this_arg, &crate::lightning::ln::chan_utils::ChannelTransactionParameters { inner: unsafe { ObjOps::nonnull_ptr_to_inner((channel_parameters as *const lightning::ln::chan_utils::ChannelTransactionParameters<>) as *mut _) }, is_owned: false }) - } -} - -use lightning::chain::keysinterface::EcdsaChannelSigner as rustEcdsaChannelSigner; -impl rustEcdsaChannelSigner for EcdsaChannelSigner { - fn sign_counterparty_commitment(&self, mut commitment_tx: &lightning::ln::chan_utils::CommitmentTransaction, mut preimages: Vec, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result<(bitcoin::secp256k1::ecdsa::Signature, Vec), ()> { - let mut local_preimages = Vec::new(); for mut item in preimages.drain(..) { local_preimages.push( { crate::c_types::ThirtyTwoBytes { data: item.0 } }); }; - let mut ret = (self.sign_counterparty_commitment)(self.this_arg, &crate::lightning::ln::chan_utils::CommitmentTransaction { inner: unsafe { ObjOps::nonnull_ptr_to_inner((commitment_tx as *const lightning::ln::chan_utils::CommitmentTransaction<>) as *mut _) }, is_owned: false }, local_preimages.into()); - let mut local_ret = match ret.result_ok { true => Ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).to_rust(); let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.into_rust().drain(..) { local_orig_ret_0_1.push( { item.into_rust() }); }; let mut local_ret_0 = (orig_ret_0_0.into_rust(), local_orig_ret_0_1); local_ret_0 }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; - local_ret - } - fn validate_counterparty_revocation(&self, mut idx: u64, mut secret: &bitcoin::secp256k1::SecretKey) -> Result<(), ()> { - let mut ret = (self.validate_counterparty_revocation)(self.this_arg, idx, secret.as_ref()); - let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; - local_ret - } - fn sign_holder_commitment_and_htlcs(&self, mut commitment_tx: &lightning::ln::chan_utils::HolderCommitmentTransaction, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result<(bitcoin::secp256k1::ecdsa::Signature, Vec), ()> { - let mut ret = (self.sign_holder_commitment_and_htlcs)(self.this_arg, &crate::lightning::ln::chan_utils::HolderCommitmentTransaction { inner: unsafe { ObjOps::nonnull_ptr_to_inner((commitment_tx as *const lightning::ln::chan_utils::HolderCommitmentTransaction<>) as *mut _) }, is_owned: false }); - let mut local_ret = match ret.result_ok { true => Ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).to_rust(); let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.into_rust().drain(..) { local_orig_ret_0_1.push( { item.into_rust() }); }; let mut local_ret_0 = (orig_ret_0_0.into_rust(), local_orig_ret_0_1); local_ret_0 }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; - local_ret - } - fn sign_justice_revoked_output(&self, mut justice_tx: &bitcoin::blockdata::transaction::Transaction, mut input: usize, mut amount: u64, mut per_commitment_key: &bitcoin::secp256k1::SecretKey, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { - let mut ret = (self.sign_justice_revoked_output)(self.this_arg, crate::c_types::Transaction::from_bitcoin(justice_tx), input, amount, per_commitment_key.as_ref()); - let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; - local_ret - } - fn sign_justice_revoked_htlc(&self, mut justice_tx: &bitcoin::blockdata::transaction::Transaction, mut input: usize, mut amount: u64, mut per_commitment_key: &bitcoin::secp256k1::SecretKey, mut htlc: &lightning::ln::chan_utils::HTLCOutputInCommitment, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { - let mut ret = (self.sign_justice_revoked_htlc)(self.this_arg, crate::c_types::Transaction::from_bitcoin(justice_tx), input, amount, per_commitment_key.as_ref(), &crate::lightning::ln::chan_utils::HTLCOutputInCommitment { inner: unsafe { ObjOps::nonnull_ptr_to_inner((htlc as *const lightning::ln::chan_utils::HTLCOutputInCommitment<>) as *mut _) }, is_owned: false }); - let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; - local_ret - } - fn sign_counterparty_htlc_transaction(&self, mut htlc_tx: &bitcoin::blockdata::transaction::Transaction, mut input: usize, mut amount: u64, mut per_commitment_point: &bitcoin::secp256k1::PublicKey, mut htlc: &lightning::ln::chan_utils::HTLCOutputInCommitment, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { - let mut ret = (self.sign_counterparty_htlc_transaction)(self.this_arg, crate::c_types::Transaction::from_bitcoin(htlc_tx), input, amount, crate::c_types::PublicKey::from_rust(&per_commitment_point), &crate::lightning::ln::chan_utils::HTLCOutputInCommitment { inner: unsafe { ObjOps::nonnull_ptr_to_inner((htlc as *const lightning::ln::chan_utils::HTLCOutputInCommitment<>) as *mut _) }, is_owned: false }); - let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; - local_ret - } - fn sign_closing_transaction(&self, mut closing_tx: &lightning::ln::chan_utils::ClosingTransaction, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { - let mut ret = (self.sign_closing_transaction)(self.this_arg, &crate::lightning::ln::chan_utils::ClosingTransaction { inner: unsafe { ObjOps::nonnull_ptr_to_inner((closing_tx as *const lightning::ln::chan_utils::ClosingTransaction<>) as *mut _) }, is_owned: false }); - let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; - local_ret - } - fn sign_holder_anchor_input(&self, mut anchor_tx: &bitcoin::blockdata::transaction::Transaction, mut input: usize, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { - let mut ret = (self.sign_holder_anchor_input)(self.this_arg, crate::c_types::Transaction::from_bitcoin(anchor_tx), input); - let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; - local_ret - } - fn sign_channel_announcement_with_funding_key(&self, mut msg: &lightning::ln::msgs::UnsignedChannelAnnouncement, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { - let mut ret = (self.sign_channel_announcement_with_funding_key)(self.this_arg, &crate::lightning::ln::msgs::UnsignedChannelAnnouncement { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::UnsignedChannelAnnouncement<>) as *mut _) }, is_owned: false }); - let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; - local_ret - } -} - -// We're essentially a pointer already, or at least a set of pointers, so allow us to be used -// directly as a Deref trait in higher-level structs: -impl core::ops::Deref for EcdsaChannelSigner { - type Target = Self; - fn deref(&self) -> &Self { - self - } -} -/// Calls the free function if one is set -#[no_mangle] -pub extern "C" fn EcdsaChannelSigner_free(this_ptr: EcdsaChannelSigner) { } -impl Drop for EcdsaChannelSigner { - fn drop(&mut self) { - if let Some(f) = self.free { - f(self.this_arg); - } - } -} -/// A writeable signer. -/// -/// There will always be two instances of a signer per channel, one occupied by the -/// [`ChannelManager`] and another by the channel's [`ChannelMonitor`]. -/// -/// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager -/// [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor -#[repr(C)] -pub struct WriteableEcdsaChannelSigner { - /// An opaque pointer which is passed to your function implementations as an argument. - /// This has no meaning in the LDK, and can be NULL or any other value. - pub this_arg: *mut c_void, - /// Implementation of EcdsaChannelSigner for this object. - pub EcdsaChannelSigner: crate::lightning::chain::keysinterface::EcdsaChannelSigner, - /// Serialize the object into a byte array - pub write: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_u8Z, - /// Frees any resources associated with this object given its this_arg pointer. - /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. - pub free: Option, -} -unsafe impl Send for WriteableEcdsaChannelSigner {} -unsafe impl Sync for WriteableEcdsaChannelSigner {} -#[no_mangle] -pub(crate) extern "C" fn WriteableEcdsaChannelSigner_clone_fields(orig: &WriteableEcdsaChannelSigner) -> WriteableEcdsaChannelSigner { - WriteableEcdsaChannelSigner { - this_arg: orig.this_arg, - EcdsaChannelSigner: crate::lightning::chain::keysinterface::EcdsaChannelSigner_clone_fields(&orig.EcdsaChannelSigner), - write: Clone::clone(&orig.write), - free: Clone::clone(&orig.free), - } -} -impl lightning::chain::keysinterface::EcdsaChannelSigner for WriteableEcdsaChannelSigner { - fn sign_counterparty_commitment(&self, mut commitment_tx: &lightning::ln::chan_utils::CommitmentTransaction, mut preimages: Vec, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result<(bitcoin::secp256k1::ecdsa::Signature, Vec), ()> { - let mut local_preimages = Vec::new(); for mut item in preimages.drain(..) { local_preimages.push( { crate::c_types::ThirtyTwoBytes { data: item.0 } }); }; - let mut ret = (self.EcdsaChannelSigner.sign_counterparty_commitment)(self.EcdsaChannelSigner.this_arg, &crate::lightning::ln::chan_utils::CommitmentTransaction { inner: unsafe { ObjOps::nonnull_ptr_to_inner((commitment_tx as *const lightning::ln::chan_utils::CommitmentTransaction<>) as *mut _) }, is_owned: false }, local_preimages.into()); - let mut local_ret = match ret.result_ok { true => Ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).to_rust(); let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.into_rust().drain(..) { local_orig_ret_0_1.push( { item.into_rust() }); }; let mut local_ret_0 = (orig_ret_0_0.into_rust(), local_orig_ret_0_1); local_ret_0 }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; - local_ret - } - fn validate_counterparty_revocation(&self, mut idx: u64, mut secret: &bitcoin::secp256k1::SecretKey) -> Result<(), ()> { - let mut ret = (self.EcdsaChannelSigner.validate_counterparty_revocation)(self.EcdsaChannelSigner.this_arg, idx, secret.as_ref()); - let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; - local_ret - } - fn sign_holder_commitment_and_htlcs(&self, mut commitment_tx: &lightning::ln::chan_utils::HolderCommitmentTransaction, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result<(bitcoin::secp256k1::ecdsa::Signature, Vec), ()> { - let mut ret = (self.EcdsaChannelSigner.sign_holder_commitment_and_htlcs)(self.EcdsaChannelSigner.this_arg, &crate::lightning::ln::chan_utils::HolderCommitmentTransaction { inner: unsafe { ObjOps::nonnull_ptr_to_inner((commitment_tx as *const lightning::ln::chan_utils::HolderCommitmentTransaction<>) as *mut _) }, is_owned: false }); - let mut local_ret = match ret.result_ok { true => Ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).to_rust(); let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.into_rust().drain(..) { local_orig_ret_0_1.push( { item.into_rust() }); }; let mut local_ret_0 = (orig_ret_0_0.into_rust(), local_orig_ret_0_1); local_ret_0 }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; - local_ret - } - fn sign_justice_revoked_output(&self, mut justice_tx: &bitcoin::blockdata::transaction::Transaction, mut input: usize, mut amount: u64, mut per_commitment_key: &bitcoin::secp256k1::SecretKey, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { - let mut ret = (self.EcdsaChannelSigner.sign_justice_revoked_output)(self.EcdsaChannelSigner.this_arg, crate::c_types::Transaction::from_bitcoin(justice_tx), input, amount, per_commitment_key.as_ref()); - let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; - local_ret - } - fn sign_justice_revoked_htlc(&self, mut justice_tx: &bitcoin::blockdata::transaction::Transaction, mut input: usize, mut amount: u64, mut per_commitment_key: &bitcoin::secp256k1::SecretKey, mut htlc: &lightning::ln::chan_utils::HTLCOutputInCommitment, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { - let mut ret = (self.EcdsaChannelSigner.sign_justice_revoked_htlc)(self.EcdsaChannelSigner.this_arg, crate::c_types::Transaction::from_bitcoin(justice_tx), input, amount, per_commitment_key.as_ref(), &crate::lightning::ln::chan_utils::HTLCOutputInCommitment { inner: unsafe { ObjOps::nonnull_ptr_to_inner((htlc as *const lightning::ln::chan_utils::HTLCOutputInCommitment<>) as *mut _) }, is_owned: false }); - let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; - local_ret - } - fn sign_counterparty_htlc_transaction(&self, mut htlc_tx: &bitcoin::blockdata::transaction::Transaction, mut input: usize, mut amount: u64, mut per_commitment_point: &bitcoin::secp256k1::PublicKey, mut htlc: &lightning::ln::chan_utils::HTLCOutputInCommitment, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { - let mut ret = (self.EcdsaChannelSigner.sign_counterparty_htlc_transaction)(self.EcdsaChannelSigner.this_arg, crate::c_types::Transaction::from_bitcoin(htlc_tx), input, amount, crate::c_types::PublicKey::from_rust(&per_commitment_point), &crate::lightning::ln::chan_utils::HTLCOutputInCommitment { inner: unsafe { ObjOps::nonnull_ptr_to_inner((htlc as *const lightning::ln::chan_utils::HTLCOutputInCommitment<>) as *mut _) }, is_owned: false }); - let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; - local_ret - } - fn sign_closing_transaction(&self, mut closing_tx: &lightning::ln::chan_utils::ClosingTransaction, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { - let mut ret = (self.EcdsaChannelSigner.sign_closing_transaction)(self.EcdsaChannelSigner.this_arg, &crate::lightning::ln::chan_utils::ClosingTransaction { inner: unsafe { ObjOps::nonnull_ptr_to_inner((closing_tx as *const lightning::ln::chan_utils::ClosingTransaction<>) as *mut _) }, is_owned: false }); - let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; - local_ret - } - fn sign_holder_anchor_input(&self, mut anchor_tx: &bitcoin::blockdata::transaction::Transaction, mut input: usize, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { - let mut ret = (self.EcdsaChannelSigner.sign_holder_anchor_input)(self.EcdsaChannelSigner.this_arg, crate::c_types::Transaction::from_bitcoin(anchor_tx), input); - let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; - local_ret - } - fn sign_channel_announcement_with_funding_key(&self, mut msg: &lightning::ln::msgs::UnsignedChannelAnnouncement, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { - let mut ret = (self.EcdsaChannelSigner.sign_channel_announcement_with_funding_key)(self.EcdsaChannelSigner.this_arg, &crate::lightning::ln::msgs::UnsignedChannelAnnouncement { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::UnsignedChannelAnnouncement<>) as *mut _) }, is_owned: false }); - let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; - local_ret - } -} -impl lightning::chain::keysinterface::ChannelSigner for WriteableEcdsaChannelSigner { - fn get_per_commitment_point(&self, mut idx: u64, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> bitcoin::secp256k1::PublicKey { - let mut ret = (self.EcdsaChannelSigner.ChannelSigner.get_per_commitment_point)(self.EcdsaChannelSigner.ChannelSigner.this_arg, idx); - ret.into_rust() - } - fn release_commitment_secret(&self, mut idx: u64) -> [u8; 32] { - let mut ret = (self.EcdsaChannelSigner.ChannelSigner.release_commitment_secret)(self.EcdsaChannelSigner.ChannelSigner.this_arg, idx); - ret.data - } - fn validate_holder_commitment(&self, mut holder_tx: &lightning::ln::chan_utils::HolderCommitmentTransaction, mut preimages: Vec) -> Result<(), ()> { - let mut local_preimages = Vec::new(); for mut item in preimages.drain(..) { local_preimages.push( { crate::c_types::ThirtyTwoBytes { data: item.0 } }); }; - let mut ret = (self.EcdsaChannelSigner.ChannelSigner.validate_holder_commitment)(self.EcdsaChannelSigner.ChannelSigner.this_arg, &crate::lightning::ln::chan_utils::HolderCommitmentTransaction { inner: unsafe { ObjOps::nonnull_ptr_to_inner((holder_tx as *const lightning::ln::chan_utils::HolderCommitmentTransaction<>) as *mut _) }, is_owned: false }, local_preimages.into()); - let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; - local_ret - } - fn pubkeys(&self) -> &lightning::ln::chan_utils::ChannelPublicKeys { - if let Some(f) = self.EcdsaChannelSigner.ChannelSigner.set_pubkeys { - (f)(&self.EcdsaChannelSigner.ChannelSigner); - } - unsafe { &*self.EcdsaChannelSigner.ChannelSigner.pubkeys.get() }.get_native_ref() - } - fn channel_keys_id(&self) -> [u8; 32] { - let mut ret = (self.EcdsaChannelSigner.ChannelSigner.channel_keys_id)(self.EcdsaChannelSigner.ChannelSigner.this_arg); - ret.data - } - fn provide_channel_parameters(&mut self, mut channel_parameters: &lightning::ln::chan_utils::ChannelTransactionParameters) { - (self.EcdsaChannelSigner.ChannelSigner.provide_channel_parameters)(self.EcdsaChannelSigner.ChannelSigner.this_arg, &crate::lightning::ln::chan_utils::ChannelTransactionParameters { inner: unsafe { ObjOps::nonnull_ptr_to_inner((channel_parameters as *const lightning::ln::chan_utils::ChannelTransactionParameters<>) as *mut _) }, is_owned: false }) - } -} -impl lightning::util::ser::Writeable for WriteableEcdsaChannelSigner { - fn write(&self, w: &mut W) -> Result<(), crate::c_types::io::Error> { - let vec = (self.write)(self.this_arg); - w.write_all(vec.as_slice()) - } -} - -use lightning::chain::keysinterface::WriteableEcdsaChannelSigner as rustWriteableEcdsaChannelSigner; -impl rustWriteableEcdsaChannelSigner for WriteableEcdsaChannelSigner { -} - -// We're essentially a pointer already, or at least a set of pointers, so allow us to be used -// directly as a Deref trait in higher-level structs: -impl core::ops::Deref for WriteableEcdsaChannelSigner { - type Target = Self; - fn deref(&self) -> &Self { - self - } -} -/// Calls the free function if one is set -#[no_mangle] -pub extern "C" fn WriteableEcdsaChannelSigner_free(this_ptr: WriteableEcdsaChannelSigner) { } -impl Drop for WriteableEcdsaChannelSigner { - fn drop(&mut self) { - if let Some(f) = self.free { - f(self.this_arg); - } - } -} -/// Specifies the recipient of an invoice. -/// -/// This indicates to [`NodeSigner::sign_invoice`] what node secret key should be used to sign -/// the invoice. -#[derive(Clone)] -#[must_use] -#[repr(C)] -pub enum Recipient { - /// The invoice should be signed with the local node secret key. - Node, - /// The invoice should be signed with the phantom node secret key. This secret key must be the - /// same for all nodes participating in the [phantom node payment]. - /// - /// [phantom node payment]: PhantomKeysManager - PhantomNode, -} -use lightning::chain::keysinterface::Recipient as RecipientImport; -pub(crate) type nativeRecipient = RecipientImport; - -impl Recipient { - #[allow(unused)] - pub(crate) fn to_native(&self) -> nativeRecipient { - match self { - Recipient::Node => nativeRecipient::Node, - Recipient::PhantomNode => nativeRecipient::PhantomNode, - } - } - #[allow(unused)] - pub(crate) fn into_native(self) -> nativeRecipient { - match self { - Recipient::Node => nativeRecipient::Node, - Recipient::PhantomNode => nativeRecipient::PhantomNode, - } - } - #[allow(unused)] - pub(crate) fn from_native(native: &nativeRecipient) -> Self { - match native { - nativeRecipient::Node => Recipient::Node, - nativeRecipient::PhantomNode => Recipient::PhantomNode, - } - } - #[allow(unused)] - pub(crate) fn native_into(native: nativeRecipient) -> Self { - match native { - nativeRecipient::Node => Recipient::Node, - nativeRecipient::PhantomNode => Recipient::PhantomNode, - } - } -} -/// Creates a copy of the Recipient -#[no_mangle] -pub extern "C" fn Recipient_clone(orig: &Recipient) -> Recipient { - orig.clone() -} -#[no_mangle] -/// Utility method to constructs a new Node-variant Recipient -pub extern "C" fn Recipient_node() -> Recipient { - Recipient::Node} -#[no_mangle] -/// Utility method to constructs a new PhantomNode-variant Recipient -pub extern "C" fn Recipient_phantom_node() -> Recipient { - Recipient::PhantomNode} -/// A trait that describes a source of entropy. -#[repr(C)] -pub struct EntropySource { - /// An opaque pointer which is passed to your function implementations as an argument. - /// This has no meaning in the LDK, and can be NULL or any other value. - pub this_arg: *mut c_void, - /// Gets a unique, cryptographically-secure, random 32-byte value. This method must return a - /// different value each time it is called. - #[must_use] - pub get_secure_random_bytes: extern "C" fn (this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes, - /// Frees any resources associated with this object given its this_arg pointer. - /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. - pub free: Option, -} -unsafe impl Send for EntropySource {} -unsafe impl Sync for EntropySource {} -#[no_mangle] -pub(crate) extern "C" fn EntropySource_clone_fields(orig: &EntropySource) -> EntropySource { - EntropySource { - this_arg: orig.this_arg, - get_secure_random_bytes: Clone::clone(&orig.get_secure_random_bytes), - free: Clone::clone(&orig.free), - } -} - -use lightning::chain::keysinterface::EntropySource as rustEntropySource; -impl rustEntropySource for EntropySource { - fn get_secure_random_bytes(&self) -> [u8; 32] { - let mut ret = (self.get_secure_random_bytes)(self.this_arg); - ret.data - } -} - -// We're essentially a pointer already, or at least a set of pointers, so allow us to be used -// directly as a Deref trait in higher-level structs: -impl core::ops::Deref for EntropySource { - type Target = Self; - fn deref(&self) -> &Self { - self - } -} -/// Calls the free function if one is set -#[no_mangle] -pub extern "C" fn EntropySource_free(this_ptr: EntropySource) { } -impl Drop for EntropySource { - fn drop(&mut self) { - if let Some(f) = self.free { - f(self.this_arg); - } - } -} -/// A trait that can handle cryptographic operations at the scope level of a node. -#[repr(C)] -pub struct NodeSigner { - /// An opaque pointer which is passed to your function implementations as an argument. - /// This has no meaning in the LDK, and can be NULL or any other value. - pub this_arg: *mut c_void, - /// Get secret key material as bytes for use in encrypting and decrypting inbound payment data. - /// - /// If the implementor of this trait supports [phantom node payments], then every node that is - /// intended to be included in the phantom invoice route hints must return the same value from - /// this method. - /// - /// This method must return the same value each time it is called. - /// - /// [phantom node payments]: PhantomKeysManager - #[must_use] - pub get_inbound_payment_key_material: extern "C" fn (this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes, - /// Get node id based on the provided [`Recipient`]. - /// - /// This method must return the same value each time it is called with a given [`Recipient`] - /// parameter. - /// - /// Errors if the [`Recipient`] variant is not supported by the implementation. - #[must_use] - pub get_node_id: extern "C" fn (this_arg: *const c_void, recipient: crate::lightning::chain::keysinterface::Recipient) -> crate::c_types::derived::CResult_PublicKeyNoneZ, - /// Gets the ECDH shared secret of our node secret and `other_key`, multiplying by `tweak` if - /// one is provided. Note that this tweak can be applied to `other_key` instead of our node - /// secret, though this is less efficient. - /// - /// Note that if this fails while attempting to forward an HTLC, LDK will panic. The error - /// should be resolved to allow LDK to resume forwarding HTLCs. - /// - /// Errors if the [`Recipient`] variant is not supported by the implementation. - #[must_use] - pub ecdh: extern "C" fn (this_arg: *const c_void, recipient: crate::lightning::chain::keysinterface::Recipient, other_key: crate::c_types::PublicKey, tweak: crate::c_types::derived::COption_ScalarZ) -> crate::c_types::derived::CResult_SharedSecretNoneZ, - /// Sign an invoice. - /// - /// By parameterizing by the raw invoice bytes instead of the hash, we allow implementors of - /// this trait to parse the invoice and make sure they're signing what they expect, rather than - /// blindly signing the hash. - /// - /// The `hrp_bytes` are ASCII bytes, while the `invoice_data` is base32. - /// - /// The secret key used to sign the invoice is dependent on the [`Recipient`]. - /// - /// Errors if the [`Recipient`] variant is not supported by the implementation. - #[must_use] - pub sign_invoice: extern "C" fn (this_arg: *const c_void, hrp_bytes: crate::c_types::u8slice, invoice_data: crate::c_types::derived::CVec_U5Z, recipient: crate::lightning::chain::keysinterface::Recipient) -> crate::c_types::derived::CResult_RecoverableSignatureNoneZ, - /// Sign a gossip message. - /// - /// Note that if this fails, LDK may panic and the message will not be broadcast to the network - /// or a possible channel counterparty. If LDK panics, the error should be resolved to allow the - /// message to be broadcast, as otherwise it may prevent one from receiving funds over the - /// corresponding channel. - #[must_use] - pub sign_gossip_message: extern "C" fn (this_arg: *const c_void, msg: crate::lightning::ln::msgs::UnsignedGossipMessage) -> crate::c_types::derived::CResult_SignatureNoneZ, - /// Frees any resources associated with this object given its this_arg pointer. - /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. - pub free: Option, -} -unsafe impl Send for NodeSigner {} -unsafe impl Sync for NodeSigner {} -#[no_mangle] -pub(crate) extern "C" fn NodeSigner_clone_fields(orig: &NodeSigner) -> NodeSigner { - NodeSigner { - this_arg: orig.this_arg, - get_inbound_payment_key_material: Clone::clone(&orig.get_inbound_payment_key_material), - get_node_id: Clone::clone(&orig.get_node_id), - ecdh: Clone::clone(&orig.ecdh), - sign_invoice: Clone::clone(&orig.sign_invoice), - sign_gossip_message: Clone::clone(&orig.sign_gossip_message), - free: Clone::clone(&orig.free), - } -} - -use lightning::chain::keysinterface::NodeSigner as rustNodeSigner; -impl rustNodeSigner for NodeSigner { - fn get_inbound_payment_key_material(&self) -> lightning::chain::keysinterface::KeyMaterial { - let mut ret = (self.get_inbound_payment_key_material)(self.this_arg); - ::lightning::chain::keysinterface::KeyMaterial(ret.data) - } - fn get_node_id(&self, mut recipient: lightning::chain::keysinterface::Recipient) -> Result { - let mut ret = (self.get_node_id)(self.this_arg, crate::lightning::chain::keysinterface::Recipient::native_into(recipient)); - let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; - local_ret - } - fn ecdh(&self, mut recipient: lightning::chain::keysinterface::Recipient, mut other_key: &bitcoin::secp256k1::PublicKey, mut tweak: Option<&bitcoin::secp256k1::Scalar>) -> Result { - let mut local_tweak = if tweak.is_none() { crate::c_types::derived::COption_ScalarZ::None } else { crate::c_types::derived::COption_ScalarZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option is otherwise un-expressable. */ { crate::c_types::BigEndianScalar::from_rust(&(*tweak.as_ref().unwrap()).clone()) }) }; - let mut ret = (self.ecdh)(self.this_arg, crate::lightning::chain::keysinterface::Recipient::native_into(recipient), crate::c_types::PublicKey::from_rust(&other_key), local_tweak); - let mut local_ret = match ret.result_ok { true => Ok( { ::bitcoin::secp256k1::ecdh::SharedSecret::from_bytes((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).data) }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; - local_ret - } - fn sign_invoice(&self, mut hrp_bytes: &[u8], mut invoice_data: &[bitcoin::bech32::u5], mut recipient: lightning::chain::keysinterface::Recipient) -> Result { - let mut local_hrp_bytes = crate::c_types::u8slice::from_slice(hrp_bytes); - let mut local_invoice_data_clone = Vec::new(); local_invoice_data_clone.extend_from_slice(invoice_data); let mut invoice_data = local_invoice_data_clone; let mut local_invoice_data = Vec::new(); for mut item in invoice_data.drain(..) { local_invoice_data.push( { item.into() }); }; - let mut ret = (self.sign_invoice)(self.this_arg, local_hrp_bytes, local_invoice_data.into(), crate::lightning::chain::keysinterface::Recipient::native_into(recipient)); - let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; - local_ret - } - fn sign_gossip_message(&self, mut msg: lightning::ln::msgs::UnsignedGossipMessage) -> Result { - let mut ret = (self.sign_gossip_message)(self.this_arg, crate::lightning::ln::msgs::UnsignedGossipMessage::native_into(msg)); - let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; - local_ret - } -} - -// We're essentially a pointer already, or at least a set of pointers, so allow us to be used -// directly as a Deref trait in higher-level structs: -impl core::ops::Deref for NodeSigner { - type Target = Self; - fn deref(&self) -> &Self { - self - } -} -/// Calls the free function if one is set -#[no_mangle] -pub extern "C" fn NodeSigner_free(this_ptr: NodeSigner) { } -impl Drop for NodeSigner { - fn drop(&mut self) { - if let Some(f) = self.free { - f(self.this_arg); - } - } -} -/// A trait that can return signer instances for individual channels. -#[repr(C)] -pub struct SignerProvider { - /// An opaque pointer which is passed to your function implementations as an argument. - /// This has no meaning in the LDK, and can be NULL or any other value. - pub this_arg: *mut c_void, - /// Generates a unique `channel_keys_id` that can be used to obtain a [`Self::Signer`] through - /// [`SignerProvider::derive_channel_signer`]. The `user_channel_id` is provided to allow - /// implementations of [`SignerProvider`] to maintain a mapping between itself and the generated - /// `channel_keys_id`. - /// - /// This method must return a different value each time it is called. - #[must_use] - pub generate_channel_keys_id: extern "C" fn (this_arg: *const c_void, inbound: bool, channel_value_satoshis: u64, user_channel_id: crate::c_types::U128) -> crate::c_types::ThirtyTwoBytes, - /// Derives the private key material backing a `Signer`. - /// - /// To derive a new `Signer`, a fresh `channel_keys_id` should be obtained through - /// [`SignerProvider::generate_channel_keys_id`]. Otherwise, an existing `Signer` can be - /// re-derived from its `channel_keys_id`, which can be obtained through its trait method - /// [`ChannelSigner::channel_keys_id`]. - #[must_use] - pub derive_channel_signer: extern "C" fn (this_arg: *const c_void, channel_value_satoshis: u64, channel_keys_id: crate::c_types::ThirtyTwoBytes) -> crate::lightning::chain::keysinterface::WriteableEcdsaChannelSigner, - /// Reads a [`Signer`] for this [`SignerProvider`] from the given input stream. - /// This is only called during deserialization of other objects which contain - /// [`WriteableEcdsaChannelSigner`]-implementing objects (i.e., [`ChannelMonitor`]s and [`ChannelManager`]s). - /// The bytes are exactly those which `::write()` writes, and - /// contain no versioning scheme. You may wish to include your own version prefix and ensure - /// you've read all of the provided bytes to ensure no corruption occurred. - /// - /// This method is slowly being phased out -- it will only be called when reading objects - /// written by LDK versions prior to 0.0.113. - /// - /// [`Signer`]: Self::Signer - /// [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor - /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager - #[must_use] - pub read_chan_signer: extern "C" fn (this_arg: *const c_void, reader: crate::c_types::u8slice) -> crate::c_types::derived::CResult_WriteableEcdsaChannelSignerDecodeErrorZ, - /// Get a script pubkey which we send funds to when claiming on-chain contestable outputs. - /// - /// This method should return a different value each time it is called, to avoid linking - /// on-chain funds across channels as controlled to the same user. - #[must_use] - pub get_destination_script: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_u8Z, - /// Get a script pubkey which we will send funds to when closing a channel. - /// - /// This method should return a different value each time it is called, to avoid linking - /// on-chain funds across channels as controlled to the same user. - #[must_use] - pub get_shutdown_scriptpubkey: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::script::ShutdownScript, - /// Frees any resources associated with this object given its this_arg pointer. - /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. - pub free: Option, -} -unsafe impl Send for SignerProvider {} -unsafe impl Sync for SignerProvider {} -#[no_mangle] -pub(crate) extern "C" fn SignerProvider_clone_fields(orig: &SignerProvider) -> SignerProvider { - SignerProvider { - this_arg: orig.this_arg, - generate_channel_keys_id: Clone::clone(&orig.generate_channel_keys_id), - derive_channel_signer: Clone::clone(&orig.derive_channel_signer), - read_chan_signer: Clone::clone(&orig.read_chan_signer), - get_destination_script: Clone::clone(&orig.get_destination_script), - get_shutdown_scriptpubkey: Clone::clone(&orig.get_shutdown_scriptpubkey), - free: Clone::clone(&orig.free), - } -} - -use lightning::chain::keysinterface::SignerProvider as rustSignerProvider; -impl rustSignerProvider for SignerProvider { - type Signer = crate::lightning::chain::keysinterface::WriteableEcdsaChannelSigner; - fn generate_channel_keys_id(&self, mut inbound: bool, mut channel_value_satoshis: u64, mut user_channel_id: u128) -> [u8; 32] { - let mut ret = (self.generate_channel_keys_id)(self.this_arg, inbound, channel_value_satoshis, user_channel_id.into()); - ret.data - } - fn derive_channel_signer(&self, mut channel_value_satoshis: u64, mut channel_keys_id: [u8; 32]) -> crate::lightning::chain::keysinterface::WriteableEcdsaChannelSigner { - let mut ret = (self.derive_channel_signer)(self.this_arg, channel_value_satoshis, crate::c_types::ThirtyTwoBytes { data: channel_keys_id }); - ret - } - fn read_chan_signer(&self, mut reader: &[u8]) -> Result { - let mut local_reader = crate::c_types::u8slice::from_slice(reader); - let mut ret = (self.read_chan_signer)(self.this_arg, local_reader); - let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }) }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).into_native() })}; - local_ret - } - fn get_destination_script(&self) -> bitcoin::blockdata::script::Script { - let mut ret = (self.get_destination_script)(self.this_arg); - ::bitcoin::blockdata::script::Script::from(ret.into_rust()) - } - fn get_shutdown_scriptpubkey(&self) -> lightning::ln::script::ShutdownScript { - let mut ret = (self.get_shutdown_scriptpubkey)(self.this_arg); - *unsafe { Box::from_raw(ret.take_inner()) } - } -} - -// We're essentially a pointer already, or at least a set of pointers, so allow us to be used -// directly as a Deref trait in higher-level structs: -impl core::ops::Deref for SignerProvider { - type Target = Self; - fn deref(&self) -> &Self { - self - } -} -/// Calls the free function if one is set -#[no_mangle] -pub extern "C" fn SignerProvider_free(this_ptr: SignerProvider) { } -impl Drop for SignerProvider { - fn drop(&mut self) { - if let Some(f) = self.free { - f(self.this_arg); - } - } -} - -use lightning::chain::keysinterface::InMemorySigner as nativeInMemorySignerImport; -pub(crate) type nativeInMemorySigner = nativeInMemorySignerImport; - -/// A simple implementation of [`WriteableEcdsaChannelSigner`] that just keeps the private keys in memory. -/// -/// This implementation performs no policy checks and is insufficient by itself as -/// a secure external signer. -#[must_use] -#[repr(C)] -pub struct InMemorySigner { - /// A pointer to the opaque Rust object. - - /// Nearly everywhere, inner must be non-null, however in places where - /// the Rust equivalent takes an Option, it may be set to null to indicate None. - pub inner: *mut nativeInMemorySigner, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for InMemorySigner { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeInMemorySigner>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; - } - } -} -/// Frees any resources used by the InMemorySigner, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn InMemorySigner_free(this_obj: InMemorySigner) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn InMemorySigner_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeInMemorySigner) }; -} -#[allow(unused)] -impl InMemorySigner { - pub(crate) fn get_native_ref(&self) -> &'static nativeInMemorySigner { - unsafe { &*ObjOps::untweak_ptr(self.inner) } - } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInMemorySigner { - unsafe { &mut *ObjOps::untweak_ptr(self.inner) } - } - /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy - pub(crate) fn take_inner(mut self) -> *mut nativeInMemorySigner { - assert!(self.is_owned); - let ret = ObjOps::untweak_ptr(self.inner); - self.inner = core::ptr::null_mut(); - ret - } -} -/// Holder secret key in the 2-of-2 multisig script of a channel. This key also backs the -/// holder's anchor output in a commitment transaction, if one is present. -#[no_mangle] -pub extern "C" fn InMemorySigner_get_funding_key(this_ptr: &InMemorySigner) -> *const [u8; 32] { - let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_key; - inner_val.as_ref() -} -/// Holder secret key in the 2-of-2 multisig script of a channel. This key also backs the -/// holder's anchor output in a commitment transaction, if one is present. -#[no_mangle] -pub extern "C" fn InMemorySigner_set_funding_key(this_ptr: &mut InMemorySigner, mut val: crate::c_types::SecretKey) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_key = val.into_rust(); -} -/// Holder secret key for blinded revocation pubkey. -#[no_mangle] -pub extern "C" fn InMemorySigner_get_revocation_base_key(this_ptr: &InMemorySigner) -> *const [u8; 32] { - let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_base_key; - inner_val.as_ref() -} -/// Holder secret key for blinded revocation pubkey. -#[no_mangle] -pub extern "C" fn InMemorySigner_set_revocation_base_key(this_ptr: &mut InMemorySigner, mut val: crate::c_types::SecretKey) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_base_key = val.into_rust(); -} -/// Holder secret key used for our balance in counterparty-broadcasted commitment transactions. -#[no_mangle] -pub extern "C" fn InMemorySigner_get_payment_key(this_ptr: &InMemorySigner) -> *const [u8; 32] { - let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_key; - inner_val.as_ref() -} -/// Holder secret key used for our balance in counterparty-broadcasted commitment transactions. -#[no_mangle] -pub extern "C" fn InMemorySigner_set_payment_key(this_ptr: &mut InMemorySigner, mut val: crate::c_types::SecretKey) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_key = val.into_rust(); -} -/// Holder secret key used in an HTLC transaction. -#[no_mangle] -pub extern "C" fn InMemorySigner_get_delayed_payment_base_key(this_ptr: &InMemorySigner) -> *const [u8; 32] { - let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_base_key; - inner_val.as_ref() -} -/// Holder secret key used in an HTLC transaction. -#[no_mangle] -pub extern "C" fn InMemorySigner_set_delayed_payment_base_key(this_ptr: &mut InMemorySigner, mut val: crate::c_types::SecretKey) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_base_key = val.into_rust(); -} -/// Holder HTLC secret key used in commitment transaction HTLC outputs. -#[no_mangle] -pub extern "C" fn InMemorySigner_get_htlc_base_key(this_ptr: &InMemorySigner) -> *const [u8; 32] { - let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_base_key; - inner_val.as_ref() -} -/// Holder HTLC secret key used in commitment transaction HTLC outputs. -#[no_mangle] -pub extern "C" fn InMemorySigner_set_htlc_base_key(this_ptr: &mut InMemorySigner, mut val: crate::c_types::SecretKey) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_base_key = val.into_rust(); -} -/// Commitment seed. -#[no_mangle] -pub extern "C" fn InMemorySigner_get_commitment_seed(this_ptr: &InMemorySigner) -> *const [u8; 32] { - let mut inner_val = &mut this_ptr.get_native_mut_ref().commitment_seed; - inner_val -} -/// Commitment seed. -#[no_mangle] -pub extern "C" fn InMemorySigner_set_commitment_seed(this_ptr: &mut InMemorySigner, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.commitment_seed = val.data; -} -impl Clone for InMemorySigner { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeInMemorySigner>::is_null(self.inner) { core::ptr::null_mut() } else { - ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, - is_owned: true, - } - } -} -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn InMemorySigner_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeInMemorySigner)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the InMemorySigner -pub extern "C" fn InMemorySigner_clone(orig: &InMemorySigner) -> InMemorySigner { - orig.clone() -} -/// Creates a new [`InMemorySigner`]. -#[must_use] -#[no_mangle] -pub extern "C" fn InMemorySigner_new(mut funding_key: crate::c_types::SecretKey, mut revocation_base_key: crate::c_types::SecretKey, mut payment_key: crate::c_types::SecretKey, mut delayed_payment_base_key: crate::c_types::SecretKey, mut htlc_base_key: crate::c_types::SecretKey, mut commitment_seed: crate::c_types::ThirtyTwoBytes, mut channel_value_satoshis: u64, mut channel_keys_id: crate::c_types::ThirtyTwoBytes, mut rand_bytes_unique_start: crate::c_types::ThirtyTwoBytes) -> crate::lightning::chain::keysinterface::InMemorySigner { - let mut ret = lightning::chain::keysinterface::InMemorySigner::new(secp256k1::global::SECP256K1, funding_key.into_rust(), revocation_base_key.into_rust(), payment_key.into_rust(), delayed_payment_base_key.into_rust(), htlc_base_key.into_rust(), commitment_seed.data, channel_value_satoshis, channel_keys_id.data, rand_bytes_unique_start.data); - crate::lightning::chain::keysinterface::InMemorySigner { inner: ObjOps::heap_alloc(ret), is_owned: true } -} - -/// Returns the counterparty's pubkeys. -/// -/// Will panic if [`ChannelSigner::provide_channel_parameters`] has not been called before. -#[must_use] -#[no_mangle] -pub extern "C" fn InMemorySigner_counterparty_pubkeys(this_arg: &crate::lightning::chain::keysinterface::InMemorySigner) -> crate::lightning::ln::chan_utils::ChannelPublicKeys { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.counterparty_pubkeys(); - crate::lightning::ln::chan_utils::ChannelPublicKeys { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::chan_utils::ChannelPublicKeys<>) as *mut _) }, is_owned: false } -} - -/// Returns the `contest_delay` value specified by our counterparty and applied on holder-broadcastable -/// transactions, i.e., the amount of time that we have to wait to recover our funds if we -/// broadcast a transaction. -/// -/// Will panic if [`ChannelSigner::provide_channel_parameters`] has not been called before. -#[must_use] -#[no_mangle] -pub extern "C" fn InMemorySigner_counterparty_selected_contest_delay(this_arg: &crate::lightning::chain::keysinterface::InMemorySigner) -> u16 { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.counterparty_selected_contest_delay(); - ret -} - -/// Returns the `contest_delay` value specified by us and applied on transactions broadcastable -/// by our counterparty, i.e., the amount of time that they have to wait to recover their funds -/// if they broadcast a transaction. -/// -/// Will panic if [`ChannelSigner::provide_channel_parameters`] has not been called before. -#[must_use] -#[no_mangle] -pub extern "C" fn InMemorySigner_holder_selected_contest_delay(this_arg: &crate::lightning::chain::keysinterface::InMemorySigner) -> u16 { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.holder_selected_contest_delay(); - ret -} - -/// Returns whether the holder is the initiator. -/// -/// Will panic if [`ChannelSigner::provide_channel_parameters`] has not been called before. -#[must_use] -#[no_mangle] -pub extern "C" fn InMemorySigner_is_outbound(this_arg: &crate::lightning::chain::keysinterface::InMemorySigner) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.is_outbound(); - ret -} - -/// Funding outpoint -/// -/// Will panic if [`ChannelSigner::provide_channel_parameters`] has not been called before. -#[must_use] -#[no_mangle] -pub extern "C" fn InMemorySigner_funding_outpoint(this_arg: &crate::lightning::chain::keysinterface::InMemorySigner) -> crate::lightning::chain::transaction::OutPoint { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.funding_outpoint(); - crate::lightning::chain::transaction::OutPoint { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::chain::transaction::OutPoint<>) as *mut _) }, is_owned: false } -} - -/// Returns a [`ChannelTransactionParameters`] for this channel, to be used when verifying or -/// building transactions. -/// -/// Will panic if [`ChannelSigner::provide_channel_parameters`] has not been called before. -#[must_use] -#[no_mangle] -pub extern "C" fn InMemorySigner_get_channel_parameters(this_arg: &crate::lightning::chain::keysinterface::InMemorySigner) -> crate::lightning::ln::chan_utils::ChannelTransactionParameters { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_channel_parameters(); - crate::lightning::ln::chan_utils::ChannelTransactionParameters { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::chan_utils::ChannelTransactionParameters<>) as *mut _) }, is_owned: false } -} - -/// Returns whether anchors should be used. -/// -/// Will panic if [`ChannelSigner::provide_channel_parameters`] has not been called before. -#[must_use] -#[no_mangle] -pub extern "C" fn InMemorySigner_opt_anchors(this_arg: &crate::lightning::chain::keysinterface::InMemorySigner) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.opt_anchors(); - ret -} - -/// Sign the single input of `spend_tx` at index `input_idx`, which spends the output described -/// by `descriptor`, returning the witness stack for the input. -/// -/// Returns an error if the input at `input_idx` does not exist, has a non-empty `script_sig`, -/// is not spending the outpoint described by [`descriptor.outpoint`], -/// or if an output descriptor `script_pubkey` does not match the one we can spend. -/// -/// [`descriptor.outpoint`]: StaticPaymentOutputDescriptor::outpoint -#[must_use] -#[no_mangle] -pub extern "C" fn InMemorySigner_sign_counterparty_payment_input(this_arg: &crate::lightning::chain::keysinterface::InMemorySigner, mut spend_tx: crate::c_types::Transaction, mut input_idx: usize, descriptor: &crate::lightning::chain::keysinterface::StaticPaymentOutputDescriptor) -> crate::c_types::derived::CResult_CVec_CVec_u8ZZNoneZ { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.sign_counterparty_payment_input(&spend_tx.into_bitcoin(), input_idx, descriptor.get_native_ref(), secp256k1::global::SECP256K1); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = Vec::new(); for mut item in o.drain(..) { local_ret_0.push( { let mut local_ret_0_0 = Vec::new(); for mut item in item.drain(..) { local_ret_0_0.push( { item }); }; local_ret_0_0.into() }); }; local_ret_0.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} - -/// Sign the single input of `spend_tx` at index `input_idx` which spends the output -/// described by `descriptor`, returning the witness stack for the input. -/// -/// Returns an error if the input at `input_idx` does not exist, has a non-empty `script_sig`, -/// is not spending the outpoint described by [`descriptor.outpoint`], does not have a -/// sequence set to [`descriptor.to_self_delay`], or if an output descriptor -/// `script_pubkey` does not match the one we can spend. -/// -/// [`descriptor.outpoint`]: DelayedPaymentOutputDescriptor::outpoint -/// [`descriptor.to_self_delay`]: DelayedPaymentOutputDescriptor::to_self_delay -#[must_use] -#[no_mangle] -pub extern "C" fn InMemorySigner_sign_dynamic_p2wsh_input(this_arg: &crate::lightning::chain::keysinterface::InMemorySigner, mut spend_tx: crate::c_types::Transaction, mut input_idx: usize, descriptor: &crate::lightning::chain::keysinterface::DelayedPaymentOutputDescriptor) -> crate::c_types::derived::CResult_CVec_CVec_u8ZZNoneZ { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.sign_dynamic_p2wsh_input(&spend_tx.into_bitcoin(), input_idx, descriptor.get_native_ref(), secp256k1::global::SECP256K1); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = Vec::new(); for mut item in o.drain(..) { local_ret_0.push( { let mut local_ret_0_0 = Vec::new(); for mut item in item.drain(..) { local_ret_0_0.push( { item }); }; local_ret_0_0.into() }); }; local_ret_0.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} - -impl From for crate::lightning::chain::keysinterface::EntropySource { - fn from(obj: nativeInMemorySigner) -> Self { - let mut rust_obj = InMemorySigner { inner: ObjOps::heap_alloc(obj), is_owned: true }; - let mut ret = InMemorySigner_as_EntropySource(&rust_obj); - // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn - rust_obj.inner = core::ptr::null_mut(); - ret.free = Some(InMemorySigner_free_void); - ret - } -} -/// Constructs a new EntropySource which calls the relevant methods on this_arg. -/// This copies the `inner` pointer in this_arg and thus the returned EntropySource must be freed before this_arg is -#[no_mangle] -pub extern "C" fn InMemorySigner_as_EntropySource(this_arg: &InMemorySigner) -> crate::lightning::chain::keysinterface::EntropySource { - crate::lightning::chain::keysinterface::EntropySource { - this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, - free: None, - get_secure_random_bytes: InMemorySigner_EntropySource_get_secure_random_bytes, - } -} - -#[must_use] -extern "C" fn InMemorySigner_EntropySource_get_secure_random_bytes(this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes { - let mut ret = >::get_secure_random_bytes(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, ); - crate::c_types::ThirtyTwoBytes { data: ret } -} - -impl From for crate::lightning::chain::keysinterface::ChannelSigner { - fn from(obj: nativeInMemorySigner) -> Self { - let mut rust_obj = InMemorySigner { inner: ObjOps::heap_alloc(obj), is_owned: true }; - let mut ret = InMemorySigner_as_ChannelSigner(&rust_obj); - // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn - rust_obj.inner = core::ptr::null_mut(); - ret.free = Some(InMemorySigner_free_void); - ret - } -} -/// Constructs a new ChannelSigner which calls the relevant methods on this_arg. -/// This copies the `inner` pointer in this_arg and thus the returned ChannelSigner must be freed before this_arg is -#[no_mangle] -pub extern "C" fn InMemorySigner_as_ChannelSigner(this_arg: &InMemorySigner) -> crate::lightning::chain::keysinterface::ChannelSigner { - crate::lightning::chain::keysinterface::ChannelSigner { - this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, - free: None, - get_per_commitment_point: InMemorySigner_ChannelSigner_get_per_commitment_point, - release_commitment_secret: InMemorySigner_ChannelSigner_release_commitment_secret, - validate_holder_commitment: InMemorySigner_ChannelSigner_validate_holder_commitment, - - pubkeys: crate::lightning::ln::chan_utils::ChannelPublicKeys { inner: core::ptr::null_mut(), is_owned: true }.into(), - set_pubkeys: Some(InMemorySigner_ChannelSigner_set_pubkeys), - channel_keys_id: InMemorySigner_ChannelSigner_channel_keys_id, - provide_channel_parameters: InMemorySigner_ChannelSigner_provide_channel_parameters, - } -} - -#[must_use] -extern "C" fn InMemorySigner_ChannelSigner_get_per_commitment_point(this_arg: *const c_void, mut idx: u64) -> crate::c_types::PublicKey { - let mut ret = >::get_per_commitment_point(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, idx, secp256k1::global::SECP256K1); - crate::c_types::PublicKey::from_rust(&ret) -} -#[must_use] -extern "C" fn InMemorySigner_ChannelSigner_release_commitment_secret(this_arg: *const c_void, mut idx: u64) -> crate::c_types::ThirtyTwoBytes { - let mut ret = >::release_commitment_secret(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, idx); - crate::c_types::ThirtyTwoBytes { data: ret } -} -#[must_use] -extern "C" fn InMemorySigner_ChannelSigner_validate_holder_commitment(this_arg: *const c_void, holder_tx: &crate::lightning::ln::chan_utils::HolderCommitmentTransaction, mut preimages: crate::c_types::derived::CVec_PaymentPreimageZ) -> crate::c_types::derived::CResult_NoneNoneZ { - let mut local_preimages = Vec::new(); for mut item in preimages.into_rust().drain(..) { local_preimages.push( { ::lightning::ln::PaymentPreimage(item.data) }); }; - let mut ret = >::validate_holder_commitment(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, holder_tx.get_native_ref(), local_preimages); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} -#[must_use] -extern "C" fn InMemorySigner_ChannelSigner_pubkeys(this_arg: *const c_void) -> crate::lightning::ln::chan_utils::ChannelPublicKeys { - let mut ret = >::pubkeys(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, ); - crate::lightning::ln::chan_utils::ChannelPublicKeys { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::chan_utils::ChannelPublicKeys<>) as *mut _) }, is_owned: false } -} -extern "C" fn InMemorySigner_ChannelSigner_set_pubkeys(trait_self_arg: &ChannelSigner) { - // This is a bit race-y in the general case, but for our specific use-cases today, we're safe - // Specifically, we must ensure that the first time we're called it can never be in parallel - if unsafe { &*trait_self_arg.pubkeys.get() }.inner.is_null() { - *unsafe { &mut *(&*(trait_self_arg as *const ChannelSigner)).pubkeys.get() } = InMemorySigner_ChannelSigner_pubkeys(trait_self_arg.this_arg).into(); - } -} -#[must_use] -extern "C" fn InMemorySigner_ChannelSigner_channel_keys_id(this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes { - let mut ret = >::channel_keys_id(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, ); - crate::c_types::ThirtyTwoBytes { data: ret } -} -extern "C" fn InMemorySigner_ChannelSigner_provide_channel_parameters(this_arg: *mut c_void, channel_parameters: &crate::lightning::ln::chan_utils::ChannelTransactionParameters) { - >::provide_channel_parameters(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, channel_parameters.get_native_ref()) -} - -impl From for crate::lightning::chain::keysinterface::EcdsaChannelSigner { - fn from(obj: nativeInMemorySigner) -> Self { - let mut rust_obj = InMemorySigner { inner: ObjOps::heap_alloc(obj), is_owned: true }; - let mut ret = InMemorySigner_as_EcdsaChannelSigner(&rust_obj); - // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn - rust_obj.inner = core::ptr::null_mut(); - ret.free = Some(InMemorySigner_free_void); - ret - } -} -/// Constructs a new EcdsaChannelSigner which calls the relevant methods on this_arg. -/// This copies the `inner` pointer in this_arg and thus the returned EcdsaChannelSigner must be freed before this_arg is -#[no_mangle] -pub extern "C" fn InMemorySigner_as_EcdsaChannelSigner(this_arg: &InMemorySigner) -> crate::lightning::chain::keysinterface::EcdsaChannelSigner { - crate::lightning::chain::keysinterface::EcdsaChannelSigner { - this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, - free: None, - sign_counterparty_commitment: InMemorySigner_EcdsaChannelSigner_sign_counterparty_commitment, - validate_counterparty_revocation: InMemorySigner_EcdsaChannelSigner_validate_counterparty_revocation, - sign_holder_commitment_and_htlcs: InMemorySigner_EcdsaChannelSigner_sign_holder_commitment_and_htlcs, - sign_justice_revoked_output: InMemorySigner_EcdsaChannelSigner_sign_justice_revoked_output, - sign_justice_revoked_htlc: InMemorySigner_EcdsaChannelSigner_sign_justice_revoked_htlc, - sign_counterparty_htlc_transaction: InMemorySigner_EcdsaChannelSigner_sign_counterparty_htlc_transaction, - sign_closing_transaction: InMemorySigner_EcdsaChannelSigner_sign_closing_transaction, - sign_holder_anchor_input: InMemorySigner_EcdsaChannelSigner_sign_holder_anchor_input, - sign_channel_announcement_with_funding_key: InMemorySigner_EcdsaChannelSigner_sign_channel_announcement_with_funding_key, - ChannelSigner: crate::lightning::chain::keysinterface::ChannelSigner { - this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, - free: None, - get_per_commitment_point: InMemorySigner_ChannelSigner_get_per_commitment_point, - release_commitment_secret: InMemorySigner_ChannelSigner_release_commitment_secret, - validate_holder_commitment: InMemorySigner_ChannelSigner_validate_holder_commitment, - - pubkeys: crate::lightning::ln::chan_utils::ChannelPublicKeys { inner: core::ptr::null_mut(), is_owned: true }.into(), - set_pubkeys: Some(InMemorySigner_ChannelSigner_set_pubkeys), - channel_keys_id: InMemorySigner_ChannelSigner_channel_keys_id, - provide_channel_parameters: InMemorySigner_ChannelSigner_provide_channel_parameters, - }, - } -} - -#[must_use] -extern "C" fn InMemorySigner_EcdsaChannelSigner_sign_counterparty_commitment(this_arg: *const c_void, commitment_tx: &crate::lightning::ln::chan_utils::CommitmentTransaction, mut preimages: crate::c_types::derived::CVec_PaymentPreimageZ) -> crate::c_types::derived::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { - let mut local_preimages = Vec::new(); for mut item in preimages.into_rust().drain(..) { local_preimages.push( { ::lightning::ln::PaymentPreimage(item.data) }); }; - let mut ret = >::sign_counterparty_commitment(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, commitment_tx.get_native_ref(), local_preimages, secp256k1::global::SECP256K1); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = o; let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.drain(..) { local_orig_ret_0_1.push( { crate::c_types::Signature::from_rust(&item) }); }; let mut local_ret_0 = (crate::c_types::Signature::from_rust(&orig_ret_0_0), local_orig_ret_0_1.into()).into(); local_ret_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} -#[must_use] -extern "C" fn InMemorySigner_EcdsaChannelSigner_validate_counterparty_revocation(this_arg: *const c_void, mut idx: u64, secret: *const [u8; 32]) -> crate::c_types::derived::CResult_NoneNoneZ { - let mut ret = >::validate_counterparty_revocation(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, idx, &::bitcoin::secp256k1::SecretKey::from_slice(&unsafe { *secret}[..]).unwrap()); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} -#[must_use] -extern "C" fn InMemorySigner_EcdsaChannelSigner_sign_holder_commitment_and_htlcs(this_arg: *const c_void, commitment_tx: &crate::lightning::ln::chan_utils::HolderCommitmentTransaction) -> crate::c_types::derived::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { - let mut ret = >::sign_holder_commitment_and_htlcs(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, commitment_tx.get_native_ref(), secp256k1::global::SECP256K1); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = o; let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.drain(..) { local_orig_ret_0_1.push( { crate::c_types::Signature::from_rust(&item) }); }; let mut local_ret_0 = (crate::c_types::Signature::from_rust(&orig_ret_0_0), local_orig_ret_0_1.into()).into(); local_ret_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} -#[must_use] -extern "C" fn InMemorySigner_EcdsaChannelSigner_sign_justice_revoked_output(this_arg: *const c_void, mut justice_tx: crate::c_types::Transaction, mut input: usize, mut amount: u64, per_commitment_key: *const [u8; 32]) -> crate::c_types::derived::CResult_SignatureNoneZ { - let mut ret = >::sign_justice_revoked_output(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, &justice_tx.into_bitcoin(), input, amount, &::bitcoin::secp256k1::SecretKey::from_slice(&unsafe { *per_commitment_key}[..]).unwrap(), secp256k1::global::SECP256K1); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Signature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} -#[must_use] -extern "C" fn InMemorySigner_EcdsaChannelSigner_sign_justice_revoked_htlc(this_arg: *const c_void, mut justice_tx: crate::c_types::Transaction, mut input: usize, mut amount: u64, per_commitment_key: *const [u8; 32], htlc: &crate::lightning::ln::chan_utils::HTLCOutputInCommitment) -> crate::c_types::derived::CResult_SignatureNoneZ { - let mut ret = >::sign_justice_revoked_htlc(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, &justice_tx.into_bitcoin(), input, amount, &::bitcoin::secp256k1::SecretKey::from_slice(&unsafe { *per_commitment_key}[..]).unwrap(), htlc.get_native_ref(), secp256k1::global::SECP256K1); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Signature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} -#[must_use] -extern "C" fn InMemorySigner_EcdsaChannelSigner_sign_counterparty_htlc_transaction(this_arg: *const c_void, mut htlc_tx: crate::c_types::Transaction, mut input: usize, mut amount: u64, mut per_commitment_point: crate::c_types::PublicKey, htlc: &crate::lightning::ln::chan_utils::HTLCOutputInCommitment) -> crate::c_types::derived::CResult_SignatureNoneZ { - let mut ret = >::sign_counterparty_htlc_transaction(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, &htlc_tx.into_bitcoin(), input, amount, &per_commitment_point.into_rust(), htlc.get_native_ref(), secp256k1::global::SECP256K1); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Signature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} -#[must_use] -extern "C" fn InMemorySigner_EcdsaChannelSigner_sign_closing_transaction(this_arg: *const c_void, closing_tx: &crate::lightning::ln::chan_utils::ClosingTransaction) -> crate::c_types::derived::CResult_SignatureNoneZ { - let mut ret = >::sign_closing_transaction(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, closing_tx.get_native_ref(), secp256k1::global::SECP256K1); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Signature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} -#[must_use] -extern "C" fn InMemorySigner_EcdsaChannelSigner_sign_holder_anchor_input(this_arg: *const c_void, mut anchor_tx: crate::c_types::Transaction, mut input: usize) -> crate::c_types::derived::CResult_SignatureNoneZ { - let mut ret = >::sign_holder_anchor_input(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, &anchor_tx.into_bitcoin(), input, secp256k1::global::SECP256K1); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Signature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} -#[must_use] -extern "C" fn InMemorySigner_EcdsaChannelSigner_sign_channel_announcement_with_funding_key(this_arg: *const c_void, msg: &crate::lightning::ln::msgs::UnsignedChannelAnnouncement) -> crate::c_types::derived::CResult_SignatureNoneZ { - let mut ret = >::sign_channel_announcement_with_funding_key(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, msg.get_native_ref(), secp256k1::global::SECP256K1); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Signature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} - -impl From for crate::lightning::chain::keysinterface::WriteableEcdsaChannelSigner { - fn from(obj: nativeInMemorySigner) -> Self { - let mut rust_obj = InMemorySigner { inner: ObjOps::heap_alloc(obj), is_owned: true }; - let mut ret = InMemorySigner_as_WriteableEcdsaChannelSigner(&rust_obj); - // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn - rust_obj.inner = core::ptr::null_mut(); - ret.free = Some(InMemorySigner_free_void); - ret - } -} -/// Constructs a new WriteableEcdsaChannelSigner which calls the relevant methods on this_arg. -/// This copies the `inner` pointer in this_arg and thus the returned WriteableEcdsaChannelSigner must be freed before this_arg is -#[no_mangle] -pub extern "C" fn InMemorySigner_as_WriteableEcdsaChannelSigner(this_arg: &InMemorySigner) -> crate::lightning::chain::keysinterface::WriteableEcdsaChannelSigner { - crate::lightning::chain::keysinterface::WriteableEcdsaChannelSigner { - this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, - free: None, - EcdsaChannelSigner: crate::lightning::chain::keysinterface::EcdsaChannelSigner { - this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, - free: None, - sign_counterparty_commitment: InMemorySigner_EcdsaChannelSigner_sign_counterparty_commitment, - validate_counterparty_revocation: InMemorySigner_EcdsaChannelSigner_validate_counterparty_revocation, - sign_holder_commitment_and_htlcs: InMemorySigner_EcdsaChannelSigner_sign_holder_commitment_and_htlcs, - sign_justice_revoked_output: InMemorySigner_EcdsaChannelSigner_sign_justice_revoked_output, - sign_justice_revoked_htlc: InMemorySigner_EcdsaChannelSigner_sign_justice_revoked_htlc, - sign_counterparty_htlc_transaction: InMemorySigner_EcdsaChannelSigner_sign_counterparty_htlc_transaction, - sign_closing_transaction: InMemorySigner_EcdsaChannelSigner_sign_closing_transaction, - sign_holder_anchor_input: InMemorySigner_EcdsaChannelSigner_sign_holder_anchor_input, - sign_channel_announcement_with_funding_key: InMemorySigner_EcdsaChannelSigner_sign_channel_announcement_with_funding_key, - ChannelSigner: crate::lightning::chain::keysinterface::ChannelSigner { - this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, - free: None, - get_per_commitment_point: InMemorySigner_ChannelSigner_get_per_commitment_point, - release_commitment_secret: InMemorySigner_ChannelSigner_release_commitment_secret, - validate_holder_commitment: InMemorySigner_ChannelSigner_validate_holder_commitment, - - pubkeys: crate::lightning::ln::chan_utils::ChannelPublicKeys { inner: core::ptr::null_mut(), is_owned: true }.into(), - set_pubkeys: Some(InMemorySigner_ChannelSigner_set_pubkeys), - channel_keys_id: InMemorySigner_ChannelSigner_channel_keys_id, - provide_channel_parameters: InMemorySigner_ChannelSigner_provide_channel_parameters, - }, - }, - write: InMemorySigner_write_void, - } -} - - -#[no_mangle] -/// Serialize the InMemorySigner object into a byte array which can be read by InMemorySigner_read -pub extern "C" fn InMemorySigner_write(obj: &crate::lightning::chain::keysinterface::InMemorySigner) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) -} -#[no_mangle] -pub(crate) extern "C" fn InMemorySigner_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInMemorySigner) }) -} -#[no_mangle] -/// Read a InMemorySigner from a byte array, created by InMemorySigner_write -pub extern "C" fn InMemorySigner_read(ser: crate::c_types::u8slice, arg: crate::lightning::chain::keysinterface::EntropySource) -> crate::c_types::derived::CResult_InMemorySignerDecodeErrorZ { - let arg_conv = arg; - let res: Result = crate::c_types::deserialize_obj_arg(ser, arg_conv); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::chain::keysinterface::InMemorySigner { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; - local_res -} - -use lightning::chain::keysinterface::KeysManager as nativeKeysManagerImport; -pub(crate) type nativeKeysManager = nativeKeysManagerImport; - -/// Simple implementation of [`EntropySource`], [`NodeSigner`], and [`SignerProvider`] that takes a -/// 32-byte seed for use as a BIP 32 extended key and derives keys from that. -/// -/// Your `node_id` is seed/0'. -/// Unilateral closes may use seed/1'. -/// Cooperative closes may use seed/2'. -/// The two close keys may be needed to claim on-chain funds! -/// -/// This struct cannot be used for nodes that wish to support receiving phantom payments; -/// [`PhantomKeysManager`] must be used instead. -/// -/// Note that switching between this struct and [`PhantomKeysManager`] will invalidate any -/// previously issued invoices and attempts to pay previous invoices will fail. -#[must_use] -#[repr(C)] -pub struct KeysManager { - /// A pointer to the opaque Rust object. - - /// Nearly everywhere, inner must be non-null, however in places where - /// the Rust equivalent takes an Option, it may be set to null to indicate None. - pub inner: *mut nativeKeysManager, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for KeysManager { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeKeysManager>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; - } - } -} -/// Frees any resources used by the KeysManager, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn KeysManager_free(this_obj: KeysManager) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn KeysManager_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeKeysManager) }; -} -#[allow(unused)] -impl KeysManager { - pub(crate) fn get_native_ref(&self) -> &'static nativeKeysManager { - unsafe { &*ObjOps::untweak_ptr(self.inner) } - } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeKeysManager { - unsafe { &mut *ObjOps::untweak_ptr(self.inner) } - } - /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy - pub(crate) fn take_inner(mut self) -> *mut nativeKeysManager { - assert!(self.is_owned); - let ret = ObjOps::untweak_ptr(self.inner); - self.inner = core::ptr::null_mut(); - ret - } -} -/// Constructs a [`KeysManager`] from a 32-byte seed. If the seed is in some way biased (e.g., -/// your CSRNG is busted) this may panic (but more importantly, you will possibly lose funds). -/// `starting_time` isn't strictly required to actually be a time, but it must absolutely, -/// without a doubt, be unique to this instance. ie if you start multiple times with the same -/// `seed`, `starting_time` must be unique to each run. Thus, the easiest way to achieve this -/// is to simply use the current time (with very high precision). -/// -/// The `seed` MUST be backed up safely prior to use so that the keys can be re-created, however, -/// obviously, `starting_time` should be unique every time you reload the library - it is only -/// used to generate new ephemeral key data (which will be stored by the individual channel if -/// necessary). -/// -/// Note that the seed is required to recover certain on-chain funds independent of -/// [`ChannelMonitor`] data, though a current copy of [`ChannelMonitor`] data is also required -/// for any channel, and some on-chain during-closing funds. -/// -/// [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor -#[must_use] -#[no_mangle] -pub extern "C" fn KeysManager_new(seed: *const [u8; 32], mut starting_time_secs: u64, mut starting_time_nanos: u32) -> crate::lightning::chain::keysinterface::KeysManager { - let mut ret = lightning::chain::keysinterface::KeysManager::new(unsafe { &*seed}, starting_time_secs, starting_time_nanos); - crate::lightning::chain::keysinterface::KeysManager { inner: ObjOps::heap_alloc(ret), is_owned: true } -} - -/// Gets the \"node_id\" secret key used to sign gossip announcements, decode onion data, etc. -#[must_use] -#[no_mangle] -pub extern "C" fn KeysManager_get_node_secret_key(this_arg: &crate::lightning::chain::keysinterface::KeysManager) -> crate::c_types::SecretKey { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_node_secret_key(); - crate::c_types::SecretKey::from_rust(ret) -} - -/// Derive an old [`WriteableEcdsaChannelSigner`] containing per-channel secrets based on a key derivation parameters. -#[must_use] -#[no_mangle] -pub extern "C" fn KeysManager_derive_channel_keys(this_arg: &crate::lightning::chain::keysinterface::KeysManager, mut channel_value_satoshis: u64, params: *const [u8; 32]) -> crate::lightning::chain::keysinterface::InMemorySigner { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.derive_channel_keys(channel_value_satoshis, unsafe { &*params}); - crate::lightning::chain::keysinterface::InMemorySigner { inner: ObjOps::heap_alloc(ret), is_owned: true } -} - -/// Creates a [`Transaction`] which spends the given descriptors to the given outputs, plus an -/// output to the given change destination (if sufficient change value remains). The -/// transaction will have a feerate, at least, of the given value. -/// -/// Returns `Err(())` if the output value is greater than the input value minus required fee, -/// if a descriptor was duplicated, or if an output descriptor `script_pubkey` -/// does not match the one we can spend. -/// -/// We do not enforce that outputs meet the dust limit or that any output scripts are standard. -/// -/// May panic if the [`SpendableOutputDescriptor`]s were not generated by channels which used -/// this [`KeysManager`] or one of the [`InMemorySigner`] created by this [`KeysManager`]. -#[must_use] -#[no_mangle] -pub extern "C" fn KeysManager_spend_spendable_outputs(this_arg: &crate::lightning::chain::keysinterface::KeysManager, mut descriptors: crate::c_types::derived::CVec_SpendableOutputDescriptorZ, mut outputs: crate::c_types::derived::CVec_TxOutZ, mut change_destination_script: crate::c_types::derived::CVec_u8Z, mut feerate_sat_per_1000_weight: u32) -> crate::c_types::derived::CResult_TransactionNoneZ { - let mut local_descriptors = Vec::new(); for mut item in descriptors.into_rust().drain(..) { local_descriptors.push( { item.into_native() }); }; - let mut local_outputs = Vec::new(); for mut item in outputs.into_rust().drain(..) { local_outputs.push( { item.into_rust() }); }; - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.spend_spendable_outputs(&local_descriptors.iter().collect::>()[..], local_outputs, ::bitcoin::blockdata::script::Script::from(change_destination_script.into_rust()), feerate_sat_per_1000_weight, secp256k1::global::SECP256K1); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Transaction::from_bitcoin(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} - -impl From for crate::lightning::chain::keysinterface::EntropySource { - fn from(obj: nativeKeysManager) -> Self { - let mut rust_obj = KeysManager { inner: ObjOps::heap_alloc(obj), is_owned: true }; - let mut ret = KeysManager_as_EntropySource(&rust_obj); - // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn - rust_obj.inner = core::ptr::null_mut(); - ret.free = Some(KeysManager_free_void); - ret - } -} -/// Constructs a new EntropySource which calls the relevant methods on this_arg. -/// This copies the `inner` pointer in this_arg and thus the returned EntropySource must be freed before this_arg is -#[no_mangle] -pub extern "C" fn KeysManager_as_EntropySource(this_arg: &KeysManager) -> crate::lightning::chain::keysinterface::EntropySource { - crate::lightning::chain::keysinterface::EntropySource { - this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, - free: None, - get_secure_random_bytes: KeysManager_EntropySource_get_secure_random_bytes, - } -} - -#[must_use] -extern "C" fn KeysManager_EntropySource_get_secure_random_bytes(this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes { - let mut ret = >::get_secure_random_bytes(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, ); - crate::c_types::ThirtyTwoBytes { data: ret } -} - -impl From for crate::lightning::chain::keysinterface::NodeSigner { - fn from(obj: nativeKeysManager) -> Self { - let mut rust_obj = KeysManager { inner: ObjOps::heap_alloc(obj), is_owned: true }; - let mut ret = KeysManager_as_NodeSigner(&rust_obj); - // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn - rust_obj.inner = core::ptr::null_mut(); - ret.free = Some(KeysManager_free_void); - ret - } -} -/// Constructs a new NodeSigner which calls the relevant methods on this_arg. -/// This copies the `inner` pointer in this_arg and thus the returned NodeSigner must be freed before this_arg is -#[no_mangle] -pub extern "C" fn KeysManager_as_NodeSigner(this_arg: &KeysManager) -> crate::lightning::chain::keysinterface::NodeSigner { - crate::lightning::chain::keysinterface::NodeSigner { - this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, - free: None, - get_inbound_payment_key_material: KeysManager_NodeSigner_get_inbound_payment_key_material, - get_node_id: KeysManager_NodeSigner_get_node_id, - ecdh: KeysManager_NodeSigner_ecdh, - sign_invoice: KeysManager_NodeSigner_sign_invoice, - sign_gossip_message: KeysManager_NodeSigner_sign_gossip_message, - } -} - -#[must_use] -extern "C" fn KeysManager_NodeSigner_get_inbound_payment_key_material(this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes { - let mut ret = >::get_inbound_payment_key_material(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, ); - crate::c_types::ThirtyTwoBytes { data: ret.0 } -} -#[must_use] -extern "C" fn KeysManager_NodeSigner_get_node_id(this_arg: *const c_void, mut recipient: crate::lightning::chain::keysinterface::Recipient) -> crate::c_types::derived::CResult_PublicKeyNoneZ { - let mut ret = >::get_node_id(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, recipient.into_native()); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::PublicKey::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} -#[must_use] -extern "C" fn KeysManager_NodeSigner_ecdh(this_arg: *const c_void, mut recipient: crate::lightning::chain::keysinterface::Recipient, mut other_key: crate::c_types::PublicKey, mut tweak: crate::c_types::derived::COption_ScalarZ) -> crate::c_types::derived::CResult_SharedSecretNoneZ { - let mut local_tweak_base = { /*tweak*/ let tweak_opt = tweak; if tweak_opt.is_none() { None } else { Some({ { { tweak_opt.take() }.into_rust() }})} }; let mut local_tweak = local_tweak_base.as_ref(); - let mut ret = >::ecdh(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, recipient.into_native(), &other_key.into_rust(), local_tweak); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ThirtyTwoBytes { data: o.secret_bytes() } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} -#[must_use] -extern "C" fn KeysManager_NodeSigner_sign_invoice(this_arg: *const c_void, mut hrp_bytes: crate::c_types::u8slice, mut invoice_data: crate::c_types::derived::CVec_U5Z, mut recipient: crate::lightning::chain::keysinterface::Recipient) -> crate::c_types::derived::CResult_RecoverableSignatureNoneZ { - let mut local_invoice_data = Vec::new(); for mut item in invoice_data.into_rust().drain(..) { local_invoice_data.push( { item.into() }); }; - let mut ret = >::sign_invoice(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, hrp_bytes.to_slice(), &local_invoice_data[..], recipient.into_native()); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::RecoverableSignature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} -#[must_use] -extern "C" fn KeysManager_NodeSigner_sign_gossip_message(this_arg: *const c_void, mut msg: crate::lightning::ln::msgs::UnsignedGossipMessage) -> crate::c_types::derived::CResult_SignatureNoneZ { - let mut ret = >::sign_gossip_message(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, msg.into_native()); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Signature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} - -impl From for crate::lightning::chain::keysinterface::SignerProvider { - fn from(obj: nativeKeysManager) -> Self { - let mut rust_obj = KeysManager { inner: ObjOps::heap_alloc(obj), is_owned: true }; - let mut ret = KeysManager_as_SignerProvider(&rust_obj); - // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn - rust_obj.inner = core::ptr::null_mut(); - ret.free = Some(KeysManager_free_void); - ret - } -} -/// Constructs a new SignerProvider which calls the relevant methods on this_arg. -/// This copies the `inner` pointer in this_arg and thus the returned SignerProvider must be freed before this_arg is -#[no_mangle] -pub extern "C" fn KeysManager_as_SignerProvider(this_arg: &KeysManager) -> crate::lightning::chain::keysinterface::SignerProvider { - crate::lightning::chain::keysinterface::SignerProvider { - this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, - free: None, - generate_channel_keys_id: KeysManager_SignerProvider_generate_channel_keys_id, - derive_channel_signer: KeysManager_SignerProvider_derive_channel_signer, - read_chan_signer: KeysManager_SignerProvider_read_chan_signer, - get_destination_script: KeysManager_SignerProvider_get_destination_script, - get_shutdown_scriptpubkey: KeysManager_SignerProvider_get_shutdown_scriptpubkey, - } -} - -#[must_use] -extern "C" fn KeysManager_SignerProvider_generate_channel_keys_id(this_arg: *const c_void, mut inbound: bool, mut channel_value_satoshis: u64, mut user_channel_id: crate::c_types::U128) -> crate::c_types::ThirtyTwoBytes { - let mut ret = >::generate_channel_keys_id(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, inbound, channel_value_satoshis, user_channel_id.into()); - crate::c_types::ThirtyTwoBytes { data: ret } -} -#[must_use] -extern "C" fn KeysManager_SignerProvider_derive_channel_signer(this_arg: *const c_void, mut channel_value_satoshis: u64, mut channel_keys_id: crate::c_types::ThirtyTwoBytes) -> crate::lightning::chain::keysinterface::WriteableEcdsaChannelSigner { - let mut ret = >::derive_channel_signer(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, channel_value_satoshis, channel_keys_id.data); - Into::into(ret) -} -#[must_use] -extern "C" fn KeysManager_SignerProvider_read_chan_signer(this_arg: *const c_void, mut reader: crate::c_types::u8slice) -> crate::c_types::derived::CResult_WriteableEcdsaChannelSignerDecodeErrorZ { - let mut ret = >::read_chan_signer(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, reader.to_slice()); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { Into::into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; - local_ret -} -#[must_use] -extern "C" fn KeysManager_SignerProvider_get_destination_script(this_arg: *const c_void) -> crate::c_types::derived::CVec_u8Z { - let mut ret = >::get_destination_script(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, ); - ret.into_bytes().into() -} -#[must_use] -extern "C" fn KeysManager_SignerProvider_get_shutdown_scriptpubkey(this_arg: *const c_void) -> crate::lightning::ln::script::ShutdownScript { - let mut ret = >::get_shutdown_scriptpubkey(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, ); - crate::lightning::ln::script::ShutdownScript { inner: ObjOps::heap_alloc(ret), is_owned: true } -} - - -use lightning::chain::keysinterface::PhantomKeysManager as nativePhantomKeysManagerImport; -pub(crate) type nativePhantomKeysManager = nativePhantomKeysManagerImport; - -/// Similar to [`KeysManager`], but allows the node using this struct to receive phantom node -/// payments. -/// -/// A phantom node payment is a payment made to a phantom invoice, which is an invoice that can be -/// paid to one of multiple nodes. This works because we encode the invoice route hints such that -/// LDK will recognize an incoming payment as destined for a phantom node, and collect the payment -/// itself without ever needing to forward to this fake node. -/// -/// Phantom node payments are useful for load balancing between multiple LDK nodes. They also -/// provide some fault tolerance, because payers will automatically retry paying other provided -/// nodes in the case that one node goes down. -/// -/// Note that multi-path payments are not supported in phantom invoices for security reasons. -/// Switching between this struct and [`KeysManager`] will invalidate any previously issued -/// invoices and attempts to pay previous invoices will fail. -#[must_use] -#[repr(C)] -pub struct PhantomKeysManager { - /// A pointer to the opaque Rust object. - - /// Nearly everywhere, inner must be non-null, however in places where - /// the Rust equivalent takes an Option, it may be set to null to indicate None. - pub inner: *mut nativePhantomKeysManager, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for PhantomKeysManager { - fn drop(&mut self) { - if self.is_owned && !<*mut nativePhantomKeysManager>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; - } - } -} -/// Frees any resources used by the PhantomKeysManager, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn PhantomKeysManager_free(this_obj: PhantomKeysManager) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn PhantomKeysManager_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativePhantomKeysManager) }; -} -#[allow(unused)] -impl PhantomKeysManager { - pub(crate) fn get_native_ref(&self) -> &'static nativePhantomKeysManager { - unsafe { &*ObjOps::untweak_ptr(self.inner) } - } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePhantomKeysManager { - unsafe { &mut *ObjOps::untweak_ptr(self.inner) } - } - /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy - pub(crate) fn take_inner(mut self) -> *mut nativePhantomKeysManager { - assert!(self.is_owned); - let ret = ObjOps::untweak_ptr(self.inner); - self.inner = core::ptr::null_mut(); - ret - } -} -impl From for crate::lightning::chain::keysinterface::EntropySource { - fn from(obj: nativePhantomKeysManager) -> Self { - let mut rust_obj = PhantomKeysManager { inner: ObjOps::heap_alloc(obj), is_owned: true }; - let mut ret = PhantomKeysManager_as_EntropySource(&rust_obj); - // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn - rust_obj.inner = core::ptr::null_mut(); - ret.free = Some(PhantomKeysManager_free_void); - ret - } -} -/// Constructs a new EntropySource which calls the relevant methods on this_arg. -/// This copies the `inner` pointer in this_arg and thus the returned EntropySource must be freed before this_arg is -#[no_mangle] -pub extern "C" fn PhantomKeysManager_as_EntropySource(this_arg: &PhantomKeysManager) -> crate::lightning::chain::keysinterface::EntropySource { - crate::lightning::chain::keysinterface::EntropySource { - this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, - free: None, - get_secure_random_bytes: PhantomKeysManager_EntropySource_get_secure_random_bytes, - } -} - -#[must_use] -extern "C" fn PhantomKeysManager_EntropySource_get_secure_random_bytes(this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes { - let mut ret = >::get_secure_random_bytes(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, ); - crate::c_types::ThirtyTwoBytes { data: ret } -} - -impl From for crate::lightning::chain::keysinterface::NodeSigner { - fn from(obj: nativePhantomKeysManager) -> Self { - let mut rust_obj = PhantomKeysManager { inner: ObjOps::heap_alloc(obj), is_owned: true }; - let mut ret = PhantomKeysManager_as_NodeSigner(&rust_obj); - // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn - rust_obj.inner = core::ptr::null_mut(); - ret.free = Some(PhantomKeysManager_free_void); - ret - } -} -/// Constructs a new NodeSigner which calls the relevant methods on this_arg. -/// This copies the `inner` pointer in this_arg and thus the returned NodeSigner must be freed before this_arg is -#[no_mangle] -pub extern "C" fn PhantomKeysManager_as_NodeSigner(this_arg: &PhantomKeysManager) -> crate::lightning::chain::keysinterface::NodeSigner { - crate::lightning::chain::keysinterface::NodeSigner { - this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, - free: None, - get_inbound_payment_key_material: PhantomKeysManager_NodeSigner_get_inbound_payment_key_material, - get_node_id: PhantomKeysManager_NodeSigner_get_node_id, - ecdh: PhantomKeysManager_NodeSigner_ecdh, - sign_invoice: PhantomKeysManager_NodeSigner_sign_invoice, - sign_gossip_message: PhantomKeysManager_NodeSigner_sign_gossip_message, - } -} - -#[must_use] -extern "C" fn PhantomKeysManager_NodeSigner_get_inbound_payment_key_material(this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes { - let mut ret = >::get_inbound_payment_key_material(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, ); - crate::c_types::ThirtyTwoBytes { data: ret.0 } -} -#[must_use] -extern "C" fn PhantomKeysManager_NodeSigner_get_node_id(this_arg: *const c_void, mut recipient: crate::lightning::chain::keysinterface::Recipient) -> crate::c_types::derived::CResult_PublicKeyNoneZ { - let mut ret = >::get_node_id(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, recipient.into_native()); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::PublicKey::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} -#[must_use] -extern "C" fn PhantomKeysManager_NodeSigner_ecdh(this_arg: *const c_void, mut recipient: crate::lightning::chain::keysinterface::Recipient, mut other_key: crate::c_types::PublicKey, mut tweak: crate::c_types::derived::COption_ScalarZ) -> crate::c_types::derived::CResult_SharedSecretNoneZ { - let mut local_tweak_base = { /*tweak*/ let tweak_opt = tweak; if tweak_opt.is_none() { None } else { Some({ { { tweak_opt.take() }.into_rust() }})} }; let mut local_tweak = local_tweak_base.as_ref(); - let mut ret = >::ecdh(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, recipient.into_native(), &other_key.into_rust(), local_tweak); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ThirtyTwoBytes { data: o.secret_bytes() } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} -#[must_use] -extern "C" fn PhantomKeysManager_NodeSigner_sign_invoice(this_arg: *const c_void, mut hrp_bytes: crate::c_types::u8slice, mut invoice_data: crate::c_types::derived::CVec_U5Z, mut recipient: crate::lightning::chain::keysinterface::Recipient) -> crate::c_types::derived::CResult_RecoverableSignatureNoneZ { - let mut local_invoice_data = Vec::new(); for mut item in invoice_data.into_rust().drain(..) { local_invoice_data.push( { item.into() }); }; - let mut ret = >::sign_invoice(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, hrp_bytes.to_slice(), &local_invoice_data[..], recipient.into_native()); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::RecoverableSignature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} -#[must_use] -extern "C" fn PhantomKeysManager_NodeSigner_sign_gossip_message(this_arg: *const c_void, mut msg: crate::lightning::ln::msgs::UnsignedGossipMessage) -> crate::c_types::derived::CResult_SignatureNoneZ { - let mut ret = >::sign_gossip_message(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, msg.into_native()); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Signature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} - -impl From for crate::lightning::chain::keysinterface::SignerProvider { - fn from(obj: nativePhantomKeysManager) -> Self { - let mut rust_obj = PhantomKeysManager { inner: ObjOps::heap_alloc(obj), is_owned: true }; - let mut ret = PhantomKeysManager_as_SignerProvider(&rust_obj); - // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn - rust_obj.inner = core::ptr::null_mut(); - ret.free = Some(PhantomKeysManager_free_void); - ret - } -} -/// Constructs a new SignerProvider which calls the relevant methods on this_arg. -/// This copies the `inner` pointer in this_arg and thus the returned SignerProvider must be freed before this_arg is -#[no_mangle] -pub extern "C" fn PhantomKeysManager_as_SignerProvider(this_arg: &PhantomKeysManager) -> crate::lightning::chain::keysinterface::SignerProvider { - crate::lightning::chain::keysinterface::SignerProvider { - this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, - free: None, - generate_channel_keys_id: PhantomKeysManager_SignerProvider_generate_channel_keys_id, - derive_channel_signer: PhantomKeysManager_SignerProvider_derive_channel_signer, - read_chan_signer: PhantomKeysManager_SignerProvider_read_chan_signer, - get_destination_script: PhantomKeysManager_SignerProvider_get_destination_script, - get_shutdown_scriptpubkey: PhantomKeysManager_SignerProvider_get_shutdown_scriptpubkey, - } -} - -#[must_use] -extern "C" fn PhantomKeysManager_SignerProvider_generate_channel_keys_id(this_arg: *const c_void, mut inbound: bool, mut channel_value_satoshis: u64, mut user_channel_id: crate::c_types::U128) -> crate::c_types::ThirtyTwoBytes { - let mut ret = >::generate_channel_keys_id(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, inbound, channel_value_satoshis, user_channel_id.into()); - crate::c_types::ThirtyTwoBytes { data: ret } -} -#[must_use] -extern "C" fn PhantomKeysManager_SignerProvider_derive_channel_signer(this_arg: *const c_void, mut channel_value_satoshis: u64, mut channel_keys_id: crate::c_types::ThirtyTwoBytes) -> crate::lightning::chain::keysinterface::WriteableEcdsaChannelSigner { - let mut ret = >::derive_channel_signer(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, channel_value_satoshis, channel_keys_id.data); - Into::into(ret) -} -#[must_use] -extern "C" fn PhantomKeysManager_SignerProvider_read_chan_signer(this_arg: *const c_void, mut reader: crate::c_types::u8slice) -> crate::c_types::derived::CResult_WriteableEcdsaChannelSignerDecodeErrorZ { - let mut ret = >::read_chan_signer(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, reader.to_slice()); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { Into::into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; - local_ret -} -#[must_use] -extern "C" fn PhantomKeysManager_SignerProvider_get_destination_script(this_arg: *const c_void) -> crate::c_types::derived::CVec_u8Z { - let mut ret = >::get_destination_script(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, ); - ret.into_bytes().into() -} -#[must_use] -extern "C" fn PhantomKeysManager_SignerProvider_get_shutdown_scriptpubkey(this_arg: *const c_void) -> crate::lightning::ln::script::ShutdownScript { - let mut ret = >::get_shutdown_scriptpubkey(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, ); - crate::lightning::ln::script::ShutdownScript { inner: ObjOps::heap_alloc(ret), is_owned: true } -} - -/// Constructs a [`PhantomKeysManager`] given a 32-byte seed and an additional `cross_node_seed` -/// that is shared across all nodes that intend to participate in [phantom node payments] -/// together. -/// -/// See [`KeysManager::new`] for more information on `seed`, `starting_time_secs`, and -/// `starting_time_nanos`. -/// -/// `cross_node_seed` must be the same across all phantom payment-receiving nodes and also the -/// same across restarts, or else inbound payments may fail. -/// -/// [phantom node payments]: PhantomKeysManager -#[must_use] -#[no_mangle] -pub extern "C" fn PhantomKeysManager_new(seed: *const [u8; 32], mut starting_time_secs: u64, mut starting_time_nanos: u32, cross_node_seed: *const [u8; 32]) -> crate::lightning::chain::keysinterface::PhantomKeysManager { - let mut ret = lightning::chain::keysinterface::PhantomKeysManager::new(unsafe { &*seed}, starting_time_secs, starting_time_nanos, unsafe { &*cross_node_seed}); - crate::lightning::chain::keysinterface::PhantomKeysManager { inner: ObjOps::heap_alloc(ret), is_owned: true } -} - -/// See [`KeysManager::spend_spendable_outputs`] for documentation on this method. -#[must_use] -#[no_mangle] -pub extern "C" fn PhantomKeysManager_spend_spendable_outputs(this_arg: &crate::lightning::chain::keysinterface::PhantomKeysManager, mut descriptors: crate::c_types::derived::CVec_SpendableOutputDescriptorZ, mut outputs: crate::c_types::derived::CVec_TxOutZ, mut change_destination_script: crate::c_types::derived::CVec_u8Z, mut feerate_sat_per_1000_weight: u32) -> crate::c_types::derived::CResult_TransactionNoneZ { - let mut local_descriptors = Vec::new(); for mut item in descriptors.into_rust().drain(..) { local_descriptors.push( { item.into_native() }); }; - let mut local_outputs = Vec::new(); for mut item in outputs.into_rust().drain(..) { local_outputs.push( { item.into_rust() }); }; - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.spend_spendable_outputs(&local_descriptors.iter().collect::>()[..], local_outputs, ::bitcoin::blockdata::script::Script::from(change_destination_script.into_rust()), feerate_sat_per_1000_weight, secp256k1::global::SECP256K1); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Transaction::from_bitcoin(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} - -/// See [`KeysManager::derive_channel_keys`] for documentation on this method. -#[must_use] -#[no_mangle] -pub extern "C" fn PhantomKeysManager_derive_channel_keys(this_arg: &crate::lightning::chain::keysinterface::PhantomKeysManager, mut channel_value_satoshis: u64, params: *const [u8; 32]) -> crate::lightning::chain::keysinterface::InMemorySigner { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.derive_channel_keys(channel_value_satoshis, unsafe { &*params}); - crate::lightning::chain::keysinterface::InMemorySigner { inner: ObjOps::heap_alloc(ret), is_owned: true } -} - -/// Gets the \"node_id\" secret key used to sign gossip announcements, decode onion data, etc. -#[must_use] -#[no_mangle] -pub extern "C" fn PhantomKeysManager_get_node_secret_key(this_arg: &crate::lightning::chain::keysinterface::PhantomKeysManager) -> crate::c_types::SecretKey { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_node_secret_key(); - crate::c_types::SecretKey::from_rust(ret) -} - -/// Gets the \"node_id\" secret key of the phantom node used to sign invoices, decode the -/// last-hop onion data, etc. -#[must_use] -#[no_mangle] -pub extern "C" fn PhantomKeysManager_get_phantom_node_secret_key(this_arg: &crate::lightning::chain::keysinterface::PhantomKeysManager) -> crate::c_types::SecretKey { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_phantom_node_secret_key(); - crate::c_types::SecretKey::from_rust(ret) -} - diff --git a/lightning-c-bindings/src/lightning/chain/mod.rs b/lightning-c-bindings/src/lightning/chain/mod.rs index 74fe7212..54dd4ef4 100644 --- a/lightning-c-bindings/src/lightning/chain/mod.rs +++ b/lightning-c-bindings/src/lightning/chain/mod.rs @@ -20,7 +20,6 @@ pub mod chaininterface; pub mod chainmonitor; pub mod channelmonitor; pub mod transaction; -pub mod keysinterface; mod onchaintx { use alloc::str::FromStr; @@ -321,8 +320,7 @@ pub struct Confirm { /// /// [`transactions_confirmed`]: Self::transactions_confirmed /// [`transaction_unconfirmed`]: Self::transaction_unconfirmed - #[must_use] - pub get_relevant_txids: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_C2Tuple_TxidBlockHashZZ, + pub get_relevant_txids: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_C2Tuple_TxidCOption_BlockHashZZZ, /// Frees any resources associated with this object given its this_arg pointer. /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. pub free: Option, @@ -357,7 +355,7 @@ impl rustConfirm for Confirm { } fn get_relevant_txids(&self) -> Vec<(bitcoin::hash_types::Txid, Option)> { let mut ret = (self.get_relevant_txids)(self.this_arg); - let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item.to_rust(); let mut local_orig_ret_0_1 = if orig_ret_0_1.data == [0; 32] { None } else { Some( { ::bitcoin::hash_types::BlockHash::from_slice(&orig_ret_0_1.data[..]).unwrap() }) }; let mut local_ret_0 = (::bitcoin::hash_types::Txid::from_slice(&orig_ret_0_0.data[..]).unwrap(), local_orig_ret_0_1); local_ret_0 }); }; + let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item.to_rust(); let mut local_orig_ret_0_1 = { /*orig_ret_0_1*/ let orig_ret_0_1_opt = orig_ret_0_1; if orig_ret_0_1_opt.is_none() { None } else { Some({ { ::bitcoin::hash_types::BlockHash::from_slice(&{ orig_ret_0_1_opt.take() }.data[..]).unwrap() }})} }; let mut local_ret_0 = (::bitcoin::hash_types::Txid::from_slice(&orig_ret_0_0.data[..]).unwrap(), local_orig_ret_0_1); local_ret_0 }); }; local_ret } } @@ -555,7 +553,6 @@ pub struct Watch { /// [`get_outputs_to_watch`]: channelmonitor::ChannelMonitor::get_outputs_to_watch /// [`block_connected`]: channelmonitor::ChannelMonitor::block_connected /// [`block_disconnected`]: channelmonitor::ChannelMonitor::block_disconnected - #[must_use] pub watch_channel: extern "C" fn (this_arg: *const c_void, funding_txo: crate::lightning::chain::transaction::OutPoint, monitor: crate::lightning::chain::channelmonitor::ChannelMonitor) -> crate::lightning::chain::ChannelMonitorUpdateStatus, /// Updates a channel identified by `funding_txo` by applying `update` to its monitor. /// @@ -563,7 +560,6 @@ pub struct Watch { /// [`ChannelMonitorUpdateStatus`] for invariants around returning an error. /// /// [`update_monitor`]: channelmonitor::ChannelMonitor::update_monitor - #[must_use] pub update_channel: extern "C" fn (this_arg: *const c_void, funding_txo: crate::lightning::chain::transaction::OutPoint, update: &crate::lightning::chain::channelmonitor::ChannelMonitorUpdate) -> crate::lightning::chain::ChannelMonitorUpdateStatus, /// Returns any monitor events since the last call. Subsequent calls must only return new /// events. @@ -574,7 +570,6 @@ pub struct Watch { /// /// For details on asynchronous [`ChannelMonitor`] updating and returning /// [`MonitorEvent::Completed`] here, see [`ChannelMonitorUpdateStatus::InProgress`]. - #[must_use] pub release_pending_monitor_events: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ, /// Frees any resources associated with this object given its this_arg pointer. /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. @@ -594,8 +589,8 @@ pub(crate) extern "C" fn Watch_clone_fields(orig: &Watch) -> Watch { } use lightning::chain::Watch as rustWatch; -impl rustWatch for Watch { - fn watch_channel(&self, mut funding_txo: lightning::chain::transaction::OutPoint, mut monitor: lightning::chain::channelmonitor::ChannelMonitor) -> lightning::chain::ChannelMonitorUpdateStatus { +impl rustWatch for Watch { + fn watch_channel(&self, mut funding_txo: lightning::chain::transaction::OutPoint, mut monitor: lightning::chain::channelmonitor::ChannelMonitor) -> lightning::chain::ChannelMonitorUpdateStatus { let mut ret = (self.watch_channel)(self.this_arg, crate::lightning::chain::transaction::OutPoint { inner: ObjOps::heap_alloc(funding_txo), is_owned: true }, crate::lightning::chain::channelmonitor::ChannelMonitor { inner: ObjOps::heap_alloc(monitor), is_owned: true }); ret.into_native() } @@ -769,20 +764,16 @@ impl WatchedOutput { } } /// First block where the transaction output may have been spent. -/// -/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[no_mangle] -pub extern "C" fn WatchedOutput_get_block_hash(this_ptr: &WatchedOutput) -> crate::c_types::ThirtyTwoBytes { +pub extern "C" fn WatchedOutput_get_block_hash(this_ptr: &WatchedOutput) -> crate::c_types::derived::COption_BlockHashZ { let mut inner_val = &mut this_ptr.get_native_mut_ref().block_hash; - let mut local_inner_val = if inner_val.is_none() { crate::c_types::ThirtyTwoBytes::null() } else { { crate::c_types::ThirtyTwoBytes { data: (inner_val.unwrap()).into_inner() } } }; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_BlockHashZ::None } else { crate::c_types::derived::COption_BlockHashZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option is otherwise un-expressable. */ { crate::c_types::ThirtyTwoBytes { data: (*inner_val.as_ref().unwrap()).clone().into_inner() } }) }; local_inner_val } /// First block where the transaction output may have been spent. -/// -/// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None #[no_mangle] -pub extern "C" fn WatchedOutput_set_block_hash(this_ptr: &mut WatchedOutput, mut val: crate::c_types::ThirtyTwoBytes) { - let mut local_val = if val.data == [0; 32] { None } else { Some( { ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap() }) }; +pub extern "C" fn WatchedOutput_set_block_hash(this_ptr: &mut WatchedOutput, mut val: crate::c_types::derived::COption_BlockHashZ) { + let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::bitcoin::hash_types::BlockHash::from_slice(&{ val_opt.take() }.data[..]).unwrap() }})} }; unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.block_hash = local_val; } /// Outpoint identifying the transaction output. @@ -810,8 +801,8 @@ pub extern "C" fn WatchedOutput_set_script_pubkey(this_ptr: &mut WatchedOutput, /// Constructs a new WatchedOutput given each field #[must_use] #[no_mangle] -pub extern "C" fn WatchedOutput_new(mut block_hash_arg: crate::c_types::ThirtyTwoBytes, mut outpoint_arg: crate::lightning::chain::transaction::OutPoint, mut script_pubkey_arg: crate::c_types::derived::CVec_u8Z) -> WatchedOutput { - let mut local_block_hash_arg = if block_hash_arg.data == [0; 32] { None } else { Some( { ::bitcoin::hash_types::BlockHash::from_slice(&block_hash_arg.data[..]).unwrap() }) }; +pub extern "C" fn WatchedOutput_new(mut block_hash_arg: crate::c_types::derived::COption_BlockHashZ, mut outpoint_arg: crate::lightning::chain::transaction::OutPoint, mut script_pubkey_arg: crate::c_types::derived::CVec_u8Z) -> WatchedOutput { + let mut local_block_hash_arg = { /*block_hash_arg*/ let block_hash_arg_opt = block_hash_arg; if block_hash_arg_opt.is_none() { None } else { Some({ { ::bitcoin::hash_types::BlockHash::from_slice(&{ block_hash_arg_opt.take() }.data[..]).unwrap() }})} }; WatchedOutput { inner: ObjOps::heap_alloc(nativeWatchedOutput { block_hash: local_block_hash_arg, outpoint: *unsafe { Box::from_raw(outpoint_arg.take_inner()) }, diff --git a/lightning-c-bindings/src/lightning/events.rs b/lightning-c-bindings/src/lightning/events.rs deleted file mode 100644 index 50b6875b..00000000 --- a/lightning-c-bindings/src/lightning/events.rs +++ /dev/null @@ -1,3634 +0,0 @@ -// This file is Copyright its original authors, visible in version control -// history and in the source files from which this was generated. -// -// This file is licensed under the license available in the LICENSE or LICENSE.md -// file in the root of this repository or, if no such file exists, the same -// license as that which applies to the original source files from which this -// source was automatically generated. - -//! Events are returned from various bits in the library which indicate some action must be taken -//! by the client. -//! -//! Because we don't have a built-in runtime, it's up to the client to call events at a time in the -//! future, as well as generate and broadcast funding transactions handle payment preimages and a -//! few other things. - -use alloc::str::FromStr; -use core::ffi::c_void; -use core::convert::Infallible; -use bitcoin::hashes::Hash; -use crate::c_types::*; -#[cfg(feature="no-std")] -use alloc::{vec::Vec, boxed::Box}; - -/// Some information provided on receipt of payment depends on whether the payment received is a -/// spontaneous payment or a \"conventional\" lightning payment that's paying an invoice. -#[derive(Clone)] -#[must_use] -#[repr(C)] -pub enum PaymentPurpose { - /// Information for receiving a payment that we generated an invoice for. - InvoicePayment { - /// The preimage to the payment_hash, if the payment hash (and secret) were fetched via - /// [`ChannelManager::create_inbound_payment`]. If provided, this can be handed directly to - /// [`ChannelManager::claim_funds`]. - /// - /// [`ChannelManager::create_inbound_payment`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment - /// [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds - /// - /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None - payment_preimage: crate::c_types::ThirtyTwoBytes, - /// The \"payment secret\". This authenticates the sender to the recipient, preventing a - /// number of deanonymization attacks during the routing process. - /// It is provided here for your reference, however its accuracy is enforced directly by - /// [`ChannelManager`] using the values you previously provided to - /// [`ChannelManager::create_inbound_payment`] or - /// [`ChannelManager::create_inbound_payment_for_hash`]. - /// - /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager - /// [`ChannelManager::create_inbound_payment`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment - /// [`ChannelManager::create_inbound_payment_for_hash`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash - payment_secret: crate::c_types::ThirtyTwoBytes, - }, - /// Because this is a spontaneous payment, the payer generated their own preimage rather than us - /// (the payee) providing a preimage. - SpontaneousPayment( - crate::c_types::ThirtyTwoBytes), -} -use lightning::events::PaymentPurpose as PaymentPurposeImport; -pub(crate) type nativePaymentPurpose = PaymentPurposeImport; - -impl PaymentPurpose { - #[allow(unused)] - pub(crate) fn to_native(&self) -> nativePaymentPurpose { - match self { - PaymentPurpose::InvoicePayment {ref payment_preimage, ref payment_secret, } => { - let mut payment_preimage_nonref = Clone::clone(payment_preimage); - let mut local_payment_preimage_nonref = if payment_preimage_nonref.data == [0; 32] { None } else { Some( { ::lightning::ln::PaymentPreimage(payment_preimage_nonref.data) }) }; - let mut payment_secret_nonref = Clone::clone(payment_secret); - nativePaymentPurpose::InvoicePayment { - payment_preimage: local_payment_preimage_nonref, - payment_secret: ::lightning::ln::PaymentSecret(payment_secret_nonref.data), - } - }, - PaymentPurpose::SpontaneousPayment (ref a, ) => { - let mut a_nonref = Clone::clone(a); - nativePaymentPurpose::SpontaneousPayment ( - ::lightning::ln::PaymentPreimage(a_nonref.data), - ) - }, - } - } - #[allow(unused)] - pub(crate) fn into_native(self) -> nativePaymentPurpose { - match self { - PaymentPurpose::InvoicePayment {mut payment_preimage, mut payment_secret, } => { - let mut local_payment_preimage = if payment_preimage.data == [0; 32] { None } else { Some( { ::lightning::ln::PaymentPreimage(payment_preimage.data) }) }; - nativePaymentPurpose::InvoicePayment { - payment_preimage: local_payment_preimage, - payment_secret: ::lightning::ln::PaymentSecret(payment_secret.data), - } - }, - PaymentPurpose::SpontaneousPayment (mut a, ) => { - nativePaymentPurpose::SpontaneousPayment ( - ::lightning::ln::PaymentPreimage(a.data), - ) - }, - } - } - #[allow(unused)] - pub(crate) fn from_native(native: &nativePaymentPurpose) -> Self { - match native { - nativePaymentPurpose::InvoicePayment {ref payment_preimage, ref payment_secret, } => { - let mut payment_preimage_nonref = Clone::clone(payment_preimage); - let mut local_payment_preimage_nonref = if payment_preimage_nonref.is_none() { crate::c_types::ThirtyTwoBytes::null() } else { { crate::c_types::ThirtyTwoBytes { data: (payment_preimage_nonref.unwrap()).0 } } }; - let mut payment_secret_nonref = Clone::clone(payment_secret); - PaymentPurpose::InvoicePayment { - payment_preimage: local_payment_preimage_nonref, - payment_secret: crate::c_types::ThirtyTwoBytes { data: payment_secret_nonref.0 }, - } - }, - nativePaymentPurpose::SpontaneousPayment (ref a, ) => { - let mut a_nonref = Clone::clone(a); - PaymentPurpose::SpontaneousPayment ( - crate::c_types::ThirtyTwoBytes { data: a_nonref.0 }, - ) - }, - } - } - #[allow(unused)] - pub(crate) fn native_into(native: nativePaymentPurpose) -> Self { - match native { - nativePaymentPurpose::InvoicePayment {mut payment_preimage, mut payment_secret, } => { - let mut local_payment_preimage = if payment_preimage.is_none() { crate::c_types::ThirtyTwoBytes::null() } else { { crate::c_types::ThirtyTwoBytes { data: (payment_preimage.unwrap()).0 } } }; - PaymentPurpose::InvoicePayment { - payment_preimage: local_payment_preimage, - payment_secret: crate::c_types::ThirtyTwoBytes { data: payment_secret.0 }, - } - }, - nativePaymentPurpose::SpontaneousPayment (mut a, ) => { - PaymentPurpose::SpontaneousPayment ( - crate::c_types::ThirtyTwoBytes { data: a.0 }, - ) - }, - } - } -} -/// Frees any resources used by the PaymentPurpose -#[no_mangle] -pub extern "C" fn PaymentPurpose_free(this_ptr: PaymentPurpose) { } -/// Creates a copy of the PaymentPurpose -#[no_mangle] -pub extern "C" fn PaymentPurpose_clone(orig: &PaymentPurpose) -> PaymentPurpose { - orig.clone() -} -#[no_mangle] -/// Utility method to constructs a new InvoicePayment-variant PaymentPurpose -pub extern "C" fn PaymentPurpose_invoice_payment(payment_preimage: crate::c_types::ThirtyTwoBytes, payment_secret: crate::c_types::ThirtyTwoBytes) -> PaymentPurpose { - PaymentPurpose::InvoicePayment { - payment_preimage, - payment_secret, - } -} -#[no_mangle] -/// Utility method to constructs a new SpontaneousPayment-variant PaymentPurpose -pub extern "C" fn PaymentPurpose_spontaneous_payment(a: crate::c_types::ThirtyTwoBytes) -> PaymentPurpose { - PaymentPurpose::SpontaneousPayment(a, ) -} -/// Checks if two PaymentPurposes contain equal inner contents. -/// This ignores pointers and is_owned flags and looks at the values in fields. -#[no_mangle] -pub extern "C" fn PaymentPurpose_eq(a: &PaymentPurpose, b: &PaymentPurpose) -> bool { - if &a.to_native() == &b.to_native() { true } else { false } -} -#[no_mangle] -/// Serialize the PaymentPurpose object into a byte array which can be read by PaymentPurpose_read -pub extern "C" fn PaymentPurpose_write(obj: &crate::lightning::events::PaymentPurpose) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(&unsafe { &*obj }.to_native()) -} -#[no_mangle] -/// Read a PaymentPurpose from a byte array, created by PaymentPurpose_write -pub extern "C" fn PaymentPurpose_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PaymentPurposeDecodeErrorZ { - let res: Result = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::events::PaymentPurpose::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; - local_res -} -/// When the payment path failure took place and extra details about it. [`PathFailure::OnPath`] may -/// contain a [`NetworkUpdate`] that needs to be applied to the [`NetworkGraph`]. -/// -/// [`NetworkUpdate`]: crate::routing::gossip::NetworkUpdate -/// [`NetworkGraph`]: crate::routing::gossip::NetworkGraph -#[derive(Clone)] -#[must_use] -#[repr(C)] -pub enum PathFailure { - /// We failed to initially send the payment and no HTLC was committed to. Contains the relevant - /// error. - InitialSend { - /// The error surfaced from initial send. - err: crate::lightning::util::errors::APIError, - }, - /// A hop on the path failed to forward our payment. - OnPath { - /// If present, this [`NetworkUpdate`] should be applied to the [`NetworkGraph`] so that routing - /// decisions can take into account the update. - /// - /// [`NetworkUpdate`]: crate::routing::gossip::NetworkUpdate - /// [`NetworkGraph`]: crate::routing::gossip::NetworkGraph - network_update: crate::c_types::derived::COption_NetworkUpdateZ, - }, -} -use lightning::events::PathFailure as PathFailureImport; -pub(crate) type nativePathFailure = PathFailureImport; - -impl PathFailure { - #[allow(unused)] - pub(crate) fn to_native(&self) -> nativePathFailure { - match self { - PathFailure::InitialSend {ref err, } => { - let mut err_nonref = Clone::clone(err); - nativePathFailure::InitialSend { - err: err_nonref.into_native(), - } - }, - PathFailure::OnPath {ref network_update, } => { - let mut network_update_nonref = Clone::clone(network_update); - let mut local_network_update_nonref = { /*network_update_nonref*/ let network_update_nonref_opt = network_update_nonref; if network_update_nonref_opt.is_none() { None } else { Some({ { { network_update_nonref_opt.take() }.into_native() }})} }; - nativePathFailure::OnPath { - network_update: local_network_update_nonref, - } - }, - } - } - #[allow(unused)] - pub(crate) fn into_native(self) -> nativePathFailure { - match self { - PathFailure::InitialSend {mut err, } => { - nativePathFailure::InitialSend { - err: err.into_native(), - } - }, - PathFailure::OnPath {mut network_update, } => { - let mut local_network_update = { /*network_update*/ let network_update_opt = network_update; if network_update_opt.is_none() { None } else { Some({ { { network_update_opt.take() }.into_native() }})} }; - nativePathFailure::OnPath { - network_update: local_network_update, - } - }, - } - } - #[allow(unused)] - pub(crate) fn from_native(native: &nativePathFailure) -> Self { - match native { - nativePathFailure::InitialSend {ref err, } => { - let mut err_nonref = Clone::clone(err); - PathFailure::InitialSend { - err: crate::lightning::util::errors::APIError::native_into(err_nonref), - } - }, - nativePathFailure::OnPath {ref network_update, } => { - let mut network_update_nonref = Clone::clone(network_update); - let mut local_network_update_nonref = if network_update_nonref.is_none() { crate::c_types::derived::COption_NetworkUpdateZ::None } else { crate::c_types::derived::COption_NetworkUpdateZ::Some( { crate::lightning::routing::gossip::NetworkUpdate::native_into(network_update_nonref.unwrap()) }) }; - PathFailure::OnPath { - network_update: local_network_update_nonref, - } - }, - } - } - #[allow(unused)] - pub(crate) fn native_into(native: nativePathFailure) -> Self { - match native { - nativePathFailure::InitialSend {mut err, } => { - PathFailure::InitialSend { - err: crate::lightning::util::errors::APIError::native_into(err), - } - }, - nativePathFailure::OnPath {mut network_update, } => { - let mut local_network_update = if network_update.is_none() { crate::c_types::derived::COption_NetworkUpdateZ::None } else { crate::c_types::derived::COption_NetworkUpdateZ::Some( { crate::lightning::routing::gossip::NetworkUpdate::native_into(network_update.unwrap()) }) }; - PathFailure::OnPath { - network_update: local_network_update, - } - }, - } - } -} -/// Frees any resources used by the PathFailure -#[no_mangle] -pub extern "C" fn PathFailure_free(this_ptr: PathFailure) { } -/// Creates a copy of the PathFailure -#[no_mangle] -pub extern "C" fn PathFailure_clone(orig: &PathFailure) -> PathFailure { - orig.clone() -} -#[no_mangle] -/// Utility method to constructs a new InitialSend-variant PathFailure -pub extern "C" fn PathFailure_initial_send(err: crate::lightning::util::errors::APIError) -> PathFailure { - PathFailure::InitialSend { - err, - } -} -#[no_mangle] -/// Utility method to constructs a new OnPath-variant PathFailure -pub extern "C" fn PathFailure_on_path(network_update: crate::c_types::derived::COption_NetworkUpdateZ) -> PathFailure { - PathFailure::OnPath { - network_update, - } -} -/// Checks if two PathFailures contain equal inner contents. -/// This ignores pointers and is_owned flags and looks at the values in fields. -#[no_mangle] -pub extern "C" fn PathFailure_eq(a: &PathFailure, b: &PathFailure) -> bool { - if &a.to_native() == &b.to_native() { true } else { false } -} -#[no_mangle] -/// Serialize the PathFailure object into a byte array which can be read by PathFailure_read -pub extern "C" fn PathFailure_write(obj: &crate::lightning::events::PathFailure) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(&unsafe { &*obj }.to_native()) -} -#[no_mangle] -/// Read a PathFailure from a byte array, created by PathFailure_write -pub extern "C" fn PathFailure_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_COption_PathFailureZDecodeErrorZ { - let res: Result, lightning::ln::msgs::DecodeError> = crate::c_types::maybe_deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_res_0 = if o.is_none() { crate::c_types::derived::COption_PathFailureZ::None } else { crate::c_types::derived::COption_PathFailureZ::Some( { crate::lightning::events::PathFailure::native_into(o.unwrap()) }) }; local_res_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; - local_res -} -/// The reason the channel was closed. See individual variants more details. -#[derive(Clone)] -#[must_use] -#[repr(C)] -pub enum ClosureReason { - /// Closure generated from receiving a peer error message. - /// - /// Our counterparty may have broadcasted their latest commitment state, and we have - /// as well. - CounterpartyForceClosed { - /// The error which the peer sent us. - /// - /// Be careful about printing the peer_msg, a well-crafted message could exploit - /// a security vulnerability in the terminal emulator or the logging subsystem. - /// To be safe, use `Display` on `UntrustedString` - /// - /// [`UntrustedString`]: crate::util::string::UntrustedString - peer_msg: crate::lightning::util::string::UntrustedString, - }, - /// Closure generated from [`ChannelManager::force_close_channel`], called by the user. - /// - /// [`ChannelManager::force_close_channel`]: crate::ln::channelmanager::ChannelManager::force_close_channel. - HolderForceClosed, - /// The channel was closed after negotiating a cooperative close and we've now broadcasted - /// the cooperative close transaction. Note the shutdown may have been initiated by us. - CooperativeClosure, - /// A commitment transaction was confirmed on chain, closing the channel. Most likely this - /// commitment transaction came from our counterparty, but it may also have come from - /// a copy of our own `ChannelMonitor`. - CommitmentTxConfirmed, - /// The funding transaction failed to confirm in a timely manner on an inbound channel. - FundingTimedOut, - /// Closure generated from processing an event, likely a HTLC forward/relay/reception. - ProcessingError { - /// A developer-readable error message which we generated. - err: crate::c_types::Str, - }, - /// The peer disconnected prior to funding completing. In this case the spec mandates that we - /// forget the channel entirely - we can attempt again if the peer reconnects. - /// - /// This includes cases where we restarted prior to funding completion, including prior to the - /// initial [`ChannelMonitor`] persistence completing. - /// - /// In LDK versions prior to 0.0.107 this could also occur if we were unable to connect to the - /// peer because of mutual incompatibility between us and our channel counterparty. - /// - /// [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor - DisconnectedPeer, - /// Closure generated from `ChannelManager::read` if the [`ChannelMonitor`] is newer than - /// the [`ChannelManager`] deserialized. - /// - /// [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor - /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager - OutdatedChannelManager, -} -use lightning::events::ClosureReason as ClosureReasonImport; -pub(crate) type nativeClosureReason = ClosureReasonImport; - -impl ClosureReason { - #[allow(unused)] - pub(crate) fn to_native(&self) -> nativeClosureReason { - match self { - ClosureReason::CounterpartyForceClosed {ref peer_msg, } => { - let mut peer_msg_nonref = Clone::clone(peer_msg); - nativeClosureReason::CounterpartyForceClosed { - peer_msg: *unsafe { Box::from_raw(peer_msg_nonref.take_inner()) }, - } - }, - ClosureReason::HolderForceClosed => nativeClosureReason::HolderForceClosed, - ClosureReason::CooperativeClosure => nativeClosureReason::CooperativeClosure, - ClosureReason::CommitmentTxConfirmed => nativeClosureReason::CommitmentTxConfirmed, - ClosureReason::FundingTimedOut => nativeClosureReason::FundingTimedOut, - ClosureReason::ProcessingError {ref err, } => { - let mut err_nonref = Clone::clone(err); - nativeClosureReason::ProcessingError { - err: err_nonref.into_string(), - } - }, - ClosureReason::DisconnectedPeer => nativeClosureReason::DisconnectedPeer, - ClosureReason::OutdatedChannelManager => nativeClosureReason::OutdatedChannelManager, - } - } - #[allow(unused)] - pub(crate) fn into_native(self) -> nativeClosureReason { - match self { - ClosureReason::CounterpartyForceClosed {mut peer_msg, } => { - nativeClosureReason::CounterpartyForceClosed { - peer_msg: *unsafe { Box::from_raw(peer_msg.take_inner()) }, - } - }, - ClosureReason::HolderForceClosed => nativeClosureReason::HolderForceClosed, - ClosureReason::CooperativeClosure => nativeClosureReason::CooperativeClosure, - ClosureReason::CommitmentTxConfirmed => nativeClosureReason::CommitmentTxConfirmed, - ClosureReason::FundingTimedOut => nativeClosureReason::FundingTimedOut, - ClosureReason::ProcessingError {mut err, } => { - nativeClosureReason::ProcessingError { - err: err.into_string(), - } - }, - ClosureReason::DisconnectedPeer => nativeClosureReason::DisconnectedPeer, - ClosureReason::OutdatedChannelManager => nativeClosureReason::OutdatedChannelManager, - } - } - #[allow(unused)] - pub(crate) fn from_native(native: &nativeClosureReason) -> Self { - match native { - nativeClosureReason::CounterpartyForceClosed {ref peer_msg, } => { - let mut peer_msg_nonref = Clone::clone(peer_msg); - ClosureReason::CounterpartyForceClosed { - peer_msg: crate::lightning::util::string::UntrustedString { inner: ObjOps::heap_alloc(peer_msg_nonref), is_owned: true }, - } - }, - nativeClosureReason::HolderForceClosed => ClosureReason::HolderForceClosed, - nativeClosureReason::CooperativeClosure => ClosureReason::CooperativeClosure, - nativeClosureReason::CommitmentTxConfirmed => ClosureReason::CommitmentTxConfirmed, - nativeClosureReason::FundingTimedOut => ClosureReason::FundingTimedOut, - nativeClosureReason::ProcessingError {ref err, } => { - let mut err_nonref = Clone::clone(err); - ClosureReason::ProcessingError { - err: err_nonref.into(), - } - }, - nativeClosureReason::DisconnectedPeer => ClosureReason::DisconnectedPeer, - nativeClosureReason::OutdatedChannelManager => ClosureReason::OutdatedChannelManager, - } - } - #[allow(unused)] - pub(crate) fn native_into(native: nativeClosureReason) -> Self { - match native { - nativeClosureReason::CounterpartyForceClosed {mut peer_msg, } => { - ClosureReason::CounterpartyForceClosed { - peer_msg: crate::lightning::util::string::UntrustedString { inner: ObjOps::heap_alloc(peer_msg), is_owned: true }, - } - }, - nativeClosureReason::HolderForceClosed => ClosureReason::HolderForceClosed, - nativeClosureReason::CooperativeClosure => ClosureReason::CooperativeClosure, - nativeClosureReason::CommitmentTxConfirmed => ClosureReason::CommitmentTxConfirmed, - nativeClosureReason::FundingTimedOut => ClosureReason::FundingTimedOut, - nativeClosureReason::ProcessingError {mut err, } => { - ClosureReason::ProcessingError { - err: err.into(), - } - }, - nativeClosureReason::DisconnectedPeer => ClosureReason::DisconnectedPeer, - nativeClosureReason::OutdatedChannelManager => ClosureReason::OutdatedChannelManager, - } - } -} -/// Frees any resources used by the ClosureReason -#[no_mangle] -pub extern "C" fn ClosureReason_free(this_ptr: ClosureReason) { } -/// Creates a copy of the ClosureReason -#[no_mangle] -pub extern "C" fn ClosureReason_clone(orig: &ClosureReason) -> ClosureReason { - orig.clone() -} -#[no_mangle] -/// Utility method to constructs a new CounterpartyForceClosed-variant ClosureReason -pub extern "C" fn ClosureReason_counterparty_force_closed(peer_msg: crate::lightning::util::string::UntrustedString) -> ClosureReason { - ClosureReason::CounterpartyForceClosed { - peer_msg, - } -} -#[no_mangle] -/// Utility method to constructs a new HolderForceClosed-variant ClosureReason -pub extern "C" fn ClosureReason_holder_force_closed() -> ClosureReason { - ClosureReason::HolderForceClosed} -#[no_mangle] -/// Utility method to constructs a new CooperativeClosure-variant ClosureReason -pub extern "C" fn ClosureReason_cooperative_closure() -> ClosureReason { - ClosureReason::CooperativeClosure} -#[no_mangle] -/// Utility method to constructs a new CommitmentTxConfirmed-variant ClosureReason -pub extern "C" fn ClosureReason_commitment_tx_confirmed() -> ClosureReason { - ClosureReason::CommitmentTxConfirmed} -#[no_mangle] -/// Utility method to constructs a new FundingTimedOut-variant ClosureReason -pub extern "C" fn ClosureReason_funding_timed_out() -> ClosureReason { - ClosureReason::FundingTimedOut} -#[no_mangle] -/// Utility method to constructs a new ProcessingError-variant ClosureReason -pub extern "C" fn ClosureReason_processing_error(err: crate::c_types::Str) -> ClosureReason { - ClosureReason::ProcessingError { - err, - } -} -#[no_mangle] -/// Utility method to constructs a new DisconnectedPeer-variant ClosureReason -pub extern "C" fn ClosureReason_disconnected_peer() -> ClosureReason { - ClosureReason::DisconnectedPeer} -#[no_mangle] -/// Utility method to constructs a new OutdatedChannelManager-variant ClosureReason -pub extern "C" fn ClosureReason_outdated_channel_manager() -> ClosureReason { - ClosureReason::OutdatedChannelManager} -/// Checks if two ClosureReasons contain equal inner contents. -/// This ignores pointers and is_owned flags and looks at the values in fields. -#[no_mangle] -pub extern "C" fn ClosureReason_eq(a: &ClosureReason, b: &ClosureReason) -> bool { - if &a.to_native() == &b.to_native() { true } else { false } -} -#[no_mangle] -/// Serialize the ClosureReason object into a byte array which can be read by ClosureReason_read -pub extern "C" fn ClosureReason_write(obj: &crate::lightning::events::ClosureReason) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(&unsafe { &*obj }.to_native()) -} -#[no_mangle] -/// Read a ClosureReason from a byte array, created by ClosureReason_write -pub extern "C" fn ClosureReason_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_COption_ClosureReasonZDecodeErrorZ { - let res: Result, lightning::ln::msgs::DecodeError> = crate::c_types::maybe_deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_res_0 = if o.is_none() { crate::c_types::derived::COption_ClosureReasonZ::None } else { crate::c_types::derived::COption_ClosureReasonZ::Some( { crate::lightning::events::ClosureReason::native_into(o.unwrap()) }) }; local_res_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; - local_res -} -/// Intended destination of a failed HTLC as indicated in [`Event::HTLCHandlingFailed`]. -#[derive(Clone)] -#[must_use] -#[repr(C)] -pub enum HTLCDestination { - /// We tried forwarding to a channel but failed to do so. An example of such an instance is when - /// there is insufficient capacity in our outbound channel. - NextHopChannel { - /// The `node_id` of the next node. For backwards compatibility, this field is - /// marked as optional, versions prior to 0.0.110 may not always be able to provide - /// counterparty node information. - /// - /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None - node_id: crate::c_types::PublicKey, - /// The outgoing `channel_id` between us and the next node. - channel_id: crate::c_types::ThirtyTwoBytes, - }, - /// Scenario where we are unsure of the next node to forward the HTLC to. - UnknownNextHop { - /// Short channel id we are requesting to forward an HTLC to. - requested_forward_scid: u64, - }, - /// We couldn't forward to the outgoing scid. An example would be attempting to send a duplicate - /// intercept HTLC. - InvalidForward { - /// Short channel id we are requesting to forward an HTLC to. - requested_forward_scid: u64, - }, - /// Failure scenario where an HTLC may have been forwarded to be intended for us, - /// but is invalid for some reason, so we reject it. - /// - /// Some of the reasons may include: - /// * HTLC Timeouts - /// * Excess HTLCs for a payment that we have already fully received, over-paying for the - /// payment, - /// * The counterparty node modified the HTLC in transit, - /// * A probing attack where an intermediary node is trying to detect if we are the ultimate - /// recipient for a payment. - FailedPayment { - /// The payment hash of the payment we attempted to process. - payment_hash: crate::c_types::ThirtyTwoBytes, - }, -} -use lightning::events::HTLCDestination as HTLCDestinationImport; -pub(crate) type nativeHTLCDestination = HTLCDestinationImport; - -impl HTLCDestination { - #[allow(unused)] - pub(crate) fn to_native(&self) -> nativeHTLCDestination { - match self { - HTLCDestination::NextHopChannel {ref node_id, ref channel_id, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut local_node_id_nonref = if node_id_nonref.is_null() { None } else { Some( { node_id_nonref.into_rust() }) }; - let mut channel_id_nonref = Clone::clone(channel_id); - nativeHTLCDestination::NextHopChannel { - node_id: local_node_id_nonref, - channel_id: channel_id_nonref.data, - } - }, - HTLCDestination::UnknownNextHop {ref requested_forward_scid, } => { - let mut requested_forward_scid_nonref = Clone::clone(requested_forward_scid); - nativeHTLCDestination::UnknownNextHop { - requested_forward_scid: requested_forward_scid_nonref, - } - }, - HTLCDestination::InvalidForward {ref requested_forward_scid, } => { - let mut requested_forward_scid_nonref = Clone::clone(requested_forward_scid); - nativeHTLCDestination::InvalidForward { - requested_forward_scid: requested_forward_scid_nonref, - } - }, - HTLCDestination::FailedPayment {ref payment_hash, } => { - let mut payment_hash_nonref = Clone::clone(payment_hash); - nativeHTLCDestination::FailedPayment { - payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data), - } - }, - } - } - #[allow(unused)] - pub(crate) fn into_native(self) -> nativeHTLCDestination { - match self { - HTLCDestination::NextHopChannel {mut node_id, mut channel_id, } => { - let mut local_node_id = if node_id.is_null() { None } else { Some( { node_id.into_rust() }) }; - nativeHTLCDestination::NextHopChannel { - node_id: local_node_id, - channel_id: channel_id.data, - } - }, - HTLCDestination::UnknownNextHop {mut requested_forward_scid, } => { - nativeHTLCDestination::UnknownNextHop { - requested_forward_scid: requested_forward_scid, - } - }, - HTLCDestination::InvalidForward {mut requested_forward_scid, } => { - nativeHTLCDestination::InvalidForward { - requested_forward_scid: requested_forward_scid, - } - }, - HTLCDestination::FailedPayment {mut payment_hash, } => { - nativeHTLCDestination::FailedPayment { - payment_hash: ::lightning::ln::PaymentHash(payment_hash.data), - } - }, - } - } - #[allow(unused)] - pub(crate) fn from_native(native: &nativeHTLCDestination) -> Self { - match native { - nativeHTLCDestination::NextHopChannel {ref node_id, ref channel_id, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut local_node_id_nonref = if node_id_nonref.is_none() { crate::c_types::PublicKey::null() } else { { crate::c_types::PublicKey::from_rust(&(node_id_nonref.unwrap())) } }; - let mut channel_id_nonref = Clone::clone(channel_id); - HTLCDestination::NextHopChannel { - node_id: local_node_id_nonref, - channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id_nonref }, - } - }, - nativeHTLCDestination::UnknownNextHop {ref requested_forward_scid, } => { - let mut requested_forward_scid_nonref = Clone::clone(requested_forward_scid); - HTLCDestination::UnknownNextHop { - requested_forward_scid: requested_forward_scid_nonref, - } - }, - nativeHTLCDestination::InvalidForward {ref requested_forward_scid, } => { - let mut requested_forward_scid_nonref = Clone::clone(requested_forward_scid); - HTLCDestination::InvalidForward { - requested_forward_scid: requested_forward_scid_nonref, - } - }, - nativeHTLCDestination::FailedPayment {ref payment_hash, } => { - let mut payment_hash_nonref = Clone::clone(payment_hash); - HTLCDestination::FailedPayment { - payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 }, - } - }, - } - } - #[allow(unused)] - pub(crate) fn native_into(native: nativeHTLCDestination) -> Self { - match native { - nativeHTLCDestination::NextHopChannel {mut node_id, mut channel_id, } => { - let mut local_node_id = if node_id.is_none() { crate::c_types::PublicKey::null() } else { { crate::c_types::PublicKey::from_rust(&(node_id.unwrap())) } }; - HTLCDestination::NextHopChannel { - node_id: local_node_id, - channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id }, - } - }, - nativeHTLCDestination::UnknownNextHop {mut requested_forward_scid, } => { - HTLCDestination::UnknownNextHop { - requested_forward_scid: requested_forward_scid, - } - }, - nativeHTLCDestination::InvalidForward {mut requested_forward_scid, } => { - HTLCDestination::InvalidForward { - requested_forward_scid: requested_forward_scid, - } - }, - nativeHTLCDestination::FailedPayment {mut payment_hash, } => { - HTLCDestination::FailedPayment { - payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 }, - } - }, - } - } -} -/// Frees any resources used by the HTLCDestination -#[no_mangle] -pub extern "C" fn HTLCDestination_free(this_ptr: HTLCDestination) { } -/// Creates a copy of the HTLCDestination -#[no_mangle] -pub extern "C" fn HTLCDestination_clone(orig: &HTLCDestination) -> HTLCDestination { - orig.clone() -} -#[no_mangle] -/// Utility method to constructs a new NextHopChannel-variant HTLCDestination -pub extern "C" fn HTLCDestination_next_hop_channel(node_id: crate::c_types::PublicKey, channel_id: crate::c_types::ThirtyTwoBytes) -> HTLCDestination { - HTLCDestination::NextHopChannel { - node_id, - channel_id, - } -} -#[no_mangle] -/// Utility method to constructs a new UnknownNextHop-variant HTLCDestination -pub extern "C" fn HTLCDestination_unknown_next_hop(requested_forward_scid: u64) -> HTLCDestination { - HTLCDestination::UnknownNextHop { - requested_forward_scid, - } -} -#[no_mangle] -/// Utility method to constructs a new InvalidForward-variant HTLCDestination -pub extern "C" fn HTLCDestination_invalid_forward(requested_forward_scid: u64) -> HTLCDestination { - HTLCDestination::InvalidForward { - requested_forward_scid, - } -} -#[no_mangle] -/// Utility method to constructs a new FailedPayment-variant HTLCDestination -pub extern "C" fn HTLCDestination_failed_payment(payment_hash: crate::c_types::ThirtyTwoBytes) -> HTLCDestination { - HTLCDestination::FailedPayment { - payment_hash, - } -} -/// Checks if two HTLCDestinations contain equal inner contents. -/// This ignores pointers and is_owned flags and looks at the values in fields. -#[no_mangle] -pub extern "C" fn HTLCDestination_eq(a: &HTLCDestination, b: &HTLCDestination) -> bool { - if &a.to_native() == &b.to_native() { true } else { false } -} -#[no_mangle] -/// Serialize the HTLCDestination object into a byte array which can be read by HTLCDestination_read -pub extern "C" fn HTLCDestination_write(obj: &crate::lightning::events::HTLCDestination) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(&unsafe { &*obj }.to_native()) -} -#[no_mangle] -/// Read a HTLCDestination from a byte array, created by HTLCDestination_write -pub extern "C" fn HTLCDestination_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_COption_HTLCDestinationZDecodeErrorZ { - let res: Result, lightning::ln::msgs::DecodeError> = crate::c_types::maybe_deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_res_0 = if o.is_none() { crate::c_types::derived::COption_HTLCDestinationZ::None } else { crate::c_types::derived::COption_HTLCDestinationZ::Some( { crate::lightning::events::HTLCDestination::native_into(o.unwrap()) }) }; local_res_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; - local_res -} -/// The reason the payment failed. Used in [`Event::PaymentFailed`]. -#[derive(Clone)] -#[must_use] -#[repr(C)] -pub enum PaymentFailureReason { - /// The intended recipient rejected our payment. - RecipientRejected, - /// The user chose to abandon this payment by calling [`ChannelManager::abandon_payment`]. - /// - /// [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment - UserAbandoned, - /// We exhausted all of our retry attempts while trying to send the payment, or we - /// exhausted the [`Retry::Timeout`] if the user set one. If at any point a retry - /// attempt failed while being forwarded along the path, an [`Event::PaymentPathFailed`] will - /// have come before this. - /// - /// [`Retry::Timeout`]: crate::ln::channelmanager::Retry::Timeout - RetriesExhausted, - /// The payment expired while retrying, based on the provided - /// [`PaymentParameters::expiry_time`]. - /// - /// [`PaymentParameters::expiry_time`]: crate::routing::router::PaymentParameters::expiry_time - PaymentExpired, - /// We failed to find a route while retrying the payment. - RouteNotFound, - /// This error should generally never happen. This likely means that there is a problem with - /// your router. - UnexpectedError, -} -use lightning::events::PaymentFailureReason as PaymentFailureReasonImport; -pub(crate) type nativePaymentFailureReason = PaymentFailureReasonImport; - -impl PaymentFailureReason { - #[allow(unused)] - pub(crate) fn to_native(&self) -> nativePaymentFailureReason { - match self { - PaymentFailureReason::RecipientRejected => nativePaymentFailureReason::RecipientRejected, - PaymentFailureReason::UserAbandoned => nativePaymentFailureReason::UserAbandoned, - PaymentFailureReason::RetriesExhausted => nativePaymentFailureReason::RetriesExhausted, - PaymentFailureReason::PaymentExpired => nativePaymentFailureReason::PaymentExpired, - PaymentFailureReason::RouteNotFound => nativePaymentFailureReason::RouteNotFound, - PaymentFailureReason::UnexpectedError => nativePaymentFailureReason::UnexpectedError, - } - } - #[allow(unused)] - pub(crate) fn into_native(self) -> nativePaymentFailureReason { - match self { - PaymentFailureReason::RecipientRejected => nativePaymentFailureReason::RecipientRejected, - PaymentFailureReason::UserAbandoned => nativePaymentFailureReason::UserAbandoned, - PaymentFailureReason::RetriesExhausted => nativePaymentFailureReason::RetriesExhausted, - PaymentFailureReason::PaymentExpired => nativePaymentFailureReason::PaymentExpired, - PaymentFailureReason::RouteNotFound => nativePaymentFailureReason::RouteNotFound, - PaymentFailureReason::UnexpectedError => nativePaymentFailureReason::UnexpectedError, - } - } - #[allow(unused)] - pub(crate) fn from_native(native: &nativePaymentFailureReason) -> Self { - match native { - nativePaymentFailureReason::RecipientRejected => PaymentFailureReason::RecipientRejected, - nativePaymentFailureReason::UserAbandoned => PaymentFailureReason::UserAbandoned, - nativePaymentFailureReason::RetriesExhausted => PaymentFailureReason::RetriesExhausted, - nativePaymentFailureReason::PaymentExpired => PaymentFailureReason::PaymentExpired, - nativePaymentFailureReason::RouteNotFound => PaymentFailureReason::RouteNotFound, - nativePaymentFailureReason::UnexpectedError => PaymentFailureReason::UnexpectedError, - } - } - #[allow(unused)] - pub(crate) fn native_into(native: nativePaymentFailureReason) -> Self { - match native { - nativePaymentFailureReason::RecipientRejected => PaymentFailureReason::RecipientRejected, - nativePaymentFailureReason::UserAbandoned => PaymentFailureReason::UserAbandoned, - nativePaymentFailureReason::RetriesExhausted => PaymentFailureReason::RetriesExhausted, - nativePaymentFailureReason::PaymentExpired => PaymentFailureReason::PaymentExpired, - nativePaymentFailureReason::RouteNotFound => PaymentFailureReason::RouteNotFound, - nativePaymentFailureReason::UnexpectedError => PaymentFailureReason::UnexpectedError, - } - } -} -/// Creates a copy of the PaymentFailureReason -#[no_mangle] -pub extern "C" fn PaymentFailureReason_clone(orig: &PaymentFailureReason) -> PaymentFailureReason { - orig.clone() -} -#[no_mangle] -/// Utility method to constructs a new RecipientRejected-variant PaymentFailureReason -pub extern "C" fn PaymentFailureReason_recipient_rejected() -> PaymentFailureReason { - PaymentFailureReason::RecipientRejected} -#[no_mangle] -/// Utility method to constructs a new UserAbandoned-variant PaymentFailureReason -pub extern "C" fn PaymentFailureReason_user_abandoned() -> PaymentFailureReason { - PaymentFailureReason::UserAbandoned} -#[no_mangle] -/// Utility method to constructs a new RetriesExhausted-variant PaymentFailureReason -pub extern "C" fn PaymentFailureReason_retries_exhausted() -> PaymentFailureReason { - PaymentFailureReason::RetriesExhausted} -#[no_mangle] -/// Utility method to constructs a new PaymentExpired-variant PaymentFailureReason -pub extern "C" fn PaymentFailureReason_payment_expired() -> PaymentFailureReason { - PaymentFailureReason::PaymentExpired} -#[no_mangle] -/// Utility method to constructs a new RouteNotFound-variant PaymentFailureReason -pub extern "C" fn PaymentFailureReason_route_not_found() -> PaymentFailureReason { - PaymentFailureReason::RouteNotFound} -#[no_mangle] -/// Utility method to constructs a new UnexpectedError-variant PaymentFailureReason -pub extern "C" fn PaymentFailureReason_unexpected_error() -> PaymentFailureReason { - PaymentFailureReason::UnexpectedError} -/// Checks if two PaymentFailureReasons contain equal inner contents. -/// This ignores pointers and is_owned flags and looks at the values in fields. -#[no_mangle] -pub extern "C" fn PaymentFailureReason_eq(a: &PaymentFailureReason, b: &PaymentFailureReason) -> bool { - if &a.to_native() == &b.to_native() { true } else { false } -} -#[no_mangle] -/// Serialize the PaymentFailureReason object into a byte array which can be read by PaymentFailureReason_read -pub extern "C" fn PaymentFailureReason_write(obj: &crate::lightning::events::PaymentFailureReason) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(&unsafe { &*obj }.to_native()) -} -#[no_mangle] -/// Read a PaymentFailureReason from a byte array, created by PaymentFailureReason_write -pub extern "C" fn PaymentFailureReason_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PaymentFailureReasonDecodeErrorZ { - let res: Result = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::events::PaymentFailureReason::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; - local_res -} -/// An Event which you should probably take some action in response to. -/// -/// Note that while Writeable and Readable are implemented for Event, you probably shouldn't use -/// them directly as they don't round-trip exactly (for example FundingGenerationReady is never -/// written as it makes no sense to respond to it after reconnecting to peers). -#[derive(Clone)] -#[must_use] -#[repr(C)] -pub enum Event { - /// Used to indicate that the client should generate a funding transaction with the given - /// parameters and then call [`ChannelManager::funding_transaction_generated`]. - /// Generated in [`ChannelManager`] message handling. - /// Note that *all inputs* in the funding transaction must spend SegWit outputs or your - /// counterparty can steal your funds! - /// - /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager - /// [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated - FundingGenerationReady { - /// The random channel_id we picked which you'll need to pass into - /// [`ChannelManager::funding_transaction_generated`]. - /// - /// [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated - temporary_channel_id: crate::c_types::ThirtyTwoBytes, - /// The counterparty's node_id, which you'll need to pass back into - /// [`ChannelManager::funding_transaction_generated`]. - /// - /// [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated - counterparty_node_id: crate::c_types::PublicKey, - /// The value, in satoshis, that the output should have. - channel_value_satoshis: u64, - /// The script which should be used in the transaction output. - output_script: crate::c_types::derived::CVec_u8Z, - /// The `user_channel_id` value passed in to [`ChannelManager::create_channel`], or a - /// random value for an inbound channel. This may be zero for objects serialized with LDK - /// versions prior to 0.0.113. - /// - /// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel - user_channel_id: crate::c_types::U128, - }, - /// Indicates that we've been offered a payment and it needs to be claimed via calling - /// [`ChannelManager::claim_funds`] with the preimage given in [`PaymentPurpose`]. - /// - /// Note that if the preimage is not known, you should call - /// [`ChannelManager::fail_htlc_backwards`] or [`ChannelManager::fail_htlc_backwards_with_reason`] - /// to free up resources for this HTLC and avoid network congestion. - /// If you fail to call either [`ChannelManager::claim_funds`], [`ChannelManager::fail_htlc_backwards`], - /// or [`ChannelManager::fail_htlc_backwards_with_reason`] within the HTLC's timeout, the HTLC will be - /// automatically failed. - /// - /// # Note - /// LDK will not stop an inbound payment from being paid multiple times, so multiple - /// `PaymentClaimable` events may be generated for the same payment. In such a case it is - /// polite (and required in the lightning specification) to fail the payment the second time - /// and give the sender their money back rather than accepting double payment. - /// - /// # Note - /// This event used to be called `PaymentReceived` in LDK versions 0.0.112 and earlier. - /// - /// [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds - /// [`ChannelManager::fail_htlc_backwards`]: crate::ln::channelmanager::ChannelManager::fail_htlc_backwards - /// [`ChannelManager::fail_htlc_backwards_with_reason`]: crate::ln::channelmanager::ChannelManager::fail_htlc_backwards_with_reason - PaymentClaimable { - /// The node that will receive the payment after it has been claimed. - /// This is useful to identify payments received via [phantom nodes]. - /// This field will always be filled in when the event was generated by LDK versions - /// 0.0.113 and above. - /// - /// [phantom nodes]: crate::chain::keysinterface::PhantomKeysManager - /// - /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None - receiver_node_id: crate::c_types::PublicKey, - /// The hash for which the preimage should be handed to the ChannelManager. Note that LDK will - /// not stop you from registering duplicate payment hashes for inbound payments. - payment_hash: crate::c_types::ThirtyTwoBytes, - /// The fields in the onion which were received with each HTLC. Only fields which were - /// identical in each HTLC involved in the payment will be included here. - /// - /// Payments received on LDK versions prior to 0.0.115 will have this field unset. - /// - /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None - onion_fields: crate::lightning::ln::outbound_payment::RecipientOnionFields, - /// The value, in thousandths of a satoshi, that this payment is for. - amount_msat: u64, - /// Information for claiming this received payment, based on whether the purpose of the - /// payment is to pay an invoice or to send a spontaneous payment. - purpose: crate::lightning::events::PaymentPurpose, - /// The `channel_id` indicating over which channel we received the payment. - /// - /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None - via_channel_id: crate::c_types::ThirtyTwoBytes, - /// The `user_channel_id` indicating over which channel we received the payment. - via_user_channel_id: crate::c_types::derived::COption_u128Z, - /// The block height at which this payment will be failed back and will no longer be - /// eligible for claiming. - /// - /// Prior to this height, a call to [`ChannelManager::claim_funds`] is guaranteed to - /// succeed, however you should wait for [`Event::PaymentClaimed`] to be sure. - /// - /// [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds - claim_deadline: crate::c_types::derived::COption_u32Z, - }, - /// Indicates a payment has been claimed and we've received money! - /// - /// This most likely occurs when [`ChannelManager::claim_funds`] has been called in response - /// to an [`Event::PaymentClaimable`]. However, if we previously crashed during a - /// [`ChannelManager::claim_funds`] call you may see this event without a corresponding - /// [`Event::PaymentClaimable`] event. - /// - /// # Note - /// LDK will not stop an inbound payment from being paid multiple times, so multiple - /// `PaymentClaimable` events may be generated for the same payment. If you then call - /// [`ChannelManager::claim_funds`] twice for the same [`Event::PaymentClaimable`] you may get - /// multiple `PaymentClaimed` events. - /// - /// [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds - PaymentClaimed { - /// The node that received the payment. - /// This is useful to identify payments which were received via [phantom nodes]. - /// This field will always be filled in when the event was generated by LDK versions - /// 0.0.113 and above. - /// - /// [phantom nodes]: crate::chain::keysinterface::PhantomKeysManager - /// - /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None - receiver_node_id: crate::c_types::PublicKey, - /// The payment hash of the claimed payment. Note that LDK will not stop you from - /// registering duplicate payment hashes for inbound payments. - payment_hash: crate::c_types::ThirtyTwoBytes, - /// The value, in thousandths of a satoshi, that this payment is for. - amount_msat: u64, - /// The purpose of the claimed payment, i.e. whether the payment was for an invoice or a - /// spontaneous payment. - purpose: crate::lightning::events::PaymentPurpose, - }, - /// Indicates an outbound payment we made succeeded (i.e. it made it all the way to its target - /// and we got back the payment preimage for it). - /// - /// Note for MPP payments: in rare cases, this event may be preceded by a `PaymentPathFailed` - /// event. In this situation, you SHOULD treat this payment as having succeeded. - PaymentSent { - /// The `payment_id` passed to [`ChannelManager::send_payment`]. - /// - /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment - /// - /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None - payment_id: crate::c_types::ThirtyTwoBytes, - /// The preimage to the hash given to ChannelManager::send_payment. - /// Note that this serves as a payment receipt, if you wish to have such a thing, you must - /// store it somehow! - payment_preimage: crate::c_types::ThirtyTwoBytes, - /// The hash that was given to [`ChannelManager::send_payment`]. - /// - /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment - payment_hash: crate::c_types::ThirtyTwoBytes, - /// The total fee which was spent at intermediate hops in this payment, across all paths. - /// - /// Note that, like [`Route::get_total_fees`] this does *not* include any potential - /// overpayment to the recipient node. - /// - /// If the recipient or an intermediate node misbehaves and gives us free money, this may - /// overstate the amount paid, though this is unlikely. - /// - /// [`Route::get_total_fees`]: crate::routing::router::Route::get_total_fees - fee_paid_msat: crate::c_types::derived::COption_u64Z, - }, - /// Indicates an outbound payment failed. Individual [`Event::PaymentPathFailed`] events - /// provide failure information for each path attempt in the payment, including retries. - /// - /// This event is provided once there are no further pending HTLCs for the payment and the - /// payment is no longer retryable, due either to the [`Retry`] provided or - /// [`ChannelManager::abandon_payment`] having been called for the corresponding payment. - /// - /// [`Retry`]: crate::ln::channelmanager::Retry - /// [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment - PaymentFailed { - /// The `payment_id` passed to [`ChannelManager::send_payment`]. - /// - /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment - payment_id: crate::c_types::ThirtyTwoBytes, - /// The hash that was given to [`ChannelManager::send_payment`]. - /// - /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment - payment_hash: crate::c_types::ThirtyTwoBytes, - /// The reason the payment failed. This is only `None` for events generated or serialized - /// by versions prior to 0.0.115. - reason: crate::c_types::derived::COption_PaymentFailureReasonZ, - }, - /// Indicates that a path for an outbound payment was successful. - /// - /// Always generated after [`Event::PaymentSent`] and thus useful for scoring channels. See - /// [`Event::PaymentSent`] for obtaining the payment preimage. - PaymentPathSuccessful { - /// The `payment_id` passed to [`ChannelManager::send_payment`]. - /// - /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment - payment_id: crate::c_types::ThirtyTwoBytes, - /// The hash that was given to [`ChannelManager::send_payment`]. - /// - /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment - /// - /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None - payment_hash: crate::c_types::ThirtyTwoBytes, - /// The payment path that was successful. - /// - /// May contain a closed channel if the HTLC sent along the path was fulfilled on chain. - path: crate::lightning::routing::router::Path, - }, - /// Indicates an outbound HTLC we sent failed, likely due to an intermediary node being unable to - /// handle the HTLC. - /// - /// Note that this does *not* indicate that all paths for an MPP payment have failed, see - /// [`Event::PaymentFailed`]. - /// - /// See [`ChannelManager::abandon_payment`] for giving up on this payment before its retries have - /// been exhausted. - /// - /// [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment - PaymentPathFailed { - /// The `payment_id` passed to [`ChannelManager::send_payment`]. - /// - /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment - /// [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment - /// - /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None - payment_id: crate::c_types::ThirtyTwoBytes, - /// The hash that was given to [`ChannelManager::send_payment`]. - /// - /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment - payment_hash: crate::c_types::ThirtyTwoBytes, - /// Indicates the payment was rejected for some reason by the recipient. This implies that - /// the payment has failed, not just the route in question. If this is not set, the payment may - /// be retried via a different route. - payment_failed_permanently: bool, - /// Extra error details based on the failure type. May contain an update that needs to be - /// applied to the [`NetworkGraph`]. - /// - /// [`NetworkGraph`]: crate::routing::gossip::NetworkGraph - failure: crate::lightning::events::PathFailure, - /// The payment path that failed. - path: crate::lightning::routing::router::Path, - /// The channel responsible for the failed payment path. - /// - /// Note that for route hints or for the first hop in a path this may be an SCID alias and - /// may not refer to a channel in the public network graph. These aliases may also collide - /// with channels in the public network graph. - /// - /// If this is `Some`, then the corresponding channel should be avoided when the payment is - /// retried. May be `None` for older [`Event`] serializations. - short_channel_id: crate::c_types::derived::COption_u64Z, - }, - /// Indicates that a probe payment we sent returned successful, i.e., only failed at the destination. - ProbeSuccessful { - /// The id returned by [`ChannelManager::send_probe`]. - /// - /// [`ChannelManager::send_probe`]: crate::ln::channelmanager::ChannelManager::send_probe - payment_id: crate::c_types::ThirtyTwoBytes, - /// The hash generated by [`ChannelManager::send_probe`]. - /// - /// [`ChannelManager::send_probe`]: crate::ln::channelmanager::ChannelManager::send_probe - payment_hash: crate::c_types::ThirtyTwoBytes, - /// The payment path that was successful. - path: crate::lightning::routing::router::Path, - }, - /// Indicates that a probe payment we sent failed at an intermediary node on the path. - ProbeFailed { - /// The id returned by [`ChannelManager::send_probe`]. - /// - /// [`ChannelManager::send_probe`]: crate::ln::channelmanager::ChannelManager::send_probe - payment_id: crate::c_types::ThirtyTwoBytes, - /// The hash generated by [`ChannelManager::send_probe`]. - /// - /// [`ChannelManager::send_probe`]: crate::ln::channelmanager::ChannelManager::send_probe - payment_hash: crate::c_types::ThirtyTwoBytes, - /// The payment path that failed. - path: crate::lightning::routing::router::Path, - /// The channel responsible for the failed probe. - /// - /// Note that for route hints or for the first hop in a path this may be an SCID alias and - /// may not refer to a channel in the public network graph. These aliases may also collide - /// with channels in the public network graph. - short_channel_id: crate::c_types::derived::COption_u64Z, - }, - /// Used to indicate that [`ChannelManager::process_pending_htlc_forwards`] should be called at - /// a time in the future. - /// - /// [`ChannelManager::process_pending_htlc_forwards`]: crate::ln::channelmanager::ChannelManager::process_pending_htlc_forwards - PendingHTLCsForwardable { - /// The minimum amount of time that should be waited prior to calling - /// process_pending_htlc_forwards. To increase the effort required to correlate payments, - /// you should wait a random amount of time in roughly the range (now + time_forwardable, - /// now + 5*time_forwardable). - time_forwardable: u64, - }, - /// Used to indicate that we've intercepted an HTLC forward. This event will only be generated if - /// you've encoded an intercept scid in the receiver's invoice route hints using - /// [`ChannelManager::get_intercept_scid`] and have set [`UserConfig::accept_intercept_htlcs`]. - /// - /// [`ChannelManager::forward_intercepted_htlc`] or - /// [`ChannelManager::fail_intercepted_htlc`] MUST be called in response to this event. See - /// their docs for more information. - /// - /// [`ChannelManager::get_intercept_scid`]: crate::ln::channelmanager::ChannelManager::get_intercept_scid - /// [`UserConfig::accept_intercept_htlcs`]: crate::util::config::UserConfig::accept_intercept_htlcs - /// [`ChannelManager::forward_intercepted_htlc`]: crate::ln::channelmanager::ChannelManager::forward_intercepted_htlc - /// [`ChannelManager::fail_intercepted_htlc`]: crate::ln::channelmanager::ChannelManager::fail_intercepted_htlc - HTLCIntercepted { - /// An id to help LDK identify which HTLC is being forwarded or failed. - intercept_id: crate::c_types::ThirtyTwoBytes, - /// The fake scid that was programmed as the next hop's scid, generated using - /// [`ChannelManager::get_intercept_scid`]. - /// - /// [`ChannelManager::get_intercept_scid`]: crate::ln::channelmanager::ChannelManager::get_intercept_scid - requested_next_hop_scid: u64, - /// The payment hash used for this HTLC. - payment_hash: crate::c_types::ThirtyTwoBytes, - /// How many msats were received on the inbound edge of this HTLC. - inbound_amount_msat: u64, - /// How many msats the payer intended to route to the next node. Depending on the reason you are - /// intercepting this payment, you might take a fee by forwarding less than this amount. - /// - /// Note that LDK will NOT check that expected fees were factored into this value. You MUST - /// check that whatever fee you want has been included here or subtract it as required. Further, - /// LDK will not stop you from forwarding more than you received. - expected_outbound_amount_msat: u64, - }, - /// Used to indicate that an output which you should know how to spend was confirmed on chain - /// and is now spendable. - /// Such an output will *not* ever be spent by rust-lightning, and are not at risk of your - /// counterparty spending them due to some kind of timeout. Thus, you need to store them - /// somewhere and spend them when you create on-chain transactions. - SpendableOutputs { - /// The outputs which you should store as spendable by you. - outputs: crate::c_types::derived::CVec_SpendableOutputDescriptorZ, - }, - /// This event is generated when a payment has been successfully forwarded through us and a - /// forwarding fee earned. - PaymentForwarded { - /// The incoming channel between the previous node and us. This is only `None` for events - /// generated or serialized by versions prior to 0.0.107. - /// - /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None - prev_channel_id: crate::c_types::ThirtyTwoBytes, - /// The outgoing channel between the next node and us. This is only `None` for events - /// generated or serialized by versions prior to 0.0.107. - /// - /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None - next_channel_id: crate::c_types::ThirtyTwoBytes, - /// The fee, in milli-satoshis, which was earned as a result of the payment. - /// - /// Note that if we force-closed the channel over which we forwarded an HTLC while the HTLC - /// was pending, the amount the next hop claimed will have been rounded down to the nearest - /// whole satoshi. Thus, the fee calculated here may be higher than expected as we still - /// claimed the full value in millisatoshis from the source. In this case, - /// `claim_from_onchain_tx` will be set. - /// - /// If the channel which sent us the payment has been force-closed, we will claim the funds - /// via an on-chain transaction. In that case we do not yet know the on-chain transaction - /// fees which we will spend and will instead set this to `None`. It is possible duplicate - /// `PaymentForwarded` events are generated for the same payment iff `fee_earned_msat` is - /// `None`. - fee_earned_msat: crate::c_types::derived::COption_u64Z, - /// If this is `true`, the forwarded HTLC was claimed by our counterparty via an on-chain - /// transaction. - claim_from_onchain_tx: bool, - /// The final amount forwarded, in milli-satoshis, after the fee is deducted. - /// - /// The caveat described above the `fee_earned_msat` field applies here as well. - outbound_amount_forwarded_msat: crate::c_types::derived::COption_u64Z, - }, - /// Used to indicate that a channel with the given `channel_id` is being opened and pending - /// confirmation on-chain. - /// - /// This event is emitted when the funding transaction has been signed and is broadcast to the - /// network. For 0conf channels it will be immediately followed by the corresponding - /// [`Event::ChannelReady`] event. - ChannelPending { - /// The `channel_id` of the channel that is pending confirmation. - channel_id: crate::c_types::ThirtyTwoBytes, - /// The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound - /// channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if - /// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise - /// `user_channel_id` will be randomized for an inbound channel. - /// - /// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel - /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel - /// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels - user_channel_id: crate::c_types::U128, - /// The `temporary_channel_id` this channel used to be known by during channel establishment. - /// - /// Will be `None` for channels created prior to LDK version 0.0.115. - /// - /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None - former_temporary_channel_id: crate::c_types::ThirtyTwoBytes, - /// The `node_id` of the channel counterparty. - counterparty_node_id: crate::c_types::PublicKey, - /// The outpoint of the channel's funding transaction. - funding_txo: crate::lightning::chain::transaction::OutPoint, - }, - /// Used to indicate that a channel with the given `channel_id` is ready to - /// be used. This event is emitted either when the funding transaction has been confirmed - /// on-chain, or, in case of a 0conf channel, when both parties have confirmed the channel - /// establishment. - ChannelReady { - /// The `channel_id` of the channel that is ready. - channel_id: crate::c_types::ThirtyTwoBytes, - /// The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound - /// channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if - /// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise - /// `user_channel_id` will be randomized for an inbound channel. - /// - /// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel - /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel - /// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels - user_channel_id: crate::c_types::U128, - /// The `node_id` of the channel counterparty. - counterparty_node_id: crate::c_types::PublicKey, - /// The features that this channel will operate with. - channel_type: crate::lightning::ln::features::ChannelTypeFeatures, - }, - /// Used to indicate that a previously opened channel with the given `channel_id` is in the - /// process of closure. - ChannelClosed { - /// The `channel_id` of the channel which has been closed. Note that on-chain transactions - /// resolving the channel are likely still awaiting confirmation. - channel_id: crate::c_types::ThirtyTwoBytes, - /// The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound - /// channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if - /// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise - /// `user_channel_id` will be randomized for inbound channels. - /// This may be zero for inbound channels serialized prior to 0.0.113 and will always be - /// zero for objects serialized with LDK versions prior to 0.0.102. - /// - /// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel - /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel - /// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels - user_channel_id: crate::c_types::U128, - /// The reason the channel was closed. - reason: crate::lightning::events::ClosureReason, - }, - /// Used to indicate to the user that they can abandon the funding transaction and recycle the - /// inputs for another purpose. - DiscardFunding { - /// The channel_id of the channel which has been closed. - channel_id: crate::c_types::ThirtyTwoBytes, - /// The full transaction received from the user - transaction: crate::c_types::Transaction, - }, - /// Indicates a request to open a new channel by a peer. - /// - /// To accept the request, call [`ChannelManager::accept_inbound_channel`]. To reject the - /// request, call [`ChannelManager::force_close_without_broadcasting_txn`]. - /// - /// The event is only triggered when a new open channel request is received and the - /// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. - /// - /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel - /// [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn - /// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels - OpenChannelRequest { - /// The temporary channel ID of the channel requested to be opened. - /// - /// When responding to the request, the `temporary_channel_id` should be passed - /// back to the ChannelManager through [`ChannelManager::accept_inbound_channel`] to accept, - /// or through [`ChannelManager::force_close_without_broadcasting_txn`] to reject. - /// - /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel - /// [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn - temporary_channel_id: crate::c_types::ThirtyTwoBytes, - /// The node_id of the counterparty requesting to open the channel. - /// - /// When responding to the request, the `counterparty_node_id` should be passed - /// back to the `ChannelManager` through [`ChannelManager::accept_inbound_channel`] to - /// accept the request, or through [`ChannelManager::force_close_without_broadcasting_txn`] to reject the - /// request. - /// - /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel - /// [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn - counterparty_node_id: crate::c_types::PublicKey, - /// The channel value of the requested channel. - funding_satoshis: u64, - /// Our starting balance in the channel if the request is accepted, in milli-satoshi. - push_msat: u64, - /// The features that this channel will operate with. If you reject the channel, a - /// well-behaved counterparty may automatically re-attempt the channel with a new set of - /// feature flags. - /// - /// Note that if [`ChannelTypeFeatures::supports_scid_privacy`] returns true on this type, - /// the resulting [`ChannelManager`] will not be readable by versions of LDK prior to - /// 0.0.106. - /// - /// Furthermore, note that if [`ChannelTypeFeatures::supports_zero_conf`] returns true on this type, - /// the resulting [`ChannelManager`] will not be readable by versions of LDK prior to - /// 0.0.107. Channels setting this type also need to get manually accepted via - /// [`crate::ln::channelmanager::ChannelManager::accept_inbound_channel_from_trusted_peer_0conf`], - /// or will be rejected otherwise. - /// - /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager - channel_type: crate::lightning::ln::features::ChannelTypeFeatures, - }, - /// Indicates that the HTLC was accepted, but could not be processed when or after attempting to - /// forward it. - /// - /// Some scenarios where this event may be sent include: - /// * Insufficient capacity in the outbound channel - /// * While waiting to forward the HTLC, the channel it is meant to be forwarded through closes - /// * When an unknown SCID is requested for forwarding a payment. - /// * Expected MPP amount has already been reached - /// * The HTLC has timed out - /// - /// This event, however, does not get generated if an HTLC fails to meet the forwarding - /// requirements (i.e. insufficient fees paid, or a CLTV that is too soon). - HTLCHandlingFailed { - /// The channel over which the HTLC was received. - prev_channel_id: crate::c_types::ThirtyTwoBytes, - /// Destination of the HTLC that failed to be processed. - failed_next_destination: crate::lightning::events::HTLCDestination, - }, -} -use lightning::events::Event as EventImport; -pub(crate) type nativeEvent = EventImport; - -impl Event { - #[allow(unused)] - pub(crate) fn to_native(&self) -> nativeEvent { - match self { - Event::FundingGenerationReady {ref temporary_channel_id, ref counterparty_node_id, ref channel_value_satoshis, ref output_script, ref user_channel_id, } => { - let mut temporary_channel_id_nonref = Clone::clone(temporary_channel_id); - let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id); - let mut channel_value_satoshis_nonref = Clone::clone(channel_value_satoshis); - let mut output_script_nonref = Clone::clone(output_script); - let mut user_channel_id_nonref = Clone::clone(user_channel_id); - nativeEvent::FundingGenerationReady { - temporary_channel_id: temporary_channel_id_nonref.data, - counterparty_node_id: counterparty_node_id_nonref.into_rust(), - channel_value_satoshis: channel_value_satoshis_nonref, - output_script: ::bitcoin::blockdata::script::Script::from(output_script_nonref.into_rust()), - user_channel_id: user_channel_id_nonref.into(), - } - }, - Event::PaymentClaimable {ref receiver_node_id, ref payment_hash, ref onion_fields, ref amount_msat, ref purpose, ref via_channel_id, ref via_user_channel_id, ref claim_deadline, } => { - let mut receiver_node_id_nonref = Clone::clone(receiver_node_id); - let mut local_receiver_node_id_nonref = if receiver_node_id_nonref.is_null() { None } else { Some( { receiver_node_id_nonref.into_rust() }) }; - let mut payment_hash_nonref = Clone::clone(payment_hash); - let mut onion_fields_nonref = Clone::clone(onion_fields); - let mut local_onion_fields_nonref = if onion_fields_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(onion_fields_nonref.take_inner()) } }) }; - let mut amount_msat_nonref = Clone::clone(amount_msat); - let mut purpose_nonref = Clone::clone(purpose); - let mut via_channel_id_nonref = Clone::clone(via_channel_id); - let mut local_via_channel_id_nonref = if via_channel_id_nonref.data == [0; 32] { None } else { Some( { via_channel_id_nonref.data }) }; - let mut via_user_channel_id_nonref = Clone::clone(via_user_channel_id); - let mut local_via_user_channel_id_nonref = { /*via_user_channel_id_nonref*/ let via_user_channel_id_nonref_opt = via_user_channel_id_nonref; if via_user_channel_id_nonref_opt.is_none() { None } else { Some({ { { via_user_channel_id_nonref_opt.take() }.into() }})} }; - let mut claim_deadline_nonref = Clone::clone(claim_deadline); - let mut local_claim_deadline_nonref = if claim_deadline_nonref.is_some() { Some( { claim_deadline_nonref.take() }) } else { None }; - nativeEvent::PaymentClaimable { - receiver_node_id: local_receiver_node_id_nonref, - payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data), - onion_fields: local_onion_fields_nonref, - amount_msat: amount_msat_nonref, - purpose: purpose_nonref.into_native(), - via_channel_id: local_via_channel_id_nonref, - via_user_channel_id: local_via_user_channel_id_nonref, - claim_deadline: local_claim_deadline_nonref, - } - }, - Event::PaymentClaimed {ref receiver_node_id, ref payment_hash, ref amount_msat, ref purpose, } => { - let mut receiver_node_id_nonref = Clone::clone(receiver_node_id); - let mut local_receiver_node_id_nonref = if receiver_node_id_nonref.is_null() { None } else { Some( { receiver_node_id_nonref.into_rust() }) }; - let mut payment_hash_nonref = Clone::clone(payment_hash); - let mut amount_msat_nonref = Clone::clone(amount_msat); - let mut purpose_nonref = Clone::clone(purpose); - nativeEvent::PaymentClaimed { - receiver_node_id: local_receiver_node_id_nonref, - payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data), - amount_msat: amount_msat_nonref, - purpose: purpose_nonref.into_native(), - } - }, - Event::PaymentSent {ref payment_id, ref payment_preimage, ref payment_hash, ref fee_paid_msat, } => { - let mut payment_id_nonref = Clone::clone(payment_id); - let mut local_payment_id_nonref = if payment_id_nonref.data == [0; 32] { None } else { Some( { ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data) }) }; - let mut payment_preimage_nonref = Clone::clone(payment_preimage); - let mut payment_hash_nonref = Clone::clone(payment_hash); - let mut fee_paid_msat_nonref = Clone::clone(fee_paid_msat); - let mut local_fee_paid_msat_nonref = if fee_paid_msat_nonref.is_some() { Some( { fee_paid_msat_nonref.take() }) } else { None }; - nativeEvent::PaymentSent { - payment_id: local_payment_id_nonref, - payment_preimage: ::lightning::ln::PaymentPreimage(payment_preimage_nonref.data), - payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data), - fee_paid_msat: local_fee_paid_msat_nonref, - } - }, - Event::PaymentFailed {ref payment_id, ref payment_hash, ref reason, } => { - let mut payment_id_nonref = Clone::clone(payment_id); - let mut payment_hash_nonref = Clone::clone(payment_hash); - let mut reason_nonref = Clone::clone(reason); - let mut local_reason_nonref = { /*reason_nonref*/ let reason_nonref_opt = reason_nonref; if reason_nonref_opt.is_none() { None } else { Some({ { { reason_nonref_opt.take() }.into_native() }})} }; - nativeEvent::PaymentFailed { - payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data), - payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data), - reason: local_reason_nonref, - } - }, - Event::PaymentPathSuccessful {ref payment_id, ref payment_hash, ref path, } => { - let mut payment_id_nonref = Clone::clone(payment_id); - let mut payment_hash_nonref = Clone::clone(payment_hash); - let mut local_payment_hash_nonref = if payment_hash_nonref.data == [0; 32] { None } else { Some( { ::lightning::ln::PaymentHash(payment_hash_nonref.data) }) }; - let mut path_nonref = Clone::clone(path); - nativeEvent::PaymentPathSuccessful { - payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data), - payment_hash: local_payment_hash_nonref, - path: *unsafe { Box::from_raw(path_nonref.take_inner()) }, - } - }, - Event::PaymentPathFailed {ref payment_id, ref payment_hash, ref payment_failed_permanently, ref failure, ref path, ref short_channel_id, } => { - let mut payment_id_nonref = Clone::clone(payment_id); - let mut local_payment_id_nonref = if payment_id_nonref.data == [0; 32] { None } else { Some( { ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data) }) }; - let mut payment_hash_nonref = Clone::clone(payment_hash); - let mut payment_failed_permanently_nonref = Clone::clone(payment_failed_permanently); - let mut failure_nonref = Clone::clone(failure); - let mut path_nonref = Clone::clone(path); - let mut short_channel_id_nonref = Clone::clone(short_channel_id); - let mut local_short_channel_id_nonref = if short_channel_id_nonref.is_some() { Some( { short_channel_id_nonref.take() }) } else { None }; - nativeEvent::PaymentPathFailed { - payment_id: local_payment_id_nonref, - payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data), - payment_failed_permanently: payment_failed_permanently_nonref, - failure: failure_nonref.into_native(), - path: *unsafe { Box::from_raw(path_nonref.take_inner()) }, - short_channel_id: local_short_channel_id_nonref, - } - }, - Event::ProbeSuccessful {ref payment_id, ref payment_hash, ref path, } => { - let mut payment_id_nonref = Clone::clone(payment_id); - let mut payment_hash_nonref = Clone::clone(payment_hash); - let mut path_nonref = Clone::clone(path); - nativeEvent::ProbeSuccessful { - payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data), - payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data), - path: *unsafe { Box::from_raw(path_nonref.take_inner()) }, - } - }, - Event::ProbeFailed {ref payment_id, ref payment_hash, ref path, ref short_channel_id, } => { - let mut payment_id_nonref = Clone::clone(payment_id); - let mut payment_hash_nonref = Clone::clone(payment_hash); - let mut path_nonref = Clone::clone(path); - let mut short_channel_id_nonref = Clone::clone(short_channel_id); - let mut local_short_channel_id_nonref = if short_channel_id_nonref.is_some() { Some( { short_channel_id_nonref.take() }) } else { None }; - nativeEvent::ProbeFailed { - payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data), - payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data), - path: *unsafe { Box::from_raw(path_nonref.take_inner()) }, - short_channel_id: local_short_channel_id_nonref, - } - }, - Event::PendingHTLCsForwardable {ref time_forwardable, } => { - let mut time_forwardable_nonref = Clone::clone(time_forwardable); - nativeEvent::PendingHTLCsForwardable { - time_forwardable: core::time::Duration::from_secs(time_forwardable_nonref), - } - }, - Event::HTLCIntercepted {ref intercept_id, ref requested_next_hop_scid, ref payment_hash, ref inbound_amount_msat, ref expected_outbound_amount_msat, } => { - let mut intercept_id_nonref = Clone::clone(intercept_id); - let mut requested_next_hop_scid_nonref = Clone::clone(requested_next_hop_scid); - let mut payment_hash_nonref = Clone::clone(payment_hash); - let mut inbound_amount_msat_nonref = Clone::clone(inbound_amount_msat); - let mut expected_outbound_amount_msat_nonref = Clone::clone(expected_outbound_amount_msat); - nativeEvent::HTLCIntercepted { - intercept_id: ::lightning::ln::channelmanager::InterceptId(intercept_id_nonref.data), - requested_next_hop_scid: requested_next_hop_scid_nonref, - payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data), - inbound_amount_msat: inbound_amount_msat_nonref, - expected_outbound_amount_msat: expected_outbound_amount_msat_nonref, - } - }, - Event::SpendableOutputs {ref outputs, } => { - let mut outputs_nonref = Clone::clone(outputs); - let mut local_outputs_nonref = Vec::new(); for mut item in outputs_nonref.into_rust().drain(..) { local_outputs_nonref.push( { item.into_native() }); }; - nativeEvent::SpendableOutputs { - outputs: local_outputs_nonref, - } - }, - Event::PaymentForwarded {ref prev_channel_id, ref next_channel_id, ref fee_earned_msat, ref claim_from_onchain_tx, ref outbound_amount_forwarded_msat, } => { - let mut prev_channel_id_nonref = Clone::clone(prev_channel_id); - let mut local_prev_channel_id_nonref = if prev_channel_id_nonref.data == [0; 32] { None } else { Some( { prev_channel_id_nonref.data }) }; - let mut next_channel_id_nonref = Clone::clone(next_channel_id); - let mut local_next_channel_id_nonref = if next_channel_id_nonref.data == [0; 32] { None } else { Some( { next_channel_id_nonref.data }) }; - let mut fee_earned_msat_nonref = Clone::clone(fee_earned_msat); - let mut local_fee_earned_msat_nonref = if fee_earned_msat_nonref.is_some() { Some( { fee_earned_msat_nonref.take() }) } else { None }; - let mut claim_from_onchain_tx_nonref = Clone::clone(claim_from_onchain_tx); - let mut outbound_amount_forwarded_msat_nonref = Clone::clone(outbound_amount_forwarded_msat); - let mut local_outbound_amount_forwarded_msat_nonref = if outbound_amount_forwarded_msat_nonref.is_some() { Some( { outbound_amount_forwarded_msat_nonref.take() }) } else { None }; - nativeEvent::PaymentForwarded { - prev_channel_id: local_prev_channel_id_nonref, - next_channel_id: local_next_channel_id_nonref, - fee_earned_msat: local_fee_earned_msat_nonref, - claim_from_onchain_tx: claim_from_onchain_tx_nonref, - outbound_amount_forwarded_msat: local_outbound_amount_forwarded_msat_nonref, - } - }, - Event::ChannelPending {ref channel_id, ref user_channel_id, ref former_temporary_channel_id, ref counterparty_node_id, ref funding_txo, } => { - let mut channel_id_nonref = Clone::clone(channel_id); - let mut user_channel_id_nonref = Clone::clone(user_channel_id); - let mut former_temporary_channel_id_nonref = Clone::clone(former_temporary_channel_id); - let mut local_former_temporary_channel_id_nonref = if former_temporary_channel_id_nonref.data == [0; 32] { None } else { Some( { former_temporary_channel_id_nonref.data }) }; - let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id); - let mut funding_txo_nonref = Clone::clone(funding_txo); - nativeEvent::ChannelPending { - channel_id: channel_id_nonref.data, - user_channel_id: user_channel_id_nonref.into(), - former_temporary_channel_id: local_former_temporary_channel_id_nonref, - counterparty_node_id: counterparty_node_id_nonref.into_rust(), - funding_txo: crate::c_types::C_to_bitcoin_outpoint(funding_txo_nonref), - } - }, - Event::ChannelReady {ref channel_id, ref user_channel_id, ref counterparty_node_id, ref channel_type, } => { - let mut channel_id_nonref = Clone::clone(channel_id); - let mut user_channel_id_nonref = Clone::clone(user_channel_id); - let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id); - let mut channel_type_nonref = Clone::clone(channel_type); - nativeEvent::ChannelReady { - channel_id: channel_id_nonref.data, - user_channel_id: user_channel_id_nonref.into(), - counterparty_node_id: counterparty_node_id_nonref.into_rust(), - channel_type: *unsafe { Box::from_raw(channel_type_nonref.take_inner()) }, - } - }, - Event::ChannelClosed {ref channel_id, ref user_channel_id, ref reason, } => { - let mut channel_id_nonref = Clone::clone(channel_id); - let mut user_channel_id_nonref = Clone::clone(user_channel_id); - let mut reason_nonref = Clone::clone(reason); - nativeEvent::ChannelClosed { - channel_id: channel_id_nonref.data, - user_channel_id: user_channel_id_nonref.into(), - reason: reason_nonref.into_native(), - } - }, - Event::DiscardFunding {ref channel_id, ref transaction, } => { - let mut channel_id_nonref = Clone::clone(channel_id); - let mut transaction_nonref = Clone::clone(transaction); - nativeEvent::DiscardFunding { - channel_id: channel_id_nonref.data, - transaction: transaction_nonref.into_bitcoin(), - } - }, - Event::OpenChannelRequest {ref temporary_channel_id, ref counterparty_node_id, ref funding_satoshis, ref push_msat, ref channel_type, } => { - let mut temporary_channel_id_nonref = Clone::clone(temporary_channel_id); - let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id); - let mut funding_satoshis_nonref = Clone::clone(funding_satoshis); - let mut push_msat_nonref = Clone::clone(push_msat); - let mut channel_type_nonref = Clone::clone(channel_type); - nativeEvent::OpenChannelRequest { - temporary_channel_id: temporary_channel_id_nonref.data, - counterparty_node_id: counterparty_node_id_nonref.into_rust(), - funding_satoshis: funding_satoshis_nonref, - push_msat: push_msat_nonref, - channel_type: *unsafe { Box::from_raw(channel_type_nonref.take_inner()) }, - } - }, - Event::HTLCHandlingFailed {ref prev_channel_id, ref failed_next_destination, } => { - let mut prev_channel_id_nonref = Clone::clone(prev_channel_id); - let mut failed_next_destination_nonref = Clone::clone(failed_next_destination); - nativeEvent::HTLCHandlingFailed { - prev_channel_id: prev_channel_id_nonref.data, - failed_next_destination: failed_next_destination_nonref.into_native(), - } - }, - } - } - #[allow(unused)] - pub(crate) fn into_native(self) -> nativeEvent { - match self { - Event::FundingGenerationReady {mut temporary_channel_id, mut counterparty_node_id, mut channel_value_satoshis, mut output_script, mut user_channel_id, } => { - nativeEvent::FundingGenerationReady { - temporary_channel_id: temporary_channel_id.data, - counterparty_node_id: counterparty_node_id.into_rust(), - channel_value_satoshis: channel_value_satoshis, - output_script: ::bitcoin::blockdata::script::Script::from(output_script.into_rust()), - user_channel_id: user_channel_id.into(), - } - }, - Event::PaymentClaimable {mut receiver_node_id, mut payment_hash, mut onion_fields, mut amount_msat, mut purpose, mut via_channel_id, mut via_user_channel_id, mut claim_deadline, } => { - let mut local_receiver_node_id = if receiver_node_id.is_null() { None } else { Some( { receiver_node_id.into_rust() }) }; - let mut local_onion_fields = if onion_fields.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(onion_fields.take_inner()) } }) }; - let mut local_via_channel_id = if via_channel_id.data == [0; 32] { None } else { Some( { via_channel_id.data }) }; - let mut local_via_user_channel_id = { /*via_user_channel_id*/ let via_user_channel_id_opt = via_user_channel_id; if via_user_channel_id_opt.is_none() { None } else { Some({ { { via_user_channel_id_opt.take() }.into() }})} }; - let mut local_claim_deadline = if claim_deadline.is_some() { Some( { claim_deadline.take() }) } else { None }; - nativeEvent::PaymentClaimable { - receiver_node_id: local_receiver_node_id, - payment_hash: ::lightning::ln::PaymentHash(payment_hash.data), - onion_fields: local_onion_fields, - amount_msat: amount_msat, - purpose: purpose.into_native(), - via_channel_id: local_via_channel_id, - via_user_channel_id: local_via_user_channel_id, - claim_deadline: local_claim_deadline, - } - }, - Event::PaymentClaimed {mut receiver_node_id, mut payment_hash, mut amount_msat, mut purpose, } => { - let mut local_receiver_node_id = if receiver_node_id.is_null() { None } else { Some( { receiver_node_id.into_rust() }) }; - nativeEvent::PaymentClaimed { - receiver_node_id: local_receiver_node_id, - payment_hash: ::lightning::ln::PaymentHash(payment_hash.data), - amount_msat: amount_msat, - purpose: purpose.into_native(), - } - }, - Event::PaymentSent {mut payment_id, mut payment_preimage, mut payment_hash, mut fee_paid_msat, } => { - let mut local_payment_id = if payment_id.data == [0; 32] { None } else { Some( { ::lightning::ln::channelmanager::PaymentId(payment_id.data) }) }; - let mut local_fee_paid_msat = if fee_paid_msat.is_some() { Some( { fee_paid_msat.take() }) } else { None }; - nativeEvent::PaymentSent { - payment_id: local_payment_id, - payment_preimage: ::lightning::ln::PaymentPreimage(payment_preimage.data), - payment_hash: ::lightning::ln::PaymentHash(payment_hash.data), - fee_paid_msat: local_fee_paid_msat, - } - }, - Event::PaymentFailed {mut payment_id, mut payment_hash, mut reason, } => { - let mut local_reason = { /*reason*/ let reason_opt = reason; if reason_opt.is_none() { None } else { Some({ { { reason_opt.take() }.into_native() }})} }; - nativeEvent::PaymentFailed { - payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id.data), - payment_hash: ::lightning::ln::PaymentHash(payment_hash.data), - reason: local_reason, - } - }, - Event::PaymentPathSuccessful {mut payment_id, mut payment_hash, mut path, } => { - let mut local_payment_hash = if payment_hash.data == [0; 32] { None } else { Some( { ::lightning::ln::PaymentHash(payment_hash.data) }) }; - nativeEvent::PaymentPathSuccessful { - payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id.data), - payment_hash: local_payment_hash, - path: *unsafe { Box::from_raw(path.take_inner()) }, - } - }, - Event::PaymentPathFailed {mut payment_id, mut payment_hash, mut payment_failed_permanently, mut failure, mut path, mut short_channel_id, } => { - let mut local_payment_id = if payment_id.data == [0; 32] { None } else { Some( { ::lightning::ln::channelmanager::PaymentId(payment_id.data) }) }; - let mut local_short_channel_id = if short_channel_id.is_some() { Some( { short_channel_id.take() }) } else { None }; - nativeEvent::PaymentPathFailed { - payment_id: local_payment_id, - payment_hash: ::lightning::ln::PaymentHash(payment_hash.data), - payment_failed_permanently: payment_failed_permanently, - failure: failure.into_native(), - path: *unsafe { Box::from_raw(path.take_inner()) }, - short_channel_id: local_short_channel_id, - } - }, - Event::ProbeSuccessful {mut payment_id, mut payment_hash, mut path, } => { - nativeEvent::ProbeSuccessful { - payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id.data), - payment_hash: ::lightning::ln::PaymentHash(payment_hash.data), - path: *unsafe { Box::from_raw(path.take_inner()) }, - } - }, - Event::ProbeFailed {mut payment_id, mut payment_hash, mut path, mut short_channel_id, } => { - let mut local_short_channel_id = if short_channel_id.is_some() { Some( { short_channel_id.take() }) } else { None }; - nativeEvent::ProbeFailed { - payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id.data), - payment_hash: ::lightning::ln::PaymentHash(payment_hash.data), - path: *unsafe { Box::from_raw(path.take_inner()) }, - short_channel_id: local_short_channel_id, - } - }, - Event::PendingHTLCsForwardable {mut time_forwardable, } => { - nativeEvent::PendingHTLCsForwardable { - time_forwardable: core::time::Duration::from_secs(time_forwardable), - } - }, - Event::HTLCIntercepted {mut intercept_id, mut requested_next_hop_scid, mut payment_hash, mut inbound_amount_msat, mut expected_outbound_amount_msat, } => { - nativeEvent::HTLCIntercepted { - intercept_id: ::lightning::ln::channelmanager::InterceptId(intercept_id.data), - requested_next_hop_scid: requested_next_hop_scid, - payment_hash: ::lightning::ln::PaymentHash(payment_hash.data), - inbound_amount_msat: inbound_amount_msat, - expected_outbound_amount_msat: expected_outbound_amount_msat, - } - }, - Event::SpendableOutputs {mut outputs, } => { - let mut local_outputs = Vec::new(); for mut item in outputs.into_rust().drain(..) { local_outputs.push( { item.into_native() }); }; - nativeEvent::SpendableOutputs { - outputs: local_outputs, - } - }, - Event::PaymentForwarded {mut prev_channel_id, mut next_channel_id, mut fee_earned_msat, mut claim_from_onchain_tx, mut outbound_amount_forwarded_msat, } => { - let mut local_prev_channel_id = if prev_channel_id.data == [0; 32] { None } else { Some( { prev_channel_id.data }) }; - let mut local_next_channel_id = if next_channel_id.data == [0; 32] { None } else { Some( { next_channel_id.data }) }; - let mut local_fee_earned_msat = if fee_earned_msat.is_some() { Some( { fee_earned_msat.take() }) } else { None }; - let mut local_outbound_amount_forwarded_msat = if outbound_amount_forwarded_msat.is_some() { Some( { outbound_amount_forwarded_msat.take() }) } else { None }; - nativeEvent::PaymentForwarded { - prev_channel_id: local_prev_channel_id, - next_channel_id: local_next_channel_id, - fee_earned_msat: local_fee_earned_msat, - claim_from_onchain_tx: claim_from_onchain_tx, - outbound_amount_forwarded_msat: local_outbound_amount_forwarded_msat, - } - }, - Event::ChannelPending {mut channel_id, mut user_channel_id, mut former_temporary_channel_id, mut counterparty_node_id, mut funding_txo, } => { - let mut local_former_temporary_channel_id = if former_temporary_channel_id.data == [0; 32] { None } else { Some( { former_temporary_channel_id.data }) }; - nativeEvent::ChannelPending { - channel_id: channel_id.data, - user_channel_id: user_channel_id.into(), - former_temporary_channel_id: local_former_temporary_channel_id, - counterparty_node_id: counterparty_node_id.into_rust(), - funding_txo: crate::c_types::C_to_bitcoin_outpoint(funding_txo), - } - }, - Event::ChannelReady {mut channel_id, mut user_channel_id, mut counterparty_node_id, mut channel_type, } => { - nativeEvent::ChannelReady { - channel_id: channel_id.data, - user_channel_id: user_channel_id.into(), - counterparty_node_id: counterparty_node_id.into_rust(), - channel_type: *unsafe { Box::from_raw(channel_type.take_inner()) }, - } - }, - Event::ChannelClosed {mut channel_id, mut user_channel_id, mut reason, } => { - nativeEvent::ChannelClosed { - channel_id: channel_id.data, - user_channel_id: user_channel_id.into(), - reason: reason.into_native(), - } - }, - Event::DiscardFunding {mut channel_id, mut transaction, } => { - nativeEvent::DiscardFunding { - channel_id: channel_id.data, - transaction: transaction.into_bitcoin(), - } - }, - Event::OpenChannelRequest {mut temporary_channel_id, mut counterparty_node_id, mut funding_satoshis, mut push_msat, mut channel_type, } => { - nativeEvent::OpenChannelRequest { - temporary_channel_id: temporary_channel_id.data, - counterparty_node_id: counterparty_node_id.into_rust(), - funding_satoshis: funding_satoshis, - push_msat: push_msat, - channel_type: *unsafe { Box::from_raw(channel_type.take_inner()) }, - } - }, - Event::HTLCHandlingFailed {mut prev_channel_id, mut failed_next_destination, } => { - nativeEvent::HTLCHandlingFailed { - prev_channel_id: prev_channel_id.data, - failed_next_destination: failed_next_destination.into_native(), - } - }, - } - } - #[allow(unused)] - pub(crate) fn from_native(native: &nativeEvent) -> Self { - match native { - nativeEvent::FundingGenerationReady {ref temporary_channel_id, ref counterparty_node_id, ref channel_value_satoshis, ref output_script, ref user_channel_id, } => { - let mut temporary_channel_id_nonref = Clone::clone(temporary_channel_id); - let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id); - let mut channel_value_satoshis_nonref = Clone::clone(channel_value_satoshis); - let mut output_script_nonref = Clone::clone(output_script); - let mut user_channel_id_nonref = Clone::clone(user_channel_id); - Event::FundingGenerationReady { - temporary_channel_id: crate::c_types::ThirtyTwoBytes { data: temporary_channel_id_nonref }, - counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id_nonref), - channel_value_satoshis: channel_value_satoshis_nonref, - output_script: output_script_nonref.into_bytes().into(), - user_channel_id: user_channel_id_nonref.into(), - } - }, - nativeEvent::PaymentClaimable {ref receiver_node_id, ref payment_hash, ref onion_fields, ref amount_msat, ref purpose, ref via_channel_id, ref via_user_channel_id, ref claim_deadline, } => { - let mut receiver_node_id_nonref = Clone::clone(receiver_node_id); - let mut local_receiver_node_id_nonref = if receiver_node_id_nonref.is_none() { crate::c_types::PublicKey::null() } else { { crate::c_types::PublicKey::from_rust(&(receiver_node_id_nonref.unwrap())) } }; - let mut payment_hash_nonref = Clone::clone(payment_hash); - let mut onion_fields_nonref = Clone::clone(onion_fields); - let mut local_onion_fields_nonref = crate::lightning::ln::outbound_payment::RecipientOnionFields { inner: if onion_fields_nonref.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((onion_fields_nonref.unwrap())) } }, is_owned: true }; - let mut amount_msat_nonref = Clone::clone(amount_msat); - let mut purpose_nonref = Clone::clone(purpose); - let mut via_channel_id_nonref = Clone::clone(via_channel_id); - let mut local_via_channel_id_nonref = if via_channel_id_nonref.is_none() { crate::c_types::ThirtyTwoBytes { data: [0; 32] } } else { { crate::c_types::ThirtyTwoBytes { data: (via_channel_id_nonref.unwrap()) } } }; - let mut via_user_channel_id_nonref = Clone::clone(via_user_channel_id); - let mut local_via_user_channel_id_nonref = if via_user_channel_id_nonref.is_none() { crate::c_types::derived::COption_u128Z::None } else { crate::c_types::derived::COption_u128Z::Some( { via_user_channel_id_nonref.unwrap().into() }) }; - let mut claim_deadline_nonref = Clone::clone(claim_deadline); - let mut local_claim_deadline_nonref = if claim_deadline_nonref.is_none() { crate::c_types::derived::COption_u32Z::None } else { crate::c_types::derived::COption_u32Z::Some( { claim_deadline_nonref.unwrap() }) }; - Event::PaymentClaimable { - receiver_node_id: local_receiver_node_id_nonref, - payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 }, - onion_fields: local_onion_fields_nonref, - amount_msat: amount_msat_nonref, - purpose: crate::lightning::events::PaymentPurpose::native_into(purpose_nonref), - via_channel_id: local_via_channel_id_nonref, - via_user_channel_id: local_via_user_channel_id_nonref, - claim_deadline: local_claim_deadline_nonref, - } - }, - nativeEvent::PaymentClaimed {ref receiver_node_id, ref payment_hash, ref amount_msat, ref purpose, } => { - let mut receiver_node_id_nonref = Clone::clone(receiver_node_id); - let mut local_receiver_node_id_nonref = if receiver_node_id_nonref.is_none() { crate::c_types::PublicKey::null() } else { { crate::c_types::PublicKey::from_rust(&(receiver_node_id_nonref.unwrap())) } }; - let mut payment_hash_nonref = Clone::clone(payment_hash); - let mut amount_msat_nonref = Clone::clone(amount_msat); - let mut purpose_nonref = Clone::clone(purpose); - Event::PaymentClaimed { - receiver_node_id: local_receiver_node_id_nonref, - payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 }, - amount_msat: amount_msat_nonref, - purpose: crate::lightning::events::PaymentPurpose::native_into(purpose_nonref), - } - }, - nativeEvent::PaymentSent {ref payment_id, ref payment_preimage, ref payment_hash, ref fee_paid_msat, } => { - let mut payment_id_nonref = Clone::clone(payment_id); - let mut local_payment_id_nonref = if payment_id_nonref.is_none() { crate::c_types::ThirtyTwoBytes::null() } else { { crate::c_types::ThirtyTwoBytes { data: (payment_id_nonref.unwrap()).0 } } }; - let mut payment_preimage_nonref = Clone::clone(payment_preimage); - let mut payment_hash_nonref = Clone::clone(payment_hash); - let mut fee_paid_msat_nonref = Clone::clone(fee_paid_msat); - let mut local_fee_paid_msat_nonref = if fee_paid_msat_nonref.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { fee_paid_msat_nonref.unwrap() }) }; - Event::PaymentSent { - payment_id: local_payment_id_nonref, - payment_preimage: crate::c_types::ThirtyTwoBytes { data: payment_preimage_nonref.0 }, - payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 }, - fee_paid_msat: local_fee_paid_msat_nonref, - } - }, - nativeEvent::PaymentFailed {ref payment_id, ref payment_hash, ref reason, } => { - let mut payment_id_nonref = Clone::clone(payment_id); - let mut payment_hash_nonref = Clone::clone(payment_hash); - let mut reason_nonref = Clone::clone(reason); - let mut local_reason_nonref = if reason_nonref.is_none() { crate::c_types::derived::COption_PaymentFailureReasonZ::None } else { crate::c_types::derived::COption_PaymentFailureReasonZ::Some( { crate::lightning::events::PaymentFailureReason::native_into(reason_nonref.unwrap()) }) }; - Event::PaymentFailed { - payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id_nonref.0 }, - payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 }, - reason: local_reason_nonref, - } - }, - nativeEvent::PaymentPathSuccessful {ref payment_id, ref payment_hash, ref path, } => { - let mut payment_id_nonref = Clone::clone(payment_id); - let mut payment_hash_nonref = Clone::clone(payment_hash); - let mut local_payment_hash_nonref = if payment_hash_nonref.is_none() { crate::c_types::ThirtyTwoBytes::null() } else { { crate::c_types::ThirtyTwoBytes { data: (payment_hash_nonref.unwrap()).0 } } }; - let mut path_nonref = Clone::clone(path); - Event::PaymentPathSuccessful { - payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id_nonref.0 }, - payment_hash: local_payment_hash_nonref, - path: crate::lightning::routing::router::Path { inner: ObjOps::heap_alloc(path_nonref), is_owned: true }, - } - }, - nativeEvent::PaymentPathFailed {ref payment_id, ref payment_hash, ref payment_failed_permanently, ref failure, ref path, ref short_channel_id, } => { - let mut payment_id_nonref = Clone::clone(payment_id); - let mut local_payment_id_nonref = if payment_id_nonref.is_none() { crate::c_types::ThirtyTwoBytes::null() } else { { crate::c_types::ThirtyTwoBytes { data: (payment_id_nonref.unwrap()).0 } } }; - let mut payment_hash_nonref = Clone::clone(payment_hash); - let mut payment_failed_permanently_nonref = Clone::clone(payment_failed_permanently); - let mut failure_nonref = Clone::clone(failure); - let mut path_nonref = Clone::clone(path); - let mut short_channel_id_nonref = Clone::clone(short_channel_id); - let mut local_short_channel_id_nonref = if short_channel_id_nonref.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { short_channel_id_nonref.unwrap() }) }; - Event::PaymentPathFailed { - payment_id: local_payment_id_nonref, - payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 }, - payment_failed_permanently: payment_failed_permanently_nonref, - failure: crate::lightning::events::PathFailure::native_into(failure_nonref), - path: crate::lightning::routing::router::Path { inner: ObjOps::heap_alloc(path_nonref), is_owned: true }, - short_channel_id: local_short_channel_id_nonref, - } - }, - nativeEvent::ProbeSuccessful {ref payment_id, ref payment_hash, ref path, } => { - let mut payment_id_nonref = Clone::clone(payment_id); - let mut payment_hash_nonref = Clone::clone(payment_hash); - let mut path_nonref = Clone::clone(path); - Event::ProbeSuccessful { - payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id_nonref.0 }, - payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 }, - path: crate::lightning::routing::router::Path { inner: ObjOps::heap_alloc(path_nonref), is_owned: true }, - } - }, - nativeEvent::ProbeFailed {ref payment_id, ref payment_hash, ref path, ref short_channel_id, } => { - let mut payment_id_nonref = Clone::clone(payment_id); - let mut payment_hash_nonref = Clone::clone(payment_hash); - let mut path_nonref = Clone::clone(path); - let mut short_channel_id_nonref = Clone::clone(short_channel_id); - let mut local_short_channel_id_nonref = if short_channel_id_nonref.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { short_channel_id_nonref.unwrap() }) }; - Event::ProbeFailed { - payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id_nonref.0 }, - payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 }, - path: crate::lightning::routing::router::Path { inner: ObjOps::heap_alloc(path_nonref), is_owned: true }, - short_channel_id: local_short_channel_id_nonref, - } - }, - nativeEvent::PendingHTLCsForwardable {ref time_forwardable, } => { - let mut time_forwardable_nonref = Clone::clone(time_forwardable); - Event::PendingHTLCsForwardable { - time_forwardable: time_forwardable_nonref.as_secs(), - } - }, - nativeEvent::HTLCIntercepted {ref intercept_id, ref requested_next_hop_scid, ref payment_hash, ref inbound_amount_msat, ref expected_outbound_amount_msat, } => { - let mut intercept_id_nonref = Clone::clone(intercept_id); - let mut requested_next_hop_scid_nonref = Clone::clone(requested_next_hop_scid); - let mut payment_hash_nonref = Clone::clone(payment_hash); - let mut inbound_amount_msat_nonref = Clone::clone(inbound_amount_msat); - let mut expected_outbound_amount_msat_nonref = Clone::clone(expected_outbound_amount_msat); - Event::HTLCIntercepted { - intercept_id: crate::c_types::ThirtyTwoBytes { data: intercept_id_nonref.0 }, - requested_next_hop_scid: requested_next_hop_scid_nonref, - payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 }, - inbound_amount_msat: inbound_amount_msat_nonref, - expected_outbound_amount_msat: expected_outbound_amount_msat_nonref, - } - }, - nativeEvent::SpendableOutputs {ref outputs, } => { - let mut outputs_nonref = Clone::clone(outputs); - let mut local_outputs_nonref = Vec::new(); for mut item in outputs_nonref.drain(..) { local_outputs_nonref.push( { crate::lightning::chain::keysinterface::SpendableOutputDescriptor::native_into(item) }); }; - Event::SpendableOutputs { - outputs: local_outputs_nonref.into(), - } - }, - nativeEvent::PaymentForwarded {ref prev_channel_id, ref next_channel_id, ref fee_earned_msat, ref claim_from_onchain_tx, ref outbound_amount_forwarded_msat, } => { - let mut prev_channel_id_nonref = Clone::clone(prev_channel_id); - let mut local_prev_channel_id_nonref = if prev_channel_id_nonref.is_none() { crate::c_types::ThirtyTwoBytes { data: [0; 32] } } else { { crate::c_types::ThirtyTwoBytes { data: (prev_channel_id_nonref.unwrap()) } } }; - let mut next_channel_id_nonref = Clone::clone(next_channel_id); - let mut local_next_channel_id_nonref = if next_channel_id_nonref.is_none() { crate::c_types::ThirtyTwoBytes { data: [0; 32] } } else { { crate::c_types::ThirtyTwoBytes { data: (next_channel_id_nonref.unwrap()) } } }; - let mut fee_earned_msat_nonref = Clone::clone(fee_earned_msat); - let mut local_fee_earned_msat_nonref = if fee_earned_msat_nonref.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { fee_earned_msat_nonref.unwrap() }) }; - let mut claim_from_onchain_tx_nonref = Clone::clone(claim_from_onchain_tx); - let mut outbound_amount_forwarded_msat_nonref = Clone::clone(outbound_amount_forwarded_msat); - let mut local_outbound_amount_forwarded_msat_nonref = if outbound_amount_forwarded_msat_nonref.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { outbound_amount_forwarded_msat_nonref.unwrap() }) }; - Event::PaymentForwarded { - prev_channel_id: local_prev_channel_id_nonref, - next_channel_id: local_next_channel_id_nonref, - fee_earned_msat: local_fee_earned_msat_nonref, - claim_from_onchain_tx: claim_from_onchain_tx_nonref, - outbound_amount_forwarded_msat: local_outbound_amount_forwarded_msat_nonref, - } - }, - nativeEvent::ChannelPending {ref channel_id, ref user_channel_id, ref former_temporary_channel_id, ref counterparty_node_id, ref funding_txo, } => { - let mut channel_id_nonref = Clone::clone(channel_id); - let mut user_channel_id_nonref = Clone::clone(user_channel_id); - let mut former_temporary_channel_id_nonref = Clone::clone(former_temporary_channel_id); - let mut local_former_temporary_channel_id_nonref = if former_temporary_channel_id_nonref.is_none() { crate::c_types::ThirtyTwoBytes { data: [0; 32] } } else { { crate::c_types::ThirtyTwoBytes { data: (former_temporary_channel_id_nonref.unwrap()) } } }; - let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id); - let mut funding_txo_nonref = Clone::clone(funding_txo); - Event::ChannelPending { - channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id_nonref }, - user_channel_id: user_channel_id_nonref.into(), - former_temporary_channel_id: local_former_temporary_channel_id_nonref, - counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id_nonref), - funding_txo: crate::c_types::bitcoin_to_C_outpoint(funding_txo_nonref), - } - }, - nativeEvent::ChannelReady {ref channel_id, ref user_channel_id, ref counterparty_node_id, ref channel_type, } => { - let mut channel_id_nonref = Clone::clone(channel_id); - let mut user_channel_id_nonref = Clone::clone(user_channel_id); - let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id); - let mut channel_type_nonref = Clone::clone(channel_type); - Event::ChannelReady { - channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id_nonref }, - user_channel_id: user_channel_id_nonref.into(), - counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id_nonref), - channel_type: crate::lightning::ln::features::ChannelTypeFeatures { inner: ObjOps::heap_alloc(channel_type_nonref), is_owned: true }, - } - }, - nativeEvent::ChannelClosed {ref channel_id, ref user_channel_id, ref reason, } => { - let mut channel_id_nonref = Clone::clone(channel_id); - let mut user_channel_id_nonref = Clone::clone(user_channel_id); - let mut reason_nonref = Clone::clone(reason); - Event::ChannelClosed { - channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id_nonref }, - user_channel_id: user_channel_id_nonref.into(), - reason: crate::lightning::events::ClosureReason::native_into(reason_nonref), - } - }, - nativeEvent::DiscardFunding {ref channel_id, ref transaction, } => { - let mut channel_id_nonref = Clone::clone(channel_id); - let mut transaction_nonref = Clone::clone(transaction); - Event::DiscardFunding { - channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id_nonref }, - transaction: crate::c_types::Transaction::from_bitcoin(&transaction_nonref), - } - }, - nativeEvent::OpenChannelRequest {ref temporary_channel_id, ref counterparty_node_id, ref funding_satoshis, ref push_msat, ref channel_type, } => { - let mut temporary_channel_id_nonref = Clone::clone(temporary_channel_id); - let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id); - let mut funding_satoshis_nonref = Clone::clone(funding_satoshis); - let mut push_msat_nonref = Clone::clone(push_msat); - let mut channel_type_nonref = Clone::clone(channel_type); - Event::OpenChannelRequest { - temporary_channel_id: crate::c_types::ThirtyTwoBytes { data: temporary_channel_id_nonref }, - counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id_nonref), - funding_satoshis: funding_satoshis_nonref, - push_msat: push_msat_nonref, - channel_type: crate::lightning::ln::features::ChannelTypeFeatures { inner: ObjOps::heap_alloc(channel_type_nonref), is_owned: true }, - } - }, - nativeEvent::HTLCHandlingFailed {ref prev_channel_id, ref failed_next_destination, } => { - let mut prev_channel_id_nonref = Clone::clone(prev_channel_id); - let mut failed_next_destination_nonref = Clone::clone(failed_next_destination); - Event::HTLCHandlingFailed { - prev_channel_id: crate::c_types::ThirtyTwoBytes { data: prev_channel_id_nonref }, - failed_next_destination: crate::lightning::events::HTLCDestination::native_into(failed_next_destination_nonref), - } - }, - } - } - #[allow(unused)] - pub(crate) fn native_into(native: nativeEvent) -> Self { - match native { - nativeEvent::FundingGenerationReady {mut temporary_channel_id, mut counterparty_node_id, mut channel_value_satoshis, mut output_script, mut user_channel_id, } => { - Event::FundingGenerationReady { - temporary_channel_id: crate::c_types::ThirtyTwoBytes { data: temporary_channel_id }, - counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id), - channel_value_satoshis: channel_value_satoshis, - output_script: output_script.into_bytes().into(), - user_channel_id: user_channel_id.into(), - } - }, - nativeEvent::PaymentClaimable {mut receiver_node_id, mut payment_hash, mut onion_fields, mut amount_msat, mut purpose, mut via_channel_id, mut via_user_channel_id, mut claim_deadline, } => { - let mut local_receiver_node_id = if receiver_node_id.is_none() { crate::c_types::PublicKey::null() } else { { crate::c_types::PublicKey::from_rust(&(receiver_node_id.unwrap())) } }; - let mut local_onion_fields = crate::lightning::ln::outbound_payment::RecipientOnionFields { inner: if onion_fields.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((onion_fields.unwrap())) } }, is_owned: true }; - let mut local_via_channel_id = if via_channel_id.is_none() { crate::c_types::ThirtyTwoBytes { data: [0; 32] } } else { { crate::c_types::ThirtyTwoBytes { data: (via_channel_id.unwrap()) } } }; - let mut local_via_user_channel_id = if via_user_channel_id.is_none() { crate::c_types::derived::COption_u128Z::None } else { crate::c_types::derived::COption_u128Z::Some( { via_user_channel_id.unwrap().into() }) }; - let mut local_claim_deadline = if claim_deadline.is_none() { crate::c_types::derived::COption_u32Z::None } else { crate::c_types::derived::COption_u32Z::Some( { claim_deadline.unwrap() }) }; - Event::PaymentClaimable { - receiver_node_id: local_receiver_node_id, - payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 }, - onion_fields: local_onion_fields, - amount_msat: amount_msat, - purpose: crate::lightning::events::PaymentPurpose::native_into(purpose), - via_channel_id: local_via_channel_id, - via_user_channel_id: local_via_user_channel_id, - claim_deadline: local_claim_deadline, - } - }, - nativeEvent::PaymentClaimed {mut receiver_node_id, mut payment_hash, mut amount_msat, mut purpose, } => { - let mut local_receiver_node_id = if receiver_node_id.is_none() { crate::c_types::PublicKey::null() } else { { crate::c_types::PublicKey::from_rust(&(receiver_node_id.unwrap())) } }; - Event::PaymentClaimed { - receiver_node_id: local_receiver_node_id, - payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 }, - amount_msat: amount_msat, - purpose: crate::lightning::events::PaymentPurpose::native_into(purpose), - } - }, - nativeEvent::PaymentSent {mut payment_id, mut payment_preimage, mut payment_hash, mut fee_paid_msat, } => { - let mut local_payment_id = if payment_id.is_none() { crate::c_types::ThirtyTwoBytes::null() } else { { crate::c_types::ThirtyTwoBytes { data: (payment_id.unwrap()).0 } } }; - let mut local_fee_paid_msat = if fee_paid_msat.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { fee_paid_msat.unwrap() }) }; - Event::PaymentSent { - payment_id: local_payment_id, - payment_preimage: crate::c_types::ThirtyTwoBytes { data: payment_preimage.0 }, - payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 }, - fee_paid_msat: local_fee_paid_msat, - } - }, - nativeEvent::PaymentFailed {mut payment_id, mut payment_hash, mut reason, } => { - let mut local_reason = if reason.is_none() { crate::c_types::derived::COption_PaymentFailureReasonZ::None } else { crate::c_types::derived::COption_PaymentFailureReasonZ::Some( { crate::lightning::events::PaymentFailureReason::native_into(reason.unwrap()) }) }; - Event::PaymentFailed { - payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id.0 }, - payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 }, - reason: local_reason, - } - }, - nativeEvent::PaymentPathSuccessful {mut payment_id, mut payment_hash, mut path, } => { - let mut local_payment_hash = if payment_hash.is_none() { crate::c_types::ThirtyTwoBytes::null() } else { { crate::c_types::ThirtyTwoBytes { data: (payment_hash.unwrap()).0 } } }; - Event::PaymentPathSuccessful { - payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id.0 }, - payment_hash: local_payment_hash, - path: crate::lightning::routing::router::Path { inner: ObjOps::heap_alloc(path), is_owned: true }, - } - }, - nativeEvent::PaymentPathFailed {mut payment_id, mut payment_hash, mut payment_failed_permanently, mut failure, mut path, mut short_channel_id, } => { - let mut local_payment_id = if payment_id.is_none() { crate::c_types::ThirtyTwoBytes::null() } else { { crate::c_types::ThirtyTwoBytes { data: (payment_id.unwrap()).0 } } }; - let mut local_short_channel_id = if short_channel_id.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { short_channel_id.unwrap() }) }; - Event::PaymentPathFailed { - payment_id: local_payment_id, - payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 }, - payment_failed_permanently: payment_failed_permanently, - failure: crate::lightning::events::PathFailure::native_into(failure), - path: crate::lightning::routing::router::Path { inner: ObjOps::heap_alloc(path), is_owned: true }, - short_channel_id: local_short_channel_id, - } - }, - nativeEvent::ProbeSuccessful {mut payment_id, mut payment_hash, mut path, } => { - Event::ProbeSuccessful { - payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id.0 }, - payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 }, - path: crate::lightning::routing::router::Path { inner: ObjOps::heap_alloc(path), is_owned: true }, - } - }, - nativeEvent::ProbeFailed {mut payment_id, mut payment_hash, mut path, mut short_channel_id, } => { - let mut local_short_channel_id = if short_channel_id.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { short_channel_id.unwrap() }) }; - Event::ProbeFailed { - payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id.0 }, - payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 }, - path: crate::lightning::routing::router::Path { inner: ObjOps::heap_alloc(path), is_owned: true }, - short_channel_id: local_short_channel_id, - } - }, - nativeEvent::PendingHTLCsForwardable {mut time_forwardable, } => { - Event::PendingHTLCsForwardable { - time_forwardable: time_forwardable.as_secs(), - } - }, - nativeEvent::HTLCIntercepted {mut intercept_id, mut requested_next_hop_scid, mut payment_hash, mut inbound_amount_msat, mut expected_outbound_amount_msat, } => { - Event::HTLCIntercepted { - intercept_id: crate::c_types::ThirtyTwoBytes { data: intercept_id.0 }, - requested_next_hop_scid: requested_next_hop_scid, - payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 }, - inbound_amount_msat: inbound_amount_msat, - expected_outbound_amount_msat: expected_outbound_amount_msat, - } - }, - nativeEvent::SpendableOutputs {mut outputs, } => { - let mut local_outputs = Vec::new(); for mut item in outputs.drain(..) { local_outputs.push( { crate::lightning::chain::keysinterface::SpendableOutputDescriptor::native_into(item) }); }; - Event::SpendableOutputs { - outputs: local_outputs.into(), - } - }, - nativeEvent::PaymentForwarded {mut prev_channel_id, mut next_channel_id, mut fee_earned_msat, mut claim_from_onchain_tx, mut outbound_amount_forwarded_msat, } => { - let mut local_prev_channel_id = if prev_channel_id.is_none() { crate::c_types::ThirtyTwoBytes { data: [0; 32] } } else { { crate::c_types::ThirtyTwoBytes { data: (prev_channel_id.unwrap()) } } }; - let mut local_next_channel_id = if next_channel_id.is_none() { crate::c_types::ThirtyTwoBytes { data: [0; 32] } } else { { crate::c_types::ThirtyTwoBytes { data: (next_channel_id.unwrap()) } } }; - let mut local_fee_earned_msat = if fee_earned_msat.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { fee_earned_msat.unwrap() }) }; - let mut local_outbound_amount_forwarded_msat = if outbound_amount_forwarded_msat.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { outbound_amount_forwarded_msat.unwrap() }) }; - Event::PaymentForwarded { - prev_channel_id: local_prev_channel_id, - next_channel_id: local_next_channel_id, - fee_earned_msat: local_fee_earned_msat, - claim_from_onchain_tx: claim_from_onchain_tx, - outbound_amount_forwarded_msat: local_outbound_amount_forwarded_msat, - } - }, - nativeEvent::ChannelPending {mut channel_id, mut user_channel_id, mut former_temporary_channel_id, mut counterparty_node_id, mut funding_txo, } => { - let mut local_former_temporary_channel_id = if former_temporary_channel_id.is_none() { crate::c_types::ThirtyTwoBytes { data: [0; 32] } } else { { crate::c_types::ThirtyTwoBytes { data: (former_temporary_channel_id.unwrap()) } } }; - Event::ChannelPending { - channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id }, - user_channel_id: user_channel_id.into(), - former_temporary_channel_id: local_former_temporary_channel_id, - counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id), - funding_txo: crate::c_types::bitcoin_to_C_outpoint(funding_txo), - } - }, - nativeEvent::ChannelReady {mut channel_id, mut user_channel_id, mut counterparty_node_id, mut channel_type, } => { - Event::ChannelReady { - channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id }, - user_channel_id: user_channel_id.into(), - counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id), - channel_type: crate::lightning::ln::features::ChannelTypeFeatures { inner: ObjOps::heap_alloc(channel_type), is_owned: true }, - } - }, - nativeEvent::ChannelClosed {mut channel_id, mut user_channel_id, mut reason, } => { - Event::ChannelClosed { - channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id }, - user_channel_id: user_channel_id.into(), - reason: crate::lightning::events::ClosureReason::native_into(reason), - } - }, - nativeEvent::DiscardFunding {mut channel_id, mut transaction, } => { - Event::DiscardFunding { - channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id }, - transaction: crate::c_types::Transaction::from_bitcoin(&transaction), - } - }, - nativeEvent::OpenChannelRequest {mut temporary_channel_id, mut counterparty_node_id, mut funding_satoshis, mut push_msat, mut channel_type, } => { - Event::OpenChannelRequest { - temporary_channel_id: crate::c_types::ThirtyTwoBytes { data: temporary_channel_id }, - counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id), - funding_satoshis: funding_satoshis, - push_msat: push_msat, - channel_type: crate::lightning::ln::features::ChannelTypeFeatures { inner: ObjOps::heap_alloc(channel_type), is_owned: true }, - } - }, - nativeEvent::HTLCHandlingFailed {mut prev_channel_id, mut failed_next_destination, } => { - Event::HTLCHandlingFailed { - prev_channel_id: crate::c_types::ThirtyTwoBytes { data: prev_channel_id }, - failed_next_destination: crate::lightning::events::HTLCDestination::native_into(failed_next_destination), - } - }, - } - } -} -/// Frees any resources used by the Event -#[no_mangle] -pub extern "C" fn Event_free(this_ptr: Event) { } -/// Creates a copy of the Event -#[no_mangle] -pub extern "C" fn Event_clone(orig: &Event) -> Event { - orig.clone() -} -#[no_mangle] -/// Utility method to constructs a new FundingGenerationReady-variant Event -pub extern "C" fn Event_funding_generation_ready(temporary_channel_id: crate::c_types::ThirtyTwoBytes, counterparty_node_id: crate::c_types::PublicKey, channel_value_satoshis: u64, output_script: crate::c_types::derived::CVec_u8Z, user_channel_id: crate::c_types::U128) -> Event { - Event::FundingGenerationReady { - temporary_channel_id, - counterparty_node_id, - channel_value_satoshis, - output_script, - user_channel_id, - } -} -#[no_mangle] -/// Utility method to constructs a new PaymentClaimable-variant Event -pub extern "C" fn Event_payment_claimable(receiver_node_id: crate::c_types::PublicKey, payment_hash: crate::c_types::ThirtyTwoBytes, onion_fields: crate::lightning::ln::outbound_payment::RecipientOnionFields, amount_msat: u64, purpose: crate::lightning::events::PaymentPurpose, via_channel_id: crate::c_types::ThirtyTwoBytes, via_user_channel_id: crate::c_types::derived::COption_u128Z, claim_deadline: crate::c_types::derived::COption_u32Z) -> Event { - Event::PaymentClaimable { - receiver_node_id, - payment_hash, - onion_fields, - amount_msat, - purpose, - via_channel_id, - via_user_channel_id, - claim_deadline, - } -} -#[no_mangle] -/// Utility method to constructs a new PaymentClaimed-variant Event -pub extern "C" fn Event_payment_claimed(receiver_node_id: crate::c_types::PublicKey, payment_hash: crate::c_types::ThirtyTwoBytes, amount_msat: u64, purpose: crate::lightning::events::PaymentPurpose) -> Event { - Event::PaymentClaimed { - receiver_node_id, - payment_hash, - amount_msat, - purpose, - } -} -#[no_mangle] -/// Utility method to constructs a new PaymentSent-variant Event -pub extern "C" fn Event_payment_sent(payment_id: crate::c_types::ThirtyTwoBytes, payment_preimage: crate::c_types::ThirtyTwoBytes, payment_hash: crate::c_types::ThirtyTwoBytes, fee_paid_msat: crate::c_types::derived::COption_u64Z) -> Event { - Event::PaymentSent { - payment_id, - payment_preimage, - payment_hash, - fee_paid_msat, - } -} -#[no_mangle] -/// Utility method to constructs a new PaymentFailed-variant Event -pub extern "C" fn Event_payment_failed(payment_id: crate::c_types::ThirtyTwoBytes, payment_hash: crate::c_types::ThirtyTwoBytes, reason: crate::c_types::derived::COption_PaymentFailureReasonZ) -> Event { - Event::PaymentFailed { - payment_id, - payment_hash, - reason, - } -} -#[no_mangle] -/// Utility method to constructs a new PaymentPathSuccessful-variant Event -pub extern "C" fn Event_payment_path_successful(payment_id: crate::c_types::ThirtyTwoBytes, payment_hash: crate::c_types::ThirtyTwoBytes, path: crate::lightning::routing::router::Path) -> Event { - Event::PaymentPathSuccessful { - payment_id, - payment_hash, - path, - } -} -#[no_mangle] -/// Utility method to constructs a new PaymentPathFailed-variant Event -pub extern "C" fn Event_payment_path_failed(payment_id: crate::c_types::ThirtyTwoBytes, payment_hash: crate::c_types::ThirtyTwoBytes, payment_failed_permanently: bool, failure: crate::lightning::events::PathFailure, path: crate::lightning::routing::router::Path, short_channel_id: crate::c_types::derived::COption_u64Z) -> Event { - Event::PaymentPathFailed { - payment_id, - payment_hash, - payment_failed_permanently, - failure, - path, - short_channel_id, - } -} -#[no_mangle] -/// Utility method to constructs a new ProbeSuccessful-variant Event -pub extern "C" fn Event_probe_successful(payment_id: crate::c_types::ThirtyTwoBytes, payment_hash: crate::c_types::ThirtyTwoBytes, path: crate::lightning::routing::router::Path) -> Event { - Event::ProbeSuccessful { - payment_id, - payment_hash, - path, - } -} -#[no_mangle] -/// Utility method to constructs a new ProbeFailed-variant Event -pub extern "C" fn Event_probe_failed(payment_id: crate::c_types::ThirtyTwoBytes, payment_hash: crate::c_types::ThirtyTwoBytes, path: crate::lightning::routing::router::Path, short_channel_id: crate::c_types::derived::COption_u64Z) -> Event { - Event::ProbeFailed { - payment_id, - payment_hash, - path, - short_channel_id, - } -} -#[no_mangle] -/// Utility method to constructs a new PendingHTLCsForwardable-variant Event -pub extern "C" fn Event_pending_htlcs_forwardable(time_forwardable: u64) -> Event { - Event::PendingHTLCsForwardable { - time_forwardable, - } -} -#[no_mangle] -/// Utility method to constructs a new HTLCIntercepted-variant Event -pub extern "C" fn Event_htlcintercepted(intercept_id: crate::c_types::ThirtyTwoBytes, requested_next_hop_scid: u64, payment_hash: crate::c_types::ThirtyTwoBytes, inbound_amount_msat: u64, expected_outbound_amount_msat: u64) -> Event { - Event::HTLCIntercepted { - intercept_id, - requested_next_hop_scid, - payment_hash, - inbound_amount_msat, - expected_outbound_amount_msat, - } -} -#[no_mangle] -/// Utility method to constructs a new SpendableOutputs-variant Event -pub extern "C" fn Event_spendable_outputs(outputs: crate::c_types::derived::CVec_SpendableOutputDescriptorZ) -> Event { - Event::SpendableOutputs { - outputs, - } -} -#[no_mangle] -/// Utility method to constructs a new PaymentForwarded-variant Event -pub extern "C" fn Event_payment_forwarded(prev_channel_id: crate::c_types::ThirtyTwoBytes, next_channel_id: crate::c_types::ThirtyTwoBytes, fee_earned_msat: crate::c_types::derived::COption_u64Z, claim_from_onchain_tx: bool, outbound_amount_forwarded_msat: crate::c_types::derived::COption_u64Z) -> Event { - Event::PaymentForwarded { - prev_channel_id, - next_channel_id, - fee_earned_msat, - claim_from_onchain_tx, - outbound_amount_forwarded_msat, - } -} -#[no_mangle] -/// Utility method to constructs a new ChannelPending-variant Event -pub extern "C" fn Event_channel_pending(channel_id: crate::c_types::ThirtyTwoBytes, user_channel_id: crate::c_types::U128, former_temporary_channel_id: crate::c_types::ThirtyTwoBytes, counterparty_node_id: crate::c_types::PublicKey, funding_txo: crate::lightning::chain::transaction::OutPoint) -> Event { - Event::ChannelPending { - channel_id, - user_channel_id, - former_temporary_channel_id, - counterparty_node_id, - funding_txo, - } -} -#[no_mangle] -/// Utility method to constructs a new ChannelReady-variant Event -pub extern "C" fn Event_channel_ready(channel_id: crate::c_types::ThirtyTwoBytes, user_channel_id: crate::c_types::U128, counterparty_node_id: crate::c_types::PublicKey, channel_type: crate::lightning::ln::features::ChannelTypeFeatures) -> Event { - Event::ChannelReady { - channel_id, - user_channel_id, - counterparty_node_id, - channel_type, - } -} -#[no_mangle] -/// Utility method to constructs a new ChannelClosed-variant Event -pub extern "C" fn Event_channel_closed(channel_id: crate::c_types::ThirtyTwoBytes, user_channel_id: crate::c_types::U128, reason: crate::lightning::events::ClosureReason) -> Event { - Event::ChannelClosed { - channel_id, - user_channel_id, - reason, - } -} -#[no_mangle] -/// Utility method to constructs a new DiscardFunding-variant Event -pub extern "C" fn Event_discard_funding(channel_id: crate::c_types::ThirtyTwoBytes, transaction: crate::c_types::Transaction) -> Event { - Event::DiscardFunding { - channel_id, - transaction, - } -} -#[no_mangle] -/// Utility method to constructs a new OpenChannelRequest-variant Event -pub extern "C" fn Event_open_channel_request(temporary_channel_id: crate::c_types::ThirtyTwoBytes, counterparty_node_id: crate::c_types::PublicKey, funding_satoshis: u64, push_msat: u64, channel_type: crate::lightning::ln::features::ChannelTypeFeatures) -> Event { - Event::OpenChannelRequest { - temporary_channel_id, - counterparty_node_id, - funding_satoshis, - push_msat, - channel_type, - } -} -#[no_mangle] -/// Utility method to constructs a new HTLCHandlingFailed-variant Event -pub extern "C" fn Event_htlchandling_failed(prev_channel_id: crate::c_types::ThirtyTwoBytes, failed_next_destination: crate::lightning::events::HTLCDestination) -> Event { - Event::HTLCHandlingFailed { - prev_channel_id, - failed_next_destination, - } -} -/// Checks if two Events contain equal inner contents. -/// This ignores pointers and is_owned flags and looks at the values in fields. -#[no_mangle] -pub extern "C" fn Event_eq(a: &Event, b: &Event) -> bool { - if &a.to_native() == &b.to_native() { true } else { false } -} -#[no_mangle] -/// Serialize the Event object into a byte array which can be read by Event_read -pub extern "C" fn Event_write(obj: &crate::lightning::events::Event) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(&unsafe { &*obj }.to_native()) -} -#[no_mangle] -/// Read a Event from a byte array, created by Event_write -pub extern "C" fn Event_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_COption_EventZDecodeErrorZ { - let res: Result, lightning::ln::msgs::DecodeError> = crate::c_types::maybe_deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_res_0 = if o.is_none() { crate::c_types::derived::COption_EventZ::None } else { crate::c_types::derived::COption_EventZ::Some( { crate::lightning::events::Event::native_into(o.unwrap()) }) }; local_res_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; - local_res -} -/// An event generated by ChannelManager which indicates a message should be sent to a peer (or -/// broadcast to most peers). -/// These events are handled by PeerManager::process_events if you are using a PeerManager. -#[derive(Clone)] -#[must_use] -#[repr(C)] -pub enum MessageSendEvent { - /// Used to indicate that we've accepted a channel open and should send the accept_channel - /// message provided to the given peer. - SendAcceptChannel { - /// The node_id of the node which should receive this message - node_id: crate::c_types::PublicKey, - /// The message which should be sent. - msg: crate::lightning::ln::msgs::AcceptChannel, - }, - /// Used to indicate that we've initiated a channel open and should send the open_channel - /// message provided to the given peer. - SendOpenChannel { - /// The node_id of the node which should receive this message - node_id: crate::c_types::PublicKey, - /// The message which should be sent. - msg: crate::lightning::ln::msgs::OpenChannel, - }, - /// Used to indicate that a funding_created message should be sent to the peer with the given node_id. - SendFundingCreated { - /// The node_id of the node which should receive this message - node_id: crate::c_types::PublicKey, - /// The message which should be sent. - msg: crate::lightning::ln::msgs::FundingCreated, - }, - /// Used to indicate that a funding_signed message should be sent to the peer with the given node_id. - SendFundingSigned { - /// The node_id of the node which should receive this message - node_id: crate::c_types::PublicKey, - /// The message which should be sent. - msg: crate::lightning::ln::msgs::FundingSigned, - }, - /// Used to indicate that a channel_ready message should be sent to the peer with the given node_id. - SendChannelReady { - /// The node_id of the node which should receive these message(s) - node_id: crate::c_types::PublicKey, - /// The channel_ready message which should be sent. - msg: crate::lightning::ln::msgs::ChannelReady, - }, - /// Used to indicate that an announcement_signatures message should be sent to the peer with the given node_id. - SendAnnouncementSignatures { - /// The node_id of the node which should receive these message(s) - node_id: crate::c_types::PublicKey, - /// The announcement_signatures message which should be sent. - msg: crate::lightning::ln::msgs::AnnouncementSignatures, - }, - /// Used to indicate that a series of HTLC update messages, as well as a commitment_signed - /// message should be sent to the peer with the given node_id. - UpdateHTLCs { - /// The node_id of the node which should receive these message(s) - node_id: crate::c_types::PublicKey, - /// The update messages which should be sent. ALL messages in the struct should be sent! - updates: crate::lightning::ln::msgs::CommitmentUpdate, - }, - /// Used to indicate that a revoke_and_ack message should be sent to the peer with the given node_id. - SendRevokeAndACK { - /// The node_id of the node which should receive this message - node_id: crate::c_types::PublicKey, - /// The message which should be sent. - msg: crate::lightning::ln::msgs::RevokeAndACK, - }, - /// Used to indicate that a closing_signed message should be sent to the peer with the given node_id. - SendClosingSigned { - /// The node_id of the node which should receive this message - node_id: crate::c_types::PublicKey, - /// The message which should be sent. - msg: crate::lightning::ln::msgs::ClosingSigned, - }, - /// Used to indicate that a shutdown message should be sent to the peer with the given node_id. - SendShutdown { - /// The node_id of the node which should receive this message - node_id: crate::c_types::PublicKey, - /// The message which should be sent. - msg: crate::lightning::ln::msgs::Shutdown, - }, - /// Used to indicate that a channel_reestablish message should be sent to the peer with the given node_id. - SendChannelReestablish { - /// The node_id of the node which should receive this message - node_id: crate::c_types::PublicKey, - /// The message which should be sent. - msg: crate::lightning::ln::msgs::ChannelReestablish, - }, - /// Used to send a channel_announcement and channel_update to a specific peer, likely on - /// initial connection to ensure our peers know about our channels. - SendChannelAnnouncement { - /// The node_id of the node which should receive this message - node_id: crate::c_types::PublicKey, - /// The channel_announcement which should be sent. - msg: crate::lightning::ln::msgs::ChannelAnnouncement, - /// The followup channel_update which should be sent. - update_msg: crate::lightning::ln::msgs::ChannelUpdate, - }, - /// Used to indicate that a channel_announcement and channel_update should be broadcast to all - /// peers (except the peer with node_id either msg.contents.node_id_1 or msg.contents.node_id_2). - /// - /// Note that after doing so, you very likely (unless you did so very recently) want to - /// broadcast a node_announcement (e.g. via [`PeerManager::broadcast_node_announcement`]). This - /// ensures that any nodes which see our channel_announcement also have a relevant - /// node_announcement, including relevant feature flags which may be important for routing - /// through or to us. - /// - /// [`PeerManager::broadcast_node_announcement`]: crate::ln::peer_handler::PeerManager::broadcast_node_announcement - BroadcastChannelAnnouncement { - /// The channel_announcement which should be sent. - msg: crate::lightning::ln::msgs::ChannelAnnouncement, - /// The followup channel_update which should be sent. - /// - /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None - update_msg: crate::lightning::ln::msgs::ChannelUpdate, - }, - /// Used to indicate that a channel_update should be broadcast to all peers. - BroadcastChannelUpdate { - /// The channel_update which should be sent. - msg: crate::lightning::ln::msgs::ChannelUpdate, - }, - /// Used to indicate that a node_announcement should be broadcast to all peers. - BroadcastNodeAnnouncement { - /// The node_announcement which should be sent. - msg: crate::lightning::ln::msgs::NodeAnnouncement, - }, - /// Used to indicate that a channel_update should be sent to a single peer. - /// In contrast to [`Self::BroadcastChannelUpdate`], this is used when the channel is a - /// private channel and we shouldn't be informing all of our peers of channel parameters. - SendChannelUpdate { - /// The node_id of the node which should receive this message - node_id: crate::c_types::PublicKey, - /// The channel_update which should be sent. - msg: crate::lightning::ln::msgs::ChannelUpdate, - }, - /// Broadcast an error downstream to be handled - HandleError { - /// The node_id of the node which should receive this message - node_id: crate::c_types::PublicKey, - /// The action which should be taken. - action: crate::lightning::ln::msgs::ErrorAction, - }, - /// Query a peer for channels with funding transaction UTXOs in a block range. - SendChannelRangeQuery { - /// The node_id of this message recipient - node_id: crate::c_types::PublicKey, - /// The query_channel_range which should be sent. - msg: crate::lightning::ln::msgs::QueryChannelRange, - }, - /// Request routing gossip messages from a peer for a list of channels identified by - /// their short_channel_ids. - SendShortIdsQuery { - /// The node_id of this message recipient - node_id: crate::c_types::PublicKey, - /// The query_short_channel_ids which should be sent. - msg: crate::lightning::ln::msgs::QueryShortChannelIds, - }, - /// Sends a reply to a channel range query. This may be one of several SendReplyChannelRange events - /// emitted during processing of the query. - SendReplyChannelRange { - /// The node_id of this message recipient - node_id: crate::c_types::PublicKey, - /// The reply_channel_range which should be sent. - msg: crate::lightning::ln::msgs::ReplyChannelRange, - }, - /// Sends a timestamp filter for inbound gossip. This should be sent on each new connection to - /// enable receiving gossip messages from the peer. - SendGossipTimestampFilter { - /// The node_id of this message recipient - node_id: crate::c_types::PublicKey, - /// The gossip_timestamp_filter which should be sent. - msg: crate::lightning::ln::msgs::GossipTimestampFilter, - }, -} -use lightning::events::MessageSendEvent as MessageSendEventImport; -pub(crate) type nativeMessageSendEvent = MessageSendEventImport; - -impl MessageSendEvent { - #[allow(unused)] - pub(crate) fn to_native(&self) -> nativeMessageSendEvent { - match self { - MessageSendEvent::SendAcceptChannel {ref node_id, ref msg, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut msg_nonref = Clone::clone(msg); - nativeMessageSendEvent::SendAcceptChannel { - node_id: node_id_nonref.into_rust(), - msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, - } - }, - MessageSendEvent::SendOpenChannel {ref node_id, ref msg, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut msg_nonref = Clone::clone(msg); - nativeMessageSendEvent::SendOpenChannel { - node_id: node_id_nonref.into_rust(), - msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, - } - }, - MessageSendEvent::SendFundingCreated {ref node_id, ref msg, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut msg_nonref = Clone::clone(msg); - nativeMessageSendEvent::SendFundingCreated { - node_id: node_id_nonref.into_rust(), - msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, - } - }, - MessageSendEvent::SendFundingSigned {ref node_id, ref msg, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut msg_nonref = Clone::clone(msg); - nativeMessageSendEvent::SendFundingSigned { - node_id: node_id_nonref.into_rust(), - msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, - } - }, - MessageSendEvent::SendChannelReady {ref node_id, ref msg, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut msg_nonref = Clone::clone(msg); - nativeMessageSendEvent::SendChannelReady { - node_id: node_id_nonref.into_rust(), - msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, - } - }, - MessageSendEvent::SendAnnouncementSignatures {ref node_id, ref msg, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut msg_nonref = Clone::clone(msg); - nativeMessageSendEvent::SendAnnouncementSignatures { - node_id: node_id_nonref.into_rust(), - msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, - } - }, - MessageSendEvent::UpdateHTLCs {ref node_id, ref updates, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut updates_nonref = Clone::clone(updates); - nativeMessageSendEvent::UpdateHTLCs { - node_id: node_id_nonref.into_rust(), - updates: *unsafe { Box::from_raw(updates_nonref.take_inner()) }, - } - }, - MessageSendEvent::SendRevokeAndACK {ref node_id, ref msg, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut msg_nonref = Clone::clone(msg); - nativeMessageSendEvent::SendRevokeAndACK { - node_id: node_id_nonref.into_rust(), - msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, - } - }, - MessageSendEvent::SendClosingSigned {ref node_id, ref msg, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut msg_nonref = Clone::clone(msg); - nativeMessageSendEvent::SendClosingSigned { - node_id: node_id_nonref.into_rust(), - msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, - } - }, - MessageSendEvent::SendShutdown {ref node_id, ref msg, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut msg_nonref = Clone::clone(msg); - nativeMessageSendEvent::SendShutdown { - node_id: node_id_nonref.into_rust(), - msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, - } - }, - MessageSendEvent::SendChannelReestablish {ref node_id, ref msg, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut msg_nonref = Clone::clone(msg); - nativeMessageSendEvent::SendChannelReestablish { - node_id: node_id_nonref.into_rust(), - msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, - } - }, - MessageSendEvent::SendChannelAnnouncement {ref node_id, ref msg, ref update_msg, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut msg_nonref = Clone::clone(msg); - let mut update_msg_nonref = Clone::clone(update_msg); - nativeMessageSendEvent::SendChannelAnnouncement { - node_id: node_id_nonref.into_rust(), - msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, - update_msg: *unsafe { Box::from_raw(update_msg_nonref.take_inner()) }, - } - }, - MessageSendEvent::BroadcastChannelAnnouncement {ref msg, ref update_msg, } => { - let mut msg_nonref = Clone::clone(msg); - let mut update_msg_nonref = Clone::clone(update_msg); - let mut local_update_msg_nonref = if update_msg_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(update_msg_nonref.take_inner()) } }) }; - nativeMessageSendEvent::BroadcastChannelAnnouncement { - msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, - update_msg: local_update_msg_nonref, - } - }, - MessageSendEvent::BroadcastChannelUpdate {ref msg, } => { - let mut msg_nonref = Clone::clone(msg); - nativeMessageSendEvent::BroadcastChannelUpdate { - msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, - } - }, - MessageSendEvent::BroadcastNodeAnnouncement {ref msg, } => { - let mut msg_nonref = Clone::clone(msg); - nativeMessageSendEvent::BroadcastNodeAnnouncement { - msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, - } - }, - MessageSendEvent::SendChannelUpdate {ref node_id, ref msg, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut msg_nonref = Clone::clone(msg); - nativeMessageSendEvent::SendChannelUpdate { - node_id: node_id_nonref.into_rust(), - msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, - } - }, - MessageSendEvent::HandleError {ref node_id, ref action, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut action_nonref = Clone::clone(action); - nativeMessageSendEvent::HandleError { - node_id: node_id_nonref.into_rust(), - action: action_nonref.into_native(), - } - }, - MessageSendEvent::SendChannelRangeQuery {ref node_id, ref msg, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut msg_nonref = Clone::clone(msg); - nativeMessageSendEvent::SendChannelRangeQuery { - node_id: node_id_nonref.into_rust(), - msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, - } - }, - MessageSendEvent::SendShortIdsQuery {ref node_id, ref msg, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut msg_nonref = Clone::clone(msg); - nativeMessageSendEvent::SendShortIdsQuery { - node_id: node_id_nonref.into_rust(), - msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, - } - }, - MessageSendEvent::SendReplyChannelRange {ref node_id, ref msg, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut msg_nonref = Clone::clone(msg); - nativeMessageSendEvent::SendReplyChannelRange { - node_id: node_id_nonref.into_rust(), - msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, - } - }, - MessageSendEvent::SendGossipTimestampFilter {ref node_id, ref msg, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut msg_nonref = Clone::clone(msg); - nativeMessageSendEvent::SendGossipTimestampFilter { - node_id: node_id_nonref.into_rust(), - msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, - } - }, - } - } - #[allow(unused)] - pub(crate) fn into_native(self) -> nativeMessageSendEvent { - match self { - MessageSendEvent::SendAcceptChannel {mut node_id, mut msg, } => { - nativeMessageSendEvent::SendAcceptChannel { - node_id: node_id.into_rust(), - msg: *unsafe { Box::from_raw(msg.take_inner()) }, - } - }, - MessageSendEvent::SendOpenChannel {mut node_id, mut msg, } => { - nativeMessageSendEvent::SendOpenChannel { - node_id: node_id.into_rust(), - msg: *unsafe { Box::from_raw(msg.take_inner()) }, - } - }, - MessageSendEvent::SendFundingCreated {mut node_id, mut msg, } => { - nativeMessageSendEvent::SendFundingCreated { - node_id: node_id.into_rust(), - msg: *unsafe { Box::from_raw(msg.take_inner()) }, - } - }, - MessageSendEvent::SendFundingSigned {mut node_id, mut msg, } => { - nativeMessageSendEvent::SendFundingSigned { - node_id: node_id.into_rust(), - msg: *unsafe { Box::from_raw(msg.take_inner()) }, - } - }, - MessageSendEvent::SendChannelReady {mut node_id, mut msg, } => { - nativeMessageSendEvent::SendChannelReady { - node_id: node_id.into_rust(), - msg: *unsafe { Box::from_raw(msg.take_inner()) }, - } - }, - MessageSendEvent::SendAnnouncementSignatures {mut node_id, mut msg, } => { - nativeMessageSendEvent::SendAnnouncementSignatures { - node_id: node_id.into_rust(), - msg: *unsafe { Box::from_raw(msg.take_inner()) }, - } - }, - MessageSendEvent::UpdateHTLCs {mut node_id, mut updates, } => { - nativeMessageSendEvent::UpdateHTLCs { - node_id: node_id.into_rust(), - updates: *unsafe { Box::from_raw(updates.take_inner()) }, - } - }, - MessageSendEvent::SendRevokeAndACK {mut node_id, mut msg, } => { - nativeMessageSendEvent::SendRevokeAndACK { - node_id: node_id.into_rust(), - msg: *unsafe { Box::from_raw(msg.take_inner()) }, - } - }, - MessageSendEvent::SendClosingSigned {mut node_id, mut msg, } => { - nativeMessageSendEvent::SendClosingSigned { - node_id: node_id.into_rust(), - msg: *unsafe { Box::from_raw(msg.take_inner()) }, - } - }, - MessageSendEvent::SendShutdown {mut node_id, mut msg, } => { - nativeMessageSendEvent::SendShutdown { - node_id: node_id.into_rust(), - msg: *unsafe { Box::from_raw(msg.take_inner()) }, - } - }, - MessageSendEvent::SendChannelReestablish {mut node_id, mut msg, } => { - nativeMessageSendEvent::SendChannelReestablish { - node_id: node_id.into_rust(), - msg: *unsafe { Box::from_raw(msg.take_inner()) }, - } - }, - MessageSendEvent::SendChannelAnnouncement {mut node_id, mut msg, mut update_msg, } => { - nativeMessageSendEvent::SendChannelAnnouncement { - node_id: node_id.into_rust(), - msg: *unsafe { Box::from_raw(msg.take_inner()) }, - update_msg: *unsafe { Box::from_raw(update_msg.take_inner()) }, - } - }, - MessageSendEvent::BroadcastChannelAnnouncement {mut msg, mut update_msg, } => { - let mut local_update_msg = if update_msg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(update_msg.take_inner()) } }) }; - nativeMessageSendEvent::BroadcastChannelAnnouncement { - msg: *unsafe { Box::from_raw(msg.take_inner()) }, - update_msg: local_update_msg, - } - }, - MessageSendEvent::BroadcastChannelUpdate {mut msg, } => { - nativeMessageSendEvent::BroadcastChannelUpdate { - msg: *unsafe { Box::from_raw(msg.take_inner()) }, - } - }, - MessageSendEvent::BroadcastNodeAnnouncement {mut msg, } => { - nativeMessageSendEvent::BroadcastNodeAnnouncement { - msg: *unsafe { Box::from_raw(msg.take_inner()) }, - } - }, - MessageSendEvent::SendChannelUpdate {mut node_id, mut msg, } => { - nativeMessageSendEvent::SendChannelUpdate { - node_id: node_id.into_rust(), - msg: *unsafe { Box::from_raw(msg.take_inner()) }, - } - }, - MessageSendEvent::HandleError {mut node_id, mut action, } => { - nativeMessageSendEvent::HandleError { - node_id: node_id.into_rust(), - action: action.into_native(), - } - }, - MessageSendEvent::SendChannelRangeQuery {mut node_id, mut msg, } => { - nativeMessageSendEvent::SendChannelRangeQuery { - node_id: node_id.into_rust(), - msg: *unsafe { Box::from_raw(msg.take_inner()) }, - } - }, - MessageSendEvent::SendShortIdsQuery {mut node_id, mut msg, } => { - nativeMessageSendEvent::SendShortIdsQuery { - node_id: node_id.into_rust(), - msg: *unsafe { Box::from_raw(msg.take_inner()) }, - } - }, - MessageSendEvent::SendReplyChannelRange {mut node_id, mut msg, } => { - nativeMessageSendEvent::SendReplyChannelRange { - node_id: node_id.into_rust(), - msg: *unsafe { Box::from_raw(msg.take_inner()) }, - } - }, - MessageSendEvent::SendGossipTimestampFilter {mut node_id, mut msg, } => { - nativeMessageSendEvent::SendGossipTimestampFilter { - node_id: node_id.into_rust(), - msg: *unsafe { Box::from_raw(msg.take_inner()) }, - } - }, - } - } - #[allow(unused)] - pub(crate) fn from_native(native: &nativeMessageSendEvent) -> Self { - match native { - nativeMessageSendEvent::SendAcceptChannel {ref node_id, ref msg, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut msg_nonref = Clone::clone(msg); - MessageSendEvent::SendAcceptChannel { - node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), - msg: crate::lightning::ln::msgs::AcceptChannel { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, - } - }, - nativeMessageSendEvent::SendOpenChannel {ref node_id, ref msg, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut msg_nonref = Clone::clone(msg); - MessageSendEvent::SendOpenChannel { - node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), - msg: crate::lightning::ln::msgs::OpenChannel { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, - } - }, - nativeMessageSendEvent::SendFundingCreated {ref node_id, ref msg, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut msg_nonref = Clone::clone(msg); - MessageSendEvent::SendFundingCreated { - node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), - msg: crate::lightning::ln::msgs::FundingCreated { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, - } - }, - nativeMessageSendEvent::SendFundingSigned {ref node_id, ref msg, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut msg_nonref = Clone::clone(msg); - MessageSendEvent::SendFundingSigned { - node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), - msg: crate::lightning::ln::msgs::FundingSigned { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, - } - }, - nativeMessageSendEvent::SendChannelReady {ref node_id, ref msg, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut msg_nonref = Clone::clone(msg); - MessageSendEvent::SendChannelReady { - node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), - msg: crate::lightning::ln::msgs::ChannelReady { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, - } - }, - nativeMessageSendEvent::SendAnnouncementSignatures {ref node_id, ref msg, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut msg_nonref = Clone::clone(msg); - MessageSendEvent::SendAnnouncementSignatures { - node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), - msg: crate::lightning::ln::msgs::AnnouncementSignatures { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, - } - }, - nativeMessageSendEvent::UpdateHTLCs {ref node_id, ref updates, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut updates_nonref = Clone::clone(updates); - MessageSendEvent::UpdateHTLCs { - node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), - updates: crate::lightning::ln::msgs::CommitmentUpdate { inner: ObjOps::heap_alloc(updates_nonref), is_owned: true }, - } - }, - nativeMessageSendEvent::SendRevokeAndACK {ref node_id, ref msg, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut msg_nonref = Clone::clone(msg); - MessageSendEvent::SendRevokeAndACK { - node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), - msg: crate::lightning::ln::msgs::RevokeAndACK { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, - } - }, - nativeMessageSendEvent::SendClosingSigned {ref node_id, ref msg, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut msg_nonref = Clone::clone(msg); - MessageSendEvent::SendClosingSigned { - node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), - msg: crate::lightning::ln::msgs::ClosingSigned { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, - } - }, - nativeMessageSendEvent::SendShutdown {ref node_id, ref msg, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut msg_nonref = Clone::clone(msg); - MessageSendEvent::SendShutdown { - node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), - msg: crate::lightning::ln::msgs::Shutdown { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, - } - }, - nativeMessageSendEvent::SendChannelReestablish {ref node_id, ref msg, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut msg_nonref = Clone::clone(msg); - MessageSendEvent::SendChannelReestablish { - node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), - msg: crate::lightning::ln::msgs::ChannelReestablish { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, - } - }, - nativeMessageSendEvent::SendChannelAnnouncement {ref node_id, ref msg, ref update_msg, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut msg_nonref = Clone::clone(msg); - let mut update_msg_nonref = Clone::clone(update_msg); - MessageSendEvent::SendChannelAnnouncement { - node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), - msg: crate::lightning::ln::msgs::ChannelAnnouncement { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, - update_msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(update_msg_nonref), is_owned: true }, - } - }, - nativeMessageSendEvent::BroadcastChannelAnnouncement {ref msg, ref update_msg, } => { - let mut msg_nonref = Clone::clone(msg); - let mut update_msg_nonref = Clone::clone(update_msg); - let mut local_update_msg_nonref = crate::lightning::ln::msgs::ChannelUpdate { inner: if update_msg_nonref.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((update_msg_nonref.unwrap())) } }, is_owned: true }; - MessageSendEvent::BroadcastChannelAnnouncement { - msg: crate::lightning::ln::msgs::ChannelAnnouncement { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, - update_msg: local_update_msg_nonref, - } - }, - nativeMessageSendEvent::BroadcastChannelUpdate {ref msg, } => { - let mut msg_nonref = Clone::clone(msg); - MessageSendEvent::BroadcastChannelUpdate { - msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, - } - }, - nativeMessageSendEvent::BroadcastNodeAnnouncement {ref msg, } => { - let mut msg_nonref = Clone::clone(msg); - MessageSendEvent::BroadcastNodeAnnouncement { - msg: crate::lightning::ln::msgs::NodeAnnouncement { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, - } - }, - nativeMessageSendEvent::SendChannelUpdate {ref node_id, ref msg, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut msg_nonref = Clone::clone(msg); - MessageSendEvent::SendChannelUpdate { - node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), - msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, - } - }, - nativeMessageSendEvent::HandleError {ref node_id, ref action, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut action_nonref = Clone::clone(action); - MessageSendEvent::HandleError { - node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), - action: crate::lightning::ln::msgs::ErrorAction::native_into(action_nonref), - } - }, - nativeMessageSendEvent::SendChannelRangeQuery {ref node_id, ref msg, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut msg_nonref = Clone::clone(msg); - MessageSendEvent::SendChannelRangeQuery { - node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), - msg: crate::lightning::ln::msgs::QueryChannelRange { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, - } - }, - nativeMessageSendEvent::SendShortIdsQuery {ref node_id, ref msg, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut msg_nonref = Clone::clone(msg); - MessageSendEvent::SendShortIdsQuery { - node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), - msg: crate::lightning::ln::msgs::QueryShortChannelIds { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, - } - }, - nativeMessageSendEvent::SendReplyChannelRange {ref node_id, ref msg, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut msg_nonref = Clone::clone(msg); - MessageSendEvent::SendReplyChannelRange { - node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), - msg: crate::lightning::ln::msgs::ReplyChannelRange { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, - } - }, - nativeMessageSendEvent::SendGossipTimestampFilter {ref node_id, ref msg, } => { - let mut node_id_nonref = Clone::clone(node_id); - let mut msg_nonref = Clone::clone(msg); - MessageSendEvent::SendGossipTimestampFilter { - node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), - msg: crate::lightning::ln::msgs::GossipTimestampFilter { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, - } - }, - } - } - #[allow(unused)] - pub(crate) fn native_into(native: nativeMessageSendEvent) -> Self { - match native { - nativeMessageSendEvent::SendAcceptChannel {mut node_id, mut msg, } => { - MessageSendEvent::SendAcceptChannel { - node_id: crate::c_types::PublicKey::from_rust(&node_id), - msg: crate::lightning::ln::msgs::AcceptChannel { inner: ObjOps::heap_alloc(msg), is_owned: true }, - } - }, - nativeMessageSendEvent::SendOpenChannel {mut node_id, mut msg, } => { - MessageSendEvent::SendOpenChannel { - node_id: crate::c_types::PublicKey::from_rust(&node_id), - msg: crate::lightning::ln::msgs::OpenChannel { inner: ObjOps::heap_alloc(msg), is_owned: true }, - } - }, - nativeMessageSendEvent::SendFundingCreated {mut node_id, mut msg, } => { - MessageSendEvent::SendFundingCreated { - node_id: crate::c_types::PublicKey::from_rust(&node_id), - msg: crate::lightning::ln::msgs::FundingCreated { inner: ObjOps::heap_alloc(msg), is_owned: true }, - } - }, - nativeMessageSendEvent::SendFundingSigned {mut node_id, mut msg, } => { - MessageSendEvent::SendFundingSigned { - node_id: crate::c_types::PublicKey::from_rust(&node_id), - msg: crate::lightning::ln::msgs::FundingSigned { inner: ObjOps::heap_alloc(msg), is_owned: true }, - } - }, - nativeMessageSendEvent::SendChannelReady {mut node_id, mut msg, } => { - MessageSendEvent::SendChannelReady { - node_id: crate::c_types::PublicKey::from_rust(&node_id), - msg: crate::lightning::ln::msgs::ChannelReady { inner: ObjOps::heap_alloc(msg), is_owned: true }, - } - }, - nativeMessageSendEvent::SendAnnouncementSignatures {mut node_id, mut msg, } => { - MessageSendEvent::SendAnnouncementSignatures { - node_id: crate::c_types::PublicKey::from_rust(&node_id), - msg: crate::lightning::ln::msgs::AnnouncementSignatures { inner: ObjOps::heap_alloc(msg), is_owned: true }, - } - }, - nativeMessageSendEvent::UpdateHTLCs {mut node_id, mut updates, } => { - MessageSendEvent::UpdateHTLCs { - node_id: crate::c_types::PublicKey::from_rust(&node_id), - updates: crate::lightning::ln::msgs::CommitmentUpdate { inner: ObjOps::heap_alloc(updates), is_owned: true }, - } - }, - nativeMessageSendEvent::SendRevokeAndACK {mut node_id, mut msg, } => { - MessageSendEvent::SendRevokeAndACK { - node_id: crate::c_types::PublicKey::from_rust(&node_id), - msg: crate::lightning::ln::msgs::RevokeAndACK { inner: ObjOps::heap_alloc(msg), is_owned: true }, - } - }, - nativeMessageSendEvent::SendClosingSigned {mut node_id, mut msg, } => { - MessageSendEvent::SendClosingSigned { - node_id: crate::c_types::PublicKey::from_rust(&node_id), - msg: crate::lightning::ln::msgs::ClosingSigned { inner: ObjOps::heap_alloc(msg), is_owned: true }, - } - }, - nativeMessageSendEvent::SendShutdown {mut node_id, mut msg, } => { - MessageSendEvent::SendShutdown { - node_id: crate::c_types::PublicKey::from_rust(&node_id), - msg: crate::lightning::ln::msgs::Shutdown { inner: ObjOps::heap_alloc(msg), is_owned: true }, - } - }, - nativeMessageSendEvent::SendChannelReestablish {mut node_id, mut msg, } => { - MessageSendEvent::SendChannelReestablish { - node_id: crate::c_types::PublicKey::from_rust(&node_id), - msg: crate::lightning::ln::msgs::ChannelReestablish { inner: ObjOps::heap_alloc(msg), is_owned: true }, - } - }, - nativeMessageSendEvent::SendChannelAnnouncement {mut node_id, mut msg, mut update_msg, } => { - MessageSendEvent::SendChannelAnnouncement { - node_id: crate::c_types::PublicKey::from_rust(&node_id), - msg: crate::lightning::ln::msgs::ChannelAnnouncement { inner: ObjOps::heap_alloc(msg), is_owned: true }, - update_msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(update_msg), is_owned: true }, - } - }, - nativeMessageSendEvent::BroadcastChannelAnnouncement {mut msg, mut update_msg, } => { - let mut local_update_msg = crate::lightning::ln::msgs::ChannelUpdate { inner: if update_msg.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((update_msg.unwrap())) } }, is_owned: true }; - MessageSendEvent::BroadcastChannelAnnouncement { - msg: crate::lightning::ln::msgs::ChannelAnnouncement { inner: ObjOps::heap_alloc(msg), is_owned: true }, - update_msg: local_update_msg, - } - }, - nativeMessageSendEvent::BroadcastChannelUpdate {mut msg, } => { - MessageSendEvent::BroadcastChannelUpdate { - msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(msg), is_owned: true }, - } - }, - nativeMessageSendEvent::BroadcastNodeAnnouncement {mut msg, } => { - MessageSendEvent::BroadcastNodeAnnouncement { - msg: crate::lightning::ln::msgs::NodeAnnouncement { inner: ObjOps::heap_alloc(msg), is_owned: true }, - } - }, - nativeMessageSendEvent::SendChannelUpdate {mut node_id, mut msg, } => { - MessageSendEvent::SendChannelUpdate { - node_id: crate::c_types::PublicKey::from_rust(&node_id), - msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(msg), is_owned: true }, - } - }, - nativeMessageSendEvent::HandleError {mut node_id, mut action, } => { - MessageSendEvent::HandleError { - node_id: crate::c_types::PublicKey::from_rust(&node_id), - action: crate::lightning::ln::msgs::ErrorAction::native_into(action), - } - }, - nativeMessageSendEvent::SendChannelRangeQuery {mut node_id, mut msg, } => { - MessageSendEvent::SendChannelRangeQuery { - node_id: crate::c_types::PublicKey::from_rust(&node_id), - msg: crate::lightning::ln::msgs::QueryChannelRange { inner: ObjOps::heap_alloc(msg), is_owned: true }, - } - }, - nativeMessageSendEvent::SendShortIdsQuery {mut node_id, mut msg, } => { - MessageSendEvent::SendShortIdsQuery { - node_id: crate::c_types::PublicKey::from_rust(&node_id), - msg: crate::lightning::ln::msgs::QueryShortChannelIds { inner: ObjOps::heap_alloc(msg), is_owned: true }, - } - }, - nativeMessageSendEvent::SendReplyChannelRange {mut node_id, mut msg, } => { - MessageSendEvent::SendReplyChannelRange { - node_id: crate::c_types::PublicKey::from_rust(&node_id), - msg: crate::lightning::ln::msgs::ReplyChannelRange { inner: ObjOps::heap_alloc(msg), is_owned: true }, - } - }, - nativeMessageSendEvent::SendGossipTimestampFilter {mut node_id, mut msg, } => { - MessageSendEvent::SendGossipTimestampFilter { - node_id: crate::c_types::PublicKey::from_rust(&node_id), - msg: crate::lightning::ln::msgs::GossipTimestampFilter { inner: ObjOps::heap_alloc(msg), is_owned: true }, - } - }, - } - } -} -/// Frees any resources used by the MessageSendEvent -#[no_mangle] -pub extern "C" fn MessageSendEvent_free(this_ptr: MessageSendEvent) { } -/// Creates a copy of the MessageSendEvent -#[no_mangle] -pub extern "C" fn MessageSendEvent_clone(orig: &MessageSendEvent) -> MessageSendEvent { - orig.clone() -} -#[no_mangle] -/// Utility method to constructs a new SendAcceptChannel-variant MessageSendEvent -pub extern "C" fn MessageSendEvent_send_accept_channel(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::AcceptChannel) -> MessageSendEvent { - MessageSendEvent::SendAcceptChannel { - node_id, - msg, - } -} -#[no_mangle] -/// Utility method to constructs a new SendOpenChannel-variant MessageSendEvent -pub extern "C" fn MessageSendEvent_send_open_channel(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::OpenChannel) -> MessageSendEvent { - MessageSendEvent::SendOpenChannel { - node_id, - msg, - } -} -#[no_mangle] -/// Utility method to constructs a new SendFundingCreated-variant MessageSendEvent -pub extern "C" fn MessageSendEvent_send_funding_created(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::FundingCreated) -> MessageSendEvent { - MessageSendEvent::SendFundingCreated { - node_id, - msg, - } -} -#[no_mangle] -/// Utility method to constructs a new SendFundingSigned-variant MessageSendEvent -pub extern "C" fn MessageSendEvent_send_funding_signed(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::FundingSigned) -> MessageSendEvent { - MessageSendEvent::SendFundingSigned { - node_id, - msg, - } -} -#[no_mangle] -/// Utility method to constructs a new SendChannelReady-variant MessageSendEvent -pub extern "C" fn MessageSendEvent_send_channel_ready(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::ChannelReady) -> MessageSendEvent { - MessageSendEvent::SendChannelReady { - node_id, - msg, - } -} -#[no_mangle] -/// Utility method to constructs a new SendAnnouncementSignatures-variant MessageSendEvent -pub extern "C" fn MessageSendEvent_send_announcement_signatures(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::AnnouncementSignatures) -> MessageSendEvent { - MessageSendEvent::SendAnnouncementSignatures { - node_id, - msg, - } -} -#[no_mangle] -/// Utility method to constructs a new UpdateHTLCs-variant MessageSendEvent -pub extern "C" fn MessageSendEvent_update_htlcs(node_id: crate::c_types::PublicKey, updates: crate::lightning::ln::msgs::CommitmentUpdate) -> MessageSendEvent { - MessageSendEvent::UpdateHTLCs { - node_id, - updates, - } -} -#[no_mangle] -/// Utility method to constructs a new SendRevokeAndACK-variant MessageSendEvent -pub extern "C" fn MessageSendEvent_send_revoke_and_ack(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::RevokeAndACK) -> MessageSendEvent { - MessageSendEvent::SendRevokeAndACK { - node_id, - msg, - } -} -#[no_mangle] -/// Utility method to constructs a new SendClosingSigned-variant MessageSendEvent -pub extern "C" fn MessageSendEvent_send_closing_signed(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::ClosingSigned) -> MessageSendEvent { - MessageSendEvent::SendClosingSigned { - node_id, - msg, - } -} -#[no_mangle] -/// Utility method to constructs a new SendShutdown-variant MessageSendEvent -pub extern "C" fn MessageSendEvent_send_shutdown(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::Shutdown) -> MessageSendEvent { - MessageSendEvent::SendShutdown { - node_id, - msg, - } -} -#[no_mangle] -/// Utility method to constructs a new SendChannelReestablish-variant MessageSendEvent -pub extern "C" fn MessageSendEvent_send_channel_reestablish(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::ChannelReestablish) -> MessageSendEvent { - MessageSendEvent::SendChannelReestablish { - node_id, - msg, - } -} -#[no_mangle] -/// Utility method to constructs a new SendChannelAnnouncement-variant MessageSendEvent -pub extern "C" fn MessageSendEvent_send_channel_announcement(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::ChannelAnnouncement, update_msg: crate::lightning::ln::msgs::ChannelUpdate) -> MessageSendEvent { - MessageSendEvent::SendChannelAnnouncement { - node_id, - msg, - update_msg, - } -} -#[no_mangle] -/// Utility method to constructs a new BroadcastChannelAnnouncement-variant MessageSendEvent -pub extern "C" fn MessageSendEvent_broadcast_channel_announcement(msg: crate::lightning::ln::msgs::ChannelAnnouncement, update_msg: crate::lightning::ln::msgs::ChannelUpdate) -> MessageSendEvent { - MessageSendEvent::BroadcastChannelAnnouncement { - msg, - update_msg, - } -} -#[no_mangle] -/// Utility method to constructs a new BroadcastChannelUpdate-variant MessageSendEvent -pub extern "C" fn MessageSendEvent_broadcast_channel_update(msg: crate::lightning::ln::msgs::ChannelUpdate) -> MessageSendEvent { - MessageSendEvent::BroadcastChannelUpdate { - msg, - } -} -#[no_mangle] -/// Utility method to constructs a new BroadcastNodeAnnouncement-variant MessageSendEvent -pub extern "C" fn MessageSendEvent_broadcast_node_announcement(msg: crate::lightning::ln::msgs::NodeAnnouncement) -> MessageSendEvent { - MessageSendEvent::BroadcastNodeAnnouncement { - msg, - } -} -#[no_mangle] -/// Utility method to constructs a new SendChannelUpdate-variant MessageSendEvent -pub extern "C" fn MessageSendEvent_send_channel_update(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::ChannelUpdate) -> MessageSendEvent { - MessageSendEvent::SendChannelUpdate { - node_id, - msg, - } -} -#[no_mangle] -/// Utility method to constructs a new HandleError-variant MessageSendEvent -pub extern "C" fn MessageSendEvent_handle_error(node_id: crate::c_types::PublicKey, action: crate::lightning::ln::msgs::ErrorAction) -> MessageSendEvent { - MessageSendEvent::HandleError { - node_id, - action, - } -} -#[no_mangle] -/// Utility method to constructs a new SendChannelRangeQuery-variant MessageSendEvent -pub extern "C" fn MessageSendEvent_send_channel_range_query(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::QueryChannelRange) -> MessageSendEvent { - MessageSendEvent::SendChannelRangeQuery { - node_id, - msg, - } -} -#[no_mangle] -/// Utility method to constructs a new SendShortIdsQuery-variant MessageSendEvent -pub extern "C" fn MessageSendEvent_send_short_ids_query(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::QueryShortChannelIds) -> MessageSendEvent { - MessageSendEvent::SendShortIdsQuery { - node_id, - msg, - } -} -#[no_mangle] -/// Utility method to constructs a new SendReplyChannelRange-variant MessageSendEvent -pub extern "C" fn MessageSendEvent_send_reply_channel_range(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::ReplyChannelRange) -> MessageSendEvent { - MessageSendEvent::SendReplyChannelRange { - node_id, - msg, - } -} -#[no_mangle] -/// Utility method to constructs a new SendGossipTimestampFilter-variant MessageSendEvent -pub extern "C" fn MessageSendEvent_send_gossip_timestamp_filter(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::GossipTimestampFilter) -> MessageSendEvent { - MessageSendEvent::SendGossipTimestampFilter { - node_id, - msg, - } -} -/// A trait indicating an object may generate message send events -#[repr(C)] -pub struct MessageSendEventsProvider { - /// An opaque pointer which is passed to your function implementations as an argument. - /// This has no meaning in the LDK, and can be NULL or any other value. - pub this_arg: *mut c_void, - /// Gets the list of pending events which were generated by previous actions, clearing the list - /// in the process. - #[must_use] - pub get_and_clear_pending_msg_events: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_MessageSendEventZ, - /// Frees any resources associated with this object given its this_arg pointer. - /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. - pub free: Option, -} -unsafe impl Send for MessageSendEventsProvider {} -unsafe impl Sync for MessageSendEventsProvider {} -#[no_mangle] -pub(crate) extern "C" fn MessageSendEventsProvider_clone_fields(orig: &MessageSendEventsProvider) -> MessageSendEventsProvider { - MessageSendEventsProvider { - this_arg: orig.this_arg, - get_and_clear_pending_msg_events: Clone::clone(&orig.get_and_clear_pending_msg_events), - free: Clone::clone(&orig.free), - } -} - -use lightning::events::MessageSendEventsProvider as rustMessageSendEventsProvider; -impl rustMessageSendEventsProvider for MessageSendEventsProvider { - fn get_and_clear_pending_msg_events(&self) -> Vec { - let mut ret = (self.get_and_clear_pending_msg_events)(self.this_arg); - let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); }; - local_ret - } -} - -// We're essentially a pointer already, or at least a set of pointers, so allow us to be used -// directly as a Deref trait in higher-level structs: -impl core::ops::Deref for MessageSendEventsProvider { - type Target = Self; - fn deref(&self) -> &Self { - self - } -} -/// Calls the free function if one is set -#[no_mangle] -pub extern "C" fn MessageSendEventsProvider_free(this_ptr: MessageSendEventsProvider) { } -impl Drop for MessageSendEventsProvider { - fn drop(&mut self) { - if let Some(f) = self.free { - f(self.this_arg); - } - } -} -/// A trait indicating an object may generate onion messages to send -#[repr(C)] -pub struct OnionMessageProvider { - /// An opaque pointer which is passed to your function implementations as an argument. - /// This has no meaning in the LDK, and can be NULL or any other value. - pub this_arg: *mut c_void, - /// Gets the next pending onion message for the peer with the given node id. - /// - /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None - #[must_use] - pub next_onion_message_for_peer: extern "C" fn (this_arg: *const c_void, peer_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::msgs::OnionMessage, - /// Frees any resources associated with this object given its this_arg pointer. - /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. - pub free: Option, -} -unsafe impl Send for OnionMessageProvider {} -unsafe impl Sync for OnionMessageProvider {} -#[no_mangle] -pub(crate) extern "C" fn OnionMessageProvider_clone_fields(orig: &OnionMessageProvider) -> OnionMessageProvider { - OnionMessageProvider { - this_arg: orig.this_arg, - next_onion_message_for_peer: Clone::clone(&orig.next_onion_message_for_peer), - free: Clone::clone(&orig.free), - } -} - -use lightning::events::OnionMessageProvider as rustOnionMessageProvider; -impl rustOnionMessageProvider for OnionMessageProvider { - fn next_onion_message_for_peer(&self, mut peer_node_id: bitcoin::secp256k1::PublicKey) -> Option { - let mut ret = (self.next_onion_message_for_peer)(self.this_arg, crate::c_types::PublicKey::from_rust(&peer_node_id)); - let mut local_ret = if ret.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(ret.take_inner()) } }) }; - local_ret - } -} - -// We're essentially a pointer already, or at least a set of pointers, so allow us to be used -// directly as a Deref trait in higher-level structs: -impl core::ops::Deref for OnionMessageProvider { - type Target = Self; - fn deref(&self) -> &Self { - self - } -} -/// Calls the free function if one is set -#[no_mangle] -pub extern "C" fn OnionMessageProvider_free(this_ptr: OnionMessageProvider) { } -impl Drop for OnionMessageProvider { - fn drop(&mut self) { - if let Some(f) = self.free { - f(self.this_arg); - } - } -} -/// A trait indicating an object may generate events. -/// -/// Events are processed by passing an [`EventHandler`] to [`process_pending_events`]. -/// -/// Implementations of this trait may also feature an async version of event handling, as shown with -/// [`ChannelManager::process_pending_events_async`] and -/// [`ChainMonitor::process_pending_events_async`]. -/// -/// # Requirements -/// -/// When using this trait, [`process_pending_events`] will call [`handle_event`] for each pending -/// event since the last invocation. -/// -/// In order to ensure no [`Event`]s are lost, implementors of this trait will persist [`Event`]s -/// and replay any unhandled events on startup. An [`Event`] is considered handled when -/// [`process_pending_events`] returns, thus handlers MUST fully handle [`Event`]s and persist any -/// relevant changes to disk *before* returning. -/// -/// Further, because an application may crash between an [`Event`] being handled and the -/// implementor of this trait being re-serialized, [`Event`] handling must be idempotent - in -/// effect, [`Event`]s may be replayed. -/// -/// Note, handlers may call back into the provider and thus deadlocking must be avoided. Be sure to -/// consult the provider's documentation on the implication of processing events and how a handler -/// may safely use the provider (e.g., see [`ChannelManager::process_pending_events`] and -/// [`ChainMonitor::process_pending_events`]). -/// -/// (C-not implementable) As there is likely no reason for a user to implement this trait on their -/// own type(s). -/// -/// [`process_pending_events`]: Self::process_pending_events -/// [`handle_event`]: EventHandler::handle_event -/// [`ChannelManager::process_pending_events`]: crate::ln::channelmanager::ChannelManager#method.process_pending_events -/// [`ChainMonitor::process_pending_events`]: crate::chain::chainmonitor::ChainMonitor#method.process_pending_events -/// [`ChannelManager::process_pending_events_async`]: crate::ln::channelmanager::ChannelManager::process_pending_events_async -/// [`ChainMonitor::process_pending_events_async`]: crate::chain::chainmonitor::ChainMonitor::process_pending_events_async -#[repr(C)] -pub struct EventsProvider { - /// An opaque pointer which is passed to your function implementations as an argument. - /// This has no meaning in the LDK, and can be NULL or any other value. - pub this_arg: *mut c_void, - /// Processes any events generated since the last call using the given event handler. - /// - /// See the trait-level documentation for requirements. - pub process_pending_events: extern "C" fn (this_arg: *const c_void, handler: crate::lightning::events::EventHandler), - /// Frees any resources associated with this object given its this_arg pointer. - /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. - pub free: Option, -} -unsafe impl Send for EventsProvider {} -unsafe impl Sync for EventsProvider {} -#[no_mangle] -pub(crate) extern "C" fn EventsProvider_clone_fields(orig: &EventsProvider) -> EventsProvider { - EventsProvider { - this_arg: orig.this_arg, - process_pending_events: Clone::clone(&orig.process_pending_events), - free: Clone::clone(&orig.free), - } -} - -use lightning::events::EventsProvider as rustEventsProvider; -/// Calls the free function if one is set -#[no_mangle] -pub extern "C" fn EventsProvider_free(this_ptr: EventsProvider) { } -impl Drop for EventsProvider { - fn drop(&mut self) { - if let Some(f) = self.free { - f(self.this_arg); - } - } -} -/// A trait implemented for objects handling events from [`EventsProvider`]. -/// -/// An async variation also exists for implementations of [`EventsProvider`] that support async -/// event handling. The async event handler should satisfy the generic bounds: `F: -/// core::future::Future, H: Fn(Event) -> F`. -#[repr(C)] -pub struct EventHandler { - /// An opaque pointer which is passed to your function implementations as an argument. - /// This has no meaning in the LDK, and can be NULL or any other value. - pub this_arg: *mut c_void, - /// Handles the given [`Event`]. - /// - /// See [`EventsProvider`] for details that must be considered when implementing this method. - pub handle_event: extern "C" fn (this_arg: *const c_void, event: crate::lightning::events::Event), - /// Frees any resources associated with this object given its this_arg pointer. - /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. - pub free: Option, -} -unsafe impl Send for EventHandler {} -unsafe impl Sync for EventHandler {} -#[no_mangle] -pub(crate) extern "C" fn EventHandler_clone_fields(orig: &EventHandler) -> EventHandler { - EventHandler { - this_arg: orig.this_arg, - handle_event: Clone::clone(&orig.handle_event), - free: Clone::clone(&orig.free), - } -} - -use lightning::events::EventHandler as rustEventHandler; -impl rustEventHandler for EventHandler { - fn handle_event(&self, mut event: lightning::events::Event) { - (self.handle_event)(self.this_arg, crate::lightning::events::Event::native_into(event)) - } -} - -// We're essentially a pointer already, or at least a set of pointers, so allow us to be used -// directly as a Deref trait in higher-level structs: -impl core::ops::Deref for EventHandler { - type Target = Self; - fn deref(&self) -> &Self { - self - } -} -/// Calls the free function if one is set -#[no_mangle] -pub extern "C" fn EventHandler_free(this_ptr: EventHandler) { } -impl Drop for EventHandler { - fn drop(&mut self) { - if let Some(f) = self.free { - f(self.this_arg); - } - } -} diff --git a/lightning-c-bindings/src/lightning/ln/chan_utils.rs b/lightning-c-bindings/src/lightning/ln/chan_utils.rs index ebfd1299..b6a68d66 100644 --- a/lightning-c-bindings/src/lightning/ln/chan_utils.rs +++ b/lightning-c-bindings/src/lightning/ln/chan_utils.rs @@ -7,7 +7,7 @@ // source was automatically generated. //! Various utilities for building scripts and deriving keys related to channels. These are -//! largely of interest for those implementing the traits on [`chain::keysinterface`] by hand. +//! largely of interest for those implementing the traits on [`crate::sign`] by hand. use alloc::str::FromStr; use core::ffi::c_void; @@ -35,17 +35,31 @@ pub static OFFERED_HTLC_SCRIPT_WEIGHT_ANCHORS: usize = lightning::ln::chan_utils #[no_mangle] pub static MAX_ACCEPTED_HTLC_SCRIPT_WEIGHT: usize = lightning::ln::chan_utils::MAX_ACCEPTED_HTLC_SCRIPT_WEIGHT; +/// The upper bound weight of an anchor input. + +#[no_mangle] +pub static ANCHOR_INPUT_WITNESS_WEIGHT: u64 = lightning::ln::chan_utils::ANCHOR_INPUT_WITNESS_WEIGHT; +/// The upper bound weight of an HTLC timeout input from a commitment transaction with anchor +/// outputs. + +#[no_mangle] +pub static HTLC_TIMEOUT_INPUT_ANCHOR_WITNESS_WEIGHT: u64 = lightning::ln::chan_utils::HTLC_TIMEOUT_INPUT_ANCHOR_WITNESS_WEIGHT; +/// The upper bound weight of an HTLC success input from a commitment transaction with anchor +/// outputs. + +#[no_mangle] +pub static HTLC_SUCCESS_INPUT_ANCHOR_WITNESS_WEIGHT: u64 = lightning::ln::chan_utils::HTLC_SUCCESS_INPUT_ANCHOR_WITNESS_WEIGHT; /// Gets the weight for an HTLC-Success transaction. #[no_mangle] -pub extern "C" fn htlc_success_tx_weight(mut opt_anchors: bool) -> u64 { - let mut ret = lightning::ln::chan_utils::htlc_success_tx_weight(opt_anchors); +pub extern "C" fn htlc_success_tx_weight(channel_type_features: &crate::lightning::ln::features::ChannelTypeFeatures) -> u64 { + let mut ret = lightning::ln::chan_utils::htlc_success_tx_weight(channel_type_features.get_native_ref()); ret } /// Gets the weight for an HTLC-Timeout transaction. #[no_mangle] -pub extern "C" fn htlc_timeout_tx_weight(mut opt_anchors: bool) -> u64 { - let mut ret = lightning::ln::chan_utils::htlc_timeout_tx_weight(opt_anchors); +pub extern "C" fn htlc_timeout_tx_weight(channel_type_features: &crate::lightning::ln::features::ChannelTypeFeatures) -> u64 { + let mut ret = lightning::ln::chan_utils::htlc_timeout_tx_weight(channel_type_features.get_native_ref()); ret } @@ -906,8 +920,8 @@ pub extern "C" fn HTLCOutputInCommitment_read(ser: crate::c_types::u8slice) -> c /// Gets the witness redeemscript for an HTLC output in a commitment transaction. Note that htlc /// does not need to have its previous_output_index filled. #[no_mangle] -pub extern "C" fn get_htlc_redeemscript(htlc: &crate::lightning::ln::chan_utils::HTLCOutputInCommitment, mut opt_anchors: bool, keys: &crate::lightning::ln::chan_utils::TxCreationKeys) -> crate::c_types::derived::CVec_u8Z { - let mut ret = lightning::ln::chan_utils::get_htlc_redeemscript(htlc.get_native_ref(), opt_anchors, keys.get_native_ref()); +pub extern "C" fn get_htlc_redeemscript(htlc: &crate::lightning::ln::chan_utils::HTLCOutputInCommitment, channel_type_features: &crate::lightning::ln::features::ChannelTypeFeatures, keys: &crate::lightning::ln::chan_utils::TxCreationKeys) -> crate::c_types::derived::CVec_u8Z { + let mut ret = lightning::ln::chan_utils::get_htlc_redeemscript(htlc.get_native_ref(), channel_type_features.get_native_ref(), keys.get_native_ref()); ret.into_bytes().into() } @@ -927,18 +941,16 @@ pub extern "C" fn make_funding_redeemscript(mut broadcaster: crate::c_types::Pub /// Panics if htlc.transaction_output_index.is_none() (as such HTLCs do not appear in the /// commitment transaction). #[no_mangle] -pub extern "C" fn build_htlc_transaction(commitment_txid: *const [u8; 32], mut feerate_per_kw: u32, mut contest_delay: u16, htlc: &crate::lightning::ln::chan_utils::HTLCOutputInCommitment, mut opt_anchors: bool, mut use_non_zero_fee_anchors: bool, mut broadcaster_delayed_payment_key: crate::c_types::PublicKey, mut revocation_key: crate::c_types::PublicKey) -> crate::c_types::Transaction { - let mut ret = lightning::ln::chan_utils::build_htlc_transaction(&::bitcoin::hash_types::Txid::from_slice(&unsafe { &*commitment_txid }[..]).unwrap(), feerate_per_kw, contest_delay, htlc.get_native_ref(), opt_anchors, use_non_zero_fee_anchors, &broadcaster_delayed_payment_key.into_rust(), &revocation_key.into_rust()); +pub extern "C" fn build_htlc_transaction(commitment_txid: *const [u8; 32], mut feerate_per_kw: u32, mut contest_delay: u16, htlc: &crate::lightning::ln::chan_utils::HTLCOutputInCommitment, channel_type_features: &crate::lightning::ln::features::ChannelTypeFeatures, mut broadcaster_delayed_payment_key: crate::c_types::PublicKey, mut revocation_key: crate::c_types::PublicKey) -> crate::c_types::Transaction { + let mut ret = lightning::ln::chan_utils::build_htlc_transaction(&::bitcoin::hash_types::Txid::from_slice(&unsafe { &*commitment_txid }[..]).unwrap(), feerate_per_kw, contest_delay, htlc.get_native_ref(), channel_type_features.get_native_ref(), &broadcaster_delayed_payment_key.into_rust(), &revocation_key.into_rust()); crate::c_types::Transaction::from_bitcoin(&ret) } /// Returns the witness required to satisfy and spend a HTLC input. -/// -/// Note that preimage (or a relevant inner pointer) may be NULL or all-0s to represent None #[no_mangle] -pub extern "C" fn build_htlc_input_witness(mut local_sig: crate::c_types::Signature, mut remote_sig: crate::c_types::Signature, mut preimage: crate::c_types::ThirtyTwoBytes, mut redeem_script: crate::c_types::u8slice, mut opt_anchors: bool) -> crate::c_types::Witness { - let mut local_preimage = if preimage.data == [0; 32] { None } else { Some( { ::lightning::ln::PaymentPreimage(preimage.data) }) }; - let mut ret = lightning::ln::chan_utils::build_htlc_input_witness(&local_sig.into_rust(), &remote_sig.into_rust(), &local_preimage, &::bitcoin::blockdata::script::Script::from(Vec::from(redeem_script.to_slice())), opt_anchors); +pub extern "C" fn build_htlc_input_witness(mut local_sig: crate::c_types::Signature, mut remote_sig: crate::c_types::Signature, mut preimage: crate::c_types::derived::COption_PaymentPreimageZ, mut redeem_script: crate::c_types::u8slice, channel_type_features: &crate::lightning::ln::features::ChannelTypeFeatures) -> crate::c_types::Witness { + let mut local_preimage = { /*preimage*/ let preimage_opt = preimage; if preimage_opt.is_none() { None } else { Some({ { ::lightning::ln::PaymentPreimage({ preimage_opt.take() }.data) }})} }; + let mut ret = lightning::ln::chan_utils::build_htlc_input_witness(&local_sig.into_rust(), &remote_sig.into_rust(), &local_preimage, &::bitcoin::blockdata::script::Script::from(Vec::from(redeem_script.to_slice())), channel_type_features.get_native_ref()); crate::c_types::Witness::from_bitcoin(&ret) } @@ -1094,54 +1106,32 @@ pub extern "C" fn ChannelTransactionParameters_set_funding_outpoint(this_ptr: &m let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_outpoint = local_val; } -/// Are anchors (zero fee HTLC transaction variant) used for this channel. Boolean is -/// serialization backwards-compatible. +/// This channel's type, as negotiated during channel open. For old objects where this field +/// wasn't serialized, it will default to static_remote_key at deserialization. #[no_mangle] -pub extern "C" fn ChannelTransactionParameters_get_opt_anchors(this_ptr: &ChannelTransactionParameters) -> crate::c_types::derived::COption_NoneZ { - let mut inner_val = &mut this_ptr.get_native_mut_ref().opt_anchors; - let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_NoneZ::None } else { crate::c_types::derived::COption_NoneZ::Some /* { () /**/ } */ }; - local_inner_val +pub extern "C" fn ChannelTransactionParameters_get_channel_type_features(this_ptr: &ChannelTransactionParameters) -> crate::lightning::ln::features::ChannelTypeFeatures { + let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type_features; + crate::lightning::ln::features::ChannelTypeFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::features::ChannelTypeFeatures<>) as *mut _) }, is_owned: false } } -/// Are anchors (zero fee HTLC transaction variant) used for this channel. Boolean is -/// serialization backwards-compatible. +/// This channel's type, as negotiated during channel open. For old objects where this field +/// wasn't serialized, it will default to static_remote_key at deserialization. #[no_mangle] -pub extern "C" fn ChannelTransactionParameters_set_opt_anchors(this_ptr: &mut ChannelTransactionParameters, mut val: crate::c_types::derived::COption_NoneZ) { - let mut local_val = if val.is_some() { Some( { () /*val.take()*/ }) } else { None }; - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.opt_anchors = local_val; -} -/// Are non-zero-fee anchors are enabled (used in conjuction with opt_anchors) -/// It is intended merely for backwards compatibility with signers that need it. -/// There is no support for this feature in LDK channel negotiation. -#[no_mangle] -pub extern "C" fn ChannelTransactionParameters_get_opt_non_zero_fee_anchors(this_ptr: &ChannelTransactionParameters) -> crate::c_types::derived::COption_NoneZ { - let mut inner_val = &mut this_ptr.get_native_mut_ref().opt_non_zero_fee_anchors; - let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_NoneZ::None } else { crate::c_types::derived::COption_NoneZ::Some /* { () /**/ } */ }; - local_inner_val -} -/// Are non-zero-fee anchors are enabled (used in conjuction with opt_anchors) -/// It is intended merely for backwards compatibility with signers that need it. -/// There is no support for this feature in LDK channel negotiation. -#[no_mangle] -pub extern "C" fn ChannelTransactionParameters_set_opt_non_zero_fee_anchors(this_ptr: &mut ChannelTransactionParameters, mut val: crate::c_types::derived::COption_NoneZ) { - let mut local_val = if val.is_some() { Some( { () /*val.take()*/ }) } else { None }; - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.opt_non_zero_fee_anchors = local_val; +pub extern "C" fn ChannelTransactionParameters_set_channel_type_features(this_ptr: &mut ChannelTransactionParameters, mut val: crate::lightning::ln::features::ChannelTypeFeatures) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type_features = *unsafe { Box::from_raw(val.take_inner()) }; } /// Constructs a new ChannelTransactionParameters given each field #[must_use] #[no_mangle] -pub extern "C" fn ChannelTransactionParameters_new(mut holder_pubkeys_arg: crate::lightning::ln::chan_utils::ChannelPublicKeys, mut holder_selected_contest_delay_arg: u16, mut is_outbound_from_holder_arg: bool, mut counterparty_parameters_arg: crate::lightning::ln::chan_utils::CounterpartyChannelTransactionParameters, mut funding_outpoint_arg: crate::lightning::chain::transaction::OutPoint, mut opt_anchors_arg: crate::c_types::derived::COption_NoneZ, mut opt_non_zero_fee_anchors_arg: crate::c_types::derived::COption_NoneZ) -> ChannelTransactionParameters { +pub extern "C" fn ChannelTransactionParameters_new(mut holder_pubkeys_arg: crate::lightning::ln::chan_utils::ChannelPublicKeys, mut holder_selected_contest_delay_arg: u16, mut is_outbound_from_holder_arg: bool, mut counterparty_parameters_arg: crate::lightning::ln::chan_utils::CounterpartyChannelTransactionParameters, mut funding_outpoint_arg: crate::lightning::chain::transaction::OutPoint, mut channel_type_features_arg: crate::lightning::ln::features::ChannelTypeFeatures) -> ChannelTransactionParameters { let mut local_counterparty_parameters_arg = if counterparty_parameters_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(counterparty_parameters_arg.take_inner()) } }) }; let mut local_funding_outpoint_arg = if funding_outpoint_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(funding_outpoint_arg.take_inner()) } }) }; - let mut local_opt_anchors_arg = if opt_anchors_arg.is_some() { Some( { () /*opt_anchors_arg.take()*/ }) } else { None }; - let mut local_opt_non_zero_fee_anchors_arg = if opt_non_zero_fee_anchors_arg.is_some() { Some( { () /*opt_non_zero_fee_anchors_arg.take()*/ }) } else { None }; ChannelTransactionParameters { inner: ObjOps::heap_alloc(nativeChannelTransactionParameters { holder_pubkeys: *unsafe { Box::from_raw(holder_pubkeys_arg.take_inner()) }, holder_selected_contest_delay: holder_selected_contest_delay_arg, is_outbound_from_holder: is_outbound_from_holder_arg, counterparty_parameters: local_counterparty_parameters_arg, funding_outpoint: local_funding_outpoint_arg, - opt_anchors: local_opt_anchors_arg, - opt_non_zero_fee_anchors: local_opt_non_zero_fee_anchors_arg, + channel_type_features: *unsafe { Box::from_raw(channel_type_features_arg.take_inner()) }, }), is_owned: true } } impl Clone for ChannelTransactionParameters { @@ -1440,15 +1430,15 @@ pub extern "C" fn DirectedChannelTransactionParameters_is_outbound(this_arg: &cr #[no_mangle] pub extern "C" fn DirectedChannelTransactionParameters_funding_outpoint(this_arg: &crate::lightning::ln::chan_utils::DirectedChannelTransactionParameters) -> crate::lightning::chain::transaction::OutPoint { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.funding_outpoint(); - crate::c_types::bitcoin_to_C_outpoint(ret) + crate::c_types::bitcoin_to_C_outpoint(&ret) } /// Whether to use anchors for this channel #[must_use] #[no_mangle] -pub extern "C" fn DirectedChannelTransactionParameters_opt_anchors(this_arg: &crate::lightning::ln::chan_utils::DirectedChannelTransactionParameters) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.opt_anchors(); - ret +pub extern "C" fn DirectedChannelTransactionParameters_channel_type_features(this_arg: &crate::lightning::ln::chan_utils::DirectedChannelTransactionParameters) -> crate::lightning::ln::features::ChannelTypeFeatures { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.channel_type_features(); + crate::lightning::ln::features::ChannelTypeFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::ChannelTypeFeatures<>) as *mut _) }, is_owned: false } } @@ -1719,7 +1709,7 @@ pub extern "C" fn BuiltCommitmentTransaction_sign_counterparty_commitment(this_a /// Signs the holder commitment transaction because we are about to broadcast it. #[must_use] #[no_mangle] -pub extern "C" fn BuiltCommitmentTransaction_sign_holder_commitment(this_arg: &crate::lightning::ln::chan_utils::BuiltCommitmentTransaction, funding_key: *const [u8; 32], mut funding_redeemscript: crate::c_types::u8slice, mut channel_value_satoshis: u64, entropy_source: &crate::lightning::chain::keysinterface::EntropySource) -> crate::c_types::Signature { +pub extern "C" fn BuiltCommitmentTransaction_sign_holder_commitment(this_arg: &crate::lightning::ln::chan_utils::BuiltCommitmentTransaction, funding_key: *const [u8; 32], mut funding_redeemscript: crate::c_types::u8slice, mut channel_value_satoshis: u64, entropy_source: &crate::lightning::sign::EntropySource) -> crate::c_types::Signature { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.sign_holder_commitment(&::bitcoin::secp256k1::SecretKey::from_slice(&unsafe { *funding_key}[..]).unwrap(), &::bitcoin::blockdata::script::Script::from(Vec::from(funding_redeemscript.to_slice())), channel_value_satoshis, entropy_source, secp256k1::global::SECP256K1); crate::c_types::Signature::from_rust(&ret) } @@ -2200,9 +2190,9 @@ pub extern "C" fn TrustedCommitmentTransaction_keys(this_arg: &crate::lightning: /// Should anchors be used. #[must_use] #[no_mangle] -pub extern "C" fn TrustedCommitmentTransaction_opt_anchors(this_arg: &crate::lightning::ln::chan_utils::TrustedCommitmentTransaction) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.opt_anchors(); - ret +pub extern "C" fn TrustedCommitmentTransaction_channel_type_features(this_arg: &crate::lightning::ln::chan_utils::TrustedCommitmentTransaction) -> crate::lightning::ln::features::ChannelTypeFeatures { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.channel_type_features(); + crate::lightning::ln::features::ChannelTypeFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::ChannelTypeFeatures<>) as *mut _) }, is_owned: false } } /// Get a signature for each HTLC which was included in the commitment transaction (ie for @@ -2213,7 +2203,7 @@ pub extern "C" fn TrustedCommitmentTransaction_opt_anchors(this_arg: &crate::lig /// This function is only valid in the holder commitment context, it always uses EcdsaSighashType::All. #[must_use] #[no_mangle] -pub extern "C" fn TrustedCommitmentTransaction_get_htlc_sigs(this_arg: &crate::lightning::ln::chan_utils::TrustedCommitmentTransaction, htlc_base_key: *const [u8; 32], channel_parameters: &crate::lightning::ln::chan_utils::DirectedChannelTransactionParameters, entropy_source: &crate::lightning::chain::keysinterface::EntropySource) -> crate::c_types::derived::CResult_CVec_SignatureZNoneZ { +pub extern "C" fn TrustedCommitmentTransaction_get_htlc_sigs(this_arg: &crate::lightning::ln::chan_utils::TrustedCommitmentTransaction, htlc_base_key: *const [u8; 32], channel_parameters: &crate::lightning::ln::chan_utils::DirectedChannelTransactionParameters, entropy_source: &crate::lightning::sign::EntropySource) -> crate::c_types::derived::CResult_CVec_SignatureZNoneZ { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_htlc_sigs(&::bitcoin::secp256k1::SecretKey::from_slice(&unsafe { *htlc_base_key}[..]).unwrap(), channel_parameters.get_native_ref(), entropy_source, secp256k1::global::SECP256K1); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = Vec::new(); for mut item in o.drain(..) { local_ret_0.push( { crate::c_types::Signature::from_rust(&item) }); }; local_ret_0.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; local_ret diff --git a/lightning-c-bindings/src/lightning/ln/channelmanager.rs b/lightning-c-bindings/src/lightning/ln/channelmanager.rs index bcca9dfc..051661db 100644 --- a/lightning-c-bindings/src/lightning/ln/channelmanager.rs +++ b/lightning-c-bindings/src/lightning/ln/channelmanager.rs @@ -100,7 +100,7 @@ pub extern "C" fn FailureCode_incorrect_or_unknown_payment_details() -> FailureC FailureCode::IncorrectOrUnknownPaymentDetails} use lightning::ln::channelmanager::ChannelManager as nativeChannelManagerImport; -pub(crate) type nativeChannelManager = nativeChannelManagerImport; +pub(crate) type nativeChannelManager = nativeChannelManagerImport; /// Manager which keeps track of a number of channels and sends messages to the appropriate /// channel, also tracking HTLC preimages and forwarding onion packets appropriately. @@ -994,7 +994,8 @@ pub extern "C" fn ChannelDetails_set_outbound_capacity_msat(this_ptr: &mut Chann /// the current state and per-HTLC limit(s). This is intended for use when routing, allowing us /// to use a limit as close as possible to the HTLC limit we can currently send. /// -/// See also [`ChannelDetails::balance_msat`] and [`ChannelDetails::outbound_capacity_msat`]. +/// See also [`ChannelDetails::next_outbound_htlc_minimum_msat`], +/// [`ChannelDetails::balance_msat`], and [`ChannelDetails::outbound_capacity_msat`]. #[no_mangle] pub extern "C" fn ChannelDetails_get_next_outbound_htlc_limit_msat(this_ptr: &ChannelDetails) -> u64 { let mut inner_val = &mut this_ptr.get_native_mut_ref().next_outbound_htlc_limit_msat; @@ -1005,11 +1006,29 @@ pub extern "C" fn ChannelDetails_get_next_outbound_htlc_limit_msat(this_ptr: &Ch /// the current state and per-HTLC limit(s). This is intended for use when routing, allowing us /// to use a limit as close as possible to the HTLC limit we can currently send. /// -/// See also [`ChannelDetails::balance_msat`] and [`ChannelDetails::outbound_capacity_msat`]. +/// See also [`ChannelDetails::next_outbound_htlc_minimum_msat`], +/// [`ChannelDetails::balance_msat`], and [`ChannelDetails::outbound_capacity_msat`]. #[no_mangle] pub extern "C" fn ChannelDetails_set_next_outbound_htlc_limit_msat(this_ptr: &mut ChannelDetails, mut val: u64) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_outbound_htlc_limit_msat = val; } +/// The minimum value for sending a single HTLC to the remote peer. This is the equivalent of +/// [`ChannelDetails::next_outbound_htlc_limit_msat`] but represents a lower-bound, rather than +/// an upper-bound. This is intended for use when routing, allowing us to ensure we pick a +/// route which is valid. +#[no_mangle] +pub extern "C" fn ChannelDetails_get_next_outbound_htlc_minimum_msat(this_ptr: &ChannelDetails) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().next_outbound_htlc_minimum_msat; + *inner_val +} +/// The minimum value for sending a single HTLC to the remote peer. This is the equivalent of +/// [`ChannelDetails::next_outbound_htlc_limit_msat`] but represents a lower-bound, rather than +/// an upper-bound. This is intended for use when routing, allowing us to ensure we pick a +/// route which is valid. +#[no_mangle] +pub extern "C" fn ChannelDetails_set_next_outbound_htlc_minimum_msat(this_ptr: &mut ChannelDetails, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_outbound_htlc_minimum_msat = val; +} /// The available inbound capacity for the remote peer to send HTLCs to us. This does not /// include any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not /// available for inclusion in new inbound HTLCs). @@ -1146,6 +1165,23 @@ pub extern "C" fn ChannelDetails_get_is_channel_ready(this_ptr: &ChannelDetails) pub extern "C" fn ChannelDetails_set_is_channel_ready(this_ptr: &mut ChannelDetails, mut val: bool) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.is_channel_ready = val; } +/// The stage of the channel's shutdown. +/// `None` for `ChannelDetails` serialized on LDK versions prior to 0.0.116. +/// +/// Returns a copy of the field. +#[no_mangle] +pub extern "C" fn ChannelDetails_get_channel_shutdown_state(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_ChannelShutdownStateZ { + let mut inner_val = this_ptr.get_native_mut_ref().channel_shutdown_state.clone(); + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_ChannelShutdownStateZ::None } else { crate::c_types::derived::COption_ChannelShutdownStateZ::Some( { crate::lightning::ln::channelmanager::ChannelShutdownState::native_into(inner_val.unwrap()) }) }; + local_inner_val +} +/// The stage of the channel's shutdown. +/// `None` for `ChannelDetails` serialized on LDK versions prior to 0.0.116. +#[no_mangle] +pub extern "C" fn ChannelDetails_set_channel_shutdown_state(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_ChannelShutdownStateZ) { + let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { { val_opt.take() }.into_native() }})} }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_shutdown_state = local_val; +} /// True if the channel is (a) confirmed and channel_ready messages have been exchanged, (b) /// the peer is connected, and (c) the channel is not currently negotiating a shutdown. /// @@ -1226,7 +1262,7 @@ pub extern "C" fn ChannelDetails_set_config(this_ptr: &mut ChannelDetails, mut v /// Constructs a new ChannelDetails given each field #[must_use] #[no_mangle] -pub extern "C" fn ChannelDetails_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut counterparty_arg: crate::lightning::ln::channelmanager::ChannelCounterparty, mut funding_txo_arg: crate::lightning::chain::transaction::OutPoint, mut channel_type_arg: crate::lightning::ln::features::ChannelTypeFeatures, mut short_channel_id_arg: crate::c_types::derived::COption_u64Z, mut outbound_scid_alias_arg: crate::c_types::derived::COption_u64Z, mut inbound_scid_alias_arg: crate::c_types::derived::COption_u64Z, mut channel_value_satoshis_arg: u64, mut unspendable_punishment_reserve_arg: crate::c_types::derived::COption_u64Z, mut user_channel_id_arg: crate::c_types::U128, mut feerate_sat_per_1000_weight_arg: crate::c_types::derived::COption_u32Z, mut balance_msat_arg: u64, mut outbound_capacity_msat_arg: u64, mut next_outbound_htlc_limit_msat_arg: u64, mut inbound_capacity_msat_arg: u64, mut confirmations_required_arg: crate::c_types::derived::COption_u32Z, mut confirmations_arg: crate::c_types::derived::COption_u32Z, mut force_close_spend_delay_arg: crate::c_types::derived::COption_u16Z, mut is_outbound_arg: bool, mut is_channel_ready_arg: bool, mut is_usable_arg: bool, mut is_public_arg: bool, mut inbound_htlc_minimum_msat_arg: crate::c_types::derived::COption_u64Z, mut inbound_htlc_maximum_msat_arg: crate::c_types::derived::COption_u64Z, mut config_arg: crate::lightning::util::config::ChannelConfig) -> ChannelDetails { +pub extern "C" fn ChannelDetails_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut counterparty_arg: crate::lightning::ln::channelmanager::ChannelCounterparty, mut funding_txo_arg: crate::lightning::chain::transaction::OutPoint, mut channel_type_arg: crate::lightning::ln::features::ChannelTypeFeatures, mut short_channel_id_arg: crate::c_types::derived::COption_u64Z, mut outbound_scid_alias_arg: crate::c_types::derived::COption_u64Z, mut inbound_scid_alias_arg: crate::c_types::derived::COption_u64Z, mut channel_value_satoshis_arg: u64, mut unspendable_punishment_reserve_arg: crate::c_types::derived::COption_u64Z, mut user_channel_id_arg: crate::c_types::U128, mut feerate_sat_per_1000_weight_arg: crate::c_types::derived::COption_u32Z, mut balance_msat_arg: u64, mut outbound_capacity_msat_arg: u64, mut next_outbound_htlc_limit_msat_arg: u64, mut next_outbound_htlc_minimum_msat_arg: u64, mut inbound_capacity_msat_arg: u64, mut confirmations_required_arg: crate::c_types::derived::COption_u32Z, mut confirmations_arg: crate::c_types::derived::COption_u32Z, mut force_close_spend_delay_arg: crate::c_types::derived::COption_u16Z, mut is_outbound_arg: bool, mut is_channel_ready_arg: bool, mut channel_shutdown_state_arg: crate::c_types::derived::COption_ChannelShutdownStateZ, mut is_usable_arg: bool, mut is_public_arg: bool, mut inbound_htlc_minimum_msat_arg: crate::c_types::derived::COption_u64Z, mut inbound_htlc_maximum_msat_arg: crate::c_types::derived::COption_u64Z, mut config_arg: crate::lightning::util::config::ChannelConfig) -> ChannelDetails { let mut local_funding_txo_arg = if funding_txo_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(funding_txo_arg.take_inner()) } }) }; let mut local_channel_type_arg = if channel_type_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(channel_type_arg.take_inner()) } }) }; let mut local_short_channel_id_arg = if short_channel_id_arg.is_some() { Some( { short_channel_id_arg.take() }) } else { None }; @@ -1237,6 +1273,7 @@ pub extern "C" fn ChannelDetails_new(mut channel_id_arg: crate::c_types::ThirtyT let mut local_confirmations_required_arg = if confirmations_required_arg.is_some() { Some( { confirmations_required_arg.take() }) } else { None }; let mut local_confirmations_arg = if confirmations_arg.is_some() { Some( { confirmations_arg.take() }) } else { None }; let mut local_force_close_spend_delay_arg = if force_close_spend_delay_arg.is_some() { Some( { force_close_spend_delay_arg.take() }) } else { None }; + let mut local_channel_shutdown_state_arg = { /*channel_shutdown_state_arg*/ let channel_shutdown_state_arg_opt = channel_shutdown_state_arg; if channel_shutdown_state_arg_opt.is_none() { None } else { Some({ { { channel_shutdown_state_arg_opt.take() }.into_native() }})} }; let mut local_inbound_htlc_minimum_msat_arg = if inbound_htlc_minimum_msat_arg.is_some() { Some( { inbound_htlc_minimum_msat_arg.take() }) } else { None }; let mut local_inbound_htlc_maximum_msat_arg = if inbound_htlc_maximum_msat_arg.is_some() { Some( { inbound_htlc_maximum_msat_arg.take() }) } else { None }; let mut local_config_arg = if config_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(config_arg.take_inner()) } }) }; @@ -1255,12 +1292,14 @@ pub extern "C" fn ChannelDetails_new(mut channel_id_arg: crate::c_types::ThirtyT balance_msat: balance_msat_arg, outbound_capacity_msat: outbound_capacity_msat_arg, next_outbound_htlc_limit_msat: next_outbound_htlc_limit_msat_arg, + next_outbound_htlc_minimum_msat: next_outbound_htlc_minimum_msat_arg, inbound_capacity_msat: inbound_capacity_msat_arg, confirmations_required: local_confirmations_required_arg, confirmations: local_confirmations_arg, force_close_spend_delay: local_force_close_spend_delay_arg, is_outbound: is_outbound_arg, is_channel_ready: is_channel_ready_arg, + channel_shutdown_state: local_channel_shutdown_state_arg, is_usable: is_usable_arg, is_public: is_public_arg, inbound_htlc_minimum_msat: local_inbound_htlc_minimum_msat_arg, @@ -1315,6 +1354,105 @@ pub extern "C" fn ChannelDetails_get_outbound_payment_scid(this_arg: &crate::lig local_ret } +/// Further information on the details of the channel shutdown. +/// Upon channels being forced closed (i.e. commitment transaction confirmation detected +/// by `ChainMonitor`), ChannelShutdownState will be set to `ShutdownComplete` or +/// the channel will be removed shortly. +/// Also note, that in normal operation, peers could disconnect at any of these states +/// and require peer re-connection before making progress onto other states +#[derive(Clone)] +#[must_use] +#[repr(C)] +pub enum ChannelShutdownState { + /// Channel has not sent or received a shutdown message. + NotShuttingDown, + /// Local node has sent a shutdown message for this channel. + ShutdownInitiated, + /// Shutdown message exchanges have concluded and the channels are in the midst of + /// resolving all existing open HTLCs before closing can continue. + ResolvingHTLCs, + /// All HTLCs have been resolved, nodes are currently negotiating channel close onchain fee rates. + NegotiatingClosingFee, + /// We've successfully negotiated a closing_signed dance. At this point `ChannelManager` is about + /// to drop the channel. + ShutdownComplete, +} +use lightning::ln::channelmanager::ChannelShutdownState as ChannelShutdownStateImport; +pub(crate) type nativeChannelShutdownState = ChannelShutdownStateImport; + +impl ChannelShutdownState { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeChannelShutdownState { + match self { + ChannelShutdownState::NotShuttingDown => nativeChannelShutdownState::NotShuttingDown, + ChannelShutdownState::ShutdownInitiated => nativeChannelShutdownState::ShutdownInitiated, + ChannelShutdownState::ResolvingHTLCs => nativeChannelShutdownState::ResolvingHTLCs, + ChannelShutdownState::NegotiatingClosingFee => nativeChannelShutdownState::NegotiatingClosingFee, + ChannelShutdownState::ShutdownComplete => nativeChannelShutdownState::ShutdownComplete, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeChannelShutdownState { + match self { + ChannelShutdownState::NotShuttingDown => nativeChannelShutdownState::NotShuttingDown, + ChannelShutdownState::ShutdownInitiated => nativeChannelShutdownState::ShutdownInitiated, + ChannelShutdownState::ResolvingHTLCs => nativeChannelShutdownState::ResolvingHTLCs, + ChannelShutdownState::NegotiatingClosingFee => nativeChannelShutdownState::NegotiatingClosingFee, + ChannelShutdownState::ShutdownComplete => nativeChannelShutdownState::ShutdownComplete, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &nativeChannelShutdownState) -> Self { + match native { + nativeChannelShutdownState::NotShuttingDown => ChannelShutdownState::NotShuttingDown, + nativeChannelShutdownState::ShutdownInitiated => ChannelShutdownState::ShutdownInitiated, + nativeChannelShutdownState::ResolvingHTLCs => ChannelShutdownState::ResolvingHTLCs, + nativeChannelShutdownState::NegotiatingClosingFee => ChannelShutdownState::NegotiatingClosingFee, + nativeChannelShutdownState::ShutdownComplete => ChannelShutdownState::ShutdownComplete, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeChannelShutdownState) -> Self { + match native { + nativeChannelShutdownState::NotShuttingDown => ChannelShutdownState::NotShuttingDown, + nativeChannelShutdownState::ShutdownInitiated => ChannelShutdownState::ShutdownInitiated, + nativeChannelShutdownState::ResolvingHTLCs => ChannelShutdownState::ResolvingHTLCs, + nativeChannelShutdownState::NegotiatingClosingFee => ChannelShutdownState::NegotiatingClosingFee, + nativeChannelShutdownState::ShutdownComplete => ChannelShutdownState::ShutdownComplete, + } + } +} +/// Creates a copy of the ChannelShutdownState +#[no_mangle] +pub extern "C" fn ChannelShutdownState_clone(orig: &ChannelShutdownState) -> ChannelShutdownState { + orig.clone() +} +#[no_mangle] +/// Utility method to constructs a new NotShuttingDown-variant ChannelShutdownState +pub extern "C" fn ChannelShutdownState_not_shutting_down() -> ChannelShutdownState { + ChannelShutdownState::NotShuttingDown} +#[no_mangle] +/// Utility method to constructs a new ShutdownInitiated-variant ChannelShutdownState +pub extern "C" fn ChannelShutdownState_shutdown_initiated() -> ChannelShutdownState { + ChannelShutdownState::ShutdownInitiated} +#[no_mangle] +/// Utility method to constructs a new ResolvingHTLCs-variant ChannelShutdownState +pub extern "C" fn ChannelShutdownState_resolving_htlcs() -> ChannelShutdownState { + ChannelShutdownState::ResolvingHTLCs} +#[no_mangle] +/// Utility method to constructs a new NegotiatingClosingFee-variant ChannelShutdownState +pub extern "C" fn ChannelShutdownState_negotiating_closing_fee() -> ChannelShutdownState { + ChannelShutdownState::NegotiatingClosingFee} +#[no_mangle] +/// Utility method to constructs a new ShutdownComplete-variant ChannelShutdownState +pub extern "C" fn ChannelShutdownState_shutdown_complete() -> ChannelShutdownState { + ChannelShutdownState::ShutdownComplete} +/// Checks if two ChannelShutdownStates contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +#[no_mangle] +pub extern "C" fn ChannelShutdownState_eq(a: &ChannelShutdownState, b: &ChannelShutdownState) -> bool { + if &a.to_native() == &b.to_native() { true } else { false } +} /// Used by [`ChannelManager::list_recent_payments`] to express the status of recent payments. /// These include payments that have yet to find a successful path, or have unresolved HTLCs. #[derive(Clone)] @@ -1336,9 +1474,7 @@ pub enum RecentPaymentDetails { Fulfilled { /// Hash of the payment that was claimed. `None` for serializations of [`ChannelManager`] /// made before LDK version 0.0.104. - /// - /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None - payment_hash: crate::c_types::ThirtyTwoBytes, + payment_hash: crate::c_types::derived::COption_PaymentHashZ, }, /// After a payment's retries are exhausted per the provided [`Retry`], or it is explicitly /// abandoned via [`ChannelManager::abandon_payment`], it is marked as abandoned until all @@ -1365,7 +1501,7 @@ impl RecentPaymentDetails { }, RecentPaymentDetails::Fulfilled {ref payment_hash, } => { let mut payment_hash_nonref = Clone::clone(payment_hash); - let mut local_payment_hash_nonref = if payment_hash_nonref.data == [0; 32] { None } else { Some( { ::lightning::ln::PaymentHash(payment_hash_nonref.data) }) }; + let mut local_payment_hash_nonref = { /*payment_hash_nonref*/ let payment_hash_nonref_opt = payment_hash_nonref; if payment_hash_nonref_opt.is_none() { None } else { Some({ { ::lightning::ln::PaymentHash({ payment_hash_nonref_opt.take() }.data) }})} }; nativeRecentPaymentDetails::Fulfilled { payment_hash: local_payment_hash_nonref, } @@ -1388,7 +1524,7 @@ impl RecentPaymentDetails { } }, RecentPaymentDetails::Fulfilled {mut payment_hash, } => { - let mut local_payment_hash = if payment_hash.data == [0; 32] { None } else { Some( { ::lightning::ln::PaymentHash(payment_hash.data) }) }; + let mut local_payment_hash = { /*payment_hash*/ let payment_hash_opt = payment_hash; if payment_hash_opt.is_none() { None } else { Some({ { ::lightning::ln::PaymentHash({ payment_hash_opt.take() }.data) }})} }; nativeRecentPaymentDetails::Fulfilled { payment_hash: local_payment_hash, } @@ -1413,7 +1549,7 @@ impl RecentPaymentDetails { }, nativeRecentPaymentDetails::Fulfilled {ref payment_hash, } => { let mut payment_hash_nonref = Clone::clone(payment_hash); - let mut local_payment_hash_nonref = if payment_hash_nonref.is_none() { crate::c_types::ThirtyTwoBytes::null() } else { { crate::c_types::ThirtyTwoBytes { data: (payment_hash_nonref.unwrap()).0 } } }; + let mut local_payment_hash_nonref = if payment_hash_nonref.is_none() { crate::c_types::derived::COption_PaymentHashZ::None } else { crate::c_types::derived::COption_PaymentHashZ::Some( { crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.unwrap().0 } }) }; RecentPaymentDetails::Fulfilled { payment_hash: local_payment_hash_nonref, } @@ -1436,7 +1572,7 @@ impl RecentPaymentDetails { } }, nativeRecentPaymentDetails::Fulfilled {mut payment_hash, } => { - let mut local_payment_hash = if payment_hash.is_none() { crate::c_types::ThirtyTwoBytes::null() } else { { crate::c_types::ThirtyTwoBytes { data: (payment_hash.unwrap()).0 } } }; + let mut local_payment_hash = if payment_hash.is_none() { crate::c_types::derived::COption_PaymentHashZ::None } else { crate::c_types::derived::COption_PaymentHashZ::Some( { crate::c_types::ThirtyTwoBytes { data: payment_hash.unwrap().0 } }) }; RecentPaymentDetails::Fulfilled { payment_hash: local_payment_hash, } @@ -1467,7 +1603,7 @@ pub extern "C" fn RecentPaymentDetails_pending(payment_hash: crate::c_types::Thi } #[no_mangle] /// Utility method to constructs a new Fulfilled-variant RecentPaymentDetails -pub extern "C" fn RecentPaymentDetails_fulfilled(payment_hash: crate::c_types::ThirtyTwoBytes) -> RecentPaymentDetails { +pub extern "C" fn RecentPaymentDetails_fulfilled(payment_hash: crate::c_types::derived::COption_PaymentHashZ) -> RecentPaymentDetails { RecentPaymentDetails::Fulfilled { payment_hash, } @@ -1485,7 +1621,7 @@ pub(crate) type nativePhantomRouteHints = nativePhantomRouteHintsImport; /// Route hints used in constructing invoices for [phantom node payents]. /// -/// [phantom node payments]: crate::chain::keysinterface::PhantomKeysManager +/// [phantom node payments]: crate::sign::PhantomKeysManager #[must_use] #[repr(C)] pub struct PhantomRouteHints { @@ -1601,6 +1737,8 @@ pub extern "C" fn PhantomRouteHints_clone(orig: &PhantomRouteHints) -> PhantomRo } /// Constructs a new `ChannelManager` to hold several channels and route between them. /// +/// The current time or latest block header time can be provided as the `current_timestamp`. +/// /// This is the main \"logic hub\" for all channel-related actions, and implements /// [`ChannelMessageHandler`]. /// @@ -1616,8 +1754,8 @@ pub extern "C" fn PhantomRouteHints_clone(orig: &PhantomRouteHints) -> PhantomRo /// [`params.best_block.block_hash`]: chain::BestBlock::block_hash #[must_use] #[no_mangle] -pub extern "C" fn ChannelManager_new(mut fee_est: crate::lightning::chain::chaininterface::FeeEstimator, mut chain_monitor: crate::lightning::chain::Watch, mut tx_broadcaster: crate::lightning::chain::chaininterface::BroadcasterInterface, mut router: crate::lightning::routing::router::Router, mut logger: crate::lightning::util::logger::Logger, mut entropy_source: crate::lightning::chain::keysinterface::EntropySource, mut node_signer: crate::lightning::chain::keysinterface::NodeSigner, mut signer_provider: crate::lightning::chain::keysinterface::SignerProvider, mut config: crate::lightning::util::config::UserConfig, mut params: crate::lightning::ln::channelmanager::ChainParameters) -> crate::lightning::ln::channelmanager::ChannelManager { - let mut ret = lightning::ln::channelmanager::ChannelManager::new(fee_est, chain_monitor, tx_broadcaster, router, logger, entropy_source, node_signer, signer_provider, *unsafe { Box::from_raw(config.take_inner()) }, *unsafe { Box::from_raw(params.take_inner()) }); +pub extern "C" fn ChannelManager_new(mut fee_est: crate::lightning::chain::chaininterface::FeeEstimator, mut chain_monitor: crate::lightning::chain::Watch, mut tx_broadcaster: crate::lightning::chain::chaininterface::BroadcasterInterface, mut router: crate::lightning::routing::router::Router, mut logger: crate::lightning::util::logger::Logger, mut entropy_source: crate::lightning::sign::EntropySource, mut node_signer: crate::lightning::sign::NodeSigner, mut signer_provider: crate::lightning::sign::SignerProvider, mut config: crate::lightning::util::config::UserConfig, mut params: crate::lightning::ln::channelmanager::ChainParameters, mut current_timestamp: u32) -> crate::lightning::ln::channelmanager::ChannelManager { + let mut ret = lightning::ln::channelmanager::ChannelManager::new(fee_est, chain_monitor, tx_broadcaster, router, logger, entropy_source, node_signer, signer_provider, *unsafe { Box::from_raw(config.take_inner()) }, *unsafe { Box::from_raw(params.take_inner()) }, current_timestamp); crate::lightning::ln::channelmanager::ChannelManager { inner: ObjOps::heap_alloc(ret), is_owned: true } } @@ -1640,6 +1778,10 @@ pub extern "C" fn ChannelManager_get_current_default_configuration(this_arg: &cr /// Raises [`APIError::APIMisuseError`] when `channel_value_satoshis` > 2**24 or `push_msat` is /// greater than `channel_value_satoshis * 1k` or `channel_value_satoshis < 1000`. /// +/// Raises [`APIError::ChannelUnavailable`] if the channel cannot be opened due to failing to +/// generate a shutdown scriptpubkey or destination script set by +/// [`SignerProvider::get_shutdown_scriptpubkey`] or [`SignerProvider::get_destination_script`]. +/// /// Note that we do not check if you are currently connected to the given peer. If no /// connection is available, the outbound `open_channel` message may fail to send, resulting in /// the channel eventually being silently forgotten (dropped on reload). @@ -1728,6 +1870,11 @@ pub extern "C" fn ChannelManager_list_recent_payments(this_arg: &crate::lightnin /// /// May generate a [`SendShutdown`] message event on success, which should be relayed. /// +/// Raises [`APIError::ChannelUnavailable`] if the channel cannot be closed due to failing to +/// generate a shutdown scriptpubkey or destination script set by +/// [`SignerProvider::get_shutdown_scriptpubkey`]. A force-closure may be needed to close the +/// channel. +/// /// [`ChannelConfig::force_close_avoidance_max_fee_satoshis`]: crate::util::config::ChannelConfig::force_close_avoidance_max_fee_satoshis /// [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background /// [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal @@ -1754,16 +1901,30 @@ pub extern "C" fn ChannelManager_close_channel(this_arg: &crate::lightning::ln:: /// transaction feerate below `target_feerate_sat_per_1000_weight` (or the feerate which /// will appear on a force-closure transaction, whichever is lower). /// +/// The `shutdown_script` provided will be used as the `scriptPubKey` for the closing transaction. +/// Will fail if a shutdown script has already been set for this channel by +/// ['ChannelHandshakeConfig::commit_upfront_shutdown_pubkey`]. The given shutdown script must +/// also be compatible with our and the counterparty's features. +/// /// May generate a [`SendShutdown`] message event on success, which should be relayed. /// +/// Raises [`APIError::ChannelUnavailable`] if the channel cannot be closed due to failing to +/// generate a shutdown scriptpubkey or destination script set by +/// [`SignerProvider::get_shutdown_scriptpubkey`]. A force-closure may be needed to close the +/// channel. +/// /// [`ChannelConfig::force_close_avoidance_max_fee_satoshis`]: crate::util::config::ChannelConfig::force_close_avoidance_max_fee_satoshis /// [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background /// [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal /// [`SendShutdown`]: crate::events::MessageSendEvent::SendShutdown +/// +/// Note that shutdown_script (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn ChannelManager_close_channel_with_target_feerate(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, channel_id: *const [u8; 32], mut counterparty_node_id: crate::c_types::PublicKey, mut target_feerate_sats_per_1000_weight: u32) -> crate::c_types::derived::CResult_NoneAPIErrorZ { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.close_channel_with_target_feerate(unsafe { &*channel_id}, &counterparty_node_id.into_rust(), target_feerate_sats_per_1000_weight); +pub extern "C" fn ChannelManager_close_channel_with_feerate_and_script(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, channel_id: *const [u8; 32], mut counterparty_node_id: crate::c_types::PublicKey, mut target_feerate_sats_per_1000_weight: crate::c_types::derived::COption_u32Z, mut shutdown_script: crate::lightning::ln::script::ShutdownScript) -> crate::c_types::derived::CResult_NoneAPIErrorZ { + let mut local_target_feerate_sats_per_1000_weight = if target_feerate_sats_per_1000_weight.is_some() { Some( { target_feerate_sats_per_1000_weight.take() }) } else { None }; + let mut local_shutdown_script = if shutdown_script.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(shutdown_script.take_inner()) } }) }; + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.close_channel_with_feerate_and_script(unsafe { &*channel_id}, &counterparty_node_id.into_rust(), local_target_feerate_sats_per_1000_weight, local_shutdown_script); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() }; local_ret } @@ -1854,6 +2015,7 @@ pub extern "C" fn ChannelManager_force_close_all_channels_without_broadcasting_t /// irrevocably committed to on our end. In such a case, do NOT retry the payment with a /// different route unless you intend to pay twice! /// +/// [`RouteHop`]: crate::routing::router::RouteHop /// [`Event::PaymentSent`]: events::Event::PaymentSent /// [`Event::PaymentFailed`]: events::Event::PaymentFailed /// [`UpdateHTLCs`]: events::MessageSendEvent::UpdateHTLCs @@ -1867,7 +2029,7 @@ pub extern "C" fn ChannelManager_send_payment_with_route(this_arg: &crate::light local_ret } -/// Similar to [`ChannelManager::send_payment`], but will automatically find a route based on +/// Similar to [`ChannelManager::send_payment_with_route`], but will automatically find a route based on /// `route_params` and retry failed payment paths based on `retry_strategy`. #[must_use] #[no_mangle] @@ -1910,15 +2072,11 @@ pub extern "C" fn ChannelManager_abandon_payment(this_arg: &crate::lightning::ln /// Similar to regular payments, you MUST NOT reuse a `payment_preimage` value. See /// [`send_payment`] for more information about the risks of duplicate preimage usage. /// -/// Note that `route` must have exactly one path. -/// /// [`send_payment`]: Self::send_payment -/// -/// Note that payment_preimage (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn ChannelManager_send_spontaneous_payment(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, route: &crate::lightning::routing::router::Route, mut payment_preimage: crate::c_types::ThirtyTwoBytes, mut recipient_onion: crate::lightning::ln::outbound_payment::RecipientOnionFields, mut payment_id: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_PaymentHashPaymentSendFailureZ { - let mut local_payment_preimage = if payment_preimage.data == [0; 32] { None } else { Some( { ::lightning::ln::PaymentPreimage(payment_preimage.data) }) }; +pub extern "C" fn ChannelManager_send_spontaneous_payment(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, route: &crate::lightning::routing::router::Route, mut payment_preimage: crate::c_types::derived::COption_PaymentPreimageZ, mut recipient_onion: crate::lightning::ln::outbound_payment::RecipientOnionFields, mut payment_id: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_PaymentHashPaymentSendFailureZ { + let mut local_payment_preimage = { /*payment_preimage*/ let payment_preimage_opt = payment_preimage; if payment_preimage_opt.is_none() { None } else { Some({ { ::lightning::ln::PaymentPreimage({ payment_preimage_opt.take() }.data) }})} }; let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.send_spontaneous_payment(route.get_native_ref(), local_payment_preimage, *unsafe { Box::from_raw(recipient_onion.take_inner()) }, ::lightning::ln::channelmanager::PaymentId(payment_id.data)); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ThirtyTwoBytes { data: o.0 } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::outbound_payment::PaymentSendFailure::native_into(e) }).into() }; local_ret @@ -1931,12 +2089,10 @@ pub extern "C" fn ChannelManager_send_spontaneous_payment(this_arg: &crate::ligh /// payments. /// /// [`PaymentParameters::for_keysend`]: crate::routing::router::PaymentParameters::for_keysend -/// -/// Note that payment_preimage (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn ChannelManager_send_spontaneous_payment_with_retry(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut payment_preimage: crate::c_types::ThirtyTwoBytes, mut recipient_onion: crate::lightning::ln::outbound_payment::RecipientOnionFields, mut payment_id: crate::c_types::ThirtyTwoBytes, mut route_params: crate::lightning::routing::router::RouteParameters, mut retry_strategy: crate::lightning::ln::outbound_payment::Retry) -> crate::c_types::derived::CResult_PaymentHashRetryableSendFailureZ { - let mut local_payment_preimage = if payment_preimage.data == [0; 32] { None } else { Some( { ::lightning::ln::PaymentPreimage(payment_preimage.data) }) }; +pub extern "C" fn ChannelManager_send_spontaneous_payment_with_retry(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut payment_preimage: crate::c_types::derived::COption_PaymentPreimageZ, mut recipient_onion: crate::lightning::ln::outbound_payment::RecipientOnionFields, mut payment_id: crate::c_types::ThirtyTwoBytes, mut route_params: crate::lightning::routing::router::RouteParameters, mut retry_strategy: crate::lightning::ln::outbound_payment::Retry) -> crate::c_types::derived::CResult_PaymentHashRetryableSendFailureZ { + let mut local_payment_preimage = { /*payment_preimage*/ let payment_preimage_opt = payment_preimage; if payment_preimage_opt.is_none() { None } else { Some({ { ::lightning::ln::PaymentPreimage({ payment_preimage_opt.take() }.data) }})} }; let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.send_spontaneous_payment_with_retry(local_payment_preimage, *unsafe { Box::from_raw(recipient_onion.take_inner()) }, ::lightning::ln::channelmanager::PaymentId(payment_id.data), *unsafe { Box::from_raw(route_params.take_inner()) }, retry_strategy.into_native()); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ThirtyTwoBytes { data: o.0 } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::outbound_payment::RetryableSendFailure::native_into(e) }).into() }; local_ret @@ -1991,6 +2147,37 @@ pub extern "C" fn ChannelManager_funding_transaction_generated(this_arg: &crate: local_ret } +/// Atomically applies partial updates to the [`ChannelConfig`] of the given channels. +/// +/// Once the updates are applied, each eligible channel (advertised with a known short channel +/// ID and a change in [`forwarding_fee_proportional_millionths`], [`forwarding_fee_base_msat`], +/// or [`cltv_expiry_delta`]) has a [`BroadcastChannelUpdate`] event message generated +/// containing the new [`ChannelUpdate`] message which should be broadcast to the network. +/// +/// Returns [`ChannelUnavailable`] when a channel is not found or an incorrect +/// `counterparty_node_id` is provided. +/// +/// Returns [`APIMisuseError`] when a [`cltv_expiry_delta`] update is to be applied with a value +/// below [`MIN_CLTV_EXPIRY_DELTA`]. +/// +/// If an error is returned, none of the updates should be considered applied. +/// +/// [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths +/// [`forwarding_fee_base_msat`]: ChannelConfig::forwarding_fee_base_msat +/// [`cltv_expiry_delta`]: ChannelConfig::cltv_expiry_delta +/// [`BroadcastChannelUpdate`]: events::MessageSendEvent::BroadcastChannelUpdate +/// [`ChannelUpdate`]: msgs::ChannelUpdate +/// [`ChannelUnavailable`]: APIError::ChannelUnavailable +/// [`APIMisuseError`]: APIError::APIMisuseError +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelManager_update_partial_channel_config(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut counterparty_node_id: crate::c_types::PublicKey, mut channel_ids: crate::c_types::derived::CVec_ThirtyTwoBytesZ, config_update: &crate::lightning::util::config::ChannelConfigUpdate) -> crate::c_types::derived::CResult_NoneAPIErrorZ { + let mut local_channel_ids = Vec::new(); for mut item in channel_ids.into_rust().drain(..) { local_channel_ids.push( { item.data }); }; + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.update_partial_channel_config(&counterparty_node_id.into_rust(), &local_channel_ids.iter().map(|a| *a).collect::>()[..], config_update.get_native_ref()); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() }; + local_ret +} + /// Atomically updates the [`ChannelConfig`] for the given channels. /// /// Once the updates are applied, each eligible channel (advertised with a known short channel @@ -2035,13 +2222,16 @@ pub extern "C" fn ChannelManager_update_channel_config(this_arg: &crate::lightni /// [`ChannelManager::fail_intercepted_htlc`] MUST be called in response to the event. /// /// Note that LDK does not enforce fee requirements in `amt_to_forward_msat`, and will not stop -/// you from forwarding more than you received. +/// you from forwarding more than you received. See +/// [`HTLCIntercepted::expected_outbound_amount_msat`] for more on forwarding a different amount +/// than expected. /// /// Errors if the event was not handled in time, in which case the HTLC was automatically failed /// backwards. /// /// [`UserConfig::accept_intercept_htlcs`]: crate::util::config::UserConfig::accept_intercept_htlcs /// [`HTLCIntercepted`]: events::Event::HTLCIntercepted +/// [`HTLCIntercepted::expected_outbound_amount_msat`]: events::Event::HTLCIntercepted::expected_outbound_amount_msat #[must_use] #[no_mangle] pub extern "C" fn ChannelManager_forward_intercepted_htlc(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut intercept_id: crate::c_types::ThirtyTwoBytes, next_hop_channel_id: *const [u8; 32], mut next_node_id: crate::c_types::PublicKey, mut amt_to_forward_msat: u64) -> crate::c_types::derived::CResult_NoneAPIErrorZ { @@ -2084,6 +2274,7 @@ pub extern "C" fn ChannelManager_process_pending_htlc_forwards(this_arg: &crate: /// * Expiring a channel's previous [`ChannelConfig`] if necessary to only allow forwarding HTLCs /// with the current [`ChannelConfig`]. /// * Removing peers which have disconnected but and no longer have any channels. +/// * Force-closing and removing channels which have not completed establishment in a timely manner. /// /// Note that this may cause reentrancy through [`chain::Watch::update_channel`] calls or feerate /// estimate fetches. @@ -2246,24 +2437,6 @@ pub extern "C" fn ChannelManager_create_inbound_payment(this_arg: &crate::lightn local_ret } -/// Legacy version of [`create_inbound_payment`]. Use this method if you wish to share -/// serialized state with LDK node(s) running 0.0.103 and earlier. -/// -/// May panic if `invoice_expiry_delta_secs` is greater than one year. -/// -/// # Note -/// This method is deprecated and will be removed soon. -/// -/// [`create_inbound_payment`]: Self::create_inbound_payment -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelManager_create_inbound_payment_legacy(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut min_value_msat: crate::c_types::derived::COption_u64Z, mut invoice_expiry_delta_secs: u32) -> crate::c_types::derived::CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ { - let mut local_min_value_msat = if min_value_msat.is_some() { Some( { min_value_msat.take() }) } else { None }; - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.create_inbound_payment_legacy(local_min_value_msat, invoice_expiry_delta_secs); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = o; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0.0 }, crate::c_types::ThirtyTwoBytes { data: orig_ret_0_1.0 }).into(); local_ret_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() }; - local_ret -} - /// Gets a [`PaymentSecret`] for a given [`PaymentHash`], for which the payment preimage is /// stored external to LDK. /// @@ -2320,24 +2493,6 @@ pub extern "C" fn ChannelManager_create_inbound_payment_for_hash(this_arg: &crat local_ret } -/// Legacy version of [`create_inbound_payment_for_hash`]. Use this method if you wish to share -/// serialized state with LDK node(s) running 0.0.103 and earlier. -/// -/// May panic if `invoice_expiry_delta_secs` is greater than one year. -/// -/// # Note -/// This method is deprecated and will be removed soon. -/// -/// [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelManager_create_inbound_payment_for_hash_legacy(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut payment_hash: crate::c_types::ThirtyTwoBytes, mut min_value_msat: crate::c_types::derived::COption_u64Z, mut invoice_expiry_delta_secs: u32) -> crate::c_types::derived::CResult_PaymentSecretAPIErrorZ { - let mut local_min_value_msat = if min_value_msat.is_some() { Some( { min_value_msat.take() }) } else { None }; - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.create_inbound_payment_for_hash_legacy(::lightning::ln::PaymentHash(payment_hash.data), local_min_value_msat, invoice_expiry_delta_secs); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ThirtyTwoBytes { data: o.0 } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() }; - local_ret -} - /// Gets an LDK-generated payment preimage from a payment hash and payment secret that were /// previously returned from [`create_inbound_payment`]. /// @@ -2353,7 +2508,7 @@ pub extern "C" fn ChannelManager_get_payment_preimage(this_arg: &crate::lightnin /// Gets a fake short channel id for use in receiving [phantom node payments]. These fake scids /// are used when constructing the phantom invoice's route hints. /// -/// [phantom node payments]: crate::chain::keysinterface::PhantomKeysManager +/// [phantom node payments]: crate::sign::PhantomKeysManager #[must_use] #[no_mangle] pub extern "C" fn ChannelManager_get_phantom_scid(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> u64 { @@ -2363,7 +2518,7 @@ pub extern "C" fn ChannelManager_get_phantom_scid(this_arg: &crate::lightning::l /// Gets route hints for use in receiving [phantom node payments]. /// -/// [phantom node payments]: crate::chain::keysinterface::PhantomKeysManager +/// [phantom node payments]: crate::sign::PhantomKeysManager #[must_use] #[no_mangle] pub extern "C" fn ChannelManager_get_phantom_route_hints(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::lightning::ln::channelmanager::PhantomRouteHints { @@ -2515,9 +2670,9 @@ extern "C" fn ChannelManager_Confirm_best_block_updated(this_arg: *const c_void, >::best_block_updated(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), height) } #[must_use] -extern "C" fn ChannelManager_Confirm_get_relevant_txids(this_arg: *const c_void) -> crate::c_types::derived::CVec_C2Tuple_TxidBlockHashZZ { +extern "C" fn ChannelManager_Confirm_get_relevant_txids(this_arg: *const c_void) -> crate::c_types::derived::CVec_C2Tuple_TxidCOption_BlockHashZZZ { let mut ret = >::get_relevant_txids(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, ); - let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item; let mut local_orig_ret_0_1 = if orig_ret_0_1.is_none() { crate::c_types::ThirtyTwoBytes::null() } else { { crate::c_types::ThirtyTwoBytes { data: (orig_ret_0_1.unwrap()).into_inner() } } }; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0.into_inner() }, local_orig_ret_0_1).into(); local_ret_0 }); }; + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item; let mut local_orig_ret_0_1 = if orig_ret_0_1.is_none() { crate::c_types::derived::COption_BlockHashZ::None } else { crate::c_types::derived::COption_BlockHashZ::Some( { crate::c_types::ThirtyTwoBytes { data: orig_ret_0_1.unwrap().into_inner() } }) }; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0.into_inner() }, local_orig_ret_0_1).into(); local_ret_0 }); }; local_ret.into() } @@ -2596,12 +2751,23 @@ pub extern "C" fn ChannelManager_as_ChannelMessageHandler(this_arg: &ChannelMana this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, free: None, handle_open_channel: ChannelManager_ChannelMessageHandler_handle_open_channel, + handle_open_channel_v2: ChannelManager_ChannelMessageHandler_handle_open_channel_v2, handle_accept_channel: ChannelManager_ChannelMessageHandler_handle_accept_channel, + handle_accept_channel_v2: ChannelManager_ChannelMessageHandler_handle_accept_channel_v2, handle_funding_created: ChannelManager_ChannelMessageHandler_handle_funding_created, handle_funding_signed: ChannelManager_ChannelMessageHandler_handle_funding_signed, handle_channel_ready: ChannelManager_ChannelMessageHandler_handle_channel_ready, handle_shutdown: ChannelManager_ChannelMessageHandler_handle_shutdown, handle_closing_signed: ChannelManager_ChannelMessageHandler_handle_closing_signed, + handle_tx_add_input: ChannelManager_ChannelMessageHandler_handle_tx_add_input, + handle_tx_add_output: ChannelManager_ChannelMessageHandler_handle_tx_add_output, + handle_tx_remove_input: ChannelManager_ChannelMessageHandler_handle_tx_remove_input, + handle_tx_remove_output: ChannelManager_ChannelMessageHandler_handle_tx_remove_output, + handle_tx_complete: ChannelManager_ChannelMessageHandler_handle_tx_complete, + handle_tx_signatures: ChannelManager_ChannelMessageHandler_handle_tx_signatures, + handle_tx_init_rbf: ChannelManager_ChannelMessageHandler_handle_tx_init_rbf, + handle_tx_ack_rbf: ChannelManager_ChannelMessageHandler_handle_tx_ack_rbf, + handle_tx_abort: ChannelManager_ChannelMessageHandler_handle_tx_abort, handle_update_add_htlc: ChannelManager_ChannelMessageHandler_handle_update_add_htlc, handle_update_fulfill_htlc: ChannelManager_ChannelMessageHandler_handle_update_fulfill_htlc, handle_update_fail_htlc: ChannelManager_ChannelMessageHandler_handle_update_fail_htlc, @@ -2617,6 +2783,7 @@ pub extern "C" fn ChannelManager_as_ChannelMessageHandler(this_arg: &ChannelMana handle_error: ChannelManager_ChannelMessageHandler_handle_error, provided_node_features: ChannelManager_ChannelMessageHandler_provided_node_features, provided_init_features: ChannelManager_ChannelMessageHandler_provided_init_features, + get_genesis_hashes: ChannelManager_ChannelMessageHandler_get_genesis_hashes, MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider { this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, free: None, @@ -2628,9 +2795,15 @@ pub extern "C" fn ChannelManager_as_ChannelMessageHandler(this_arg: &ChannelMana extern "C" fn ChannelManager_ChannelMessageHandler_handle_open_channel(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::OpenChannel) { >::handle_open_channel(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) } +extern "C" fn ChannelManager_ChannelMessageHandler_handle_open_channel_v2(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::OpenChannelV2) { + >::handle_open_channel_v2(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) +} extern "C" fn ChannelManager_ChannelMessageHandler_handle_accept_channel(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::AcceptChannel) { >::handle_accept_channel(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) } +extern "C" fn ChannelManager_ChannelMessageHandler_handle_accept_channel_v2(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::AcceptChannelV2) { + >::handle_accept_channel_v2(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) +} extern "C" fn ChannelManager_ChannelMessageHandler_handle_funding_created(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::FundingCreated) { >::handle_funding_created(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) } @@ -2646,6 +2819,33 @@ extern "C" fn ChannelManager_ChannelMessageHandler_handle_shutdown(this_arg: *co extern "C" fn ChannelManager_ChannelMessageHandler_handle_closing_signed(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ClosingSigned) { >::handle_closing_signed(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) } +extern "C" fn ChannelManager_ChannelMessageHandler_handle_tx_add_input(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxAddInput) { + >::handle_tx_add_input(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) +} +extern "C" fn ChannelManager_ChannelMessageHandler_handle_tx_add_output(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxAddOutput) { + >::handle_tx_add_output(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) +} +extern "C" fn ChannelManager_ChannelMessageHandler_handle_tx_remove_input(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxRemoveInput) { + >::handle_tx_remove_input(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) +} +extern "C" fn ChannelManager_ChannelMessageHandler_handle_tx_remove_output(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxRemoveOutput) { + >::handle_tx_remove_output(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) +} +extern "C" fn ChannelManager_ChannelMessageHandler_handle_tx_complete(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxComplete) { + >::handle_tx_complete(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) +} +extern "C" fn ChannelManager_ChannelMessageHandler_handle_tx_signatures(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxSignatures) { + >::handle_tx_signatures(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) +} +extern "C" fn ChannelManager_ChannelMessageHandler_handle_tx_init_rbf(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxInitRbf) { + >::handle_tx_init_rbf(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) +} +extern "C" fn ChannelManager_ChannelMessageHandler_handle_tx_ack_rbf(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxAckRbf) { + >::handle_tx_ack_rbf(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) +} +extern "C" fn ChannelManager_ChannelMessageHandler_handle_tx_abort(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxAbort) { + >::handle_tx_abort(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) +} extern "C" fn ChannelManager_ChannelMessageHandler_handle_update_add_htlc(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::UpdateAddHTLC) { >::handle_update_add_htlc(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) } @@ -2698,12 +2898,18 @@ extern "C" fn ChannelManager_ChannelMessageHandler_provided_init_features(this_a let mut ret = >::provided_init_features(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust()); crate::lightning::ln::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } +#[must_use] +extern "C" fn ChannelManager_ChannelMessageHandler_get_genesis_hashes(this_arg: *const c_void) -> crate::c_types::derived::COption_CVec_ChainHashZZ { + let mut ret = >::get_genesis_hashes(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, ); + let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_CVec_ChainHashZZ::None } else { crate::c_types::derived::COption_CVec_ChainHashZZ::Some( { let mut local_ret_0 = Vec::new(); for mut item in ret.unwrap().drain(..) { local_ret_0.push( { crate::c_types::ThirtyTwoBytes { data: item.to_bytes() } }); }; local_ret_0.into() }) }; + local_ret +} /// Fetches the set of [`InitFeatures`] flags which are provided by or required by /// [`ChannelManager`]. #[no_mangle] -pub extern "C" fn provided_init_features(_config: &crate::lightning::util::config::UserConfig) -> crate::lightning::ln::features::InitFeatures { - let mut ret = lightning::ln::channelmanager::provided_init_features(_config.get_native_ref()); +pub extern "C" fn provided_init_features(config: &crate::lightning::util::config::UserConfig) -> crate::lightning::ln::features::InitFeatures { + let mut ret = lightning::ln::channelmanager::provided_init_features(config.get_native_ref()); crate::lightning::ln::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } @@ -2780,9 +2986,21 @@ pub extern "C" fn ChannelManager_write(obj: &crate::lightning::ln::channelmanage pub(crate) extern "C" fn ChannelManager_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelManager) }) } +#[no_mangle] +/// Serialize the ChannelShutdownState object into a byte array which can be read by ChannelShutdownState_read +pub extern "C" fn ChannelShutdownState_write(obj: &crate::lightning::ln::channelmanager::ChannelShutdownState) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(&unsafe { &*obj }.to_native()) +} +#[no_mangle] +/// Read a ChannelShutdownState from a byte array, created by ChannelShutdownState_write +pub extern "C" fn ChannelShutdownState_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelShutdownStateDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::channelmanager::ChannelShutdownState::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} use lightning::ln::channelmanager::ChannelManagerReadArgs as nativeChannelManagerReadArgsImport; -pub(crate) type nativeChannelManagerReadArgs = nativeChannelManagerReadArgsImport<'static, crate::lightning::chain::Watch, crate::lightning::chain::chaininterface::BroadcasterInterface, crate::lightning::chain::keysinterface::EntropySource, crate::lightning::chain::keysinterface::NodeSigner, crate::lightning::chain::keysinterface::SignerProvider, crate::lightning::chain::chaininterface::FeeEstimator, crate::lightning::routing::router::Router, crate::lightning::util::logger::Logger>; +pub(crate) type nativeChannelManagerReadArgs = nativeChannelManagerReadArgsImport<'static, crate::lightning::chain::Watch, crate::lightning::chain::chaininterface::BroadcasterInterface, crate::lightning::sign::EntropySource, crate::lightning::sign::NodeSigner, crate::lightning::sign::SignerProvider, crate::lightning::chain::chaininterface::FeeEstimator, crate::lightning::routing::router::Router, crate::lightning::util::logger::Logger>; /// Arguments for the creation of a ChannelManager that are not deserialized. /// @@ -2864,31 +3082,31 @@ impl ChannelManagerReadArgs { } /// A cryptographically secure source of entropy. #[no_mangle] -pub extern "C" fn ChannelManagerReadArgs_get_entropy_source(this_ptr: &ChannelManagerReadArgs) -> *const crate::lightning::chain::keysinterface::EntropySource { +pub extern "C" fn ChannelManagerReadArgs_get_entropy_source(this_ptr: &ChannelManagerReadArgs) -> *const crate::lightning::sign::EntropySource { let mut inner_val = &mut this_ptr.get_native_mut_ref().entropy_source; inner_val } /// A cryptographically secure source of entropy. #[no_mangle] -pub extern "C" fn ChannelManagerReadArgs_set_entropy_source(this_ptr: &mut ChannelManagerReadArgs, mut val: crate::lightning::chain::keysinterface::EntropySource) { +pub extern "C" fn ChannelManagerReadArgs_set_entropy_source(this_ptr: &mut ChannelManagerReadArgs, mut val: crate::lightning::sign::EntropySource) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.entropy_source = val; } /// A signer that is able to perform node-scoped cryptographic operations. #[no_mangle] -pub extern "C" fn ChannelManagerReadArgs_get_node_signer(this_ptr: &ChannelManagerReadArgs) -> *const crate::lightning::chain::keysinterface::NodeSigner { +pub extern "C" fn ChannelManagerReadArgs_get_node_signer(this_ptr: &ChannelManagerReadArgs) -> *const crate::lightning::sign::NodeSigner { let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signer; inner_val } /// A signer that is able to perform node-scoped cryptographic operations. #[no_mangle] -pub extern "C" fn ChannelManagerReadArgs_set_node_signer(this_ptr: &mut ChannelManagerReadArgs, mut val: crate::lightning::chain::keysinterface::NodeSigner) { +pub extern "C" fn ChannelManagerReadArgs_set_node_signer(this_ptr: &mut ChannelManagerReadArgs, mut val: crate::lightning::sign::NodeSigner) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signer = val; } /// The keys provider which will give us relevant keys. Some keys will be loaded during /// deserialization and KeysInterface::read_chan_signer will be used to read per-Channel /// signing data. #[no_mangle] -pub extern "C" fn ChannelManagerReadArgs_get_signer_provider(this_ptr: &ChannelManagerReadArgs) -> *const crate::lightning::chain::keysinterface::SignerProvider { +pub extern "C" fn ChannelManagerReadArgs_get_signer_provider(this_ptr: &ChannelManagerReadArgs) -> *const crate::lightning::sign::SignerProvider { let mut inner_val = &mut this_ptr.get_native_mut_ref().signer_provider; inner_val } @@ -2896,7 +3114,7 @@ pub extern "C" fn ChannelManagerReadArgs_get_signer_provider(this_ptr: &ChannelM /// deserialization and KeysInterface::read_chan_signer will be used to read per-Channel /// signing data. #[no_mangle] -pub extern "C" fn ChannelManagerReadArgs_set_signer_provider(this_ptr: &mut ChannelManagerReadArgs, mut val: crate::lightning::chain::keysinterface::SignerProvider) { +pub extern "C" fn ChannelManagerReadArgs_set_signer_provider(this_ptr: &mut ChannelManagerReadArgs, mut val: crate::lightning::sign::SignerProvider) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signer_provider = val; } /// The fee_estimator for use in the ChannelManager in the future. @@ -2996,7 +3214,7 @@ pub extern "C" fn ChannelManagerReadArgs_set_default_config(this_ptr: &mut Chann /// populate a HashMap directly from C. #[must_use] #[no_mangle] -pub extern "C" fn ChannelManagerReadArgs_new(mut entropy_source: crate::lightning::chain::keysinterface::EntropySource, mut node_signer: crate::lightning::chain::keysinterface::NodeSigner, mut signer_provider: crate::lightning::chain::keysinterface::SignerProvider, mut fee_estimator: crate::lightning::chain::chaininterface::FeeEstimator, mut chain_monitor: crate::lightning::chain::Watch, mut tx_broadcaster: crate::lightning::chain::chaininterface::BroadcasterInterface, mut router: crate::lightning::routing::router::Router, mut logger: crate::lightning::util::logger::Logger, mut default_config: crate::lightning::util::config::UserConfig, mut channel_monitors: crate::c_types::derived::CVec_ChannelMonitorZ) -> crate::lightning::ln::channelmanager::ChannelManagerReadArgs { +pub extern "C" fn ChannelManagerReadArgs_new(mut entropy_source: crate::lightning::sign::EntropySource, mut node_signer: crate::lightning::sign::NodeSigner, mut signer_provider: crate::lightning::sign::SignerProvider, mut fee_estimator: crate::lightning::chain::chaininterface::FeeEstimator, mut chain_monitor: crate::lightning::chain::Watch, mut tx_broadcaster: crate::lightning::chain::chaininterface::BroadcasterInterface, mut router: crate::lightning::routing::router::Router, mut logger: crate::lightning::util::logger::Logger, mut default_config: crate::lightning::util::config::UserConfig, mut channel_monitors: crate::c_types::derived::CVec_ChannelMonitorZ) -> crate::lightning::ln::channelmanager::ChannelManagerReadArgs { let mut local_channel_monitors = Vec::new(); for mut item in channel_monitors.into_rust().drain(..) { local_channel_monitors.push( { item.get_native_mut_ref() }); }; let mut ret = lightning::ln::channelmanager::ChannelManagerReadArgs::new(entropy_source, node_signer, signer_provider, fee_estimator, chain_monitor, tx_broadcaster, router, logger, *unsafe { Box::from_raw(default_config.take_inner()) }, local_channel_monitors); crate::lightning::ln::channelmanager::ChannelManagerReadArgs { inner: ObjOps::heap_alloc(ret), is_owned: true } @@ -3006,7 +3224,7 @@ pub extern "C" fn ChannelManagerReadArgs_new(mut entropy_source: crate::lightnin /// Read a C2Tuple_BlockHashChannelManagerZ from a byte array, created by C2Tuple_BlockHashChannelManagerZ_write pub extern "C" fn C2Tuple_BlockHashChannelManagerZ_read(ser: crate::c_types::u8slice, arg: crate::lightning::ln::channelmanager::ChannelManagerReadArgs) -> crate::c_types::derived::CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ { let arg_conv = *unsafe { Box::from_raw(arg.take_inner()) }; - let res: Result<(bitcoin::hash_types::BlockHash, lightning::ln::channelmanager::ChannelManager), lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj_arg(ser, arg_conv); + let res: Result<(bitcoin::hash_types::BlockHash, lightning::ln::channelmanager::ChannelManager), lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj_arg(ser, arg_conv); let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_res_0_0, mut orig_res_0_1) = o; let mut local_res_0 = (crate::c_types::ThirtyTwoBytes { data: orig_res_0_0.into_inner() }, crate::lightning::ln::channelmanager::ChannelManager { inner: ObjOps::heap_alloc(orig_res_0_1), is_owned: true }).into(); local_res_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; local_res } diff --git a/lightning-c-bindings/src/lightning/ln/features.rs b/lightning-c-bindings/src/lightning/ln/features.rs index 7f8c8e8a..cb7453b1 100644 --- a/lightning-c-bindings/src/lightning/ln/features.rs +++ b/lightning-c-bindings/src/lightning/ln/features.rs @@ -63,6 +63,12 @@ //! [BOLT-3](https://github.com/lightning/bolts/blob/master/03-transactions.md) for more //! information). //! +//! LDK knows about the following features, but does not support them: +//! - `AnchorsNonzeroFeeHtlcTx` - the initial version of anchor outputs, which was later found to be +//! vulnerable (see this +//! [mailing list post](https://lists.linuxfoundation.org/pipermail/lightning-dev/2020-September/002796.html) +//! for more information). +//! //! [BOLT #9]: https://github.com/lightning/bolts/blob/master/09-features.md //! [messages]: crate::ln::msgs @@ -314,20 +320,20 @@ pub extern "C" fn NodeFeatures_supports_variable_length_onion(this_arg: &crate:: /// Set this feature as optional. #[no_mangle] -pub extern "C" fn InvoiceFeatures_set_variable_length_onion_optional(this_arg: &mut crate::lightning::ln::features::InvoiceFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInvoiceFeatures)) }.set_variable_length_onion_optional() +pub extern "C" fn Bolt11InvoiceFeatures_set_variable_length_onion_optional(this_arg: &mut crate::lightning::ln::features::Bolt11InvoiceFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeBolt11InvoiceFeatures)) }.set_variable_length_onion_optional() } /// Set this feature as required. #[no_mangle] -pub extern "C" fn InvoiceFeatures_set_variable_length_onion_required(this_arg: &mut crate::lightning::ln::features::InvoiceFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInvoiceFeatures)) }.set_variable_length_onion_required() +pub extern "C" fn Bolt11InvoiceFeatures_set_variable_length_onion_required(this_arg: &mut crate::lightning::ln::features::Bolt11InvoiceFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeBolt11InvoiceFeatures)) }.set_variable_length_onion_required() } /// Checks if this feature is supported. #[must_use] #[no_mangle] -pub extern "C" fn InvoiceFeatures_supports_variable_length_onion(this_arg: &crate::lightning::ln::features::InvoiceFeatures) -> bool { +pub extern "C" fn Bolt11InvoiceFeatures_supports_variable_length_onion(this_arg: &crate::lightning::ln::features::Bolt11InvoiceFeatures) -> bool { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_variable_length_onion(); ret } @@ -351,7 +357,7 @@ pub extern "C" fn NodeFeatures_requires_variable_length_onion(this_arg: &crate:: /// Checks if this feature is required. #[must_use] #[no_mangle] -pub extern "C" fn InvoiceFeatures_requires_variable_length_onion(this_arg: &crate::lightning::ln::features::InvoiceFeatures) -> bool { +pub extern "C" fn Bolt11InvoiceFeatures_requires_variable_length_onion(this_arg: &crate::lightning::ln::features::Bolt11InvoiceFeatures) -> bool { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_variable_length_onion(); ret } @@ -482,20 +488,20 @@ pub extern "C" fn NodeFeatures_supports_payment_secret(this_arg: &crate::lightni /// Set this feature as optional. #[no_mangle] -pub extern "C" fn InvoiceFeatures_set_payment_secret_optional(this_arg: &mut crate::lightning::ln::features::InvoiceFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInvoiceFeatures)) }.set_payment_secret_optional() +pub extern "C" fn Bolt11InvoiceFeatures_set_payment_secret_optional(this_arg: &mut crate::lightning::ln::features::Bolt11InvoiceFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeBolt11InvoiceFeatures)) }.set_payment_secret_optional() } /// Set this feature as required. #[no_mangle] -pub extern "C" fn InvoiceFeatures_set_payment_secret_required(this_arg: &mut crate::lightning::ln::features::InvoiceFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInvoiceFeatures)) }.set_payment_secret_required() +pub extern "C" fn Bolt11InvoiceFeatures_set_payment_secret_required(this_arg: &mut crate::lightning::ln::features::Bolt11InvoiceFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeBolt11InvoiceFeatures)) }.set_payment_secret_required() } /// Checks if this feature is supported. #[must_use] #[no_mangle] -pub extern "C" fn InvoiceFeatures_supports_payment_secret(this_arg: &crate::lightning::ln::features::InvoiceFeatures) -> bool { +pub extern "C" fn Bolt11InvoiceFeatures_supports_payment_secret(this_arg: &crate::lightning::ln::features::Bolt11InvoiceFeatures) -> bool { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_payment_secret(); ret } @@ -519,7 +525,7 @@ pub extern "C" fn NodeFeatures_requires_payment_secret(this_arg: &crate::lightni /// Checks if this feature is required. #[must_use] #[no_mangle] -pub extern "C" fn InvoiceFeatures_requires_payment_secret(this_arg: &crate::lightning::ln::features::InvoiceFeatures) -> bool { +pub extern "C" fn Bolt11InvoiceFeatures_requires_payment_secret(this_arg: &crate::lightning::ln::features::Bolt11InvoiceFeatures) -> bool { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_payment_secret(); ret } @@ -566,20 +572,20 @@ pub extern "C" fn NodeFeatures_supports_basic_mpp(this_arg: &crate::lightning::l /// Set this feature as optional. #[no_mangle] -pub extern "C" fn InvoiceFeatures_set_basic_mpp_optional(this_arg: &mut crate::lightning::ln::features::InvoiceFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInvoiceFeatures)) }.set_basic_mpp_optional() +pub extern "C" fn Bolt11InvoiceFeatures_set_basic_mpp_optional(this_arg: &mut crate::lightning::ln::features::Bolt11InvoiceFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeBolt11InvoiceFeatures)) }.set_basic_mpp_optional() } /// Set this feature as required. #[no_mangle] -pub extern "C" fn InvoiceFeatures_set_basic_mpp_required(this_arg: &mut crate::lightning::ln::features::InvoiceFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInvoiceFeatures)) }.set_basic_mpp_required() +pub extern "C" fn Bolt11InvoiceFeatures_set_basic_mpp_required(this_arg: &mut crate::lightning::ln::features::Bolt11InvoiceFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeBolt11InvoiceFeatures)) }.set_basic_mpp_required() } /// Checks if this feature is supported. #[must_use] #[no_mangle] -pub extern "C" fn InvoiceFeatures_supports_basic_mpp(this_arg: &crate::lightning::ln::features::InvoiceFeatures) -> bool { +pub extern "C" fn Bolt11InvoiceFeatures_supports_basic_mpp(this_arg: &crate::lightning::ln::features::Bolt11InvoiceFeatures) -> bool { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_basic_mpp(); ret } @@ -623,7 +629,7 @@ pub extern "C" fn NodeFeatures_requires_basic_mpp(this_arg: &crate::lightning::l /// Checks if this feature is required. #[must_use] #[no_mangle] -pub extern "C" fn InvoiceFeatures_requires_basic_mpp(this_arg: &crate::lightning::ln::features::InvoiceFeatures) -> bool { +pub extern "C" fn Bolt11InvoiceFeatures_requires_basic_mpp(this_arg: &crate::lightning::ln::features::Bolt11InvoiceFeatures) -> bool { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_basic_mpp(); ret } @@ -692,6 +698,90 @@ pub extern "C" fn NodeFeatures_requires_wumbo(this_arg: &crate::lightning::ln::f ret } +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn InitFeatures_set_anchors_nonzero_fee_htlc_tx_optional(this_arg: &mut crate::lightning::ln::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInitFeatures)) }.set_anchors_nonzero_fee_htlc_tx_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn InitFeatures_set_anchors_nonzero_fee_htlc_tx_required(this_arg: &mut crate::lightning::ln::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInitFeatures)) }.set_anchors_nonzero_fee_htlc_tx_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_supports_anchors_nonzero_fee_htlc_tx(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_anchors_nonzero_fee_htlc_tx(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_anchors_nonzero_fee_htlc_tx_optional(this_arg: &mut crate::lightning::ln::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeNodeFeatures)) }.set_anchors_nonzero_fee_htlc_tx_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_anchors_nonzero_fee_htlc_tx_required(this_arg: &mut crate::lightning::ln::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeNodeFeatures)) }.set_anchors_nonzero_fee_htlc_tx_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_supports_anchors_nonzero_fee_htlc_tx(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_anchors_nonzero_fee_htlc_tx(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_set_anchors_nonzero_fee_htlc_tx_optional(this_arg: &mut crate::lightning::ln::features::ChannelTypeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeChannelTypeFeatures)) }.set_anchors_nonzero_fee_htlc_tx_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_set_anchors_nonzero_fee_htlc_tx_required(this_arg: &mut crate::lightning::ln::features::ChannelTypeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeChannelTypeFeatures)) }.set_anchors_nonzero_fee_htlc_tx_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_supports_anchors_nonzero_fee_htlc_tx(this_arg: &crate::lightning::ln::features::ChannelTypeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_anchors_nonzero_fee_htlc_tx(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_requires_anchors_nonzero_fee_htlc_tx(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_anchors_nonzero_fee_htlc_tx(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_requires_anchors_nonzero_fee_htlc_tx(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_anchors_nonzero_fee_htlc_tx(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_requires_anchors_nonzero_fee_htlc_tx(this_arg: &crate::lightning::ln::features::ChannelTypeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_anchors_nonzero_fee_htlc_tx(); + ret +} + /// Set this feature as optional. #[no_mangle] pub extern "C" fn InitFeatures_set_anchors_zero_fee_htlc_tx_optional(this_arg: &mut crate::lightning::ln::features::InitFeatures) { @@ -1030,20 +1120,20 @@ pub extern "C" fn ChannelTypeFeatures_requires_scid_privacy(this_arg: &crate::li /// Set this feature as optional. #[no_mangle] -pub extern "C" fn InvoiceFeatures_set_payment_metadata_optional(this_arg: &mut crate::lightning::ln::features::InvoiceFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInvoiceFeatures)) }.set_payment_metadata_optional() +pub extern "C" fn Bolt11InvoiceFeatures_set_payment_metadata_optional(this_arg: &mut crate::lightning::ln::features::Bolt11InvoiceFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeBolt11InvoiceFeatures)) }.set_payment_metadata_optional() } /// Set this feature as required. #[no_mangle] -pub extern "C" fn InvoiceFeatures_set_payment_metadata_required(this_arg: &mut crate::lightning::ln::features::InvoiceFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInvoiceFeatures)) }.set_payment_metadata_required() +pub extern "C" fn Bolt11InvoiceFeatures_set_payment_metadata_required(this_arg: &mut crate::lightning::ln::features::Bolt11InvoiceFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeBolt11InvoiceFeatures)) }.set_payment_metadata_required() } /// Checks if this feature is supported. #[must_use] #[no_mangle] -pub extern "C" fn InvoiceFeatures_supports_payment_metadata(this_arg: &crate::lightning::ln::features::InvoiceFeatures) -> bool { +pub extern "C" fn Bolt11InvoiceFeatures_supports_payment_metadata(this_arg: &crate::lightning::ln::features::Bolt11InvoiceFeatures) -> bool { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_payment_metadata(); ret } @@ -1051,7 +1141,7 @@ pub extern "C" fn InvoiceFeatures_supports_payment_metadata(this_arg: &crate::li /// Checks if this feature is required. #[must_use] #[no_mangle] -pub extern "C" fn InvoiceFeatures_requires_payment_metadata(this_arg: &crate::lightning::ln::features::InvoiceFeatures) -> bool { +pub extern "C" fn Bolt11InvoiceFeatures_requires_payment_metadata(this_arg: &crate::lightning::ln::features::Bolt11InvoiceFeatures) -> bool { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_payment_metadata(); ret } @@ -1196,11 +1286,11 @@ pub extern "C" fn ChannelFeatures_eq(a: &ChannelFeatures, b: &ChannelFeatures) - if a.inner.is_null() || b.inner.is_null() { return false; } if a.get_native_ref() == b.get_native_ref() { true } else { false } } -/// Checks if two InvoiceFeaturess contain equal inner contents. +/// Checks if two Bolt11InvoiceFeaturess contain equal inner contents. /// This ignores pointers and is_owned flags and looks at the values in fields. /// Two objects with NULL inner values will be considered "equal" here. #[no_mangle] -pub extern "C" fn InvoiceFeatures_eq(a: &InvoiceFeatures, b: &InvoiceFeatures) -> bool { +pub extern "C" fn Bolt11InvoiceFeatures_eq(a: &Bolt11InvoiceFeatures, b: &Bolt11InvoiceFeatures) -> bool { if a.inner == b.inner { return true; } if a.inner.is_null() || b.inner.is_null() { return false; } if a.get_native_ref() == b.get_native_ref() { true } else { false } @@ -1307,10 +1397,10 @@ pub(crate) extern "C" fn ChannelFeatures_clone_void(this_ptr: *const c_void) -> pub extern "C" fn ChannelFeatures_clone(orig: &ChannelFeatures) -> ChannelFeatures { orig.clone() } -impl Clone for InvoiceFeatures { +impl Clone for Bolt11InvoiceFeatures { fn clone(&self) -> Self { Self { - inner: if <*mut nativeInvoiceFeatures>::is_null(self.inner) { core::ptr::null_mut() } else { + inner: if <*mut nativeBolt11InvoiceFeatures>::is_null(self.inner) { core::ptr::null_mut() } else { ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, is_owned: true, } @@ -1318,12 +1408,12 @@ impl Clone for InvoiceFeatures { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn InvoiceFeatures_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeInvoiceFeatures)).clone() })) as *mut c_void +pub(crate) extern "C" fn Bolt11InvoiceFeatures_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeBolt11InvoiceFeatures)).clone() })) as *mut c_void } #[no_mangle] -/// Creates a copy of the InvoiceFeatures -pub extern "C" fn InvoiceFeatures_clone(orig: &InvoiceFeatures) -> InvoiceFeatures { +/// Creates a copy of the Bolt11InvoiceFeatures +pub extern "C" fn Bolt11InvoiceFeatures_clone(orig: &Bolt11InvoiceFeatures) -> Bolt11InvoiceFeatures { orig.clone() } impl Clone for OfferFeatures { @@ -1575,18 +1665,18 @@ impl ChannelFeatures { } } -use lightning::ln::features::InvoiceFeatures as nativeInvoiceFeaturesImport; -pub(crate) type nativeInvoiceFeatures = nativeInvoiceFeaturesImport; +use lightning::ln::features::Bolt11InvoiceFeatures as nativeBolt11InvoiceFeaturesImport; +pub(crate) type nativeBolt11InvoiceFeatures = nativeBolt11InvoiceFeaturesImport; /// Features used within an invoice. #[must_use] #[repr(C)] -pub struct InvoiceFeatures { +pub struct Bolt11InvoiceFeatures { /// A pointer to the opaque Rust object. /// Nearly everywhere, inner must be non-null, however in places where /// the Rust equivalent takes an Option, it may be set to null to indicate None. - pub inner: *mut nativeInvoiceFeatures, + pub inner: *mut nativeBolt11InvoiceFeatures, /// Indicates that this is the only struct which contains the same pointer. /// Rust functions which take ownership of an object provided via an argument require @@ -1594,31 +1684,31 @@ pub struct InvoiceFeatures { pub is_owned: bool, } -impl Drop for InvoiceFeatures { +impl Drop for Bolt11InvoiceFeatures { fn drop(&mut self) { - if self.is_owned && !<*mut nativeInvoiceFeatures>::is_null(self.inner) { + if self.is_owned && !<*mut nativeBolt11InvoiceFeatures>::is_null(self.inner) { let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; } } } -/// Frees any resources used by the InvoiceFeatures, if is_owned is set and inner is non-NULL. +/// Frees any resources used by the Bolt11InvoiceFeatures, if is_owned is set and inner is non-NULL. #[no_mangle] -pub extern "C" fn InvoiceFeatures_free(this_obj: InvoiceFeatures) { } +pub extern "C" fn Bolt11InvoiceFeatures_free(this_obj: Bolt11InvoiceFeatures) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn InvoiceFeatures_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeInvoiceFeatures) }; +pub(crate) extern "C" fn Bolt11InvoiceFeatures_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeBolt11InvoiceFeatures) }; } #[allow(unused)] -impl InvoiceFeatures { - pub(crate) fn get_native_ref(&self) -> &'static nativeInvoiceFeatures { +impl Bolt11InvoiceFeatures { + pub(crate) fn get_native_ref(&self) -> &'static nativeBolt11InvoiceFeatures { unsafe { &*ObjOps::untweak_ptr(self.inner) } } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInvoiceFeatures { + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeBolt11InvoiceFeatures { unsafe { &mut *ObjOps::untweak_ptr(self.inner) } } /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy - pub(crate) fn take_inner(mut self) -> *mut nativeInvoiceFeatures { + pub(crate) fn take_inner(mut self) -> *mut nativeBolt11InvoiceFeatures { assert!(self.is_owned); let ret = ObjOps::untweak_ptr(self.inner); self.inner = core::ptr::null_mut(); @@ -1897,6 +1987,14 @@ pub extern "C" fn InitFeatures_empty() -> crate::lightning::ln::features::InitFe crate::lightning::ln::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } +/// Returns true if this `Features` object contains required features unknown by `other`. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_requires_unknown_bits_from(this_arg: &crate::lightning::ln::features::InitFeatures, other: &crate::lightning::ln::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits_from(other.get_native_ref()); + ret +} + /// Returns true if this `Features` object contains unknown feature flags which are set as /// \"required\". #[must_use] @@ -1906,6 +2004,36 @@ pub extern "C" fn InitFeatures_requires_unknown_bits(this_arg: &crate::lightning ret } +/// Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined +/// by [bLIP 2] or if it is a known `T` feature. +/// +/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will +/// be set instead (i.e., `bit - 1`). +/// +/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_set_required_custom_bit(this_arg: &mut crate::lightning::ln::features::InitFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInitFeatures)) }.set_required_custom_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined +/// by [bLIP 2] or if it is a known `T` feature. +/// +/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be +/// set instead (i.e., `bit + 1`). +/// +/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_set_optional_custom_bit(this_arg: &mut crate::lightning::ln::features::InitFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInitFeatures)) }.set_optional_custom_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + /// Create a blank Features with no features set #[must_use] #[no_mangle] @@ -1914,6 +2042,14 @@ pub extern "C" fn NodeFeatures_empty() -> crate::lightning::ln::features::NodeFe crate::lightning::ln::features::NodeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } +/// Returns true if this `Features` object contains required features unknown by `other`. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_requires_unknown_bits_from(this_arg: &crate::lightning::ln::features::NodeFeatures, other: &crate::lightning::ln::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits_from(other.get_native_ref()); + ret +} + /// Returns true if this `Features` object contains unknown feature flags which are set as /// \"required\". #[must_use] @@ -1923,6 +2059,36 @@ pub extern "C" fn NodeFeatures_requires_unknown_bits(this_arg: &crate::lightning ret } +/// Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined +/// by [bLIP 2] or if it is a known `T` feature. +/// +/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will +/// be set instead (i.e., `bit - 1`). +/// +/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_set_required_custom_bit(this_arg: &mut crate::lightning::ln::features::NodeFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeNodeFeatures)) }.set_required_custom_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined +/// by [bLIP 2] or if it is a known `T` feature. +/// +/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be +/// set instead (i.e., `bit + 1`). +/// +/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_set_optional_custom_bit(this_arg: &mut crate::lightning::ln::features::NodeFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeNodeFeatures)) }.set_optional_custom_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + /// Create a blank Features with no features set #[must_use] #[no_mangle] @@ -1931,6 +2097,14 @@ pub extern "C" fn ChannelFeatures_empty() -> crate::lightning::ln::features::Cha crate::lightning::ln::features::ChannelFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } +/// Returns true if this `Features` object contains required features unknown by `other`. +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelFeatures_requires_unknown_bits_from(this_arg: &crate::lightning::ln::features::ChannelFeatures, other: &crate::lightning::ln::features::ChannelFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits_from(other.get_native_ref()); + ret +} + /// Returns true if this `Features` object contains unknown feature flags which are set as /// \"required\". #[must_use] @@ -1940,23 +2114,91 @@ pub extern "C" fn ChannelFeatures_requires_unknown_bits(this_arg: &crate::lightn ret } +/// Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined +/// by [bLIP 2] or if it is a known `T` feature. +/// +/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will +/// be set instead (i.e., `bit - 1`). +/// +/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelFeatures_set_required_custom_bit(this_arg: &mut crate::lightning::ln::features::ChannelFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeChannelFeatures)) }.set_required_custom_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined +/// by [bLIP 2] or if it is a known `T` feature. +/// +/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be +/// set instead (i.e., `bit + 1`). +/// +/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelFeatures_set_optional_custom_bit(this_arg: &mut crate::lightning::ln::features::ChannelFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeChannelFeatures)) }.set_optional_custom_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + /// Create a blank Features with no features set #[must_use] #[no_mangle] -pub extern "C" fn InvoiceFeatures_empty() -> crate::lightning::ln::features::InvoiceFeatures { - let mut ret = lightning::ln::features::InvoiceFeatures::empty(); - crate::lightning::ln::features::InvoiceFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } +pub extern "C" fn Bolt11InvoiceFeatures_empty() -> crate::lightning::ln::features::Bolt11InvoiceFeatures { + let mut ret = lightning::ln::features::Bolt11InvoiceFeatures::empty(); + crate::lightning::ln::features::Bolt11InvoiceFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Returns true if this `Features` object contains required features unknown by `other`. +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_requires_unknown_bits_from(this_arg: &crate::lightning::ln::features::Bolt11InvoiceFeatures, other: &crate::lightning::ln::features::Bolt11InvoiceFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits_from(other.get_native_ref()); + ret } /// Returns true if this `Features` object contains unknown feature flags which are set as /// \"required\". #[must_use] #[no_mangle] -pub extern "C" fn InvoiceFeatures_requires_unknown_bits(this_arg: &crate::lightning::ln::features::InvoiceFeatures) -> bool { +pub extern "C" fn Bolt11InvoiceFeatures_requires_unknown_bits(this_arg: &crate::lightning::ln::features::Bolt11InvoiceFeatures) -> bool { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits(); ret } +/// Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined +/// by [bLIP 2] or if it is a known `T` feature. +/// +/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will +/// be set instead (i.e., `bit - 1`). +/// +/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_set_required_custom_bit(this_arg: &mut crate::lightning::ln::features::Bolt11InvoiceFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeBolt11InvoiceFeatures)) }.set_required_custom_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined +/// by [bLIP 2] or if it is a known `T` feature. +/// +/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be +/// set instead (i.e., `bit + 1`). +/// +/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_set_optional_custom_bit(this_arg: &mut crate::lightning::ln::features::Bolt11InvoiceFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeBolt11InvoiceFeatures)) }.set_optional_custom_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + /// Create a blank Features with no features set #[must_use] #[no_mangle] @@ -1965,6 +2207,14 @@ pub extern "C" fn OfferFeatures_empty() -> crate::lightning::ln::features::Offer crate::lightning::ln::features::OfferFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } +/// Returns true if this `Features` object contains required features unknown by `other`. +#[must_use] +#[no_mangle] +pub extern "C" fn OfferFeatures_requires_unknown_bits_from(this_arg: &crate::lightning::ln::features::OfferFeatures, other: &crate::lightning::ln::features::OfferFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits_from(other.get_native_ref()); + ret +} + /// Returns true if this `Features` object contains unknown feature flags which are set as /// \"required\". #[must_use] @@ -1974,6 +2224,36 @@ pub extern "C" fn OfferFeatures_requires_unknown_bits(this_arg: &crate::lightnin ret } +/// Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined +/// by [bLIP 2] or if it is a known `T` feature. +/// +/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will +/// be set instead (i.e., `bit - 1`). +/// +/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits +#[must_use] +#[no_mangle] +pub extern "C" fn OfferFeatures_set_required_custom_bit(this_arg: &mut crate::lightning::ln::features::OfferFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeOfferFeatures)) }.set_required_custom_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined +/// by [bLIP 2] or if it is a known `T` feature. +/// +/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be +/// set instead (i.e., `bit + 1`). +/// +/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits +#[must_use] +#[no_mangle] +pub extern "C" fn OfferFeatures_set_optional_custom_bit(this_arg: &mut crate::lightning::ln::features::OfferFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeOfferFeatures)) }.set_optional_custom_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + /// Create a blank Features with no features set #[must_use] #[no_mangle] @@ -1982,6 +2262,14 @@ pub extern "C" fn InvoiceRequestFeatures_empty() -> crate::lightning::ln::featur crate::lightning::ln::features::InvoiceRequestFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } +/// Returns true if this `Features` object contains required features unknown by `other`. +#[must_use] +#[no_mangle] +pub extern "C" fn InvoiceRequestFeatures_requires_unknown_bits_from(this_arg: &crate::lightning::ln::features::InvoiceRequestFeatures, other: &crate::lightning::ln::features::InvoiceRequestFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits_from(other.get_native_ref()); + ret +} + /// Returns true if this `Features` object contains unknown feature flags which are set as /// \"required\". #[must_use] @@ -1991,6 +2279,36 @@ pub extern "C" fn InvoiceRequestFeatures_requires_unknown_bits(this_arg: &crate: ret } +/// Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined +/// by [bLIP 2] or if it is a known `T` feature. +/// +/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will +/// be set instead (i.e., `bit - 1`). +/// +/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits +#[must_use] +#[no_mangle] +pub extern "C" fn InvoiceRequestFeatures_set_required_custom_bit(this_arg: &mut crate::lightning::ln::features::InvoiceRequestFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInvoiceRequestFeatures)) }.set_required_custom_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined +/// by [bLIP 2] or if it is a known `T` feature. +/// +/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be +/// set instead (i.e., `bit + 1`). +/// +/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits +#[must_use] +#[no_mangle] +pub extern "C" fn InvoiceRequestFeatures_set_optional_custom_bit(this_arg: &mut crate::lightning::ln::features::InvoiceRequestFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInvoiceRequestFeatures)) }.set_optional_custom_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + /// Create a blank Features with no features set #[must_use] #[no_mangle] @@ -1999,6 +2317,14 @@ pub extern "C" fn Bolt12InvoiceFeatures_empty() -> crate::lightning::ln::feature crate::lightning::ln::features::Bolt12InvoiceFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } +/// Returns true if this `Features` object contains required features unknown by `other`. +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt12InvoiceFeatures_requires_unknown_bits_from(this_arg: &crate::lightning::ln::features::Bolt12InvoiceFeatures, other: &crate::lightning::ln::features::Bolt12InvoiceFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits_from(other.get_native_ref()); + ret +} + /// Returns true if this `Features` object contains unknown feature flags which are set as /// \"required\". #[must_use] @@ -2008,6 +2334,36 @@ pub extern "C" fn Bolt12InvoiceFeatures_requires_unknown_bits(this_arg: &crate:: ret } +/// Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined +/// by [bLIP 2] or if it is a known `T` feature. +/// +/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will +/// be set instead (i.e., `bit - 1`). +/// +/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt12InvoiceFeatures_set_required_custom_bit(this_arg: &mut crate::lightning::ln::features::Bolt12InvoiceFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeBolt12InvoiceFeatures)) }.set_required_custom_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined +/// by [bLIP 2] or if it is a known `T` feature. +/// +/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be +/// set instead (i.e., `bit + 1`). +/// +/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt12InvoiceFeatures_set_optional_custom_bit(this_arg: &mut crate::lightning::ln::features::Bolt12InvoiceFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeBolt12InvoiceFeatures)) }.set_optional_custom_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + /// Create a blank Features with no features set #[must_use] #[no_mangle] @@ -2016,6 +2372,14 @@ pub extern "C" fn BlindedHopFeatures_empty() -> crate::lightning::ln::features:: crate::lightning::ln::features::BlindedHopFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } +/// Returns true if this `Features` object contains required features unknown by `other`. +#[must_use] +#[no_mangle] +pub extern "C" fn BlindedHopFeatures_requires_unknown_bits_from(this_arg: &crate::lightning::ln::features::BlindedHopFeatures, other: &crate::lightning::ln::features::BlindedHopFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits_from(other.get_native_ref()); + ret +} + /// Returns true if this `Features` object contains unknown feature flags which are set as /// \"required\". #[must_use] @@ -2025,6 +2389,36 @@ pub extern "C" fn BlindedHopFeatures_requires_unknown_bits(this_arg: &crate::lig ret } +/// Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined +/// by [bLIP 2] or if it is a known `T` feature. +/// +/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will +/// be set instead (i.e., `bit - 1`). +/// +/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits +#[must_use] +#[no_mangle] +pub extern "C" fn BlindedHopFeatures_set_required_custom_bit(this_arg: &mut crate::lightning::ln::features::BlindedHopFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeBlindedHopFeatures)) }.set_required_custom_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined +/// by [bLIP 2] or if it is a known `T` feature. +/// +/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be +/// set instead (i.e., `bit + 1`). +/// +/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits +#[must_use] +#[no_mangle] +pub extern "C" fn BlindedHopFeatures_set_optional_custom_bit(this_arg: &mut crate::lightning::ln::features::BlindedHopFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeBlindedHopFeatures)) }.set_optional_custom_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + /// Create a blank Features with no features set #[must_use] #[no_mangle] @@ -2033,6 +2427,14 @@ pub extern "C" fn ChannelTypeFeatures_empty() -> crate::lightning::ln::features: crate::lightning::ln::features::ChannelTypeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } +/// Returns true if this `Features` object contains required features unknown by `other`. +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_requires_unknown_bits_from(this_arg: &crate::lightning::ln::features::ChannelTypeFeatures, other: &crate::lightning::ln::features::ChannelTypeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits_from(other.get_native_ref()); + ret +} + /// Returns true if this `Features` object contains unknown feature flags which are set as /// \"required\". #[must_use] @@ -2042,6 +2444,36 @@ pub extern "C" fn ChannelTypeFeatures_requires_unknown_bits(this_arg: &crate::li ret } +/// Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined +/// by [bLIP 2] or if it is a known `T` feature. +/// +/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will +/// be set instead (i.e., `bit - 1`). +/// +/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_set_required_custom_bit(this_arg: &mut crate::lightning::ln::features::ChannelTypeFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeChannelTypeFeatures)) }.set_required_custom_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined +/// by [bLIP 2] or if it is a known `T` feature. +/// +/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be +/// set instead (i.e., `bit + 1`). +/// +/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_set_optional_custom_bit(this_arg: &mut crate::lightning::ln::features::ChannelTypeFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeChannelTypeFeatures)) }.set_optional_custom_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + #[no_mangle] /// Serialize the InitFeatures object into a byte array which can be read by InitFeatures_read pub extern "C" fn InitFeatures_write(obj: &crate::lightning::ln::features::InitFeatures) -> crate::c_types::derived::CVec_u8Z { @@ -2091,19 +2523,35 @@ pub extern "C" fn NodeFeatures_read(ser: crate::c_types::u8slice) -> crate::c_ty local_res } #[no_mangle] -/// Serialize the InvoiceFeatures object into a byte array which can be read by InvoiceFeatures_read -pub extern "C" fn InvoiceFeatures_write(obj: &crate::lightning::ln::features::InvoiceFeatures) -> crate::c_types::derived::CVec_u8Z { +/// Serialize the Bolt11InvoiceFeatures object into a byte array which can be read by Bolt11InvoiceFeatures_read +pub extern "C" fn Bolt11InvoiceFeatures_write(obj: &crate::lightning::ln::features::Bolt11InvoiceFeatures) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[no_mangle] +pub(crate) extern "C" fn Bolt11InvoiceFeatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeBolt11InvoiceFeatures) }) +} +#[no_mangle] +/// Read a Bolt11InvoiceFeatures from a byte array, created by Bolt11InvoiceFeatures_write +pub extern "C" fn Bolt11InvoiceFeatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_Bolt11InvoiceFeaturesDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::features::Bolt11InvoiceFeatures { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} +#[no_mangle] +/// Serialize the Bolt12InvoiceFeatures object into a byte array which can be read by Bolt12InvoiceFeatures_read +pub extern "C" fn Bolt12InvoiceFeatures_write(obj: &crate::lightning::ln::features::Bolt12InvoiceFeatures) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) } #[no_mangle] -pub(crate) extern "C" fn InvoiceFeatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInvoiceFeatures) }) +pub(crate) extern "C" fn Bolt12InvoiceFeatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeBolt12InvoiceFeatures) }) } #[no_mangle] -/// Read a InvoiceFeatures from a byte array, created by InvoiceFeatures_write -pub extern "C" fn InvoiceFeatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_InvoiceFeaturesDecodeErrorZ { - let res: Result = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::features::InvoiceFeatures { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; +/// Read a Bolt12InvoiceFeatures from a byte array, created by Bolt12InvoiceFeatures_write +pub extern "C" fn Bolt12InvoiceFeatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_Bolt12InvoiceFeaturesDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::features::Bolt12InvoiceFeatures { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; local_res } #[no_mangle] diff --git a/lightning-c-bindings/src/lightning/ln/inbound_payment.rs b/lightning-c-bindings/src/lightning/ln/inbound_payment.rs index 6878fa23..4a4d1dd6 100644 --- a/lightning-c-bindings/src/lightning/ln/inbound_payment.rs +++ b/lightning-c-bindings/src/lightning/ln/inbound_payment.rs @@ -23,7 +23,7 @@ pub(crate) type nativeExpandedKey = nativeExpandedKeyImport; /// A set of keys that were HKDF-expanded from an initial call to /// [`NodeSigner::get_inbound_payment_key_material`]. /// -/// [`NodeSigner::get_inbound_payment_key_material`]: crate::chain::keysinterface::NodeSigner::get_inbound_payment_key_material +/// [`NodeSigner::get_inbound_payment_key_material`]: crate::sign::NodeSigner::get_inbound_payment_key_material #[must_use] #[repr(C)] pub struct ExpandedKey { @@ -76,7 +76,7 @@ impl ExpandedKey { #[must_use] #[no_mangle] pub extern "C" fn ExpandedKey_new(key_material: *const [u8; 32]) -> crate::lightning::ln::inbound_payment::ExpandedKey { - let mut ret = lightning::ln::inbound_payment::ExpandedKey::new(&::lightning::chain::keysinterface::KeyMaterial( unsafe { *key_material })); + let mut ret = lightning::ln::inbound_payment::ExpandedKey::new(&::lightning::sign::KeyMaterial( unsafe { *key_material })); crate::lightning::ln::inbound_payment::ExpandedKey { inner: ObjOps::heap_alloc(ret), is_owned: true } } @@ -93,13 +93,13 @@ pub extern "C" fn ExpandedKey_new(key_material: *const [u8; 32]) -> crate::light /// Note that if `min_final_cltv_expiry_delta` is set to some value, then the payment will not be receivable /// on versions of LDK prior to 0.0.114. /// -/// [phantom node payments]: crate::chain::keysinterface::PhantomKeysManager -/// [`NodeSigner::get_inbound_payment_key_material`]: crate::chain::keysinterface::NodeSigner::get_inbound_payment_key_material +/// [phantom node payments]: crate::sign::PhantomKeysManager +/// [`NodeSigner::get_inbound_payment_key_material`]: crate::sign::NodeSigner::get_inbound_payment_key_material #[no_mangle] -pub extern "C" fn create(keys: &crate::lightning::ln::inbound_payment::ExpandedKey, mut min_value_msat: crate::c_types::derived::COption_u64Z, mut invoice_expiry_delta_secs: u32, entropy_source: &crate::lightning::chain::keysinterface::EntropySource, mut current_time: u64, mut min_final_cltv_expiry_delta: crate::c_types::derived::COption_u16Z) -> crate::c_types::derived::CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ { +pub extern "C" fn create(keys: &crate::lightning::ln::inbound_payment::ExpandedKey, mut min_value_msat: crate::c_types::derived::COption_u64Z, mut invoice_expiry_delta_secs: u32, entropy_source: &crate::lightning::sign::EntropySource, mut current_time: u64, mut min_final_cltv_expiry_delta: crate::c_types::derived::COption_u16Z) -> crate::c_types::derived::CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ { let mut local_min_value_msat = if min_value_msat.is_some() { Some( { min_value_msat.take() }) } else { None }; let mut local_min_final_cltv_expiry_delta = if min_final_cltv_expiry_delta.is_some() { Some( { min_final_cltv_expiry_delta.take() }) } else { None }; - let mut ret = lightning::ln::inbound_payment::create::(keys.get_native_ref(), local_min_value_msat, invoice_expiry_delta_secs, entropy_source, current_time, local_min_final_cltv_expiry_delta); + let mut ret = lightning::ln::inbound_payment::create::(keys.get_native_ref(), local_min_value_msat, invoice_expiry_delta_secs, entropy_source, current_time, local_min_final_cltv_expiry_delta); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = o; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0.0 }, crate::c_types::ThirtyTwoBytes { data: orig_ret_0_1.0 }).into(); local_ret_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; local_ret } @@ -113,7 +113,7 @@ pub extern "C" fn create(keys: &crate::lightning::ln::inbound_payment::ExpandedK /// Note that if `min_final_cltv_expiry_delta` is set to some value, then the payment will not be receivable /// on versions of LDK prior to 0.0.114. /// -/// [phantom node payments]: crate::chain::keysinterface::PhantomKeysManager +/// [phantom node payments]: crate::sign::PhantomKeysManager #[no_mangle] pub extern "C" fn create_from_hash(keys: &crate::lightning::ln::inbound_payment::ExpandedKey, mut min_value_msat: crate::c_types::derived::COption_u64Z, mut payment_hash: crate::c_types::ThirtyTwoBytes, mut invoice_expiry_delta_secs: u32, mut current_time: u64, mut min_final_cltv_expiry_delta: crate::c_types::derived::COption_u16Z) -> crate::c_types::derived::CResult_PaymentSecretNoneZ { let mut local_min_value_msat = if min_value_msat.is_some() { Some( { min_value_msat.take() }) } else { None }; diff --git a/lightning-c-bindings/src/lightning/ln/msgs.rs b/lightning-c-bindings/src/lightning/ln/msgs.rs index 02b5ebac..d3e4c4bb 100644 --- a/lightning-c-bindings/src/lightning/ln/msgs.rs +++ b/lightning-c-bindings/src/lightning/ln/msgs.rs @@ -236,6 +236,25 @@ pub extern "C" fn Init_get_features(this_ptr: &Init) -> crate::lightning::ln::fe pub extern "C" fn Init_set_features(this_ptr: &mut Init, mut val: crate::lightning::ln::features::InitFeatures) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) }; } +/// Indicates chains the sender is interested in. +/// +/// If there are no common chains, the connection will be closed. +/// +/// Returns a copy of the field. +#[no_mangle] +pub extern "C" fn Init_get_networks(this_ptr: &Init) -> crate::c_types::derived::COption_CVec_ChainHashZZ { + let mut inner_val = this_ptr.get_native_mut_ref().networks.clone(); + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_CVec_ChainHashZZ::None } else { crate::c_types::derived::COption_CVec_ChainHashZZ::Some( { let mut local_inner_val_0 = Vec::new(); for mut item in inner_val.unwrap().drain(..) { local_inner_val_0.push( { crate::c_types::ThirtyTwoBytes { data: item.to_bytes() } }); }; local_inner_val_0.into() }) }; + local_inner_val +} +/// Indicates chains the sender is interested in. +/// +/// If there are no common chains, the connection will be closed. +#[no_mangle] +pub extern "C" fn Init_set_networks(this_ptr: &mut Init, mut val: crate::c_types::derived::COption_CVec_ChainHashZZ) { + let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { let mut local_val_0 = Vec::new(); for mut item in { val_opt.take() }.into_rust().drain(..) { local_val_0.push( { ::bitcoin::blockdata::constants::ChainHash::from(&item.data[..]) }); }; local_val_0 }})} }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.networks = local_val; +} /// The receipient's network address. /// /// This adds the option to report a remote IP address back to a connecting peer using the init @@ -262,10 +281,12 @@ pub extern "C" fn Init_set_remote_network_address(this_ptr: &mut Init, mut val: /// Constructs a new Init given each field #[must_use] #[no_mangle] -pub extern "C" fn Init_new(mut features_arg: crate::lightning::ln::features::InitFeatures, mut remote_network_address_arg: crate::c_types::derived::COption_NetAddressZ) -> Init { +pub extern "C" fn Init_new(mut features_arg: crate::lightning::ln::features::InitFeatures, mut networks_arg: crate::c_types::derived::COption_CVec_ChainHashZZ, mut remote_network_address_arg: crate::c_types::derived::COption_NetAddressZ) -> Init { + let mut local_networks_arg = { /*networks_arg*/ let networks_arg_opt = networks_arg; if networks_arg_opt.is_none() { None } else { Some({ { let mut local_networks_arg_0 = Vec::new(); for mut item in { networks_arg_opt.take() }.into_rust().drain(..) { local_networks_arg_0.push( { ::bitcoin::blockdata::constants::ChainHash::from(&item.data[..]) }); }; local_networks_arg_0 }})} }; let mut local_remote_network_address_arg = { /*remote_network_address_arg*/ let remote_network_address_arg_opt = remote_network_address_arg; if remote_network_address_arg_opt.is_none() { None } else { Some({ { { remote_network_address_arg_opt.take() }.into_native() }})} }; Init { inner: ObjOps::heap_alloc(nativeInit { features: *unsafe { Box::from_raw(features_arg.take_inner()) }, + networks: local_networks_arg, remote_network_address: local_remote_network_address_arg, }), is_owned: true } } @@ -773,6 +794,8 @@ pub(crate) type nativeOpenChannel = nativeOpenChannelImport; /// An [`open_channel`] message to be sent to or received from a peer. /// +/// Used in V1 channel establishment +/// /// [`open_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-open_channel-message #[must_use] #[repr(C)] @@ -1022,6 +1045,19 @@ pub extern "C" fn OpenChannel_get_channel_flags(this_ptr: &OpenChannel) -> u8 { pub extern "C" fn OpenChannel_set_channel_flags(this_ptr: &mut OpenChannel, mut val: u8) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_flags = val; } +/// A request to pre-set the to-sender output's `scriptPubkey` for when we collaboratively close +#[no_mangle] +pub extern "C" fn OpenChannel_get_shutdown_scriptpubkey(this_ptr: &OpenChannel) -> crate::c_types::derived::COption_ScriptZ { + let mut inner_val = &mut this_ptr.get_native_mut_ref().shutdown_scriptpubkey; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_ScriptZ::None } else { crate::c_types::derived::COption_ScriptZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option is otherwise un-expressable. */ { (*inner_val.as_ref().unwrap()).clone().into_bytes().into() }) }; + local_inner_val +} +/// A request to pre-set the to-sender output's `scriptPubkey` for when we collaboratively close +#[no_mangle] +pub extern "C" fn OpenChannel_set_shutdown_scriptpubkey(this_ptr: &mut OpenChannel, mut val: crate::c_types::derived::COption_ScriptZ) { + let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::Script::from({ val_opt.take() }.into_rust()) }})} }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.shutdown_scriptpubkey = local_val; +} /// The channel type that this channel will represent /// /// If this is `None`, we derive the channel type from the intersection of our @@ -1045,6 +1081,35 @@ pub extern "C" fn OpenChannel_set_channel_type(this_ptr: &mut OpenChannel, mut v let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val; } +/// Constructs a new OpenChannel given each field +#[must_use] +#[no_mangle] +pub extern "C" fn OpenChannel_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut temporary_channel_id_arg: crate::c_types::ThirtyTwoBytes, mut funding_satoshis_arg: u64, mut push_msat_arg: u64, mut dust_limit_satoshis_arg: u64, mut max_htlc_value_in_flight_msat_arg: u64, mut channel_reserve_satoshis_arg: u64, mut htlc_minimum_msat_arg: u64, mut feerate_per_kw_arg: u32, mut to_self_delay_arg: u16, mut max_accepted_htlcs_arg: u16, mut funding_pubkey_arg: crate::c_types::PublicKey, mut revocation_basepoint_arg: crate::c_types::PublicKey, mut payment_point_arg: crate::c_types::PublicKey, mut delayed_payment_basepoint_arg: crate::c_types::PublicKey, mut htlc_basepoint_arg: crate::c_types::PublicKey, mut first_per_commitment_point_arg: crate::c_types::PublicKey, mut channel_flags_arg: u8, mut shutdown_scriptpubkey_arg: crate::c_types::derived::COption_ScriptZ, mut channel_type_arg: crate::lightning::ln::features::ChannelTypeFeatures) -> OpenChannel { + let mut local_shutdown_scriptpubkey_arg = { /*shutdown_scriptpubkey_arg*/ let shutdown_scriptpubkey_arg_opt = shutdown_scriptpubkey_arg; if shutdown_scriptpubkey_arg_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::Script::from({ shutdown_scriptpubkey_arg_opt.take() }.into_rust()) }})} }; + let mut local_channel_type_arg = if channel_type_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(channel_type_arg.take_inner()) } }) }; + OpenChannel { inner: ObjOps::heap_alloc(nativeOpenChannel { + chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(), + temporary_channel_id: temporary_channel_id_arg.data, + funding_satoshis: funding_satoshis_arg, + push_msat: push_msat_arg, + dust_limit_satoshis: dust_limit_satoshis_arg, + max_htlc_value_in_flight_msat: max_htlc_value_in_flight_msat_arg, + channel_reserve_satoshis: channel_reserve_satoshis_arg, + htlc_minimum_msat: htlc_minimum_msat_arg, + feerate_per_kw: feerate_per_kw_arg, + to_self_delay: to_self_delay_arg, + max_accepted_htlcs: max_accepted_htlcs_arg, + funding_pubkey: funding_pubkey_arg.into_rust(), + revocation_basepoint: revocation_basepoint_arg.into_rust(), + payment_point: payment_point_arg.into_rust(), + delayed_payment_basepoint: delayed_payment_basepoint_arg.into_rust(), + htlc_basepoint: htlc_basepoint_arg.into_rust(), + first_per_commitment_point: first_per_commitment_point_arg.into_rust(), + channel_flags: channel_flags_arg, + shutdown_scriptpubkey: local_shutdown_scriptpubkey_arg, + channel_type: local_channel_type_arg, + }), is_owned: true } +} impl Clone for OpenChannel { fn clone(&self) -> Self { Self { @@ -1074,11 +1139,391 @@ pub extern "C" fn OpenChannel_eq(a: &OpenChannel, b: &OpenChannel) -> bool { if a.get_native_ref() == b.get_native_ref() { true } else { false } } +use lightning::ln::msgs::OpenChannelV2 as nativeOpenChannelV2Import; +pub(crate) type nativeOpenChannelV2 = nativeOpenChannelV2Import; + +/// An open_channel2 message to be sent by or received from the channel initiator. +/// +/// Used in V2 channel establishment +/// +#[must_use] +#[repr(C)] +pub struct OpenChannelV2 { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeOpenChannelV2, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for OpenChannelV2 { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeOpenChannelV2>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the OpenChannelV2, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn OpenChannelV2_free(this_obj: OpenChannelV2) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn OpenChannelV2_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeOpenChannelV2) }; +} +#[allow(unused)] +impl OpenChannelV2 { + pub(crate) fn get_native_ref(&self) -> &'static nativeOpenChannelV2 { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOpenChannelV2 { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeOpenChannelV2 { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +/// The genesis hash of the blockchain where the channel is to be opened +#[no_mangle] +pub extern "C" fn OpenChannelV2_get_chain_hash(this_ptr: &OpenChannelV2) -> *const [u8; 32] { + let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash; + inner_val.as_inner() +} +/// The genesis hash of the blockchain where the channel is to be opened +#[no_mangle] +pub extern "C" fn OpenChannelV2_set_chain_hash(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::ThirtyTwoBytes) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap(); +} +/// A temporary channel ID derived using a zeroed out value for the channel acceptor's revocation basepoint +#[no_mangle] +pub extern "C" fn OpenChannelV2_get_temporary_channel_id(this_ptr: &OpenChannelV2) -> *const [u8; 32] { + let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id; + inner_val +} +/// A temporary channel ID derived using a zeroed out value for the channel acceptor's revocation basepoint +#[no_mangle] +pub extern "C" fn OpenChannelV2_set_temporary_channel_id(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::ThirtyTwoBytes) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = val.data; +} +/// The feerate for the funding transaction set by the channel initiator +#[no_mangle] +pub extern "C" fn OpenChannelV2_get_funding_feerate_sat_per_1000_weight(this_ptr: &OpenChannelV2) -> u32 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_feerate_sat_per_1000_weight; + *inner_val +} +/// The feerate for the funding transaction set by the channel initiator +#[no_mangle] +pub extern "C" fn OpenChannelV2_set_funding_feerate_sat_per_1000_weight(this_ptr: &mut OpenChannelV2, mut val: u32) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_feerate_sat_per_1000_weight = val; +} +/// The feerate for the commitment transaction set by the channel initiator +#[no_mangle] +pub extern "C" fn OpenChannelV2_get_commitment_feerate_sat_per_1000_weight(this_ptr: &OpenChannelV2) -> u32 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().commitment_feerate_sat_per_1000_weight; + *inner_val +} +/// The feerate for the commitment transaction set by the channel initiator +#[no_mangle] +pub extern "C" fn OpenChannelV2_set_commitment_feerate_sat_per_1000_weight(this_ptr: &mut OpenChannelV2, mut val: u32) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.commitment_feerate_sat_per_1000_weight = val; +} +/// Part of the channel value contributed by the channel initiator +#[no_mangle] +pub extern "C" fn OpenChannelV2_get_funding_satoshis(this_ptr: &OpenChannelV2) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_satoshis; + *inner_val +} +/// Part of the channel value contributed by the channel initiator +#[no_mangle] +pub extern "C" fn OpenChannelV2_set_funding_satoshis(this_ptr: &mut OpenChannelV2, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_satoshis = val; +} +/// The threshold below which outputs on transactions broadcast by the channel initiator will be +/// omitted +#[no_mangle] +pub extern "C" fn OpenChannelV2_get_dust_limit_satoshis(this_ptr: &OpenChannelV2) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().dust_limit_satoshis; + *inner_val +} +/// The threshold below which outputs on transactions broadcast by the channel initiator will be +/// omitted +#[no_mangle] +pub extern "C" fn OpenChannelV2_set_dust_limit_satoshis(this_ptr: &mut OpenChannelV2, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.dust_limit_satoshis = val; +} +/// The maximum inbound HTLC value in flight towards channel initiator, in milli-satoshi +#[no_mangle] +pub extern "C" fn OpenChannelV2_get_max_htlc_value_in_flight_msat(this_ptr: &OpenChannelV2) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_value_in_flight_msat; + *inner_val +} +/// The maximum inbound HTLC value in flight towards channel initiator, in milli-satoshi +#[no_mangle] +pub extern "C" fn OpenChannelV2_set_max_htlc_value_in_flight_msat(this_ptr: &mut OpenChannelV2, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_value_in_flight_msat = val; +} +/// The minimum HTLC size incoming to channel initiator, in milli-satoshi +#[no_mangle] +pub extern "C" fn OpenChannelV2_get_htlc_minimum_msat(this_ptr: &OpenChannelV2) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat; + *inner_val +} +/// The minimum HTLC size incoming to channel initiator, in milli-satoshi +#[no_mangle] +pub extern "C" fn OpenChannelV2_set_htlc_minimum_msat(this_ptr: &mut OpenChannelV2, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val; +} +/// The number of blocks which the counterparty will have to wait to claim on-chain funds if they +/// broadcast a commitment transaction +#[no_mangle] +pub extern "C" fn OpenChannelV2_get_to_self_delay(this_ptr: &OpenChannelV2) -> u16 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay; + *inner_val +} +/// The number of blocks which the counterparty will have to wait to claim on-chain funds if they +/// broadcast a commitment transaction +#[no_mangle] +pub extern "C" fn OpenChannelV2_set_to_self_delay(this_ptr: &mut OpenChannelV2, mut val: u16) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val; +} +/// The maximum number of inbound HTLCs towards channel initiator +#[no_mangle] +pub extern "C" fn OpenChannelV2_get_max_accepted_htlcs(this_ptr: &OpenChannelV2) -> u16 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs; + *inner_val +} +/// The maximum number of inbound HTLCs towards channel initiator +#[no_mangle] +pub extern "C" fn OpenChannelV2_set_max_accepted_htlcs(this_ptr: &mut OpenChannelV2, mut val: u16) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val; +} +/// The locktime for the funding transaction +#[no_mangle] +pub extern "C" fn OpenChannelV2_get_locktime(this_ptr: &OpenChannelV2) -> u32 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().locktime; + *inner_val +} +/// The locktime for the funding transaction +#[no_mangle] +pub extern "C" fn OpenChannelV2_set_locktime(this_ptr: &mut OpenChannelV2, mut val: u32) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.locktime = val; +} +/// The channel initiator's key controlling the funding transaction +#[no_mangle] +pub extern "C" fn OpenChannelV2_get_funding_pubkey(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey { + let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey; + crate::c_types::PublicKey::from_rust(&inner_val) +} +/// The channel initiator's key controlling the funding transaction +#[no_mangle] +pub extern "C" fn OpenChannelV2_set_funding_pubkey(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust(); +} +/// Used to derive a revocation key for transactions broadcast by counterparty +#[no_mangle] +pub extern "C" fn OpenChannelV2_get_revocation_basepoint(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey { + let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint; + crate::c_types::PublicKey::from_rust(&inner_val) +} +/// Used to derive a revocation key for transactions broadcast by counterparty +#[no_mangle] +pub extern "C" fn OpenChannelV2_set_revocation_basepoint(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_basepoint = val.into_rust(); +} +/// A payment key to channel initiator for transactions broadcast by counterparty +#[no_mangle] +pub extern "C" fn OpenChannelV2_get_payment_basepoint(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey { + let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_basepoint; + crate::c_types::PublicKey::from_rust(&inner_val) +} +/// A payment key to channel initiator for transactions broadcast by counterparty +#[no_mangle] +pub extern "C" fn OpenChannelV2_set_payment_basepoint(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_basepoint = val.into_rust(); +} +/// Used to derive a payment key to channel initiator for transactions broadcast by channel +/// initiator +#[no_mangle] +pub extern "C" fn OpenChannelV2_get_delayed_payment_basepoint(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey { + let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_basepoint; + crate::c_types::PublicKey::from_rust(&inner_val) +} +/// Used to derive a payment key to channel initiator for transactions broadcast by channel +/// initiator +#[no_mangle] +pub extern "C" fn OpenChannelV2_set_delayed_payment_basepoint(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_basepoint = val.into_rust(); +} +/// Used to derive an HTLC payment key to channel initiator +#[no_mangle] +pub extern "C" fn OpenChannelV2_get_htlc_basepoint(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey { + let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_basepoint; + crate::c_types::PublicKey::from_rust(&inner_val) +} +/// Used to derive an HTLC payment key to channel initiator +#[no_mangle] +pub extern "C" fn OpenChannelV2_set_htlc_basepoint(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_basepoint = val.into_rust(); +} +/// The first to-be-broadcast-by-channel-initiator transaction's per commitment point +#[no_mangle] +pub extern "C" fn OpenChannelV2_get_first_per_commitment_point(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey { + let mut inner_val = &mut this_ptr.get_native_mut_ref().first_per_commitment_point; + crate::c_types::PublicKey::from_rust(&inner_val) +} +/// The first to-be-broadcast-by-channel-initiator transaction's per commitment point +#[no_mangle] +pub extern "C" fn OpenChannelV2_set_first_per_commitment_point(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust(); +} +/// The second to-be-broadcast-by-channel-initiator transaction's per commitment point +#[no_mangle] +pub extern "C" fn OpenChannelV2_get_second_per_commitment_point(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey { + let mut inner_val = &mut this_ptr.get_native_mut_ref().second_per_commitment_point; + crate::c_types::PublicKey::from_rust(&inner_val) +} +/// The second to-be-broadcast-by-channel-initiator transaction's per commitment point +#[no_mangle] +pub extern "C" fn OpenChannelV2_set_second_per_commitment_point(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.second_per_commitment_point = val.into_rust(); +} +/// Channel flags +#[no_mangle] +pub extern "C" fn OpenChannelV2_get_channel_flags(this_ptr: &OpenChannelV2) -> u8 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_flags; + *inner_val +} +/// Channel flags +#[no_mangle] +pub extern "C" fn OpenChannelV2_set_channel_flags(this_ptr: &mut OpenChannelV2, mut val: u8) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_flags = val; +} +/// Optionally, a request to pre-set the to-channel-initiator output's scriptPubkey for when we +/// collaboratively close +#[no_mangle] +pub extern "C" fn OpenChannelV2_get_shutdown_scriptpubkey(this_ptr: &OpenChannelV2) -> crate::c_types::derived::COption_ScriptZ { + let mut inner_val = &mut this_ptr.get_native_mut_ref().shutdown_scriptpubkey; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_ScriptZ::None } else { crate::c_types::derived::COption_ScriptZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option is otherwise un-expressable. */ { (*inner_val.as_ref().unwrap()).clone().into_bytes().into() }) }; + local_inner_val +} +/// Optionally, a request to pre-set the to-channel-initiator output's scriptPubkey for when we +/// collaboratively close +#[no_mangle] +pub extern "C" fn OpenChannelV2_set_shutdown_scriptpubkey(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::derived::COption_ScriptZ) { + let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::Script::from({ val_opt.take() }.into_rust()) }})} }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.shutdown_scriptpubkey = local_val; +} +/// The channel type that this channel will represent. If none is set, we derive the channel +/// type from the intersection of our feature bits with our counterparty's feature bits from +/// the Init message. +/// +/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None +#[no_mangle] +pub extern "C" fn OpenChannelV2_get_channel_type(this_ptr: &OpenChannelV2) -> crate::lightning::ln::features::ChannelTypeFeatures { + let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type; + let mut local_inner_val = crate::lightning::ln::features::ChannelTypeFeatures { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::features::ChannelTypeFeatures<>) as *mut _ }, is_owned: false }; + local_inner_val +} +/// The channel type that this channel will represent. If none is set, we derive the channel +/// type from the intersection of our feature bits with our counterparty's feature bits from +/// the Init message. +/// +/// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None +#[no_mangle] +pub extern "C" fn OpenChannelV2_set_channel_type(this_ptr: &mut OpenChannelV2, mut val: crate::lightning::ln::features::ChannelTypeFeatures) { + let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val; +} +/// Optionally, a requirement that only confirmed inputs can be added +#[no_mangle] +pub extern "C" fn OpenChannelV2_get_require_confirmed_inputs(this_ptr: &OpenChannelV2) -> crate::c_types::derived::COption_NoneZ { + let mut inner_val = &mut this_ptr.get_native_mut_ref().require_confirmed_inputs; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_NoneZ::None } else { crate::c_types::derived::COption_NoneZ::Some /* { () /**/ } */ }; + local_inner_val +} +/// Optionally, a requirement that only confirmed inputs can be added +#[no_mangle] +pub extern "C" fn OpenChannelV2_set_require_confirmed_inputs(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::derived::COption_NoneZ) { + let mut local_val = if val.is_some() { Some( { () /*val.take()*/ }) } else { None }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.require_confirmed_inputs = local_val; +} +/// Constructs a new OpenChannelV2 given each field +#[must_use] +#[no_mangle] +pub extern "C" fn OpenChannelV2_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut temporary_channel_id_arg: crate::c_types::ThirtyTwoBytes, mut funding_feerate_sat_per_1000_weight_arg: u32, mut commitment_feerate_sat_per_1000_weight_arg: u32, mut funding_satoshis_arg: u64, mut dust_limit_satoshis_arg: u64, mut max_htlc_value_in_flight_msat_arg: u64, mut htlc_minimum_msat_arg: u64, mut to_self_delay_arg: u16, mut max_accepted_htlcs_arg: u16, mut locktime_arg: u32, mut funding_pubkey_arg: crate::c_types::PublicKey, mut revocation_basepoint_arg: crate::c_types::PublicKey, mut payment_basepoint_arg: crate::c_types::PublicKey, mut delayed_payment_basepoint_arg: crate::c_types::PublicKey, mut htlc_basepoint_arg: crate::c_types::PublicKey, mut first_per_commitment_point_arg: crate::c_types::PublicKey, mut second_per_commitment_point_arg: crate::c_types::PublicKey, mut channel_flags_arg: u8, mut shutdown_scriptpubkey_arg: crate::c_types::derived::COption_ScriptZ, mut channel_type_arg: crate::lightning::ln::features::ChannelTypeFeatures, mut require_confirmed_inputs_arg: crate::c_types::derived::COption_NoneZ) -> OpenChannelV2 { + let mut local_shutdown_scriptpubkey_arg = { /*shutdown_scriptpubkey_arg*/ let shutdown_scriptpubkey_arg_opt = shutdown_scriptpubkey_arg; if shutdown_scriptpubkey_arg_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::Script::from({ shutdown_scriptpubkey_arg_opt.take() }.into_rust()) }})} }; + let mut local_channel_type_arg = if channel_type_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(channel_type_arg.take_inner()) } }) }; + let mut local_require_confirmed_inputs_arg = if require_confirmed_inputs_arg.is_some() { Some( { () /*require_confirmed_inputs_arg.take()*/ }) } else { None }; + OpenChannelV2 { inner: ObjOps::heap_alloc(nativeOpenChannelV2 { + chain_hash: ::bitcoin::hash_types::BlockHash::from_slice(&chain_hash_arg.data[..]).unwrap(), + temporary_channel_id: temporary_channel_id_arg.data, + funding_feerate_sat_per_1000_weight: funding_feerate_sat_per_1000_weight_arg, + commitment_feerate_sat_per_1000_weight: commitment_feerate_sat_per_1000_weight_arg, + funding_satoshis: funding_satoshis_arg, + dust_limit_satoshis: dust_limit_satoshis_arg, + max_htlc_value_in_flight_msat: max_htlc_value_in_flight_msat_arg, + htlc_minimum_msat: htlc_minimum_msat_arg, + to_self_delay: to_self_delay_arg, + max_accepted_htlcs: max_accepted_htlcs_arg, + locktime: locktime_arg, + funding_pubkey: funding_pubkey_arg.into_rust(), + revocation_basepoint: revocation_basepoint_arg.into_rust(), + payment_basepoint: payment_basepoint_arg.into_rust(), + delayed_payment_basepoint: delayed_payment_basepoint_arg.into_rust(), + htlc_basepoint: htlc_basepoint_arg.into_rust(), + first_per_commitment_point: first_per_commitment_point_arg.into_rust(), + second_per_commitment_point: second_per_commitment_point_arg.into_rust(), + channel_flags: channel_flags_arg, + shutdown_scriptpubkey: local_shutdown_scriptpubkey_arg, + channel_type: local_channel_type_arg, + require_confirmed_inputs: local_require_confirmed_inputs_arg, + }), is_owned: true } +} +impl Clone for OpenChannelV2 { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeOpenChannelV2>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn OpenChannelV2_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeOpenChannelV2)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the OpenChannelV2 +pub extern "C" fn OpenChannelV2_clone(orig: &OpenChannelV2) -> OpenChannelV2 { + orig.clone() +} +/// Checks if two OpenChannelV2s contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn OpenChannelV2_eq(a: &OpenChannelV2, b: &OpenChannelV2) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} + use lightning::ln::msgs::AcceptChannel as nativeAcceptChannelImport; pub(crate) type nativeAcceptChannel = nativeAcceptChannelImport; /// An [`accept_channel`] message to be sent to or received from a peer. /// +/// Used in V1 channel establishment +/// /// [`accept_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-accept_channel-message #[must_use] #[repr(C)] @@ -1280,6 +1725,19 @@ pub extern "C" fn AcceptChannel_get_first_per_commitment_point(this_ptr: &Accept pub extern "C" fn AcceptChannel_set_first_per_commitment_point(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust(); } +/// A request to pre-set the to-sender output's scriptPubkey for when we collaboratively close +#[no_mangle] +pub extern "C" fn AcceptChannel_get_shutdown_scriptpubkey(this_ptr: &AcceptChannel) -> crate::c_types::derived::COption_ScriptZ { + let mut inner_val = &mut this_ptr.get_native_mut_ref().shutdown_scriptpubkey; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_ScriptZ::None } else { crate::c_types::derived::COption_ScriptZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option is otherwise un-expressable. */ { (*inner_val.as_ref().unwrap()).clone().into_bytes().into() }) }; + local_inner_val +} +/// A request to pre-set the to-sender output's scriptPubkey for when we collaboratively close +#[no_mangle] +pub extern "C" fn AcceptChannel_set_shutdown_scriptpubkey(this_ptr: &mut AcceptChannel, mut val: crate::c_types::derived::COption_ScriptZ) { + let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::Script::from({ val_opt.take() }.into_rust()) }})} }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.shutdown_scriptpubkey = local_val; +} /// The channel type that this channel will represent. /// /// If this is `None`, we derive the channel type from the intersection of @@ -1305,6 +1763,31 @@ pub extern "C" fn AcceptChannel_set_channel_type(this_ptr: &mut AcceptChannel, m let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val; } +/// Constructs a new AcceptChannel given each field +#[must_use] +#[no_mangle] +pub extern "C" fn AcceptChannel_new(mut temporary_channel_id_arg: crate::c_types::ThirtyTwoBytes, mut dust_limit_satoshis_arg: u64, mut max_htlc_value_in_flight_msat_arg: u64, mut channel_reserve_satoshis_arg: u64, mut htlc_minimum_msat_arg: u64, mut minimum_depth_arg: u32, mut to_self_delay_arg: u16, mut max_accepted_htlcs_arg: u16, mut funding_pubkey_arg: crate::c_types::PublicKey, mut revocation_basepoint_arg: crate::c_types::PublicKey, mut payment_point_arg: crate::c_types::PublicKey, mut delayed_payment_basepoint_arg: crate::c_types::PublicKey, mut htlc_basepoint_arg: crate::c_types::PublicKey, mut first_per_commitment_point_arg: crate::c_types::PublicKey, mut shutdown_scriptpubkey_arg: crate::c_types::derived::COption_ScriptZ, mut channel_type_arg: crate::lightning::ln::features::ChannelTypeFeatures) -> AcceptChannel { + let mut local_shutdown_scriptpubkey_arg = { /*shutdown_scriptpubkey_arg*/ let shutdown_scriptpubkey_arg_opt = shutdown_scriptpubkey_arg; if shutdown_scriptpubkey_arg_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::Script::from({ shutdown_scriptpubkey_arg_opt.take() }.into_rust()) }})} }; + let mut local_channel_type_arg = if channel_type_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(channel_type_arg.take_inner()) } }) }; + AcceptChannel { inner: ObjOps::heap_alloc(nativeAcceptChannel { + temporary_channel_id: temporary_channel_id_arg.data, + dust_limit_satoshis: dust_limit_satoshis_arg, + max_htlc_value_in_flight_msat: max_htlc_value_in_flight_msat_arg, + channel_reserve_satoshis: channel_reserve_satoshis_arg, + htlc_minimum_msat: htlc_minimum_msat_arg, + minimum_depth: minimum_depth_arg, + to_self_delay: to_self_delay_arg, + max_accepted_htlcs: max_accepted_htlcs_arg, + funding_pubkey: funding_pubkey_arg.into_rust(), + revocation_basepoint: revocation_basepoint_arg.into_rust(), + payment_point: payment_point_arg.into_rust(), + delayed_payment_basepoint: delayed_payment_basepoint_arg.into_rust(), + htlc_basepoint: htlc_basepoint_arg.into_rust(), + first_per_commitment_point: first_per_commitment_point_arg.into_rust(), + shutdown_scriptpubkey: local_shutdown_scriptpubkey_arg, + channel_type: local_channel_type_arg, + }), is_owned: true } +} impl Clone for AcceptChannel { fn clone(&self) -> Self { Self { @@ -1334,12 +1817,348 @@ pub extern "C" fn AcceptChannel_eq(a: &AcceptChannel, b: &AcceptChannel) -> bool if a.get_native_ref() == b.get_native_ref() { true } else { false } } -use lightning::ln::msgs::FundingCreated as nativeFundingCreatedImport; -pub(crate) type nativeFundingCreated = nativeFundingCreatedImport; +use lightning::ln::msgs::AcceptChannelV2 as nativeAcceptChannelV2Import; +pub(crate) type nativeAcceptChannelV2 = nativeAcceptChannelV2Import; -/// A [`funding_created`] message to be sent to or received from a peer. +/// An accept_channel2 message to be sent by or received from the channel accepter. /// -/// [`funding_created`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-funding_created-message +/// Used in V2 channel establishment +/// +#[must_use] +#[repr(C)] +pub struct AcceptChannelV2 { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeAcceptChannelV2, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for AcceptChannelV2 { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeAcceptChannelV2>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the AcceptChannelV2, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn AcceptChannelV2_free(this_obj: AcceptChannelV2) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn AcceptChannelV2_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeAcceptChannelV2) }; +} +#[allow(unused)] +impl AcceptChannelV2 { + pub(crate) fn get_native_ref(&self) -> &'static nativeAcceptChannelV2 { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeAcceptChannelV2 { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeAcceptChannelV2 { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +/// The same `temporary_channel_id` received from the initiator's `open_channel2` message. +#[no_mangle] +pub extern "C" fn AcceptChannelV2_get_temporary_channel_id(this_ptr: &AcceptChannelV2) -> *const [u8; 32] { + let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id; + inner_val +} +/// The same `temporary_channel_id` received from the initiator's `open_channel2` message. +#[no_mangle] +pub extern "C" fn AcceptChannelV2_set_temporary_channel_id(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::ThirtyTwoBytes) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = val.data; +} +/// Part of the channel value contributed by the channel acceptor +#[no_mangle] +pub extern "C" fn AcceptChannelV2_get_funding_satoshis(this_ptr: &AcceptChannelV2) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_satoshis; + *inner_val +} +/// Part of the channel value contributed by the channel acceptor +#[no_mangle] +pub extern "C" fn AcceptChannelV2_set_funding_satoshis(this_ptr: &mut AcceptChannelV2, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_satoshis = val; +} +/// The threshold below which outputs on transactions broadcast by the channel acceptor will be +/// omitted +#[no_mangle] +pub extern "C" fn AcceptChannelV2_get_dust_limit_satoshis(this_ptr: &AcceptChannelV2) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().dust_limit_satoshis; + *inner_val +} +/// The threshold below which outputs on transactions broadcast by the channel acceptor will be +/// omitted +#[no_mangle] +pub extern "C" fn AcceptChannelV2_set_dust_limit_satoshis(this_ptr: &mut AcceptChannelV2, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.dust_limit_satoshis = val; +} +/// The maximum inbound HTLC value in flight towards channel acceptor, in milli-satoshi +#[no_mangle] +pub extern "C" fn AcceptChannelV2_get_max_htlc_value_in_flight_msat(this_ptr: &AcceptChannelV2) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_value_in_flight_msat; + *inner_val +} +/// The maximum inbound HTLC value in flight towards channel acceptor, in milli-satoshi +#[no_mangle] +pub extern "C" fn AcceptChannelV2_set_max_htlc_value_in_flight_msat(this_ptr: &mut AcceptChannelV2, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_value_in_flight_msat = val; +} +/// The minimum HTLC size incoming to channel acceptor, in milli-satoshi +#[no_mangle] +pub extern "C" fn AcceptChannelV2_get_htlc_minimum_msat(this_ptr: &AcceptChannelV2) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat; + *inner_val +} +/// The minimum HTLC size incoming to channel acceptor, in milli-satoshi +#[no_mangle] +pub extern "C" fn AcceptChannelV2_set_htlc_minimum_msat(this_ptr: &mut AcceptChannelV2, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val; +} +/// Minimum depth of the funding transaction before the channel is considered open +#[no_mangle] +pub extern "C" fn AcceptChannelV2_get_minimum_depth(this_ptr: &AcceptChannelV2) -> u32 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().minimum_depth; + *inner_val +} +/// Minimum depth of the funding transaction before the channel is considered open +#[no_mangle] +pub extern "C" fn AcceptChannelV2_set_minimum_depth(this_ptr: &mut AcceptChannelV2, mut val: u32) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.minimum_depth = val; +} +/// The number of blocks which the counterparty will have to wait to claim on-chain funds if they +/// broadcast a commitment transaction +#[no_mangle] +pub extern "C" fn AcceptChannelV2_get_to_self_delay(this_ptr: &AcceptChannelV2) -> u16 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay; + *inner_val +} +/// The number of blocks which the counterparty will have to wait to claim on-chain funds if they +/// broadcast a commitment transaction +#[no_mangle] +pub extern "C" fn AcceptChannelV2_set_to_self_delay(this_ptr: &mut AcceptChannelV2, mut val: u16) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val; +} +/// The maximum number of inbound HTLCs towards channel acceptor +#[no_mangle] +pub extern "C" fn AcceptChannelV2_get_max_accepted_htlcs(this_ptr: &AcceptChannelV2) -> u16 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs; + *inner_val +} +/// The maximum number of inbound HTLCs towards channel acceptor +#[no_mangle] +pub extern "C" fn AcceptChannelV2_set_max_accepted_htlcs(this_ptr: &mut AcceptChannelV2, mut val: u16) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val; +} +/// The channel acceptor's key controlling the funding transaction +#[no_mangle] +pub extern "C" fn AcceptChannelV2_get_funding_pubkey(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey { + let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey; + crate::c_types::PublicKey::from_rust(&inner_val) +} +/// The channel acceptor's key controlling the funding transaction +#[no_mangle] +pub extern "C" fn AcceptChannelV2_set_funding_pubkey(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust(); +} +/// Used to derive a revocation key for transactions broadcast by counterparty +#[no_mangle] +pub extern "C" fn AcceptChannelV2_get_revocation_basepoint(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey { + let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint; + crate::c_types::PublicKey::from_rust(&inner_val) +} +/// Used to derive a revocation key for transactions broadcast by counterparty +#[no_mangle] +pub extern "C" fn AcceptChannelV2_set_revocation_basepoint(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_basepoint = val.into_rust(); +} +/// A payment key to channel acceptor for transactions broadcast by counterparty +#[no_mangle] +pub extern "C" fn AcceptChannelV2_get_payment_basepoint(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey { + let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_basepoint; + crate::c_types::PublicKey::from_rust(&inner_val) +} +/// A payment key to channel acceptor for transactions broadcast by counterparty +#[no_mangle] +pub extern "C" fn AcceptChannelV2_set_payment_basepoint(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_basepoint = val.into_rust(); +} +/// Used to derive a payment key to channel acceptor for transactions broadcast by channel +/// acceptor +#[no_mangle] +pub extern "C" fn AcceptChannelV2_get_delayed_payment_basepoint(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey { + let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_basepoint; + crate::c_types::PublicKey::from_rust(&inner_val) +} +/// Used to derive a payment key to channel acceptor for transactions broadcast by channel +/// acceptor +#[no_mangle] +pub extern "C" fn AcceptChannelV2_set_delayed_payment_basepoint(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_basepoint = val.into_rust(); +} +/// Used to derive an HTLC payment key to channel acceptor for transactions broadcast by counterparty +#[no_mangle] +pub extern "C" fn AcceptChannelV2_get_htlc_basepoint(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey { + let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_basepoint; + crate::c_types::PublicKey::from_rust(&inner_val) +} +/// Used to derive an HTLC payment key to channel acceptor for transactions broadcast by counterparty +#[no_mangle] +pub extern "C" fn AcceptChannelV2_set_htlc_basepoint(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_basepoint = val.into_rust(); +} +/// The first to-be-broadcast-by-channel-acceptor transaction's per commitment point +#[no_mangle] +pub extern "C" fn AcceptChannelV2_get_first_per_commitment_point(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey { + let mut inner_val = &mut this_ptr.get_native_mut_ref().first_per_commitment_point; + crate::c_types::PublicKey::from_rust(&inner_val) +} +/// The first to-be-broadcast-by-channel-acceptor transaction's per commitment point +#[no_mangle] +pub extern "C" fn AcceptChannelV2_set_first_per_commitment_point(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust(); +} +/// The second to-be-broadcast-by-channel-acceptor transaction's per commitment point +#[no_mangle] +pub extern "C" fn AcceptChannelV2_get_second_per_commitment_point(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey { + let mut inner_val = &mut this_ptr.get_native_mut_ref().second_per_commitment_point; + crate::c_types::PublicKey::from_rust(&inner_val) +} +/// The second to-be-broadcast-by-channel-acceptor transaction's per commitment point +#[no_mangle] +pub extern "C" fn AcceptChannelV2_set_second_per_commitment_point(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.second_per_commitment_point = val.into_rust(); +} +/// Optionally, a request to pre-set the to-channel-acceptor output's scriptPubkey for when we +/// collaboratively close +#[no_mangle] +pub extern "C" fn AcceptChannelV2_get_shutdown_scriptpubkey(this_ptr: &AcceptChannelV2) -> crate::c_types::derived::COption_ScriptZ { + let mut inner_val = &mut this_ptr.get_native_mut_ref().shutdown_scriptpubkey; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_ScriptZ::None } else { crate::c_types::derived::COption_ScriptZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option is otherwise un-expressable. */ { (*inner_val.as_ref().unwrap()).clone().into_bytes().into() }) }; + local_inner_val +} +/// Optionally, a request to pre-set the to-channel-acceptor output's scriptPubkey for when we +/// collaboratively close +#[no_mangle] +pub extern "C" fn AcceptChannelV2_set_shutdown_scriptpubkey(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::derived::COption_ScriptZ) { + let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::Script::from({ val_opt.take() }.into_rust()) }})} }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.shutdown_scriptpubkey = local_val; +} +/// The channel type that this channel will represent. If none is set, we derive the channel +/// type from the intersection of our feature bits with our counterparty's feature bits from +/// the Init message. +/// +/// This is required to match the equivalent field in [`OpenChannelV2::channel_type`]. +/// +/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None +#[no_mangle] +pub extern "C" fn AcceptChannelV2_get_channel_type(this_ptr: &AcceptChannelV2) -> crate::lightning::ln::features::ChannelTypeFeatures { + let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type; + let mut local_inner_val = crate::lightning::ln::features::ChannelTypeFeatures { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::features::ChannelTypeFeatures<>) as *mut _ }, is_owned: false }; + local_inner_val +} +/// The channel type that this channel will represent. If none is set, we derive the channel +/// type from the intersection of our feature bits with our counterparty's feature bits from +/// the Init message. +/// +/// This is required to match the equivalent field in [`OpenChannelV2::channel_type`]. +/// +/// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None +#[no_mangle] +pub extern "C" fn AcceptChannelV2_set_channel_type(this_ptr: &mut AcceptChannelV2, mut val: crate::lightning::ln::features::ChannelTypeFeatures) { + let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val; +} +/// Optionally, a requirement that only confirmed inputs can be added +#[no_mangle] +pub extern "C" fn AcceptChannelV2_get_require_confirmed_inputs(this_ptr: &AcceptChannelV2) -> crate::c_types::derived::COption_NoneZ { + let mut inner_val = &mut this_ptr.get_native_mut_ref().require_confirmed_inputs; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_NoneZ::None } else { crate::c_types::derived::COption_NoneZ::Some /* { () /**/ } */ }; + local_inner_val +} +/// Optionally, a requirement that only confirmed inputs can be added +#[no_mangle] +pub extern "C" fn AcceptChannelV2_set_require_confirmed_inputs(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::derived::COption_NoneZ) { + let mut local_val = if val.is_some() { Some( { () /*val.take()*/ }) } else { None }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.require_confirmed_inputs = local_val; +} +/// Constructs a new AcceptChannelV2 given each field +#[must_use] +#[no_mangle] +pub extern "C" fn AcceptChannelV2_new(mut temporary_channel_id_arg: crate::c_types::ThirtyTwoBytes, mut funding_satoshis_arg: u64, mut dust_limit_satoshis_arg: u64, mut max_htlc_value_in_flight_msat_arg: u64, mut htlc_minimum_msat_arg: u64, mut minimum_depth_arg: u32, mut to_self_delay_arg: u16, mut max_accepted_htlcs_arg: u16, mut funding_pubkey_arg: crate::c_types::PublicKey, mut revocation_basepoint_arg: crate::c_types::PublicKey, mut payment_basepoint_arg: crate::c_types::PublicKey, mut delayed_payment_basepoint_arg: crate::c_types::PublicKey, mut htlc_basepoint_arg: crate::c_types::PublicKey, mut first_per_commitment_point_arg: crate::c_types::PublicKey, mut second_per_commitment_point_arg: crate::c_types::PublicKey, mut shutdown_scriptpubkey_arg: crate::c_types::derived::COption_ScriptZ, mut channel_type_arg: crate::lightning::ln::features::ChannelTypeFeatures, mut require_confirmed_inputs_arg: crate::c_types::derived::COption_NoneZ) -> AcceptChannelV2 { + let mut local_shutdown_scriptpubkey_arg = { /*shutdown_scriptpubkey_arg*/ let shutdown_scriptpubkey_arg_opt = shutdown_scriptpubkey_arg; if shutdown_scriptpubkey_arg_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::Script::from({ shutdown_scriptpubkey_arg_opt.take() }.into_rust()) }})} }; + let mut local_channel_type_arg = if channel_type_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(channel_type_arg.take_inner()) } }) }; + let mut local_require_confirmed_inputs_arg = if require_confirmed_inputs_arg.is_some() { Some( { () /*require_confirmed_inputs_arg.take()*/ }) } else { None }; + AcceptChannelV2 { inner: ObjOps::heap_alloc(nativeAcceptChannelV2 { + temporary_channel_id: temporary_channel_id_arg.data, + funding_satoshis: funding_satoshis_arg, + dust_limit_satoshis: dust_limit_satoshis_arg, + max_htlc_value_in_flight_msat: max_htlc_value_in_flight_msat_arg, + htlc_minimum_msat: htlc_minimum_msat_arg, + minimum_depth: minimum_depth_arg, + to_self_delay: to_self_delay_arg, + max_accepted_htlcs: max_accepted_htlcs_arg, + funding_pubkey: funding_pubkey_arg.into_rust(), + revocation_basepoint: revocation_basepoint_arg.into_rust(), + payment_basepoint: payment_basepoint_arg.into_rust(), + delayed_payment_basepoint: delayed_payment_basepoint_arg.into_rust(), + htlc_basepoint: htlc_basepoint_arg.into_rust(), + first_per_commitment_point: first_per_commitment_point_arg.into_rust(), + second_per_commitment_point: second_per_commitment_point_arg.into_rust(), + shutdown_scriptpubkey: local_shutdown_scriptpubkey_arg, + channel_type: local_channel_type_arg, + require_confirmed_inputs: local_require_confirmed_inputs_arg, + }), is_owned: true } +} +impl Clone for AcceptChannelV2 { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeAcceptChannelV2>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn AcceptChannelV2_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeAcceptChannelV2)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the AcceptChannelV2 +pub extern "C" fn AcceptChannelV2_clone(orig: &AcceptChannelV2) -> AcceptChannelV2 { + orig.clone() +} +/// Checks if two AcceptChannelV2s contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn AcceptChannelV2_eq(a: &AcceptChannelV2, b: &AcceptChannelV2) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} + +use lightning::ln::msgs::FundingCreated as nativeFundingCreatedImport; +pub(crate) type nativeFundingCreated = nativeFundingCreatedImport; + +/// A [`funding_created`] message to be sent to or received from a peer. +/// +/// Used in V1 channel establishment +/// +/// [`funding_created`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-funding_created-message #[must_use] #[repr(C)] pub struct FundingCreated { @@ -1475,6 +2294,8 @@ pub(crate) type nativeFundingSigned = nativeFundingSignedImport; /// A [`funding_signed`] message to be sent to or received from a peer. /// +/// Used in V1 channel establishment +/// /// [`funding_signed`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-funding_signed-message #[must_use] #[repr(C)] @@ -1682,14 +2503,1127 @@ pub extern "C" fn ChannelReady_new(mut channel_id_arg: crate::c_types::ThirtyTwo let mut local_short_channel_id_alias_arg = if short_channel_id_alias_arg.is_some() { Some( { short_channel_id_alias_arg.take() }) } else { None }; ChannelReady { inner: ObjOps::heap_alloc(nativeChannelReady { channel_id: channel_id_arg.data, - next_per_commitment_point: next_per_commitment_point_arg.into_rust(), - short_channel_id_alias: local_short_channel_id_alias_arg, + next_per_commitment_point: next_per_commitment_point_arg.into_rust(), + short_channel_id_alias: local_short_channel_id_alias_arg, + }), is_owned: true } +} +impl Clone for ChannelReady { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeChannelReady>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn ChannelReady_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelReady)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the ChannelReady +pub extern "C" fn ChannelReady_clone(orig: &ChannelReady) -> ChannelReady { + orig.clone() +} +/// Checks if two ChannelReadys contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn ChannelReady_eq(a: &ChannelReady, b: &ChannelReady) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} + +use lightning::ln::msgs::TxAddInput as nativeTxAddInputImport; +pub(crate) type nativeTxAddInput = nativeTxAddInputImport; + +/// A tx_add_input message for adding an input during interactive transaction construction +/// +#[must_use] +#[repr(C)] +pub struct TxAddInput { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeTxAddInput, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for TxAddInput { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeTxAddInput>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the TxAddInput, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn TxAddInput_free(this_obj: TxAddInput) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn TxAddInput_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxAddInput) }; +} +#[allow(unused)] +impl TxAddInput { + pub(crate) fn get_native_ref(&self) -> &'static nativeTxAddInput { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxAddInput { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeTxAddInput { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +/// The channel ID +#[no_mangle] +pub extern "C" fn TxAddInput_get_channel_id(this_ptr: &TxAddInput) -> *const [u8; 32] { + let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id; + inner_val +} +/// The channel ID +#[no_mangle] +pub extern "C" fn TxAddInput_set_channel_id(this_ptr: &mut TxAddInput, mut val: crate::c_types::ThirtyTwoBytes) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data; +} +/// A randomly chosen unique identifier for this input, which is even for initiators and odd for +/// non-initiators. +#[no_mangle] +pub extern "C" fn TxAddInput_get_serial_id(this_ptr: &TxAddInput) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().serial_id; + *inner_val +} +/// A randomly chosen unique identifier for this input, which is even for initiators and odd for +/// non-initiators. +#[no_mangle] +pub extern "C" fn TxAddInput_set_serial_id(this_ptr: &mut TxAddInput, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.serial_id = val; +} +/// Serialized transaction that contains the output this input spends to verify that it is non +/// malleable. +#[no_mangle] +pub extern "C" fn TxAddInput_get_prevtx(this_ptr: &TxAddInput) -> crate::lightning::util::ser::TransactionU16LenLimited { + let mut inner_val = &mut this_ptr.get_native_mut_ref().prevtx; + crate::lightning::util::ser::TransactionU16LenLimited { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::util::ser::TransactionU16LenLimited<>) as *mut _) }, is_owned: false } +} +/// Serialized transaction that contains the output this input spends to verify that it is non +/// malleable. +#[no_mangle] +pub extern "C" fn TxAddInput_set_prevtx(this_ptr: &mut TxAddInput, mut val: crate::lightning::util::ser::TransactionU16LenLimited) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.prevtx = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// The index of the output being spent +#[no_mangle] +pub extern "C" fn TxAddInput_get_prevtx_out(this_ptr: &TxAddInput) -> u32 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().prevtx_out; + *inner_val +} +/// The index of the output being spent +#[no_mangle] +pub extern "C" fn TxAddInput_set_prevtx_out(this_ptr: &mut TxAddInput, mut val: u32) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.prevtx_out = val; +} +/// The sequence number of this input +#[no_mangle] +pub extern "C" fn TxAddInput_get_sequence(this_ptr: &TxAddInput) -> u32 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().sequence; + *inner_val +} +/// The sequence number of this input +#[no_mangle] +pub extern "C" fn TxAddInput_set_sequence(this_ptr: &mut TxAddInput, mut val: u32) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.sequence = val; +} +/// Constructs a new TxAddInput given each field +#[must_use] +#[no_mangle] +pub extern "C" fn TxAddInput_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut serial_id_arg: u64, mut prevtx_arg: crate::lightning::util::ser::TransactionU16LenLimited, mut prevtx_out_arg: u32, mut sequence_arg: u32) -> TxAddInput { + TxAddInput { inner: ObjOps::heap_alloc(nativeTxAddInput { + channel_id: channel_id_arg.data, + serial_id: serial_id_arg, + prevtx: *unsafe { Box::from_raw(prevtx_arg.take_inner()) }, + prevtx_out: prevtx_out_arg, + sequence: sequence_arg, + }), is_owned: true } +} +impl Clone for TxAddInput { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeTxAddInput>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn TxAddInput_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeTxAddInput)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the TxAddInput +pub extern "C" fn TxAddInput_clone(orig: &TxAddInput) -> TxAddInput { + orig.clone() +} +/// Checks if two TxAddInputs contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn TxAddInput_eq(a: &TxAddInput, b: &TxAddInput) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} + +use lightning::ln::msgs::TxAddOutput as nativeTxAddOutputImport; +pub(crate) type nativeTxAddOutput = nativeTxAddOutputImport; + +/// A tx_add_output message for adding an output during interactive transaction construction. +/// +#[must_use] +#[repr(C)] +pub struct TxAddOutput { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeTxAddOutput, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for TxAddOutput { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeTxAddOutput>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the TxAddOutput, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn TxAddOutput_free(this_obj: TxAddOutput) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn TxAddOutput_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxAddOutput) }; +} +#[allow(unused)] +impl TxAddOutput { + pub(crate) fn get_native_ref(&self) -> &'static nativeTxAddOutput { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxAddOutput { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeTxAddOutput { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +/// The channel ID +#[no_mangle] +pub extern "C" fn TxAddOutput_get_channel_id(this_ptr: &TxAddOutput) -> *const [u8; 32] { + let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id; + inner_val +} +/// The channel ID +#[no_mangle] +pub extern "C" fn TxAddOutput_set_channel_id(this_ptr: &mut TxAddOutput, mut val: crate::c_types::ThirtyTwoBytes) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data; +} +/// A randomly chosen unique identifier for this output, which is even for initiators and odd for +/// non-initiators. +#[no_mangle] +pub extern "C" fn TxAddOutput_get_serial_id(this_ptr: &TxAddOutput) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().serial_id; + *inner_val +} +/// A randomly chosen unique identifier for this output, which is even for initiators and odd for +/// non-initiators. +#[no_mangle] +pub extern "C" fn TxAddOutput_set_serial_id(this_ptr: &mut TxAddOutput, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.serial_id = val; +} +/// The satoshi value of the output +#[no_mangle] +pub extern "C" fn TxAddOutput_get_sats(this_ptr: &TxAddOutput) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().sats; + *inner_val +} +/// The satoshi value of the output +#[no_mangle] +pub extern "C" fn TxAddOutput_set_sats(this_ptr: &mut TxAddOutput, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.sats = val; +} +/// The scriptPubKey for the output +#[no_mangle] +pub extern "C" fn TxAddOutput_get_script(this_ptr: &TxAddOutput) -> crate::c_types::u8slice { + let mut inner_val = &mut this_ptr.get_native_mut_ref().script; + crate::c_types::u8slice::from_slice(&inner_val[..]) +} +/// The scriptPubKey for the output +#[no_mangle] +pub extern "C" fn TxAddOutput_set_script(this_ptr: &mut TxAddOutput, mut val: crate::c_types::derived::CVec_u8Z) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.script = ::bitcoin::blockdata::script::Script::from(val.into_rust()); +} +/// Constructs a new TxAddOutput given each field +#[must_use] +#[no_mangle] +pub extern "C" fn TxAddOutput_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut serial_id_arg: u64, mut sats_arg: u64, mut script_arg: crate::c_types::derived::CVec_u8Z) -> TxAddOutput { + TxAddOutput { inner: ObjOps::heap_alloc(nativeTxAddOutput { + channel_id: channel_id_arg.data, + serial_id: serial_id_arg, + sats: sats_arg, + script: ::bitcoin::blockdata::script::Script::from(script_arg.into_rust()), + }), is_owned: true } +} +impl Clone for TxAddOutput { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeTxAddOutput>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn TxAddOutput_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeTxAddOutput)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the TxAddOutput +pub extern "C" fn TxAddOutput_clone(orig: &TxAddOutput) -> TxAddOutput { + orig.clone() +} +/// Checks if two TxAddOutputs contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn TxAddOutput_eq(a: &TxAddOutput, b: &TxAddOutput) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} + +use lightning::ln::msgs::TxRemoveInput as nativeTxRemoveInputImport; +pub(crate) type nativeTxRemoveInput = nativeTxRemoveInputImport; + +/// A tx_remove_input message for removing an input during interactive transaction construction. +/// +#[must_use] +#[repr(C)] +pub struct TxRemoveInput { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeTxRemoveInput, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for TxRemoveInput { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeTxRemoveInput>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the TxRemoveInput, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn TxRemoveInput_free(this_obj: TxRemoveInput) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn TxRemoveInput_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxRemoveInput) }; +} +#[allow(unused)] +impl TxRemoveInput { + pub(crate) fn get_native_ref(&self) -> &'static nativeTxRemoveInput { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxRemoveInput { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeTxRemoveInput { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +/// The channel ID +#[no_mangle] +pub extern "C" fn TxRemoveInput_get_channel_id(this_ptr: &TxRemoveInput) -> *const [u8; 32] { + let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id; + inner_val +} +/// The channel ID +#[no_mangle] +pub extern "C" fn TxRemoveInput_set_channel_id(this_ptr: &mut TxRemoveInput, mut val: crate::c_types::ThirtyTwoBytes) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data; +} +/// The serial ID of the input to be removed +#[no_mangle] +pub extern "C" fn TxRemoveInput_get_serial_id(this_ptr: &TxRemoveInput) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().serial_id; + *inner_val +} +/// The serial ID of the input to be removed +#[no_mangle] +pub extern "C" fn TxRemoveInput_set_serial_id(this_ptr: &mut TxRemoveInput, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.serial_id = val; +} +/// Constructs a new TxRemoveInput given each field +#[must_use] +#[no_mangle] +pub extern "C" fn TxRemoveInput_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut serial_id_arg: u64) -> TxRemoveInput { + TxRemoveInput { inner: ObjOps::heap_alloc(nativeTxRemoveInput { + channel_id: channel_id_arg.data, + serial_id: serial_id_arg, + }), is_owned: true } +} +impl Clone for TxRemoveInput { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeTxRemoveInput>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn TxRemoveInput_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeTxRemoveInput)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the TxRemoveInput +pub extern "C" fn TxRemoveInput_clone(orig: &TxRemoveInput) -> TxRemoveInput { + orig.clone() +} +/// Checks if two TxRemoveInputs contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn TxRemoveInput_eq(a: &TxRemoveInput, b: &TxRemoveInput) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} + +use lightning::ln::msgs::TxRemoveOutput as nativeTxRemoveOutputImport; +pub(crate) type nativeTxRemoveOutput = nativeTxRemoveOutputImport; + +/// A tx_remove_output message for removing an output during interactive transaction construction. +/// +#[must_use] +#[repr(C)] +pub struct TxRemoveOutput { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeTxRemoveOutput, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for TxRemoveOutput { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeTxRemoveOutput>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the TxRemoveOutput, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn TxRemoveOutput_free(this_obj: TxRemoveOutput) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn TxRemoveOutput_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxRemoveOutput) }; +} +#[allow(unused)] +impl TxRemoveOutput { + pub(crate) fn get_native_ref(&self) -> &'static nativeTxRemoveOutput { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxRemoveOutput { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeTxRemoveOutput { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +/// The channel ID +#[no_mangle] +pub extern "C" fn TxRemoveOutput_get_channel_id(this_ptr: &TxRemoveOutput) -> *const [u8; 32] { + let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id; + inner_val +} +/// The channel ID +#[no_mangle] +pub extern "C" fn TxRemoveOutput_set_channel_id(this_ptr: &mut TxRemoveOutput, mut val: crate::c_types::ThirtyTwoBytes) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data; +} +/// The serial ID of the output to be removed +#[no_mangle] +pub extern "C" fn TxRemoveOutput_get_serial_id(this_ptr: &TxRemoveOutput) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().serial_id; + *inner_val +} +/// The serial ID of the output to be removed +#[no_mangle] +pub extern "C" fn TxRemoveOutput_set_serial_id(this_ptr: &mut TxRemoveOutput, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.serial_id = val; +} +/// Constructs a new TxRemoveOutput given each field +#[must_use] +#[no_mangle] +pub extern "C" fn TxRemoveOutput_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut serial_id_arg: u64) -> TxRemoveOutput { + TxRemoveOutput { inner: ObjOps::heap_alloc(nativeTxRemoveOutput { + channel_id: channel_id_arg.data, + serial_id: serial_id_arg, + }), is_owned: true } +} +impl Clone for TxRemoveOutput { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeTxRemoveOutput>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn TxRemoveOutput_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeTxRemoveOutput)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the TxRemoveOutput +pub extern "C" fn TxRemoveOutput_clone(orig: &TxRemoveOutput) -> TxRemoveOutput { + orig.clone() +} +/// Checks if two TxRemoveOutputs contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn TxRemoveOutput_eq(a: &TxRemoveOutput, b: &TxRemoveOutput) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} + +use lightning::ln::msgs::TxComplete as nativeTxCompleteImport; +pub(crate) type nativeTxComplete = nativeTxCompleteImport; + +/// A tx_complete message signalling the conclusion of a peer's transaction contributions during +/// interactive transaction construction. +/// +#[must_use] +#[repr(C)] +pub struct TxComplete { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeTxComplete, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for TxComplete { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeTxComplete>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the TxComplete, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn TxComplete_free(this_obj: TxComplete) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn TxComplete_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxComplete) }; +} +#[allow(unused)] +impl TxComplete { + pub(crate) fn get_native_ref(&self) -> &'static nativeTxComplete { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxComplete { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeTxComplete { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +/// The channel ID +#[no_mangle] +pub extern "C" fn TxComplete_get_channel_id(this_ptr: &TxComplete) -> *const [u8; 32] { + let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id; + inner_val +} +/// The channel ID +#[no_mangle] +pub extern "C" fn TxComplete_set_channel_id(this_ptr: &mut TxComplete, mut val: crate::c_types::ThirtyTwoBytes) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data; +} +/// Constructs a new TxComplete given each field +#[must_use] +#[no_mangle] +pub extern "C" fn TxComplete_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes) -> TxComplete { + TxComplete { inner: ObjOps::heap_alloc(nativeTxComplete { + channel_id: channel_id_arg.data, + }), is_owned: true } +} +impl Clone for TxComplete { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeTxComplete>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn TxComplete_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeTxComplete)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the TxComplete +pub extern "C" fn TxComplete_clone(orig: &TxComplete) -> TxComplete { + orig.clone() +} +/// Checks if two TxCompletes contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn TxComplete_eq(a: &TxComplete, b: &TxComplete) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} + +use lightning::ln::msgs::TxSignatures as nativeTxSignaturesImport; +pub(crate) type nativeTxSignatures = nativeTxSignaturesImport; + +/// A tx_signatures message containing the sender's signatures for a transaction constructed with +/// interactive transaction construction. +/// +#[must_use] +#[repr(C)] +pub struct TxSignatures { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeTxSignatures, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for TxSignatures { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeTxSignatures>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the TxSignatures, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn TxSignatures_free(this_obj: TxSignatures) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn TxSignatures_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxSignatures) }; +} +#[allow(unused)] +impl TxSignatures { + pub(crate) fn get_native_ref(&self) -> &'static nativeTxSignatures { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxSignatures { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeTxSignatures { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +/// The channel ID +#[no_mangle] +pub extern "C" fn TxSignatures_get_channel_id(this_ptr: &TxSignatures) -> *const [u8; 32] { + let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id; + inner_val +} +/// The channel ID +#[no_mangle] +pub extern "C" fn TxSignatures_set_channel_id(this_ptr: &mut TxSignatures, mut val: crate::c_types::ThirtyTwoBytes) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data; +} +/// The TXID +#[no_mangle] +pub extern "C" fn TxSignatures_get_tx_hash(this_ptr: &TxSignatures) -> *const [u8; 32] { + let mut inner_val = &mut this_ptr.get_native_mut_ref().tx_hash; + inner_val.as_inner() +} +/// The TXID +#[no_mangle] +pub extern "C" fn TxSignatures_set_tx_hash(this_ptr: &mut TxSignatures, mut val: crate::c_types::ThirtyTwoBytes) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.tx_hash = ::bitcoin::hash_types::Txid::from_slice(&val.data[..]).unwrap(); +} +/// The list of witnesses +/// +/// Returns a copy of the field. +#[no_mangle] +pub extern "C" fn TxSignatures_get_witnesses(this_ptr: &TxSignatures) -> crate::c_types::derived::CVec_WitnessZ { + let mut inner_val = this_ptr.get_native_mut_ref().witnesses.clone(); + let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { crate::c_types::Witness::from_bitcoin(&item) }); }; + local_inner_val.into() +} +/// The list of witnesses +#[no_mangle] +pub extern "C" fn TxSignatures_set_witnesses(this_ptr: &mut TxSignatures, mut val: crate::c_types::derived::CVec_WitnessZ) { + let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_bitcoin() }); }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.witnesses = local_val; +} +/// Constructs a new TxSignatures given each field +#[must_use] +#[no_mangle] +pub extern "C" fn TxSignatures_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut tx_hash_arg: crate::c_types::ThirtyTwoBytes, mut witnesses_arg: crate::c_types::derived::CVec_WitnessZ) -> TxSignatures { + let mut local_witnesses_arg = Vec::new(); for mut item in witnesses_arg.into_rust().drain(..) { local_witnesses_arg.push( { item.into_bitcoin() }); }; + TxSignatures { inner: ObjOps::heap_alloc(nativeTxSignatures { + channel_id: channel_id_arg.data, + tx_hash: ::bitcoin::hash_types::Txid::from_slice(&tx_hash_arg.data[..]).unwrap(), + witnesses: local_witnesses_arg, + }), is_owned: true } +} +impl Clone for TxSignatures { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeTxSignatures>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn TxSignatures_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeTxSignatures)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the TxSignatures +pub extern "C" fn TxSignatures_clone(orig: &TxSignatures) -> TxSignatures { + orig.clone() +} +/// Checks if two TxSignaturess contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn TxSignatures_eq(a: &TxSignatures, b: &TxSignatures) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} + +use lightning::ln::msgs::TxInitRbf as nativeTxInitRbfImport; +pub(crate) type nativeTxInitRbf = nativeTxInitRbfImport; + +/// A tx_init_rbf message which initiates a replacement of the transaction after it's been +/// completed. +/// +#[must_use] +#[repr(C)] +pub struct TxInitRbf { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeTxInitRbf, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for TxInitRbf { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeTxInitRbf>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the TxInitRbf, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn TxInitRbf_free(this_obj: TxInitRbf) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn TxInitRbf_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxInitRbf) }; +} +#[allow(unused)] +impl TxInitRbf { + pub(crate) fn get_native_ref(&self) -> &'static nativeTxInitRbf { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxInitRbf { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeTxInitRbf { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +/// The channel ID +#[no_mangle] +pub extern "C" fn TxInitRbf_get_channel_id(this_ptr: &TxInitRbf) -> *const [u8; 32] { + let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id; + inner_val +} +/// The channel ID +#[no_mangle] +pub extern "C" fn TxInitRbf_set_channel_id(this_ptr: &mut TxInitRbf, mut val: crate::c_types::ThirtyTwoBytes) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data; +} +/// The locktime of the transaction +#[no_mangle] +pub extern "C" fn TxInitRbf_get_locktime(this_ptr: &TxInitRbf) -> u32 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().locktime; + *inner_val +} +/// The locktime of the transaction +#[no_mangle] +pub extern "C" fn TxInitRbf_set_locktime(this_ptr: &mut TxInitRbf, mut val: u32) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.locktime = val; +} +/// The feerate of the transaction +#[no_mangle] +pub extern "C" fn TxInitRbf_get_feerate_sat_per_1000_weight(this_ptr: &TxInitRbf) -> u32 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().feerate_sat_per_1000_weight; + *inner_val +} +/// The feerate of the transaction +#[no_mangle] +pub extern "C" fn TxInitRbf_set_feerate_sat_per_1000_weight(this_ptr: &mut TxInitRbf, mut val: u32) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.feerate_sat_per_1000_weight = val; +} +/// The number of satoshis the sender will contribute to or, if negative, remove from +/// (e.g. splice-out) the funding output of the transaction +#[no_mangle] +pub extern "C" fn TxInitRbf_get_funding_output_contribution(this_ptr: &TxInitRbf) -> crate::c_types::derived::COption_i64Z { + let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_output_contribution; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_i64Z::None } else { crate::c_types::derived::COption_i64Z::Some( { inner_val.unwrap() }) }; + local_inner_val +} +/// The number of satoshis the sender will contribute to or, if negative, remove from +/// (e.g. splice-out) the funding output of the transaction +#[no_mangle] +pub extern "C" fn TxInitRbf_set_funding_output_contribution(this_ptr: &mut TxInitRbf, mut val: crate::c_types::derived::COption_i64Z) { + let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_output_contribution = local_val; +} +/// Constructs a new TxInitRbf given each field +#[must_use] +#[no_mangle] +pub extern "C" fn TxInitRbf_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut locktime_arg: u32, mut feerate_sat_per_1000_weight_arg: u32, mut funding_output_contribution_arg: crate::c_types::derived::COption_i64Z) -> TxInitRbf { + let mut local_funding_output_contribution_arg = if funding_output_contribution_arg.is_some() { Some( { funding_output_contribution_arg.take() }) } else { None }; + TxInitRbf { inner: ObjOps::heap_alloc(nativeTxInitRbf { + channel_id: channel_id_arg.data, + locktime: locktime_arg, + feerate_sat_per_1000_weight: feerate_sat_per_1000_weight_arg, + funding_output_contribution: local_funding_output_contribution_arg, + }), is_owned: true } +} +impl Clone for TxInitRbf { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeTxInitRbf>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn TxInitRbf_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeTxInitRbf)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the TxInitRbf +pub extern "C" fn TxInitRbf_clone(orig: &TxInitRbf) -> TxInitRbf { + orig.clone() +} +/// Checks if two TxInitRbfs contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn TxInitRbf_eq(a: &TxInitRbf, b: &TxInitRbf) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} + +use lightning::ln::msgs::TxAckRbf as nativeTxAckRbfImport; +pub(crate) type nativeTxAckRbf = nativeTxAckRbfImport; + +/// A tx_ack_rbf message which acknowledges replacement of the transaction after it's been +/// completed. +/// +#[must_use] +#[repr(C)] +pub struct TxAckRbf { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeTxAckRbf, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for TxAckRbf { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeTxAckRbf>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the TxAckRbf, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn TxAckRbf_free(this_obj: TxAckRbf) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn TxAckRbf_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxAckRbf) }; +} +#[allow(unused)] +impl TxAckRbf { + pub(crate) fn get_native_ref(&self) -> &'static nativeTxAckRbf { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxAckRbf { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeTxAckRbf { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +/// The channel ID +#[no_mangle] +pub extern "C" fn TxAckRbf_get_channel_id(this_ptr: &TxAckRbf) -> *const [u8; 32] { + let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id; + inner_val +} +/// The channel ID +#[no_mangle] +pub extern "C" fn TxAckRbf_set_channel_id(this_ptr: &mut TxAckRbf, mut val: crate::c_types::ThirtyTwoBytes) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data; +} +/// The number of satoshis the sender will contribute to or, if negative, remove from +/// (e.g. splice-out) the funding output of the transaction +#[no_mangle] +pub extern "C" fn TxAckRbf_get_funding_output_contribution(this_ptr: &TxAckRbf) -> crate::c_types::derived::COption_i64Z { + let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_output_contribution; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_i64Z::None } else { crate::c_types::derived::COption_i64Z::Some( { inner_val.unwrap() }) }; + local_inner_val +} +/// The number of satoshis the sender will contribute to or, if negative, remove from +/// (e.g. splice-out) the funding output of the transaction +#[no_mangle] +pub extern "C" fn TxAckRbf_set_funding_output_contribution(this_ptr: &mut TxAckRbf, mut val: crate::c_types::derived::COption_i64Z) { + let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_output_contribution = local_val; +} +/// Constructs a new TxAckRbf given each field +#[must_use] +#[no_mangle] +pub extern "C" fn TxAckRbf_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut funding_output_contribution_arg: crate::c_types::derived::COption_i64Z) -> TxAckRbf { + let mut local_funding_output_contribution_arg = if funding_output_contribution_arg.is_some() { Some( { funding_output_contribution_arg.take() }) } else { None }; + TxAckRbf { inner: ObjOps::heap_alloc(nativeTxAckRbf { + channel_id: channel_id_arg.data, + funding_output_contribution: local_funding_output_contribution_arg, + }), is_owned: true } +} +impl Clone for TxAckRbf { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeTxAckRbf>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn TxAckRbf_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeTxAckRbf)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the TxAckRbf +pub extern "C" fn TxAckRbf_clone(orig: &TxAckRbf) -> TxAckRbf { + orig.clone() +} +/// Checks if two TxAckRbfs contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn TxAckRbf_eq(a: &TxAckRbf, b: &TxAckRbf) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} + +use lightning::ln::msgs::TxAbort as nativeTxAbortImport; +pub(crate) type nativeTxAbort = nativeTxAbortImport; + +/// A tx_abort message which signals the cancellation of an in-progress transaction negotiation. +/// +#[must_use] +#[repr(C)] +pub struct TxAbort { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeTxAbort, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for TxAbort { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeTxAbort>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the TxAbort, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn TxAbort_free(this_obj: TxAbort) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn TxAbort_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTxAbort) }; +} +#[allow(unused)] +impl TxAbort { + pub(crate) fn get_native_ref(&self) -> &'static nativeTxAbort { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTxAbort { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeTxAbort { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +/// The channel ID +#[no_mangle] +pub extern "C" fn TxAbort_get_channel_id(this_ptr: &TxAbort) -> *const [u8; 32] { + let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id; + inner_val +} +/// The channel ID +#[no_mangle] +pub extern "C" fn TxAbort_set_channel_id(this_ptr: &mut TxAbort, mut val: crate::c_types::ThirtyTwoBytes) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data; +} +/// Message data +/// +/// Returns a copy of the field. +#[no_mangle] +pub extern "C" fn TxAbort_get_data(this_ptr: &TxAbort) -> crate::c_types::derived::CVec_u8Z { + let mut inner_val = this_ptr.get_native_mut_ref().data.clone(); + let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); }; + local_inner_val.into() +} +/// Message data +#[no_mangle] +pub extern "C" fn TxAbort_set_data(this_ptr: &mut TxAbort, mut val: crate::c_types::derived::CVec_u8Z) { + let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.data = local_val; +} +/// Constructs a new TxAbort given each field +#[must_use] +#[no_mangle] +pub extern "C" fn TxAbort_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut data_arg: crate::c_types::derived::CVec_u8Z) -> TxAbort { + let mut local_data_arg = Vec::new(); for mut item in data_arg.into_rust().drain(..) { local_data_arg.push( { item }); }; + TxAbort { inner: ObjOps::heap_alloc(nativeTxAbort { + channel_id: channel_id_arg.data, + data: local_data_arg, }), is_owned: true } } -impl Clone for ChannelReady { +impl Clone for TxAbort { fn clone(&self) -> Self { Self { - inner: if <*mut nativeChannelReady>::is_null(self.inner) { core::ptr::null_mut() } else { + inner: if <*mut nativeTxAbort>::is_null(self.inner) { core::ptr::null_mut() } else { ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, is_owned: true, } @@ -1697,19 +3631,19 @@ impl Clone for ChannelReady { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn ChannelReady_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelReady)).clone() })) as *mut c_void +pub(crate) extern "C" fn TxAbort_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeTxAbort)).clone() })) as *mut c_void } #[no_mangle] -/// Creates a copy of the ChannelReady -pub extern "C" fn ChannelReady_clone(orig: &ChannelReady) -> ChannelReady { +/// Creates a copy of the TxAbort +pub extern "C" fn TxAbort_clone(orig: &TxAbort) -> TxAbort { orig.clone() } -/// Checks if two ChannelReadys contain equal inner contents. +/// Checks if two TxAborts contain equal inner contents. /// This ignores pointers and is_owned flags and looks at the values in fields. /// Two objects with NULL inner values will be considered "equal" here. #[no_mangle] -pub extern "C" fn ChannelReady_eq(a: &ChannelReady, b: &ChannelReady) -> bool { +pub extern "C" fn TxAbort_eq(a: &TxAbort, b: &TxAbort) -> bool { if a.inner == b.inner { return true; } if a.inner.is_null() || b.inner.is_null() { return false; } if a.get_native_ref() == b.get_native_ref() { true } else { false } @@ -2200,6 +4134,25 @@ pub extern "C" fn UpdateAddHTLC_get_cltv_expiry(this_ptr: &UpdateAddHTLC) -> u32 pub extern "C" fn UpdateAddHTLC_set_cltv_expiry(this_ptr: &mut UpdateAddHTLC, mut val: u32) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry = val; } +/// The extra fee skimmed by the sender of this message. See +/// [`ChannelConfig::accept_underpaying_htlcs`]. +/// +/// [`ChannelConfig::accept_underpaying_htlcs`]: crate::util::config::ChannelConfig::accept_underpaying_htlcs +#[no_mangle] +pub extern "C" fn UpdateAddHTLC_get_skimmed_fee_msat(this_ptr: &UpdateAddHTLC) -> crate::c_types::derived::COption_u64Z { + let mut inner_val = &mut this_ptr.get_native_mut_ref().skimmed_fee_msat; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) }; + local_inner_val +} +/// The extra fee skimmed by the sender of this message. See +/// [`ChannelConfig::accept_underpaying_htlcs`]. +/// +/// [`ChannelConfig::accept_underpaying_htlcs`]: crate::util::config::ChannelConfig::accept_underpaying_htlcs +#[no_mangle] +pub extern "C" fn UpdateAddHTLC_set_skimmed_fee_msat(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::derived::COption_u64Z) { + let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.skimmed_fee_msat = local_val; +} impl Clone for UpdateAddHTLC { fn clone(&self) -> Self { Self { @@ -3026,122 +4979,6 @@ pub extern "C" fn UpdateFee_eq(a: &UpdateFee, b: &UpdateFee) -> bool { if a.get_native_ref() == b.get_native_ref() { true } else { false } } -use lightning::ln::msgs::DataLossProtect as nativeDataLossProtectImport; -pub(crate) type nativeDataLossProtect = nativeDataLossProtectImport; - -/// Proof that the sender knows the per-commitment secret of the previous commitment transaction. -/// -/// This is used to convince the recipient that the channel is at a certain commitment -/// number even if they lost that data due to a local failure. Of course, the peer may lie -/// and even later commitments may have been revoked. -#[must_use] -#[repr(C)] -pub struct DataLossProtect { - /// A pointer to the opaque Rust object. - - /// Nearly everywhere, inner must be non-null, however in places where - /// the Rust equivalent takes an Option, it may be set to null to indicate None. - pub inner: *mut nativeDataLossProtect, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for DataLossProtect { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeDataLossProtect>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; - } - } -} -/// Frees any resources used by the DataLossProtect, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn DataLossProtect_free(this_obj: DataLossProtect) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn DataLossProtect_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeDataLossProtect) }; -} -#[allow(unused)] -impl DataLossProtect { - pub(crate) fn get_native_ref(&self) -> &'static nativeDataLossProtect { - unsafe { &*ObjOps::untweak_ptr(self.inner) } - } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeDataLossProtect { - unsafe { &mut *ObjOps::untweak_ptr(self.inner) } - } - /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy - pub(crate) fn take_inner(mut self) -> *mut nativeDataLossProtect { - assert!(self.is_owned); - let ret = ObjOps::untweak_ptr(self.inner); - self.inner = core::ptr::null_mut(); - ret - } -} -/// Proof that the sender knows the per-commitment secret of a specific commitment transaction -/// belonging to the recipient -#[no_mangle] -pub extern "C" fn DataLossProtect_get_your_last_per_commitment_secret(this_ptr: &DataLossProtect) -> *const [u8; 32] { - let mut inner_val = &mut this_ptr.get_native_mut_ref().your_last_per_commitment_secret; - inner_val -} -/// Proof that the sender knows the per-commitment secret of a specific commitment transaction -/// belonging to the recipient -#[no_mangle] -pub extern "C" fn DataLossProtect_set_your_last_per_commitment_secret(this_ptr: &mut DataLossProtect, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.your_last_per_commitment_secret = val.data; -} -/// The sender's per-commitment point for their current commitment transaction -#[no_mangle] -pub extern "C" fn DataLossProtect_get_my_current_per_commitment_point(this_ptr: &DataLossProtect) -> crate::c_types::PublicKey { - let mut inner_val = &mut this_ptr.get_native_mut_ref().my_current_per_commitment_point; - crate::c_types::PublicKey::from_rust(&inner_val) -} -/// The sender's per-commitment point for their current commitment transaction -#[no_mangle] -pub extern "C" fn DataLossProtect_set_my_current_per_commitment_point(this_ptr: &mut DataLossProtect, mut val: crate::c_types::PublicKey) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.my_current_per_commitment_point = val.into_rust(); -} -/// Constructs a new DataLossProtect given each field -#[must_use] -#[no_mangle] -pub extern "C" fn DataLossProtect_new(mut your_last_per_commitment_secret_arg: crate::c_types::ThirtyTwoBytes, mut my_current_per_commitment_point_arg: crate::c_types::PublicKey) -> DataLossProtect { - DataLossProtect { inner: ObjOps::heap_alloc(nativeDataLossProtect { - your_last_per_commitment_secret: your_last_per_commitment_secret_arg.data, - my_current_per_commitment_point: my_current_per_commitment_point_arg.into_rust(), - }), is_owned: true } -} -impl Clone for DataLossProtect { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeDataLossProtect>::is_null(self.inner) { core::ptr::null_mut() } else { - ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, - is_owned: true, - } - } -} -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn DataLossProtect_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeDataLossProtect)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the DataLossProtect -pub extern "C" fn DataLossProtect_clone(orig: &DataLossProtect) -> DataLossProtect { - orig.clone() -} -/// Checks if two DataLossProtects contain equal inner contents. -/// This ignores pointers and is_owned flags and looks at the values in fields. -/// Two objects with NULL inner values will be considered "equal" here. -#[no_mangle] -pub extern "C" fn DataLossProtect_eq(a: &DataLossProtect, b: &DataLossProtect) -> bool { - if a.inner == b.inner { return true; } - if a.inner.is_null() || b.inner.is_null() { return false; } - if a.get_native_ref() == b.get_native_ref() { true } else { false } -} - use lightning::ln::msgs::ChannelReestablish as nativeChannelReestablishImport; pub(crate) type nativeChannelReestablish = nativeChannelReestablishImport; @@ -3227,6 +5064,57 @@ pub extern "C" fn ChannelReestablish_get_next_remote_commitment_number(this_ptr: pub extern "C" fn ChannelReestablish_set_next_remote_commitment_number(this_ptr: &mut ChannelReestablish, mut val: u64) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_remote_commitment_number = val; } +/// Proof that the sender knows the per-commitment secret of a specific commitment transaction +/// belonging to the recipient +#[no_mangle] +pub extern "C" fn ChannelReestablish_get_your_last_per_commitment_secret(this_ptr: &ChannelReestablish) -> *const [u8; 32] { + let mut inner_val = &mut this_ptr.get_native_mut_ref().your_last_per_commitment_secret; + inner_val +} +/// Proof that the sender knows the per-commitment secret of a specific commitment transaction +/// belonging to the recipient +#[no_mangle] +pub extern "C" fn ChannelReestablish_set_your_last_per_commitment_secret(this_ptr: &mut ChannelReestablish, mut val: crate::c_types::ThirtyTwoBytes) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.your_last_per_commitment_secret = val.data; +} +/// The sender's per-commitment point for their current commitment transaction +#[no_mangle] +pub extern "C" fn ChannelReestablish_get_my_current_per_commitment_point(this_ptr: &ChannelReestablish) -> crate::c_types::PublicKey { + let mut inner_val = &mut this_ptr.get_native_mut_ref().my_current_per_commitment_point; + crate::c_types::PublicKey::from_rust(&inner_val) +} +/// The sender's per-commitment point for their current commitment transaction +#[no_mangle] +pub extern "C" fn ChannelReestablish_set_my_current_per_commitment_point(this_ptr: &mut ChannelReestablish, mut val: crate::c_types::PublicKey) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.my_current_per_commitment_point = val.into_rust(); +} +/// The next funding transaction ID +#[no_mangle] +pub extern "C" fn ChannelReestablish_get_next_funding_txid(this_ptr: &ChannelReestablish) -> crate::c_types::derived::COption_TxidZ { + let mut inner_val = &mut this_ptr.get_native_mut_ref().next_funding_txid; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_TxidZ::None } else { crate::c_types::derived::COption_TxidZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option is otherwise un-expressable. */ { crate::c_types::ThirtyTwoBytes { data: (*inner_val.as_ref().unwrap()).clone().into_inner() } }) }; + local_inner_val +} +/// The next funding transaction ID +#[no_mangle] +pub extern "C" fn ChannelReestablish_set_next_funding_txid(this_ptr: &mut ChannelReestablish, mut val: crate::c_types::derived::COption_TxidZ) { + let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::bitcoin::hash_types::Txid::from_slice(&{ val_opt.take() }.data[..]).unwrap() }})} }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_funding_txid = local_val; +} +/// Constructs a new ChannelReestablish given each field +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelReestablish_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut next_local_commitment_number_arg: u64, mut next_remote_commitment_number_arg: u64, mut your_last_per_commitment_secret_arg: crate::c_types::ThirtyTwoBytes, mut my_current_per_commitment_point_arg: crate::c_types::PublicKey, mut next_funding_txid_arg: crate::c_types::derived::COption_TxidZ) -> ChannelReestablish { + let mut local_next_funding_txid_arg = { /*next_funding_txid_arg*/ let next_funding_txid_arg_opt = next_funding_txid_arg; if next_funding_txid_arg_opt.is_none() { None } else { Some({ { ::bitcoin::hash_types::Txid::from_slice(&{ next_funding_txid_arg_opt.take() }.data[..]).unwrap() }})} }; + ChannelReestablish { inner: ObjOps::heap_alloc(nativeChannelReestablish { + channel_id: channel_id_arg.data, + next_local_commitment_number: next_local_commitment_number_arg, + next_remote_commitment_number: next_remote_commitment_number_arg, + your_last_per_commitment_secret: your_last_per_commitment_secret_arg.data, + my_current_per_commitment_point: my_current_per_commitment_point_arg.into_rust(), + next_funding_txid: local_next_funding_txid_arg, + }), is_owned: true } +} impl Clone for ChannelReestablish { fn clone(&self) -> Self { Self { @@ -5400,6 +7288,11 @@ pub enum ErrorAction { /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None msg: crate::lightning::ln::msgs::ErrorMessage, }, + /// The peer did something incorrect. Tell them without closing any channels and disconnect them. + DisconnectPeerWithWarning { + /// A warning message which we should make an effort to send before we disconnect. + msg: crate::lightning::ln::msgs::WarningMessage, + }, /// The peer did something harmless that we weren't able to process, just log and ignore IgnoreError, /// The peer did something harmless that we weren't able to meaningfully process. @@ -5439,6 +7332,12 @@ impl ErrorAction { msg: local_msg_nonref, } }, + ErrorAction::DisconnectPeerWithWarning {ref msg, } => { + let mut msg_nonref = Clone::clone(msg); + nativeErrorAction::DisconnectPeerWithWarning { + msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, + } + }, ErrorAction::IgnoreError => nativeErrorAction::IgnoreError, ErrorAction::IgnoreAndLog (ref a, ) => { let mut a_nonref = Clone::clone(a); @@ -5472,6 +7371,11 @@ impl ErrorAction { msg: local_msg, } }, + ErrorAction::DisconnectPeerWithWarning {mut msg, } => { + nativeErrorAction::DisconnectPeerWithWarning { + msg: *unsafe { Box::from_raw(msg.take_inner()) }, + } + }, ErrorAction::IgnoreError => nativeErrorAction::IgnoreError, ErrorAction::IgnoreAndLog (mut a, ) => { nativeErrorAction::IgnoreAndLog ( @@ -5502,6 +7406,12 @@ impl ErrorAction { msg: local_msg_nonref, } }, + nativeErrorAction::DisconnectPeerWithWarning {ref msg, } => { + let mut msg_nonref = Clone::clone(msg); + ErrorAction::DisconnectPeerWithWarning { + msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, + } + }, nativeErrorAction::IgnoreError => ErrorAction::IgnoreError, nativeErrorAction::IgnoreAndLog (ref a, ) => { let mut a_nonref = Clone::clone(a); @@ -5535,6 +7445,11 @@ impl ErrorAction { msg: local_msg, } }, + nativeErrorAction::DisconnectPeerWithWarning {mut msg, } => { + ErrorAction::DisconnectPeerWithWarning { + msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg), is_owned: true }, + } + }, nativeErrorAction::IgnoreError => ErrorAction::IgnoreError, nativeErrorAction::IgnoreAndLog (mut a, ) => { ErrorAction::IgnoreAndLog ( @@ -5572,6 +7487,13 @@ pub extern "C" fn ErrorAction_disconnect_peer(msg: crate::lightning::ln::msgs::E } } #[no_mangle] +/// Utility method to constructs a new DisconnectPeerWithWarning-variant ErrorAction +pub extern "C" fn ErrorAction_disconnect_peer_with_warning(msg: crate::lightning::ln::msgs::WarningMessage) -> ErrorAction { + ErrorAction::DisconnectPeerWithWarning { + msg, + } +} +#[no_mangle] /// Utility method to constructs a new IgnoreError-variant ErrorAction pub extern "C" fn ErrorAction_ignore_error() -> ErrorAction { ErrorAction::IgnoreError} @@ -5889,8 +7811,12 @@ pub struct ChannelMessageHandler { pub this_arg: *mut c_void, /// Handle an incoming `open_channel` message from the given peer. pub handle_open_channel: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::OpenChannel), + /// Handle an incoming `open_channel2` message from the given peer. + pub handle_open_channel_v2: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::OpenChannelV2), /// Handle an incoming `accept_channel` message from the given peer. pub handle_accept_channel: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::AcceptChannel), + /// Handle an incoming `accept_channel2` message from the given peer. + pub handle_accept_channel_v2: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::AcceptChannelV2), /// Handle an incoming `funding_created` message from the given peer. pub handle_funding_created: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::FundingCreated), /// Handle an incoming `funding_signed` message from the given peer. @@ -5901,6 +7827,24 @@ pub struct ChannelMessageHandler { pub handle_shutdown: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::Shutdown), /// Handle an incoming `closing_signed` message from the given peer. pub handle_closing_signed: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ClosingSigned), + /// Handle an incoming `tx_add_input message` from the given peer. + pub handle_tx_add_input: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxAddInput), + /// Handle an incoming `tx_add_output` message from the given peer. + pub handle_tx_add_output: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxAddOutput), + /// Handle an incoming `tx_remove_input` message from the given peer. + pub handle_tx_remove_input: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxRemoveInput), + /// Handle an incoming `tx_remove_output` message from the given peer. + pub handle_tx_remove_output: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxRemoveOutput), + /// Handle an incoming `tx_complete message` from the given peer. + pub handle_tx_complete: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxComplete), + /// Handle an incoming `tx_signatures` message from the given peer. + pub handle_tx_signatures: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxSignatures), + /// Handle an incoming `tx_init_rbf` message from the given peer. + pub handle_tx_init_rbf: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxInitRbf), + /// Handle an incoming `tx_ack_rbf` message from the given peer. + pub handle_tx_ack_rbf: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxAckRbf), + /// Handle an incoming `tx_abort message` from the given peer. + pub handle_tx_abort: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxAbort), /// Handle an incoming `update_add_htlc` message from the given peer. pub handle_update_add_htlc: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::UpdateAddHTLC), /// Handle an incoming `update_fulfill_htlc` message from the given peer. @@ -5924,7 +7868,6 @@ pub struct ChannelMessageHandler { /// May return an `Err(())` if the features the peer supports are not sufficient to communicate /// with us. Implementors should be somewhat conservative about doing so, however, as other /// message handlers may still wish to communicate with this peer. - #[must_use] pub peer_connected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::Init, inbound: bool) -> crate::c_types::derived::CResult_NoneNoneZ, /// Handle an incoming `channel_reestablish` message from the given peer. pub handle_channel_reestablish: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ChannelReestablish), @@ -5935,15 +7878,18 @@ pub struct ChannelMessageHandler { /// Gets the node feature flags which this handler itself supports. All available handlers are /// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`] /// which are broadcasted in our [`NodeAnnouncement`] message. - #[must_use] pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures, /// Gets the init feature flags which should be sent to the given peer. All available handlers /// are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`] /// which are sent in our [`Init`] message. /// /// Note that this method is called before [`Self::peer_connected`]. - #[must_use] pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures, + /// Gets the genesis hashes for this `ChannelMessageHandler` indicating which chains it supports. + /// + /// If it's `None`, then no particular network chain hash compatibility will be enforced when + /// connecting to peers. + pub get_genesis_hashes: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::COption_CVec_ChainHashZZ, /// Implementation of MessageSendEventsProvider for this object. pub MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider, /// Frees any resources associated with this object given its this_arg pointer. @@ -5957,12 +7903,23 @@ pub(crate) extern "C" fn ChannelMessageHandler_clone_fields(orig: &ChannelMessag ChannelMessageHandler { this_arg: orig.this_arg, handle_open_channel: Clone::clone(&orig.handle_open_channel), + handle_open_channel_v2: Clone::clone(&orig.handle_open_channel_v2), handle_accept_channel: Clone::clone(&orig.handle_accept_channel), + handle_accept_channel_v2: Clone::clone(&orig.handle_accept_channel_v2), handle_funding_created: Clone::clone(&orig.handle_funding_created), handle_funding_signed: Clone::clone(&orig.handle_funding_signed), handle_channel_ready: Clone::clone(&orig.handle_channel_ready), handle_shutdown: Clone::clone(&orig.handle_shutdown), handle_closing_signed: Clone::clone(&orig.handle_closing_signed), + handle_tx_add_input: Clone::clone(&orig.handle_tx_add_input), + handle_tx_add_output: Clone::clone(&orig.handle_tx_add_output), + handle_tx_remove_input: Clone::clone(&orig.handle_tx_remove_input), + handle_tx_remove_output: Clone::clone(&orig.handle_tx_remove_output), + handle_tx_complete: Clone::clone(&orig.handle_tx_complete), + handle_tx_signatures: Clone::clone(&orig.handle_tx_signatures), + handle_tx_init_rbf: Clone::clone(&orig.handle_tx_init_rbf), + handle_tx_ack_rbf: Clone::clone(&orig.handle_tx_ack_rbf), + handle_tx_abort: Clone::clone(&orig.handle_tx_abort), handle_update_add_htlc: Clone::clone(&orig.handle_update_add_htlc), handle_update_fulfill_htlc: Clone::clone(&orig.handle_update_fulfill_htlc), handle_update_fail_htlc: Clone::clone(&orig.handle_update_fail_htlc), @@ -5978,6 +7935,7 @@ pub(crate) extern "C" fn ChannelMessageHandler_clone_fields(orig: &ChannelMessag handle_error: Clone::clone(&orig.handle_error), provided_node_features: Clone::clone(&orig.provided_node_features), provided_init_features: Clone::clone(&orig.provided_init_features), + get_genesis_hashes: Clone::clone(&orig.get_genesis_hashes), MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider_clone_fields(&orig.MessageSendEventsProvider), free: Clone::clone(&orig.free), } @@ -5995,9 +7953,15 @@ impl rustChannelMessageHandler for ChannelMessageHandler { fn handle_open_channel(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::OpenChannel) { (self.handle_open_channel)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::OpenChannel { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::OpenChannel<>) as *mut _) }, is_owned: false }) } + fn handle_open_channel_v2(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::OpenChannelV2) { + (self.handle_open_channel_v2)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::OpenChannelV2 { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::OpenChannelV2<>) as *mut _) }, is_owned: false }) + } fn handle_accept_channel(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::AcceptChannel) { (self.handle_accept_channel)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::AcceptChannel { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::AcceptChannel<>) as *mut _) }, is_owned: false }) } + fn handle_accept_channel_v2(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::AcceptChannelV2) { + (self.handle_accept_channel_v2)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::AcceptChannelV2 { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::AcceptChannelV2<>) as *mut _) }, is_owned: false }) + } fn handle_funding_created(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::FundingCreated) { (self.handle_funding_created)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::FundingCreated { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::FundingCreated<>) as *mut _) }, is_owned: false }) } @@ -6013,6 +7977,33 @@ impl rustChannelMessageHandler for ChannelMessageHandler { fn handle_closing_signed(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ClosingSigned) { (self.handle_closing_signed)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::ClosingSigned { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::ClosingSigned<>) as *mut _) }, is_owned: false }) } + fn handle_tx_add_input(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxAddInput) { + (self.handle_tx_add_input)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxAddInput { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxAddInput<>) as *mut _) }, is_owned: false }) + } + fn handle_tx_add_output(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxAddOutput) { + (self.handle_tx_add_output)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxAddOutput { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxAddOutput<>) as *mut _) }, is_owned: false }) + } + fn handle_tx_remove_input(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxRemoveInput) { + (self.handle_tx_remove_input)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxRemoveInput { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxRemoveInput<>) as *mut _) }, is_owned: false }) + } + fn handle_tx_remove_output(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxRemoveOutput) { + (self.handle_tx_remove_output)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxRemoveOutput { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxRemoveOutput<>) as *mut _) }, is_owned: false }) + } + fn handle_tx_complete(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxComplete) { + (self.handle_tx_complete)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxComplete { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxComplete<>) as *mut _) }, is_owned: false }) + } + fn handle_tx_signatures(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxSignatures) { + (self.handle_tx_signatures)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxSignatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxSignatures<>) as *mut _) }, is_owned: false }) + } + fn handle_tx_init_rbf(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxInitRbf) { + (self.handle_tx_init_rbf)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxInitRbf { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxInitRbf<>) as *mut _) }, is_owned: false }) + } + fn handle_tx_ack_rbf(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxAckRbf) { + (self.handle_tx_ack_rbf)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxAckRbf { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxAckRbf<>) as *mut _) }, is_owned: false }) + } + fn handle_tx_abort(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxAbort) { + (self.handle_tx_abort)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxAbort { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxAbort<>) as *mut _) }, is_owned: false }) + } fn handle_update_add_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateAddHTLC) { (self.handle_update_add_htlc)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::UpdateAddHTLC { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::UpdateAddHTLC<>) as *mut _) }, is_owned: false }) } @@ -6062,6 +8053,11 @@ impl rustChannelMessageHandler for ChannelMessageHandler { let mut ret = (self.provided_init_features)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id)); *unsafe { Box::from_raw(ret.take_inner()) } } + fn get_genesis_hashes(&self) -> Option> { + let mut ret = (self.get_genesis_hashes)(self.this_arg); + let mut local_ret = { /*ret*/ let ret_opt = ret; if ret_opt.is_none() { None } else { Some({ { let mut local_ret_0 = Vec::new(); for mut item in { ret_opt.take() }.into_rust().drain(..) { local_ret_0.push( { ::bitcoin::blockdata::constants::ChainHash::from(&item.data[..]) }); }; local_ret_0 }})} }; + local_ret + } } // We're essentially a pointer already, or at least a set of pointers, so allow us to be used @@ -6096,20 +8092,16 @@ pub struct RoutingMessageHandler { pub this_arg: *mut c_void, /// Handle an incoming `node_announcement` message, returning `true` if it should be forwarded on, /// `false` or returning an `Err` otherwise. - #[must_use] pub handle_node_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ, /// Handle a `channel_announcement` message, returning `true` if it should be forwarded on, `false` /// or returning an `Err` otherwise. - #[must_use] pub handle_channel_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ, /// Handle an incoming `channel_update` message, returning true if it should be forwarded on, /// `false` or returning an `Err` otherwise. - #[must_use] pub handle_channel_update: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CResult_boolLightningErrorZ, /// Gets channel announcements and updates required to dump our routing table to a remote node, /// starting at the `short_channel_id` indicated by `starting_point` and including announcements /// for a single channel. - #[must_use] pub get_next_channel_announcement: extern "C" fn (this_arg: *const c_void, starting_point: u64) -> crate::c_types::derived::COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ, /// Gets a node announcement required to dump our routing table to a remote node, starting at /// the node *after* the provided pubkey and including up to one announcement immediately @@ -6118,7 +8110,6 @@ pub struct RoutingMessageHandler { /// /// Note that starting_point (or a relevant inner pointer) may be NULL or all-0s to represent None /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None - #[must_use] pub get_next_node_announcement: extern "C" fn (this_arg: *const c_void, starting_point: crate::lightning::routing::gossip::NodeId) -> crate::lightning::ln::msgs::NodeAnnouncement, /// Called when a connection is established with a peer. This can be used to /// perform routing table synchronization using a strategy defined by the @@ -6127,44 +8118,36 @@ pub struct RoutingMessageHandler { /// May return an `Err(())` if the features the peer supports are not sufficient to communicate /// with us. Implementors should be somewhat conservative about doing so, however, as other /// message handlers may still wish to communicate with this peer. - #[must_use] pub peer_connected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, init: &crate::lightning::ln::msgs::Init, inbound: bool) -> crate::c_types::derived::CResult_NoneNoneZ, /// Handles the reply of a query we initiated to learn about channels /// for a given range of blocks. We can expect to receive one or more /// replies to a single query. - #[must_use] pub handle_reply_channel_range: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::ReplyChannelRange) -> crate::c_types::derived::CResult_NoneLightningErrorZ, /// Handles the reply of a query we initiated asking for routing gossip /// messages for a list of channels. We should receive this message when /// a node has completed its best effort to send us the pertaining routing /// gossip messages. - #[must_use] pub handle_reply_short_channel_ids_end: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::ReplyShortChannelIdsEnd) -> crate::c_types::derived::CResult_NoneLightningErrorZ, /// Handles when a peer asks us to send a list of `short_channel_id`s /// for the requested range of blocks. - #[must_use] pub handle_query_channel_range: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::QueryChannelRange) -> crate::c_types::derived::CResult_NoneLightningErrorZ, /// Handles when a peer asks us to send routing gossip messages for a /// list of `short_channel_id`s. - #[must_use] pub handle_query_short_channel_ids: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::QueryShortChannelIds) -> crate::c_types::derived::CResult_NoneLightningErrorZ, /// Indicates that there are a large number of [`ChannelAnnouncement`] (or other) messages /// pending some async action. While there is no guarantee of the rate of future messages, the /// caller should seek to reduce the rate of new gossip messages handled, especially /// [`ChannelAnnouncement`]s. - #[must_use] pub processing_queue_high: extern "C" fn (this_arg: *const c_void) -> bool, /// Gets the node feature flags which this handler itself supports. All available handlers are /// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`] /// which are broadcasted in our [`NodeAnnouncement`] message. - #[must_use] pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures, /// Gets the init feature flags which should be sent to the given peer. All available handlers /// are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`] /// which are sent in our [`Init`] message. /// /// Note that this method is called before [`Self::peer_connected`]. - #[must_use] pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures, /// Implementation of MessageSendEventsProvider for this object. pub MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider, @@ -6302,7 +8285,6 @@ pub struct OnionMessageHandler { /// May return an `Err(())` if the features the peer supports are not sufficient to communicate /// with us. Implementors should be somewhat conservative about doing so, however, as other /// message handlers may still wish to communicate with this peer. - #[must_use] pub peer_connected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, init: &crate::lightning::ln::msgs::Init, inbound: bool) -> crate::c_types::derived::CResult_NoneNoneZ, /// Indicates a connection to the peer failed/an existing connection was lost. Allows handlers to /// drop and refuse to forward onion messages to this peer. @@ -6310,14 +8292,12 @@ pub struct OnionMessageHandler { /// Gets the node feature flags which this handler itself supports. All available handlers are /// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`] /// which are broadcasted in our [`NodeAnnouncement`] message. - #[must_use] pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures, /// Gets the init feature flags which should be sent to the given peer. All available handlers /// are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`] /// which are sent in our [`Init`] message. /// /// Note that this method is called before [`Self::peer_connected`]. - #[must_use] pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures, /// Implementation of OnionMessageProvider for this object. pub OnionMessageProvider: crate::lightning::events::OnionMessageProvider, @@ -6417,6 +8397,166 @@ pub extern "C" fn AcceptChannel_read(ser: crate::c_types::u8slice) -> crate::c_t local_res } #[no_mangle] +/// Serialize the AcceptChannelV2 object into a byte array which can be read by AcceptChannelV2_read +pub extern "C" fn AcceptChannelV2_write(obj: &crate::lightning::ln::msgs::AcceptChannelV2) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[no_mangle] +pub(crate) extern "C" fn AcceptChannelV2_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAcceptChannelV2) }) +} +#[no_mangle] +/// Read a AcceptChannelV2 from a byte array, created by AcceptChannelV2_write +pub extern "C" fn AcceptChannelV2_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_AcceptChannelV2DecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::AcceptChannelV2 { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} +#[no_mangle] +/// Serialize the TxAddInput object into a byte array which can be read by TxAddInput_read +pub extern "C" fn TxAddInput_write(obj: &crate::lightning::ln::msgs::TxAddInput) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[no_mangle] +pub(crate) extern "C" fn TxAddInput_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxAddInput) }) +} +#[no_mangle] +/// Read a TxAddInput from a byte array, created by TxAddInput_write +pub extern "C" fn TxAddInput_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxAddInputDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::TxAddInput { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} +#[no_mangle] +/// Serialize the TxAddOutput object into a byte array which can be read by TxAddOutput_read +pub extern "C" fn TxAddOutput_write(obj: &crate::lightning::ln::msgs::TxAddOutput) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[no_mangle] +pub(crate) extern "C" fn TxAddOutput_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxAddOutput) }) +} +#[no_mangle] +/// Read a TxAddOutput from a byte array, created by TxAddOutput_write +pub extern "C" fn TxAddOutput_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxAddOutputDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::TxAddOutput { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} +#[no_mangle] +/// Serialize the TxRemoveInput object into a byte array which can be read by TxRemoveInput_read +pub extern "C" fn TxRemoveInput_write(obj: &crate::lightning::ln::msgs::TxRemoveInput) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[no_mangle] +pub(crate) extern "C" fn TxRemoveInput_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxRemoveInput) }) +} +#[no_mangle] +/// Read a TxRemoveInput from a byte array, created by TxRemoveInput_write +pub extern "C" fn TxRemoveInput_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxRemoveInputDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::TxRemoveInput { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} +#[no_mangle] +/// Serialize the TxRemoveOutput object into a byte array which can be read by TxRemoveOutput_read +pub extern "C" fn TxRemoveOutput_write(obj: &crate::lightning::ln::msgs::TxRemoveOutput) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[no_mangle] +pub(crate) extern "C" fn TxRemoveOutput_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxRemoveOutput) }) +} +#[no_mangle] +/// Read a TxRemoveOutput from a byte array, created by TxRemoveOutput_write +pub extern "C" fn TxRemoveOutput_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxRemoveOutputDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::TxRemoveOutput { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} +#[no_mangle] +/// Serialize the TxComplete object into a byte array which can be read by TxComplete_read +pub extern "C" fn TxComplete_write(obj: &crate::lightning::ln::msgs::TxComplete) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[no_mangle] +pub(crate) extern "C" fn TxComplete_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxComplete) }) +} +#[no_mangle] +/// Read a TxComplete from a byte array, created by TxComplete_write +pub extern "C" fn TxComplete_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxCompleteDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::TxComplete { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} +#[no_mangle] +/// Serialize the TxSignatures object into a byte array which can be read by TxSignatures_read +pub extern "C" fn TxSignatures_write(obj: &crate::lightning::ln::msgs::TxSignatures) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[no_mangle] +pub(crate) extern "C" fn TxSignatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxSignatures) }) +} +#[no_mangle] +/// Read a TxSignatures from a byte array, created by TxSignatures_write +pub extern "C" fn TxSignatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxSignaturesDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::TxSignatures { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} +#[no_mangle] +/// Serialize the TxInitRbf object into a byte array which can be read by TxInitRbf_read +pub extern "C" fn TxInitRbf_write(obj: &crate::lightning::ln::msgs::TxInitRbf) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[no_mangle] +pub(crate) extern "C" fn TxInitRbf_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxInitRbf) }) +} +#[no_mangle] +/// Read a TxInitRbf from a byte array, created by TxInitRbf_write +pub extern "C" fn TxInitRbf_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxInitRbfDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::TxInitRbf { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} +#[no_mangle] +/// Serialize the TxAckRbf object into a byte array which can be read by TxAckRbf_read +pub extern "C" fn TxAckRbf_write(obj: &crate::lightning::ln::msgs::TxAckRbf) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[no_mangle] +pub(crate) extern "C" fn TxAckRbf_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxAckRbf) }) +} +#[no_mangle] +/// Read a TxAckRbf from a byte array, created by TxAckRbf_write +pub extern "C" fn TxAckRbf_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxAckRbfDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::TxAckRbf { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} +#[no_mangle] +/// Serialize the TxAbort object into a byte array which can be read by TxAbort_read +pub extern "C" fn TxAbort_write(obj: &crate::lightning::ln::msgs::TxAbort) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[no_mangle] +pub(crate) extern "C" fn TxAbort_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxAbort) }) +} +#[no_mangle] +/// Read a TxAbort from a byte array, created by TxAbort_write +pub extern "C" fn TxAbort_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TxAbortDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::TxAbort { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} +#[no_mangle] /// Serialize the AnnouncementSignatures object into a byte array which can be read by AnnouncementSignatures_read pub extern "C" fn AnnouncementSignatures_write(obj: &crate::lightning::ln::msgs::AnnouncementSignatures) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) @@ -6577,6 +8717,22 @@ pub extern "C" fn OpenChannel_read(ser: crate::c_types::u8slice) -> crate::c_typ local_res } #[no_mangle] +/// Serialize the OpenChannelV2 object into a byte array which can be read by OpenChannelV2_read +pub extern "C" fn OpenChannelV2_write(obj: &crate::lightning::ln::msgs::OpenChannelV2) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[no_mangle] +pub(crate) extern "C" fn OpenChannelV2_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOpenChannelV2) }) +} +#[no_mangle] +/// Read a OpenChannelV2 from a byte array, created by OpenChannelV2_write +pub extern "C" fn OpenChannelV2_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OpenChannelV2DecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::OpenChannelV2 { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} +#[no_mangle] /// Serialize the RevokeAndACK object into a byte array which can be read by RevokeAndACK_read pub extern "C" fn RevokeAndACK_write(obj: &crate::lightning::ln::msgs::RevokeAndACK) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) diff --git a/lightning-c-bindings/src/lightning/ln/outbound_payment.rs b/lightning-c-bindings/src/lightning/ln/outbound_payment.rs index 004ba53b..05afcdc2 100644 --- a/lightning-c-bindings/src/lightning/ln/outbound_payment.rs +++ b/lightning-c-bindings/src/lightning/ln/outbound_payment.rs @@ -216,6 +216,12 @@ pub extern "C" fn RetryableSendFailure_route_not_found() -> RetryableSendFailure /// Utility method to constructs a new DuplicatePayment-variant RetryableSendFailure pub extern "C" fn RetryableSendFailure_duplicate_payment() -> RetryableSendFailure { RetryableSendFailure::DuplicatePayment} +/// Checks if two RetryableSendFailures contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +#[no_mangle] +pub extern "C" fn RetryableSendFailure_eq(a: &RetryableSendFailure, b: &RetryableSendFailure) -> bool { + if &a.to_native() == &b.to_native() { true } else { false } +} /// If a payment fails to send with [`ChannelManager::send_payment_with_route`], it can be in one /// of several states. This enum is returned as the Err() type describing which state the payment /// is in, see the description of individual enum states for more. @@ -535,15 +541,13 @@ impl RecipientOnionFields { /// If you do not have one, the [`Route`] you pay over must not contain multiple paths as /// multi-path payments require a recipient-provided secret. /// -/// Note that for spontaneous payments most lightning nodes do not currently support MPP -/// receives, thus you should generally never be providing a secret here for spontaneous -/// payments. -/// -/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None +/// Some implementations may reject spontaneous payments with payment secrets, so you may only +/// want to provide a secret for a spontaneous payment if MPP is needed and you know your +/// recipient will not reject it. #[no_mangle] -pub extern "C" fn RecipientOnionFields_get_payment_secret(this_ptr: &RecipientOnionFields) -> crate::c_types::ThirtyTwoBytes { +pub extern "C" fn RecipientOnionFields_get_payment_secret(this_ptr: &RecipientOnionFields) -> crate::c_types::derived::COption_PaymentSecretZ { let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_secret; - let mut local_inner_val = if inner_val.is_none() { crate::c_types::ThirtyTwoBytes::null() } else { { crate::c_types::ThirtyTwoBytes { data: (inner_val.unwrap()).0 } } }; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_PaymentSecretZ::None } else { crate::c_types::derived::COption_PaymentSecretZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option is otherwise un-expressable. */ { crate::c_types::ThirtyTwoBytes { data: (*inner_val.as_ref().unwrap()).clone().0 } }) }; local_inner_val } /// The [`PaymentSecret`] is an arbitrary 32 bytes provided by the recipient for us to repeat @@ -554,14 +558,12 @@ pub extern "C" fn RecipientOnionFields_get_payment_secret(this_ptr: &RecipientOn /// If you do not have one, the [`Route`] you pay over must not contain multiple paths as /// multi-path payments require a recipient-provided secret. /// -/// Note that for spontaneous payments most lightning nodes do not currently support MPP -/// receives, thus you should generally never be providing a secret here for spontaneous -/// payments. -/// -/// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None +/// Some implementations may reject spontaneous payments with payment secrets, so you may only +/// want to provide a secret for a spontaneous payment if MPP is needed and you know your +/// recipient will not reject it. #[no_mangle] -pub extern "C" fn RecipientOnionFields_set_payment_secret(this_ptr: &mut RecipientOnionFields, mut val: crate::c_types::ThirtyTwoBytes) { - let mut local_val = if val.data == [0; 32] { None } else { Some( { ::lightning::ln::PaymentSecret(val.data) }) }; +pub extern "C" fn RecipientOnionFields_set_payment_secret(this_ptr: &mut RecipientOnionFields, mut val: crate::c_types::derived::COption_PaymentSecretZ) { + let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::lightning::ln::PaymentSecret({ val_opt.take() }.data) }})} }; unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_secret = local_val; } /// The payment metadata serves a similar purpose as [`Self::payment_secret`] but is of @@ -604,8 +606,8 @@ pub extern "C" fn RecipientOnionFields_set_payment_metadata(this_ptr: &mut Recip /// Constructs a new RecipientOnionFields given each field #[must_use] #[no_mangle] -pub extern "C" fn RecipientOnionFields_new(mut payment_secret_arg: crate::c_types::ThirtyTwoBytes, mut payment_metadata_arg: crate::c_types::derived::COption_CVec_u8ZZ) -> RecipientOnionFields { - let mut local_payment_secret_arg = if payment_secret_arg.data == [0; 32] { None } else { Some( { ::lightning::ln::PaymentSecret(payment_secret_arg.data) }) }; +pub extern "C" fn RecipientOnionFields_new(mut payment_secret_arg: crate::c_types::derived::COption_PaymentSecretZ, mut payment_metadata_arg: crate::c_types::derived::COption_CVec_u8ZZ) -> RecipientOnionFields { + let mut local_payment_secret_arg = { /*payment_secret_arg*/ let payment_secret_arg_opt = payment_secret_arg; if payment_secret_arg_opt.is_none() { None } else { Some({ { ::lightning::ln::PaymentSecret({ payment_secret_arg_opt.take() }.data) }})} }; let mut local_payment_metadata_arg = { /*payment_metadata_arg*/ let payment_metadata_arg_opt = payment_metadata_arg; if payment_metadata_arg_opt.is_none() { None } else { Some({ { let mut local_payment_metadata_arg_0 = Vec::new(); for mut item in { payment_metadata_arg_opt.take() }.into_rust().drain(..) { local_payment_metadata_arg_0.push( { item }); }; local_payment_metadata_arg_0 }})} }; RecipientOnionFields { inner: ObjOps::heap_alloc(nativeRecipientOnionFields { payment_secret: local_payment_secret_arg, @@ -667,10 +669,13 @@ pub extern "C" fn RecipientOnionFields_secret_only(mut payment_secret: crate::c_ } /// Creates a new [`RecipientOnionFields`] with no fields. This generally does not create -/// payable HTLCs except for spontaneous payments, i.e. this should generally only be used for -/// calls to [`ChannelManager::send_spontaneous_payment`]. +/// payable HTLCs except for single-path spontaneous payments, i.e. this should generally +/// only be used for calls to [`ChannelManager::send_spontaneous_payment`]. If you are sending +/// a spontaneous MPP this will not work as all MPP require payment secrets; you may +/// instead want to use [`RecipientOnionFields::secret_only`]. /// /// [`ChannelManager::send_spontaneous_payment`]: super::channelmanager::ChannelManager::send_spontaneous_payment +/// [`RecipientOnionFields::secret_only`]: RecipientOnionFields::secret_only #[must_use] #[no_mangle] pub extern "C" fn RecipientOnionFields_spontaneous_empty() -> crate::lightning::ln::outbound_payment::RecipientOnionFields { diff --git a/lightning-c-bindings/src/lightning/ln/peer_handler.rs b/lightning-c-bindings/src/lightning/ln/peer_handler.rs index 0842280f..6ac10683 100644 --- a/lightning-c-bindings/src/lightning/ln/peer_handler.rs +++ b/lightning-c-bindings/src/lightning/ln/peer_handler.rs @@ -38,13 +38,23 @@ pub struct CustomMessageHandler { /// Handles the given message sent from `sender_node_id`, possibly producing messages for /// [`CustomMessageHandler::get_and_clear_pending_msg`] to return and thus for [`PeerManager`] /// to send. - #[must_use] pub handle_custom_message: extern "C" fn (this_arg: *const c_void, msg: crate::lightning::ln::wire::Type, sender_node_id: crate::c_types::PublicKey) -> crate::c_types::derived::CResult_NoneLightningErrorZ, /// Returns the list of pending messages that were generated by the handler, clearing the list /// in the process. Each message is paired with the node id of the intended recipient. If no /// connection to the node exists, then the message is simply not sent. - #[must_use] pub get_and_clear_pending_msg: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_C2Tuple_PublicKeyTypeZZ, + /// Gets the node feature flags which this handler itself supports. All available handlers are + /// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`] + /// which are broadcasted in our [`NodeAnnouncement`] message. + /// + /// [`NodeAnnouncement`]: crate::ln::msgs::NodeAnnouncement + pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures, + /// Gets the init feature flags which should be sent to the given peer. All available handlers + /// are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`] + /// which are sent in our [`Init`] message. + /// + /// [`Init`]: crate::ln::msgs::Init + pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures, /// Implementation of CustomMessageReader for this object. pub CustomMessageReader: crate::lightning::ln::wire::CustomMessageReader, /// Frees any resources associated with this object given its this_arg pointer. @@ -59,6 +69,8 @@ pub(crate) extern "C" fn CustomMessageHandler_clone_fields(orig: &CustomMessageH this_arg: orig.this_arg, handle_custom_message: Clone::clone(&orig.handle_custom_message), get_and_clear_pending_msg: Clone::clone(&orig.get_and_clear_pending_msg), + provided_node_features: Clone::clone(&orig.provided_node_features), + provided_init_features: Clone::clone(&orig.provided_init_features), CustomMessageReader: crate::lightning::ln::wire::CustomMessageReader_clone_fields(&orig.CustomMessageReader), free: Clone::clone(&orig.free), } @@ -84,6 +96,14 @@ impl rustCustomMessageHandler for CustomMessageHandler { let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item.to_rust(); let mut local_ret_0 = (orig_ret_0_0.into_rust(), orig_ret_0_1); local_ret_0 }); }; local_ret } + fn provided_node_features(&self) -> lightning::ln::features::NodeFeatures { + let mut ret = (self.provided_node_features)(self.this_arg); + *unsafe { Box::from_raw(ret.take_inner()) } + } + fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning::ln::features::InitFeatures { + let mut ret = (self.provided_init_features)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id)); + *unsafe { Box::from_raw(ret.take_inner()) } + } } // We're essentially a pointer already, or at least a set of pointers, so allow us to be used @@ -387,6 +407,34 @@ extern "C" fn IgnoringMessageHandler_OnionMessageHandler_provided_init_features( crate::lightning::ln::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } +impl From for crate::lightning::onion_message::offers::OffersMessageHandler { + fn from(obj: nativeIgnoringMessageHandler) -> Self { + let mut rust_obj = IgnoringMessageHandler { inner: ObjOps::heap_alloc(obj), is_owned: true }; + let mut ret = IgnoringMessageHandler_as_OffersMessageHandler(&rust_obj); + // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn + rust_obj.inner = core::ptr::null_mut(); + ret.free = Some(IgnoringMessageHandler_free_void); + ret + } +} +/// Constructs a new OffersMessageHandler which calls the relevant methods on this_arg. +/// This copies the `inner` pointer in this_arg and thus the returned OffersMessageHandler must be freed before this_arg is +#[no_mangle] +pub extern "C" fn IgnoringMessageHandler_as_OffersMessageHandler(this_arg: &IgnoringMessageHandler) -> crate::lightning::onion_message::offers::OffersMessageHandler { + crate::lightning::onion_message::offers::OffersMessageHandler { + this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, + free: None, + handle_message: IgnoringMessageHandler_OffersMessageHandler_handle_message, + } +} + +#[must_use] +extern "C" fn IgnoringMessageHandler_OffersMessageHandler_handle_message(this_arg: *const c_void, mut message: crate::lightning::onion_message::offers::OffersMessage) -> crate::c_types::derived::COption_OffersMessageZ { + let mut ret = >::handle_message(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, message.into_native()); + let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_OffersMessageZ::None } else { crate::c_types::derived::COption_OffersMessageZ::Some( { crate::lightning::onion_message::offers::OffersMessage::native_into(ret.unwrap()) }) }; + local_ret +} + impl From for crate::lightning::onion_message::messenger::CustomOnionMessageHandler { fn from(obj: nativeIgnoringMessageHandler) -> Self { let mut rust_obj = IgnoringMessageHandler { inner: ObjOps::heap_alloc(obj), is_owned: true }; @@ -409,7 +457,8 @@ pub extern "C" fn IgnoringMessageHandler_as_CustomOnionMessageHandler(this_arg: } } -extern "C" fn IgnoringMessageHandler_CustomOnionMessageHandler_handle_custom_message(this_arg: *const c_void, mut msg: crate::lightning::onion_message::packet::CustomOnionMessageContents) { +#[must_use] +extern "C" fn IgnoringMessageHandler_CustomOnionMessageHandler_handle_custom_message(this_arg: *const c_void, mut msg: crate::lightning::onion_message::packet::CustomOnionMessageContents) -> crate::c_types::derived::COption_CustomOnionMessageContentsZ { unreachable!(); } #[must_use] @@ -476,6 +525,8 @@ pub extern "C" fn IgnoringMessageHandler_as_CustomMessageHandler(this_arg: &Igno free: None, handle_custom_message: IgnoringMessageHandler_CustomMessageHandler_handle_custom_message, get_and_clear_pending_msg: IgnoringMessageHandler_CustomMessageHandler_get_and_clear_pending_msg, + provided_node_features: IgnoringMessageHandler_CustomMessageHandler_provided_node_features, + provided_init_features: IgnoringMessageHandler_CustomMessageHandler_provided_init_features, CustomMessageReader: crate::lightning::ln::wire::CustomMessageReader { this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, free: None, @@ -494,6 +545,16 @@ extern "C" fn IgnoringMessageHandler_CustomMessageHandler_get_and_clear_pending_ let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item; let mut local_ret_0 = (crate::c_types::PublicKey::from_rust(&orig_ret_0_0), Into::into(orig_ret_0_1)).into(); local_ret_0 }); }; local_ret.into() } +#[must_use] +extern "C" fn IgnoringMessageHandler_CustomMessageHandler_provided_node_features(this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures { + let mut ret = >::provided_node_features(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, ); + crate::lightning::ln::features::NodeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } +} +#[must_use] +extern "C" fn IgnoringMessageHandler_CustomMessageHandler_provided_init_features(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures { + let mut ret = >::provided_init_features(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, &their_node_id.into_rust()); + crate::lightning::ln::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } +} use lightning::ln::peer_handler::ErroringMessageHandler as nativeErroringMessageHandlerImport; @@ -601,12 +662,23 @@ pub extern "C" fn ErroringMessageHandler_as_ChannelMessageHandler(this_arg: &Err this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, free: None, handle_open_channel: ErroringMessageHandler_ChannelMessageHandler_handle_open_channel, + handle_open_channel_v2: ErroringMessageHandler_ChannelMessageHandler_handle_open_channel_v2, handle_accept_channel: ErroringMessageHandler_ChannelMessageHandler_handle_accept_channel, + handle_accept_channel_v2: ErroringMessageHandler_ChannelMessageHandler_handle_accept_channel_v2, handle_funding_created: ErroringMessageHandler_ChannelMessageHandler_handle_funding_created, handle_funding_signed: ErroringMessageHandler_ChannelMessageHandler_handle_funding_signed, handle_channel_ready: ErroringMessageHandler_ChannelMessageHandler_handle_channel_ready, handle_shutdown: ErroringMessageHandler_ChannelMessageHandler_handle_shutdown, handle_closing_signed: ErroringMessageHandler_ChannelMessageHandler_handle_closing_signed, + handle_tx_add_input: ErroringMessageHandler_ChannelMessageHandler_handle_tx_add_input, + handle_tx_add_output: ErroringMessageHandler_ChannelMessageHandler_handle_tx_add_output, + handle_tx_remove_input: ErroringMessageHandler_ChannelMessageHandler_handle_tx_remove_input, + handle_tx_remove_output: ErroringMessageHandler_ChannelMessageHandler_handle_tx_remove_output, + handle_tx_complete: ErroringMessageHandler_ChannelMessageHandler_handle_tx_complete, + handle_tx_signatures: ErroringMessageHandler_ChannelMessageHandler_handle_tx_signatures, + handle_tx_init_rbf: ErroringMessageHandler_ChannelMessageHandler_handle_tx_init_rbf, + handle_tx_ack_rbf: ErroringMessageHandler_ChannelMessageHandler_handle_tx_ack_rbf, + handle_tx_abort: ErroringMessageHandler_ChannelMessageHandler_handle_tx_abort, handle_update_add_htlc: ErroringMessageHandler_ChannelMessageHandler_handle_update_add_htlc, handle_update_fulfill_htlc: ErroringMessageHandler_ChannelMessageHandler_handle_update_fulfill_htlc, handle_update_fail_htlc: ErroringMessageHandler_ChannelMessageHandler_handle_update_fail_htlc, @@ -622,6 +694,7 @@ pub extern "C" fn ErroringMessageHandler_as_ChannelMessageHandler(this_arg: &Err handle_error: ErroringMessageHandler_ChannelMessageHandler_handle_error, provided_node_features: ErroringMessageHandler_ChannelMessageHandler_provided_node_features, provided_init_features: ErroringMessageHandler_ChannelMessageHandler_provided_init_features, + get_genesis_hashes: ErroringMessageHandler_ChannelMessageHandler_get_genesis_hashes, MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider { this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, free: None, @@ -633,9 +706,15 @@ pub extern "C" fn ErroringMessageHandler_as_ChannelMessageHandler(this_arg: &Err extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_open_channel(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::OpenChannel) { >::handle_open_channel(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) } +extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_open_channel_v2(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::OpenChannelV2) { + >::handle_open_channel_v2(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) +} extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_accept_channel(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::AcceptChannel) { >::handle_accept_channel(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) } +extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_accept_channel_v2(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::AcceptChannelV2) { + >::handle_accept_channel_v2(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) +} extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_funding_created(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::FundingCreated) { >::handle_funding_created(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) } @@ -651,6 +730,33 @@ extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_shutdown(this_ extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_closing_signed(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ClosingSigned) { >::handle_closing_signed(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) } +extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_tx_add_input(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxAddInput) { + >::handle_tx_add_input(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) +} +extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_tx_add_output(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxAddOutput) { + >::handle_tx_add_output(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) +} +extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_tx_remove_input(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxRemoveInput) { + >::handle_tx_remove_input(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) +} +extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_tx_remove_output(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxRemoveOutput) { + >::handle_tx_remove_output(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) +} +extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_tx_complete(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxComplete) { + >::handle_tx_complete(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) +} +extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_tx_signatures(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxSignatures) { + >::handle_tx_signatures(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) +} +extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_tx_init_rbf(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxInitRbf) { + >::handle_tx_init_rbf(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) +} +extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_tx_ack_rbf(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxAckRbf) { + >::handle_tx_ack_rbf(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) +} +extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_tx_abort(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxAbort) { + >::handle_tx_abort(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) +} extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_update_add_htlc(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::UpdateAddHTLC) { >::handle_update_add_htlc(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) } @@ -703,10 +809,16 @@ extern "C" fn ErroringMessageHandler_ChannelMessageHandler_provided_init_feature let mut ret = >::provided_init_features(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust()); crate::lightning::ln::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } +#[must_use] +extern "C" fn ErroringMessageHandler_ChannelMessageHandler_get_genesis_hashes(this_arg: *const c_void) -> crate::c_types::derived::COption_CVec_ChainHashZZ { + let mut ret = >::get_genesis_hashes(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, ); + let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_CVec_ChainHashZZ::None } else { crate::c_types::derived::COption_CVec_ChainHashZZ::Some( { let mut local_ret_0 = Vec::new(); for mut item in ret.unwrap().drain(..) { local_ret_0.push( { crate::c_types::ThirtyTwoBytes { data: item.to_bytes() } }); }; local_ret_0.into() }) }; + local_ret +} use lightning::ln::peer_handler::MessageHandler as nativeMessageHandlerImport; -pub(crate) type nativeMessageHandler = nativeMessageHandlerImport; +pub(crate) type nativeMessageHandler = nativeMessageHandlerImport; /// Provides references to trait impls which handle different types of messages. #[must_use] @@ -789,27 +901,45 @@ pub extern "C" fn MessageHandler_get_route_handler(this_ptr: &MessageHandler) -> pub extern "C" fn MessageHandler_set_route_handler(this_ptr: &mut MessageHandler, mut val: crate::lightning::ln::msgs::RoutingMessageHandler) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.route_handler = val; } -/// A message handler which handles onion messages. For now, this can only be an -/// [`IgnoringMessageHandler`]. +/// A message handler which handles onion messages. This should generally be an +/// [`OnionMessenger`], but can also be an [`IgnoringMessageHandler`]. +/// +/// [`OnionMessenger`]: crate::onion_message::OnionMessenger #[no_mangle] pub extern "C" fn MessageHandler_get_onion_message_handler(this_ptr: &MessageHandler) -> *const crate::lightning::ln::msgs::OnionMessageHandler { let mut inner_val = &mut this_ptr.get_native_mut_ref().onion_message_handler; inner_val } -/// A message handler which handles onion messages. For now, this can only be an -/// [`IgnoringMessageHandler`]. +/// A message handler which handles onion messages. This should generally be an +/// [`OnionMessenger`], but can also be an [`IgnoringMessageHandler`]. +/// +/// [`OnionMessenger`]: crate::onion_message::OnionMessenger #[no_mangle] pub extern "C" fn MessageHandler_set_onion_message_handler(this_ptr: &mut MessageHandler, mut val: crate::lightning::ln::msgs::OnionMessageHandler) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.onion_message_handler = val; } +/// A message handler which handles custom messages. The only LDK-provided implementation is +/// [`IgnoringMessageHandler`]. +#[no_mangle] +pub extern "C" fn MessageHandler_get_custom_message_handler(this_ptr: &MessageHandler) -> *const crate::lightning::ln::peer_handler::CustomMessageHandler { + let mut inner_val = &mut this_ptr.get_native_mut_ref().custom_message_handler; + inner_val +} +/// A message handler which handles custom messages. The only LDK-provided implementation is +/// [`IgnoringMessageHandler`]. +#[no_mangle] +pub extern "C" fn MessageHandler_set_custom_message_handler(this_ptr: &mut MessageHandler, mut val: crate::lightning::ln::peer_handler::CustomMessageHandler) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.custom_message_handler = val; +} /// Constructs a new MessageHandler given each field #[must_use] #[no_mangle] -pub extern "C" fn MessageHandler_new(mut chan_handler_arg: crate::lightning::ln::msgs::ChannelMessageHandler, mut route_handler_arg: crate::lightning::ln::msgs::RoutingMessageHandler, mut onion_message_handler_arg: crate::lightning::ln::msgs::OnionMessageHandler) -> MessageHandler { +pub extern "C" fn MessageHandler_new(mut chan_handler_arg: crate::lightning::ln::msgs::ChannelMessageHandler, mut route_handler_arg: crate::lightning::ln::msgs::RoutingMessageHandler, mut onion_message_handler_arg: crate::lightning::ln::msgs::OnionMessageHandler, mut custom_message_handler_arg: crate::lightning::ln::peer_handler::CustomMessageHandler) -> MessageHandler { MessageHandler { inner: ObjOps::heap_alloc(nativeMessageHandler { chan_handler: chan_handler_arg, route_handler: route_handler_arg, onion_message_handler: onion_message_handler_arg, + custom_message_handler: custom_message_handler_arg, }), is_owned: true } } /// Provides an object which can be used to send data to and which uniquely identifies a connection @@ -846,7 +976,6 @@ pub struct SocketDescriptor { /// (indicating that read events should be paused to prevent DoS in the send buffer), /// `resume_read` may be set indicating that read events on this descriptor should resume. A /// `resume_read` of false carries no meaning, and should not cause any action. - #[must_use] pub send_data: extern "C" fn (this_arg: *mut c_void, data: crate::c_types::u8slice, resume_read: bool) -> usize, /// Disconnect the socket pointed to by this SocketDescriptor. /// @@ -1011,7 +1140,7 @@ pub extern "C" fn PeerHandleError_clone(orig: &PeerHandleError) -> PeerHandleErr } use lightning::ln::peer_handler::PeerManager as nativePeerManagerImport; -pub(crate) type nativePeerManager = nativePeerManagerImport; +pub(crate) type nativePeerManager = nativePeerManagerImport; /// A PeerManager manages a set of peers, described by their [`SocketDescriptor`] and marshalls /// socket events into messages which it passes on to its [`MessageHandler`]. @@ -1089,8 +1218,8 @@ impl PeerManager { /// minute should suffice. #[must_use] #[no_mangle] -pub extern "C" fn PeerManager_new(mut message_handler: crate::lightning::ln::peer_handler::MessageHandler, mut current_time: u32, ephemeral_random_data: *const [u8; 32], mut logger: crate::lightning::util::logger::Logger, mut custom_message_handler: crate::lightning::ln::peer_handler::CustomMessageHandler, mut node_signer: crate::lightning::chain::keysinterface::NodeSigner) -> crate::lightning::ln::peer_handler::PeerManager { - let mut ret = lightning::ln::peer_handler::PeerManager::new(*unsafe { Box::from_raw(message_handler.take_inner()) }, current_time, unsafe { &*ephemeral_random_data}, logger, custom_message_handler, node_signer); +pub extern "C" fn PeerManager_new(mut message_handler: crate::lightning::ln::peer_handler::MessageHandler, mut current_time: u32, ephemeral_random_data: *const [u8; 32], mut logger: crate::lightning::util::logger::Logger, mut node_signer: crate::lightning::sign::NodeSigner) -> crate::lightning::ln::peer_handler::PeerManager { + let mut ret = lightning::ln::peer_handler::PeerManager::new(*unsafe { Box::from_raw(message_handler.take_inner()) }, current_time, unsafe { &*ephemeral_random_data}, logger, node_signer); crate::lightning::ln::peer_handler::PeerManager { inner: ObjOps::heap_alloc(ret), is_owned: true } } diff --git a/lightning-c-bindings/src/lightning/ln/wire.rs b/lightning-c-bindings/src/lightning/ln/wire.rs index 849b9818..a39f35e7 100644 --- a/lightning-c-bindings/src/lightning/ln/wire.rs +++ b/lightning-c-bindings/src/lightning/ln/wire.rs @@ -30,7 +30,6 @@ pub struct CustomMessageReader { /// implementation and the message could be decoded, must return `Ok(Some(message))`. If the /// message type is unknown to the implementation, must return `Ok(None)`. If a decoding error /// occur, must return `Err(DecodeError::X)` where `X` details the encountered error. - #[must_use] pub read: extern "C" fn (this_arg: *const c_void, message_type: u16, buffer: crate::c_types::u8slice) -> crate::c_types::derived::CResult_COption_TypeZDecodeErrorZ, /// Frees any resources associated with this object given its this_arg pointer. /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. @@ -95,7 +94,6 @@ pub struct Type { /// This has no meaning in the LDK, and can be NULL or any other value. pub this_arg: *mut c_void, /// Returns the type identifying the message payload. - #[must_use] pub type_id: extern "C" fn (this_arg: *const c_void) -> u16, /// Return a human-readable "debug" string describing this object pub debug_str: extern "C" fn (this_arg: *const c_void) -> crate::c_types::Str, diff --git a/lightning-c-bindings/src/lightning/mod.rs b/lightning-c-bindings/src/lightning/mod.rs index 20cee4b2..0f8a1432 100644 --- a/lightning-c-bindings/src/lightning/mod.rs +++ b/lightning-c-bindings/src/lightning/mod.rs @@ -48,6 +48,7 @@ pub mod chain; pub mod ln; pub mod offers; pub mod routing; +pub mod sign; pub mod onion_message; pub mod blinded_path; pub mod events; diff --git a/lightning-c-bindings/src/lightning/offers/invoice.rs b/lightning-c-bindings/src/lightning/offers/invoice.rs index 778d5b41..2ad519ac 100644 --- a/lightning-c-bindings/src/lightning/offers/invoice.rs +++ b/lightning-c-bindings/src/lightning/offers/invoice.rs @@ -8,9 +8,9 @@ //! Data structures and encoding for `invoice` messages. //! -//! An [`Invoice`] can be built from a parsed [`InvoiceRequest`] for the \"offer to be paid\" flow or -//! from a [`Refund`] as an \"offer for money\" flow. The expected recipient of the payment then sends -//! the invoice to the intended payer, who will then pay it. +//! A [`Bolt12Invoice`] can be built from a parsed [`InvoiceRequest`] for the \"offer to be paid\" +//! flow or from a [`Refund`] as an \"offer for money\" flow. The expected recipient of the payment +//! then sends the invoice to the intended payer, who will then pay it. //! //! The payment recipient must include a [`PaymentHash`], so as to reveal the preimage upon payment //! receipt, and one or more [`BlindedPath`]s for the payer to use when sending the payment. @@ -30,10 +30,10 @@ //! # use lightning::offers::invoice::BlindedPayInfo; //! # use lightning::blinded_path::BlindedPath; //! # -//! # fn create_payment_paths() -> Vec<(BlindedPath, BlindedPayInfo)> { unimplemented!() } +//! # fn create_payment_paths() -> Vec<(BlindedPayInfo, BlindedPath)> { unimplemented!() } //! # fn create_payment_hash() -> PaymentHash { unimplemented!() } //! # -//! # fn parse_invoice_request(bytes: Vec) -> Result<(), lightning::offers::parse::ParseError> { +//! # fn parse_invoice_request(bytes: Vec) -> Result<(), lightning::offers::parse::Bolt12ParseError> { //! let payment_paths = create_payment_paths(); //! let payment_hash = create_payment_hash(); //! let secp_ctx = Secp256k1::new(); @@ -58,7 +58,7 @@ //! # Ok(()) //! # } //! -//! # fn parse_refund(bytes: Vec) -> Result<(), lightning::offers::parse::ParseError> { +//! # fn parse_refund(bytes: Vec) -> Result<(), lightning::offers::parse::Bolt12ParseError> { //! # let payment_paths = create_payment_paths(); //! # let payment_hash = create_payment_hash(); //! # let secp_ctx = Secp256k1::new(); @@ -95,18 +95,18 @@ use crate::c_types::*; use alloc::{vec::Vec, boxed::Box}; -use lightning::offers::invoice::UnsignedInvoice as nativeUnsignedInvoiceImport; -pub(crate) type nativeUnsignedInvoice = nativeUnsignedInvoiceImport<'static>; +use lightning::offers::invoice::UnsignedBolt12Invoice as nativeUnsignedBolt12InvoiceImport; +pub(crate) type nativeUnsignedBolt12Invoice = nativeUnsignedBolt12InvoiceImport<'static>; -/// A semantically valid [`Invoice`] that hasn't been signed. +/// A semantically valid [`Bolt12Invoice`] that hasn't been signed. #[must_use] #[repr(C)] -pub struct UnsignedInvoice { +pub struct UnsignedBolt12Invoice { /// A pointer to the opaque Rust object. /// Nearly everywhere, inner must be non-null, however in places where /// the Rust equivalent takes an Option, it may be set to null to indicate None. - pub inner: *mut nativeUnsignedInvoice, + pub inner: *mut nativeUnsignedBolt12Invoice, /// Indicates that this is the only struct which contains the same pointer. /// Rust functions which take ownership of an object provided via an argument require @@ -114,31 +114,31 @@ pub struct UnsignedInvoice { pub is_owned: bool, } -impl Drop for UnsignedInvoice { +impl Drop for UnsignedBolt12Invoice { fn drop(&mut self) { - if self.is_owned && !<*mut nativeUnsignedInvoice>::is_null(self.inner) { + if self.is_owned && !<*mut nativeUnsignedBolt12Invoice>::is_null(self.inner) { let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; } } } -/// Frees any resources used by the UnsignedInvoice, if is_owned is set and inner is non-NULL. +/// Frees any resources used by the UnsignedBolt12Invoice, if is_owned is set and inner is non-NULL. #[no_mangle] -pub extern "C" fn UnsignedInvoice_free(this_obj: UnsignedInvoice) { } +pub extern "C" fn UnsignedBolt12Invoice_free(this_obj: UnsignedBolt12Invoice) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn UnsignedInvoice_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUnsignedInvoice) }; +pub(crate) extern "C" fn UnsignedBolt12Invoice_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUnsignedBolt12Invoice) }; } #[allow(unused)] -impl UnsignedInvoice { - pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedInvoice { +impl UnsignedBolt12Invoice { + pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedBolt12Invoice { unsafe { &*ObjOps::untweak_ptr(self.inner) } } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedInvoice { + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedBolt12Invoice { unsafe { &mut *ObjOps::untweak_ptr(self.inner) } } /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy - pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedInvoice { + pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedBolt12Invoice { assert!(self.is_owned); let ret = ObjOps::untweak_ptr(self.inner); self.inner = core::ptr::null_mut(); @@ -148,12 +148,180 @@ impl UnsignedInvoice { /// The public key corresponding to the key needed to sign the invoice. #[must_use] #[no_mangle] -pub extern "C" fn UnsignedInvoice_signing_pubkey(this_arg: &crate::lightning::offers::invoice::UnsignedInvoice) -> crate::c_types::PublicKey { +pub extern "C" fn UnsignedBolt12Invoice_signing_pubkey(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::PublicKey { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signing_pubkey(); crate::c_types::PublicKey::from_rust(&ret) } +use lightning::offers::invoice::Bolt12Invoice as nativeBolt12InvoiceImport; +pub(crate) type nativeBolt12Invoice = nativeBolt12InvoiceImport; + +/// A `Bolt12Invoice` is a payment request, typically corresponding to an [`Offer`] or a [`Refund`]. +/// +/// An invoice may be sent in response to an [`InvoiceRequest`] in the case of an offer or sent +/// directly after scanning a refund. It includes all the information needed to pay a recipient. +/// +/// [`Offer`]: crate::offers::offer::Offer +/// [`Refund`]: crate::offers::refund::Refund +/// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest +#[must_use] +#[repr(C)] +pub struct Bolt12Invoice { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeBolt12Invoice, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for Bolt12Invoice { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeBolt12Invoice>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the Bolt12Invoice, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn Bolt12Invoice_free(this_obj: Bolt12Invoice) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn Bolt12Invoice_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeBolt12Invoice) }; +} +#[allow(unused)] +impl Bolt12Invoice { + pub(crate) fn get_native_ref(&self) -> &'static nativeBolt12Invoice { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeBolt12Invoice { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeBolt12Invoice { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +impl Clone for Bolt12Invoice { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeBolt12Invoice>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn Bolt12Invoice_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeBolt12Invoice)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the Bolt12Invoice +pub extern "C" fn Bolt12Invoice_clone(orig: &Bolt12Invoice) -> Bolt12Invoice { + orig.clone() +} +/// A complete description of the purpose of the originating offer or refund. Intended to be +/// displayed to the user but with the caveat that it has not been verified in any way. +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt12Invoice_description(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::lightning::util::string::PrintableString { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.description(); + crate::lightning::util::string::PrintableString { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Duration since the Unix epoch when the invoice was created. +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt12Invoice_created_at(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> u64 { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.created_at(); + ret.as_secs() +} + +/// Duration since [`Bolt12Invoice::created_at`] when the invoice has expired and therefore +/// should no longer be paid. +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt12Invoice_relative_expiry(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> u64 { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.relative_expiry(); + ret.as_secs() +} + +/// Whether the invoice has expired. +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt12Invoice_is_expired(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.is_expired(); + ret +} + +/// SHA256 hash of the payment preimage that will be given in return for paying the invoice. +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt12Invoice_payment_hash(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::ThirtyTwoBytes { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payment_hash(); + crate::c_types::ThirtyTwoBytes { data: ret.0 } +} + +/// The minimum amount required for a successful payment of the invoice. +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt12Invoice_amount_msats(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> u64 { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount_msats(); + ret +} + +/// Features pertaining to paying an invoice. +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt12Invoice_features(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::lightning::ln::features::Bolt12InvoiceFeatures { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.features(); + crate::lightning::ln::features::Bolt12InvoiceFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::Bolt12InvoiceFeatures<>) as *mut _) }, is_owned: false } +} + +/// The public key corresponding to the key used to sign the invoice. +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt12Invoice_signing_pubkey(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::PublicKey { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signing_pubkey(); + crate::c_types::PublicKey::from_rust(&ret) +} + +/// Hash that was used for signing the invoice. +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt12Invoice_signable_hash(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::ThirtyTwoBytes { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signable_hash(); + crate::c_types::ThirtyTwoBytes { data: ret } +} + +/// Verifies that the invoice was for a request or refund created using the given key. +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt12Invoice_verify(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice, key: &crate::lightning::ln::inbound_payment::ExpandedKey) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.verify(key.get_native_ref(), secp256k1::global::SECP256K1); + ret +} + +#[no_mangle] +/// Serialize the Bolt12Invoice object into a byte array which can be read by Bolt12Invoice_read +pub extern "C" fn Bolt12Invoice_write(obj: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[no_mangle] +pub(crate) extern "C" fn Bolt12Invoice_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeBolt12Invoice) }) +} + use lightning::offers::invoice::BlindedPayInfo as nativeBlindedPayInfoImport; pub(crate) type nativeBlindedPayInfo = nativeBlindedPayInfoImport; diff --git a/lightning-c-bindings/src/lightning/offers/invoice_request.rs b/lightning-c-bindings/src/lightning/offers/invoice_request.rs index fb0e3224..b458687e 100644 --- a/lightning-c-bindings/src/lightning/offers/invoice_request.rs +++ b/lightning-c-bindings/src/lightning/offers/invoice_request.rs @@ -10,12 +10,12 @@ //! //! An [`InvoiceRequest`] can be built from a parsed [`Offer`] as an \"offer to be paid\". It is //! typically constructed by a customer and sent to the merchant who had published the corresponding -//! offer. The recipient of the request responds with an [`Invoice`]. +//! offer. The recipient of the request responds with a [`Bolt12Invoice`]. //! //! For an \"offer for money\" (e.g., refund, ATM withdrawal), where an offer doesn't exist as a //! precursor, see [`Refund`]. //! -//! [`Invoice`]: crate::offers::invoice::Invoice +//! [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice //! [`Refund`]: crate::offers::refund::Refund //! //! ``` @@ -29,7 +29,7 @@ //! use lightning::offers::offer::Offer; //! use lightning::util::ser::Writeable; //! -//! # fn parse() -> Result<(), lightning::offers::parse::ParseError> { +//! # fn parse() -> Result<(), lightning::offers::parse::Bolt12ParseError> { //! let secp_ctx = Secp256k1::new(); //! let keys = KeyPair::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32])?); //! let pubkey = PublicKey::from(keys); @@ -114,12 +114,12 @@ impl UnsignedInvoiceRequest { use lightning::offers::invoice_request::InvoiceRequest as nativeInvoiceRequestImport; pub(crate) type nativeInvoiceRequest = nativeInvoiceRequestImport; -/// An `InvoiceRequest` is a request for an [`Invoice`] formulated from an [`Offer`]. +/// An `InvoiceRequest` is a request for a [`Bolt12Invoice`] formulated from an [`Offer`]. /// /// An offer may provide choices such as quantity, amount, chain, features, etc. An invoice request /// specifies these such that its recipient can send an invoice for payment. /// -/// [`Invoice`]: crate::offers::invoice::Invoice +/// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice /// [`Offer`]: crate::offers::offer::Offer #[must_use] #[repr(C)] @@ -255,6 +255,19 @@ pub extern "C" fn InvoiceRequest_payer_note(this_arg: &crate::lightning::offers: local_ret } +/// Verifies that the request was for an offer created using the given key. Returns the derived +/// keys need to sign an [`Bolt12Invoice`] for the request if they could be extracted from the +/// metadata. +/// +/// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice +#[must_use] +#[no_mangle] +pub extern "C" fn InvoiceRequest_verify(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest, key: &crate::lightning::ln::inbound_payment::ExpandedKey) -> crate::c_types::derived::CResult_COption_KeyPairZNoneZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.verify(key.get_native_ref(), secp256k1::global::SECP256K1); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = if o.is_none() { crate::c_types::derived::COption_KeyPairZ::None } else { crate::c_types::derived::COption_KeyPairZ::Some( { crate::c_types::SecretKey::from_rust(o.unwrap().secret_key()) }) }; local_ret_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + #[no_mangle] /// Serialize the InvoiceRequest object into a byte array which can be read by InvoiceRequest_read pub extern "C" fn InvoiceRequest_write(obj: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::derived::CVec_u8Z { diff --git a/lightning-c-bindings/src/lightning/offers/mod.rs b/lightning-c-bindings/src/lightning/offers/mod.rs index 41c8bef8..0ea60899 100644 --- a/lightning-c-bindings/src/lightning/offers/mod.rs +++ b/lightning-c-bindings/src/lightning/offers/mod.rs @@ -20,6 +20,7 @@ use crate::c_types::*; use alloc::{vec::Vec, boxed::Box}; pub mod invoice; +pub mod invoice_error; pub mod invoice_request; pub mod offer; pub mod parse; diff --git a/lightning-c-bindings/src/lightning/offers/offer.rs b/lightning-c-bindings/src/lightning/offers/offer.rs index bef11fad..a5d19c3c 100644 --- a/lightning-c-bindings/src/lightning/offers/offer.rs +++ b/lightning-c-bindings/src/lightning/offers/offer.rs @@ -23,7 +23,7 @@ //! //! use bitcoin::secp256k1::{KeyPair, PublicKey, Secp256k1, SecretKey}; //! use lightning::offers::offer::{Offer, OfferBuilder, Quantity}; -//! use lightning::offers::parse::ParseError; +//! use lightning::offers::parse::Bolt12ParseError; //! use lightning::util::ser::{Readable, Writeable}; //! //! # use lightning::blinded_path::BlindedPath; @@ -34,7 +34,7 @@ //! # fn create_another_blinded_path() -> BlindedPath { unimplemented!() } //! # //! # #[cfg(feature = \"std\")] -//! # fn build() -> Result<(), ParseError> { +//! # fn build() -> Result<(), Bolt12ParseError> { //! let secp_ctx = Secp256k1::new(); //! let keys = KeyPair::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32]).unwrap()); //! let pubkey = PublicKey::from(keys); @@ -80,8 +80,8 @@ pub(crate) type nativeOffer = nativeOfferImport; /// An `Offer` is a potentially long-lived proposal for payment of a good or service. /// /// An offer is a precursor to an [`InvoiceRequest`]. A merchant publishes an offer from which a -/// customer may request an [`Invoice`] for a specific quantity and using an amount sufficient to -/// cover that quantity (i.e., at least `quantity * amount`). See [`Offer::amount`]. +/// customer may request an [`Bolt12Invoice`] for a specific quantity and using an amount sufficient +/// to cover that quantity (i.e., at least `quantity * amount`). See [`Offer::amount`]. /// /// Offers may be denominated in currency other than bitcoin but are ultimately paid using the /// latter. @@ -89,7 +89,7 @@ pub(crate) type nativeOffer = nativeOfferImport; /// Through the use of [`BlindedPath`]s, offers provide recipient privacy. /// /// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest -/// [`Invoice`]: crate::offers::invoice::Invoice +/// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice #[must_use] #[repr(C)] pub struct Offer { @@ -437,3 +437,19 @@ pub(crate) extern "C" fn Quantity_clone_void(this_ptr: *const c_void) -> *mut c_ pub extern "C" fn Quantity_clone(orig: &Quantity) -> Quantity { orig.clone() } +#[no_mangle] +/// Read a Offer object from a string +pub extern "C" fn Offer_from_str(s: crate::c_types::Str) -> crate::c_types::derived::CResult_OfferBolt12ParseErrorZ { + match lightning::offers::offer::Offer::from_str(s.into_str()) { + Ok(r) => { + crate::c_types::CResultTempl::ok( + crate::lightning::offers::offer::Offer { inner: ObjOps::heap_alloc(r), is_owned: true } + ) + }, + Err(e) => { + crate::c_types::CResultTempl::err( + crate::lightning::offers::parse::Bolt12ParseError { inner: ObjOps::heap_alloc(e), is_owned: true } + ) + }, + }.into() +} diff --git a/lightning-c-bindings/src/lightning/offers/parse.rs b/lightning-c-bindings/src/lightning/offers/parse.rs index c1664e8c..7730cc13 100644 --- a/lightning-c-bindings/src/lightning/offers/parse.rs +++ b/lightning-c-bindings/src/lightning/offers/parse.rs @@ -27,3 +27,369 @@ use crate::c_types::*; use alloc::{vec::Vec, boxed::Box}; } + +use lightning::offers::parse::Bolt12ParseError as nativeBolt12ParseErrorImport; +pub(crate) type nativeBolt12ParseError = nativeBolt12ParseErrorImport; + +/// Error when parsing a bech32 encoded message using [`str::parse`]. +#[must_use] +#[repr(C)] +pub struct Bolt12ParseError { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeBolt12ParseError, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for Bolt12ParseError { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeBolt12ParseError>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the Bolt12ParseError, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn Bolt12ParseError_free(this_obj: Bolt12ParseError) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn Bolt12ParseError_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeBolt12ParseError) }; +} +#[allow(unused)] +impl Bolt12ParseError { + pub(crate) fn get_native_ref(&self) -> &'static nativeBolt12ParseError { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeBolt12ParseError { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeBolt12ParseError { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +impl Clone for Bolt12ParseError { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeBolt12ParseError>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn Bolt12ParseError_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeBolt12ParseError)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the Bolt12ParseError +pub extern "C" fn Bolt12ParseError_clone(orig: &Bolt12ParseError) -> Bolt12ParseError { + orig.clone() +} +/// Error when interpreting a TLV stream as a specific type. +#[derive(Clone)] +#[must_use] +#[repr(C)] +pub enum Bolt12SemanticError { + /// The current [`std::time::SystemTime`] is past the offer or invoice's expiration. + AlreadyExpired, + /// The provided chain hash does not correspond to a supported chain. + UnsupportedChain, + /// A chain was provided but was not expected. + UnexpectedChain, + /// An amount was expected but was missing. + MissingAmount, + /// The amount exceeded the total bitcoin supply. + InvalidAmount, + /// An amount was provided but was not sufficient in value. + InsufficientAmount, + /// An amount was provided but was not expected. + UnexpectedAmount, + /// A currency was provided that is not supported. + UnsupportedCurrency, + /// A feature was required but is unknown. + UnknownRequiredFeatures, + /// Features were provided but were not expected. + UnexpectedFeatures, + /// A required description was not provided. + MissingDescription, + /// A signing pubkey was not provided. + MissingSigningPubkey, + /// A signing pubkey was provided but a different one was expected. + InvalidSigningPubkey, + /// A signing pubkey was provided but was not expected. + UnexpectedSigningPubkey, + /// A quantity was expected but was missing. + MissingQuantity, + /// An unsupported quantity was provided. + InvalidQuantity, + /// A quantity or quantity bounds was provided but was not expected. + UnexpectedQuantity, + /// Metadata could not be used to verify the offers message. + InvalidMetadata, + /// Metadata was provided but was not expected. + UnexpectedMetadata, + /// Payer metadata was expected but was missing. + MissingPayerMetadata, + /// A payer id was expected but was missing. + MissingPayerId, + /// Blinded paths were expected but were missing. + MissingPaths, + /// The blinded payinfo given does not match the number of blinded path hops. + InvalidPayInfo, + /// An invoice creation time was expected but was missing. + MissingCreationTime, + /// An invoice payment hash was expected but was missing. + MissingPaymentHash, + /// A signature was expected but was missing. + MissingSignature, +} +use lightning::offers::parse::Bolt12SemanticError as Bolt12SemanticErrorImport; +pub(crate) type nativeBolt12SemanticError = Bolt12SemanticErrorImport; + +impl Bolt12SemanticError { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeBolt12SemanticError { + match self { + Bolt12SemanticError::AlreadyExpired => nativeBolt12SemanticError::AlreadyExpired, + Bolt12SemanticError::UnsupportedChain => nativeBolt12SemanticError::UnsupportedChain, + Bolt12SemanticError::UnexpectedChain => nativeBolt12SemanticError::UnexpectedChain, + Bolt12SemanticError::MissingAmount => nativeBolt12SemanticError::MissingAmount, + Bolt12SemanticError::InvalidAmount => nativeBolt12SemanticError::InvalidAmount, + Bolt12SemanticError::InsufficientAmount => nativeBolt12SemanticError::InsufficientAmount, + Bolt12SemanticError::UnexpectedAmount => nativeBolt12SemanticError::UnexpectedAmount, + Bolt12SemanticError::UnsupportedCurrency => nativeBolt12SemanticError::UnsupportedCurrency, + Bolt12SemanticError::UnknownRequiredFeatures => nativeBolt12SemanticError::UnknownRequiredFeatures, + Bolt12SemanticError::UnexpectedFeatures => nativeBolt12SemanticError::UnexpectedFeatures, + Bolt12SemanticError::MissingDescription => nativeBolt12SemanticError::MissingDescription, + Bolt12SemanticError::MissingSigningPubkey => nativeBolt12SemanticError::MissingSigningPubkey, + Bolt12SemanticError::InvalidSigningPubkey => nativeBolt12SemanticError::InvalidSigningPubkey, + Bolt12SemanticError::UnexpectedSigningPubkey => nativeBolt12SemanticError::UnexpectedSigningPubkey, + Bolt12SemanticError::MissingQuantity => nativeBolt12SemanticError::MissingQuantity, + Bolt12SemanticError::InvalidQuantity => nativeBolt12SemanticError::InvalidQuantity, + Bolt12SemanticError::UnexpectedQuantity => nativeBolt12SemanticError::UnexpectedQuantity, + Bolt12SemanticError::InvalidMetadata => nativeBolt12SemanticError::InvalidMetadata, + Bolt12SemanticError::UnexpectedMetadata => nativeBolt12SemanticError::UnexpectedMetadata, + Bolt12SemanticError::MissingPayerMetadata => nativeBolt12SemanticError::MissingPayerMetadata, + Bolt12SemanticError::MissingPayerId => nativeBolt12SemanticError::MissingPayerId, + Bolt12SemanticError::MissingPaths => nativeBolt12SemanticError::MissingPaths, + Bolt12SemanticError::InvalidPayInfo => nativeBolt12SemanticError::InvalidPayInfo, + Bolt12SemanticError::MissingCreationTime => nativeBolt12SemanticError::MissingCreationTime, + Bolt12SemanticError::MissingPaymentHash => nativeBolt12SemanticError::MissingPaymentHash, + Bolt12SemanticError::MissingSignature => nativeBolt12SemanticError::MissingSignature, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeBolt12SemanticError { + match self { + Bolt12SemanticError::AlreadyExpired => nativeBolt12SemanticError::AlreadyExpired, + Bolt12SemanticError::UnsupportedChain => nativeBolt12SemanticError::UnsupportedChain, + Bolt12SemanticError::UnexpectedChain => nativeBolt12SemanticError::UnexpectedChain, + Bolt12SemanticError::MissingAmount => nativeBolt12SemanticError::MissingAmount, + Bolt12SemanticError::InvalidAmount => nativeBolt12SemanticError::InvalidAmount, + Bolt12SemanticError::InsufficientAmount => nativeBolt12SemanticError::InsufficientAmount, + Bolt12SemanticError::UnexpectedAmount => nativeBolt12SemanticError::UnexpectedAmount, + Bolt12SemanticError::UnsupportedCurrency => nativeBolt12SemanticError::UnsupportedCurrency, + Bolt12SemanticError::UnknownRequiredFeatures => nativeBolt12SemanticError::UnknownRequiredFeatures, + Bolt12SemanticError::UnexpectedFeatures => nativeBolt12SemanticError::UnexpectedFeatures, + Bolt12SemanticError::MissingDescription => nativeBolt12SemanticError::MissingDescription, + Bolt12SemanticError::MissingSigningPubkey => nativeBolt12SemanticError::MissingSigningPubkey, + Bolt12SemanticError::InvalidSigningPubkey => nativeBolt12SemanticError::InvalidSigningPubkey, + Bolt12SemanticError::UnexpectedSigningPubkey => nativeBolt12SemanticError::UnexpectedSigningPubkey, + Bolt12SemanticError::MissingQuantity => nativeBolt12SemanticError::MissingQuantity, + Bolt12SemanticError::InvalidQuantity => nativeBolt12SemanticError::InvalidQuantity, + Bolt12SemanticError::UnexpectedQuantity => nativeBolt12SemanticError::UnexpectedQuantity, + Bolt12SemanticError::InvalidMetadata => nativeBolt12SemanticError::InvalidMetadata, + Bolt12SemanticError::UnexpectedMetadata => nativeBolt12SemanticError::UnexpectedMetadata, + Bolt12SemanticError::MissingPayerMetadata => nativeBolt12SemanticError::MissingPayerMetadata, + Bolt12SemanticError::MissingPayerId => nativeBolt12SemanticError::MissingPayerId, + Bolt12SemanticError::MissingPaths => nativeBolt12SemanticError::MissingPaths, + Bolt12SemanticError::InvalidPayInfo => nativeBolt12SemanticError::InvalidPayInfo, + Bolt12SemanticError::MissingCreationTime => nativeBolt12SemanticError::MissingCreationTime, + Bolt12SemanticError::MissingPaymentHash => nativeBolt12SemanticError::MissingPaymentHash, + Bolt12SemanticError::MissingSignature => nativeBolt12SemanticError::MissingSignature, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &nativeBolt12SemanticError) -> Self { + match native { + nativeBolt12SemanticError::AlreadyExpired => Bolt12SemanticError::AlreadyExpired, + nativeBolt12SemanticError::UnsupportedChain => Bolt12SemanticError::UnsupportedChain, + nativeBolt12SemanticError::UnexpectedChain => Bolt12SemanticError::UnexpectedChain, + nativeBolt12SemanticError::MissingAmount => Bolt12SemanticError::MissingAmount, + nativeBolt12SemanticError::InvalidAmount => Bolt12SemanticError::InvalidAmount, + nativeBolt12SemanticError::InsufficientAmount => Bolt12SemanticError::InsufficientAmount, + nativeBolt12SemanticError::UnexpectedAmount => Bolt12SemanticError::UnexpectedAmount, + nativeBolt12SemanticError::UnsupportedCurrency => Bolt12SemanticError::UnsupportedCurrency, + nativeBolt12SemanticError::UnknownRequiredFeatures => Bolt12SemanticError::UnknownRequiredFeatures, + nativeBolt12SemanticError::UnexpectedFeatures => Bolt12SemanticError::UnexpectedFeatures, + nativeBolt12SemanticError::MissingDescription => Bolt12SemanticError::MissingDescription, + nativeBolt12SemanticError::MissingSigningPubkey => Bolt12SemanticError::MissingSigningPubkey, + nativeBolt12SemanticError::InvalidSigningPubkey => Bolt12SemanticError::InvalidSigningPubkey, + nativeBolt12SemanticError::UnexpectedSigningPubkey => Bolt12SemanticError::UnexpectedSigningPubkey, + nativeBolt12SemanticError::MissingQuantity => Bolt12SemanticError::MissingQuantity, + nativeBolt12SemanticError::InvalidQuantity => Bolt12SemanticError::InvalidQuantity, + nativeBolt12SemanticError::UnexpectedQuantity => Bolt12SemanticError::UnexpectedQuantity, + nativeBolt12SemanticError::InvalidMetadata => Bolt12SemanticError::InvalidMetadata, + nativeBolt12SemanticError::UnexpectedMetadata => Bolt12SemanticError::UnexpectedMetadata, + nativeBolt12SemanticError::MissingPayerMetadata => Bolt12SemanticError::MissingPayerMetadata, + nativeBolt12SemanticError::MissingPayerId => Bolt12SemanticError::MissingPayerId, + nativeBolt12SemanticError::MissingPaths => Bolt12SemanticError::MissingPaths, + nativeBolt12SemanticError::InvalidPayInfo => Bolt12SemanticError::InvalidPayInfo, + nativeBolt12SemanticError::MissingCreationTime => Bolt12SemanticError::MissingCreationTime, + nativeBolt12SemanticError::MissingPaymentHash => Bolt12SemanticError::MissingPaymentHash, + nativeBolt12SemanticError::MissingSignature => Bolt12SemanticError::MissingSignature, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeBolt12SemanticError) -> Self { + match native { + nativeBolt12SemanticError::AlreadyExpired => Bolt12SemanticError::AlreadyExpired, + nativeBolt12SemanticError::UnsupportedChain => Bolt12SemanticError::UnsupportedChain, + nativeBolt12SemanticError::UnexpectedChain => Bolt12SemanticError::UnexpectedChain, + nativeBolt12SemanticError::MissingAmount => Bolt12SemanticError::MissingAmount, + nativeBolt12SemanticError::InvalidAmount => Bolt12SemanticError::InvalidAmount, + nativeBolt12SemanticError::InsufficientAmount => Bolt12SemanticError::InsufficientAmount, + nativeBolt12SemanticError::UnexpectedAmount => Bolt12SemanticError::UnexpectedAmount, + nativeBolt12SemanticError::UnsupportedCurrency => Bolt12SemanticError::UnsupportedCurrency, + nativeBolt12SemanticError::UnknownRequiredFeatures => Bolt12SemanticError::UnknownRequiredFeatures, + nativeBolt12SemanticError::UnexpectedFeatures => Bolt12SemanticError::UnexpectedFeatures, + nativeBolt12SemanticError::MissingDescription => Bolt12SemanticError::MissingDescription, + nativeBolt12SemanticError::MissingSigningPubkey => Bolt12SemanticError::MissingSigningPubkey, + nativeBolt12SemanticError::InvalidSigningPubkey => Bolt12SemanticError::InvalidSigningPubkey, + nativeBolt12SemanticError::UnexpectedSigningPubkey => Bolt12SemanticError::UnexpectedSigningPubkey, + nativeBolt12SemanticError::MissingQuantity => Bolt12SemanticError::MissingQuantity, + nativeBolt12SemanticError::InvalidQuantity => Bolt12SemanticError::InvalidQuantity, + nativeBolt12SemanticError::UnexpectedQuantity => Bolt12SemanticError::UnexpectedQuantity, + nativeBolt12SemanticError::InvalidMetadata => Bolt12SemanticError::InvalidMetadata, + nativeBolt12SemanticError::UnexpectedMetadata => Bolt12SemanticError::UnexpectedMetadata, + nativeBolt12SemanticError::MissingPayerMetadata => Bolt12SemanticError::MissingPayerMetadata, + nativeBolt12SemanticError::MissingPayerId => Bolt12SemanticError::MissingPayerId, + nativeBolt12SemanticError::MissingPaths => Bolt12SemanticError::MissingPaths, + nativeBolt12SemanticError::InvalidPayInfo => Bolt12SemanticError::InvalidPayInfo, + nativeBolt12SemanticError::MissingCreationTime => Bolt12SemanticError::MissingCreationTime, + nativeBolt12SemanticError::MissingPaymentHash => Bolt12SemanticError::MissingPaymentHash, + nativeBolt12SemanticError::MissingSignature => Bolt12SemanticError::MissingSignature, + } + } +} +/// Creates a copy of the Bolt12SemanticError +#[no_mangle] +pub extern "C" fn Bolt12SemanticError_clone(orig: &Bolt12SemanticError) -> Bolt12SemanticError { + orig.clone() +} +#[no_mangle] +/// Utility method to constructs a new AlreadyExpired-variant Bolt12SemanticError +pub extern "C" fn Bolt12SemanticError_already_expired() -> Bolt12SemanticError { + Bolt12SemanticError::AlreadyExpired} +#[no_mangle] +/// Utility method to constructs a new UnsupportedChain-variant Bolt12SemanticError +pub extern "C" fn Bolt12SemanticError_unsupported_chain() -> Bolt12SemanticError { + Bolt12SemanticError::UnsupportedChain} +#[no_mangle] +/// Utility method to constructs a new UnexpectedChain-variant Bolt12SemanticError +pub extern "C" fn Bolt12SemanticError_unexpected_chain() -> Bolt12SemanticError { + Bolt12SemanticError::UnexpectedChain} +#[no_mangle] +/// Utility method to constructs a new MissingAmount-variant Bolt12SemanticError +pub extern "C" fn Bolt12SemanticError_missing_amount() -> Bolt12SemanticError { + Bolt12SemanticError::MissingAmount} +#[no_mangle] +/// Utility method to constructs a new InvalidAmount-variant Bolt12SemanticError +pub extern "C" fn Bolt12SemanticError_invalid_amount() -> Bolt12SemanticError { + Bolt12SemanticError::InvalidAmount} +#[no_mangle] +/// Utility method to constructs a new InsufficientAmount-variant Bolt12SemanticError +pub extern "C" fn Bolt12SemanticError_insufficient_amount() -> Bolt12SemanticError { + Bolt12SemanticError::InsufficientAmount} +#[no_mangle] +/// Utility method to constructs a new UnexpectedAmount-variant Bolt12SemanticError +pub extern "C" fn Bolt12SemanticError_unexpected_amount() -> Bolt12SemanticError { + Bolt12SemanticError::UnexpectedAmount} +#[no_mangle] +/// Utility method to constructs a new UnsupportedCurrency-variant Bolt12SemanticError +pub extern "C" fn Bolt12SemanticError_unsupported_currency() -> Bolt12SemanticError { + Bolt12SemanticError::UnsupportedCurrency} +#[no_mangle] +/// Utility method to constructs a new UnknownRequiredFeatures-variant Bolt12SemanticError +pub extern "C" fn Bolt12SemanticError_unknown_required_features() -> Bolt12SemanticError { + Bolt12SemanticError::UnknownRequiredFeatures} +#[no_mangle] +/// Utility method to constructs a new UnexpectedFeatures-variant Bolt12SemanticError +pub extern "C" fn Bolt12SemanticError_unexpected_features() -> Bolt12SemanticError { + Bolt12SemanticError::UnexpectedFeatures} +#[no_mangle] +/// Utility method to constructs a new MissingDescription-variant Bolt12SemanticError +pub extern "C" fn Bolt12SemanticError_missing_description() -> Bolt12SemanticError { + Bolt12SemanticError::MissingDescription} +#[no_mangle] +/// Utility method to constructs a new MissingSigningPubkey-variant Bolt12SemanticError +pub extern "C" fn Bolt12SemanticError_missing_signing_pubkey() -> Bolt12SemanticError { + Bolt12SemanticError::MissingSigningPubkey} +#[no_mangle] +/// Utility method to constructs a new InvalidSigningPubkey-variant Bolt12SemanticError +pub extern "C" fn Bolt12SemanticError_invalid_signing_pubkey() -> Bolt12SemanticError { + Bolt12SemanticError::InvalidSigningPubkey} +#[no_mangle] +/// Utility method to constructs a new UnexpectedSigningPubkey-variant Bolt12SemanticError +pub extern "C" fn Bolt12SemanticError_unexpected_signing_pubkey() -> Bolt12SemanticError { + Bolt12SemanticError::UnexpectedSigningPubkey} +#[no_mangle] +/// Utility method to constructs a new MissingQuantity-variant Bolt12SemanticError +pub extern "C" fn Bolt12SemanticError_missing_quantity() -> Bolt12SemanticError { + Bolt12SemanticError::MissingQuantity} +#[no_mangle] +/// Utility method to constructs a new InvalidQuantity-variant Bolt12SemanticError +pub extern "C" fn Bolt12SemanticError_invalid_quantity() -> Bolt12SemanticError { + Bolt12SemanticError::InvalidQuantity} +#[no_mangle] +/// Utility method to constructs a new UnexpectedQuantity-variant Bolt12SemanticError +pub extern "C" fn Bolt12SemanticError_unexpected_quantity() -> Bolt12SemanticError { + Bolt12SemanticError::UnexpectedQuantity} +#[no_mangle] +/// Utility method to constructs a new InvalidMetadata-variant Bolt12SemanticError +pub extern "C" fn Bolt12SemanticError_invalid_metadata() -> Bolt12SemanticError { + Bolt12SemanticError::InvalidMetadata} +#[no_mangle] +/// Utility method to constructs a new UnexpectedMetadata-variant Bolt12SemanticError +pub extern "C" fn Bolt12SemanticError_unexpected_metadata() -> Bolt12SemanticError { + Bolt12SemanticError::UnexpectedMetadata} +#[no_mangle] +/// Utility method to constructs a new MissingPayerMetadata-variant Bolt12SemanticError +pub extern "C" fn Bolt12SemanticError_missing_payer_metadata() -> Bolt12SemanticError { + Bolt12SemanticError::MissingPayerMetadata} +#[no_mangle] +/// Utility method to constructs a new MissingPayerId-variant Bolt12SemanticError +pub extern "C" fn Bolt12SemanticError_missing_payer_id() -> Bolt12SemanticError { + Bolt12SemanticError::MissingPayerId} +#[no_mangle] +/// Utility method to constructs a new MissingPaths-variant Bolt12SemanticError +pub extern "C" fn Bolt12SemanticError_missing_paths() -> Bolt12SemanticError { + Bolt12SemanticError::MissingPaths} +#[no_mangle] +/// Utility method to constructs a new InvalidPayInfo-variant Bolt12SemanticError +pub extern "C" fn Bolt12SemanticError_invalid_pay_info() -> Bolt12SemanticError { + Bolt12SemanticError::InvalidPayInfo} +#[no_mangle] +/// Utility method to constructs a new MissingCreationTime-variant Bolt12SemanticError +pub extern "C" fn Bolt12SemanticError_missing_creation_time() -> Bolt12SemanticError { + Bolt12SemanticError::MissingCreationTime} +#[no_mangle] +/// Utility method to constructs a new MissingPaymentHash-variant Bolt12SemanticError +pub extern "C" fn Bolt12SemanticError_missing_payment_hash() -> Bolt12SemanticError { + Bolt12SemanticError::MissingPaymentHash} +#[no_mangle] +/// Utility method to constructs a new MissingSignature-variant Bolt12SemanticError +pub extern "C" fn Bolt12SemanticError_missing_signature() -> Bolt12SemanticError { + Bolt12SemanticError::MissingSignature} diff --git a/lightning-c-bindings/src/lightning/offers/refund.rs b/lightning-c-bindings/src/lightning/offers/refund.rs index 1e44848d..fe35bc20 100644 --- a/lightning-c-bindings/src/lightning/offers/refund.rs +++ b/lightning-c-bindings/src/lightning/offers/refund.rs @@ -9,11 +9,11 @@ //! Data structures and encoding for refunds. //! //! A [`Refund`] is an \"offer for money\" and is typically constructed by a merchant and presented -//! directly to the customer. The recipient responds with an [`Invoice`] to be paid. +//! directly to the customer. The recipient responds with a [`Bolt12Invoice`] to be paid. //! //! This is an [`InvoiceRequest`] produced *not* in response to an [`Offer`]. //! -//! [`Invoice`]: crate::offers::invoice::Invoice +//! [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice //! [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest //! [`Offer`]: crate::offers::offer::Offer //! @@ -27,7 +27,7 @@ //! //! use bitcoin::network::constants::Network; //! use bitcoin::secp256k1::{KeyPair, PublicKey, Secp256k1, SecretKey}; -//! use lightning::offers::parse::ParseError; +//! use lightning::offers::parse::Bolt12ParseError; //! use lightning::offers::refund::{Refund, RefundBuilder}; //! use lightning::util::ser::{Readable, Writeable}; //! @@ -39,7 +39,7 @@ //! # fn create_another_blinded_path() -> BlindedPath { unimplemented!() } //! # //! # #[cfg(feature = \"std\")] -//! # fn build() -> Result<(), ParseError> { +//! # fn build() -> Result<(), Bolt12ParseError> { //! let secp_ctx = Secp256k1::new(); //! let keys = KeyPair::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32]).unwrap()); //! let pubkey = PublicKey::from(keys); @@ -82,13 +82,13 @@ use alloc::{vec::Vec, boxed::Box}; use lightning::offers::refund::Refund as nativeRefundImport; pub(crate) type nativeRefund = nativeRefundImport; -/// A `Refund` is a request to send an [`Invoice`] without a preceding [`Offer`]. +/// A `Refund` is a request to send an [`Bolt12Invoice`] without a preceding [`Offer`]. /// /// Typically, after an invoice is paid, the recipient may publish a refund allowing the sender to /// recoup their funds. A refund may be used more generally as an \"offer for money\", such as with a /// bitcoin ATM. /// -/// [`Invoice`]: crate::offers::invoice::Invoice +/// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice /// [`Offer`]: crate::offers::offer::Offer #[must_use] #[repr(C)] @@ -283,3 +283,19 @@ pub extern "C" fn Refund_write(obj: &crate::lightning::offers::refund::Refund) - pub(crate) extern "C" fn Refund_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRefund) }) } +#[no_mangle] +/// Read a Refund object from a string +pub extern "C" fn Refund_from_str(s: crate::c_types::Str) -> crate::c_types::derived::CResult_RefundBolt12ParseErrorZ { + match lightning::offers::refund::Refund::from_str(s.into_str()) { + Ok(r) => { + crate::c_types::CResultTempl::ok( + crate::lightning::offers::refund::Refund { inner: ObjOps::heap_alloc(r), is_owned: true } + ) + }, + Err(e) => { + crate::c_types::CResultTempl::err( + crate::lightning::offers::parse::Bolt12ParseError { inner: ObjOps::heap_alloc(e), is_owned: true } + ) + }, + }.into() +} diff --git a/lightning-c-bindings/src/lightning/onion_message/messenger.rs b/lightning-c-bindings/src/lightning/onion_message/messenger.rs index 1018d03d..0c989038 100644 --- a/lightning-c-bindings/src/lightning/onion_message/messenger.rs +++ b/lightning-c-bindings/src/lightning/onion_message/messenger.rs @@ -19,7 +19,7 @@ use alloc::{vec::Vec, boxed::Box}; use lightning::onion_message::messenger::OnionMessenger as nativeOnionMessengerImport; -pub(crate) type nativeOnionMessenger = nativeOnionMessengerImport; +pub(crate) type nativeOnionMessenger = nativeOnionMessengerImport; /// A sender, receiver and forwarder of onion messages. In upcoming releases, this object will be /// used to retrieve invoices and fulfill invoice requests from [offers]. Currently, only sending @@ -32,9 +32,9 @@ pub(crate) type nativeOnionMessenger = nativeOnionMessengerImport, destination: Destination) -> Result { +/// # unimplemented!() +/// # } +/// # } /// # let seed = [42u8; 32]; /// # let time = Duration::from_secs(123456); /// # let keys_manager = KeysManager::new(&seed, time.as_secs(), time.subsec_nanos()); @@ -53,10 +59,15 @@ pub(crate) type nativeOnionMessenger = nativeOnionMessengerImport @@ -139,6 +156,253 @@ impl OnionMessenger { ret } } +/// A trait defining behavior for routing an [`OnionMessage`]. +/// +/// [`OnionMessage`]: msgs::OnionMessage +#[repr(C)] +pub struct MessageRouter { + /// An opaque pointer which is passed to your function implementations as an argument. + /// This has no meaning in the LDK, and can be NULL or any other value. + pub this_arg: *mut c_void, + /// Returns a route for sending an [`OnionMessage`] to the given [`Destination`]. + /// + /// [`OnionMessage`]: msgs::OnionMessage + pub find_path: extern "C" fn (this_arg: *const c_void, sender: crate::c_types::PublicKey, peers: crate::c_types::derived::CVec_PublicKeyZ, destination: crate::lightning::onion_message::messenger::Destination) -> crate::c_types::derived::CResult_OnionMessagePathNoneZ, + /// Frees any resources associated with this object given its this_arg pointer. + /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + pub free: Option, +} +unsafe impl Send for MessageRouter {} +unsafe impl Sync for MessageRouter {} +#[no_mangle] +pub(crate) extern "C" fn MessageRouter_clone_fields(orig: &MessageRouter) -> MessageRouter { + MessageRouter { + this_arg: orig.this_arg, + find_path: Clone::clone(&orig.find_path), + free: Clone::clone(&orig.free), + } +} + +use lightning::onion_message::messenger::MessageRouter as rustMessageRouter; +impl rustMessageRouter for MessageRouter { + fn find_path(&self, mut sender: bitcoin::secp256k1::PublicKey, mut peers: Vec, mut destination: lightning::onion_message::messenger::Destination) -> Result { + let mut local_peers = Vec::new(); for mut item in peers.drain(..) { local_peers.push( { crate::c_types::PublicKey::from_rust(&item) }); }; + let mut ret = (self.find_path)(self.this_arg, crate::c_types::PublicKey::from_rust(&sender), local_peers.into(), crate::lightning::onion_message::messenger::Destination::native_into(destination)); + let mut local_ret = match ret.result_ok { true => Ok( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).take_inner()) } }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } +} + +// We're essentially a pointer already, or at least a set of pointers, so allow us to be used +// directly as a Deref trait in higher-level structs: +impl core::ops::Deref for MessageRouter { + type Target = Self; + fn deref(&self) -> &Self { + self + } +} +/// Calls the free function if one is set +#[no_mangle] +pub extern "C" fn MessageRouter_free(this_ptr: MessageRouter) { } +impl Drop for MessageRouter { + fn drop(&mut self) { + if let Some(f) = self.free { + f(self.this_arg); + } + } +} + +use lightning::onion_message::messenger::DefaultMessageRouter as nativeDefaultMessageRouterImport; +pub(crate) type nativeDefaultMessageRouter = nativeDefaultMessageRouterImport; + +/// A [`MessageRouter`] that always fails. +#[must_use] +#[repr(C)] +pub struct DefaultMessageRouter { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeDefaultMessageRouter, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for DefaultMessageRouter { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeDefaultMessageRouter>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the DefaultMessageRouter, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn DefaultMessageRouter_free(this_obj: DefaultMessageRouter) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn DefaultMessageRouter_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeDefaultMessageRouter) }; +} +#[allow(unused)] +impl DefaultMessageRouter { + pub(crate) fn get_native_ref(&self) -> &'static nativeDefaultMessageRouter { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeDefaultMessageRouter { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeDefaultMessageRouter { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +/// Constructs a new DefaultMessageRouter given each field +#[must_use] +#[no_mangle] +pub extern "C" fn DefaultMessageRouter_new() -> DefaultMessageRouter { + DefaultMessageRouter { inner: ObjOps::heap_alloc(lightning::onion_message::messenger::DefaultMessageRouter {}), is_owned: true } +} +impl From for crate::lightning::onion_message::messenger::MessageRouter { + fn from(obj: nativeDefaultMessageRouter) -> Self { + let mut rust_obj = DefaultMessageRouter { inner: ObjOps::heap_alloc(obj), is_owned: true }; + let mut ret = DefaultMessageRouter_as_MessageRouter(&rust_obj); + // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn + rust_obj.inner = core::ptr::null_mut(); + ret.free = Some(DefaultMessageRouter_free_void); + ret + } +} +/// Constructs a new MessageRouter which calls the relevant methods on this_arg. +/// This copies the `inner` pointer in this_arg and thus the returned MessageRouter must be freed before this_arg is +#[no_mangle] +pub extern "C" fn DefaultMessageRouter_as_MessageRouter(this_arg: &DefaultMessageRouter) -> crate::lightning::onion_message::messenger::MessageRouter { + crate::lightning::onion_message::messenger::MessageRouter { + this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, + free: None, + find_path: DefaultMessageRouter_MessageRouter_find_path, + } +} + +#[must_use] +extern "C" fn DefaultMessageRouter_MessageRouter_find_path(this_arg: *const c_void, mut sender: crate::c_types::PublicKey, mut peers: crate::c_types::derived::CVec_PublicKeyZ, mut destination: crate::lightning::onion_message::messenger::Destination) -> crate::c_types::derived::CResult_OnionMessagePathNoneZ { + let mut local_peers = Vec::new(); for mut item in peers.into_rust().drain(..) { local_peers.push( { item.into_rust() }); }; + let mut ret = >::find_path(unsafe { &mut *(this_arg as *mut nativeDefaultMessageRouter) }, sender.into_rust(), local_peers, destination.into_native()); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::onion_message::messenger::OnionMessagePath { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + + +use lightning::onion_message::messenger::OnionMessagePath as nativeOnionMessagePathImport; +pub(crate) type nativeOnionMessagePath = nativeOnionMessagePathImport; + +/// A path for sending an [`msgs::OnionMessage`]. +#[must_use] +#[repr(C)] +pub struct OnionMessagePath { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeOnionMessagePath, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for OnionMessagePath { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeOnionMessagePath>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the OnionMessagePath, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn OnionMessagePath_free(this_obj: OnionMessagePath) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn OnionMessagePath_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeOnionMessagePath) }; +} +#[allow(unused)] +impl OnionMessagePath { + pub(crate) fn get_native_ref(&self) -> &'static nativeOnionMessagePath { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOnionMessagePath { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeOnionMessagePath { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +/// Nodes on the path between the sender and the destination. +/// +/// Returns a copy of the field. +#[no_mangle] +pub extern "C" fn OnionMessagePath_get_intermediate_nodes(this_ptr: &OnionMessagePath) -> crate::c_types::derived::CVec_PublicKeyZ { + let mut inner_val = this_ptr.get_native_mut_ref().intermediate_nodes.clone(); + let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { crate::c_types::PublicKey::from_rust(&item) }); }; + local_inner_val.into() +} +/// Nodes on the path between the sender and the destination. +#[no_mangle] +pub extern "C" fn OnionMessagePath_set_intermediate_nodes(this_ptr: &mut OnionMessagePath, mut val: crate::c_types::derived::CVec_PublicKeyZ) { + let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_rust() }); }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.intermediate_nodes = local_val; +} +/// The recipient of the message. +#[no_mangle] +pub extern "C" fn OnionMessagePath_get_destination(this_ptr: &OnionMessagePath) -> crate::lightning::onion_message::messenger::Destination { + let mut inner_val = &mut this_ptr.get_native_mut_ref().destination; + crate::lightning::onion_message::messenger::Destination::from_native(inner_val) +} +/// The recipient of the message. +#[no_mangle] +pub extern "C" fn OnionMessagePath_set_destination(this_ptr: &mut OnionMessagePath, mut val: crate::lightning::onion_message::messenger::Destination) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.destination = val.into_native(); +} +/// Constructs a new OnionMessagePath given each field +#[must_use] +#[no_mangle] +pub extern "C" fn OnionMessagePath_new(mut intermediate_nodes_arg: crate::c_types::derived::CVec_PublicKeyZ, mut destination_arg: crate::lightning::onion_message::messenger::Destination) -> OnionMessagePath { + let mut local_intermediate_nodes_arg = Vec::new(); for mut item in intermediate_nodes_arg.into_rust().drain(..) { local_intermediate_nodes_arg.push( { item.into_rust() }); }; + OnionMessagePath { inner: ObjOps::heap_alloc(nativeOnionMessagePath { + intermediate_nodes: local_intermediate_nodes_arg, + destination: destination_arg.into_native(), + }), is_owned: true } +} +impl Clone for OnionMessagePath { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeOnionMessagePath>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn OnionMessagePath_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeOnionMessagePath)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the OnionMessagePath +pub extern "C" fn OnionMessagePath_clone(orig: &OnionMessagePath) -> OnionMessagePath { + orig.clone() +} /// The destination of an onion message. #[derive(Clone)] #[must_use] @@ -262,7 +526,7 @@ pub enum SendError { BufferFull, /// Failed to retrieve our node id from the provided [`NodeSigner`]. /// - /// [`NodeSigner`]: crate::chain::keysinterface::NodeSigner + /// [`NodeSigner`]: crate::sign::NodeSigner GetNodeIdFailed, /// We attempted to send to a blinded path where we are the introduction node, and failed to /// advance the blinded path to make the second hop the new introduction node. Either @@ -407,11 +671,10 @@ pub struct CustomOnionMessageHandler { /// An opaque pointer which is passed to your function implementations as an argument. /// This has no meaning in the LDK, and can be NULL or any other value. pub this_arg: *mut c_void, - /// Called with the custom message that was received. - pub handle_custom_message: extern "C" fn (this_arg: *const c_void, msg: crate::lightning::onion_message::packet::CustomOnionMessageContents), + /// Called with the custom message that was received, returning a response to send, if any. + pub handle_custom_message: extern "C" fn (this_arg: *const c_void, msg: crate::lightning::onion_message::packet::CustomOnionMessageContents) -> crate::c_types::derived::COption_CustomOnionMessageContentsZ, /// Read a custom message of type `message_type` from `buffer`, returning `Ok(None)` if the /// message type is unknown. - #[must_use] pub read_custom_message: extern "C" fn (this_arg: *const c_void, message_type: u64, buffer: crate::c_types::u8slice) -> crate::c_types::derived::CResult_COption_CustomOnionMessageContentsZDecodeErrorZ, /// Frees any resources associated with this object given its this_arg pointer. /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. @@ -432,8 +695,10 @@ pub(crate) extern "C" fn CustomOnionMessageHandler_clone_fields(orig: &CustomOni use lightning::onion_message::messenger::CustomOnionMessageHandler as rustCustomOnionMessageHandler; impl rustCustomOnionMessageHandler for CustomOnionMessageHandler { type CustomMessage = crate::lightning::onion_message::packet::CustomOnionMessageContents; - fn handle_custom_message(&self, mut msg: crate::lightning::onion_message::packet::CustomOnionMessageContents) { - (self.handle_custom_message)(self.this_arg, Into::into(msg)) + fn handle_custom_message(&self, mut msg: crate::lightning::onion_message::packet::CustomOnionMessageContents) -> Option { + let mut ret = (self.handle_custom_message)(self.this_arg, Into::into(msg)); + let mut local_ret = { /*ret*/ let ret_opt = ret; if ret_opt.is_none() { None } else { Some({ { { ret_opt.take() } }})} }; + local_ret } fn read_custom_message(&self, mut message_type: u64, mut buffer: &mut R) -> Result, lightning::ln::msgs::DecodeError> { let mut ret = (self.read_custom_message)(self.this_arg, message_type, crate::c_types::u8slice::from_vec(&crate::c_types::reader_to_vec(buffer))); @@ -464,21 +729,21 @@ impl Drop for CustomOnionMessageHandler { /// their respective handlers. #[must_use] #[no_mangle] -pub extern "C" fn OnionMessenger_new(mut entropy_source: crate::lightning::chain::keysinterface::EntropySource, mut node_signer: crate::lightning::chain::keysinterface::NodeSigner, mut logger: crate::lightning::util::logger::Logger, mut custom_handler: crate::lightning::onion_message::messenger::CustomOnionMessageHandler) -> crate::lightning::onion_message::messenger::OnionMessenger { - let mut ret = lightning::onion_message::messenger::OnionMessenger::new(entropy_source, node_signer, logger, custom_handler); +pub extern "C" fn OnionMessenger_new(mut entropy_source: crate::lightning::sign::EntropySource, mut node_signer: crate::lightning::sign::NodeSigner, mut logger: crate::lightning::util::logger::Logger, mut message_router: crate::lightning::onion_message::messenger::MessageRouter, mut offers_handler: crate::lightning::onion_message::offers::OffersMessageHandler, mut custom_handler: crate::lightning::onion_message::messenger::CustomOnionMessageHandler) -> crate::lightning::onion_message::messenger::OnionMessenger { + let mut ret = lightning::onion_message::messenger::OnionMessenger::new(entropy_source, node_signer, logger, message_router, offers_handler, custom_handler); crate::lightning::onion_message::messenger::OnionMessenger { inner: ObjOps::heap_alloc(ret), is_owned: true } } -/// Send an onion message with contents `message` to `destination`, routing it through `intermediate_nodes`. +/// Send an onion message with contents `message` to the destination of `path`. +/// /// See [`OnionMessenger`] for example usage. /// /// Note that reply_path (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn OnionMessenger_send_onion_message(this_arg: &crate::lightning::onion_message::messenger::OnionMessenger, mut intermediate_nodes: crate::c_types::derived::CVec_PublicKeyZ, mut destination: crate::lightning::onion_message::messenger::Destination, mut message: crate::lightning::onion_message::packet::OnionMessageContents, mut reply_path: crate::lightning::blinded_path::BlindedPath) -> crate::c_types::derived::CResult_NoneSendErrorZ { - let mut local_intermediate_nodes = Vec::new(); for mut item in intermediate_nodes.into_rust().drain(..) { local_intermediate_nodes.push( { item.into_rust() }); }; +pub extern "C" fn OnionMessenger_send_onion_message(this_arg: &crate::lightning::onion_message::messenger::OnionMessenger, mut path: crate::lightning::onion_message::messenger::OnionMessagePath, mut message: crate::lightning::onion_message::packet::OnionMessageContents, mut reply_path: crate::lightning::blinded_path::BlindedPath) -> crate::c_types::derived::CResult_NoneSendErrorZ { let mut local_reply_path = if reply_path.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(reply_path.take_inner()) } }) }; - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.send_onion_message(&local_intermediate_nodes[..], destination.into_native(), message.into_native(), local_reply_path); + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.send_onion_message(*unsafe { Box::from_raw(path.take_inner()) }, message.into_native(), local_reply_path); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::onion_message::messenger::SendError::native_into(e) }).into() }; local_ret } diff --git a/lightning-c-bindings/src/lightning/onion_message/mod.rs b/lightning-c-bindings/src/lightning/onion_message/mod.rs index ad9bd5dd..83d2f00d 100644 --- a/lightning-c-bindings/src/lightning/onion_message/mod.rs +++ b/lightning-c-bindings/src/lightning/onion_message/mod.rs @@ -28,4 +28,5 @@ use crate::c_types::*; use alloc::{vec::Vec, boxed::Box}; pub mod messenger; +pub mod offers; pub mod packet; diff --git a/lightning-c-bindings/src/lightning/onion_message/packet.rs b/lightning-c-bindings/src/lightning/onion_message/packet.rs index 9ca90379..8b253aad 100644 --- a/lightning-c-bindings/src/lightning/onion_message/packet.rs +++ b/lightning-c-bindings/src/lightning/onion_message/packet.rs @@ -21,6 +21,9 @@ use alloc::{vec::Vec, boxed::Box}; #[must_use] #[repr(C)] pub enum OnionMessageContents { + /// A message related to BOLT 12 Offers. + Offers( + crate::lightning::onion_message::offers::OffersMessage), /// A custom onion message specified by the user. Custom( crate::lightning::onion_message::packet::CustomOnionMessageContents), @@ -32,6 +35,11 @@ impl OnionMessageContents { #[allow(unused)] pub(crate) fn into_native(self) -> nativeOnionMessageContents { match self { + OnionMessageContents::Offers (mut a, ) => { + nativeOnionMessageContents::Offers ( + a.into_native(), + ) + }, OnionMessageContents::Custom (mut a, ) => { nativeOnionMessageContents::Custom ( a, @@ -42,6 +50,11 @@ impl OnionMessageContents { #[allow(unused)] pub(crate) fn native_into(native: nativeOnionMessageContents) -> Self { match native { + nativeOnionMessageContents::Offers (mut a, ) => { + OnionMessageContents::Offers ( + crate::lightning::onion_message::offers::OffersMessage::native_into(a), + ) + }, nativeOnionMessageContents::Custom (mut a, ) => { OnionMessageContents::Custom ( Into::into(a), @@ -54,6 +67,11 @@ impl OnionMessageContents { #[no_mangle] pub extern "C" fn OnionMessageContents_free(this_ptr: OnionMessageContents) { } #[no_mangle] +/// Utility method to constructs a new Offers-variant OnionMessageContents +pub extern "C" fn OnionMessageContents_offers(a: crate::lightning::onion_message::offers::OffersMessage) -> OnionMessageContents { + OnionMessageContents::Offers(a, ) +} +#[no_mangle] /// Utility method to constructs a new Custom-variant OnionMessageContents pub extern "C" fn OnionMessageContents_custom(a: crate::lightning::onion_message::packet::CustomOnionMessageContents) -> OnionMessageContents { OnionMessageContents::Custom(a, ) @@ -65,7 +83,6 @@ pub struct CustomOnionMessageContents { /// This has no meaning in the LDK, and can be NULL or any other value. pub this_arg: *mut c_void, /// Returns the TLV type identifying the message contents. MUST be >= 64. - #[must_use] pub tlv_type: extern "C" fn (this_arg: *const c_void) -> u64, /// Serialize the object into a byte array pub write: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_u8Z, diff --git a/lightning-c-bindings/src/lightning/routing/gossip.rs b/lightning-c-bindings/src/lightning/routing/gossip.rs index 021fa0b3..ed22681e 100644 --- a/lightning-c-bindings/src/lightning/routing/gossip.rs +++ b/lightning-c-bindings/src/lightning/routing/gossip.rs @@ -509,6 +509,34 @@ pub extern "C" fn NetworkGraph_handle_network_update(this_arg: &crate::lightning unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.handle_network_update(&network_update.to_native()) } +/// Gets the genesis hash for this network graph. +#[must_use] +#[no_mangle] +pub extern "C" fn NetworkGraph_get_genesis_hash(this_arg: &crate::lightning::routing::gossip::NetworkGraph) -> crate::c_types::ThirtyTwoBytes { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_genesis_hash(); + crate::c_types::ThirtyTwoBytes { data: ret.into_inner() } +} + +/// Verifies the signature of a [`NodeAnnouncement`]. +/// +/// Returns an error if it is invalid. +#[no_mangle] +pub extern "C" fn verify_node_announcement(msg: &crate::lightning::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CResult_NoneLightningErrorZ { + let mut ret = lightning::routing::gossip::verify_node_announcement(msg.get_native_ref(), secp256k1::global::SECP256K1); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; + local_ret +} + +/// Verifies all signatures included in a [`ChannelAnnouncement`]. +/// +/// Returns an error if one of the signatures is invalid. +#[no_mangle] +pub extern "C" fn verify_channel_announcement(msg: &crate::lightning::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CResult_NoneLightningErrorZ { + let mut ret = lightning::routing::gossip::verify_channel_announcement(msg.get_native_ref(), secp256k1::global::SECP256K1); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; + local_ret +} + impl From for crate::lightning::ln::msgs::RoutingMessageHandler { fn from(obj: nativeP2PGossipSync) -> Self { let mut rust_obj = P2PGossipSync { inner: ObjOps::heap_alloc(obj), is_owned: true }; @@ -1178,7 +1206,7 @@ pub enum EffectiveCapacity { liquidity_msat: u64, }, /// The maximum HTLC amount in one direction as advertised on the gossip network. - MaximumHTLC { + AdvertisedMaxHTLC { /// The maximum HTLC amount denominated in millisatoshi. amount_msat: u64, }, @@ -1192,6 +1220,11 @@ pub enum EffectiveCapacity { /// A capacity sufficient to route any payment, typically used for private channels provided by /// an invoice. Infinite, + /// The maximum HTLC amount as provided by an invoice route hint. + HintMaxHTLC { + /// The maximum HTLC amount denominated in millisatoshi. + amount_msat: u64, + }, /// A capacity that is unknown possibly because either the chain state is unavailable to know /// the total capacity or the `htlc_maximum_msat` was not advertised on the gossip network. Unknown, @@ -1209,9 +1242,9 @@ impl EffectiveCapacity { liquidity_msat: liquidity_msat_nonref, } }, - EffectiveCapacity::MaximumHTLC {ref amount_msat, } => { + EffectiveCapacity::AdvertisedMaxHTLC {ref amount_msat, } => { let mut amount_msat_nonref = Clone::clone(amount_msat); - nativeEffectiveCapacity::MaximumHTLC { + nativeEffectiveCapacity::AdvertisedMaxHTLC { amount_msat: amount_msat_nonref, } }, @@ -1224,6 +1257,12 @@ impl EffectiveCapacity { } }, EffectiveCapacity::Infinite => nativeEffectiveCapacity::Infinite, + EffectiveCapacity::HintMaxHTLC {ref amount_msat, } => { + let mut amount_msat_nonref = Clone::clone(amount_msat); + nativeEffectiveCapacity::HintMaxHTLC { + amount_msat: amount_msat_nonref, + } + }, EffectiveCapacity::Unknown => nativeEffectiveCapacity::Unknown, } } @@ -1235,8 +1274,8 @@ impl EffectiveCapacity { liquidity_msat: liquidity_msat, } }, - EffectiveCapacity::MaximumHTLC {mut amount_msat, } => { - nativeEffectiveCapacity::MaximumHTLC { + EffectiveCapacity::AdvertisedMaxHTLC {mut amount_msat, } => { + nativeEffectiveCapacity::AdvertisedMaxHTLC { amount_msat: amount_msat, } }, @@ -1247,6 +1286,11 @@ impl EffectiveCapacity { } }, EffectiveCapacity::Infinite => nativeEffectiveCapacity::Infinite, + EffectiveCapacity::HintMaxHTLC {mut amount_msat, } => { + nativeEffectiveCapacity::HintMaxHTLC { + amount_msat: amount_msat, + } + }, EffectiveCapacity::Unknown => nativeEffectiveCapacity::Unknown, } } @@ -1259,9 +1303,9 @@ impl EffectiveCapacity { liquidity_msat: liquidity_msat_nonref, } }, - nativeEffectiveCapacity::MaximumHTLC {ref amount_msat, } => { + nativeEffectiveCapacity::AdvertisedMaxHTLC {ref amount_msat, } => { let mut amount_msat_nonref = Clone::clone(amount_msat); - EffectiveCapacity::MaximumHTLC { + EffectiveCapacity::AdvertisedMaxHTLC { amount_msat: amount_msat_nonref, } }, @@ -1274,6 +1318,12 @@ impl EffectiveCapacity { } }, nativeEffectiveCapacity::Infinite => EffectiveCapacity::Infinite, + nativeEffectiveCapacity::HintMaxHTLC {ref amount_msat, } => { + let mut amount_msat_nonref = Clone::clone(amount_msat); + EffectiveCapacity::HintMaxHTLC { + amount_msat: amount_msat_nonref, + } + }, nativeEffectiveCapacity::Unknown => EffectiveCapacity::Unknown, } } @@ -1285,8 +1335,8 @@ impl EffectiveCapacity { liquidity_msat: liquidity_msat, } }, - nativeEffectiveCapacity::MaximumHTLC {mut amount_msat, } => { - EffectiveCapacity::MaximumHTLC { + nativeEffectiveCapacity::AdvertisedMaxHTLC {mut amount_msat, } => { + EffectiveCapacity::AdvertisedMaxHTLC { amount_msat: amount_msat, } }, @@ -1297,6 +1347,11 @@ impl EffectiveCapacity { } }, nativeEffectiveCapacity::Infinite => EffectiveCapacity::Infinite, + nativeEffectiveCapacity::HintMaxHTLC {mut amount_msat, } => { + EffectiveCapacity::HintMaxHTLC { + amount_msat: amount_msat, + } + }, nativeEffectiveCapacity::Unknown => EffectiveCapacity::Unknown, } } @@ -1317,9 +1372,9 @@ pub extern "C" fn EffectiveCapacity_exact_liquidity(liquidity_msat: u64) -> Effe } } #[no_mangle] -/// Utility method to constructs a new MaximumHTLC-variant EffectiveCapacity -pub extern "C" fn EffectiveCapacity_maximum_htlc(amount_msat: u64) -> EffectiveCapacity { - EffectiveCapacity::MaximumHTLC { +/// Utility method to constructs a new AdvertisedMaxHTLC-variant EffectiveCapacity +pub extern "C" fn EffectiveCapacity_advertised_max_htlc(amount_msat: u64) -> EffectiveCapacity { + EffectiveCapacity::AdvertisedMaxHTLC { amount_msat, } } @@ -1336,6 +1391,13 @@ pub extern "C" fn EffectiveCapacity_total(capacity_msat: u64, htlc_maximum_msat: pub extern "C" fn EffectiveCapacity_infinite() -> EffectiveCapacity { EffectiveCapacity::Infinite} #[no_mangle] +/// Utility method to constructs a new HintMaxHTLC-variant EffectiveCapacity +pub extern "C" fn EffectiveCapacity_hint_max_htlc(amount_msat: u64) -> EffectiveCapacity { + EffectiveCapacity::HintMaxHTLC { + amount_msat, + } +} +#[no_mangle] /// Utility method to constructs a new Unknown-variant EffectiveCapacity pub extern "C" fn EffectiveCapacity_unknown() -> EffectiveCapacity { EffectiveCapacity::Unknown} @@ -2015,8 +2077,8 @@ pub extern "C" fn NetworkGraph_update_node_from_unsigned_announcement(this_arg: /// Store or update channel info from a channel announcement. /// -/// You probably don't want to call this directly, instead relying on a P2PGossipSync's -/// RoutingMessageHandler implementation to call it indirectly. This may be useful to accept +/// You probably don't want to call this directly, instead relying on a [`P2PGossipSync`]'s +/// [`RoutingMessageHandler`] implementation to call it indirectly. This may be useful to accept /// routing messages from a source using a protocol other than the lightning P2P protocol. /// /// If a [`UtxoLookup`] object is provided via `utxo_lookup`, it will be called to verify @@ -2030,6 +2092,21 @@ pub extern "C" fn NetworkGraph_update_channel_from_announcement(this_arg: &crate local_ret } +/// Store or update channel info from a channel announcement. +/// +/// You probably don't want to call this directly, instead relying on a [`P2PGossipSync`]'s +/// [`RoutingMessageHandler`] implementation to call it indirectly. This may be useful to accept +/// routing messages from a source using a protocol other than the lightning P2P protocol. +/// +/// This will skip verification of if the channel is actually on-chain. +#[must_use] +#[no_mangle] +pub extern "C" fn NetworkGraph_update_channel_from_announcement_no_lookup(this_arg: &crate::lightning::routing::gossip::NetworkGraph, msg: &crate::lightning::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CResult_NoneLightningErrorZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.update_channel_from_announcement_no_lookup(msg.get_native_ref()); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; + local_ret +} + /// Store or update channel info from a channel announcement without verifying the associated /// signatures. Because we aren't given the associated signatures here we cannot relay the /// channel announcement to any of our peers. diff --git a/lightning-c-bindings/src/lightning/routing/router.rs b/lightning-c-bindings/src/lightning/routing/router.rs index 2b7cc359..5e12f9e8 100644 --- a/lightning-c-bindings/src/lightning/routing/router.rs +++ b/lightning-c-bindings/src/lightning/routing/router.rs @@ -70,8 +70,8 @@ impl DefaultRouter { /// Creates a new router. #[must_use] #[no_mangle] -pub extern "C" fn DefaultRouter_new(network_graph: &crate::lightning::routing::gossip::NetworkGraph, mut logger: crate::lightning::util::logger::Logger, mut random_seed_bytes: crate::c_types::ThirtyTwoBytes, mut scorer: crate::lightning::routing::scoring::LockableScore) -> crate::lightning::routing::router::DefaultRouter { - let mut ret = lightning::routing::router::DefaultRouter::new(network_graph.get_native_ref(), logger, random_seed_bytes.data, scorer); +pub extern "C" fn DefaultRouter_new(network_graph: &crate::lightning::routing::gossip::NetworkGraph, mut logger: crate::lightning::util::logger::Logger, mut random_seed_bytes: crate::c_types::ThirtyTwoBytes, mut scorer: crate::lightning::routing::scoring::LockableScore, mut score_params: crate::lightning::routing::scoring::ProbabilisticScoringFeeParameters) -> crate::lightning::routing::router::DefaultRouter { + let mut ret = lightning::routing::router::DefaultRouter::new(network_graph.get_native_ref(), logger, random_seed_bytes.data, scorer, *unsafe { Box::from_raw(score_params.take_inner()) }); crate::lightning::routing::router::DefaultRouter { inner: ObjOps::heap_alloc(ret), is_owned: true } } @@ -98,16 +98,16 @@ pub extern "C" fn DefaultRouter_as_Router(this_arg: &DefaultRouter) -> crate::li } #[must_use] -extern "C" fn DefaultRouter_Router_find_route(this_arg: *const c_void, mut payer: crate::c_types::PublicKey, route_params: &crate::lightning::routing::router::RouteParameters, first_hops: *mut crate::c_types::derived::CVec_ChannelDetailsZ, inflight_htlcs: &crate::lightning::routing::router::InFlightHtlcs) -> crate::c_types::derived::CResult_RouteLightningErrorZ { +extern "C" fn DefaultRouter_Router_find_route(this_arg: *const c_void, mut payer: crate::c_types::PublicKey, route_params: &crate::lightning::routing::router::RouteParameters, first_hops: *mut crate::c_types::derived::CVec_ChannelDetailsZ, mut inflight_htlcs: crate::lightning::routing::router::InFlightHtlcs) -> crate::c_types::derived::CResult_RouteLightningErrorZ { let mut local_first_hops_base = if first_hops == core::ptr::null_mut() { None } else { Some( { let mut local_first_hops_0 = Vec::new(); for mut item in unsafe { &mut *first_hops }.as_slice().iter() { local_first_hops_0.push( { item.get_native_ref() }); }; local_first_hops_0 }) }; let mut local_first_hops = local_first_hops_base.as_ref().map(|a| &a[..]); - let mut ret = >::find_route(unsafe { &mut *(this_arg as *mut nativeDefaultRouter) }, &payer.into_rust(), route_params.get_native_ref(), local_first_hops, inflight_htlcs.get_native_ref()); + let mut ret = >::find_route(unsafe { &mut *(this_arg as *mut nativeDefaultRouter) }, &payer.into_rust(), route_params.get_native_ref(), local_first_hops, *unsafe { Box::from_raw(inflight_htlcs.take_inner()) }); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::router::Route { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; local_ret } #[must_use] -extern "C" fn DefaultRouter_Router_find_route_with_id(this_arg: *const c_void, mut payer: crate::c_types::PublicKey, route_params: &crate::lightning::routing::router::RouteParameters, first_hops: *mut crate::c_types::derived::CVec_ChannelDetailsZ, inflight_htlcs: &crate::lightning::routing::router::InFlightHtlcs, mut _payment_hash: crate::c_types::ThirtyTwoBytes, mut _payment_id: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_RouteLightningErrorZ { +extern "C" fn DefaultRouter_Router_find_route_with_id(this_arg: *const c_void, mut payer: crate::c_types::PublicKey, route_params: &crate::lightning::routing::router::RouteParameters, first_hops: *mut crate::c_types::derived::CVec_ChannelDetailsZ, mut inflight_htlcs: crate::lightning::routing::router::InFlightHtlcs, mut _payment_hash: crate::c_types::ThirtyTwoBytes, mut _payment_id: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_RouteLightningErrorZ { let mut local_first_hops_base = if first_hops == core::ptr::null_mut() { None } else { Some( { let mut local_first_hops_0 = Vec::new(); for mut item in unsafe { &mut *first_hops }.as_slice().iter() { local_first_hops_0.push( { item.get_native_ref() }); }; local_first_hops_0 }) }; let mut local_first_hops = local_first_hops_base.as_ref().map(|a| &a[..]); - let mut ret = >::find_route_with_id(unsafe { &mut *(this_arg as *mut nativeDefaultRouter) }, &payer.into_rust(), route_params.get_native_ref(), local_first_hops, inflight_htlcs.get_native_ref(), ::lightning::ln::PaymentHash(_payment_hash.data), ::lightning::ln::channelmanager::PaymentId(_payment_id.data)); + let mut ret = >::find_route_with_id(unsafe { &mut *(this_arg as *mut nativeDefaultRouter) }, &payer.into_rust(), route_params.get_native_ref(), local_first_hops, *unsafe { Box::from_raw(inflight_htlcs.take_inner()) }, ::lightning::ln::PaymentHash(_payment_hash.data), ::lightning::ln::channelmanager::PaymentId(_payment_id.data)); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::router::Route { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; local_ret } @@ -118,17 +118,23 @@ pub struct Router { /// An opaque pointer which is passed to your function implementations as an argument. /// This has no meaning in the LDK, and can be NULL or any other value. pub this_arg: *mut c_void, - /// Finds a [`Route`] between `payer` and `payee` for a payment with the given values. + /// Finds a [`Route`] for a payment between the given `payer` and a payee. + /// + /// The `payee` and the payment's value are given in [`RouteParameters::payment_params`] + /// and [`RouteParameters::final_value_msat`], respectively. /// /// Note that first_hops (or a relevant inner pointer) may be NULL or all-0s to represent None - #[must_use] - pub find_route: extern "C" fn (this_arg: *const c_void, payer: crate::c_types::PublicKey, route_params: &crate::lightning::routing::router::RouteParameters, first_hops: *mut crate::c_types::derived::CVec_ChannelDetailsZ, inflight_htlcs: &crate::lightning::routing::router::InFlightHtlcs) -> crate::c_types::derived::CResult_RouteLightningErrorZ, - /// Finds a [`Route`] between `payer` and `payee` for a payment with the given values. Includes - /// `PaymentHash` and `PaymentId` to be able to correlate the request with a specific payment. + pub find_route: extern "C" fn (this_arg: *const c_void, payer: crate::c_types::PublicKey, route_params: &crate::lightning::routing::router::RouteParameters, first_hops: *mut crate::c_types::derived::CVec_ChannelDetailsZ, inflight_htlcs: crate::lightning::routing::router::InFlightHtlcs) -> crate::c_types::derived::CResult_RouteLightningErrorZ, + /// Finds a [`Route`] for a payment between the given `payer` and a payee. + /// + /// The `payee` and the payment's value are given in [`RouteParameters::payment_params`] + /// and [`RouteParameters::final_value_msat`], respectively. + /// + /// Includes a [`PaymentHash`] and a [`PaymentId`] to be able to correlate the request with a specific + /// payment. /// /// Note that first_hops (or a relevant inner pointer) may be NULL or all-0s to represent None - #[must_use] - pub find_route_with_id: extern "C" fn (this_arg: *const c_void, payer: crate::c_types::PublicKey, route_params: &crate::lightning::routing::router::RouteParameters, first_hops: *mut crate::c_types::derived::CVec_ChannelDetailsZ, inflight_htlcs: &crate::lightning::routing::router::InFlightHtlcs, _payment_hash: crate::c_types::ThirtyTwoBytes, _payment_id: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_RouteLightningErrorZ, + pub find_route_with_id: extern "C" fn (this_arg: *const c_void, payer: crate::c_types::PublicKey, route_params: &crate::lightning::routing::router::RouteParameters, first_hops: *mut crate::c_types::derived::CVec_ChannelDetailsZ, inflight_htlcs: crate::lightning::routing::router::InFlightHtlcs, _payment_hash: crate::c_types::ThirtyTwoBytes, _payment_id: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_RouteLightningErrorZ, /// Frees any resources associated with this object given its this_arg pointer. /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. pub free: Option, @@ -147,15 +153,15 @@ pub(crate) extern "C" fn Router_clone_fields(orig: &Router) -> Router { use lightning::routing::router::Router as rustRouter; impl rustRouter for Router { - fn find_route(&self, mut payer: &bitcoin::secp256k1::PublicKey, mut route_params: &lightning::routing::router::RouteParameters, mut first_hops: Option<&[&lightning::ln::channelmanager::ChannelDetails]>, mut inflight_htlcs: &lightning::routing::router::InFlightHtlcs) -> Result { + fn find_route(&self, mut payer: &bitcoin::secp256k1::PublicKey, mut route_params: &lightning::routing::router::RouteParameters, mut first_hops: Option<&[&lightning::ln::channelmanager::ChannelDetails]>, mut inflight_htlcs: lightning::routing::router::InFlightHtlcs) -> Result { let mut local_first_hops_base = if first_hops.is_none() { SmartPtr::null() } else { SmartPtr::from_obj( { let mut local_first_hops_0 = Vec::new(); for item in (first_hops.unwrap()).iter() { local_first_hops_0.push( { crate::lightning::ln::channelmanager::ChannelDetails { inner: unsafe { ObjOps::nonnull_ptr_to_inner(((*item) as *const lightning::ln::channelmanager::ChannelDetails<>) as *mut _) }, is_owned: false } }); }; local_first_hops_0.into() }) }; let mut local_first_hops = *local_first_hops_base; - let mut ret = (self.find_route)(self.this_arg, crate::c_types::PublicKey::from_rust(&payer), &crate::lightning::routing::router::RouteParameters { inner: unsafe { ObjOps::nonnull_ptr_to_inner((route_params as *const lightning::routing::router::RouteParameters<>) as *mut _) }, is_owned: false }, local_first_hops, &crate::lightning::routing::router::InFlightHtlcs { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inflight_htlcs as *const lightning::routing::router::InFlightHtlcs<>) as *mut _) }, is_owned: false }); + let mut ret = (self.find_route)(self.this_arg, crate::c_types::PublicKey::from_rust(&payer), &crate::lightning::routing::router::RouteParameters { inner: unsafe { ObjOps::nonnull_ptr_to_inner((route_params as *const lightning::routing::router::RouteParameters<>) as *mut _) }, is_owned: false }, local_first_hops, crate::lightning::routing::router::InFlightHtlcs { inner: ObjOps::heap_alloc(inflight_htlcs), is_owned: true }); let mut local_ret = match ret.result_ok { true => Ok( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).take_inner()) } }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })}; local_ret } - fn find_route_with_id(&self, mut payer: &bitcoin::secp256k1::PublicKey, mut route_params: &lightning::routing::router::RouteParameters, mut first_hops: Option<&[&lightning::ln::channelmanager::ChannelDetails]>, mut inflight_htlcs: &lightning::routing::router::InFlightHtlcs, mut _payment_hash: lightning::ln::PaymentHash, mut _payment_id: lightning::ln::channelmanager::PaymentId) -> Result { + fn find_route_with_id(&self, mut payer: &bitcoin::secp256k1::PublicKey, mut route_params: &lightning::routing::router::RouteParameters, mut first_hops: Option<&[&lightning::ln::channelmanager::ChannelDetails]>, mut inflight_htlcs: lightning::routing::router::InFlightHtlcs, mut _payment_hash: lightning::ln::PaymentHash, mut _payment_id: lightning::ln::channelmanager::PaymentId) -> Result { let mut local_first_hops_base = if first_hops.is_none() { SmartPtr::null() } else { SmartPtr::from_obj( { let mut local_first_hops_0 = Vec::new(); for item in (first_hops.unwrap()).iter() { local_first_hops_0.push( { crate::lightning::ln::channelmanager::ChannelDetails { inner: unsafe { ObjOps::nonnull_ptr_to_inner(((*item) as *const lightning::ln::channelmanager::ChannelDetails<>) as *mut _) }, is_owned: false } }); }; local_first_hops_0.into() }) }; let mut local_first_hops = *local_first_hops_base; - let mut ret = (self.find_route_with_id)(self.this_arg, crate::c_types::PublicKey::from_rust(&payer), &crate::lightning::routing::router::RouteParameters { inner: unsafe { ObjOps::nonnull_ptr_to_inner((route_params as *const lightning::routing::router::RouteParameters<>) as *mut _) }, is_owned: false }, local_first_hops, &crate::lightning::routing::router::InFlightHtlcs { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inflight_htlcs as *const lightning::routing::router::InFlightHtlcs<>) as *mut _) }, is_owned: false }, crate::c_types::ThirtyTwoBytes { data: _payment_hash.0 }, crate::c_types::ThirtyTwoBytes { data: _payment_id.0 }); + let mut ret = (self.find_route_with_id)(self.this_arg, crate::c_types::PublicKey::from_rust(&payer), &crate::lightning::routing::router::RouteParameters { inner: unsafe { ObjOps::nonnull_ptr_to_inner((route_params as *const lightning::routing::router::RouteParameters<>) as *mut _) }, is_owned: false }, local_first_hops, crate::lightning::routing::router::InFlightHtlcs { inner: ObjOps::heap_alloc(inflight_htlcs), is_owned: true }, crate::c_types::ThirtyTwoBytes { data: _payment_hash.0 }, crate::c_types::ThirtyTwoBytes { data: _payment_id.0 }); let mut local_ret = match ret.result_ok { true => Ok( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).take_inner()) } }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })}; local_ret } @@ -279,8 +285,8 @@ pub extern "C" fn ScorerAccountingForInFlightHtlcs_as_Score(this_arg: &ScorerAcc } #[must_use] -extern "C" fn ScorerAccountingForInFlightHtlcs_Score_channel_penalty_msat(this_arg: *const c_void, mut short_channel_id: u64, source: &crate::lightning::routing::gossip::NodeId, target: &crate::lightning::routing::gossip::NodeId, mut usage: crate::lightning::routing::scoring::ChannelUsage) -> u64 { - let mut ret = >::channel_penalty_msat(unsafe { &mut *(this_arg as *mut nativeScorerAccountingForInFlightHtlcs) }, short_channel_id, source.get_native_ref(), target.get_native_ref(), *unsafe { Box::from_raw(usage.take_inner()) }); +extern "C" fn ScorerAccountingForInFlightHtlcs_Score_channel_penalty_msat(this_arg: *const c_void, mut short_channel_id: u64, source: &crate::lightning::routing::gossip::NodeId, target: &crate::lightning::routing::gossip::NodeId, mut usage: crate::lightning::routing::scoring::ChannelUsage, score_params: &crate::lightning::routing::scoring::ProbabilisticScoringFeeParameters) -> u64 { + let mut ret = >::channel_penalty_msat(unsafe { &mut *(this_arg as *mut nativeScorerAccountingForInFlightHtlcs) }, short_channel_id, source.get_native_ref(), target.get_native_ref(), *unsafe { Box::from_raw(usage.take_inner()) }, score_params.get_native_ref()); ret } extern "C" fn ScorerAccountingForInFlightHtlcs_Score_payment_path_failed(this_arg: *mut c_void, path: &crate::lightning::routing::router::Path, mut short_channel_id: u64) { @@ -381,6 +387,13 @@ pub extern "C" fn InFlightHtlcs_process_path(this_arg: &mut crate::lightning::ro unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::routing::router::nativeInFlightHtlcs)) }.process_path(path.get_native_ref(), payer_node_id.into_rust()) } +/// Adds a known HTLC given the public key of the HTLC source, target, and short channel +/// id. +#[no_mangle] +pub extern "C" fn InFlightHtlcs_add_inflight_htlc(this_arg: &mut crate::lightning::routing::router::InFlightHtlcs, source: &crate::lightning::routing::gossip::NodeId, target: &crate::lightning::routing::gossip::NodeId, mut channel_scid: u64, mut used_msat: u64) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::routing::router::nativeInFlightHtlcs)) }.add_inflight_htlc(source.get_native_ref(), target.get_native_ref(), channel_scid, used_msat) +} + /// Returns liquidity in msat given the public key of the HTLC source, target, and short channel /// id. #[must_use] @@ -621,9 +634,9 @@ use lightning::routing::router::BlindedTail as nativeBlindedTailImport; pub(crate) type nativeBlindedTail = nativeBlindedTailImport; /// The blinded portion of a [`Path`], if we're routing to a recipient who provided blinded paths in -/// their BOLT12 [`Invoice`]. +/// their [`Bolt12Invoice`]. /// -/// [`Invoice`]: crate::offers::invoice::Invoice +/// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice #[must_use] #[repr(C)] pub struct BlindedTail { @@ -1017,11 +1030,9 @@ pub extern "C" fn Route_set_paths(this_ptr: &mut Route, mut val: crate::c_types: let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.paths = local_val; } -/// The `payment_params` parameter passed to [`find_route`]. -/// This is used by `ChannelManager` to track information which may be required for retries, -/// provided back to you via [`Event::PaymentPathFailed`]. +/// The `payment_params` parameter passed via [`RouteParameters`] to [`find_route`]. /// -/// [`Event::PaymentPathFailed`]: crate::events::Event::PaymentPathFailed +/// This is used by `ChannelManager` to track information which may be required for retries. /// /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[no_mangle] @@ -1030,11 +1041,9 @@ pub extern "C" fn Route_get_payment_params(this_ptr: &Route) -> crate::lightning let mut local_inner_val = crate::lightning::routing::router::PaymentParameters { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::routing::router::PaymentParameters<>) as *mut _ }, is_owned: false }; local_inner_val } -/// The `payment_params` parameter passed to [`find_route`]. -/// This is used by `ChannelManager` to track information which may be required for retries, -/// provided back to you via [`Event::PaymentPathFailed`]. +/// The `payment_params` parameter passed via [`RouteParameters`] to [`find_route`]. /// -/// [`Event::PaymentPathFailed`]: crate::events::Event::PaymentPathFailed +/// This is used by `ChannelManager` to track information which may be required for retries. /// /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None #[no_mangle] @@ -1094,7 +1103,7 @@ pub extern "C" fn Route_eq(a: &Route, b: &Route) -> bool { /// Returns the total amount of fees paid on this [`Route`]. /// /// This doesn't include any extra payment made to the recipient, which can happen in excess of -/// the amount passed to [`find_route`]'s `params.final_value_msat`. +/// the amount passed to [`find_route`]'s `route_params.final_value_msat`. #[must_use] #[no_mangle] pub extern "C" fn Route_get_total_fees(this_arg: &crate::lightning::routing::router::Route) -> u64 { @@ -1133,10 +1142,7 @@ pub(crate) type nativeRouteParameters = nativeRouteParametersImport; /// Parameters needed to find a [`Route`]. /// -/// Passed to [`find_route`] and [`build_route_from_hops`], but also provided in -/// [`Event::PaymentPathFailed`]. -/// -/// [`Event::PaymentPathFailed`]: crate::events::Event::PaymentPathFailed +/// Passed to [`find_route`] and [`build_route_from_hops`]. #[must_use] #[repr(C)] pub struct RouteParameters { @@ -1270,7 +1276,7 @@ pub static DEFAULT_MAX_PATH_COUNT: u8 = lightning::routing::router::DEFAULT_MAX_ use lightning::routing::router::PaymentParameters as nativePaymentParametersImport; pub(crate) type nativePaymentParameters = nativePaymentParametersImport; -/// The recipient of a payment. +/// Information used to route a payment. #[must_use] #[repr(C)] pub struct PaymentParameters { @@ -1317,54 +1323,16 @@ impl PaymentParameters { ret } } -/// The node id of the payee. -#[no_mangle] -pub extern "C" fn PaymentParameters_get_payee_pubkey(this_ptr: &PaymentParameters) -> crate::c_types::PublicKey { - let mut inner_val = &mut this_ptr.get_native_mut_ref().payee_pubkey; - crate::c_types::PublicKey::from_rust(&inner_val) -} -/// The node id of the payee. -#[no_mangle] -pub extern "C" fn PaymentParameters_set_payee_pubkey(this_ptr: &mut PaymentParameters, mut val: crate::c_types::PublicKey) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payee_pubkey = val.into_rust(); -} -/// Features supported by the payee. -/// -/// May be set from the payee's invoice or via [`for_keysend`]. May be `None` if the invoice -/// does not contain any features. -/// -/// [`for_keysend`]: Self::for_keysend -/// -/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None -#[no_mangle] -pub extern "C" fn PaymentParameters_get_features(this_ptr: &PaymentParameters) -> crate::lightning::ln::features::InvoiceFeatures { - let mut inner_val = &mut this_ptr.get_native_mut_ref().features; - let mut local_inner_val = crate::lightning::ln::features::InvoiceFeatures { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::features::InvoiceFeatures<>) as *mut _ }, is_owned: false }; - local_inner_val -} -/// Features supported by the payee. -/// -/// May be set from the payee's invoice or via [`for_keysend`]. May be `None` if the invoice -/// does not contain any features. -/// -/// [`for_keysend`]: Self::for_keysend -/// -/// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None -#[no_mangle] -pub extern "C" fn PaymentParameters_set_features(this_ptr: &mut PaymentParameters, mut val: crate::lightning::ln::features::InvoiceFeatures) { - let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = local_val; -} -/// Hints for routing to the payee, containing channels connecting the payee to public nodes. +/// Information about the payee, such as their features and route hints for their channels. #[no_mangle] -pub extern "C" fn PaymentParameters_get_route_hints(this_ptr: &PaymentParameters) -> crate::lightning::routing::router::Hints { - let mut inner_val = &mut this_ptr.get_native_mut_ref().route_hints; - crate::lightning::routing::router::Hints::from_native(inner_val) +pub extern "C" fn PaymentParameters_get_payee(this_ptr: &PaymentParameters) -> crate::lightning::routing::router::Payee { + let mut inner_val = &mut this_ptr.get_native_mut_ref().payee; + crate::lightning::routing::router::Payee::from_native(inner_val) } -/// Hints for routing to the payee, containing channels connecting the payee to public nodes. +/// Information about the payee, such as their features and route hints for their channels. #[no_mangle] -pub extern "C" fn PaymentParameters_set_route_hints(this_ptr: &mut PaymentParameters, mut val: crate::lightning::routing::router::Hints) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.route_hints = val.into_native(); +pub extern "C" fn PaymentParameters_set_payee(this_ptr: &mut PaymentParameters, mut val: crate::lightning::routing::router::Payee) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payee = val.into_native(); } /// Expiration of a payment to the payee, in seconds relative to the UNIX epoch. #[no_mangle] @@ -1459,34 +1427,19 @@ pub extern "C" fn PaymentParameters_set_previously_failed_channels(this_ptr: &mu let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); }; unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.previously_failed_channels = local_val; } -/// The minimum CLTV delta at the end of the route. This value must not be zero. -#[no_mangle] -pub extern "C" fn PaymentParameters_get_final_cltv_expiry_delta(this_ptr: &PaymentParameters) -> u32 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().final_cltv_expiry_delta; - *inner_val -} -/// The minimum CLTV delta at the end of the route. This value must not be zero. -#[no_mangle] -pub extern "C" fn PaymentParameters_set_final_cltv_expiry_delta(this_ptr: &mut PaymentParameters, mut val: u32) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.final_cltv_expiry_delta = val; -} /// Constructs a new PaymentParameters given each field #[must_use] #[no_mangle] -pub extern "C" fn PaymentParameters_new(mut payee_pubkey_arg: crate::c_types::PublicKey, mut features_arg: crate::lightning::ln::features::InvoiceFeatures, mut route_hints_arg: crate::lightning::routing::router::Hints, mut expiry_time_arg: crate::c_types::derived::COption_u64Z, mut max_total_cltv_expiry_delta_arg: u32, mut max_path_count_arg: u8, mut max_channel_saturation_power_of_half_arg: u8, mut previously_failed_channels_arg: crate::c_types::derived::CVec_u64Z, mut final_cltv_expiry_delta_arg: u32) -> PaymentParameters { - let mut local_features_arg = if features_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(features_arg.take_inner()) } }) }; +pub extern "C" fn PaymentParameters_new(mut payee_arg: crate::lightning::routing::router::Payee, mut expiry_time_arg: crate::c_types::derived::COption_u64Z, mut max_total_cltv_expiry_delta_arg: u32, mut max_path_count_arg: u8, mut max_channel_saturation_power_of_half_arg: u8, mut previously_failed_channels_arg: crate::c_types::derived::CVec_u64Z) -> PaymentParameters { let mut local_expiry_time_arg = if expiry_time_arg.is_some() { Some( { expiry_time_arg.take() }) } else { None }; let mut local_previously_failed_channels_arg = Vec::new(); for mut item in previously_failed_channels_arg.into_rust().drain(..) { local_previously_failed_channels_arg.push( { item }); }; PaymentParameters { inner: ObjOps::heap_alloc(nativePaymentParameters { - payee_pubkey: payee_pubkey_arg.into_rust(), - features: local_features_arg, - route_hints: route_hints_arg.into_native(), + payee: payee_arg.into_native(), expiry_time: local_expiry_time_arg, max_total_cltv_expiry_delta: max_total_cltv_expiry_delta_arg, max_path_count: max_path_count_arg, max_channel_saturation_power_of_half: max_channel_saturation_power_of_half_arg, previously_failed_channels: local_previously_failed_channels_arg, - final_cltv_expiry_delta: final_cltv_expiry_delta_arg, }), is_owned: true } } impl Clone for PaymentParameters { @@ -1559,134 +1512,217 @@ pub extern "C" fn PaymentParameters_from_node_id(mut payee_pubkey: crate::c_type /// /// The `final_cltv_expiry_delta` should match the expected final CLTV delta the recipient has /// provided. +/// +/// Note that MPP keysend is not widely supported yet. The `allow_mpp` lets you choose +/// whether your router will be allowed to find a multi-part route for this payment. If you +/// set `allow_mpp` to true, you should ensure a payment secret is set on send, likely via +/// [`RecipientOnionFields::secret_only`]. +/// +/// [`RecipientOnionFields::secret_only`]: crate::ln::channelmanager::RecipientOnionFields::secret_only +#[must_use] +#[no_mangle] +pub extern "C" fn PaymentParameters_for_keysend(mut payee_pubkey: crate::c_types::PublicKey, mut final_cltv_expiry_delta: u32, mut allow_mpp: bool) -> crate::lightning::routing::router::PaymentParameters { + let mut ret = lightning::routing::router::PaymentParameters::for_keysend(payee_pubkey.into_rust(), final_cltv_expiry_delta, allow_mpp); + crate::lightning::routing::router::PaymentParameters { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Creates parameters for paying to a blinded payee from the provided invoice. Sets +/// [`Payee::Blinded::route_hints`], [`Payee::Blinded::features`], and +/// [`PaymentParameters::expiry_time`]. #[must_use] #[no_mangle] -pub extern "C" fn PaymentParameters_for_keysend(mut payee_pubkey: crate::c_types::PublicKey, mut final_cltv_expiry_delta: u32) -> crate::lightning::routing::router::PaymentParameters { - let mut ret = lightning::routing::router::PaymentParameters::for_keysend(payee_pubkey.into_rust(), final_cltv_expiry_delta); +pub extern "C" fn PaymentParameters_from_bolt12_invoice(invoice: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::lightning::routing::router::PaymentParameters { + let mut ret = lightning::routing::router::PaymentParameters::from_bolt12_invoice(invoice.get_native_ref()); crate::lightning::routing::router::PaymentParameters { inner: ObjOps::heap_alloc(ret), is_owned: true } } -/// Routing hints for the tail of the route. +/// The recipient of a payment, differing based on whether they've hidden their identity with route +/// blinding. #[derive(Clone)] #[must_use] #[repr(C)] -pub enum Hints { +pub enum Payee { /// The recipient provided blinded paths and payinfo to reach them. The blinded paths themselves /// will be included in the final [`Route`]. - Blinded( - crate::c_types::derived::CVec_C2Tuple_BlindedPayInfoBlindedPathZZ), + Blinded { + /// Aggregated routing info and blinded paths, for routing to the payee without knowing their + /// node id. + route_hints: crate::c_types::derived::CVec_C2Tuple_BlindedPayInfoBlindedPathZZ, + /// Features supported by the payee. + /// + /// May be set from the payee's invoice. May be `None` if the invoice does not contain any + /// features. + /// + /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + features: crate::lightning::ln::features::Bolt12InvoiceFeatures, + }, /// The recipient included these route hints in their BOLT11 invoice. - Clear( - crate::c_types::derived::CVec_RouteHintZ), -} -use lightning::routing::router::Hints as HintsImport; -pub(crate) type nativeHints = HintsImport; - -impl Hints { + Clear { + /// The node id of the payee. + node_id: crate::c_types::PublicKey, + /// Hints for routing to the payee, containing channels connecting the payee to public nodes. + route_hints: crate::c_types::derived::CVec_RouteHintZ, + /// Features supported by the payee. + /// + /// May be set from the payee's invoice or via [`for_keysend`]. May be `None` if the invoice + /// does not contain any features. + /// + /// [`for_keysend`]: PaymentParameters::for_keysend + /// + /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + features: crate::lightning::ln::features::Bolt11InvoiceFeatures, + /// The minimum CLTV delta at the end of the route. This value must not be zero. + final_cltv_expiry_delta: u32, + }, +} +use lightning::routing::router::Payee as PayeeImport; +pub(crate) type nativePayee = PayeeImport; + +impl Payee { #[allow(unused)] - pub(crate) fn to_native(&self) -> nativeHints { + pub(crate) fn to_native(&self) -> nativePayee { match self { - Hints::Blinded (ref a, ) => { - let mut a_nonref = Clone::clone(a); - let mut local_a_nonref = Vec::new(); for mut item in a_nonref.into_rust().drain(..) { local_a_nonref.push( { let (mut orig_a_nonref_0_0, mut orig_a_nonref_0_1) = item.to_rust(); let mut local_a_nonref_0 = (*unsafe { Box::from_raw(orig_a_nonref_0_0.take_inner()) }, *unsafe { Box::from_raw(orig_a_nonref_0_1.take_inner()) }); local_a_nonref_0 }); }; - nativeHints::Blinded ( - local_a_nonref, - ) + Payee::Blinded {ref route_hints, ref features, } => { + let mut route_hints_nonref = Clone::clone(route_hints); + let mut local_route_hints_nonref = Vec::new(); for mut item in route_hints_nonref.into_rust().drain(..) { local_route_hints_nonref.push( { let (mut orig_route_hints_nonref_0_0, mut orig_route_hints_nonref_0_1) = item.to_rust(); let mut local_route_hints_nonref_0 = (*unsafe { Box::from_raw(orig_route_hints_nonref_0_0.take_inner()) }, *unsafe { Box::from_raw(orig_route_hints_nonref_0_1.take_inner()) }); local_route_hints_nonref_0 }); }; + let mut features_nonref = Clone::clone(features); + let mut local_features_nonref = if features_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(features_nonref.take_inner()) } }) }; + nativePayee::Blinded { + route_hints: local_route_hints_nonref, + features: local_features_nonref, + } }, - Hints::Clear (ref a, ) => { - let mut a_nonref = Clone::clone(a); - let mut local_a_nonref = Vec::new(); for mut item in a_nonref.into_rust().drain(..) { local_a_nonref.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; - nativeHints::Clear ( - local_a_nonref, - ) + Payee::Clear {ref node_id, ref route_hints, ref features, ref final_cltv_expiry_delta, } => { + let mut node_id_nonref = Clone::clone(node_id); + let mut route_hints_nonref = Clone::clone(route_hints); + let mut local_route_hints_nonref = Vec::new(); for mut item in route_hints_nonref.into_rust().drain(..) { local_route_hints_nonref.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; + let mut features_nonref = Clone::clone(features); + let mut local_features_nonref = if features_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(features_nonref.take_inner()) } }) }; + let mut final_cltv_expiry_delta_nonref = Clone::clone(final_cltv_expiry_delta); + nativePayee::Clear { + node_id: node_id_nonref.into_rust(), + route_hints: local_route_hints_nonref, + features: local_features_nonref, + final_cltv_expiry_delta: final_cltv_expiry_delta_nonref, + } }, } } #[allow(unused)] - pub(crate) fn into_native(self) -> nativeHints { + pub(crate) fn into_native(self) -> nativePayee { match self { - Hints::Blinded (mut a, ) => { - let mut local_a = Vec::new(); for mut item in a.into_rust().drain(..) { local_a.push( { let (mut orig_a_0_0, mut orig_a_0_1) = item.to_rust(); let mut local_a_0 = (*unsafe { Box::from_raw(orig_a_0_0.take_inner()) }, *unsafe { Box::from_raw(orig_a_0_1.take_inner()) }); local_a_0 }); }; - nativeHints::Blinded ( - local_a, - ) + Payee::Blinded {mut route_hints, mut features, } => { + let mut local_route_hints = Vec::new(); for mut item in route_hints.into_rust().drain(..) { local_route_hints.push( { let (mut orig_route_hints_0_0, mut orig_route_hints_0_1) = item.to_rust(); let mut local_route_hints_0 = (*unsafe { Box::from_raw(orig_route_hints_0_0.take_inner()) }, *unsafe { Box::from_raw(orig_route_hints_0_1.take_inner()) }); local_route_hints_0 }); }; + let mut local_features = if features.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(features.take_inner()) } }) }; + nativePayee::Blinded { + route_hints: local_route_hints, + features: local_features, + } }, - Hints::Clear (mut a, ) => { - let mut local_a = Vec::new(); for mut item in a.into_rust().drain(..) { local_a.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; - nativeHints::Clear ( - local_a, - ) + Payee::Clear {mut node_id, mut route_hints, mut features, mut final_cltv_expiry_delta, } => { + let mut local_route_hints = Vec::new(); for mut item in route_hints.into_rust().drain(..) { local_route_hints.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; + let mut local_features = if features.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(features.take_inner()) } }) }; + nativePayee::Clear { + node_id: node_id.into_rust(), + route_hints: local_route_hints, + features: local_features, + final_cltv_expiry_delta: final_cltv_expiry_delta, + } }, } } #[allow(unused)] - pub(crate) fn from_native(native: &nativeHints) -> Self { + pub(crate) fn from_native(native: &nativePayee) -> Self { match native { - nativeHints::Blinded (ref a, ) => { - let mut a_nonref = Clone::clone(a); - let mut local_a_nonref = Vec::new(); for mut item in a_nonref.drain(..) { local_a_nonref.push( { let (mut orig_a_nonref_0_0, mut orig_a_nonref_0_1) = item; let mut local_a_nonref_0 = (crate::lightning::offers::invoice::BlindedPayInfo { inner: ObjOps::heap_alloc(orig_a_nonref_0_0), is_owned: true }, crate::lightning::blinded_path::BlindedPath { inner: ObjOps::heap_alloc(orig_a_nonref_0_1), is_owned: true }).into(); local_a_nonref_0 }); }; - Hints::Blinded ( - local_a_nonref.into(), - ) + nativePayee::Blinded {ref route_hints, ref features, } => { + let mut route_hints_nonref = Clone::clone(route_hints); + let mut local_route_hints_nonref = Vec::new(); for mut item in route_hints_nonref.drain(..) { local_route_hints_nonref.push( { let (mut orig_route_hints_nonref_0_0, mut orig_route_hints_nonref_0_1) = item; let mut local_route_hints_nonref_0 = (crate::lightning::offers::invoice::BlindedPayInfo { inner: ObjOps::heap_alloc(orig_route_hints_nonref_0_0), is_owned: true }, crate::lightning::blinded_path::BlindedPath { inner: ObjOps::heap_alloc(orig_route_hints_nonref_0_1), is_owned: true }).into(); local_route_hints_nonref_0 }); }; + let mut features_nonref = Clone::clone(features); + let mut local_features_nonref = crate::lightning::ln::features::Bolt12InvoiceFeatures { inner: if features_nonref.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((features_nonref.unwrap())) } }, is_owned: true }; + Payee::Blinded { + route_hints: local_route_hints_nonref.into(), + features: local_features_nonref, + } }, - nativeHints::Clear (ref a, ) => { - let mut a_nonref = Clone::clone(a); - let mut local_a_nonref = Vec::new(); for mut item in a_nonref.drain(..) { local_a_nonref.push( { crate::lightning::routing::router::RouteHint { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; - Hints::Clear ( - local_a_nonref.into(), - ) + nativePayee::Clear {ref node_id, ref route_hints, ref features, ref final_cltv_expiry_delta, } => { + let mut node_id_nonref = Clone::clone(node_id); + let mut route_hints_nonref = Clone::clone(route_hints); + let mut local_route_hints_nonref = Vec::new(); for mut item in route_hints_nonref.drain(..) { local_route_hints_nonref.push( { crate::lightning::routing::router::RouteHint { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; + let mut features_nonref = Clone::clone(features); + let mut local_features_nonref = crate::lightning::ln::features::Bolt11InvoiceFeatures { inner: if features_nonref.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((features_nonref.unwrap())) } }, is_owned: true }; + let mut final_cltv_expiry_delta_nonref = Clone::clone(final_cltv_expiry_delta); + Payee::Clear { + node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), + route_hints: local_route_hints_nonref.into(), + features: local_features_nonref, + final_cltv_expiry_delta: final_cltv_expiry_delta_nonref, + } }, } } #[allow(unused)] - pub(crate) fn native_into(native: nativeHints) -> Self { + pub(crate) fn native_into(native: nativePayee) -> Self { match native { - nativeHints::Blinded (mut a, ) => { - let mut local_a = Vec::new(); for mut item in a.drain(..) { local_a.push( { let (mut orig_a_0_0, mut orig_a_0_1) = item; let mut local_a_0 = (crate::lightning::offers::invoice::BlindedPayInfo { inner: ObjOps::heap_alloc(orig_a_0_0), is_owned: true }, crate::lightning::blinded_path::BlindedPath { inner: ObjOps::heap_alloc(orig_a_0_1), is_owned: true }).into(); local_a_0 }); }; - Hints::Blinded ( - local_a.into(), - ) + nativePayee::Blinded {mut route_hints, mut features, } => { + let mut local_route_hints = Vec::new(); for mut item in route_hints.drain(..) { local_route_hints.push( { let (mut orig_route_hints_0_0, mut orig_route_hints_0_1) = item; let mut local_route_hints_0 = (crate::lightning::offers::invoice::BlindedPayInfo { inner: ObjOps::heap_alloc(orig_route_hints_0_0), is_owned: true }, crate::lightning::blinded_path::BlindedPath { inner: ObjOps::heap_alloc(orig_route_hints_0_1), is_owned: true }).into(); local_route_hints_0 }); }; + let mut local_features = crate::lightning::ln::features::Bolt12InvoiceFeatures { inner: if features.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((features.unwrap())) } }, is_owned: true }; + Payee::Blinded { + route_hints: local_route_hints.into(), + features: local_features, + } }, - nativeHints::Clear (mut a, ) => { - let mut local_a = Vec::new(); for mut item in a.drain(..) { local_a.push( { crate::lightning::routing::router::RouteHint { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; - Hints::Clear ( - local_a.into(), - ) + nativePayee::Clear {mut node_id, mut route_hints, mut features, mut final_cltv_expiry_delta, } => { + let mut local_route_hints = Vec::new(); for mut item in route_hints.drain(..) { local_route_hints.push( { crate::lightning::routing::router::RouteHint { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; + let mut local_features = crate::lightning::ln::features::Bolt11InvoiceFeatures { inner: if features.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((features.unwrap())) } }, is_owned: true }; + Payee::Clear { + node_id: crate::c_types::PublicKey::from_rust(&node_id), + route_hints: local_route_hints.into(), + features: local_features, + final_cltv_expiry_delta: final_cltv_expiry_delta, + } }, } } } -/// Frees any resources used by the Hints +/// Frees any resources used by the Payee #[no_mangle] -pub extern "C" fn Hints_free(this_ptr: Hints) { } -/// Creates a copy of the Hints +pub extern "C" fn Payee_free(this_ptr: Payee) { } +/// Creates a copy of the Payee #[no_mangle] -pub extern "C" fn Hints_clone(orig: &Hints) -> Hints { +pub extern "C" fn Payee_clone(orig: &Payee) -> Payee { orig.clone() } #[no_mangle] -/// Utility method to constructs a new Blinded-variant Hints -pub extern "C" fn Hints_blinded(a: crate::c_types::derived::CVec_C2Tuple_BlindedPayInfoBlindedPathZZ) -> Hints { - Hints::Blinded(a, ) +/// Utility method to constructs a new Blinded-variant Payee +pub extern "C" fn Payee_blinded(route_hints: crate::c_types::derived::CVec_C2Tuple_BlindedPayInfoBlindedPathZZ, features: crate::lightning::ln::features::Bolt12InvoiceFeatures) -> Payee { + Payee::Blinded { + route_hints, + features, + } } #[no_mangle] -/// Utility method to constructs a new Clear-variant Hints -pub extern "C" fn Hints_clear(a: crate::c_types::derived::CVec_RouteHintZ) -> Hints { - Hints::Clear(a, ) +/// Utility method to constructs a new Clear-variant Payee +pub extern "C" fn Payee_clear(node_id: crate::c_types::PublicKey, route_hints: crate::c_types::derived::CVec_RouteHintZ, features: crate::lightning::ln::features::Bolt11InvoiceFeatures, final_cltv_expiry_delta: u32) -> Payee { + Payee::Clear { + node_id, + route_hints, + features, + final_cltv_expiry_delta, + } } -/// Generates a non-cryptographic 64-bit hash of the Hints. +/// Generates a non-cryptographic 64-bit hash of the Payee. #[no_mangle] -pub extern "C" fn Hints_hash(o: &Hints) -> u64 { +pub extern "C" fn Payee_hash(o: &Payee) -> u64 { // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core #[allow(deprecated)] let mut hasher = core::hash::SipHasher::new(); core::hash::Hash::hash(&o.to_native(), &mut hasher); core::hash::Hasher::finish(&hasher) } -/// Checks if two Hintss contain equal inner contents. +/// Checks if two Payees contain equal inner contents. /// This ignores pointers and is_owned flags and looks at the values in fields. #[no_mangle] -pub extern "C" fn Hints_eq(a: &Hints, b: &Hints) -> bool { +pub extern "C" fn Payee_eq(a: &Payee, b: &Payee) -> bool { if &a.to_native() == &b.to_native() { true } else { false } } @@ -2006,10 +2042,12 @@ pub extern "C" fn RouteHintHop_read(ser: crate::c_types::u8slice) -> crate::c_ty } /// Finds a route from us (payer) to the given target node (payee). /// -/// If the payee provided features in their invoice, they should be provided via `params.payee`. +/// If the payee provided features in their invoice, they should be provided via the `payee` field +/// in the given [`RouteParameters::payment_params`]. /// Without this, MPP will only be used if the payee's features are available in the network graph. /// -/// Private routing paths between a public node and the target may be included in `params.payee`. +/// Private routing paths between a public node and the target may be included in the `payee` field +/// of [`RouteParameters::payment_params`]. /// /// If some channels aren't announced, it may be useful to fill in `first_hops` with the results /// from [`ChannelManager::list_usable_channels`]. If it is filled in, the view of these channels @@ -2019,15 +2057,9 @@ pub extern "C" fn RouteHintHop_read(ser: crate::c_types::u8slice) -> crate::c_ty /// However, the enabled/disabled bit on such channels as well as the `htlc_minimum_msat` / /// `htlc_maximum_msat` *are* checked as they may change based on the receiving node. /// -/// # Note -/// -/// May be used to re-compute a [`Route`] when handling a [`Event::PaymentPathFailed`]. Any -/// adjustments to the [`NetworkGraph`] and channel scores should be made prior to calling this -/// function. -/// /// # Panics /// -/// Panics if first_hops contains channels without short_channel_ids; +/// Panics if first_hops contains channels without `short_channel_id`s; /// [`ChannelManager::list_usable_channels`] will never include such channels. /// /// [`ChannelManager::list_usable_channels`]: crate::ln::channelmanager::ChannelManager::list_usable_channels @@ -2036,9 +2068,9 @@ pub extern "C" fn RouteHintHop_read(ser: crate::c_types::u8slice) -> crate::c_ty /// /// Note that first_hops (or a relevant inner pointer) may be NULL or all-0s to represent None #[no_mangle] -pub extern "C" fn find_route(mut our_node_pubkey: crate::c_types::PublicKey, route_params: &crate::lightning::routing::router::RouteParameters, network_graph: &crate::lightning::routing::gossip::NetworkGraph, first_hops: *mut crate::c_types::derived::CVec_ChannelDetailsZ, mut logger: crate::lightning::util::logger::Logger, scorer: &crate::lightning::routing::scoring::Score, random_seed_bytes: *const [u8; 32]) -> crate::c_types::derived::CResult_RouteLightningErrorZ { +pub extern "C" fn find_route(mut our_node_pubkey: crate::c_types::PublicKey, route_params: &crate::lightning::routing::router::RouteParameters, network_graph: &crate::lightning::routing::gossip::NetworkGraph, first_hops: *mut crate::c_types::derived::CVec_ChannelDetailsZ, mut logger: crate::lightning::util::logger::Logger, scorer: &crate::lightning::routing::scoring::Score, score_params: &crate::lightning::routing::scoring::ProbabilisticScoringFeeParameters, random_seed_bytes: *const [u8; 32]) -> crate::c_types::derived::CResult_RouteLightningErrorZ { let mut local_first_hops_base = if first_hops == core::ptr::null_mut() { None } else { Some( { let mut local_first_hops_0 = Vec::new(); for mut item in unsafe { &mut *first_hops }.as_slice().iter() { local_first_hops_0.push( { item.get_native_ref() }); }; local_first_hops_0 }) }; let mut local_first_hops = local_first_hops_base.as_ref().map(|a| &a[..]); - let mut ret = lightning::routing::router::find_route::(&our_node_pubkey.into_rust(), route_params.get_native_ref(), network_graph.get_native_ref(), local_first_hops, logger, scorer, unsafe { &*random_seed_bytes}); + let mut ret = lightning::routing::router::find_route::(&our_node_pubkey.into_rust(), route_params.get_native_ref(), network_graph.get_native_ref(), local_first_hops, logger, scorer, score_params.get_native_ref(), unsafe { &*random_seed_bytes}); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::router::Route { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; local_ret } diff --git a/lightning-c-bindings/src/lightning/routing/scoring.rs b/lightning-c-bindings/src/lightning/routing/scoring.rs index 820a7b16..f76cf9d1 100644 --- a/lightning-c-bindings/src/lightning/routing/scoring.rs +++ b/lightning-c-bindings/src/lightning/routing/scoring.rs @@ -18,8 +18,8 @@ //! # //! # use lightning::routing::gossip::NetworkGraph; //! # use lightning::routing::router::{RouteParameters, find_route}; -//! # use lightning::routing::scoring::{ProbabilisticScorer, ProbabilisticScoringParameters}; -//! # use lightning::chain::keysinterface::KeysManager; +//! # use lightning::routing::scoring::{ProbabilisticScorer, ProbabilisticScoringFeeParameters, ProbabilisticScoringDecayParameters}; +//! # use lightning::sign::KeysManager; //! # use lightning::util::logger::{Logger, Record}; //! # use bitcoin::secp256k1::PublicKey; //! # @@ -31,18 +31,20 @@ //! # let logger = FakeLogger {}; //! # //! // Use the default channel penalties. -//! let params = ProbabilisticScoringParameters::default(); -//! let scorer = ProbabilisticScorer::new(params, &network_graph, &logger); +//! let params = ProbabilisticScoringFeeParameters::default(); +//! let decay_params = ProbabilisticScoringDecayParameters::default(); +//! let scorer = ProbabilisticScorer::new(decay_params, &network_graph, &logger); //! //! // Or use custom channel penalties. -//! let params = ProbabilisticScoringParameters { -//! liquidity_penalty_multiplier_msat: 2 * 1000, -//! ..ProbabilisticScoringParameters::default() +//! let params = ProbabilisticScoringFeeParameters { +//! \tliquidity_penalty_multiplier_msat: 2 * 1000, +//! \t..ProbabilisticScoringFeeParameters::default() //! }; -//! let scorer = ProbabilisticScorer::new(params, &network_graph, &logger); +//! let decay_params = ProbabilisticScoringDecayParameters::default(); +//! let scorer = ProbabilisticScorer::new(decay_params, &network_graph, &logger); //! # let random_seed_bytes = [42u8; 32]; //! -//! let route = find_route(&payer, &route_params, &network_graph, None, &logger, &scorer, &random_seed_bytes); +//! let route = find_route(&payer, &route_params, &network_graph, None, &logger, &scorer, ¶ms, &random_seed_bytes); //! # } //! ``` //! @@ -77,8 +79,7 @@ pub struct Score { /// such as a chain data, network gossip, or invoice hints. For invoice hints, a capacity near /// [`u64::max_value`] is given to indicate sufficient capacity for the invoice's full amount. /// Thus, implementations should be overflow-safe. - #[must_use] - pub channel_penalty_msat: extern "C" fn (this_arg: *const c_void, short_channel_id: u64, source: &crate::lightning::routing::gossip::NodeId, target: &crate::lightning::routing::gossip::NodeId, usage: crate::lightning::routing::scoring::ChannelUsage) -> u64, + pub channel_penalty_msat: extern "C" fn (this_arg: *const c_void, short_channel_id: u64, source: &crate::lightning::routing::gossip::NodeId, target: &crate::lightning::routing::gossip::NodeId, usage: crate::lightning::routing::scoring::ChannelUsage, score_params: &crate::lightning::routing::scoring::ProbabilisticScoringFeeParameters) -> u64, /// Handles updating channel penalties after failing to route through a channel. pub payment_path_failed: extern "C" fn (this_arg: *mut c_void, path: &crate::lightning::routing::router::Path, short_channel_id: u64), /// Handles updating channel penalties after successfully routing along a path. @@ -117,8 +118,8 @@ impl lightning::util::ser::Writeable for Score { use lightning::routing::scoring::Score as rustScore; impl rustScore for Score { - fn channel_penalty_msat(&self, mut short_channel_id: u64, mut source: &lightning::routing::gossip::NodeId, mut target: &lightning::routing::gossip::NodeId, mut usage: lightning::routing::scoring::ChannelUsage) -> u64 { - let mut ret = (self.channel_penalty_msat)(self.this_arg, short_channel_id, &crate::lightning::routing::gossip::NodeId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((source as *const lightning::routing::gossip::NodeId<>) as *mut _) }, is_owned: false }, &crate::lightning::routing::gossip::NodeId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((target as *const lightning::routing::gossip::NodeId<>) as *mut _) }, is_owned: false }, crate::lightning::routing::scoring::ChannelUsage { inner: ObjOps::heap_alloc(usage), is_owned: true }); + fn channel_penalty_msat(&self, mut short_channel_id: u64, mut source: &lightning::routing::gossip::NodeId, mut target: &lightning::routing::gossip::NodeId, mut usage: lightning::routing::scoring::ChannelUsage, mut score_params: &lightning::routing::scoring::ProbabilisticScoringFeeParameters) -> u64 { + let mut ret = (self.channel_penalty_msat)(self.this_arg, short_channel_id, &crate::lightning::routing::gossip::NodeId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((source as *const lightning::routing::gossip::NodeId<>) as *mut _) }, is_owned: false }, &crate::lightning::routing::gossip::NodeId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((target as *const lightning::routing::gossip::NodeId<>) as *mut _) }, is_owned: false }, crate::lightning::routing::scoring::ChannelUsage { inner: ObjOps::heap_alloc(usage), is_owned: true }, &crate::lightning::routing::scoring::ProbabilisticScoringFeeParameters { inner: unsafe { ObjOps::nonnull_ptr_to_inner((score_params as *const lightning::routing::scoring::ProbabilisticScoringFeeParameters<>) as *mut _) }, is_owned: false }); ret } fn payment_path_failed(&mut self, mut path: &lightning::routing::router::Path, mut short_channel_id: u64) { @@ -167,7 +168,6 @@ pub struct LockableScore { /// This has no meaning in the LDK, and can be NULL or any other value. pub this_arg: *mut c_void, /// Returns the locked scorer. - #[must_use] pub lock: extern "C" fn (this_arg: *const c_void) -> crate::lightning::routing::scoring::Score, /// Frees any resources associated with this object given its this_arg pointer. /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. @@ -326,6 +326,77 @@ impl MultiThreadedLockableScore { ret } } +impl From for crate::lightning::routing::scoring::LockableScore { + fn from(obj: nativeMultiThreadedLockableScore) -> Self { + let mut rust_obj = MultiThreadedLockableScore { inner: ObjOps::heap_alloc(obj), is_owned: true }; + let mut ret = MultiThreadedLockableScore_as_LockableScore(&rust_obj); + // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn + rust_obj.inner = core::ptr::null_mut(); + ret.free = Some(MultiThreadedLockableScore_free_void); + ret + } +} +/// Constructs a new LockableScore which calls the relevant methods on this_arg. +/// This copies the `inner` pointer in this_arg and thus the returned LockableScore must be freed before this_arg is +#[no_mangle] +pub extern "C" fn MultiThreadedLockableScore_as_LockableScore(this_arg: &MultiThreadedLockableScore) -> crate::lightning::routing::scoring::LockableScore { + crate::lightning::routing::scoring::LockableScore { + this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, + free: None, + lock: MultiThreadedLockableScore_LockableScore_lock, + } +} + +#[must_use] +extern "C" fn MultiThreadedLockableScore_LockableScore_lock(this_arg: *const c_void) -> crate::lightning::routing::scoring::Score { + let mut ret = >::lock(unsafe { &mut *(this_arg as *mut nativeMultiThreadedLockableScore) }, ); + Into::into(ret) +} + +#[no_mangle] +/// Serialize the MultiThreadedLockableScore object into a byte array which can be read by MultiThreadedLockableScore_read +pub extern "C" fn MultiThreadedLockableScore_write(obj: &crate::lightning::routing::scoring::MultiThreadedLockableScore) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[no_mangle] +pub(crate) extern "C" fn MultiThreadedLockableScore_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeMultiThreadedLockableScore) }) +} +impl From for crate::lightning::routing::scoring::WriteableScore { + fn from(obj: nativeMultiThreadedLockableScore) -> Self { + let mut rust_obj = MultiThreadedLockableScore { inner: ObjOps::heap_alloc(obj), is_owned: true }; + let mut ret = MultiThreadedLockableScore_as_WriteableScore(&rust_obj); + // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn + rust_obj.inner = core::ptr::null_mut(); + ret.free = Some(MultiThreadedLockableScore_free_void); + ret + } +} +/// Constructs a new WriteableScore which calls the relevant methods on this_arg. +/// This copies the `inner` pointer in this_arg and thus the returned WriteableScore must be freed before this_arg is +#[no_mangle] +pub extern "C" fn MultiThreadedLockableScore_as_WriteableScore(this_arg: &MultiThreadedLockableScore) -> crate::lightning::routing::scoring::WriteableScore { + crate::lightning::routing::scoring::WriteableScore { + this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, + free: None, + LockableScore: crate::lightning::routing::scoring::LockableScore { + this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, + free: None, + lock: MultiThreadedLockableScore_LockableScore_lock, + }, + write: MultiThreadedLockableScore_write_void, + } +} + + +/// Creates a new [`MultiThreadedLockableScore`] given an underlying [`Score`]. +#[must_use] +#[no_mangle] +pub extern "C" fn MultiThreadedLockableScore_new(mut score: crate::lightning::routing::scoring::Score) -> crate::lightning::routing::scoring::MultiThreadedLockableScore { + let mut ret = lightning::routing::scoring::MultiThreadedLockableScore::new(score); + crate::lightning::routing::scoring::MultiThreadedLockableScore { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + use lightning::routing::scoring::MultiThreadedScoreLock as nativeMultiThreadedScoreLockImport; pub(crate) type nativeMultiThreadedScoreLock = nativeMultiThreadedScoreLockImport<'static, crate::lightning::routing::scoring::Score>; @@ -377,6 +448,15 @@ impl MultiThreadedScoreLock { ret } } +#[no_mangle] +/// Serialize the MultiThreadedScoreLock object into a byte array which can be read by MultiThreadedScoreLock_read +pub extern "C" fn MultiThreadedScoreLock_write(obj: &crate::lightning::routing::scoring::MultiThreadedScoreLock) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[no_mangle] +pub(crate) extern "C" fn MultiThreadedScoreLock_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeMultiThreadedScoreLock) }) +} impl From for crate::lightning::routing::scoring::Score { fn from(obj: nativeMultiThreadedScoreLock) -> Self { let mut rust_obj = MultiThreadedScoreLock { inner: ObjOps::heap_alloc(obj), is_owned: true }; @@ -404,8 +484,8 @@ pub extern "C" fn MultiThreadedScoreLock_as_Score(this_arg: &MultiThreadedScoreL } #[must_use] -extern "C" fn MultiThreadedScoreLock_Score_channel_penalty_msat(this_arg: *const c_void, mut short_channel_id: u64, source: &crate::lightning::routing::gossip::NodeId, target: &crate::lightning::routing::gossip::NodeId, mut usage: crate::lightning::routing::scoring::ChannelUsage) -> u64 { - let mut ret = >::channel_penalty_msat(unsafe { &mut *(this_arg as *mut nativeMultiThreadedScoreLock) }, short_channel_id, source.get_native_ref(), target.get_native_ref(), *unsafe { Box::from_raw(usage.take_inner()) }); +extern "C" fn MultiThreadedScoreLock_Score_channel_penalty_msat(this_arg: *const c_void, mut short_channel_id: u64, source: &crate::lightning::routing::gossip::NodeId, target: &crate::lightning::routing::gossip::NodeId, mut usage: crate::lightning::routing::scoring::ChannelUsage, score_params: &crate::lightning::routing::scoring::ProbabilisticScoringFeeParameters) -> u64 { + let mut ret = >::channel_penalty_msat(unsafe { &mut *(this_arg as *mut nativeMultiThreadedScoreLock) }, short_channel_id, source.get_native_ref(), target.get_native_ref(), *unsafe { Box::from_raw(usage.take_inner()) }, score_params.get_native_ref()); ret } extern "C" fn MultiThreadedScoreLock_Score_payment_path_failed(this_arg: *mut c_void, path: &crate::lightning::routing::router::Path, mut short_channel_id: u64) { @@ -421,86 +501,6 @@ extern "C" fn MultiThreadedScoreLock_Score_probe_successful(this_arg: *mut c_voi >::probe_successful(unsafe { &mut *(this_arg as *mut nativeMultiThreadedScoreLock) }, path.get_native_ref()) } -#[no_mangle] -/// Serialize the MultiThreadedScoreLock object into a byte array which can be read by MultiThreadedScoreLock_read -pub extern "C" fn MultiThreadedScoreLock_write(obj: &crate::lightning::routing::scoring::MultiThreadedScoreLock) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) -} -#[no_mangle] -pub(crate) extern "C" fn MultiThreadedScoreLock_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeMultiThreadedScoreLock) }) -} -impl From for crate::lightning::routing::scoring::LockableScore { - fn from(obj: nativeMultiThreadedLockableScore) -> Self { - let mut rust_obj = MultiThreadedLockableScore { inner: ObjOps::heap_alloc(obj), is_owned: true }; - let mut ret = MultiThreadedLockableScore_as_LockableScore(&rust_obj); - // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn - rust_obj.inner = core::ptr::null_mut(); - ret.free = Some(MultiThreadedLockableScore_free_void); - ret - } -} -/// Constructs a new LockableScore which calls the relevant methods on this_arg. -/// This copies the `inner` pointer in this_arg and thus the returned LockableScore must be freed before this_arg is -#[no_mangle] -pub extern "C" fn MultiThreadedLockableScore_as_LockableScore(this_arg: &MultiThreadedLockableScore) -> crate::lightning::routing::scoring::LockableScore { - crate::lightning::routing::scoring::LockableScore { - this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, - free: None, - lock: MultiThreadedLockableScore_LockableScore_lock, - } -} - -#[must_use] -extern "C" fn MultiThreadedLockableScore_LockableScore_lock(this_arg: *const c_void) -> crate::lightning::routing::scoring::Score { - let mut ret = >::lock(unsafe { &mut *(this_arg as *mut nativeMultiThreadedLockableScore) }, ); - Into::into(ret) -} - -#[no_mangle] -/// Serialize the MultiThreadedLockableScore object into a byte array which can be read by MultiThreadedLockableScore_read -pub extern "C" fn MultiThreadedLockableScore_write(obj: &crate::lightning::routing::scoring::MultiThreadedLockableScore) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) -} -#[no_mangle] -pub(crate) extern "C" fn MultiThreadedLockableScore_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeMultiThreadedLockableScore) }) -} -impl From for crate::lightning::routing::scoring::WriteableScore { - fn from(obj: nativeMultiThreadedLockableScore) -> Self { - let mut rust_obj = MultiThreadedLockableScore { inner: ObjOps::heap_alloc(obj), is_owned: true }; - let mut ret = MultiThreadedLockableScore_as_WriteableScore(&rust_obj); - // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn - rust_obj.inner = core::ptr::null_mut(); - ret.free = Some(MultiThreadedLockableScore_free_void); - ret - } -} -/// Constructs a new WriteableScore which calls the relevant methods on this_arg. -/// This copies the `inner` pointer in this_arg and thus the returned WriteableScore must be freed before this_arg is -#[no_mangle] -pub extern "C" fn MultiThreadedLockableScore_as_WriteableScore(this_arg: &MultiThreadedLockableScore) -> crate::lightning::routing::scoring::WriteableScore { - crate::lightning::routing::scoring::WriteableScore { - this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, - free: None, - LockableScore: crate::lightning::routing::scoring::LockableScore { - this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, - free: None, - lock: MultiThreadedLockableScore_LockableScore_lock, - }, - write: MultiThreadedLockableScore_write_void, - } -} - - -/// Creates a new [`MultiThreadedLockableScore`] given an underlying [`Score`]. -#[must_use] -#[no_mangle] -pub extern "C" fn MultiThreadedLockableScore_new(mut score: crate::lightning::routing::scoring::Score) -> crate::lightning::routing::scoring::MultiThreadedLockableScore { - let mut ret = lightning::routing::scoring::MultiThreadedLockableScore::new(score); - crate::lightning::routing::scoring::MultiThreadedLockableScore { inner: ObjOps::heap_alloc(ret), is_owned: true } -} - use lightning::routing::scoring::ChannelUsage as nativeChannelUsageImport; pub(crate) type nativeChannelUsage = nativeChannelUsageImport; @@ -721,8 +721,8 @@ pub extern "C" fn FixedPenaltyScorer_as_Score(this_arg: &FixedPenaltyScorer) -> } #[must_use] -extern "C" fn FixedPenaltyScorer_Score_channel_penalty_msat(this_arg: *const c_void, mut short_channel_id: u64, source: &crate::lightning::routing::gossip::NodeId, target: &crate::lightning::routing::gossip::NodeId, mut usage: crate::lightning::routing::scoring::ChannelUsage) -> u64 { - let mut ret = >::channel_penalty_msat(unsafe { &mut *(this_arg as *mut nativeFixedPenaltyScorer) }, short_channel_id, source.get_native_ref(), target.get_native_ref(), *unsafe { Box::from_raw(usage.take_inner()) }); +extern "C" fn FixedPenaltyScorer_Score_channel_penalty_msat(this_arg: *const c_void, mut short_channel_id: u64, source: &crate::lightning::routing::gossip::NodeId, target: &crate::lightning::routing::gossip::NodeId, mut usage: crate::lightning::routing::scoring::ChannelUsage, score_params: &crate::lightning::routing::scoring::ProbabilisticScoringFeeParameters) -> u64 { + let mut ret = >::channel_penalty_msat(unsafe { &mut *(this_arg as *mut nativeFixedPenaltyScorer) }, short_channel_id, source.get_native_ref(), target.get_native_ref(), *unsafe { Box::from_raw(usage.take_inner()) }, score_params.get_native_ref()); ret } extern "C" fn FixedPenaltyScorer_Score_payment_path_failed(this_arg: *mut c_void, path: &crate::lightning::routing::router::Path, mut short_channel_id: u64) { @@ -790,11 +790,11 @@ pub(crate) type nativeProbabilisticScorer = nativeProbabilisticScorerImport<&'st /// behavior. /// /// [1]: https://arxiv.org/abs/2107.05322 -/// [`liquidity_penalty_multiplier_msat`]: ProbabilisticScoringParameters::liquidity_penalty_multiplier_msat -/// [`liquidity_penalty_amount_multiplier_msat`]: ProbabilisticScoringParameters::liquidity_penalty_amount_multiplier_msat -/// [`liquidity_offset_half_life`]: ProbabilisticScoringParameters::liquidity_offset_half_life -/// [`historical_liquidity_penalty_multiplier_msat`]: ProbabilisticScoringParameters::historical_liquidity_penalty_multiplier_msat -/// [`historical_liquidity_penalty_amount_multiplier_msat`]: ProbabilisticScoringParameters::historical_liquidity_penalty_amount_multiplier_msat +/// [`liquidity_penalty_multiplier_msat`]: ProbabilisticScoringFeeParameters::liquidity_penalty_multiplier_msat +/// [`liquidity_penalty_amount_multiplier_msat`]: ProbabilisticScoringFeeParameters::liquidity_penalty_amount_multiplier_msat +/// [`liquidity_offset_half_life`]: ProbabilisticScoringDecayParameters::liquidity_offset_half_life +/// [`historical_liquidity_penalty_multiplier_msat`]: ProbabilisticScoringFeeParameters::historical_liquidity_penalty_multiplier_msat +/// [`historical_liquidity_penalty_amount_multiplier_msat`]: ProbabilisticScoringFeeParameters::historical_liquidity_penalty_amount_multiplier_msat #[must_use] #[repr(C)] pub struct ProbabilisticScorer { @@ -842,8 +842,8 @@ impl ProbabilisticScorer { } } -use lightning::routing::scoring::ProbabilisticScoringParameters as nativeProbabilisticScoringParametersImport; -pub(crate) type nativeProbabilisticScoringParameters = nativeProbabilisticScoringParametersImport; +use lightning::routing::scoring::ProbabilisticScoringFeeParameters as nativeProbabilisticScoringFeeParametersImport; +pub(crate) type nativeProbabilisticScoringFeeParameters = nativeProbabilisticScoringFeeParametersImport; /// Parameters for configuring [`ProbabilisticScorer`]. /// @@ -854,12 +854,12 @@ pub(crate) type nativeProbabilisticScoringParameters = nativeProbabilisticScorin /// parameters here. #[must_use] #[repr(C)] -pub struct ProbabilisticScoringParameters { +pub struct ProbabilisticScoringFeeParameters { /// A pointer to the opaque Rust object. /// Nearly everywhere, inner must be non-null, however in places where /// the Rust equivalent takes an Option, it may be set to null to indicate None. - pub inner: *mut nativeProbabilisticScoringParameters, + pub inner: *mut nativeProbabilisticScoringFeeParameters, /// Indicates that this is the only struct which contains the same pointer. /// Rust functions which take ownership of an object provided via an argument require @@ -867,31 +867,31 @@ pub struct ProbabilisticScoringParameters { pub is_owned: bool, } -impl Drop for ProbabilisticScoringParameters { +impl Drop for ProbabilisticScoringFeeParameters { fn drop(&mut self) { - if self.is_owned && !<*mut nativeProbabilisticScoringParameters>::is_null(self.inner) { + if self.is_owned && !<*mut nativeProbabilisticScoringFeeParameters>::is_null(self.inner) { let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; } } } -/// Frees any resources used by the ProbabilisticScoringParameters, if is_owned is set and inner is non-NULL. +/// Frees any resources used by the ProbabilisticScoringFeeParameters, if is_owned is set and inner is non-NULL. #[no_mangle] -pub extern "C" fn ProbabilisticScoringParameters_free(this_obj: ProbabilisticScoringParameters) { } +pub extern "C" fn ProbabilisticScoringFeeParameters_free(this_obj: ProbabilisticScoringFeeParameters) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn ProbabilisticScoringParameters_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeProbabilisticScoringParameters) }; +pub(crate) extern "C" fn ProbabilisticScoringFeeParameters_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeProbabilisticScoringFeeParameters) }; } #[allow(unused)] -impl ProbabilisticScoringParameters { - pub(crate) fn get_native_ref(&self) -> &'static nativeProbabilisticScoringParameters { +impl ProbabilisticScoringFeeParameters { + pub(crate) fn get_native_ref(&self) -> &'static nativeProbabilisticScoringFeeParameters { unsafe { &*ObjOps::untweak_ptr(self.inner) } } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeProbabilisticScoringParameters { + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeProbabilisticScoringFeeParameters { unsafe { &mut *ObjOps::untweak_ptr(self.inner) } } /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy - pub(crate) fn take_inner(mut self) -> *mut nativeProbabilisticScoringParameters { + pub(crate) fn take_inner(mut self) -> *mut nativeProbabilisticScoringFeeParameters { assert!(self.is_owned); let ret = ObjOps::untweak_ptr(self.inner); self.inner = core::ptr::null_mut(); @@ -902,7 +902,7 @@ impl ProbabilisticScoringParameters { /// /// Default value: 500 msat #[no_mangle] -pub extern "C" fn ProbabilisticScoringParameters_get_base_penalty_msat(this_ptr: &ProbabilisticScoringParameters) -> u64 { +pub extern "C" fn ProbabilisticScoringFeeParameters_get_base_penalty_msat(this_ptr: &ProbabilisticScoringFeeParameters) -> u64 { let mut inner_val = &mut this_ptr.get_native_mut_ref().base_penalty_msat; *inner_val } @@ -910,7 +910,7 @@ pub extern "C" fn ProbabilisticScoringParameters_get_base_penalty_msat(this_ptr: /// /// Default value: 500 msat #[no_mangle] -pub extern "C" fn ProbabilisticScoringParameters_set_base_penalty_msat(this_ptr: &mut ProbabilisticScoringParameters, mut val: u64) { +pub extern "C" fn ProbabilisticScoringFeeParameters_set_base_penalty_msat(this_ptr: &mut ProbabilisticScoringFeeParameters, mut val: u64) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.base_penalty_msat = val; } /// A multiplier used with the payment amount to calculate a fixed penalty applied to each @@ -926,7 +926,7 @@ pub extern "C" fn ProbabilisticScoringParameters_set_base_penalty_msat(this_ptr: /// /// [`base_penalty_msat`]: Self::base_penalty_msat #[no_mangle] -pub extern "C" fn ProbabilisticScoringParameters_get_base_penalty_amount_multiplier_msat(this_ptr: &ProbabilisticScoringParameters) -> u64 { +pub extern "C" fn ProbabilisticScoringFeeParameters_get_base_penalty_amount_multiplier_msat(this_ptr: &ProbabilisticScoringFeeParameters) -> u64 { let mut inner_val = &mut this_ptr.get_native_mut_ref().base_penalty_amount_multiplier_msat; *inner_val } @@ -943,7 +943,7 @@ pub extern "C" fn ProbabilisticScoringParameters_get_base_penalty_amount_multipl /// /// [`base_penalty_msat`]: Self::base_penalty_msat #[no_mangle] -pub extern "C" fn ProbabilisticScoringParameters_set_base_penalty_amount_multiplier_msat(this_ptr: &mut ProbabilisticScoringParameters, mut val: u64) { +pub extern "C" fn ProbabilisticScoringFeeParameters_set_base_penalty_amount_multiplier_msat(this_ptr: &mut ProbabilisticScoringFeeParameters, mut val: u64) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.base_penalty_amount_multiplier_msat = val; } /// A multiplier used in conjunction with the negative `log10` of the channel's success @@ -961,9 +961,9 @@ pub extern "C" fn ProbabilisticScoringParameters_set_base_penalty_amount_multipl /// /// Default value: 30,000 msat /// -/// [`liquidity_offset_half_life`]: Self::liquidity_offset_half_life +/// [`liquidity_offset_half_life`]: ProbabilisticScoringDecayParameters::liquidity_offset_half_life #[no_mangle] -pub extern "C" fn ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat(this_ptr: &ProbabilisticScoringParameters) -> u64 { +pub extern "C" fn ProbabilisticScoringFeeParameters_get_liquidity_penalty_multiplier_msat(this_ptr: &ProbabilisticScoringFeeParameters) -> u64 { let mut inner_val = &mut this_ptr.get_native_mut_ref().liquidity_penalty_multiplier_msat; *inner_val } @@ -982,58 +982,11 @@ pub extern "C" fn ProbabilisticScoringParameters_get_liquidity_penalty_multiplie /// /// Default value: 30,000 msat /// -/// [`liquidity_offset_half_life`]: Self::liquidity_offset_half_life +/// [`liquidity_offset_half_life`]: ProbabilisticScoringDecayParameters::liquidity_offset_half_life #[no_mangle] -pub extern "C" fn ProbabilisticScoringParameters_set_liquidity_penalty_multiplier_msat(this_ptr: &mut ProbabilisticScoringParameters, mut val: u64) { +pub extern "C" fn ProbabilisticScoringFeeParameters_set_liquidity_penalty_multiplier_msat(this_ptr: &mut ProbabilisticScoringFeeParameters, mut val: u64) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.liquidity_penalty_multiplier_msat = val; } -/// Whenever this amount of time elapses since the last update to a channel's liquidity bounds, -/// the distance from the bounds to \"zero\" is cut in half. In other words, the lower-bound on -/// the available liquidity is halved and the upper-bound moves half-way to the channel's total -/// capacity. -/// -/// Because halving the liquidity bounds grows the uncertainty on the channel's liquidity, -/// the penalty for an amount within the new bounds may change. See the [`ProbabilisticScorer`] -/// struct documentation for more info on the way the liquidity bounds are used. -/// -/// For example, if the channel's capacity is 1 million sats, and the current upper and lower -/// liquidity bounds are 200,000 sats and 600,000 sats, after this amount of time the upper -/// and lower liquidity bounds will be decayed to 100,000 and 800,000 sats. -/// -/// Default value: 6 hours -/// -/// # Note -/// -/// When built with the `no-std` feature, time will never elapse. Therefore, the channel -/// liquidity knowledge will never decay except when the bounds cross. -#[no_mangle] -pub extern "C" fn ProbabilisticScoringParameters_get_liquidity_offset_half_life(this_ptr: &ProbabilisticScoringParameters) -> u64 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().liquidity_offset_half_life; - inner_val.as_secs() -} -/// Whenever this amount of time elapses since the last update to a channel's liquidity bounds, -/// the distance from the bounds to \"zero\" is cut in half. In other words, the lower-bound on -/// the available liquidity is halved and the upper-bound moves half-way to the channel's total -/// capacity. -/// -/// Because halving the liquidity bounds grows the uncertainty on the channel's liquidity, -/// the penalty for an amount within the new bounds may change. See the [`ProbabilisticScorer`] -/// struct documentation for more info on the way the liquidity bounds are used. -/// -/// For example, if the channel's capacity is 1 million sats, and the current upper and lower -/// liquidity bounds are 200,000 sats and 600,000 sats, after this amount of time the upper -/// and lower liquidity bounds will be decayed to 100,000 and 800,000 sats. -/// -/// Default value: 6 hours -/// -/// # Note -/// -/// When built with the `no-std` feature, time will never elapse. Therefore, the channel -/// liquidity knowledge will never decay except when the bounds cross. -#[no_mangle] -pub extern "C" fn ProbabilisticScoringParameters_set_liquidity_offset_half_life(this_ptr: &mut ProbabilisticScoringParameters, mut val: u64) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.liquidity_offset_half_life = core::time::Duration::from_secs(val); -} /// A multiplier used in conjunction with a payment amount and the negative `log10` of the /// channel's success probability for the payment, as determined by our latest estimates of the /// channel's liquidity, to determine the amount penalty. @@ -1053,7 +1006,7 @@ pub extern "C" fn ProbabilisticScoringParameters_set_liquidity_offset_half_life( /// /// Default value: 192 msat #[no_mangle] -pub extern "C" fn ProbabilisticScoringParameters_get_liquidity_penalty_amount_multiplier_msat(this_ptr: &ProbabilisticScoringParameters) -> u64 { +pub extern "C" fn ProbabilisticScoringFeeParameters_get_liquidity_penalty_amount_multiplier_msat(this_ptr: &ProbabilisticScoringFeeParameters) -> u64 { let mut inner_val = &mut this_ptr.get_native_mut_ref().liquidity_penalty_amount_multiplier_msat; *inner_val } @@ -1076,7 +1029,7 @@ pub extern "C" fn ProbabilisticScoringParameters_get_liquidity_penalty_amount_mu /// /// Default value: 192 msat #[no_mangle] -pub extern "C" fn ProbabilisticScoringParameters_set_liquidity_penalty_amount_multiplier_msat(this_ptr: &mut ProbabilisticScoringParameters, mut val: u64) { +pub extern "C" fn ProbabilisticScoringFeeParameters_set_liquidity_penalty_amount_multiplier_msat(this_ptr: &mut ProbabilisticScoringFeeParameters, mut val: u64) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.liquidity_penalty_amount_multiplier_msat = val; } /// A multiplier used in conjunction with the negative `log10` of the channel's success @@ -1094,7 +1047,7 @@ pub extern "C" fn ProbabilisticScoringParameters_set_liquidity_penalty_amount_mu /// /// [`liquidity_penalty_multiplier_msat`]: Self::liquidity_penalty_multiplier_msat #[no_mangle] -pub extern "C" fn ProbabilisticScoringParameters_get_historical_liquidity_penalty_multiplier_msat(this_ptr: &ProbabilisticScoringParameters) -> u64 { +pub extern "C" fn ProbabilisticScoringFeeParameters_get_historical_liquidity_penalty_multiplier_msat(this_ptr: &ProbabilisticScoringFeeParameters) -> u64 { let mut inner_val = &mut this_ptr.get_native_mut_ref().historical_liquidity_penalty_multiplier_msat; *inner_val } @@ -1113,7 +1066,7 @@ pub extern "C" fn ProbabilisticScoringParameters_get_historical_liquidity_penalt /// /// [`liquidity_penalty_multiplier_msat`]: Self::liquidity_penalty_multiplier_msat #[no_mangle] -pub extern "C" fn ProbabilisticScoringParameters_set_historical_liquidity_penalty_multiplier_msat(this_ptr: &mut ProbabilisticScoringParameters, mut val: u64) { +pub extern "C" fn ProbabilisticScoringFeeParameters_set_historical_liquidity_penalty_multiplier_msat(this_ptr: &mut ProbabilisticScoringFeeParameters, mut val: u64) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.historical_liquidity_penalty_multiplier_msat = val; } /// A multiplier used in conjunction with the payment amount and the negative `log10` of the @@ -1135,7 +1088,7 @@ pub extern "C" fn ProbabilisticScoringParameters_set_historical_liquidity_penalt /// /// [`liquidity_penalty_amount_multiplier_msat`]: Self::liquidity_penalty_amount_multiplier_msat #[no_mangle] -pub extern "C" fn ProbabilisticScoringParameters_get_historical_liquidity_penalty_amount_multiplier_msat(this_ptr: &ProbabilisticScoringParameters) -> u64 { +pub extern "C" fn ProbabilisticScoringFeeParameters_get_historical_liquidity_penalty_amount_multiplier_msat(this_ptr: &ProbabilisticScoringFeeParameters) -> u64 { let mut inner_val = &mut this_ptr.get_native_mut_ref().historical_liquidity_penalty_amount_multiplier_msat; *inner_val } @@ -1158,53 +1111,30 @@ pub extern "C" fn ProbabilisticScoringParameters_get_historical_liquidity_penalt /// /// [`liquidity_penalty_amount_multiplier_msat`]: Self::liquidity_penalty_amount_multiplier_msat #[no_mangle] -pub extern "C" fn ProbabilisticScoringParameters_set_historical_liquidity_penalty_amount_multiplier_msat(this_ptr: &mut ProbabilisticScoringParameters, mut val: u64) { +pub extern "C" fn ProbabilisticScoringFeeParameters_set_historical_liquidity_penalty_amount_multiplier_msat(this_ptr: &mut ProbabilisticScoringFeeParameters, mut val: u64) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.historical_liquidity_penalty_amount_multiplier_msat = val; } -/// If we aren't learning any new datapoints for a channel, the historical liquidity bounds -/// tracking can simply live on with increasingly stale data. Instead, when a channel has not -/// seen a liquidity estimate update for this amount of time, the historical datapoints are -/// decayed by half. -/// -/// Note that after 16 or more half lives all historical data will be completely gone. -/// -/// Default value: 14 days -#[no_mangle] -pub extern "C" fn ProbabilisticScoringParameters_get_historical_no_updates_half_life(this_ptr: &ProbabilisticScoringParameters) -> u64 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().historical_no_updates_half_life; - inner_val.as_secs() -} -/// If we aren't learning any new datapoints for a channel, the historical liquidity bounds -/// tracking can simply live on with increasingly stale data. Instead, when a channel has not -/// seen a liquidity estimate update for this amount of time, the historical datapoints are -/// decayed by half. -/// -/// Note that after 16 or more half lives all historical data will be completely gone. -/// -/// Default value: 14 days -#[no_mangle] -pub extern "C" fn ProbabilisticScoringParameters_set_historical_no_updates_half_life(this_ptr: &mut ProbabilisticScoringParameters, mut val: u64) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.historical_no_updates_half_life = core::time::Duration::from_secs(val); -} /// This penalty is applied when `htlc_maximum_msat` is equal to or larger than half of the -/// channel's capacity, which makes us prefer nodes with a smaller `htlc_maximum_msat`. We -/// treat such nodes preferentially as this makes balance discovery attacks harder to execute, -/// thereby creating an incentive to restrict `htlc_maximum_msat` and improve privacy. +/// channel's capacity, (ie. htlc_maximum_msat ≥ 0.5 * channel_capacity) which makes us +/// prefer nodes with a smaller `htlc_maximum_msat`. We treat such nodes preferentially +/// as this makes balance discovery attacks harder to execute, thereby creating an incentive +/// to restrict `htlc_maximum_msat` and improve privacy. /// /// Default value: 250 msat #[no_mangle] -pub extern "C" fn ProbabilisticScoringParameters_get_anti_probing_penalty_msat(this_ptr: &ProbabilisticScoringParameters) -> u64 { +pub extern "C" fn ProbabilisticScoringFeeParameters_get_anti_probing_penalty_msat(this_ptr: &ProbabilisticScoringFeeParameters) -> u64 { let mut inner_val = &mut this_ptr.get_native_mut_ref().anti_probing_penalty_msat; *inner_val } /// This penalty is applied when `htlc_maximum_msat` is equal to or larger than half of the -/// channel's capacity, which makes us prefer nodes with a smaller `htlc_maximum_msat`. We -/// treat such nodes preferentially as this makes balance discovery attacks harder to execute, -/// thereby creating an incentive to restrict `htlc_maximum_msat` and improve privacy. +/// channel's capacity, (ie. htlc_maximum_msat ≥ 0.5 * channel_capacity) which makes us +/// prefer nodes with a smaller `htlc_maximum_msat`. We treat such nodes preferentially +/// as this makes balance discovery attacks harder to execute, thereby creating an incentive +/// to restrict `htlc_maximum_msat` and improve privacy. /// /// Default value: 250 msat #[no_mangle] -pub extern "C" fn ProbabilisticScoringParameters_set_anti_probing_penalty_msat(this_ptr: &mut ProbabilisticScoringParameters, mut val: u64) { +pub extern "C" fn ProbabilisticScoringFeeParameters_set_anti_probing_penalty_msat(this_ptr: &mut ProbabilisticScoringFeeParameters, mut val: u64) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.anti_probing_penalty_msat = val; } /// This penalty is applied when the amount we're attempting to send over a channel exceeds our @@ -1225,7 +1155,7 @@ pub extern "C" fn ProbabilisticScoringParameters_set_anti_probing_penalty_msat(t /// [`base_penalty_msat`]: Self::base_penalty_msat /// [`anti_probing_penalty_msat`]: Self::anti_probing_penalty_msat #[no_mangle] -pub extern "C" fn ProbabilisticScoringParameters_get_considered_impossible_penalty_msat(this_ptr: &ProbabilisticScoringParameters) -> u64 { +pub extern "C" fn ProbabilisticScoringFeeParameters_get_considered_impossible_penalty_msat(this_ptr: &ProbabilisticScoringFeeParameters) -> u64 { let mut inner_val = &mut this_ptr.get_native_mut_ref().considered_impossible_penalty_msat; *inner_val } @@ -1247,13 +1177,219 @@ pub extern "C" fn ProbabilisticScoringParameters_get_considered_impossible_penal /// [`base_penalty_msat`]: Self::base_penalty_msat /// [`anti_probing_penalty_msat`]: Self::anti_probing_penalty_msat #[no_mangle] -pub extern "C" fn ProbabilisticScoringParameters_set_considered_impossible_penalty_msat(this_ptr: &mut ProbabilisticScoringParameters, mut val: u64) { +pub extern "C" fn ProbabilisticScoringFeeParameters_set_considered_impossible_penalty_msat(this_ptr: &mut ProbabilisticScoringFeeParameters, mut val: u64) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.considered_impossible_penalty_msat = val; } -impl Clone for ProbabilisticScoringParameters { +impl Clone for ProbabilisticScoringFeeParameters { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeProbabilisticScoringFeeParameters>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn ProbabilisticScoringFeeParameters_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeProbabilisticScoringFeeParameters)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the ProbabilisticScoringFeeParameters +pub extern "C" fn ProbabilisticScoringFeeParameters_clone(orig: &ProbabilisticScoringFeeParameters) -> ProbabilisticScoringFeeParameters { + orig.clone() +} +/// Creates a "default" ProbabilisticScoringFeeParameters. See struct and individual field documentaiton for details on which values are used. +#[must_use] +#[no_mangle] +pub extern "C" fn ProbabilisticScoringFeeParameters_default() -> ProbabilisticScoringFeeParameters { + ProbabilisticScoringFeeParameters { inner: ObjOps::heap_alloc(Default::default()), is_owned: true } +} +/// Marks the node with the given `node_id` as banned, +/// i.e it will be avoided during path finding. +#[no_mangle] +pub extern "C" fn ProbabilisticScoringFeeParameters_add_banned(this_arg: &mut crate::lightning::routing::scoring::ProbabilisticScoringFeeParameters, node_id: &crate::lightning::routing::gossip::NodeId) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::routing::scoring::nativeProbabilisticScoringFeeParameters)) }.add_banned(node_id.get_native_ref()) +} + +/// Marks all nodes in the given list as banned, i.e., +/// they will be avoided during path finding. +#[no_mangle] +pub extern "C" fn ProbabilisticScoringFeeParameters_add_banned_from_list(this_arg: &mut crate::lightning::routing::scoring::ProbabilisticScoringFeeParameters, mut node_ids: crate::c_types::derived::CVec_NodeIdZ) { + let mut local_node_ids = Vec::new(); for mut item in node_ids.into_rust().drain(..) { local_node_ids.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::routing::scoring::nativeProbabilisticScoringFeeParameters)) }.add_banned_from_list(local_node_ids) +} + +/// Removes the node with the given `node_id` from the list of nodes to avoid. +#[no_mangle] +pub extern "C" fn ProbabilisticScoringFeeParameters_remove_banned(this_arg: &mut crate::lightning::routing::scoring::ProbabilisticScoringFeeParameters, node_id: &crate::lightning::routing::gossip::NodeId) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::routing::scoring::nativeProbabilisticScoringFeeParameters)) }.remove_banned(node_id.get_native_ref()) +} + +/// Sets a manual penalty for the given node. +#[no_mangle] +pub extern "C" fn ProbabilisticScoringFeeParameters_set_manual_penalty(this_arg: &mut crate::lightning::routing::scoring::ProbabilisticScoringFeeParameters, node_id: &crate::lightning::routing::gossip::NodeId, mut penalty: u64) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::routing::scoring::nativeProbabilisticScoringFeeParameters)) }.set_manual_penalty(node_id.get_native_ref(), penalty) +} + +/// Removes the node with the given `node_id` from the list of manual penalties. +#[no_mangle] +pub extern "C" fn ProbabilisticScoringFeeParameters_remove_manual_penalty(this_arg: &mut crate::lightning::routing::scoring::ProbabilisticScoringFeeParameters, node_id: &crate::lightning::routing::gossip::NodeId) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::routing::scoring::nativeProbabilisticScoringFeeParameters)) }.remove_manual_penalty(node_id.get_native_ref()) +} + +/// Clears the list of manual penalties that are applied during path finding. +#[no_mangle] +pub extern "C" fn ProbabilisticScoringFeeParameters_clear_manual_penalties(this_arg: &mut crate::lightning::routing::scoring::ProbabilisticScoringFeeParameters) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::routing::scoring::nativeProbabilisticScoringFeeParameters)) }.clear_manual_penalties() +} + + +use lightning::routing::scoring::ProbabilisticScoringDecayParameters as nativeProbabilisticScoringDecayParametersImport; +pub(crate) type nativeProbabilisticScoringDecayParameters = nativeProbabilisticScoringDecayParametersImport; + +/// Parameters for configuring [`ProbabilisticScorer`]. +/// +/// Used to configure decay parameters that are static throughout the lifetime of the scorer. +/// these decay parameters affect the score of the channel penalty and are not changed on a +/// per-route penalty cost call. +#[must_use] +#[repr(C)] +pub struct ProbabilisticScoringDecayParameters { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeProbabilisticScoringDecayParameters, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for ProbabilisticScoringDecayParameters { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeProbabilisticScoringDecayParameters>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the ProbabilisticScoringDecayParameters, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn ProbabilisticScoringDecayParameters_free(this_obj: ProbabilisticScoringDecayParameters) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn ProbabilisticScoringDecayParameters_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeProbabilisticScoringDecayParameters) }; +} +#[allow(unused)] +impl ProbabilisticScoringDecayParameters { + pub(crate) fn get_native_ref(&self) -> &'static nativeProbabilisticScoringDecayParameters { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeProbabilisticScoringDecayParameters { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeProbabilisticScoringDecayParameters { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +/// If we aren't learning any new datapoints for a channel, the historical liquidity bounds +/// tracking can simply live on with increasingly stale data. Instead, when a channel has not +/// seen a liquidity estimate update for this amount of time, the historical datapoints are +/// decayed by half. +/// For an example of historical_no_updates_half_life being used see [`historical_estimated_channel_liquidity_probabilities`] +/// +/// Note that after 16 or more half lives all historical data will be completely gone. +/// +/// Default value: 14 days +/// +/// [`historical_estimated_channel_liquidity_probabilities`]: ProbabilisticScorerUsingTime::historical_estimated_channel_liquidity_probabilities +#[no_mangle] +pub extern "C" fn ProbabilisticScoringDecayParameters_get_historical_no_updates_half_life(this_ptr: &ProbabilisticScoringDecayParameters) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().historical_no_updates_half_life; + inner_val.as_secs() +} +/// If we aren't learning any new datapoints for a channel, the historical liquidity bounds +/// tracking can simply live on with increasingly stale data. Instead, when a channel has not +/// seen a liquidity estimate update for this amount of time, the historical datapoints are +/// decayed by half. +/// For an example of historical_no_updates_half_life being used see [`historical_estimated_channel_liquidity_probabilities`] +/// +/// Note that after 16 or more half lives all historical data will be completely gone. +/// +/// Default value: 14 days +/// +/// [`historical_estimated_channel_liquidity_probabilities`]: ProbabilisticScorerUsingTime::historical_estimated_channel_liquidity_probabilities +#[no_mangle] +pub extern "C" fn ProbabilisticScoringDecayParameters_set_historical_no_updates_half_life(this_ptr: &mut ProbabilisticScoringDecayParameters, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.historical_no_updates_half_life = core::time::Duration::from_secs(val); +} +/// Whenever this amount of time elapses since the last update to a channel's liquidity bounds, +/// the distance from the bounds to \"zero\" is cut in half. In other words, the lower-bound on +/// the available liquidity is halved and the upper-bound moves half-way to the channel's total +/// capacity. +/// +/// Because halving the liquidity bounds grows the uncertainty on the channel's liquidity, +/// the penalty for an amount within the new bounds may change. See the [`ProbabilisticScorer`] +/// struct documentation for more info on the way the liquidity bounds are used. +/// +/// For example, if the channel's capacity is 1 million sats, and the current upper and lower +/// liquidity bounds are 200,000 sats and 600,000 sats, after this amount of time the upper +/// and lower liquidity bounds will be decayed to 100,000 and 800,000 sats. +/// +/// Default value: 6 hours +/// +/// # Note +/// +/// When built with the `no-std` feature, time will never elapse. Therefore, the channel +/// liquidity knowledge will never decay except when the bounds cross. +#[no_mangle] +pub extern "C" fn ProbabilisticScoringDecayParameters_get_liquidity_offset_half_life(this_ptr: &ProbabilisticScoringDecayParameters) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().liquidity_offset_half_life; + inner_val.as_secs() +} +/// Whenever this amount of time elapses since the last update to a channel's liquidity bounds, +/// the distance from the bounds to \"zero\" is cut in half. In other words, the lower-bound on +/// the available liquidity is halved and the upper-bound moves half-way to the channel's total +/// capacity. +/// +/// Because halving the liquidity bounds grows the uncertainty on the channel's liquidity, +/// the penalty for an amount within the new bounds may change. See the [`ProbabilisticScorer`] +/// struct documentation for more info on the way the liquidity bounds are used. +/// +/// For example, if the channel's capacity is 1 million sats, and the current upper and lower +/// liquidity bounds are 200,000 sats and 600,000 sats, after this amount of time the upper +/// and lower liquidity bounds will be decayed to 100,000 and 800,000 sats. +/// +/// Default value: 6 hours +/// +/// # Note +/// +/// When built with the `no-std` feature, time will never elapse. Therefore, the channel +/// liquidity knowledge will never decay except when the bounds cross. +#[no_mangle] +pub extern "C" fn ProbabilisticScoringDecayParameters_set_liquidity_offset_half_life(this_ptr: &mut ProbabilisticScoringDecayParameters, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.liquidity_offset_half_life = core::time::Duration::from_secs(val); +} +/// Constructs a new ProbabilisticScoringDecayParameters given each field +#[must_use] +#[no_mangle] +pub extern "C" fn ProbabilisticScoringDecayParameters_new(mut historical_no_updates_half_life_arg: u64, mut liquidity_offset_half_life_arg: u64) -> ProbabilisticScoringDecayParameters { + ProbabilisticScoringDecayParameters { inner: ObjOps::heap_alloc(nativeProbabilisticScoringDecayParameters { + historical_no_updates_half_life: core::time::Duration::from_secs(historical_no_updates_half_life_arg), + liquidity_offset_half_life: core::time::Duration::from_secs(liquidity_offset_half_life_arg), + }), is_owned: true } +} +impl Clone for ProbabilisticScoringDecayParameters { fn clone(&self) -> Self { Self { - inner: if <*mut nativeProbabilisticScoringParameters>::is_null(self.inner) { core::ptr::null_mut() } else { + inner: if <*mut nativeProbabilisticScoringDecayParameters>::is_null(self.inner) { core::ptr::null_mut() } else { ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, is_owned: true, } @@ -1261,20 +1397,26 @@ impl Clone for ProbabilisticScoringParameters { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn ProbabilisticScoringParameters_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeProbabilisticScoringParameters)).clone() })) as *mut c_void +pub(crate) extern "C" fn ProbabilisticScoringDecayParameters_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeProbabilisticScoringDecayParameters)).clone() })) as *mut c_void } #[no_mangle] -/// Creates a copy of the ProbabilisticScoringParameters -pub extern "C" fn ProbabilisticScoringParameters_clone(orig: &ProbabilisticScoringParameters) -> ProbabilisticScoringParameters { +/// Creates a copy of the ProbabilisticScoringDecayParameters +pub extern "C" fn ProbabilisticScoringDecayParameters_clone(orig: &ProbabilisticScoringDecayParameters) -> ProbabilisticScoringDecayParameters { orig.clone() } +/// Creates a "default" ProbabilisticScoringDecayParameters. See struct and individual field documentaiton for details on which values are used. +#[must_use] +#[no_mangle] +pub extern "C" fn ProbabilisticScoringDecayParameters_default() -> ProbabilisticScoringDecayParameters { + ProbabilisticScoringDecayParameters { inner: ObjOps::heap_alloc(Default::default()), is_owned: true } +} /// Creates a new scorer using the given scoring parameters for sending payments from a node /// through a network graph. #[must_use] #[no_mangle] -pub extern "C" fn ProbabilisticScorer_new(mut params: crate::lightning::routing::scoring::ProbabilisticScoringParameters, network_graph: &crate::lightning::routing::gossip::NetworkGraph, mut logger: crate::lightning::util::logger::Logger) -> crate::lightning::routing::scoring::ProbabilisticScorer { - let mut ret = lightning::routing::scoring::ProbabilisticScorer::new(*unsafe { Box::from_raw(params.take_inner()) }, network_graph.get_native_ref(), logger); +pub extern "C" fn ProbabilisticScorer_new(mut decay_params: crate::lightning::routing::scoring::ProbabilisticScoringDecayParameters, network_graph: &crate::lightning::routing::gossip::NetworkGraph, mut logger: crate::lightning::util::logger::Logger) -> crate::lightning::routing::scoring::ProbabilisticScorer { + let mut ret = lightning::routing::scoring::ProbabilisticScorer::new(*unsafe { Box::from_raw(decay_params.take_inner()) }, network_graph.get_native_ref(), logger); crate::lightning::routing::scoring::ProbabilisticScorer { inner: ObjOps::heap_alloc(ret), is_owned: true } } @@ -1326,51 +1468,6 @@ pub extern "C" fn ProbabilisticScorer_historical_estimated_channel_liquidity_pro local_ret } -/// Marks the node with the given `node_id` as banned, i.e., -/// it will be avoided during path finding. -#[no_mangle] -pub extern "C" fn ProbabilisticScorer_add_banned(this_arg: &mut crate::lightning::routing::scoring::ProbabilisticScorer, node_id: &crate::lightning::routing::gossip::NodeId) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::routing::scoring::nativeProbabilisticScorer)) }.add_banned(node_id.get_native_ref()) -} - -/// Removes the node with the given `node_id` from the list of nodes to avoid. -#[no_mangle] -pub extern "C" fn ProbabilisticScorer_remove_banned(this_arg: &mut crate::lightning::routing::scoring::ProbabilisticScorer, node_id: &crate::lightning::routing::gossip::NodeId) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::routing::scoring::nativeProbabilisticScorer)) }.remove_banned(node_id.get_native_ref()) -} - -/// Sets a manual penalty for the given node. -#[no_mangle] -pub extern "C" fn ProbabilisticScorer_set_manual_penalty(this_arg: &mut crate::lightning::routing::scoring::ProbabilisticScorer, node_id: &crate::lightning::routing::gossip::NodeId, mut penalty: u64) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::routing::scoring::nativeProbabilisticScorer)) }.set_manual_penalty(node_id.get_native_ref(), penalty) -} - -/// Removes the node with the given `node_id` from the list of manual penalties. -#[no_mangle] -pub extern "C" fn ProbabilisticScorer_remove_manual_penalty(this_arg: &mut crate::lightning::routing::scoring::ProbabilisticScorer, node_id: &crate::lightning::routing::gossip::NodeId) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::routing::scoring::nativeProbabilisticScorer)) }.remove_manual_penalty(node_id.get_native_ref()) -} - -/// Clears the list of manual penalties that are applied during path finding. -#[no_mangle] -pub extern "C" fn ProbabilisticScorer_clear_manual_penalties(this_arg: &mut crate::lightning::routing::scoring::ProbabilisticScorer) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::routing::scoring::nativeProbabilisticScorer)) }.clear_manual_penalties() -} - -/// Marks all nodes in the given list as banned, i.e., -/// they will be avoided during path finding. -#[no_mangle] -pub extern "C" fn ProbabilisticScoringParameters_add_banned_from_list(this_arg: &mut crate::lightning::routing::scoring::ProbabilisticScoringParameters, mut node_ids: crate::c_types::derived::CVec_NodeIdZ) { - let mut local_node_ids = Vec::new(); for mut item in node_ids.into_rust().drain(..) { local_node_ids.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::routing::scoring::nativeProbabilisticScoringParameters)) }.add_banned_from_list(local_node_ids) -} - -/// Creates a "default" ProbabilisticScoringParameters. See struct and individual field documentaiton for details on which values are used. -#[must_use] -#[no_mangle] -pub extern "C" fn ProbabilisticScoringParameters_default() -> ProbabilisticScoringParameters { - ProbabilisticScoringParameters { inner: ObjOps::heap_alloc(Default::default()), is_owned: true } -} impl From for crate::lightning::routing::scoring::Score { fn from(obj: nativeProbabilisticScorer) -> Self { let mut rust_obj = ProbabilisticScorer { inner: ObjOps::heap_alloc(obj), is_owned: true }; @@ -1398,8 +1495,8 @@ pub extern "C" fn ProbabilisticScorer_as_Score(this_arg: &ProbabilisticScorer) - } #[must_use] -extern "C" fn ProbabilisticScorer_Score_channel_penalty_msat(this_arg: *const c_void, mut short_channel_id: u64, source: &crate::lightning::routing::gossip::NodeId, target: &crate::lightning::routing::gossip::NodeId, mut usage: crate::lightning::routing::scoring::ChannelUsage) -> u64 { - let mut ret = >::channel_penalty_msat(unsafe { &mut *(this_arg as *mut nativeProbabilisticScorer) }, short_channel_id, source.get_native_ref(), target.get_native_ref(), *unsafe { Box::from_raw(usage.take_inner()) }); +extern "C" fn ProbabilisticScorer_Score_channel_penalty_msat(this_arg: *const c_void, mut short_channel_id: u64, source: &crate::lightning::routing::gossip::NodeId, target: &crate::lightning::routing::gossip::NodeId, mut usage: crate::lightning::routing::scoring::ChannelUsage, score_params: &crate::lightning::routing::scoring::ProbabilisticScoringFeeParameters) -> u64 { + let mut ret = >::channel_penalty_msat(unsafe { &mut *(this_arg as *mut nativeProbabilisticScorer) }, short_channel_id, source.get_native_ref(), target.get_native_ref(), *unsafe { Box::from_raw(usage.take_inner()) }, score_params.get_native_ref()); ret } extern "C" fn ProbabilisticScorer_Score_payment_path_failed(this_arg: *mut c_void, path: &crate::lightning::routing::router::Path, mut short_channel_id: u64) { @@ -1437,7 +1534,7 @@ pub(crate) extern "C" fn ProbabilisticScorer_write_void(obj: *const c_void) -> c } #[no_mangle] /// Read a ProbabilisticScorer from a byte array, created by ProbabilisticScorer_write -pub extern "C" fn ProbabilisticScorer_read(ser: crate::c_types::u8slice, arg_a: crate::lightning::routing::scoring::ProbabilisticScoringParameters, arg_b: &crate::lightning::routing::gossip::NetworkGraph, arg_c: crate::lightning::util::logger::Logger) -> crate::c_types::derived::CResult_ProbabilisticScorerDecodeErrorZ { +pub extern "C" fn ProbabilisticScorer_read(ser: crate::c_types::u8slice, arg_a: crate::lightning::routing::scoring::ProbabilisticScoringDecayParameters, arg_b: &crate::lightning::routing::gossip::NetworkGraph, arg_c: crate::lightning::util::logger::Logger) -> crate::c_types::derived::CResult_ProbabilisticScorerDecodeErrorZ { let arg_a_conv = *unsafe { Box::from_raw(arg_a.take_inner()) }; let arg_b_conv = arg_b.get_native_ref(); let arg_c_conv = arg_c; diff --git a/lightning-c-bindings/src/lightning/routing/utxo.rs b/lightning-c-bindings/src/lightning/routing/utxo.rs index c9ed6952..7f741e28 100644 --- a/lightning-c-bindings/src/lightning/routing/utxo.rs +++ b/lightning-c-bindings/src/lightning/routing/utxo.rs @@ -140,7 +140,7 @@ impl UtxoResult { match native { nativeUtxoResult::Sync (ref a, ) => { let mut a_nonref = Clone::clone(a); - let mut local_a_nonref = match a_nonref { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::TxOut::from_rust(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::routing::utxo::UtxoLookupError::native_into(e) }).into() }; + let mut local_a_nonref = match a_nonref { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::TxOut::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::routing::utxo::UtxoLookupError::native_into(e) }).into() }; UtxoResult::Sync ( local_a_nonref, ) @@ -157,7 +157,7 @@ impl UtxoResult { pub(crate) fn native_into(native: nativeUtxoResult) -> Self { match native { nativeUtxoResult::Sync (mut a, ) => { - let mut local_a = match a { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::TxOut::from_rust(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::routing::utxo::UtxoLookupError::native_into(e) }).into() }; + let mut local_a = match a { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::TxOut::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::routing::utxo::UtxoLookupError::native_into(e) }).into() }; UtxoResult::Sync ( local_a, ) @@ -199,7 +199,6 @@ pub struct UtxoLookup { /// is unknown. /// /// [`short_channel_id`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#definition-of-short_channel_id - #[must_use] pub get_utxo: extern "C" fn (this_arg: *const c_void, genesis_hash: *const [u8; 32], short_channel_id: u64) -> crate::lightning::routing::utxo::UtxoResult, /// Frees any resources associated with this object given its this_arg pointer. /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. diff --git a/lightning-c-bindings/src/lightning/util/config.rs b/lightning-c-bindings/src/lightning/util/config.rs index 13e65a48..e451b42b 100644 --- a/lightning-c-bindings/src/lightning/util/config.rs +++ b/lightning-c-bindings/src/lightning/util/config.rs @@ -312,7 +312,7 @@ pub extern "C" fn ChannelHandshakeConfig_set_announced_channel(this_ptr: &mut Ch /// /// Default value: true. /// -/// [`SignerProvider::get_shutdown_scriptpubkey`]: crate::chain::keysinterface::SignerProvider::get_shutdown_scriptpubkey +/// [`SignerProvider::get_shutdown_scriptpubkey`]: crate::sign::SignerProvider::get_shutdown_scriptpubkey #[no_mangle] pub extern "C" fn ChannelHandshakeConfig_get_commit_upfront_shutdown_pubkey(this_ptr: &ChannelHandshakeConfig) -> bool { let mut inner_val = &mut this_ptr.get_native_mut_ref().commit_upfront_shutdown_pubkey; @@ -330,7 +330,7 @@ pub extern "C" fn ChannelHandshakeConfig_get_commit_upfront_shutdown_pubkey(this /// /// Default value: true. /// -/// [`SignerProvider::get_shutdown_scriptpubkey`]: crate::chain::keysinterface::SignerProvider::get_shutdown_scriptpubkey +/// [`SignerProvider::get_shutdown_scriptpubkey`]: crate::sign::SignerProvider::get_shutdown_scriptpubkey #[no_mangle] pub extern "C" fn ChannelHandshakeConfig_set_commit_upfront_shutdown_pubkey(this_ptr: &mut ChannelHandshakeConfig, mut val: bool) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.commit_upfront_shutdown_pubkey = val; @@ -388,6 +388,71 @@ pub extern "C" fn ChannelHandshakeConfig_get_their_channel_reserve_proportional_ pub extern "C" fn ChannelHandshakeConfig_set_their_channel_reserve_proportional_millionths(this_ptr: &mut ChannelHandshakeConfig, mut val: u32) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.their_channel_reserve_proportional_millionths = val; } +/// If set, we attempt to negotiate the `anchors_zero_fee_htlc_tx`option for all future +/// channels. This feature requires having a reserve of onchain funds readily available to bump +/// transactions in the event of a channel force close to avoid the possibility of losing funds. +/// +/// Note that if you wish accept inbound channels with anchor outputs, you must enable +/// [`UserConfig::manually_accept_inbound_channels`] and manually accept them with +/// [`ChannelManager::accept_inbound_channel`]. This is done to give you the chance to check +/// whether your reserve of onchain funds is enough to cover the fees for all existing and new +/// channels featuring anchor outputs in the event of a force close. +/// +/// If this option is set, channels may be created that will not be readable by LDK versions +/// prior to 0.0.116, causing [`ChannelManager`]'s read method to return a +/// [`DecodeError::InvalidValue`]. +/// +/// Note that setting this to true does *not* prevent us from opening channels with +/// counterparties that do not support the `anchors_zero_fee_htlc_tx` option; we will simply +/// fall back to a `static_remote_key` channel. +/// +/// LDK will not support the legacy `option_anchors` commitment version due to a discovered +/// vulnerability after its deployment. For more context, see the [`SIGHASH_SINGLE + update_fee +/// Considered Harmful`] mailing list post. +/// +/// Default value: false. This value is likely to change to true in the future. +/// +/// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager +/// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel +/// [`DecodeError::InvalidValue`]: crate::ln::msgs::DecodeError::InvalidValue +/// [`SIGHASH_SINGLE + update_fee Considered Harmful`]: https://lists.linuxfoundation.org/pipermail/lightning-dev/2020-September/002796.html +#[no_mangle] +pub extern "C" fn ChannelHandshakeConfig_get_negotiate_anchors_zero_fee_htlc_tx(this_ptr: &ChannelHandshakeConfig) -> bool { + let mut inner_val = &mut this_ptr.get_native_mut_ref().negotiate_anchors_zero_fee_htlc_tx; + *inner_val +} +/// If set, we attempt to negotiate the `anchors_zero_fee_htlc_tx`option for all future +/// channels. This feature requires having a reserve of onchain funds readily available to bump +/// transactions in the event of a channel force close to avoid the possibility of losing funds. +/// +/// Note that if you wish accept inbound channels with anchor outputs, you must enable +/// [`UserConfig::manually_accept_inbound_channels`] and manually accept them with +/// [`ChannelManager::accept_inbound_channel`]. This is done to give you the chance to check +/// whether your reserve of onchain funds is enough to cover the fees for all existing and new +/// channels featuring anchor outputs in the event of a force close. +/// +/// If this option is set, channels may be created that will not be readable by LDK versions +/// prior to 0.0.116, causing [`ChannelManager`]'s read method to return a +/// [`DecodeError::InvalidValue`]. +/// +/// Note that setting this to true does *not* prevent us from opening channels with +/// counterparties that do not support the `anchors_zero_fee_htlc_tx` option; we will simply +/// fall back to a `static_remote_key` channel. +/// +/// LDK will not support the legacy `option_anchors` commitment version due to a discovered +/// vulnerability after its deployment. For more context, see the [`SIGHASH_SINGLE + update_fee +/// Considered Harmful`] mailing list post. +/// +/// Default value: false. This value is likely to change to true in the future. +/// +/// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager +/// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel +/// [`DecodeError::InvalidValue`]: crate::ln::msgs::DecodeError::InvalidValue +/// [`SIGHASH_SINGLE + update_fee Considered Harmful`]: https://lists.linuxfoundation.org/pipermail/lightning-dev/2020-September/002796.html +#[no_mangle] +pub extern "C" fn ChannelHandshakeConfig_set_negotiate_anchors_zero_fee_htlc_tx(this_ptr: &mut ChannelHandshakeConfig, mut val: bool) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.negotiate_anchors_zero_fee_htlc_tx = val; +} /// The maximum number of HTLCs in-flight from our counterparty towards us at the same time. /// /// Increasing the value can help improve liquidity and stability in @@ -422,7 +487,7 @@ pub extern "C" fn ChannelHandshakeConfig_set_our_max_accepted_htlcs(this_ptr: &m /// Constructs a new ChannelHandshakeConfig given each field #[must_use] #[no_mangle] -pub extern "C" fn ChannelHandshakeConfig_new(mut minimum_depth_arg: u32, mut our_to_self_delay_arg: u16, mut our_htlc_minimum_msat_arg: u64, mut max_inbound_htlc_value_in_flight_percent_of_channel_arg: u8, mut negotiate_scid_privacy_arg: bool, mut announced_channel_arg: bool, mut commit_upfront_shutdown_pubkey_arg: bool, mut their_channel_reserve_proportional_millionths_arg: u32, mut our_max_accepted_htlcs_arg: u16) -> ChannelHandshakeConfig { +pub extern "C" fn ChannelHandshakeConfig_new(mut minimum_depth_arg: u32, mut our_to_self_delay_arg: u16, mut our_htlc_minimum_msat_arg: u64, mut max_inbound_htlc_value_in_flight_percent_of_channel_arg: u8, mut negotiate_scid_privacy_arg: bool, mut announced_channel_arg: bool, mut commit_upfront_shutdown_pubkey_arg: bool, mut their_channel_reserve_proportional_millionths_arg: u32, mut negotiate_anchors_zero_fee_htlc_tx_arg: bool, mut our_max_accepted_htlcs_arg: u16) -> ChannelHandshakeConfig { ChannelHandshakeConfig { inner: ObjOps::heap_alloc(nativeChannelHandshakeConfig { minimum_depth: minimum_depth_arg, our_to_self_delay: our_to_self_delay_arg, @@ -432,6 +497,7 @@ pub extern "C" fn ChannelHandshakeConfig_new(mut minimum_depth_arg: u32, mut our announced_channel: announced_channel_arg, commit_upfront_shutdown_pubkey: commit_upfront_shutdown_pubkey_arg, their_channel_reserve_proportional_millionths: their_channel_reserve_proportional_millionths_arg, + negotiate_anchors_zero_fee_htlc_tx: negotiate_anchors_zero_fee_htlc_tx_arg, our_max_accepted_htlcs: our_max_accepted_htlcs_arg, }), is_owned: true } } @@ -779,6 +845,158 @@ pub extern "C" fn ChannelHandshakeLimits_clone(orig: &ChannelHandshakeLimits) -> pub extern "C" fn ChannelHandshakeLimits_default() -> ChannelHandshakeLimits { ChannelHandshakeLimits { inner: ObjOps::heap_alloc(Default::default()), is_owned: true } } +/// Options for how to set the max dust HTLC exposure allowed on a channel. See +/// [`ChannelConfig::max_dust_htlc_exposure`] for details. +#[derive(Clone)] +#[must_use] +#[repr(C)] +pub enum MaxDustHTLCExposure { + /// This sets a fixed limit on the total dust exposure in millisatoshis. Setting this too low + /// may prevent the sending or receipt of low-value HTLCs on high-traffic nodes, however this + /// limit is very important to prevent stealing of large amounts of dust HTLCs by miners + /// through [fee griefing + /// attacks](https://lists.linuxfoundation.org/pipermail/lightning-dev/2020-May/002714.html). + /// + /// Note that if the feerate increases significantly, without a manual increase + /// to this maximum the channel may be unable to send/receive HTLCs between the maximum dust + /// exposure and the new minimum value for HTLCs to be economically viable to claim. + FixedLimitMsat( + u64), + /// This sets a multiplier on the estimated high priority feerate (sats/KW, as obtained from + /// [`FeeEstimator`]) to determine the maximum allowed dust exposure. If this variant is used + /// then the maximum dust exposure in millisatoshis is calculated as: + /// `high_priority_feerate_per_kw * value`. For example, with our default value + /// `FeeRateMultiplier(5000)`: + /// + /// - For the minimum fee rate of 1 sat/vByte (250 sat/KW, although the minimum + /// defaults to 253 sats/KW for rounding, see [`FeeEstimator`]), the max dust exposure would + /// be 253 * 5000 = 1,265,000 msats. + /// - For a fee rate of 30 sat/vByte (7500 sat/KW), the max dust exposure would be + /// 7500 * 5000 = 37,500,000 msats. + /// + /// This allows the maximum dust exposure to automatically scale with fee rate changes. + /// + /// Note, if you're using a third-party fee estimator, this may leave you more exposed to a + /// fee griefing attack, where your fee estimator may purposely overestimate the fee rate, + /// causing you to accept more dust HTLCs than you would otherwise. + /// + /// This variant is primarily meant to serve pre-anchor channels, as HTLC fees being included + /// on HTLC outputs means your channel may be subject to more dust exposure in the event of + /// increases in fee rate. + /// + /// # Backwards Compatibility + /// This variant only became available in LDK 0.0.116, so if you downgrade to a prior version + /// by default this will be set to a [`Self::FixedLimitMsat`] of 5,000,000 msat. + /// + /// [`FeeEstimator`]: crate::chain::chaininterface::FeeEstimator + FeeRateMultiplier( + u64), +} +use lightning::util::config::MaxDustHTLCExposure as MaxDustHTLCExposureImport; +pub(crate) type nativeMaxDustHTLCExposure = MaxDustHTLCExposureImport; + +impl MaxDustHTLCExposure { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeMaxDustHTLCExposure { + match self { + MaxDustHTLCExposure::FixedLimitMsat (ref a, ) => { + let mut a_nonref = Clone::clone(a); + nativeMaxDustHTLCExposure::FixedLimitMsat ( + a_nonref, + ) + }, + MaxDustHTLCExposure::FeeRateMultiplier (ref a, ) => { + let mut a_nonref = Clone::clone(a); + nativeMaxDustHTLCExposure::FeeRateMultiplier ( + a_nonref, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeMaxDustHTLCExposure { + match self { + MaxDustHTLCExposure::FixedLimitMsat (mut a, ) => { + nativeMaxDustHTLCExposure::FixedLimitMsat ( + a, + ) + }, + MaxDustHTLCExposure::FeeRateMultiplier (mut a, ) => { + nativeMaxDustHTLCExposure::FeeRateMultiplier ( + a, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &nativeMaxDustHTLCExposure) -> Self { + match native { + nativeMaxDustHTLCExposure::FixedLimitMsat (ref a, ) => { + let mut a_nonref = Clone::clone(a); + MaxDustHTLCExposure::FixedLimitMsat ( + a_nonref, + ) + }, + nativeMaxDustHTLCExposure::FeeRateMultiplier (ref a, ) => { + let mut a_nonref = Clone::clone(a); + MaxDustHTLCExposure::FeeRateMultiplier ( + a_nonref, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeMaxDustHTLCExposure) -> Self { + match native { + nativeMaxDustHTLCExposure::FixedLimitMsat (mut a, ) => { + MaxDustHTLCExposure::FixedLimitMsat ( + a, + ) + }, + nativeMaxDustHTLCExposure::FeeRateMultiplier (mut a, ) => { + MaxDustHTLCExposure::FeeRateMultiplier ( + a, + ) + }, + } + } +} +/// Frees any resources used by the MaxDustHTLCExposure +#[no_mangle] +pub extern "C" fn MaxDustHTLCExposure_free(this_ptr: MaxDustHTLCExposure) { } +/// Creates a copy of the MaxDustHTLCExposure +#[no_mangle] +pub extern "C" fn MaxDustHTLCExposure_clone(orig: &MaxDustHTLCExposure) -> MaxDustHTLCExposure { + orig.clone() +} +#[no_mangle] +/// Utility method to constructs a new FixedLimitMsat-variant MaxDustHTLCExposure +pub extern "C" fn MaxDustHTLCExposure_fixed_limit_msat(a: u64) -> MaxDustHTLCExposure { + MaxDustHTLCExposure::FixedLimitMsat(a, ) +} +#[no_mangle] +/// Utility method to constructs a new FeeRateMultiplier-variant MaxDustHTLCExposure +pub extern "C" fn MaxDustHTLCExposure_fee_rate_multiplier(a: u64) -> MaxDustHTLCExposure { + MaxDustHTLCExposure::FeeRateMultiplier(a, ) +} +/// Checks if two MaxDustHTLCExposures contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +#[no_mangle] +pub extern "C" fn MaxDustHTLCExposure_eq(a: &MaxDustHTLCExposure, b: &MaxDustHTLCExposure) -> bool { + if &a.to_native() == &b.to_native() { true } else { false } +} +#[no_mangle] +/// Serialize the MaxDustHTLCExposure object into a byte array which can be read by MaxDustHTLCExposure_read +pub extern "C" fn MaxDustHTLCExposure_write(obj: &crate::lightning::util::config::MaxDustHTLCExposure) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(&unsafe { &*obj }.to_native()) +} +#[no_mangle] +/// Read a MaxDustHTLCExposure from a byte array, created by MaxDustHTLCExposure_write +pub extern "C" fn MaxDustHTLCExposure_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_MaxDustHTLCExposureDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::util::config::MaxDustHTLCExposure::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} use lightning::util::config::ChannelConfig as nativeChannelConfigImport; pub(crate) type nativeChannelConfig = nativeChannelConfigImport; @@ -945,18 +1163,18 @@ pub extern "C" fn ChannelConfig_set_cltv_expiry_delta(this_ptr: &mut ChannelConf /// channel negotiated throughout the channel open process, along with the fees required to have /// a broadcastable HTLC spending transaction. When a channel supports anchor outputs /// (specifically the zero fee HTLC transaction variant), this threshold no longer takes into -/// account the HTLC transaction fee as it is zero. +/// account the HTLC transaction fee as it is zero. Because of this, you may want to set this +/// value to a fixed limit for channels using anchor outputs, while the fee rate multiplier +/// variant is primarily intended for use with pre-anchor channels. /// -/// This limit is applied for sent, forwarded, and received HTLCs and limits the total -/// exposure across all three types per-channel. Setting this too low may prevent the -/// sending or receipt of low-value HTLCs on high-traffic nodes, and this limit is very -/// important to prevent stealing of dust HTLCs by miners. +/// The selected limit is applied for sent, forwarded, and received HTLCs and limits the total +/// exposure across all three types per-channel. /// -/// Default value: 5_000_000 msat. +/// Default value: [`MaxDustHTLCExposure::FeeRateMultiplier`] with a multiplier of 5000. #[no_mangle] -pub extern "C" fn ChannelConfig_get_max_dust_htlc_exposure_msat(this_ptr: &ChannelConfig) -> u64 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().max_dust_htlc_exposure_msat; - *inner_val +pub extern "C" fn ChannelConfig_get_max_dust_htlc_exposure(this_ptr: &ChannelConfig) -> crate::lightning::util::config::MaxDustHTLCExposure { + let mut inner_val = &mut this_ptr.get_native_mut_ref().max_dust_htlc_exposure; + crate::lightning::util::config::MaxDustHTLCExposure::from_native(inner_val) } /// Limit our total exposure to in-flight HTLCs which are burned to fees as they are too /// small to claim on-chain. @@ -971,17 +1189,17 @@ pub extern "C" fn ChannelConfig_get_max_dust_htlc_exposure_msat(this_ptr: &Chann /// channel negotiated throughout the channel open process, along with the fees required to have /// a broadcastable HTLC spending transaction. When a channel supports anchor outputs /// (specifically the zero fee HTLC transaction variant), this threshold no longer takes into -/// account the HTLC transaction fee as it is zero. +/// account the HTLC transaction fee as it is zero. Because of this, you may want to set this +/// value to a fixed limit for channels using anchor outputs, while the fee rate multiplier +/// variant is primarily intended for use with pre-anchor channels. /// -/// This limit is applied for sent, forwarded, and received HTLCs and limits the total -/// exposure across all three types per-channel. Setting this too low may prevent the -/// sending or receipt of low-value HTLCs on high-traffic nodes, and this limit is very -/// important to prevent stealing of dust HTLCs by miners. +/// The selected limit is applied for sent, forwarded, and received HTLCs and limits the total +/// exposure across all three types per-channel. /// -/// Default value: 5_000_000 msat. +/// Default value: [`MaxDustHTLCExposure::FeeRateMultiplier`] with a multiplier of 5000. #[no_mangle] -pub extern "C" fn ChannelConfig_set_max_dust_htlc_exposure_msat(this_ptr: &mut ChannelConfig, mut val: u64) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_dust_htlc_exposure_msat = val; +pub extern "C" fn ChannelConfig_set_max_dust_htlc_exposure(this_ptr: &mut ChannelConfig, mut val: crate::lightning::util::config::MaxDustHTLCExposure) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_dust_htlc_exposure = val.into_native(); } /// The additional fee we're willing to pay to avoid waiting for the counterparty's /// `to_self_delay` to reclaim funds. @@ -1036,16 +1254,84 @@ pub extern "C" fn ChannelConfig_get_force_close_avoidance_max_fee_satoshis(this_ pub extern "C" fn ChannelConfig_set_force_close_avoidance_max_fee_satoshis(this_ptr: &mut ChannelConfig, mut val: u64) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.force_close_avoidance_max_fee_satoshis = val; } +/// If set, allows this channel's counterparty to skim an additional fee off this node's inbound +/// HTLCs. Useful for liquidity providers to offload on-chain channel costs to end users. +/// +/// Usage: +/// - The payee will set this option and set its invoice route hints to use [intercept scids] +/// generated by this channel's counterparty. +/// - The counterparty will get an [`HTLCIntercepted`] event upon payment forward, and call +/// [`forward_intercepted_htlc`] with less than the amount provided in +/// [`HTLCIntercepted::expected_outbound_amount_msat`]. The difference between the expected and +/// actual forward amounts is their fee. +/// +/// # Note +/// It's important for payee wallet software to verify that [`PaymentClaimable::amount_msat`] is +/// as-expected if this feature is activated, otherwise they may lose money! +/// [`PaymentClaimable::counterparty_skimmed_fee_msat`] provides the fee taken by the +/// counterparty. +/// +/// # Note +/// Switching this config flag on may break compatibility with versions of LDK prior to 0.0.116. +/// Unsetting this flag between restarts may lead to payment receive failures. +/// +/// Default value: false. +/// +/// [intercept scids]: crate::ln::channelmanager::ChannelManager::get_intercept_scid +/// [`forward_intercepted_htlc`]: crate::ln::channelmanager::ChannelManager::forward_intercepted_htlc +/// [`HTLCIntercepted`]: crate::events::Event::HTLCIntercepted +/// [`HTLCIntercepted::expected_outbound_amount_msat`]: crate::events::Event::HTLCIntercepted::expected_outbound_amount_msat +/// [`PaymentClaimable::amount_msat`]: crate::events::Event::PaymentClaimable::amount_msat +/// [`PaymentClaimable::counterparty_skimmed_fee_msat`]: crate::events::Event::PaymentClaimable::counterparty_skimmed_fee_msat +#[no_mangle] +pub extern "C" fn ChannelConfig_get_accept_underpaying_htlcs(this_ptr: &ChannelConfig) -> bool { + let mut inner_val = &mut this_ptr.get_native_mut_ref().accept_underpaying_htlcs; + *inner_val +} +/// If set, allows this channel's counterparty to skim an additional fee off this node's inbound +/// HTLCs. Useful for liquidity providers to offload on-chain channel costs to end users. +/// +/// Usage: +/// - The payee will set this option and set its invoice route hints to use [intercept scids] +/// generated by this channel's counterparty. +/// - The counterparty will get an [`HTLCIntercepted`] event upon payment forward, and call +/// [`forward_intercepted_htlc`] with less than the amount provided in +/// [`HTLCIntercepted::expected_outbound_amount_msat`]. The difference between the expected and +/// actual forward amounts is their fee. +/// +/// # Note +/// It's important for payee wallet software to verify that [`PaymentClaimable::amount_msat`] is +/// as-expected if this feature is activated, otherwise they may lose money! +/// [`PaymentClaimable::counterparty_skimmed_fee_msat`] provides the fee taken by the +/// counterparty. +/// +/// # Note +/// Switching this config flag on may break compatibility with versions of LDK prior to 0.0.116. +/// Unsetting this flag between restarts may lead to payment receive failures. +/// +/// Default value: false. +/// +/// [intercept scids]: crate::ln::channelmanager::ChannelManager::get_intercept_scid +/// [`forward_intercepted_htlc`]: crate::ln::channelmanager::ChannelManager::forward_intercepted_htlc +/// [`HTLCIntercepted`]: crate::events::Event::HTLCIntercepted +/// [`HTLCIntercepted::expected_outbound_amount_msat`]: crate::events::Event::HTLCIntercepted::expected_outbound_amount_msat +/// [`PaymentClaimable::amount_msat`]: crate::events::Event::PaymentClaimable::amount_msat +/// [`PaymentClaimable::counterparty_skimmed_fee_msat`]: crate::events::Event::PaymentClaimable::counterparty_skimmed_fee_msat +#[no_mangle] +pub extern "C" fn ChannelConfig_set_accept_underpaying_htlcs(this_ptr: &mut ChannelConfig, mut val: bool) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.accept_underpaying_htlcs = val; +} /// Constructs a new ChannelConfig given each field #[must_use] #[no_mangle] -pub extern "C" fn ChannelConfig_new(mut forwarding_fee_proportional_millionths_arg: u32, mut forwarding_fee_base_msat_arg: u32, mut cltv_expiry_delta_arg: u16, mut max_dust_htlc_exposure_msat_arg: u64, mut force_close_avoidance_max_fee_satoshis_arg: u64) -> ChannelConfig { +pub extern "C" fn ChannelConfig_new(mut forwarding_fee_proportional_millionths_arg: u32, mut forwarding_fee_base_msat_arg: u32, mut cltv_expiry_delta_arg: u16, mut max_dust_htlc_exposure_arg: crate::lightning::util::config::MaxDustHTLCExposure, mut force_close_avoidance_max_fee_satoshis_arg: u64, mut accept_underpaying_htlcs_arg: bool) -> ChannelConfig { ChannelConfig { inner: ObjOps::heap_alloc(nativeChannelConfig { forwarding_fee_proportional_millionths: forwarding_fee_proportional_millionths_arg, forwarding_fee_base_msat: forwarding_fee_base_msat_arg, cltv_expiry_delta: cltv_expiry_delta_arg, - max_dust_htlc_exposure_msat: max_dust_htlc_exposure_msat_arg, + max_dust_htlc_exposure: max_dust_htlc_exposure_arg.into_native(), force_close_avoidance_max_fee_satoshis: force_close_avoidance_max_fee_satoshis_arg, + accept_underpaying_htlcs: accept_underpaying_htlcs_arg, }), is_owned: true } } impl Clone for ChannelConfig { @@ -1076,6 +1362,12 @@ pub extern "C" fn ChannelConfig_eq(a: &ChannelConfig, b: &ChannelConfig) -> bool if a.inner.is_null() || b.inner.is_null() { return false; } if a.get_native_ref() == b.get_native_ref() { true } else { false } } +/// Applies the given [`ChannelConfigUpdate`] as a partial update to the [`ChannelConfig`]. +#[no_mangle] +pub extern "C" fn ChannelConfig_apply(this_arg: &mut crate::lightning::util::config::ChannelConfig, update: &crate::lightning::util::config::ChannelConfigUpdate) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::util::config::nativeChannelConfig)) }.apply(update.get_native_ref()) +} + /// Creates a "default" ChannelConfig. See struct and individual field documentaiton for details on which values are used. #[must_use] #[no_mangle] @@ -1099,6 +1391,137 @@ pub extern "C" fn ChannelConfig_read(ser: crate::c_types::u8slice) -> crate::c_t local_res } +use lightning::util::config::ChannelConfigUpdate as nativeChannelConfigUpdateImport; +pub(crate) type nativeChannelConfigUpdate = nativeChannelConfigUpdateImport; + +/// A parallel struct to [`ChannelConfig`] to define partial updates. +#[must_use] +#[repr(C)] +pub struct ChannelConfigUpdate { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeChannelConfigUpdate, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for ChannelConfigUpdate { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeChannelConfigUpdate>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the ChannelConfigUpdate, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn ChannelConfigUpdate_free(this_obj: ChannelConfigUpdate) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn ChannelConfigUpdate_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelConfigUpdate) }; +} +#[allow(unused)] +impl ChannelConfigUpdate { + pub(crate) fn get_native_ref(&self) -> &'static nativeChannelConfigUpdate { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelConfigUpdate { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeChannelConfigUpdate { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +#[no_mangle] +pub extern "C" fn ChannelConfigUpdate_get_forwarding_fee_proportional_millionths(this_ptr: &ChannelConfigUpdate) -> crate::c_types::derived::COption_u32Z { + let mut inner_val = &mut this_ptr.get_native_mut_ref().forwarding_fee_proportional_millionths; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u32Z::None } else { crate::c_types::derived::COption_u32Z::Some( { inner_val.unwrap() }) }; + local_inner_val +} +#[no_mangle] +pub extern "C" fn ChannelConfigUpdate_set_forwarding_fee_proportional_millionths(this_ptr: &mut ChannelConfigUpdate, mut val: crate::c_types::derived::COption_u32Z) { + let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.forwarding_fee_proportional_millionths = local_val; +} +#[no_mangle] +pub extern "C" fn ChannelConfigUpdate_get_forwarding_fee_base_msat(this_ptr: &ChannelConfigUpdate) -> crate::c_types::derived::COption_u32Z { + let mut inner_val = &mut this_ptr.get_native_mut_ref().forwarding_fee_base_msat; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u32Z::None } else { crate::c_types::derived::COption_u32Z::Some( { inner_val.unwrap() }) }; + local_inner_val +} +#[no_mangle] +pub extern "C" fn ChannelConfigUpdate_set_forwarding_fee_base_msat(this_ptr: &mut ChannelConfigUpdate, mut val: crate::c_types::derived::COption_u32Z) { + let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.forwarding_fee_base_msat = local_val; +} +#[no_mangle] +pub extern "C" fn ChannelConfigUpdate_get_cltv_expiry_delta(this_ptr: &ChannelConfigUpdate) -> crate::c_types::derived::COption_u16Z { + let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u16Z::None } else { crate::c_types::derived::COption_u16Z::Some( { inner_val.unwrap() }) }; + local_inner_val +} +#[no_mangle] +pub extern "C" fn ChannelConfigUpdate_set_cltv_expiry_delta(this_ptr: &mut ChannelConfigUpdate, mut val: crate::c_types::derived::COption_u16Z) { + let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = local_val; +} +/// +/// Returns a copy of the field. +#[no_mangle] +pub extern "C" fn ChannelConfigUpdate_get_max_dust_htlc_exposure_msat(this_ptr: &ChannelConfigUpdate) -> crate::c_types::derived::COption_MaxDustHTLCExposureZ { + let mut inner_val = this_ptr.get_native_mut_ref().max_dust_htlc_exposure_msat.clone(); + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_MaxDustHTLCExposureZ::None } else { crate::c_types::derived::COption_MaxDustHTLCExposureZ::Some( { crate::lightning::util::config::MaxDustHTLCExposure::native_into(inner_val.unwrap()) }) }; + local_inner_val +} +#[no_mangle] +pub extern "C" fn ChannelConfigUpdate_set_max_dust_htlc_exposure_msat(this_ptr: &mut ChannelConfigUpdate, mut val: crate::c_types::derived::COption_MaxDustHTLCExposureZ) { + let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { { val_opt.take() }.into_native() }})} }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_dust_htlc_exposure_msat = local_val; +} +#[no_mangle] +pub extern "C" fn ChannelConfigUpdate_get_force_close_avoidance_max_fee_satoshis(this_ptr: &ChannelConfigUpdate) -> crate::c_types::derived::COption_u64Z { + let mut inner_val = &mut this_ptr.get_native_mut_ref().force_close_avoidance_max_fee_satoshis; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) }; + local_inner_val +} +#[no_mangle] +pub extern "C" fn ChannelConfigUpdate_set_force_close_avoidance_max_fee_satoshis(this_ptr: &mut ChannelConfigUpdate, mut val: crate::c_types::derived::COption_u64Z) { + let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.force_close_avoidance_max_fee_satoshis = local_val; +} +/// Constructs a new ChannelConfigUpdate given each field +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelConfigUpdate_new(mut forwarding_fee_proportional_millionths_arg: crate::c_types::derived::COption_u32Z, mut forwarding_fee_base_msat_arg: crate::c_types::derived::COption_u32Z, mut cltv_expiry_delta_arg: crate::c_types::derived::COption_u16Z, mut max_dust_htlc_exposure_msat_arg: crate::c_types::derived::COption_MaxDustHTLCExposureZ, mut force_close_avoidance_max_fee_satoshis_arg: crate::c_types::derived::COption_u64Z) -> ChannelConfigUpdate { + let mut local_forwarding_fee_proportional_millionths_arg = if forwarding_fee_proportional_millionths_arg.is_some() { Some( { forwarding_fee_proportional_millionths_arg.take() }) } else { None }; + let mut local_forwarding_fee_base_msat_arg = if forwarding_fee_base_msat_arg.is_some() { Some( { forwarding_fee_base_msat_arg.take() }) } else { None }; + let mut local_cltv_expiry_delta_arg = if cltv_expiry_delta_arg.is_some() { Some( { cltv_expiry_delta_arg.take() }) } else { None }; + let mut local_max_dust_htlc_exposure_msat_arg = { /*max_dust_htlc_exposure_msat_arg*/ let max_dust_htlc_exposure_msat_arg_opt = max_dust_htlc_exposure_msat_arg; if max_dust_htlc_exposure_msat_arg_opt.is_none() { None } else { Some({ { { max_dust_htlc_exposure_msat_arg_opt.take() }.into_native() }})} }; + let mut local_force_close_avoidance_max_fee_satoshis_arg = if force_close_avoidance_max_fee_satoshis_arg.is_some() { Some( { force_close_avoidance_max_fee_satoshis_arg.take() }) } else { None }; + ChannelConfigUpdate { inner: ObjOps::heap_alloc(nativeChannelConfigUpdate { + forwarding_fee_proportional_millionths: local_forwarding_fee_proportional_millionths_arg, + forwarding_fee_base_msat: local_forwarding_fee_base_msat_arg, + cltv_expiry_delta: local_cltv_expiry_delta_arg, + max_dust_htlc_exposure_msat: local_max_dust_htlc_exposure_msat_arg, + force_close_avoidance_max_fee_satoshis: local_force_close_avoidance_max_fee_satoshis_arg, + }), is_owned: true } +} +/// Creates a "default" ChannelConfigUpdate. See struct and individual field documentaiton for details on which values are used. +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelConfigUpdate_default() -> ChannelConfigUpdate { + ChannelConfigUpdate { inner: ObjOps::heap_alloc(Default::default()), is_owned: true } +} + use lightning::util::config::UserConfig as nativeUserConfigImport; pub(crate) type nativeUserConfig = nativeUserConfigImport; @@ -1303,10 +1726,39 @@ pub extern "C" fn UserConfig_get_accept_intercept_htlcs(this_ptr: &UserConfig) - pub extern "C" fn UserConfig_set_accept_intercept_htlcs(this_ptr: &mut UserConfig, mut val: bool) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.accept_intercept_htlcs = val; } +/// If this is set to false, when receiving a keysend payment we'll fail it if it has multiple +/// parts. If this is set to true, we'll accept the payment. +/// +/// Setting this to true will break backwards compatibility upon downgrading to an LDK +/// version < 0.0.116 while receiving an MPP keysend. If we have already received an MPP +/// keysend, downgrading will cause us to fail to deserialize [`ChannelManager`]. +/// +/// Default value: false. +/// +/// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager +#[no_mangle] +pub extern "C" fn UserConfig_get_accept_mpp_keysend(this_ptr: &UserConfig) -> bool { + let mut inner_val = &mut this_ptr.get_native_mut_ref().accept_mpp_keysend; + *inner_val +} +/// If this is set to false, when receiving a keysend payment we'll fail it if it has multiple +/// parts. If this is set to true, we'll accept the payment. +/// +/// Setting this to true will break backwards compatibility upon downgrading to an LDK +/// version < 0.0.116 while receiving an MPP keysend. If we have already received an MPP +/// keysend, downgrading will cause us to fail to deserialize [`ChannelManager`]. +/// +/// Default value: false. +/// +/// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager +#[no_mangle] +pub extern "C" fn UserConfig_set_accept_mpp_keysend(this_ptr: &mut UserConfig, mut val: bool) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.accept_mpp_keysend = val; +} /// Constructs a new UserConfig given each field #[must_use] #[no_mangle] -pub extern "C" fn UserConfig_new(mut channel_handshake_config_arg: crate::lightning::util::config::ChannelHandshakeConfig, mut channel_handshake_limits_arg: crate::lightning::util::config::ChannelHandshakeLimits, mut channel_config_arg: crate::lightning::util::config::ChannelConfig, mut accept_forwards_to_priv_channels_arg: bool, mut accept_inbound_channels_arg: bool, mut manually_accept_inbound_channels_arg: bool, mut accept_intercept_htlcs_arg: bool) -> UserConfig { +pub extern "C" fn UserConfig_new(mut channel_handshake_config_arg: crate::lightning::util::config::ChannelHandshakeConfig, mut channel_handshake_limits_arg: crate::lightning::util::config::ChannelHandshakeLimits, mut channel_config_arg: crate::lightning::util::config::ChannelConfig, mut accept_forwards_to_priv_channels_arg: bool, mut accept_inbound_channels_arg: bool, mut manually_accept_inbound_channels_arg: bool, mut accept_intercept_htlcs_arg: bool, mut accept_mpp_keysend_arg: bool) -> UserConfig { UserConfig { inner: ObjOps::heap_alloc(nativeUserConfig { channel_handshake_config: *unsafe { Box::from_raw(channel_handshake_config_arg.take_inner()) }, channel_handshake_limits: *unsafe { Box::from_raw(channel_handshake_limits_arg.take_inner()) }, @@ -1315,6 +1767,7 @@ pub extern "C" fn UserConfig_new(mut channel_handshake_config_arg: crate::lightn accept_inbound_channels: accept_inbound_channels_arg, manually_accept_inbound_channels: manually_accept_inbound_channels_arg, accept_intercept_htlcs: accept_intercept_htlcs_arg, + accept_mpp_keysend: accept_mpp_keysend_arg, }), is_owned: true } } impl Clone for UserConfig { diff --git a/lightning-c-bindings/src/lightning/util/errors.rs b/lightning-c-bindings/src/lightning/util/errors.rs index ff0f416b..7ca78917 100644 --- a/lightning-c-bindings/src/lightning/util/errors.rs +++ b/lightning-c-bindings/src/lightning/util/errors.rs @@ -65,7 +65,7 @@ pub enum APIError { /// Using a SegWit v0 script should resolve this issue. If you cannot, you won't be able to open /// a channel or cooperatively close one with this peer (and will have to force-close instead). /// - /// [`SignerProvider::get_shutdown_scriptpubkey`]: crate::chain::keysinterface::SignerProvider::get_shutdown_scriptpubkey + /// [`SignerProvider::get_shutdown_scriptpubkey`]: crate::sign::SignerProvider::get_shutdown_scriptpubkey /// [`InitFeatures`]: crate::ln::features::InitFeatures IncompatibleShutdownScript { /// The incompatible shutdown script. diff --git a/lightning-c-bindings/src/lightning/util/persist.rs b/lightning-c-bindings/src/lightning/util/persist.rs index 5aae5c69..0c77f8d0 100644 --- a/lightning-c-bindings/src/lightning/util/persist.rs +++ b/lightning-c-bindings/src/lightning/util/persist.rs @@ -25,13 +25,10 @@ pub struct Persister { /// This has no meaning in the LDK, and can be NULL or any other value. pub this_arg: *mut c_void, /// Persist the given ['ChannelManager'] to disk, returning an error if persistence failed. - #[must_use] pub persist_manager: extern "C" fn (this_arg: *const c_void, channel_manager: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::c_types::derived::CResult_NoneErrorZ, /// Persist the given [`NetworkGraph`] to disk, returning an error if persistence failed. - #[must_use] pub persist_graph: extern "C" fn (this_arg: *const c_void, network_graph: &crate::lightning::routing::gossip::NetworkGraph) -> crate::c_types::derived::CResult_NoneErrorZ, /// Persist the given [`WriteableScore`] to disk, returning an error if persistence failed. - #[must_use] pub persist_scorer: extern "C" fn (this_arg: *const c_void, scorer: &crate::lightning::routing::scoring::WriteableScore) -> crate::c_types::derived::CResult_NoneErrorZ, /// Frees any resources associated with this object given its this_arg pointer. /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. @@ -51,8 +48,8 @@ pub(crate) extern "C" fn Persister_clone_fields(orig: &Persister) -> Persister { } use lightning::util::persist::Persister as rustPersister; -impl<'a> rustPersister<'a, crate::lightning::chain::Watch, crate::lightning::chain::chaininterface::BroadcasterInterface, crate::lightning::chain::keysinterface::EntropySource, crate::lightning::chain::keysinterface::NodeSigner, crate::lightning::chain::keysinterface::SignerProvider, crate::lightning::chain::chaininterface::FeeEstimator, crate::lightning::routing::router::Router, crate::lightning::util::logger::Logger, crate::lightning::routing::scoring::WriteableScore> for Persister { - fn persist_manager(&self, mut channel_manager: &lightning::ln::channelmanager::ChannelManager) -> Result<(), lightning::io::Error> { +impl<'a> rustPersister<'a, crate::lightning::chain::Watch, crate::lightning::chain::chaininterface::BroadcasterInterface, crate::lightning::sign::EntropySource, crate::lightning::sign::NodeSigner, crate::lightning::sign::SignerProvider, crate::lightning::chain::chaininterface::FeeEstimator, crate::lightning::routing::router::Router, crate::lightning::util::logger::Logger, crate::lightning::routing::scoring::WriteableScore> for Persister { + fn persist_manager(&self, mut channel_manager: &lightning::ln::channelmanager::ChannelManager) -> Result<(), lightning::io::Error> { let mut ret = (self.persist_manager)(self.this_arg, &crate::lightning::ln::channelmanager::ChannelManager { inner: unsafe { ObjOps::nonnull_ptr_to_inner((channel_manager as *const lightning::ln::channelmanager::ChannelManager<_, _, _, _, _, _, _, _, >) as *mut _) }, is_owned: false }); let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).to_rust() })}; local_ret diff --git a/lightning-c-bindings/src/lightning/util/ser.rs b/lightning-c-bindings/src/lightning/util/ser.rs index 824dc7a0..193a22c6 100644 --- a/lightning-c-bindings/src/lightning/util/ser.rs +++ b/lightning-c-bindings/src/lightning/util/ser.rs @@ -98,6 +98,60 @@ pub extern "C" fn BigSize_new(mut a_arg: u64) -> BigSize { a_arg, )), is_owned: true } } +impl Clone for BigSize { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeBigSize>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn BigSize_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeBigSize)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the BigSize +pub extern "C" fn BigSize_clone(orig: &BigSize) -> BigSize { + orig.clone() +} +/// Generates a non-cryptographic 64-bit hash of the BigSize. +#[no_mangle] +pub extern "C" fn BigSize_hash(o: &BigSize) -> u64 { + if o.inner.is_null() { return 0; } + // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core + #[allow(deprecated)] + let mut hasher = core::hash::SipHasher::new(); + core::hash::Hash::hash(o.get_native_ref(), &mut hasher); + core::hash::Hasher::finish(&hasher) +} +/// Checks if two BigSizes contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn BigSize_eq(a: &BigSize, b: &BigSize) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} +#[no_mangle] +/// Serialize the BigSize object into a byte array which can be read by BigSize_read +pub extern "C" fn BigSize_write(obj: &crate::lightning::util::ser::BigSize) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[no_mangle] +pub(crate) extern "C" fn BigSize_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeBigSize) }) +} +#[no_mangle] +/// Read a BigSize from a byte array, created by BigSize_write +pub extern "C" fn BigSize_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_BigSizeDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::util::ser::BigSize { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} use lightning::util::ser::Hostname as nativeHostnameImport; pub(crate) type nativeHostname = nativeHostnameImport; @@ -191,3 +245,135 @@ pub extern "C" fn Hostname_len(this_arg: &crate::lightning::util::ser::Hostname) ret } +#[no_mangle] +/// Serialize the Hostname object into a byte array which can be read by Hostname_read +pub extern "C" fn Hostname_write(obj: &crate::lightning::util::ser::Hostname) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[no_mangle] +pub(crate) extern "C" fn Hostname_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeHostname) }) +} +#[no_mangle] +/// Read a Hostname from a byte array, created by Hostname_write +pub extern "C" fn Hostname_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_HostnameDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::util::ser::Hostname { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} + +use lightning::util::ser::TransactionU16LenLimited as nativeTransactionU16LenLimitedImport; +pub(crate) type nativeTransactionU16LenLimited = nativeTransactionU16LenLimitedImport; + +/// A wrapper for a `Transaction` which can only be constructed with [`TransactionU16LenLimited::new`] +/// if the `Transaction`'s consensus-serialized length is <= u16::MAX. +/// +/// Use [`TransactionU16LenLimited::into_transaction`] to convert into the contained `Transaction`. +#[must_use] +#[repr(C)] +pub struct TransactionU16LenLimited { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeTransactionU16LenLimited, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl Drop for TransactionU16LenLimited { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeTransactionU16LenLimited>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the TransactionU16LenLimited, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn TransactionU16LenLimited_free(this_obj: TransactionU16LenLimited) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn TransactionU16LenLimited_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTransactionU16LenLimited) }; +} +#[allow(unused)] +impl TransactionU16LenLimited { + pub(crate) fn get_native_ref(&self) -> &'static nativeTransactionU16LenLimited { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTransactionU16LenLimited { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeTransactionU16LenLimited { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +impl Clone for TransactionU16LenLimited { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeTransactionU16LenLimited>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn TransactionU16LenLimited_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeTransactionU16LenLimited)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the TransactionU16LenLimited +pub extern "C" fn TransactionU16LenLimited_clone(orig: &TransactionU16LenLimited) -> TransactionU16LenLimited { + orig.clone() +} +/// Checks if two TransactionU16LenLimiteds contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn TransactionU16LenLimited_eq(a: &TransactionU16LenLimited, b: &TransactionU16LenLimited) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} +/// Constructs a new `TransactionU16LenLimited` from a `Transaction` only if it's consensus- +/// serialized length is <= u16::MAX. +#[must_use] +#[no_mangle] +pub extern "C" fn TransactionU16LenLimited_new(mut transaction: crate::c_types::Transaction) -> crate::c_types::derived::CResult_TransactionU16LenLimitedNoneZ { + let mut ret = lightning::util::ser::TransactionU16LenLimited::new(transaction.into_bitcoin()); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::util::ser::TransactionU16LenLimited { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Consumes this `TransactionU16LenLimited` and returns its contained `Transaction`. +#[must_use] +#[no_mangle] +pub extern "C" fn TransactionU16LenLimited_into_transaction(mut this_arg: crate::lightning::util::ser::TransactionU16LenLimited) -> crate::c_types::Transaction { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).into_transaction(); + crate::c_types::Transaction::from_bitcoin(&ret) +} + +#[no_mangle] +/// Serialize the TransactionU16LenLimited object into a byte array which can be read by TransactionU16LenLimited_read +pub extern "C" fn TransactionU16LenLimited_write(obj: &crate::lightning::util::ser::TransactionU16LenLimited) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[no_mangle] +pub(crate) extern "C" fn TransactionU16LenLimited_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTransactionU16LenLimited) }) +} +#[no_mangle] +/// Read a TransactionU16LenLimited from a byte array, created by TransactionU16LenLimited_write +pub extern "C" fn TransactionU16LenLimited_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TransactionU16LenLimitedDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::util::ser::TransactionU16LenLimited { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} diff --git a/lightning-c-bindings/src/lightning_background_processor.rs b/lightning-c-bindings/src/lightning_background_processor.rs index 4b8360bf..d226dfaf 100644 --- a/lightning-c-bindings/src/lightning_background_processor.rs +++ b/lightning-c-bindings/src/lightning_background_processor.rs @@ -46,6 +46,8 @@ pub(crate) type nativeBackgroundProcessor = nativeBackgroundProcessorImport; /// /// [`ChannelMonitor`]: lightning::chain::channelmonitor::ChannelMonitor /// [`Event`]: lightning::events::Event +/// [`PeerManager::timer_tick_occurred`]: lightning::ln::peer_handler::PeerManager::timer_tick_occurred +/// [`PeerManager::process_events`]: lightning::ln::peer_handler::PeerManager::process_events ///BackgroundProcessor will immediately stop on drop. It should be stored until shutdown. #[must_use] #[repr(C)] diff --git a/lightning-c-bindings/src/lightning_invoice/mod.rs b/lightning-c-bindings/src/lightning_invoice/mod.rs index 6fb6248f..4e8da728 100644 --- a/lightning-c-bindings/src/lightning_invoice/mod.rs +++ b/lightning-c-bindings/src/lightning_invoice/mod.rs @@ -11,11 +11,11 @@ //! invoices and functions to create, encode and decode these. If you just want to use the standard //! en-/decoding functionality this should get you started: //! -//! * For parsing use `str::parse::(&self)` (see [`Invoice::from_str`]) +//! * For parsing use `str::parse::(&self)` (see [`Bolt11Invoice::from_str`]) //! * For constructing invoices use the [`InvoiceBuilder`] //! * For serializing invoices use the [`Display`]/[`ToString`] traits //! -//! [`Invoice::from_str`]: crate::Invoice#impl-FromStr +//! [`Bolt11Invoice::from_str`]: crate::Bolt11Invoice#impl-FromStr use alloc::str::FromStr; use core::ffi::c_void; @@ -62,7 +62,7 @@ use alloc::{vec::Vec, boxed::Box}; } #[no_mangle] /// Read a SiPrefix object from a string -pub extern "C" fn SiPrefix_from_str(s: crate::c_types::Str) -> crate::c_types::derived::CResult_SiPrefixParseErrorZ { +pub extern "C" fn SiPrefix_from_str(s: crate::c_types::Str) -> crate::c_types::derived::CResult_SiPrefixBolt11ParseErrorZ { match lightning_invoice::SiPrefix::from_str(s.into_str()) { Ok(r) => { crate::c_types::CResultTempl::ok( @@ -71,18 +71,18 @@ pub extern "C" fn SiPrefix_from_str(s: crate::c_types::Str) -> crate::c_types::d }, Err(e) => { crate::c_types::CResultTempl::err( - crate::lightning_invoice::ParseError::native_into(e) + crate::lightning_invoice::Bolt11ParseError::native_into(e) ) }, }.into() } #[no_mangle] -/// Read a Invoice object from a string -pub extern "C" fn Invoice_from_str(s: crate::c_types::Str) -> crate::c_types::derived::CResult_InvoiceParseOrSemanticErrorZ { - match lightning_invoice::Invoice::from_str(s.into_str()) { +/// Read a Bolt11Invoice object from a string +pub extern "C" fn Bolt11Invoice_from_str(s: crate::c_types::Str) -> crate::c_types::derived::CResult_Bolt11InvoiceParseOrSemanticErrorZ { + match lightning_invoice::Bolt11Invoice::from_str(s.into_str()) { Ok(r) => { crate::c_types::CResultTempl::ok( - crate::lightning_invoice::Invoice { inner: ObjOps::heap_alloc(r), is_owned: true } + crate::lightning_invoice::Bolt11Invoice { inner: ObjOps::heap_alloc(r), is_owned: true } ) }, Err(e) => { @@ -93,24 +93,24 @@ pub extern "C" fn Invoice_from_str(s: crate::c_types::Str) -> crate::c_types::de }.into() } #[no_mangle] -/// Read a SignedRawInvoice object from a string -pub extern "C" fn SignedRawInvoice_from_str(s: crate::c_types::Str) -> crate::c_types::derived::CResult_SignedRawInvoiceParseErrorZ { - match lightning_invoice::SignedRawInvoice::from_str(s.into_str()) { +/// Read a SignedRawBolt11Invoice object from a string +pub extern "C" fn SignedRawBolt11Invoice_from_str(s: crate::c_types::Str) -> crate::c_types::derived::CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ { + match lightning_invoice::SignedRawBolt11Invoice::from_str(s.into_str()) { Ok(r) => { crate::c_types::CResultTempl::ok( - crate::lightning_invoice::SignedRawInvoice { inner: ObjOps::heap_alloc(r), is_owned: true } + crate::lightning_invoice::SignedRawBolt11Invoice { inner: ObjOps::heap_alloc(r), is_owned: true } ) }, Err(e) => { crate::c_types::CResultTempl::err( - crate::lightning_invoice::ParseError::native_into(e) + crate::lightning_invoice::Bolt11ParseError::native_into(e) ) }, }.into() } #[no_mangle] -/// Get the string representation of a ParseError object -pub extern "C" fn ParseError_to_str(o: &crate::lightning_invoice::ParseError) -> Str { +/// Get the string representation of a Bolt11ParseError object +pub extern "C" fn Bolt11ParseError_to_str(o: &crate::lightning_invoice::Bolt11ParseError) -> Str { alloc::format!("{}", &o.to_native()).into() } #[no_mangle] @@ -130,13 +130,13 @@ use crate::c_types::*; use alloc::{vec::Vec, boxed::Box}; #[no_mangle] -/// Get the string representation of a Invoice object -pub extern "C" fn Invoice_to_str(o: &crate::lightning_invoice::Invoice) -> Str { +/// Get the string representation of a Bolt11Invoice object +pub extern "C" fn Bolt11Invoice_to_str(o: &crate::lightning_invoice::Bolt11Invoice) -> Str { alloc::format!("{}", o.get_native_ref()).into() } #[no_mangle] -/// Get the string representation of a SignedRawInvoice object -pub extern "C" fn SignedRawInvoice_to_str(o: &crate::lightning_invoice::SignedRawInvoice) -> Str { +/// Get the string representation of a SignedRawBolt11Invoice object +pub extern "C" fn SignedRawBolt11Invoice_to_str(o: &crate::lightning_invoice::SignedRawBolt11Invoice) -> Str { alloc::format!("{}", o.get_native_ref()).into() } #[no_mangle] @@ -188,7 +188,7 @@ use alloc::{vec::Vec, boxed::Box}; #[derive(Clone)] #[must_use] #[repr(C)] -pub enum ParseError { +pub enum Bolt11ParseError { Bech32Error( crate::c_types::Bech32Error), ParseAmountError( @@ -215,282 +215,282 @@ pub enum ParseError { /// according to BOLT11 Skip, } -use lightning_invoice::ParseError as ParseErrorImport; -pub(crate) type nativeParseError = ParseErrorImport; +use lightning_invoice::Bolt11ParseError as Bolt11ParseErrorImport; +pub(crate) type nativeBolt11ParseError = Bolt11ParseErrorImport; -impl ParseError { +impl Bolt11ParseError { #[allow(unused)] - pub(crate) fn to_native(&self) -> nativeParseError { + pub(crate) fn to_native(&self) -> nativeBolt11ParseError { match self { - ParseError::Bech32Error (ref a, ) => { + Bolt11ParseError::Bech32Error (ref a, ) => { let mut a_nonref = Clone::clone(a); - nativeParseError::Bech32Error ( + nativeBolt11ParseError::Bech32Error ( a_nonref.into_rust(), ) }, - ParseError::ParseAmountError (ref a, ) => { + Bolt11ParseError::ParseAmountError (ref a, ) => { let mut a_nonref = Clone::clone(a); - nativeParseError::ParseAmountError ( + nativeBolt11ParseError::ParseAmountError ( u8::from_str_radix(" a", 10).unwrap_err() /*a_nonref*/, ) }, - ParseError::MalformedSignature (ref a, ) => { + Bolt11ParseError::MalformedSignature (ref a, ) => { let mut a_nonref = Clone::clone(a); - nativeParseError::MalformedSignature ( + nativeBolt11ParseError::MalformedSignature ( a_nonref.into_rust(), ) }, - ParseError::BadPrefix => nativeParseError::BadPrefix, - ParseError::UnknownCurrency => nativeParseError::UnknownCurrency, - ParseError::UnknownSiPrefix => nativeParseError::UnknownSiPrefix, - ParseError::MalformedHRP => nativeParseError::MalformedHRP, - ParseError::TooShortDataPart => nativeParseError::TooShortDataPart, - ParseError::UnexpectedEndOfTaggedFields => nativeParseError::UnexpectedEndOfTaggedFields, - ParseError::DescriptionDecodeError (ref a, ) => { + Bolt11ParseError::BadPrefix => nativeBolt11ParseError::BadPrefix, + Bolt11ParseError::UnknownCurrency => nativeBolt11ParseError::UnknownCurrency, + Bolt11ParseError::UnknownSiPrefix => nativeBolt11ParseError::UnknownSiPrefix, + Bolt11ParseError::MalformedHRP => nativeBolt11ParseError::MalformedHRP, + Bolt11ParseError::TooShortDataPart => nativeBolt11ParseError::TooShortDataPart, + Bolt11ParseError::UnexpectedEndOfTaggedFields => nativeBolt11ParseError::UnexpectedEndOfTaggedFields, + Bolt11ParseError::DescriptionDecodeError (ref a, ) => { let mut a_nonref = Clone::clone(a); - nativeParseError::DescriptionDecodeError ( + nativeBolt11ParseError::DescriptionDecodeError ( core::str::from_utf8(&[0xff]).unwrap_err() /*a_nonref*/, ) }, - ParseError::PaddingError => nativeParseError::PaddingError, - ParseError::IntegerOverflowError => nativeParseError::IntegerOverflowError, - ParseError::InvalidSegWitProgramLength => nativeParseError::InvalidSegWitProgramLength, - ParseError::InvalidPubKeyHashLength => nativeParseError::InvalidPubKeyHashLength, - ParseError::InvalidScriptHashLength => nativeParseError::InvalidScriptHashLength, - ParseError::InvalidRecoveryId => nativeParseError::InvalidRecoveryId, - ParseError::InvalidSliceLength (ref a, ) => { + Bolt11ParseError::PaddingError => nativeBolt11ParseError::PaddingError, + Bolt11ParseError::IntegerOverflowError => nativeBolt11ParseError::IntegerOverflowError, + Bolt11ParseError::InvalidSegWitProgramLength => nativeBolt11ParseError::InvalidSegWitProgramLength, + Bolt11ParseError::InvalidPubKeyHashLength => nativeBolt11ParseError::InvalidPubKeyHashLength, + Bolt11ParseError::InvalidScriptHashLength => nativeBolt11ParseError::InvalidScriptHashLength, + Bolt11ParseError::InvalidRecoveryId => nativeBolt11ParseError::InvalidRecoveryId, + Bolt11ParseError::InvalidSliceLength (ref a, ) => { let mut a_nonref = Clone::clone(a); - nativeParseError::InvalidSliceLength ( + nativeBolt11ParseError::InvalidSliceLength ( a_nonref.into_string(), ) }, - ParseError::Skip => nativeParseError::Skip, + Bolt11ParseError::Skip => nativeBolt11ParseError::Skip, } } #[allow(unused)] - pub(crate) fn into_native(self) -> nativeParseError { + pub(crate) fn into_native(self) -> nativeBolt11ParseError { match self { - ParseError::Bech32Error (mut a, ) => { - nativeParseError::Bech32Error ( + Bolt11ParseError::Bech32Error (mut a, ) => { + nativeBolt11ParseError::Bech32Error ( a.into_rust(), ) }, - ParseError::ParseAmountError (mut a, ) => { - nativeParseError::ParseAmountError ( + Bolt11ParseError::ParseAmountError (mut a, ) => { + nativeBolt11ParseError::ParseAmountError ( u8::from_str_radix(" a", 10).unwrap_err() /*a*/, ) }, - ParseError::MalformedSignature (mut a, ) => { - nativeParseError::MalformedSignature ( + Bolt11ParseError::MalformedSignature (mut a, ) => { + nativeBolt11ParseError::MalformedSignature ( a.into_rust(), ) }, - ParseError::BadPrefix => nativeParseError::BadPrefix, - ParseError::UnknownCurrency => nativeParseError::UnknownCurrency, - ParseError::UnknownSiPrefix => nativeParseError::UnknownSiPrefix, - ParseError::MalformedHRP => nativeParseError::MalformedHRP, - ParseError::TooShortDataPart => nativeParseError::TooShortDataPart, - ParseError::UnexpectedEndOfTaggedFields => nativeParseError::UnexpectedEndOfTaggedFields, - ParseError::DescriptionDecodeError (mut a, ) => { - nativeParseError::DescriptionDecodeError ( + Bolt11ParseError::BadPrefix => nativeBolt11ParseError::BadPrefix, + Bolt11ParseError::UnknownCurrency => nativeBolt11ParseError::UnknownCurrency, + Bolt11ParseError::UnknownSiPrefix => nativeBolt11ParseError::UnknownSiPrefix, + Bolt11ParseError::MalformedHRP => nativeBolt11ParseError::MalformedHRP, + Bolt11ParseError::TooShortDataPart => nativeBolt11ParseError::TooShortDataPart, + Bolt11ParseError::UnexpectedEndOfTaggedFields => nativeBolt11ParseError::UnexpectedEndOfTaggedFields, + Bolt11ParseError::DescriptionDecodeError (mut a, ) => { + nativeBolt11ParseError::DescriptionDecodeError ( core::str::from_utf8(&[0xff]).unwrap_err() /*a*/, ) }, - ParseError::PaddingError => nativeParseError::PaddingError, - ParseError::IntegerOverflowError => nativeParseError::IntegerOverflowError, - ParseError::InvalidSegWitProgramLength => nativeParseError::InvalidSegWitProgramLength, - ParseError::InvalidPubKeyHashLength => nativeParseError::InvalidPubKeyHashLength, - ParseError::InvalidScriptHashLength => nativeParseError::InvalidScriptHashLength, - ParseError::InvalidRecoveryId => nativeParseError::InvalidRecoveryId, - ParseError::InvalidSliceLength (mut a, ) => { - nativeParseError::InvalidSliceLength ( + Bolt11ParseError::PaddingError => nativeBolt11ParseError::PaddingError, + Bolt11ParseError::IntegerOverflowError => nativeBolt11ParseError::IntegerOverflowError, + Bolt11ParseError::InvalidSegWitProgramLength => nativeBolt11ParseError::InvalidSegWitProgramLength, + Bolt11ParseError::InvalidPubKeyHashLength => nativeBolt11ParseError::InvalidPubKeyHashLength, + Bolt11ParseError::InvalidScriptHashLength => nativeBolt11ParseError::InvalidScriptHashLength, + Bolt11ParseError::InvalidRecoveryId => nativeBolt11ParseError::InvalidRecoveryId, + Bolt11ParseError::InvalidSliceLength (mut a, ) => { + nativeBolt11ParseError::InvalidSliceLength ( a.into_string(), ) }, - ParseError::Skip => nativeParseError::Skip, + Bolt11ParseError::Skip => nativeBolt11ParseError::Skip, } } #[allow(unused)] - pub(crate) fn from_native(native: &nativeParseError) -> Self { + pub(crate) fn from_native(native: &nativeBolt11ParseError) -> Self { match native { - nativeParseError::Bech32Error (ref a, ) => { + nativeBolt11ParseError::Bech32Error (ref a, ) => { let mut a_nonref = Clone::clone(a); - ParseError::Bech32Error ( + Bolt11ParseError::Bech32Error ( crate::c_types::Bech32Error::from_rust(a_nonref), ) }, - nativeParseError::ParseAmountError (ref a, ) => { + nativeBolt11ParseError::ParseAmountError (ref a, ) => { let mut a_nonref = Clone::clone(a); - ParseError::ParseAmountError ( + Bolt11ParseError::ParseAmountError ( crate::c_types::Error { _dummy: 0 } /*a_nonref*/, ) }, - nativeParseError::MalformedSignature (ref a, ) => { + nativeBolt11ParseError::MalformedSignature (ref a, ) => { let mut a_nonref = Clone::clone(a); - ParseError::MalformedSignature ( + Bolt11ParseError::MalformedSignature ( crate::c_types::Secp256k1Error::from_rust(a_nonref), ) }, - nativeParseError::BadPrefix => ParseError::BadPrefix, - nativeParseError::UnknownCurrency => ParseError::UnknownCurrency, - nativeParseError::UnknownSiPrefix => ParseError::UnknownSiPrefix, - nativeParseError::MalformedHRP => ParseError::MalformedHRP, - nativeParseError::TooShortDataPart => ParseError::TooShortDataPart, - nativeParseError::UnexpectedEndOfTaggedFields => ParseError::UnexpectedEndOfTaggedFields, - nativeParseError::DescriptionDecodeError (ref a, ) => { + nativeBolt11ParseError::BadPrefix => Bolt11ParseError::BadPrefix, + nativeBolt11ParseError::UnknownCurrency => Bolt11ParseError::UnknownCurrency, + nativeBolt11ParseError::UnknownSiPrefix => Bolt11ParseError::UnknownSiPrefix, + nativeBolt11ParseError::MalformedHRP => Bolt11ParseError::MalformedHRP, + nativeBolt11ParseError::TooShortDataPart => Bolt11ParseError::TooShortDataPart, + nativeBolt11ParseError::UnexpectedEndOfTaggedFields => Bolt11ParseError::UnexpectedEndOfTaggedFields, + nativeBolt11ParseError::DescriptionDecodeError (ref a, ) => { let mut a_nonref = Clone::clone(a); - ParseError::DescriptionDecodeError ( + Bolt11ParseError::DescriptionDecodeError ( crate::c_types::Error { _dummy: 0 } /*a_nonref*/, ) }, - nativeParseError::PaddingError => ParseError::PaddingError, - nativeParseError::IntegerOverflowError => ParseError::IntegerOverflowError, - nativeParseError::InvalidSegWitProgramLength => ParseError::InvalidSegWitProgramLength, - nativeParseError::InvalidPubKeyHashLength => ParseError::InvalidPubKeyHashLength, - nativeParseError::InvalidScriptHashLength => ParseError::InvalidScriptHashLength, - nativeParseError::InvalidRecoveryId => ParseError::InvalidRecoveryId, - nativeParseError::InvalidSliceLength (ref a, ) => { + nativeBolt11ParseError::PaddingError => Bolt11ParseError::PaddingError, + nativeBolt11ParseError::IntegerOverflowError => Bolt11ParseError::IntegerOverflowError, + nativeBolt11ParseError::InvalidSegWitProgramLength => Bolt11ParseError::InvalidSegWitProgramLength, + nativeBolt11ParseError::InvalidPubKeyHashLength => Bolt11ParseError::InvalidPubKeyHashLength, + nativeBolt11ParseError::InvalidScriptHashLength => Bolt11ParseError::InvalidScriptHashLength, + nativeBolt11ParseError::InvalidRecoveryId => Bolt11ParseError::InvalidRecoveryId, + nativeBolt11ParseError::InvalidSliceLength (ref a, ) => { let mut a_nonref = Clone::clone(a); - ParseError::InvalidSliceLength ( + Bolt11ParseError::InvalidSliceLength ( a_nonref.into(), ) }, - nativeParseError::Skip => ParseError::Skip, + nativeBolt11ParseError::Skip => Bolt11ParseError::Skip, } } #[allow(unused)] - pub(crate) fn native_into(native: nativeParseError) -> Self { + pub(crate) fn native_into(native: nativeBolt11ParseError) -> Self { match native { - nativeParseError::Bech32Error (mut a, ) => { - ParseError::Bech32Error ( + nativeBolt11ParseError::Bech32Error (mut a, ) => { + Bolt11ParseError::Bech32Error ( crate::c_types::Bech32Error::from_rust(a), ) }, - nativeParseError::ParseAmountError (mut a, ) => { - ParseError::ParseAmountError ( + nativeBolt11ParseError::ParseAmountError (mut a, ) => { + Bolt11ParseError::ParseAmountError ( crate::c_types::Error { _dummy: 0 } /*a*/, ) }, - nativeParseError::MalformedSignature (mut a, ) => { - ParseError::MalformedSignature ( + nativeBolt11ParseError::MalformedSignature (mut a, ) => { + Bolt11ParseError::MalformedSignature ( crate::c_types::Secp256k1Error::from_rust(a), ) }, - nativeParseError::BadPrefix => ParseError::BadPrefix, - nativeParseError::UnknownCurrency => ParseError::UnknownCurrency, - nativeParseError::UnknownSiPrefix => ParseError::UnknownSiPrefix, - nativeParseError::MalformedHRP => ParseError::MalformedHRP, - nativeParseError::TooShortDataPart => ParseError::TooShortDataPart, - nativeParseError::UnexpectedEndOfTaggedFields => ParseError::UnexpectedEndOfTaggedFields, - nativeParseError::DescriptionDecodeError (mut a, ) => { - ParseError::DescriptionDecodeError ( + nativeBolt11ParseError::BadPrefix => Bolt11ParseError::BadPrefix, + nativeBolt11ParseError::UnknownCurrency => Bolt11ParseError::UnknownCurrency, + nativeBolt11ParseError::UnknownSiPrefix => Bolt11ParseError::UnknownSiPrefix, + nativeBolt11ParseError::MalformedHRP => Bolt11ParseError::MalformedHRP, + nativeBolt11ParseError::TooShortDataPart => Bolt11ParseError::TooShortDataPart, + nativeBolt11ParseError::UnexpectedEndOfTaggedFields => Bolt11ParseError::UnexpectedEndOfTaggedFields, + nativeBolt11ParseError::DescriptionDecodeError (mut a, ) => { + Bolt11ParseError::DescriptionDecodeError ( crate::c_types::Error { _dummy: 0 } /*a*/, ) }, - nativeParseError::PaddingError => ParseError::PaddingError, - nativeParseError::IntegerOverflowError => ParseError::IntegerOverflowError, - nativeParseError::InvalidSegWitProgramLength => ParseError::InvalidSegWitProgramLength, - nativeParseError::InvalidPubKeyHashLength => ParseError::InvalidPubKeyHashLength, - nativeParseError::InvalidScriptHashLength => ParseError::InvalidScriptHashLength, - nativeParseError::InvalidRecoveryId => ParseError::InvalidRecoveryId, - nativeParseError::InvalidSliceLength (mut a, ) => { - ParseError::InvalidSliceLength ( + nativeBolt11ParseError::PaddingError => Bolt11ParseError::PaddingError, + nativeBolt11ParseError::IntegerOverflowError => Bolt11ParseError::IntegerOverflowError, + nativeBolt11ParseError::InvalidSegWitProgramLength => Bolt11ParseError::InvalidSegWitProgramLength, + nativeBolt11ParseError::InvalidPubKeyHashLength => Bolt11ParseError::InvalidPubKeyHashLength, + nativeBolt11ParseError::InvalidScriptHashLength => Bolt11ParseError::InvalidScriptHashLength, + nativeBolt11ParseError::InvalidRecoveryId => Bolt11ParseError::InvalidRecoveryId, + nativeBolt11ParseError::InvalidSliceLength (mut a, ) => { + Bolt11ParseError::InvalidSliceLength ( a.into(), ) }, - nativeParseError::Skip => ParseError::Skip, + nativeBolt11ParseError::Skip => Bolt11ParseError::Skip, } } } -/// Frees any resources used by the ParseError +/// Frees any resources used by the Bolt11ParseError #[no_mangle] -pub extern "C" fn ParseError_free(this_ptr: ParseError) { } -/// Creates a copy of the ParseError +pub extern "C" fn Bolt11ParseError_free(this_ptr: Bolt11ParseError) { } +/// Creates a copy of the Bolt11ParseError #[no_mangle] -pub extern "C" fn ParseError_clone(orig: &ParseError) -> ParseError { +pub extern "C" fn Bolt11ParseError_clone(orig: &Bolt11ParseError) -> Bolt11ParseError { orig.clone() } #[no_mangle] -/// Utility method to constructs a new Bech32Error-variant ParseError -pub extern "C" fn ParseError_bech32_error(a: crate::c_types::Bech32Error) -> ParseError { - ParseError::Bech32Error(a, ) +/// Utility method to constructs a new Bech32Error-variant Bolt11ParseError +pub extern "C" fn Bolt11ParseError_bech32_error(a: crate::c_types::Bech32Error) -> Bolt11ParseError { + Bolt11ParseError::Bech32Error(a, ) } #[no_mangle] -/// Utility method to constructs a new ParseAmountError-variant ParseError -pub extern "C" fn ParseError_parse_amount_error(a: crate::c_types::Error) -> ParseError { - ParseError::ParseAmountError(a, ) +/// Utility method to constructs a new ParseAmountError-variant Bolt11ParseError +pub extern "C" fn Bolt11ParseError_parse_amount_error(a: crate::c_types::Error) -> Bolt11ParseError { + Bolt11ParseError::ParseAmountError(a, ) } #[no_mangle] -/// Utility method to constructs a new MalformedSignature-variant ParseError -pub extern "C" fn ParseError_malformed_signature(a: crate::c_types::Secp256k1Error) -> ParseError { - ParseError::MalformedSignature(a, ) +/// Utility method to constructs a new MalformedSignature-variant Bolt11ParseError +pub extern "C" fn Bolt11ParseError_malformed_signature(a: crate::c_types::Secp256k1Error) -> Bolt11ParseError { + Bolt11ParseError::MalformedSignature(a, ) } #[no_mangle] -/// Utility method to constructs a new BadPrefix-variant ParseError -pub extern "C" fn ParseError_bad_prefix() -> ParseError { - ParseError::BadPrefix} +/// Utility method to constructs a new BadPrefix-variant Bolt11ParseError +pub extern "C" fn Bolt11ParseError_bad_prefix() -> Bolt11ParseError { + Bolt11ParseError::BadPrefix} #[no_mangle] -/// Utility method to constructs a new UnknownCurrency-variant ParseError -pub extern "C" fn ParseError_unknown_currency() -> ParseError { - ParseError::UnknownCurrency} +/// Utility method to constructs a new UnknownCurrency-variant Bolt11ParseError +pub extern "C" fn Bolt11ParseError_unknown_currency() -> Bolt11ParseError { + Bolt11ParseError::UnknownCurrency} #[no_mangle] -/// Utility method to constructs a new UnknownSiPrefix-variant ParseError -pub extern "C" fn ParseError_unknown_si_prefix() -> ParseError { - ParseError::UnknownSiPrefix} +/// Utility method to constructs a new UnknownSiPrefix-variant Bolt11ParseError +pub extern "C" fn Bolt11ParseError_unknown_si_prefix() -> Bolt11ParseError { + Bolt11ParseError::UnknownSiPrefix} #[no_mangle] -/// Utility method to constructs a new MalformedHRP-variant ParseError -pub extern "C" fn ParseError_malformed_hrp() -> ParseError { - ParseError::MalformedHRP} +/// Utility method to constructs a new MalformedHRP-variant Bolt11ParseError +pub extern "C" fn Bolt11ParseError_malformed_hrp() -> Bolt11ParseError { + Bolt11ParseError::MalformedHRP} #[no_mangle] -/// Utility method to constructs a new TooShortDataPart-variant ParseError -pub extern "C" fn ParseError_too_short_data_part() -> ParseError { - ParseError::TooShortDataPart} +/// Utility method to constructs a new TooShortDataPart-variant Bolt11ParseError +pub extern "C" fn Bolt11ParseError_too_short_data_part() -> Bolt11ParseError { + Bolt11ParseError::TooShortDataPart} #[no_mangle] -/// Utility method to constructs a new UnexpectedEndOfTaggedFields-variant ParseError -pub extern "C" fn ParseError_unexpected_end_of_tagged_fields() -> ParseError { - ParseError::UnexpectedEndOfTaggedFields} +/// Utility method to constructs a new UnexpectedEndOfTaggedFields-variant Bolt11ParseError +pub extern "C" fn Bolt11ParseError_unexpected_end_of_tagged_fields() -> Bolt11ParseError { + Bolt11ParseError::UnexpectedEndOfTaggedFields} #[no_mangle] -/// Utility method to constructs a new DescriptionDecodeError-variant ParseError -pub extern "C" fn ParseError_description_decode_error(a: crate::c_types::Error) -> ParseError { - ParseError::DescriptionDecodeError(a, ) +/// Utility method to constructs a new DescriptionDecodeError-variant Bolt11ParseError +pub extern "C" fn Bolt11ParseError_description_decode_error(a: crate::c_types::Error) -> Bolt11ParseError { + Bolt11ParseError::DescriptionDecodeError(a, ) } #[no_mangle] -/// Utility method to constructs a new PaddingError-variant ParseError -pub extern "C" fn ParseError_padding_error() -> ParseError { - ParseError::PaddingError} +/// Utility method to constructs a new PaddingError-variant Bolt11ParseError +pub extern "C" fn Bolt11ParseError_padding_error() -> Bolt11ParseError { + Bolt11ParseError::PaddingError} #[no_mangle] -/// Utility method to constructs a new IntegerOverflowError-variant ParseError -pub extern "C" fn ParseError_integer_overflow_error() -> ParseError { - ParseError::IntegerOverflowError} +/// Utility method to constructs a new IntegerOverflowError-variant Bolt11ParseError +pub extern "C" fn Bolt11ParseError_integer_overflow_error() -> Bolt11ParseError { + Bolt11ParseError::IntegerOverflowError} #[no_mangle] -/// Utility method to constructs a new InvalidSegWitProgramLength-variant ParseError -pub extern "C" fn ParseError_invalid_seg_wit_program_length() -> ParseError { - ParseError::InvalidSegWitProgramLength} +/// Utility method to constructs a new InvalidSegWitProgramLength-variant Bolt11ParseError +pub extern "C" fn Bolt11ParseError_invalid_seg_wit_program_length() -> Bolt11ParseError { + Bolt11ParseError::InvalidSegWitProgramLength} #[no_mangle] -/// Utility method to constructs a new InvalidPubKeyHashLength-variant ParseError -pub extern "C" fn ParseError_invalid_pub_key_hash_length() -> ParseError { - ParseError::InvalidPubKeyHashLength} +/// Utility method to constructs a new InvalidPubKeyHashLength-variant Bolt11ParseError +pub extern "C" fn Bolt11ParseError_invalid_pub_key_hash_length() -> Bolt11ParseError { + Bolt11ParseError::InvalidPubKeyHashLength} #[no_mangle] -/// Utility method to constructs a new InvalidScriptHashLength-variant ParseError -pub extern "C" fn ParseError_invalid_script_hash_length() -> ParseError { - ParseError::InvalidScriptHashLength} +/// Utility method to constructs a new InvalidScriptHashLength-variant Bolt11ParseError +pub extern "C" fn Bolt11ParseError_invalid_script_hash_length() -> Bolt11ParseError { + Bolt11ParseError::InvalidScriptHashLength} #[no_mangle] -/// Utility method to constructs a new InvalidRecoveryId-variant ParseError -pub extern "C" fn ParseError_invalid_recovery_id() -> ParseError { - ParseError::InvalidRecoveryId} +/// Utility method to constructs a new InvalidRecoveryId-variant Bolt11ParseError +pub extern "C" fn Bolt11ParseError_invalid_recovery_id() -> Bolt11ParseError { + Bolt11ParseError::InvalidRecoveryId} #[no_mangle] -/// Utility method to constructs a new InvalidSliceLength-variant ParseError -pub extern "C" fn ParseError_invalid_slice_length(a: crate::c_types::Str) -> ParseError { - ParseError::InvalidSliceLength(a, ) +/// Utility method to constructs a new InvalidSliceLength-variant Bolt11ParseError +pub extern "C" fn Bolt11ParseError_invalid_slice_length(a: crate::c_types::Str) -> Bolt11ParseError { + Bolt11ParseError::InvalidSliceLength(a, ) } #[no_mangle] -/// Utility method to constructs a new Skip-variant ParseError -pub extern "C" fn ParseError_skip() -> ParseError { - ParseError::Skip} -/// Checks if two ParseErrors contain equal inner contents. +/// Utility method to constructs a new Skip-variant Bolt11ParseError +pub extern "C" fn Bolt11ParseError_skip() -> Bolt11ParseError { + Bolt11ParseError::Skip} +/// Checks if two Bolt11ParseErrors contain equal inner contents. /// This ignores pointers and is_owned flags and looks at the values in fields. #[no_mangle] -pub extern "C" fn ParseError_eq(a: &ParseError, b: &ParseError) -> bool { +pub extern "C" fn Bolt11ParseError_eq(a: &Bolt11ParseError, b: &Bolt11ParseError) -> bool { if &a.to_native() == &b.to_native() { true } else { false } } /// Indicates that something went wrong while parsing or validating the invoice. Parsing errors @@ -502,10 +502,10 @@ pub extern "C" fn ParseError_eq(a: &ParseError, b: &ParseError) -> bool { pub enum ParseOrSemanticError { /// The invoice couldn't be decoded ParseError( - crate::lightning_invoice::ParseError), + crate::lightning_invoice::Bolt11ParseError), /// The invoice could be decoded but violates the BOLT11 standard SemanticError( - crate::lightning_invoice::SemanticError), + crate::lightning_invoice::Bolt11SemanticError), } use lightning_invoice::ParseOrSemanticError as ParseOrSemanticErrorImport; pub(crate) type nativeParseOrSemanticError = ParseOrSemanticErrorImport; @@ -549,13 +549,13 @@ impl ParseOrSemanticError { nativeParseOrSemanticError::ParseError (ref a, ) => { let mut a_nonref = Clone::clone(a); ParseOrSemanticError::ParseError ( - crate::lightning_invoice::ParseError::native_into(a_nonref), + crate::lightning_invoice::Bolt11ParseError::native_into(a_nonref), ) }, nativeParseOrSemanticError::SemanticError (ref a, ) => { let mut a_nonref = Clone::clone(a); ParseOrSemanticError::SemanticError ( - crate::lightning_invoice::SemanticError::native_into(a_nonref), + crate::lightning_invoice::Bolt11SemanticError::native_into(a_nonref), ) }, } @@ -565,12 +565,12 @@ impl ParseOrSemanticError { match native { nativeParseOrSemanticError::ParseError (mut a, ) => { ParseOrSemanticError::ParseError ( - crate::lightning_invoice::ParseError::native_into(a), + crate::lightning_invoice::Bolt11ParseError::native_into(a), ) }, nativeParseOrSemanticError::SemanticError (mut a, ) => { ParseOrSemanticError::SemanticError ( - crate::lightning_invoice::SemanticError::native_into(a), + crate::lightning_invoice::Bolt11SemanticError::native_into(a), ) }, } @@ -586,12 +586,12 @@ pub extern "C" fn ParseOrSemanticError_clone(orig: &ParseOrSemanticError) -> Par } #[no_mangle] /// Utility method to constructs a new ParseError-variant ParseOrSemanticError -pub extern "C" fn ParseOrSemanticError_parse_error(a: crate::lightning_invoice::ParseError) -> ParseOrSemanticError { +pub extern "C" fn ParseOrSemanticError_parse_error(a: crate::lightning_invoice::Bolt11ParseError) -> ParseOrSemanticError { ParseOrSemanticError::ParseError(a, ) } #[no_mangle] /// Utility method to constructs a new SemanticError-variant ParseOrSemanticError -pub extern "C" fn ParseOrSemanticError_semantic_error(a: crate::lightning_invoice::SemanticError) -> ParseOrSemanticError { +pub extern "C" fn ParseOrSemanticError_semantic_error(a: crate::lightning_invoice::Bolt11SemanticError) -> ParseOrSemanticError { ParseOrSemanticError::SemanticError(a, ) } /// Checks if two ParseOrSemanticErrors contain equal inner contents. @@ -623,25 +623,25 @@ pub static DEFAULT_EXPIRY_TIME: u64 = lightning_invoice::DEFAULT_EXPIRY_TIME; #[no_mangle] pub static DEFAULT_MIN_FINAL_CLTV_EXPIRY_DELTA: u64 = lightning_invoice::DEFAULT_MIN_FINAL_CLTV_EXPIRY_DELTA; -use lightning_invoice::Invoice as nativeInvoiceImport; -pub(crate) type nativeInvoice = nativeInvoiceImport; +use lightning_invoice::Bolt11Invoice as nativeBolt11InvoiceImport; +pub(crate) type nativeBolt11Invoice = nativeBolt11InvoiceImport; /// Represents a syntactically and semantically correct lightning BOLT11 invoice. /// -/// There are three ways to construct an `Invoice`: +/// There are three ways to construct a `Bolt11Invoice`: /// 1. using [`InvoiceBuilder`] -/// 2. using [`Invoice::from_signed`] -/// 3. using `str::parse::(&str)` (see [`Invoice::from_str`]) +/// 2. using [`Bolt11Invoice::from_signed`] +/// 3. using `str::parse::(&str)` (see [`Bolt11Invoice::from_str`]) /// -/// [`Invoice::from_str`]: crate::Invoice#impl-FromStr +/// [`Bolt11Invoice::from_str`]: crate::Bolt11Invoice#impl-FromStr #[must_use] #[repr(C)] -pub struct Invoice { +pub struct Bolt11Invoice { /// A pointer to the opaque Rust object. /// Nearly everywhere, inner must be non-null, however in places where /// the Rust equivalent takes an Option, it may be set to null to indicate None. - pub inner: *mut nativeInvoice, + pub inner: *mut nativeBolt11Invoice, /// Indicates that this is the only struct which contains the same pointer. /// Rust functions which take ownership of an object provided via an argument require @@ -649,50 +649,50 @@ pub struct Invoice { pub is_owned: bool, } -impl Drop for Invoice { +impl Drop for Bolt11Invoice { fn drop(&mut self) { - if self.is_owned && !<*mut nativeInvoice>::is_null(self.inner) { + if self.is_owned && !<*mut nativeBolt11Invoice>::is_null(self.inner) { let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; } } } -/// Frees any resources used by the Invoice, if is_owned is set and inner is non-NULL. +/// Frees any resources used by the Bolt11Invoice, if is_owned is set and inner is non-NULL. #[no_mangle] -pub extern "C" fn Invoice_free(this_obj: Invoice) { } +pub extern "C" fn Bolt11Invoice_free(this_obj: Bolt11Invoice) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn Invoice_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeInvoice) }; +pub(crate) extern "C" fn Bolt11Invoice_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeBolt11Invoice) }; } #[allow(unused)] -impl Invoice { - pub(crate) fn get_native_ref(&self) -> &'static nativeInvoice { +impl Bolt11Invoice { + pub(crate) fn get_native_ref(&self) -> &'static nativeBolt11Invoice { unsafe { &*ObjOps::untweak_ptr(self.inner) } } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInvoice { + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeBolt11Invoice { unsafe { &mut *ObjOps::untweak_ptr(self.inner) } } /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy - pub(crate) fn take_inner(mut self) -> *mut nativeInvoice { + pub(crate) fn take_inner(mut self) -> *mut nativeBolt11Invoice { assert!(self.is_owned); let ret = ObjOps::untweak_ptr(self.inner); self.inner = core::ptr::null_mut(); ret } } -/// Checks if two Invoices contain equal inner contents. +/// Checks if two Bolt11Invoices contain equal inner contents. /// This ignores pointers and is_owned flags and looks at the values in fields. /// Two objects with NULL inner values will be considered "equal" here. #[no_mangle] -pub extern "C" fn Invoice_eq(a: &Invoice, b: &Invoice) -> bool { +pub extern "C" fn Bolt11Invoice_eq(a: &Bolt11Invoice, b: &Bolt11Invoice) -> bool { if a.inner == b.inner { return true; } if a.inner.is_null() || b.inner.is_null() { return false; } if a.get_native_ref() == b.get_native_ref() { true } else { false } } -impl Clone for Invoice { +impl Clone for Bolt11Invoice { fn clone(&self) -> Self { Self { - inner: if <*mut nativeInvoice>::is_null(self.inner) { core::ptr::null_mut() } else { + inner: if <*mut nativeBolt11Invoice>::is_null(self.inner) { core::ptr::null_mut() } else { ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, is_owned: true, } @@ -700,17 +700,17 @@ impl Clone for Invoice { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn Invoice_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeInvoice)).clone() })) as *mut c_void +pub(crate) extern "C" fn Bolt11Invoice_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeBolt11Invoice)).clone() })) as *mut c_void } #[no_mangle] -/// Creates a copy of the Invoice -pub extern "C" fn Invoice_clone(orig: &Invoice) -> Invoice { +/// Creates a copy of the Bolt11Invoice +pub extern "C" fn Bolt11Invoice_clone(orig: &Bolt11Invoice) -> Bolt11Invoice { orig.clone() } -/// Generates a non-cryptographic 64-bit hash of the Invoice. +/// Generates a non-cryptographic 64-bit hash of the Bolt11Invoice. #[no_mangle] -pub extern "C" fn Invoice_hash(o: &Invoice) -> u64 { +pub extern "C" fn Bolt11Invoice_hash(o: &Bolt11Invoice) -> u64 { if o.inner.is_null() { return 0; } // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core #[allow(deprecated)] @@ -719,22 +719,22 @@ pub extern "C" fn Invoice_hash(o: &Invoice) -> u64 { core::hash::Hasher::finish(&hasher) } -use lightning_invoice::SignedRawInvoice as nativeSignedRawInvoiceImport; -pub(crate) type nativeSignedRawInvoice = nativeSignedRawInvoiceImport; +use lightning_invoice::SignedRawBolt11Invoice as nativeSignedRawBolt11InvoiceImport; +pub(crate) type nativeSignedRawBolt11Invoice = nativeSignedRawBolt11InvoiceImport; -/// Represents a signed [`RawInvoice`] with cached hash. The signature is not checked and may be +/// Represents a signed [`RawBolt11Invoice`] with cached hash. The signature is not checked and may be /// invalid. /// /// # Invariants -/// The hash has to be either from the deserialized invoice or from the serialized [`RawInvoice`]. +/// The hash has to be either from the deserialized invoice or from the serialized [`RawBolt11Invoice`]. #[must_use] #[repr(C)] -pub struct SignedRawInvoice { +pub struct SignedRawBolt11Invoice { /// A pointer to the opaque Rust object. /// Nearly everywhere, inner must be non-null, however in places where /// the Rust equivalent takes an Option, it may be set to null to indicate None. - pub inner: *mut nativeSignedRawInvoice, + pub inner: *mut nativeSignedRawBolt11Invoice, /// Indicates that this is the only struct which contains the same pointer. /// Rust functions which take ownership of an object provided via an argument require @@ -742,50 +742,50 @@ pub struct SignedRawInvoice { pub is_owned: bool, } -impl Drop for SignedRawInvoice { +impl Drop for SignedRawBolt11Invoice { fn drop(&mut self) { - if self.is_owned && !<*mut nativeSignedRawInvoice>::is_null(self.inner) { + if self.is_owned && !<*mut nativeSignedRawBolt11Invoice>::is_null(self.inner) { let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; } } } -/// Frees any resources used by the SignedRawInvoice, if is_owned is set and inner is non-NULL. +/// Frees any resources used by the SignedRawBolt11Invoice, if is_owned is set and inner is non-NULL. #[no_mangle] -pub extern "C" fn SignedRawInvoice_free(this_obj: SignedRawInvoice) { } +pub extern "C" fn SignedRawBolt11Invoice_free(this_obj: SignedRawBolt11Invoice) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn SignedRawInvoice_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeSignedRawInvoice) }; +pub(crate) extern "C" fn SignedRawBolt11Invoice_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeSignedRawBolt11Invoice) }; } #[allow(unused)] -impl SignedRawInvoice { - pub(crate) fn get_native_ref(&self) -> &'static nativeSignedRawInvoice { +impl SignedRawBolt11Invoice { + pub(crate) fn get_native_ref(&self) -> &'static nativeSignedRawBolt11Invoice { unsafe { &*ObjOps::untweak_ptr(self.inner) } } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeSignedRawInvoice { + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeSignedRawBolt11Invoice { unsafe { &mut *ObjOps::untweak_ptr(self.inner) } } /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy - pub(crate) fn take_inner(mut self) -> *mut nativeSignedRawInvoice { + pub(crate) fn take_inner(mut self) -> *mut nativeSignedRawBolt11Invoice { assert!(self.is_owned); let ret = ObjOps::untweak_ptr(self.inner); self.inner = core::ptr::null_mut(); ret } } -/// Checks if two SignedRawInvoices contain equal inner contents. +/// Checks if two SignedRawBolt11Invoices contain equal inner contents. /// This ignores pointers and is_owned flags and looks at the values in fields. /// Two objects with NULL inner values will be considered "equal" here. #[no_mangle] -pub extern "C" fn SignedRawInvoice_eq(a: &SignedRawInvoice, b: &SignedRawInvoice) -> bool { +pub extern "C" fn SignedRawBolt11Invoice_eq(a: &SignedRawBolt11Invoice, b: &SignedRawBolt11Invoice) -> bool { if a.inner == b.inner { return true; } if a.inner.is_null() || b.inner.is_null() { return false; } if a.get_native_ref() == b.get_native_ref() { true } else { false } } -impl Clone for SignedRawInvoice { +impl Clone for SignedRawBolt11Invoice { fn clone(&self) -> Self { Self { - inner: if <*mut nativeSignedRawInvoice>::is_null(self.inner) { core::ptr::null_mut() } else { + inner: if <*mut nativeSignedRawBolt11Invoice>::is_null(self.inner) { core::ptr::null_mut() } else { ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, is_owned: true, } @@ -793,17 +793,17 @@ impl Clone for SignedRawInvoice { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn SignedRawInvoice_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeSignedRawInvoice)).clone() })) as *mut c_void +pub(crate) extern "C" fn SignedRawBolt11Invoice_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeSignedRawBolt11Invoice)).clone() })) as *mut c_void } #[no_mangle] -/// Creates a copy of the SignedRawInvoice -pub extern "C" fn SignedRawInvoice_clone(orig: &SignedRawInvoice) -> SignedRawInvoice { +/// Creates a copy of the SignedRawBolt11Invoice +pub extern "C" fn SignedRawBolt11Invoice_clone(orig: &SignedRawBolt11Invoice) -> SignedRawBolt11Invoice { orig.clone() } -/// Generates a non-cryptographic 64-bit hash of the SignedRawInvoice. +/// Generates a non-cryptographic 64-bit hash of the SignedRawBolt11Invoice. #[no_mangle] -pub extern "C" fn SignedRawInvoice_hash(o: &SignedRawInvoice) -> u64 { +pub extern "C" fn SignedRawBolt11Invoice_hash(o: &SignedRawBolt11Invoice) -> u64 { if o.inner.is_null() { return 0; } // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core #[allow(deprecated)] @@ -812,22 +812,22 @@ pub extern "C" fn SignedRawInvoice_hash(o: &SignedRawInvoice) -> u64 { core::hash::Hasher::finish(&hasher) } -use lightning_invoice::RawInvoice as nativeRawInvoiceImport; -pub(crate) type nativeRawInvoice = nativeRawInvoiceImport; +use lightning_invoice::RawBolt11Invoice as nativeRawBolt11InvoiceImport; +pub(crate) type nativeRawBolt11Invoice = nativeRawBolt11InvoiceImport; -/// Represents an syntactically correct [`Invoice`] for a payment on the lightning network, +/// Represents an syntactically correct [`Bolt11Invoice`] for a payment on the lightning network, /// but without the signature information. /// Decoding and encoding should not lead to information loss but may lead to different hashes. /// -/// For methods without docs see the corresponding methods in [`Invoice`]. +/// For methods without docs see the corresponding methods in [`Bolt11Invoice`]. #[must_use] #[repr(C)] -pub struct RawInvoice { +pub struct RawBolt11Invoice { /// A pointer to the opaque Rust object. /// Nearly everywhere, inner must be non-null, however in places where /// the Rust equivalent takes an Option, it may be set to null to indicate None. - pub inner: *mut nativeRawInvoice, + pub inner: *mut nativeRawBolt11Invoice, /// Indicates that this is the only struct which contains the same pointer. /// Rust functions which take ownership of an object provided via an argument require @@ -835,31 +835,31 @@ pub struct RawInvoice { pub is_owned: bool, } -impl Drop for RawInvoice { +impl Drop for RawBolt11Invoice { fn drop(&mut self) { - if self.is_owned && !<*mut nativeRawInvoice>::is_null(self.inner) { + if self.is_owned && !<*mut nativeRawBolt11Invoice>::is_null(self.inner) { let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; } } } -/// Frees any resources used by the RawInvoice, if is_owned is set and inner is non-NULL. +/// Frees any resources used by the RawBolt11Invoice, if is_owned is set and inner is non-NULL. #[no_mangle] -pub extern "C" fn RawInvoice_free(this_obj: RawInvoice) { } +pub extern "C" fn RawBolt11Invoice_free(this_obj: RawBolt11Invoice) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn RawInvoice_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeRawInvoice) }; +pub(crate) extern "C" fn RawBolt11Invoice_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeRawBolt11Invoice) }; } #[allow(unused)] -impl RawInvoice { - pub(crate) fn get_native_ref(&self) -> &'static nativeRawInvoice { +impl RawBolt11Invoice { + pub(crate) fn get_native_ref(&self) -> &'static nativeRawBolt11Invoice { unsafe { &*ObjOps::untweak_ptr(self.inner) } } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeRawInvoice { + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeRawBolt11Invoice { unsafe { &mut *ObjOps::untweak_ptr(self.inner) } } /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy - pub(crate) fn take_inner(mut self) -> *mut nativeRawInvoice { + pub(crate) fn take_inner(mut self) -> *mut nativeRawBolt11Invoice { assert!(self.is_owned); let ret = ObjOps::untweak_ptr(self.inner); self.inner = core::ptr::null_mut(); @@ -868,28 +868,28 @@ impl RawInvoice { } /// data part #[no_mangle] -pub extern "C" fn RawInvoice_get_data(this_ptr: &RawInvoice) -> crate::lightning_invoice::RawDataPart { +pub extern "C" fn RawBolt11Invoice_get_data(this_ptr: &RawBolt11Invoice) -> crate::lightning_invoice::RawDataPart { let mut inner_val = &mut this_ptr.get_native_mut_ref().data; crate::lightning_invoice::RawDataPart { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning_invoice::RawDataPart<>) as *mut _) }, is_owned: false } } /// data part #[no_mangle] -pub extern "C" fn RawInvoice_set_data(this_ptr: &mut RawInvoice, mut val: crate::lightning_invoice::RawDataPart) { +pub extern "C" fn RawBolt11Invoice_set_data(this_ptr: &mut RawBolt11Invoice, mut val: crate::lightning_invoice::RawDataPart) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.data = *unsafe { Box::from_raw(val.take_inner()) }; } -/// Checks if two RawInvoices contain equal inner contents. +/// Checks if two RawBolt11Invoices contain equal inner contents. /// This ignores pointers and is_owned flags and looks at the values in fields. /// Two objects with NULL inner values will be considered "equal" here. #[no_mangle] -pub extern "C" fn RawInvoice_eq(a: &RawInvoice, b: &RawInvoice) -> bool { +pub extern "C" fn RawBolt11Invoice_eq(a: &RawBolt11Invoice, b: &RawBolt11Invoice) -> bool { if a.inner == b.inner { return true; } if a.inner.is_null() || b.inner.is_null() { return false; } if a.get_native_ref() == b.get_native_ref() { true } else { false } } -impl Clone for RawInvoice { +impl Clone for RawBolt11Invoice { fn clone(&self) -> Self { Self { - inner: if <*mut nativeRawInvoice>::is_null(self.inner) { core::ptr::null_mut() } else { + inner: if <*mut nativeRawBolt11Invoice>::is_null(self.inner) { core::ptr::null_mut() } else { ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, is_owned: true, } @@ -897,17 +897,17 @@ impl Clone for RawInvoice { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn RawInvoice_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeRawInvoice)).clone() })) as *mut c_void +pub(crate) extern "C" fn RawBolt11Invoice_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeRawBolt11Invoice)).clone() })) as *mut c_void } #[no_mangle] -/// Creates a copy of the RawInvoice -pub extern "C" fn RawInvoice_clone(orig: &RawInvoice) -> RawInvoice { +/// Creates a copy of the RawBolt11Invoice +pub extern "C" fn RawBolt11Invoice_clone(orig: &RawBolt11Invoice) -> RawBolt11Invoice { orig.clone() } -/// Generates a non-cryptographic 64-bit hash of the RawInvoice. +/// Generates a non-cryptographic 64-bit hash of the RawBolt11Invoice. #[no_mangle] -pub extern "C" fn RawInvoice_hash(o: &RawInvoice) -> u64 { +pub extern "C" fn RawBolt11Invoice_hash(o: &RawBolt11Invoice) -> u64 { if o.inner.is_null() { return 0; } // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core #[allow(deprecated)] @@ -919,7 +919,7 @@ pub extern "C" fn RawInvoice_hash(o: &RawInvoice) -> u64 { use lightning_invoice::RawDataPart as nativeRawDataPartImport; pub(crate) type nativeRawDataPart = nativeRawDataPartImport; -/// Data of the [`RawInvoice`] that is encoded in the data part +/// Data of the [`RawBolt11Invoice`] that is encoded in the data part #[must_use] #[repr(C)] pub struct RawDataPart { @@ -1959,18 +1959,18 @@ pub extern "C" fn Fallback_eq(a: &Fallback, b: &Fallback) -> bool { if &a.to_native() == &b.to_native() { true } else { false } } -use lightning_invoice::InvoiceSignature as nativeInvoiceSignatureImport; -pub(crate) type nativeInvoiceSignature = nativeInvoiceSignatureImport; +use lightning_invoice::Bolt11InvoiceSignature as nativeBolt11InvoiceSignatureImport; +pub(crate) type nativeBolt11InvoiceSignature = nativeBolt11InvoiceSignatureImport; /// Recoverable signature #[must_use] #[repr(C)] -pub struct InvoiceSignature { +pub struct Bolt11InvoiceSignature { /// A pointer to the opaque Rust object. /// Nearly everywhere, inner must be non-null, however in places where /// the Rust equivalent takes an Option, it may be set to null to indicate None. - pub inner: *mut nativeInvoiceSignature, + pub inner: *mut nativeBolt11InvoiceSignature, /// Indicates that this is the only struct which contains the same pointer. /// Rust functions which take ownership of an object provided via an argument require @@ -1978,41 +1978,41 @@ pub struct InvoiceSignature { pub is_owned: bool, } -impl Drop for InvoiceSignature { +impl Drop for Bolt11InvoiceSignature { fn drop(&mut self) { - if self.is_owned && !<*mut nativeInvoiceSignature>::is_null(self.inner) { + if self.is_owned && !<*mut nativeBolt11InvoiceSignature>::is_null(self.inner) { let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; } } } -/// Frees any resources used by the InvoiceSignature, if is_owned is set and inner is non-NULL. +/// Frees any resources used by the Bolt11InvoiceSignature, if is_owned is set and inner is non-NULL. #[no_mangle] -pub extern "C" fn InvoiceSignature_free(this_obj: InvoiceSignature) { } +pub extern "C" fn Bolt11InvoiceSignature_free(this_obj: Bolt11InvoiceSignature) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn InvoiceSignature_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeInvoiceSignature) }; +pub(crate) extern "C" fn Bolt11InvoiceSignature_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeBolt11InvoiceSignature) }; } #[allow(unused)] -impl InvoiceSignature { - pub(crate) fn get_native_ref(&self) -> &'static nativeInvoiceSignature { +impl Bolt11InvoiceSignature { + pub(crate) fn get_native_ref(&self) -> &'static nativeBolt11InvoiceSignature { unsafe { &*ObjOps::untweak_ptr(self.inner) } } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInvoiceSignature { + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeBolt11InvoiceSignature { unsafe { &mut *ObjOps::untweak_ptr(self.inner) } } /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy - pub(crate) fn take_inner(mut self) -> *mut nativeInvoiceSignature { + pub(crate) fn take_inner(mut self) -> *mut nativeBolt11InvoiceSignature { assert!(self.is_owned); let ret = ObjOps::untweak_ptr(self.inner); self.inner = core::ptr::null_mut(); ret } } -impl Clone for InvoiceSignature { +impl Clone for Bolt11InvoiceSignature { fn clone(&self) -> Self { Self { - inner: if <*mut nativeInvoiceSignature>::is_null(self.inner) { core::ptr::null_mut() } else { + inner: if <*mut nativeBolt11InvoiceSignature>::is_null(self.inner) { core::ptr::null_mut() } else { ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, is_owned: true, } @@ -2020,17 +2020,17 @@ impl Clone for InvoiceSignature { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn InvoiceSignature_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeInvoiceSignature)).clone() })) as *mut c_void +pub(crate) extern "C" fn Bolt11InvoiceSignature_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeBolt11InvoiceSignature)).clone() })) as *mut c_void } #[no_mangle] -/// Creates a copy of the InvoiceSignature -pub extern "C" fn InvoiceSignature_clone(orig: &InvoiceSignature) -> InvoiceSignature { +/// Creates a copy of the Bolt11InvoiceSignature +pub extern "C" fn Bolt11InvoiceSignature_clone(orig: &Bolt11InvoiceSignature) -> Bolt11InvoiceSignature { orig.clone() } -/// Generates a non-cryptographic 64-bit hash of the InvoiceSignature. +/// Generates a non-cryptographic 64-bit hash of the Bolt11InvoiceSignature. #[no_mangle] -pub extern "C" fn InvoiceSignature_hash(o: &InvoiceSignature) -> u64 { +pub extern "C" fn Bolt11InvoiceSignature_hash(o: &Bolt11InvoiceSignature) -> u64 { if o.inner.is_null() { return 0; } // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core #[allow(deprecated)] @@ -2038,11 +2038,11 @@ pub extern "C" fn InvoiceSignature_hash(o: &InvoiceSignature) -> u64 { core::hash::Hash::hash(o.get_native_ref(), &mut hasher); core::hash::Hasher::finish(&hasher) } -/// Checks if two InvoiceSignatures contain equal inner contents. +/// Checks if two Bolt11InvoiceSignatures contain equal inner contents. /// This ignores pointers and is_owned flags and looks at the values in fields. /// Two objects with NULL inner values will be considered "equal" here. #[no_mangle] -pub extern "C" fn InvoiceSignature_eq(a: &InvoiceSignature, b: &InvoiceSignature) -> bool { +pub extern "C" fn Bolt11InvoiceSignature_eq(a: &Bolt11InvoiceSignature, b: &Bolt11InvoiceSignature) -> bool { if a.inner == b.inner { return true; } if a.inner.is_null() || b.inner.is_null() { return false; } if a.get_native_ref() == b.get_native_ref() { true } else { false } @@ -2140,30 +2140,30 @@ pub extern "C" fn PrivateRoute_eq(a: &PrivateRoute, b: &PrivateRoute) -> bool { if a.inner.is_null() || b.inner.is_null() { return false; } if a.get_native_ref() == b.get_native_ref() { true } else { false } } -/// Disassembles the `SignedRawInvoice` into its three parts: +/// Disassembles the `SignedRawBolt11Invoice` into its three parts: /// 1. raw invoice /// 2. hash of the raw invoice /// 3. signature #[must_use] #[no_mangle] -pub extern "C" fn SignedRawInvoice_into_parts(mut this_arg: crate::lightning_invoice::SignedRawInvoice) -> crate::c_types::derived::C3Tuple_RawInvoice_u832InvoiceSignatureZ { +pub extern "C" fn SignedRawBolt11Invoice_into_parts(mut this_arg: crate::lightning_invoice::SignedRawBolt11Invoice) -> crate::c_types::derived::C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ { let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).into_parts(); - let (mut orig_ret_0, mut orig_ret_1, mut orig_ret_2) = ret; let mut local_ret = (crate::lightning_invoice::RawInvoice { inner: ObjOps::heap_alloc(orig_ret_0), is_owned: true }, crate::c_types::ThirtyTwoBytes { data: orig_ret_1 }, crate::lightning_invoice::InvoiceSignature { inner: ObjOps::heap_alloc(orig_ret_2), is_owned: true }).into(); + let (mut orig_ret_0, mut orig_ret_1, mut orig_ret_2) = ret; let mut local_ret = (crate::lightning_invoice::RawBolt11Invoice { inner: ObjOps::heap_alloc(orig_ret_0), is_owned: true }, crate::c_types::ThirtyTwoBytes { data: orig_ret_1 }, crate::lightning_invoice::Bolt11InvoiceSignature { inner: ObjOps::heap_alloc(orig_ret_2), is_owned: true }).into(); local_ret } -/// The [`RawInvoice`] which was signed. +/// The [`RawBolt11Invoice`] which was signed. #[must_use] #[no_mangle] -pub extern "C" fn SignedRawInvoice_raw_invoice(this_arg: &crate::lightning_invoice::SignedRawInvoice) -> crate::lightning_invoice::RawInvoice { +pub extern "C" fn SignedRawBolt11Invoice_raw_invoice(this_arg: &crate::lightning_invoice::SignedRawBolt11Invoice) -> crate::lightning_invoice::RawBolt11Invoice { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.raw_invoice(); - crate::lightning_invoice::RawInvoice { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning_invoice::RawInvoice<>) as *mut _) }, is_owned: false } + crate::lightning_invoice::RawBolt11Invoice { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning_invoice::RawBolt11Invoice<>) as *mut _) }, is_owned: false } } -/// The hash of the [`RawInvoice`] that was signed. +/// The hash of the [`RawBolt11Invoice`] that was signed. #[must_use] #[no_mangle] -pub extern "C" fn SignedRawInvoice_signable_hash(this_arg: &crate::lightning_invoice::SignedRawInvoice) -> *const [u8; 32] { +pub extern "C" fn SignedRawBolt11Invoice_signable_hash(this_arg: &crate::lightning_invoice::SignedRawBolt11Invoice) -> *const [u8; 32] { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signable_hash(); ret } @@ -2171,15 +2171,15 @@ pub extern "C" fn SignedRawInvoice_signable_hash(this_arg: &crate::lightning_inv /// Signature for the invoice. #[must_use] #[no_mangle] -pub extern "C" fn SignedRawInvoice_signature(this_arg: &crate::lightning_invoice::SignedRawInvoice) -> crate::lightning_invoice::InvoiceSignature { +pub extern "C" fn SignedRawBolt11Invoice_signature(this_arg: &crate::lightning_invoice::SignedRawBolt11Invoice) -> crate::lightning_invoice::Bolt11InvoiceSignature { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signature(); - crate::lightning_invoice::InvoiceSignature { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning_invoice::InvoiceSignature<>) as *mut _) }, is_owned: false } + crate::lightning_invoice::Bolt11InvoiceSignature { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning_invoice::Bolt11InvoiceSignature<>) as *mut _) }, is_owned: false } } /// Recovers the public key used for signing the invoice from the recoverable signature. #[must_use] #[no_mangle] -pub extern "C" fn SignedRawInvoice_recover_payee_pub_key(this_arg: &crate::lightning_invoice::SignedRawInvoice) -> crate::c_types::derived::CResult_PayeePubKeyErrorZ { +pub extern "C" fn SignedRawBolt11Invoice_recover_payee_pub_key(this_arg: &crate::lightning_invoice::SignedRawBolt11Invoice) -> crate::c_types::derived::CResult_PayeePubKeyErrorZ { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.recover_payee_pub_key(); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::PayeePubKey { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::Secp256k1Error::from_rust(e) }).into() }; local_ret @@ -2189,15 +2189,15 @@ pub extern "C" fn SignedRawInvoice_recover_payee_pub_key(this_arg: &crate::light /// valid for the recovered signature (which should always be true?). #[must_use] #[no_mangle] -pub extern "C" fn SignedRawInvoice_check_signature(this_arg: &crate::lightning_invoice::SignedRawInvoice) -> bool { +pub extern "C" fn SignedRawBolt11Invoice_check_signature(this_arg: &crate::lightning_invoice::SignedRawBolt11Invoice) -> bool { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.check_signature(); ret } -/// Calculate the hash of the encoded `RawInvoice` which should be signed. +/// Calculate the hash of the encoded `RawBolt11Invoice` which should be signed. #[must_use] #[no_mangle] -pub extern "C" fn RawInvoice_signable_hash(this_arg: &crate::lightning_invoice::RawInvoice) -> crate::c_types::ThirtyTwoBytes { +pub extern "C" fn RawBolt11Invoice_signable_hash(this_arg: &crate::lightning_invoice::RawBolt11Invoice) -> crate::c_types::ThirtyTwoBytes { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signable_hash(); crate::c_types::ThirtyTwoBytes { data: ret } } @@ -2206,7 +2206,7 @@ pub extern "C" fn RawInvoice_signable_hash(this_arg: &crate::lightning_invoice:: /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn RawInvoice_payment_hash(this_arg: &crate::lightning_invoice::RawInvoice) -> crate::lightning_invoice::Sha256 { +pub extern "C" fn RawBolt11Invoice_payment_hash(this_arg: &crate::lightning_invoice::RawBolt11Invoice) -> crate::lightning_invoice::Sha256 { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payment_hash(); let mut local_ret = crate::lightning_invoice::Sha256 { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning_invoice::Sha256<>) as *mut _ }, is_owned: false }; local_ret @@ -2216,7 +2216,7 @@ pub extern "C" fn RawInvoice_payment_hash(this_arg: &crate::lightning_invoice::R /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn RawInvoice_description(this_arg: &crate::lightning_invoice::RawInvoice) -> crate::lightning_invoice::Description { +pub extern "C" fn RawBolt11Invoice_description(this_arg: &crate::lightning_invoice::RawBolt11Invoice) -> crate::lightning_invoice::Description { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.description(); let mut local_ret = crate::lightning_invoice::Description { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning_invoice::Description<>) as *mut _ }, is_owned: false }; local_ret @@ -2226,7 +2226,7 @@ pub extern "C" fn RawInvoice_description(this_arg: &crate::lightning_invoice::Ra /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn RawInvoice_payee_pub_key(this_arg: &crate::lightning_invoice::RawInvoice) -> crate::lightning_invoice::PayeePubKey { +pub extern "C" fn RawBolt11Invoice_payee_pub_key(this_arg: &crate::lightning_invoice::RawBolt11Invoice) -> crate::lightning_invoice::PayeePubKey { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payee_pub_key(); let mut local_ret = crate::lightning_invoice::PayeePubKey { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning_invoice::PayeePubKey<>) as *mut _ }, is_owned: false }; local_ret @@ -2236,7 +2236,7 @@ pub extern "C" fn RawInvoice_payee_pub_key(this_arg: &crate::lightning_invoice:: /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn RawInvoice_description_hash(this_arg: &crate::lightning_invoice::RawInvoice) -> crate::lightning_invoice::Sha256 { +pub extern "C" fn RawBolt11Invoice_description_hash(this_arg: &crate::lightning_invoice::RawBolt11Invoice) -> crate::lightning_invoice::Sha256 { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.description_hash(); let mut local_ret = crate::lightning_invoice::Sha256 { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning_invoice::Sha256<>) as *mut _ }, is_owned: false }; local_ret @@ -2246,7 +2246,7 @@ pub extern "C" fn RawInvoice_description_hash(this_arg: &crate::lightning_invoic /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn RawInvoice_expiry_time(this_arg: &crate::lightning_invoice::RawInvoice) -> crate::lightning_invoice::ExpiryTime { +pub extern "C" fn RawBolt11Invoice_expiry_time(this_arg: &crate::lightning_invoice::RawBolt11Invoice) -> crate::lightning_invoice::ExpiryTime { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.expiry_time(); let mut local_ret = crate::lightning_invoice::ExpiryTime { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning_invoice::ExpiryTime<>) as *mut _ }, is_owned: false }; local_ret @@ -2256,25 +2256,23 @@ pub extern "C" fn RawInvoice_expiry_time(this_arg: &crate::lightning_invoice::Ra /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn RawInvoice_min_final_cltv_expiry_delta(this_arg: &crate::lightning_invoice::RawInvoice) -> crate::lightning_invoice::MinFinalCltvExpiryDelta { +pub extern "C" fn RawBolt11Invoice_min_final_cltv_expiry_delta(this_arg: &crate::lightning_invoice::RawBolt11Invoice) -> crate::lightning_invoice::MinFinalCltvExpiryDelta { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.min_final_cltv_expiry_delta(); let mut local_ret = crate::lightning_invoice::MinFinalCltvExpiryDelta { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning_invoice::MinFinalCltvExpiryDelta<>) as *mut _ }, is_owned: false }; local_ret } -/// -/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn RawInvoice_payment_secret(this_arg: &crate::lightning_invoice::RawInvoice) -> crate::c_types::ThirtyTwoBytes { +pub extern "C" fn RawBolt11Invoice_payment_secret(this_arg: &crate::lightning_invoice::RawBolt11Invoice) -> crate::c_types::derived::COption_PaymentSecretZ { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payment_secret(); - let mut local_ret = if ret.is_none() { crate::c_types::ThirtyTwoBytes::null() } else { { crate::c_types::ThirtyTwoBytes { data: (ret.unwrap()).0 } } }; + let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_PaymentSecretZ::None } else { crate::c_types::derived::COption_PaymentSecretZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option is otherwise un-expressable. */ { crate::c_types::ThirtyTwoBytes { data: (*ret.as_ref().unwrap()).clone().0 } }) }; local_ret } #[must_use] #[no_mangle] -pub extern "C" fn RawInvoice_payment_metadata(this_arg: &crate::lightning_invoice::RawInvoice) -> crate::c_types::derived::COption_CVec_u8ZZ { +pub extern "C" fn RawBolt11Invoice_payment_metadata(this_arg: &crate::lightning_invoice::RawBolt11Invoice) -> crate::c_types::derived::COption_CVec_u8ZZ { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payment_metadata(); let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_CVec_u8ZZ::None } else { crate::c_types::derived::COption_CVec_u8ZZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option is otherwise un-expressable. */ { let mut local_ret_0 = Vec::new(); for mut item in (*ret.as_ref().unwrap()).clone().drain(..) { local_ret_0.push( { item }); }; local_ret_0.into() }) }; local_ret @@ -2284,15 +2282,15 @@ pub extern "C" fn RawInvoice_payment_metadata(this_arg: &crate::lightning_invoic /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn RawInvoice_features(this_arg: &crate::lightning_invoice::RawInvoice) -> crate::lightning::ln::features::InvoiceFeatures { +pub extern "C" fn RawBolt11Invoice_features(this_arg: &crate::lightning_invoice::RawBolt11Invoice) -> crate::lightning::ln::features::Bolt11InvoiceFeatures { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.features(); - let mut local_ret = crate::lightning::ln::features::InvoiceFeatures { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning::ln::features::InvoiceFeatures<>) as *mut _ }, is_owned: false }; + let mut local_ret = crate::lightning::ln::features::Bolt11InvoiceFeatures { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning::ln::features::Bolt11InvoiceFeatures<>) as *mut _ }, is_owned: false }; local_ret } #[must_use] #[no_mangle] -pub extern "C" fn RawInvoice_private_routes(this_arg: &crate::lightning_invoice::RawInvoice) -> crate::c_types::derived::CVec_PrivateRouteZ { +pub extern "C" fn RawBolt11Invoice_private_routes(this_arg: &crate::lightning_invoice::RawBolt11Invoice) -> crate::c_types::derived::CVec_PrivateRouteZ { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.private_routes(); let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning_invoice::PrivateRoute { inner: unsafe { ObjOps::nonnull_ptr_to_inner((item as *const lightning_invoice::PrivateRoute<>) as *mut _) }, is_owned: false } }); }; local_ret.into() @@ -2300,7 +2298,7 @@ pub extern "C" fn RawInvoice_private_routes(this_arg: &crate::lightning_invoice: #[must_use] #[no_mangle] -pub extern "C" fn RawInvoice_amount_pico_btc(this_arg: &crate::lightning_invoice::RawInvoice) -> crate::c_types::derived::COption_u64Z { +pub extern "C" fn RawBolt11Invoice_amount_pico_btc(this_arg: &crate::lightning_invoice::RawBolt11Invoice) -> crate::c_types::derived::COption_u64Z { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount_pico_btc(); let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { ret.unwrap() }) }; local_ret @@ -2308,7 +2306,7 @@ pub extern "C" fn RawInvoice_amount_pico_btc(this_arg: &crate::lightning_invoice #[must_use] #[no_mangle] -pub extern "C" fn RawInvoice_currency(this_arg: &crate::lightning_invoice::RawInvoice) -> crate::lightning_invoice::Currency { +pub extern "C" fn RawBolt11Invoice_currency(this_arg: &crate::lightning_invoice::RawBolt11Invoice) -> crate::lightning_invoice::Currency { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.currency(); crate::lightning_invoice::Currency::native_into(ret) } @@ -2376,32 +2374,32 @@ pub extern "C" fn PositiveTimestamp_as_time(this_arg: &crate::lightning_invoice: ret.duration_since(::std::time::SystemTime::UNIX_EPOCH).expect("Times must be post-1970").as_secs() } -/// The hash of the [`RawInvoice`] that was signed. +/// The hash of the [`RawBolt11Invoice`] that was signed. #[must_use] #[no_mangle] -pub extern "C" fn Invoice_signable_hash(this_arg: &crate::lightning_invoice::Invoice) -> crate::c_types::ThirtyTwoBytes { +pub extern "C" fn Bolt11Invoice_signable_hash(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> crate::c_types::ThirtyTwoBytes { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signable_hash(); crate::c_types::ThirtyTwoBytes { data: ret } } -/// Transform the `Invoice` into it's unchecked version +/// Transform the `Bolt11Invoice` into its unchecked version. #[must_use] #[no_mangle] -pub extern "C" fn Invoice_into_signed_raw(mut this_arg: crate::lightning_invoice::Invoice) -> crate::lightning_invoice::SignedRawInvoice { +pub extern "C" fn Bolt11Invoice_into_signed_raw(mut this_arg: crate::lightning_invoice::Bolt11Invoice) -> crate::lightning_invoice::SignedRawBolt11Invoice { let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).into_signed_raw(); - crate::lightning_invoice::SignedRawInvoice { inner: ObjOps::heap_alloc(ret), is_owned: true } + crate::lightning_invoice::SignedRawBolt11Invoice { inner: ObjOps::heap_alloc(ret), is_owned: true } } /// Check that the invoice is signed correctly and that key recovery works #[must_use] #[no_mangle] -pub extern "C" fn Invoice_check_signature(this_arg: &crate::lightning_invoice::Invoice) -> crate::c_types::derived::CResult_NoneSemanticErrorZ { +pub extern "C" fn Bolt11Invoice_check_signature(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> crate::c_types::derived::CResult_NoneBolt11SemanticErrorZ { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.check_signature(); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::SemanticError::native_into(e) }).into() }; + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::Bolt11SemanticError::native_into(e) }).into() }; local_ret } -/// Constructs an `Invoice` from a [`SignedRawInvoice`] by checking all its invariants. +/// Constructs a `Bolt11Invoice` from a [`SignedRawBolt11Invoice`] by checking all its invariants. /// ``` /// use lightning_invoice::*; /// @@ -2417,30 +2415,30 @@ pub extern "C" fn Invoice_check_signature(this_arg: &crate::lightning_invoice::I /// 8s0gyuxjjgux34w75dnc6xp2l35j7es3jd4ugt3lu0xzre26yg5m7ke54n2d5sym4xcmxtl8238xxvw5h5h5\\ /// j5r6drg6k6zcqj0fcwg\"; /// -/// let signed = invoice.parse::().unwrap(); +/// let signed = invoice.parse::().unwrap(); /// -/// assert!(Invoice::from_signed(signed).is_ok()); +/// assert!(Bolt11Invoice::from_signed(signed).is_ok()); /// ``` #[must_use] #[no_mangle] -pub extern "C" fn Invoice_from_signed(mut signed_invoice: crate::lightning_invoice::SignedRawInvoice) -> crate::c_types::derived::CResult_InvoiceSemanticErrorZ { - let mut ret = lightning_invoice::Invoice::from_signed(*unsafe { Box::from_raw(signed_invoice.take_inner()) }); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::Invoice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::SemanticError::native_into(e) }).into() }; +pub extern "C" fn Bolt11Invoice_from_signed(mut signed_invoice: crate::lightning_invoice::SignedRawBolt11Invoice) -> crate::c_types::derived::CResult_Bolt11InvoiceBolt11SemanticErrorZ { + let mut ret = lightning_invoice::Bolt11Invoice::from_signed(*unsafe { Box::from_raw(signed_invoice.take_inner()) }); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::Bolt11Invoice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::Bolt11SemanticError::native_into(e) }).into() }; local_ret } -/// Returns the `Invoice`'s timestamp (should equal its creation time) +/// Returns the `Bolt11Invoice`'s timestamp (should equal its creation time) #[must_use] #[no_mangle] -pub extern "C" fn Invoice_timestamp(this_arg: &crate::lightning_invoice::Invoice) -> u64 { +pub extern "C" fn Bolt11Invoice_timestamp(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> u64 { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.timestamp(); ret.duration_since(::std::time::SystemTime::UNIX_EPOCH).expect("Times must be post-1970").as_secs() } -/// Returns the `Invoice`'s timestamp as a duration since the Unix epoch +/// Returns the `Bolt11Invoice`'s timestamp as a duration since the Unix epoch #[must_use] #[no_mangle] -pub extern "C" fn Invoice_duration_since_epoch(this_arg: &crate::lightning_invoice::Invoice) -> u64 { +pub extern "C" fn Bolt11Invoice_duration_since_epoch(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> u64 { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.duration_since_epoch(); ret.as_secs() } @@ -2448,7 +2446,7 @@ pub extern "C" fn Invoice_duration_since_epoch(this_arg: &crate::lightning_invoi /// Returns the hash to which we will receive the preimage on completion of the payment #[must_use] #[no_mangle] -pub extern "C" fn Invoice_payment_hash(this_arg: &crate::lightning_invoice::Invoice) -> *const [u8; 32] { +pub extern "C" fn Bolt11Invoice_payment_hash(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> *const [u8; 32] { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payment_hash(); ret.as_inner() } @@ -2458,7 +2456,7 @@ pub extern "C" fn Invoice_payment_hash(this_arg: &crate::lightning_invoice::Invo /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn Invoice_payee_pub_key(this_arg: &crate::lightning_invoice::Invoice) -> crate::c_types::PublicKey { +pub extern "C" fn Bolt11Invoice_payee_pub_key(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> crate::c_types::PublicKey { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payee_pub_key(); let mut local_ret = if ret.is_none() { crate::c_types::PublicKey::null() } else { { crate::c_types::PublicKey::from_rust(&(ret.unwrap())) } }; local_ret @@ -2467,7 +2465,7 @@ pub extern "C" fn Invoice_payee_pub_key(this_arg: &crate::lightning_invoice::Inv /// Get the payment secret if one was included in the invoice #[must_use] #[no_mangle] -pub extern "C" fn Invoice_payment_secret(this_arg: &crate::lightning_invoice::Invoice) -> *const [u8; 32] { +pub extern "C" fn Bolt11Invoice_payment_secret(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> *const [u8; 32] { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payment_secret(); &ret.0 } @@ -2475,7 +2473,7 @@ pub extern "C" fn Invoice_payment_secret(this_arg: &crate::lightning_invoice::In /// Get the payment metadata blob if one was included in the invoice #[must_use] #[no_mangle] -pub extern "C" fn Invoice_payment_metadata(this_arg: &crate::lightning_invoice::Invoice) -> crate::c_types::derived::COption_CVec_u8ZZ { +pub extern "C" fn Bolt11Invoice_payment_metadata(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> crate::c_types::derived::COption_CVec_u8ZZ { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payment_metadata(); let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_CVec_u8ZZ::None } else { crate::c_types::derived::COption_CVec_u8ZZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option is otherwise un-expressable. */ { let mut local_ret_0 = Vec::new(); for mut item in (*ret.as_ref().unwrap()).clone().drain(..) { local_ret_0.push( { item }); }; local_ret_0.into() }) }; local_ret @@ -2486,16 +2484,16 @@ pub extern "C" fn Invoice_payment_metadata(this_arg: &crate::lightning_invoice:: /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn Invoice_features(this_arg: &crate::lightning_invoice::Invoice) -> crate::lightning::ln::features::InvoiceFeatures { +pub extern "C" fn Bolt11Invoice_features(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> crate::lightning::ln::features::Bolt11InvoiceFeatures { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.features(); - let mut local_ret = crate::lightning::ln::features::InvoiceFeatures { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning::ln::features::InvoiceFeatures<>) as *mut _ }, is_owned: false }; + let mut local_ret = crate::lightning::ln::features::Bolt11InvoiceFeatures { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning::ln::features::Bolt11InvoiceFeatures<>) as *mut _ }, is_owned: false }; local_ret } /// Recover the payee's public key (only to be used if none was included in the invoice) #[must_use] #[no_mangle] -pub extern "C" fn Invoice_recover_payee_pub_key(this_arg: &crate::lightning_invoice::Invoice) -> crate::c_types::PublicKey { +pub extern "C" fn Bolt11Invoice_recover_payee_pub_key(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> crate::c_types::PublicKey { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.recover_payee_pub_key(); crate::c_types::PublicKey::from_rust(&ret) } @@ -2504,7 +2502,7 @@ pub extern "C" fn Invoice_recover_payee_pub_key(this_arg: &crate::lightning_invo /// Returning None if overflow occurred. #[must_use] #[no_mangle] -pub extern "C" fn Invoice_expires_at(this_arg: &crate::lightning_invoice::Invoice) -> crate::c_types::derived::COption_DurationZ { +pub extern "C" fn Bolt11Invoice_expires_at(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> crate::c_types::derived::COption_DurationZ { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.expires_at(); let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_DurationZ::None } else { crate::c_types::derived::COption_DurationZ::Some( { ret.unwrap().as_secs() }) }; local_ret @@ -2513,7 +2511,7 @@ pub extern "C" fn Invoice_expires_at(this_arg: &crate::lightning_invoice::Invoic /// Returns the invoice's expiry time, if present, otherwise [`DEFAULT_EXPIRY_TIME`]. #[must_use] #[no_mangle] -pub extern "C" fn Invoice_expiry_time(this_arg: &crate::lightning_invoice::Invoice) -> u64 { +pub extern "C" fn Bolt11Invoice_expiry_time(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> u64 { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.expiry_time(); ret.as_secs() } @@ -2521,7 +2519,7 @@ pub extern "C" fn Invoice_expiry_time(this_arg: &crate::lightning_invoice::Invoi /// Returns whether the invoice has expired. #[must_use] #[no_mangle] -pub extern "C" fn Invoice_is_expired(this_arg: &crate::lightning_invoice::Invoice) -> bool { +pub extern "C" fn Bolt11Invoice_is_expired(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> bool { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.is_expired(); ret } @@ -2529,7 +2527,7 @@ pub extern "C" fn Invoice_is_expired(this_arg: &crate::lightning_invoice::Invoic /// Returns the Duration remaining until the invoice expires. #[must_use] #[no_mangle] -pub extern "C" fn Invoice_duration_until_expiry(this_arg: &crate::lightning_invoice::Invoice) -> u64 { +pub extern "C" fn Bolt11Invoice_duration_until_expiry(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> u64 { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.duration_until_expiry(); ret.as_secs() } @@ -2538,7 +2536,7 @@ pub extern "C" fn Invoice_duration_until_expiry(this_arg: &crate::lightning_invo /// `time` is the timestamp as a duration since the Unix epoch. #[must_use] #[no_mangle] -pub extern "C" fn Invoice_expiration_remaining_from_epoch(this_arg: &crate::lightning_invoice::Invoice, mut time: u64) -> u64 { +pub extern "C" fn Bolt11Invoice_expiration_remaining_from_epoch(this_arg: &crate::lightning_invoice::Bolt11Invoice, mut time: u64) -> u64 { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.expiration_remaining_from_epoch(core::time::Duration::from_secs(time)); ret.as_secs() } @@ -2547,7 +2545,7 @@ pub extern "C" fn Invoice_expiration_remaining_from_epoch(this_arg: &crate::ligh /// `at_time` is the timestamp as a duration since the Unix epoch. #[must_use] #[no_mangle] -pub extern "C" fn Invoice_would_expire(this_arg: &crate::lightning_invoice::Invoice, mut at_time: u64) -> bool { +pub extern "C" fn Bolt11Invoice_would_expire(this_arg: &crate::lightning_invoice::Bolt11Invoice, mut at_time: u64) -> bool { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.would_expire(core::time::Duration::from_secs(at_time)); ret } @@ -2556,7 +2554,7 @@ pub extern "C" fn Invoice_would_expire(this_arg: &crate::lightning_invoice::Invo /// [`DEFAULT_MIN_FINAL_CLTV_EXPIRY_DELTA`]. #[must_use] #[no_mangle] -pub extern "C" fn Invoice_min_final_cltv_expiry_delta(this_arg: &crate::lightning_invoice::Invoice) -> u64 { +pub extern "C" fn Bolt11Invoice_min_final_cltv_expiry_delta(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> u64 { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.min_final_cltv_expiry_delta(); ret } @@ -2564,7 +2562,7 @@ pub extern "C" fn Invoice_min_final_cltv_expiry_delta(this_arg: &crate::lightnin /// Returns a list of all fallback addresses as [`Address`]es #[must_use] #[no_mangle] -pub extern "C" fn Invoice_fallback_addresses(this_arg: &crate::lightning_invoice::Invoice) -> crate::c_types::derived::CVec_AddressZ { +pub extern "C" fn Bolt11Invoice_fallback_addresses(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> crate::c_types::derived::CVec_AddressZ { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.fallback_addresses(); let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { alloc::string::ToString::to_string(&item).into() }); }; local_ret.into() @@ -2573,7 +2571,7 @@ pub extern "C" fn Invoice_fallback_addresses(this_arg: &crate::lightning_invoice /// Returns a list of all routes included in the invoice #[must_use] #[no_mangle] -pub extern "C" fn Invoice_private_routes(this_arg: &crate::lightning_invoice::Invoice) -> crate::c_types::derived::CVec_PrivateRouteZ { +pub extern "C" fn Bolt11Invoice_private_routes(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> crate::c_types::derived::CVec_PrivateRouteZ { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.private_routes(); let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning_invoice::PrivateRoute { inner: unsafe { ObjOps::nonnull_ptr_to_inner((item as *const lightning_invoice::PrivateRoute<>) as *mut _) }, is_owned: false } }); }; local_ret.into() @@ -2582,7 +2580,7 @@ pub extern "C" fn Invoice_private_routes(this_arg: &crate::lightning_invoice::In /// Returns a list of all routes included in the invoice as the underlying hints #[must_use] #[no_mangle] -pub extern "C" fn Invoice_route_hints(this_arg: &crate::lightning_invoice::Invoice) -> crate::c_types::derived::CVec_RouteHintZ { +pub extern "C" fn Bolt11Invoice_route_hints(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> crate::c_types::derived::CVec_RouteHintZ { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.route_hints(); let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::routing::router::RouteHint { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; local_ret.into() @@ -2591,7 +2589,7 @@ pub extern "C" fn Invoice_route_hints(this_arg: &crate::lightning_invoice::Invoi /// Returns the currency for which the invoice was issued #[must_use] #[no_mangle] -pub extern "C" fn Invoice_currency(this_arg: &crate::lightning_invoice::Invoice) -> crate::lightning_invoice::Currency { +pub extern "C" fn Bolt11Invoice_currency(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> crate::lightning_invoice::Currency { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.currency(); crate::lightning_invoice::Currency::native_into(ret) } @@ -2599,7 +2597,7 @@ pub extern "C" fn Invoice_currency(this_arg: &crate::lightning_invoice::Invoice) /// Returns the amount if specified in the invoice as millisatoshis. #[must_use] #[no_mangle] -pub extern "C" fn Invoice_amount_milli_satoshis(this_arg: &crate::lightning_invoice::Invoice) -> crate::c_types::derived::COption_u64Z { +pub extern "C" fn Bolt11Invoice_amount_milli_satoshis(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> crate::c_types::derived::COption_u64Z { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount_milli_satoshis(); let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { ret.unwrap() }) }; local_ret @@ -2674,7 +2672,7 @@ pub extern "C" fn PrivateRoute_into_inner(mut this_arg: crate::lightning_invoice crate::lightning::routing::router::RouteHint { inner: ObjOps::heap_alloc(ret), is_owned: true } } -/// Errors that may occur when constructing a new [`RawInvoice`] or [`Invoice`] +/// Errors that may occur when constructing a new [`RawBolt11Invoice`] or [`Bolt11Invoice`] #[derive(Clone)] #[must_use] #[repr(C)] @@ -2786,12 +2784,12 @@ pub extern "C" fn CreationError_eq(a: &CreationError, b: &CreationError) -> bool pub extern "C" fn CreationError_to_str(o: &crate::lightning_invoice::CreationError) -> Str { alloc::format!("{}", &o.to_native()).into() } -/// Errors that may occur when converting a [`RawInvoice`] to an [`Invoice`]. They relate to the -/// requirements sections in BOLT #11 +/// Errors that may occur when converting a [`RawBolt11Invoice`] to a [`Bolt11Invoice`]. They relate to +/// the requirements sections in BOLT #11 #[derive(Clone)] #[must_use] #[repr(C)] -pub enum SemanticError { +pub enum Bolt11SemanticError { /// The invoice is missing the mandatory payment hash NoPaymentHash, /// The invoice has multiple payment hashes which isn't allowed @@ -2814,125 +2812,125 @@ pub enum SemanticError { /// The invoice's amount was not a whole number of millisatoshis ImpreciseAmount, } -use lightning_invoice::SemanticError as SemanticErrorImport; -pub(crate) type nativeSemanticError = SemanticErrorImport; +use lightning_invoice::Bolt11SemanticError as Bolt11SemanticErrorImport; +pub(crate) type nativeBolt11SemanticError = Bolt11SemanticErrorImport; -impl SemanticError { +impl Bolt11SemanticError { #[allow(unused)] - pub(crate) fn to_native(&self) -> nativeSemanticError { + pub(crate) fn to_native(&self) -> nativeBolt11SemanticError { match self { - SemanticError::NoPaymentHash => nativeSemanticError::NoPaymentHash, - SemanticError::MultiplePaymentHashes => nativeSemanticError::MultiplePaymentHashes, - SemanticError::NoDescription => nativeSemanticError::NoDescription, - SemanticError::MultipleDescriptions => nativeSemanticError::MultipleDescriptions, - SemanticError::NoPaymentSecret => nativeSemanticError::NoPaymentSecret, - SemanticError::MultiplePaymentSecrets => nativeSemanticError::MultiplePaymentSecrets, - SemanticError::InvalidFeatures => nativeSemanticError::InvalidFeatures, - SemanticError::InvalidRecoveryId => nativeSemanticError::InvalidRecoveryId, - SemanticError::InvalidSignature => nativeSemanticError::InvalidSignature, - SemanticError::ImpreciseAmount => nativeSemanticError::ImpreciseAmount, + Bolt11SemanticError::NoPaymentHash => nativeBolt11SemanticError::NoPaymentHash, + Bolt11SemanticError::MultiplePaymentHashes => nativeBolt11SemanticError::MultiplePaymentHashes, + Bolt11SemanticError::NoDescription => nativeBolt11SemanticError::NoDescription, + Bolt11SemanticError::MultipleDescriptions => nativeBolt11SemanticError::MultipleDescriptions, + Bolt11SemanticError::NoPaymentSecret => nativeBolt11SemanticError::NoPaymentSecret, + Bolt11SemanticError::MultiplePaymentSecrets => nativeBolt11SemanticError::MultiplePaymentSecrets, + Bolt11SemanticError::InvalidFeatures => nativeBolt11SemanticError::InvalidFeatures, + Bolt11SemanticError::InvalidRecoveryId => nativeBolt11SemanticError::InvalidRecoveryId, + Bolt11SemanticError::InvalidSignature => nativeBolt11SemanticError::InvalidSignature, + Bolt11SemanticError::ImpreciseAmount => nativeBolt11SemanticError::ImpreciseAmount, } } #[allow(unused)] - pub(crate) fn into_native(self) -> nativeSemanticError { + pub(crate) fn into_native(self) -> nativeBolt11SemanticError { match self { - SemanticError::NoPaymentHash => nativeSemanticError::NoPaymentHash, - SemanticError::MultiplePaymentHashes => nativeSemanticError::MultiplePaymentHashes, - SemanticError::NoDescription => nativeSemanticError::NoDescription, - SemanticError::MultipleDescriptions => nativeSemanticError::MultipleDescriptions, - SemanticError::NoPaymentSecret => nativeSemanticError::NoPaymentSecret, - SemanticError::MultiplePaymentSecrets => nativeSemanticError::MultiplePaymentSecrets, - SemanticError::InvalidFeatures => nativeSemanticError::InvalidFeatures, - SemanticError::InvalidRecoveryId => nativeSemanticError::InvalidRecoveryId, - SemanticError::InvalidSignature => nativeSemanticError::InvalidSignature, - SemanticError::ImpreciseAmount => nativeSemanticError::ImpreciseAmount, + Bolt11SemanticError::NoPaymentHash => nativeBolt11SemanticError::NoPaymentHash, + Bolt11SemanticError::MultiplePaymentHashes => nativeBolt11SemanticError::MultiplePaymentHashes, + Bolt11SemanticError::NoDescription => nativeBolt11SemanticError::NoDescription, + Bolt11SemanticError::MultipleDescriptions => nativeBolt11SemanticError::MultipleDescriptions, + Bolt11SemanticError::NoPaymentSecret => nativeBolt11SemanticError::NoPaymentSecret, + Bolt11SemanticError::MultiplePaymentSecrets => nativeBolt11SemanticError::MultiplePaymentSecrets, + Bolt11SemanticError::InvalidFeatures => nativeBolt11SemanticError::InvalidFeatures, + Bolt11SemanticError::InvalidRecoveryId => nativeBolt11SemanticError::InvalidRecoveryId, + Bolt11SemanticError::InvalidSignature => nativeBolt11SemanticError::InvalidSignature, + Bolt11SemanticError::ImpreciseAmount => nativeBolt11SemanticError::ImpreciseAmount, } } #[allow(unused)] - pub(crate) fn from_native(native: &nativeSemanticError) -> Self { + pub(crate) fn from_native(native: &nativeBolt11SemanticError) -> Self { match native { - nativeSemanticError::NoPaymentHash => SemanticError::NoPaymentHash, - nativeSemanticError::MultiplePaymentHashes => SemanticError::MultiplePaymentHashes, - nativeSemanticError::NoDescription => SemanticError::NoDescription, - nativeSemanticError::MultipleDescriptions => SemanticError::MultipleDescriptions, - nativeSemanticError::NoPaymentSecret => SemanticError::NoPaymentSecret, - nativeSemanticError::MultiplePaymentSecrets => SemanticError::MultiplePaymentSecrets, - nativeSemanticError::InvalidFeatures => SemanticError::InvalidFeatures, - nativeSemanticError::InvalidRecoveryId => SemanticError::InvalidRecoveryId, - nativeSemanticError::InvalidSignature => SemanticError::InvalidSignature, - nativeSemanticError::ImpreciseAmount => SemanticError::ImpreciseAmount, + nativeBolt11SemanticError::NoPaymentHash => Bolt11SemanticError::NoPaymentHash, + nativeBolt11SemanticError::MultiplePaymentHashes => Bolt11SemanticError::MultiplePaymentHashes, + nativeBolt11SemanticError::NoDescription => Bolt11SemanticError::NoDescription, + nativeBolt11SemanticError::MultipleDescriptions => Bolt11SemanticError::MultipleDescriptions, + nativeBolt11SemanticError::NoPaymentSecret => Bolt11SemanticError::NoPaymentSecret, + nativeBolt11SemanticError::MultiplePaymentSecrets => Bolt11SemanticError::MultiplePaymentSecrets, + nativeBolt11SemanticError::InvalidFeatures => Bolt11SemanticError::InvalidFeatures, + nativeBolt11SemanticError::InvalidRecoveryId => Bolt11SemanticError::InvalidRecoveryId, + nativeBolt11SemanticError::InvalidSignature => Bolt11SemanticError::InvalidSignature, + nativeBolt11SemanticError::ImpreciseAmount => Bolt11SemanticError::ImpreciseAmount, } } #[allow(unused)] - pub(crate) fn native_into(native: nativeSemanticError) -> Self { + pub(crate) fn native_into(native: nativeBolt11SemanticError) -> Self { match native { - nativeSemanticError::NoPaymentHash => SemanticError::NoPaymentHash, - nativeSemanticError::MultiplePaymentHashes => SemanticError::MultiplePaymentHashes, - nativeSemanticError::NoDescription => SemanticError::NoDescription, - nativeSemanticError::MultipleDescriptions => SemanticError::MultipleDescriptions, - nativeSemanticError::NoPaymentSecret => SemanticError::NoPaymentSecret, - nativeSemanticError::MultiplePaymentSecrets => SemanticError::MultiplePaymentSecrets, - nativeSemanticError::InvalidFeatures => SemanticError::InvalidFeatures, - nativeSemanticError::InvalidRecoveryId => SemanticError::InvalidRecoveryId, - nativeSemanticError::InvalidSignature => SemanticError::InvalidSignature, - nativeSemanticError::ImpreciseAmount => SemanticError::ImpreciseAmount, + nativeBolt11SemanticError::NoPaymentHash => Bolt11SemanticError::NoPaymentHash, + nativeBolt11SemanticError::MultiplePaymentHashes => Bolt11SemanticError::MultiplePaymentHashes, + nativeBolt11SemanticError::NoDescription => Bolt11SemanticError::NoDescription, + nativeBolt11SemanticError::MultipleDescriptions => Bolt11SemanticError::MultipleDescriptions, + nativeBolt11SemanticError::NoPaymentSecret => Bolt11SemanticError::NoPaymentSecret, + nativeBolt11SemanticError::MultiplePaymentSecrets => Bolt11SemanticError::MultiplePaymentSecrets, + nativeBolt11SemanticError::InvalidFeatures => Bolt11SemanticError::InvalidFeatures, + nativeBolt11SemanticError::InvalidRecoveryId => Bolt11SemanticError::InvalidRecoveryId, + nativeBolt11SemanticError::InvalidSignature => Bolt11SemanticError::InvalidSignature, + nativeBolt11SemanticError::ImpreciseAmount => Bolt11SemanticError::ImpreciseAmount, } } } -/// Creates a copy of the SemanticError +/// Creates a copy of the Bolt11SemanticError #[no_mangle] -pub extern "C" fn SemanticError_clone(orig: &SemanticError) -> SemanticError { +pub extern "C" fn Bolt11SemanticError_clone(orig: &Bolt11SemanticError) -> Bolt11SemanticError { orig.clone() } #[no_mangle] -/// Utility method to constructs a new NoPaymentHash-variant SemanticError -pub extern "C" fn SemanticError_no_payment_hash() -> SemanticError { - SemanticError::NoPaymentHash} +/// Utility method to constructs a new NoPaymentHash-variant Bolt11SemanticError +pub extern "C" fn Bolt11SemanticError_no_payment_hash() -> Bolt11SemanticError { + Bolt11SemanticError::NoPaymentHash} #[no_mangle] -/// Utility method to constructs a new MultiplePaymentHashes-variant SemanticError -pub extern "C" fn SemanticError_multiple_payment_hashes() -> SemanticError { - SemanticError::MultiplePaymentHashes} +/// Utility method to constructs a new MultiplePaymentHashes-variant Bolt11SemanticError +pub extern "C" fn Bolt11SemanticError_multiple_payment_hashes() -> Bolt11SemanticError { + Bolt11SemanticError::MultiplePaymentHashes} #[no_mangle] -/// Utility method to constructs a new NoDescription-variant SemanticError -pub extern "C" fn SemanticError_no_description() -> SemanticError { - SemanticError::NoDescription} +/// Utility method to constructs a new NoDescription-variant Bolt11SemanticError +pub extern "C" fn Bolt11SemanticError_no_description() -> Bolt11SemanticError { + Bolt11SemanticError::NoDescription} #[no_mangle] -/// Utility method to constructs a new MultipleDescriptions-variant SemanticError -pub extern "C" fn SemanticError_multiple_descriptions() -> SemanticError { - SemanticError::MultipleDescriptions} +/// Utility method to constructs a new MultipleDescriptions-variant Bolt11SemanticError +pub extern "C" fn Bolt11SemanticError_multiple_descriptions() -> Bolt11SemanticError { + Bolt11SemanticError::MultipleDescriptions} #[no_mangle] -/// Utility method to constructs a new NoPaymentSecret-variant SemanticError -pub extern "C" fn SemanticError_no_payment_secret() -> SemanticError { - SemanticError::NoPaymentSecret} +/// Utility method to constructs a new NoPaymentSecret-variant Bolt11SemanticError +pub extern "C" fn Bolt11SemanticError_no_payment_secret() -> Bolt11SemanticError { + Bolt11SemanticError::NoPaymentSecret} #[no_mangle] -/// Utility method to constructs a new MultiplePaymentSecrets-variant SemanticError -pub extern "C" fn SemanticError_multiple_payment_secrets() -> SemanticError { - SemanticError::MultiplePaymentSecrets} +/// Utility method to constructs a new MultiplePaymentSecrets-variant Bolt11SemanticError +pub extern "C" fn Bolt11SemanticError_multiple_payment_secrets() -> Bolt11SemanticError { + Bolt11SemanticError::MultiplePaymentSecrets} #[no_mangle] -/// Utility method to constructs a new InvalidFeatures-variant SemanticError -pub extern "C" fn SemanticError_invalid_features() -> SemanticError { - SemanticError::InvalidFeatures} +/// Utility method to constructs a new InvalidFeatures-variant Bolt11SemanticError +pub extern "C" fn Bolt11SemanticError_invalid_features() -> Bolt11SemanticError { + Bolt11SemanticError::InvalidFeatures} #[no_mangle] -/// Utility method to constructs a new InvalidRecoveryId-variant SemanticError -pub extern "C" fn SemanticError_invalid_recovery_id() -> SemanticError { - SemanticError::InvalidRecoveryId} +/// Utility method to constructs a new InvalidRecoveryId-variant Bolt11SemanticError +pub extern "C" fn Bolt11SemanticError_invalid_recovery_id() -> Bolt11SemanticError { + Bolt11SemanticError::InvalidRecoveryId} #[no_mangle] -/// Utility method to constructs a new InvalidSignature-variant SemanticError -pub extern "C" fn SemanticError_invalid_signature() -> SemanticError { - SemanticError::InvalidSignature} +/// Utility method to constructs a new InvalidSignature-variant Bolt11SemanticError +pub extern "C" fn Bolt11SemanticError_invalid_signature() -> Bolt11SemanticError { + Bolt11SemanticError::InvalidSignature} #[no_mangle] -/// Utility method to constructs a new ImpreciseAmount-variant SemanticError -pub extern "C" fn SemanticError_imprecise_amount() -> SemanticError { - SemanticError::ImpreciseAmount} -/// Checks if two SemanticErrors contain equal inner contents. +/// Utility method to constructs a new ImpreciseAmount-variant Bolt11SemanticError +pub extern "C" fn Bolt11SemanticError_imprecise_amount() -> Bolt11SemanticError { + Bolt11SemanticError::ImpreciseAmount} +/// Checks if two Bolt11SemanticErrors contain equal inner contents. /// This ignores pointers and is_owned flags and looks at the values in fields. #[no_mangle] -pub extern "C" fn SemanticError_eq(a: &SemanticError, b: &SemanticError) -> bool { +pub extern "C" fn Bolt11SemanticError_eq(a: &Bolt11SemanticError, b: &Bolt11SemanticError) -> bool { if &a.to_native() == &b.to_native() { true } else { false } } #[no_mangle] -/// Get the string representation of a SemanticError object -pub extern "C" fn SemanticError_to_str(o: &crate::lightning_invoice::SemanticError) -> Str { +/// Get the string representation of a Bolt11SemanticError object +pub extern "C" fn Bolt11SemanticError_to_str(o: &crate::lightning_invoice::Bolt11SemanticError) -> Str { alloc::format!("{}", &o.to_native()).into() } /// When signing using a fallible method either an user-supplied `SignError` or a [`CreationError`] diff --git a/lightning-c-bindings/src/lightning_invoice/payment.rs b/lightning-c-bindings/src/lightning_invoice/payment.rs index 4c19e67a..c3baa5c3 100644 --- a/lightning-c-bindings/src/lightning_invoice/payment.rs +++ b/lightning-c-bindings/src/lightning_invoice/payment.rs @@ -16,66 +16,67 @@ use crate::c_types::*; #[cfg(feature="no-std")] use alloc::{vec::Vec, boxed::Box}; -/// Pays the given [`Invoice`], retrying if needed based on [`Retry`]. +/// Pays the given [`Bolt11Invoice`], retrying if needed based on [`Retry`]. /// -/// [`Invoice::payment_hash`] is used as the [`PaymentId`], which ensures idempotency as long -/// as the payment is still pending. Once the payment completes or fails, you must ensure that -/// a second payment with the same [`PaymentHash`] is never sent. +/// [`Bolt11Invoice::payment_hash`] is used as the [`PaymentId`], which ensures idempotency as long +/// as the payment is still pending. If the payment succeeds, you must ensure that a second payment +/// with the same [`PaymentHash`] is never sent. /// /// If you wish to use a different payment idempotency token, see [`pay_invoice_with_id`]. #[no_mangle] -pub extern "C" fn pay_invoice(invoice: &crate::lightning_invoice::Invoice, mut retry_strategy: crate::lightning::ln::outbound_payment::Retry, channelmanager: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::c_types::derived::CResult_PaymentIdPaymentErrorZ { - let mut ret = lightning_invoice::payment::pay_invoice::(invoice.get_native_ref(), retry_strategy.into_native(), channelmanager.get_native_ref()); +pub extern "C" fn pay_invoice(invoice: &crate::lightning_invoice::Bolt11Invoice, mut retry_strategy: crate::lightning::ln::outbound_payment::Retry, channelmanager: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::c_types::derived::CResult_PaymentIdPaymentErrorZ { + let mut ret = lightning_invoice::payment::pay_invoice::(invoice.get_native_ref(), retry_strategy.into_native(), channelmanager.get_native_ref()); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ThirtyTwoBytes { data: o.0 } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::payment::PaymentError::native_into(e) }).into() }; local_ret } -/// Pays the given [`Invoice`] with a custom idempotency key, retrying if needed based on [`Retry`]. +/// Pays the given [`Bolt11Invoice`] with a custom idempotency key, retrying if needed based on +/// [`Retry`]. /// /// Note that idempotency is only guaranteed as long as the payment is still pending. Once the /// payment completes or fails, no idempotency guarantees are made. /// -/// You should ensure that the [`Invoice::payment_hash`] is unique and the same [`PaymentHash`] -/// has never been paid before. +/// You should ensure that the [`Bolt11Invoice::payment_hash`] is unique and the same +/// [`PaymentHash`] has never been paid before. /// /// See [`pay_invoice`] for a variant which uses the [`PaymentHash`] for the idempotency token. #[no_mangle] -pub extern "C" fn pay_invoice_with_id(invoice: &crate::lightning_invoice::Invoice, mut payment_id: crate::c_types::ThirtyTwoBytes, mut retry_strategy: crate::lightning::ln::outbound_payment::Retry, channelmanager: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::c_types::derived::CResult_NonePaymentErrorZ { - let mut ret = lightning_invoice::payment::pay_invoice_with_id::(invoice.get_native_ref(), ::lightning::ln::channelmanager::PaymentId(payment_id.data), retry_strategy.into_native(), channelmanager.get_native_ref()); +pub extern "C" fn pay_invoice_with_id(invoice: &crate::lightning_invoice::Bolt11Invoice, mut payment_id: crate::c_types::ThirtyTwoBytes, mut retry_strategy: crate::lightning::ln::outbound_payment::Retry, channelmanager: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::c_types::derived::CResult_NonePaymentErrorZ { + let mut ret = lightning_invoice::payment::pay_invoice_with_id::(invoice.get_native_ref(), ::lightning::ln::channelmanager::PaymentId(payment_id.data), retry_strategy.into_native(), channelmanager.get_native_ref()); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::payment::PaymentError::native_into(e) }).into() }; local_ret } -/// Pays the given zero-value [`Invoice`] using the given amount, retrying if needed based on +/// Pays the given zero-value [`Bolt11Invoice`] using the given amount, retrying if needed based on /// [`Retry`]. /// -/// [`Invoice::payment_hash`] is used as the [`PaymentId`], which ensures idempotency as long -/// as the payment is still pending. Once the payment completes or fails, you must ensure that -/// a second payment with the same [`PaymentHash`] is never sent. +/// [`Bolt11Invoice::payment_hash`] is used as the [`PaymentId`], which ensures idempotency as long +/// as the payment is still pending. If the payment succeeds, you must ensure that a second payment +/// with the same [`PaymentHash`] is never sent. /// /// If you wish to use a different payment idempotency token, see /// [`pay_zero_value_invoice_with_id`]. #[no_mangle] -pub extern "C" fn pay_zero_value_invoice(invoice: &crate::lightning_invoice::Invoice, mut amount_msats: u64, mut retry_strategy: crate::lightning::ln::outbound_payment::Retry, channelmanager: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::c_types::derived::CResult_PaymentIdPaymentErrorZ { - let mut ret = lightning_invoice::payment::pay_zero_value_invoice::(invoice.get_native_ref(), amount_msats, retry_strategy.into_native(), channelmanager.get_native_ref()); +pub extern "C" fn pay_zero_value_invoice(invoice: &crate::lightning_invoice::Bolt11Invoice, mut amount_msats: u64, mut retry_strategy: crate::lightning::ln::outbound_payment::Retry, channelmanager: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::c_types::derived::CResult_PaymentIdPaymentErrorZ { + let mut ret = lightning_invoice::payment::pay_zero_value_invoice::(invoice.get_native_ref(), amount_msats, retry_strategy.into_native(), channelmanager.get_native_ref()); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ThirtyTwoBytes { data: o.0 } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::payment::PaymentError::native_into(e) }).into() }; local_ret } -/// Pays the given zero-value [`Invoice`] using the given amount and custom idempotency key, -/// , retrying if needed based on [`Retry`]. +/// Pays the given zero-value [`Bolt11Invoice`] using the given amount and custom idempotency key, +/// retrying if needed based on [`Retry`]. /// /// Note that idempotency is only guaranteed as long as the payment is still pending. Once the /// payment completes or fails, no idempotency guarantees are made. /// -/// You should ensure that the [`Invoice::payment_hash`] is unique and the same [`PaymentHash`] -/// has never been paid before. +/// You should ensure that the [`Bolt11Invoice::payment_hash`] is unique and the same +/// [`PaymentHash`] has never been paid before. /// /// See [`pay_zero_value_invoice`] for a variant which uses the [`PaymentHash`] for the /// idempotency token. #[no_mangle] -pub extern "C" fn pay_zero_value_invoice_with_id(invoice: &crate::lightning_invoice::Invoice, mut amount_msats: u64, mut payment_id: crate::c_types::ThirtyTwoBytes, mut retry_strategy: crate::lightning::ln::outbound_payment::Retry, channelmanager: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::c_types::derived::CResult_NonePaymentErrorZ { - let mut ret = lightning_invoice::payment::pay_zero_value_invoice_with_id::(invoice.get_native_ref(), amount_msats, ::lightning::ln::channelmanager::PaymentId(payment_id.data), retry_strategy.into_native(), channelmanager.get_native_ref()); +pub extern "C" fn pay_zero_value_invoice_with_id(invoice: &crate::lightning_invoice::Bolt11Invoice, mut amount_msats: u64, mut payment_id: crate::c_types::ThirtyTwoBytes, mut retry_strategy: crate::lightning::ln::outbound_payment::Retry, channelmanager: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::c_types::derived::CResult_NonePaymentErrorZ { + let mut ret = lightning_invoice::payment::pay_zero_value_invoice_with_id::(invoice.get_native_ref(), amount_msats, ::lightning::ln::channelmanager::PaymentId(payment_id.data), retry_strategy.into_native(), channelmanager.get_native_ref()); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::payment::PaymentError::native_into(e) }).into() }; local_ret } @@ -85,7 +86,7 @@ pub extern "C" fn pay_zero_value_invoice_with_id(invoice: &crate::lightning_invo #[must_use] #[repr(C)] pub enum PaymentError { - /// An error resulting from the provided [`Invoice`] or payment hash. + /// An error resulting from the provided [`Bolt11Invoice`] or payment hash. Invoice( crate::c_types::Str), /// An error occurring when sending a payment. @@ -179,3 +180,9 @@ pub extern "C" fn PaymentError_invoice(a: crate::c_types::Str) -> PaymentError { pub extern "C" fn PaymentError_sending(a: crate::lightning::ln::outbound_payment::RetryableSendFailure) -> PaymentError { PaymentError::Sending(a, ) } +/// Checks if two PaymentErrors contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +#[no_mangle] +pub extern "C" fn PaymentError_eq(a: &PaymentError, b: &PaymentError) -> bool { + if &a.to_native() == &b.to_native() { true } else { false } +} diff --git a/lightning-c-bindings/src/lightning_invoice/utils.rs b/lightning-c-bindings/src/lightning_invoice/utils.rs index e897a932..0b1f0bb1 100644 --- a/lightning-c-bindings/src/lightning_invoice/utils.rs +++ b/lightning-c-bindings/src/lightning_invoice/utils.rs @@ -47,7 +47,7 @@ use alloc::{vec::Vec, boxed::Box}; /// invoices in its `sign_invoice` implementation ([`PhantomKeysManager`] satisfies this /// requirement). /// -/// [`PhantomKeysManager`]: lightning::chain::keysinterface::PhantomKeysManager +/// [`PhantomKeysManager`]: lightning::sign::PhantomKeysManager /// [`ChannelManager::get_phantom_route_hints`]: lightning::ln::channelmanager::ChannelManager::get_phantom_route_hints /// [`ChannelManager::create_inbound_payment`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment /// [`ChannelManager::create_inbound_payment_for_hash`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash @@ -56,16 +56,14 @@ use alloc::{vec::Vec, boxed::Box}; /// /// This can be used in a `no_std` environment, where [`std::time::SystemTime`] is not /// available and the current time is supplied by the caller. -/// -/// Note that payment_hash (or a relevant inner pointer) may be NULL or all-0s to represent None #[no_mangle] -pub extern "C" fn create_phantom_invoice(mut amt_msat: crate::c_types::derived::COption_u64Z, mut payment_hash: crate::c_types::ThirtyTwoBytes, mut description: crate::c_types::Str, mut invoice_expiry_delta_secs: u32, mut phantom_route_hints: crate::c_types::derived::CVec_PhantomRouteHintsZ, mut entropy_source: crate::lightning::chain::keysinterface::EntropySource, mut node_signer: crate::lightning::chain::keysinterface::NodeSigner, mut logger: crate::lightning::util::logger::Logger, mut network: crate::lightning_invoice::Currency, mut min_final_cltv_expiry_delta: crate::c_types::derived::COption_u16Z, mut duration_since_epoch: u64) -> crate::c_types::derived::CResult_InvoiceSignOrCreationErrorZ { +pub extern "C" fn create_phantom_invoice(mut amt_msat: crate::c_types::derived::COption_u64Z, mut payment_hash: crate::c_types::derived::COption_PaymentHashZ, mut description: crate::c_types::Str, mut invoice_expiry_delta_secs: u32, mut phantom_route_hints: crate::c_types::derived::CVec_PhantomRouteHintsZ, mut entropy_source: crate::lightning::sign::EntropySource, mut node_signer: crate::lightning::sign::NodeSigner, mut logger: crate::lightning::util::logger::Logger, mut network: crate::lightning_invoice::Currency, mut min_final_cltv_expiry_delta: crate::c_types::derived::COption_u16Z, mut duration_since_epoch: u64) -> crate::c_types::derived::CResult_Bolt11InvoiceSignOrCreationErrorZ { let mut local_amt_msat = if amt_msat.is_some() { Some( { amt_msat.take() }) } else { None }; - let mut local_payment_hash = if payment_hash.data == [0; 32] { None } else { Some( { ::lightning::ln::PaymentHash(payment_hash.data) }) }; + let mut local_payment_hash = { /*payment_hash*/ let payment_hash_opt = payment_hash; if payment_hash_opt.is_none() { None } else { Some({ { ::lightning::ln::PaymentHash({ payment_hash_opt.take() }.data) }})} }; let mut local_phantom_route_hints = Vec::new(); for mut item in phantom_route_hints.into_rust().drain(..) { local_phantom_route_hints.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; let mut local_min_final_cltv_expiry_delta = if min_final_cltv_expiry_delta.is_some() { Some( { min_final_cltv_expiry_delta.take() }) } else { None }; - let mut ret = lightning_invoice::utils::create_phantom_invoice::(local_amt_msat, local_payment_hash, description.into_string(), invoice_expiry_delta_secs, local_phantom_route_hints, entropy_source, node_signer, logger, network.into_native(), local_min_final_cltv_expiry_delta, core::time::Duration::from_secs(duration_since_epoch)); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::Invoice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::SignOrCreationError::native_into(e) }).into() }; + let mut ret = lightning_invoice::utils::create_phantom_invoice::(local_amt_msat, local_payment_hash, description.into_string(), invoice_expiry_delta_secs, local_phantom_route_hints, entropy_source, node_signer, logger, network.into_native(), local_min_final_cltv_expiry_delta, core::time::Duration::from_secs(duration_since_epoch)); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::Bolt11Invoice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::SignOrCreationError::native_into(e) }).into() }; local_ret } @@ -78,9 +76,11 @@ pub extern "C" fn create_phantom_invoice(mut amt_msat: crate::c_types::derived:: /// participating node /// * It is fine to cache `phantom_route_hints` and reuse it across invoices, as long as the data is /// updated when a channel becomes disabled or closes -/// * Note that if too many channels are included in [`PhantomRouteHints::channels`], the invoice -/// may be too long for QR code scanning. To fix this, `PhantomRouteHints::channels` may be pared -/// down +/// * Note that the route hints generated from `phantom_route_hints` will be limited to a maximum +/// of 3 hints to ensure that the invoice can be scanned in a QR code. These hints are selected +/// in the order that the nodes in `PhantomRouteHints` are specified, selecting one hint per node +/// until the maximum is hit. Callers may provide as many `PhantomRouteHints::channels` as +/// desired, but note that some nodes will be trimmed if more than 3 nodes are provided. /// /// `description_hash` is a SHA-256 hash of the description text /// @@ -97,7 +97,7 @@ pub extern "C" fn create_phantom_invoice(mut amt_msat: crate::c_types::derived:: /// invoices in its `sign_invoice` implementation ([`PhantomKeysManager`] satisfies this /// requirement). /// -/// [`PhantomKeysManager`]: lightning::chain::keysinterface::PhantomKeysManager +/// [`PhantomKeysManager`]: lightning::sign::PhantomKeysManager /// [`ChannelManager::get_phantom_route_hints`]: lightning::ln::channelmanager::ChannelManager::get_phantom_route_hints /// [`ChannelManager::create_inbound_payment`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment /// [`ChannelManager::create_inbound_payment_for_hash`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash @@ -105,16 +105,14 @@ pub extern "C" fn create_phantom_invoice(mut amt_msat: crate::c_types::derived:: /// /// This can be used in a `no_std` environment, where [`std::time::SystemTime`] is not /// available and the current time is supplied by the caller. -/// -/// Note that payment_hash (or a relevant inner pointer) may be NULL or all-0s to represent None #[no_mangle] -pub extern "C" fn create_phantom_invoice_with_description_hash(mut amt_msat: crate::c_types::derived::COption_u64Z, mut payment_hash: crate::c_types::ThirtyTwoBytes, mut invoice_expiry_delta_secs: u32, mut description_hash: crate::lightning_invoice::Sha256, mut phantom_route_hints: crate::c_types::derived::CVec_PhantomRouteHintsZ, mut entropy_source: crate::lightning::chain::keysinterface::EntropySource, mut node_signer: crate::lightning::chain::keysinterface::NodeSigner, mut logger: crate::lightning::util::logger::Logger, mut network: crate::lightning_invoice::Currency, mut min_final_cltv_expiry_delta: crate::c_types::derived::COption_u16Z, mut duration_since_epoch: u64) -> crate::c_types::derived::CResult_InvoiceSignOrCreationErrorZ { +pub extern "C" fn create_phantom_invoice_with_description_hash(mut amt_msat: crate::c_types::derived::COption_u64Z, mut payment_hash: crate::c_types::derived::COption_PaymentHashZ, mut invoice_expiry_delta_secs: u32, mut description_hash: crate::lightning_invoice::Sha256, mut phantom_route_hints: crate::c_types::derived::CVec_PhantomRouteHintsZ, mut entropy_source: crate::lightning::sign::EntropySource, mut node_signer: crate::lightning::sign::NodeSigner, mut logger: crate::lightning::util::logger::Logger, mut network: crate::lightning_invoice::Currency, mut min_final_cltv_expiry_delta: crate::c_types::derived::COption_u16Z, mut duration_since_epoch: u64) -> crate::c_types::derived::CResult_Bolt11InvoiceSignOrCreationErrorZ { let mut local_amt_msat = if amt_msat.is_some() { Some( { amt_msat.take() }) } else { None }; - let mut local_payment_hash = if payment_hash.data == [0; 32] { None } else { Some( { ::lightning::ln::PaymentHash(payment_hash.data) }) }; + let mut local_payment_hash = { /*payment_hash*/ let payment_hash_opt = payment_hash; if payment_hash_opt.is_none() { None } else { Some({ { ::lightning::ln::PaymentHash({ payment_hash_opt.take() }.data) }})} }; let mut local_phantom_route_hints = Vec::new(); for mut item in phantom_route_hints.into_rust().drain(..) { local_phantom_route_hints.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; let mut local_min_final_cltv_expiry_delta = if min_final_cltv_expiry_delta.is_some() { Some( { min_final_cltv_expiry_delta.take() }) } else { None }; - let mut ret = lightning_invoice::utils::create_phantom_invoice_with_description_hash::(local_amt_msat, local_payment_hash, invoice_expiry_delta_secs, *unsafe { Box::from_raw(description_hash.take_inner()) }, local_phantom_route_hints, entropy_source, node_signer, logger, network.into_native(), local_min_final_cltv_expiry_delta, core::time::Duration::from_secs(duration_since_epoch)); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::Invoice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::SignOrCreationError::native_into(e) }).into() }; + let mut ret = lightning_invoice::utils::create_phantom_invoice_with_description_hash::(local_amt_msat, local_payment_hash, invoice_expiry_delta_secs, *unsafe { Box::from_raw(description_hash.take_inner()) }, local_phantom_route_hints, entropy_source, node_signer, logger, network.into_native(), local_min_final_cltv_expiry_delta, core::time::Duration::from_secs(duration_since_epoch)); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::Bolt11Invoice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::SignOrCreationError::native_into(e) }).into() }; local_ret } @@ -134,11 +132,11 @@ pub extern "C" fn create_phantom_invoice_with_description_hash(mut amt_msat: cra /// /// [`MIN_FINAL_CLTV_EXPIRY_DETLA`]: lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA #[no_mangle] -pub extern "C" fn create_invoice_from_channelmanager(channelmanager: &crate::lightning::ln::channelmanager::ChannelManager, mut node_signer: crate::lightning::chain::keysinterface::NodeSigner, mut logger: crate::lightning::util::logger::Logger, mut network: crate::lightning_invoice::Currency, mut amt_msat: crate::c_types::derived::COption_u64Z, mut description: crate::c_types::Str, mut invoice_expiry_delta_secs: u32, mut min_final_cltv_expiry_delta: crate::c_types::derived::COption_u16Z) -> crate::c_types::derived::CResult_InvoiceSignOrCreationErrorZ { +pub extern "C" fn create_invoice_from_channelmanager(channelmanager: &crate::lightning::ln::channelmanager::ChannelManager, mut node_signer: crate::lightning::sign::NodeSigner, mut logger: crate::lightning::util::logger::Logger, mut network: crate::lightning_invoice::Currency, mut amt_msat: crate::c_types::derived::COption_u64Z, mut description: crate::c_types::Str, mut invoice_expiry_delta_secs: u32, mut min_final_cltv_expiry_delta: crate::c_types::derived::COption_u16Z) -> crate::c_types::derived::CResult_Bolt11InvoiceSignOrCreationErrorZ { let mut local_amt_msat = if amt_msat.is_some() { Some( { amt_msat.take() }) } else { None }; let mut local_min_final_cltv_expiry_delta = if min_final_cltv_expiry_delta.is_some() { Some( { min_final_cltv_expiry_delta.take() }) } else { None }; - let mut ret = lightning_invoice::utils::create_invoice_from_channelmanager::(channelmanager.get_native_ref(), node_signer, logger, network.into_native(), local_amt_msat, description.into_string(), invoice_expiry_delta_secs, local_min_final_cltv_expiry_delta); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::Invoice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::SignOrCreationError::native_into(e) }).into() }; + let mut ret = lightning_invoice::utils::create_invoice_from_channelmanager::(channelmanager.get_native_ref(), node_signer, logger, network.into_native(), local_amt_msat, description.into_string(), invoice_expiry_delta_secs, local_min_final_cltv_expiry_delta); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::Bolt11Invoice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::SignOrCreationError::native_into(e) }).into() }; local_ret } @@ -159,11 +157,11 @@ pub extern "C" fn create_invoice_from_channelmanager(channelmanager: &crate::lig /// /// [`MIN_FINAL_CLTV_EXPIRY_DETLA`]: lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA #[no_mangle] -pub extern "C" fn create_invoice_from_channelmanager_with_description_hash(channelmanager: &crate::lightning::ln::channelmanager::ChannelManager, mut node_signer: crate::lightning::chain::keysinterface::NodeSigner, mut logger: crate::lightning::util::logger::Logger, mut network: crate::lightning_invoice::Currency, mut amt_msat: crate::c_types::derived::COption_u64Z, mut description_hash: crate::lightning_invoice::Sha256, mut invoice_expiry_delta_secs: u32, mut min_final_cltv_expiry_delta: crate::c_types::derived::COption_u16Z) -> crate::c_types::derived::CResult_InvoiceSignOrCreationErrorZ { +pub extern "C" fn create_invoice_from_channelmanager_with_description_hash(channelmanager: &crate::lightning::ln::channelmanager::ChannelManager, mut node_signer: crate::lightning::sign::NodeSigner, mut logger: crate::lightning::util::logger::Logger, mut network: crate::lightning_invoice::Currency, mut amt_msat: crate::c_types::derived::COption_u64Z, mut description_hash: crate::lightning_invoice::Sha256, mut invoice_expiry_delta_secs: u32, mut min_final_cltv_expiry_delta: crate::c_types::derived::COption_u16Z) -> crate::c_types::derived::CResult_Bolt11InvoiceSignOrCreationErrorZ { let mut local_amt_msat = if amt_msat.is_some() { Some( { amt_msat.take() }) } else { None }; let mut local_min_final_cltv_expiry_delta = if min_final_cltv_expiry_delta.is_some() { Some( { min_final_cltv_expiry_delta.take() }) } else { None }; - let mut ret = lightning_invoice::utils::create_invoice_from_channelmanager_with_description_hash::(channelmanager.get_native_ref(), node_signer, logger, network.into_native(), local_amt_msat, *unsafe { Box::from_raw(description_hash.take_inner()) }, invoice_expiry_delta_secs, local_min_final_cltv_expiry_delta); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::Invoice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::SignOrCreationError::native_into(e) }).into() }; + let mut ret = lightning_invoice::utils::create_invoice_from_channelmanager_with_description_hash::(channelmanager.get_native_ref(), node_signer, logger, network.into_native(), local_amt_msat, *unsafe { Box::from_raw(description_hash.take_inner()) }, invoice_expiry_delta_secs, local_min_final_cltv_expiry_delta); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::Bolt11Invoice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::SignOrCreationError::native_into(e) }).into() }; local_ret } @@ -171,11 +169,11 @@ pub extern "C" fn create_invoice_from_channelmanager_with_description_hash(chann /// This version can be used in a `no_std` environment, where [`std::time::SystemTime`] is not /// available and the current time is supplied by the caller. #[no_mangle] -pub extern "C" fn create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch(channelmanager: &crate::lightning::ln::channelmanager::ChannelManager, mut node_signer: crate::lightning::chain::keysinterface::NodeSigner, mut logger: crate::lightning::util::logger::Logger, mut network: crate::lightning_invoice::Currency, mut amt_msat: crate::c_types::derived::COption_u64Z, mut description_hash: crate::lightning_invoice::Sha256, mut duration_since_epoch: u64, mut invoice_expiry_delta_secs: u32, mut min_final_cltv_expiry_delta: crate::c_types::derived::COption_u16Z) -> crate::c_types::derived::CResult_InvoiceSignOrCreationErrorZ { +pub extern "C" fn create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch(channelmanager: &crate::lightning::ln::channelmanager::ChannelManager, mut node_signer: crate::lightning::sign::NodeSigner, mut logger: crate::lightning::util::logger::Logger, mut network: crate::lightning_invoice::Currency, mut amt_msat: crate::c_types::derived::COption_u64Z, mut description_hash: crate::lightning_invoice::Sha256, mut duration_since_epoch: u64, mut invoice_expiry_delta_secs: u32, mut min_final_cltv_expiry_delta: crate::c_types::derived::COption_u16Z) -> crate::c_types::derived::CResult_Bolt11InvoiceSignOrCreationErrorZ { let mut local_amt_msat = if amt_msat.is_some() { Some( { amt_msat.take() }) } else { None }; let mut local_min_final_cltv_expiry_delta = if min_final_cltv_expiry_delta.is_some() { Some( { min_final_cltv_expiry_delta.take() }) } else { None }; - let mut ret = lightning_invoice::utils::create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch::(channelmanager.get_native_ref(), node_signer, logger, network.into_native(), local_amt_msat, *unsafe { Box::from_raw(description_hash.take_inner()) }, core::time::Duration::from_secs(duration_since_epoch), invoice_expiry_delta_secs, local_min_final_cltv_expiry_delta); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::Invoice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::SignOrCreationError::native_into(e) }).into() }; + let mut ret = lightning_invoice::utils::create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch::(channelmanager.get_native_ref(), node_signer, logger, network.into_native(), local_amt_msat, *unsafe { Box::from_raw(description_hash.take_inner()) }, core::time::Duration::from_secs(duration_since_epoch), invoice_expiry_delta_secs, local_min_final_cltv_expiry_delta); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::Bolt11Invoice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::SignOrCreationError::native_into(e) }).into() }; local_ret } @@ -183,11 +181,11 @@ pub extern "C" fn create_invoice_from_channelmanager_with_description_hash_and_d /// This version can be used in a `no_std` environment, where [`std::time::SystemTime`] is not /// available and the current time is supplied by the caller. #[no_mangle] -pub extern "C" fn create_invoice_from_channelmanager_and_duration_since_epoch(channelmanager: &crate::lightning::ln::channelmanager::ChannelManager, mut node_signer: crate::lightning::chain::keysinterface::NodeSigner, mut logger: crate::lightning::util::logger::Logger, mut network: crate::lightning_invoice::Currency, mut amt_msat: crate::c_types::derived::COption_u64Z, mut description: crate::c_types::Str, mut duration_since_epoch: u64, mut invoice_expiry_delta_secs: u32, mut min_final_cltv_expiry_delta: crate::c_types::derived::COption_u16Z) -> crate::c_types::derived::CResult_InvoiceSignOrCreationErrorZ { +pub extern "C" fn create_invoice_from_channelmanager_and_duration_since_epoch(channelmanager: &crate::lightning::ln::channelmanager::ChannelManager, mut node_signer: crate::lightning::sign::NodeSigner, mut logger: crate::lightning::util::logger::Logger, mut network: crate::lightning_invoice::Currency, mut amt_msat: crate::c_types::derived::COption_u64Z, mut description: crate::c_types::Str, mut duration_since_epoch: u64, mut invoice_expiry_delta_secs: u32, mut min_final_cltv_expiry_delta: crate::c_types::derived::COption_u16Z) -> crate::c_types::derived::CResult_Bolt11InvoiceSignOrCreationErrorZ { let mut local_amt_msat = if amt_msat.is_some() { Some( { amt_msat.take() }) } else { None }; let mut local_min_final_cltv_expiry_delta = if min_final_cltv_expiry_delta.is_some() { Some( { min_final_cltv_expiry_delta.take() }) } else { None }; - let mut ret = lightning_invoice::utils::create_invoice_from_channelmanager_and_duration_since_epoch::(channelmanager.get_native_ref(), node_signer, logger, network.into_native(), local_amt_msat, description.into_string(), core::time::Duration::from_secs(duration_since_epoch), invoice_expiry_delta_secs, local_min_final_cltv_expiry_delta); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::Invoice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::SignOrCreationError::native_into(e) }).into() }; + let mut ret = lightning_invoice::utils::create_invoice_from_channelmanager_and_duration_since_epoch::(channelmanager.get_native_ref(), node_signer, logger, network.into_native(), local_amt_msat, description.into_string(), core::time::Duration::from_secs(duration_since_epoch), invoice_expiry_delta_secs, local_min_final_cltv_expiry_delta); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::Bolt11Invoice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::SignOrCreationError::native_into(e) }).into() }; local_ret } @@ -196,11 +194,11 @@ pub extern "C" fn create_invoice_from_channelmanager_and_duration_since_epoch(ch /// This may be useful if you're building an on-chain swap or involving another protocol where /// the payment hash is also involved outside the scope of lightning. #[no_mangle] -pub extern "C" fn create_invoice_from_channelmanager_and_duration_since_epoch_with_payment_hash(channelmanager: &crate::lightning::ln::channelmanager::ChannelManager, mut node_signer: crate::lightning::chain::keysinterface::NodeSigner, mut logger: crate::lightning::util::logger::Logger, mut network: crate::lightning_invoice::Currency, mut amt_msat: crate::c_types::derived::COption_u64Z, mut description: crate::c_types::Str, mut duration_since_epoch: u64, mut invoice_expiry_delta_secs: u32, mut payment_hash: crate::c_types::ThirtyTwoBytes, mut min_final_cltv_expiry_delta: crate::c_types::derived::COption_u16Z) -> crate::c_types::derived::CResult_InvoiceSignOrCreationErrorZ { +pub extern "C" fn create_invoice_from_channelmanager_and_duration_since_epoch_with_payment_hash(channelmanager: &crate::lightning::ln::channelmanager::ChannelManager, mut node_signer: crate::lightning::sign::NodeSigner, mut logger: crate::lightning::util::logger::Logger, mut network: crate::lightning_invoice::Currency, mut amt_msat: crate::c_types::derived::COption_u64Z, mut description: crate::c_types::Str, mut duration_since_epoch: u64, mut invoice_expiry_delta_secs: u32, mut payment_hash: crate::c_types::ThirtyTwoBytes, mut min_final_cltv_expiry_delta: crate::c_types::derived::COption_u16Z) -> crate::c_types::derived::CResult_Bolt11InvoiceSignOrCreationErrorZ { let mut local_amt_msat = if amt_msat.is_some() { Some( { amt_msat.take() }) } else { None }; let mut local_min_final_cltv_expiry_delta = if min_final_cltv_expiry_delta.is_some() { Some( { min_final_cltv_expiry_delta.take() }) } else { None }; - let mut ret = lightning_invoice::utils::create_invoice_from_channelmanager_and_duration_since_epoch_with_payment_hash::(channelmanager.get_native_ref(), node_signer, logger, network.into_native(), local_amt_msat, description.into_string(), core::time::Duration::from_secs(duration_since_epoch), invoice_expiry_delta_secs, ::lightning::ln::PaymentHash(payment_hash.data), local_min_final_cltv_expiry_delta); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::Invoice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::SignOrCreationError::native_into(e) }).into() }; + let mut ret = lightning_invoice::utils::create_invoice_from_channelmanager_and_duration_since_epoch_with_payment_hash::(channelmanager.get_native_ref(), node_signer, logger, network.into_native(), local_amt_msat, description.into_string(), core::time::Duration::from_secs(duration_since_epoch), invoice_expiry_delta_secs, ::lightning::ln::PaymentHash(payment_hash.data), local_min_final_cltv_expiry_delta); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::Bolt11Invoice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::SignOrCreationError::native_into(e) }).into() }; local_ret } diff --git a/lightning-c-bindings/src/lightning_persister.rs b/lightning-c-bindings/src/lightning_persister.rs index 5af129eb..49ea8790 100644 --- a/lightning-c-bindings/src/lightning_persister.rs +++ b/lightning-c-bindings/src/lightning_persister.rs @@ -109,7 +109,7 @@ pub extern "C" fn FilesystemPersister_get_data_dir(this_arg: &crate::lightning_p /// Read `ChannelMonitor`s from disk. #[must_use] #[no_mangle] -pub extern "C" fn FilesystemPersister_read_channelmonitors(this_arg: &crate::lightning_persister::FilesystemPersister, mut entropy_source: crate::lightning::chain::keysinterface::EntropySource, signer_provider: &crate::lightning::chain::keysinterface::SignerProvider) -> crate::c_types::derived::CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ { +pub extern "C" fn FilesystemPersister_read_channelmonitors(this_arg: &crate::lightning_persister::FilesystemPersister, mut entropy_source: crate::lightning::sign::EntropySource, signer_provider: &crate::lightning::sign::SignerProvider) -> crate::c_types::derived::CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.read_channelmonitors(entropy_source, signer_provider); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = Vec::new(); for mut item in o.drain(..) { local_ret_0.push( { let (mut orig_ret_0_0_0, mut orig_ret_0_0_1) = item; let mut local_ret_0_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0_0.into_inner() }, crate::lightning::chain::channelmonitor::ChannelMonitor { inner: ObjOps::heap_alloc(orig_ret_0_0_1), is_owned: true }).into(); local_ret_0_0 }); }; local_ret_0.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::IOError::from_rust(e) }).into() }; local_ret diff --git a/lightning-c-bindings/src/lightning_rapid_gossip_sync/mod.rs b/lightning-c-bindings/src/lightning_rapid_gossip_sync/mod.rs index 87b15b2c..b4c2d51c 100644 --- a/lightning-c-bindings/src/lightning_rapid_gossip_sync/mod.rs +++ b/lightning-c-bindings/src/lightning_rapid_gossip_sync/mod.rs @@ -141,6 +141,33 @@ pub extern "C" fn RapidGossipSync_new(network_graph: &crate::lightning::routing: crate::lightning_rapid_gossip_sync::RapidGossipSync { inner: ObjOps::heap_alloc(ret), is_owned: true } } +/// Sync gossip data from a file. +/// Returns the last sync timestamp to be used the next time rapid sync data is queried. +/// +/// `network_graph`: The network graph to apply the updates to +/// +/// `sync_path`: Path to the file where the gossip update data is located +/// +#[must_use] +#[no_mangle] +pub extern "C" fn RapidGossipSync_sync_network_graph_with_file_path(this_arg: &crate::lightning_rapid_gossip_sync::RapidGossipSync, mut sync_path: crate::c_types::Str) -> crate::c_types::derived::CResult_u32GraphSyncErrorZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.sync_network_graph_with_file_path(sync_path.into_str()); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { o }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_rapid_gossip_sync::error::GraphSyncError::native_into(e) }).into() }; + local_ret +} + +/// Update network graph from binary data. +/// Returns the last sync timestamp to be used the next time rapid sync data is queried. +/// +/// `update_data`: `&[u8]` binary stream that comprises the update data +#[must_use] +#[no_mangle] +pub extern "C" fn RapidGossipSync_update_network_graph(this_arg: &crate::lightning_rapid_gossip_sync::RapidGossipSync, mut update_data: crate::c_types::u8slice) -> crate::c_types::derived::CResult_u32GraphSyncErrorZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.update_network_graph(update_data.to_slice()); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { o }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_rapid_gossip_sync::error::GraphSyncError::native_into(e) }).into() }; + local_ret +} + /// Update network graph from binary data. /// Returns the last sync timestamp to be used the next time rapid sync data is queried. ///