From fa53bccc47204dba265106ed70c796f8e20109a1 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Wed, 2 Mar 2022 03:53:18 +0000 Subject: [PATCH] Update auto-generated bindings to 0.0.106 --- lightning-c-bindings/include/ldk_rust_types.h | 22 +- lightning-c-bindings/include/lightning.h | 2384 ++++++++++++++--- lightning-c-bindings/include/lightningpp.hpp | 800 ++++-- lightning-c-bindings/src/c_types/derived.rs | 1785 +++++++++--- .../src/lightning/chain/keysinterface.rs | 378 ++- .../src/lightning/ln/chan_utils.rs | 131 + .../src/lightning/ln/channelmanager.rs | 200 ++ lightning-c-bindings/src/lightning/ln/msgs.rs | 219 +- lightning-c-bindings/src/lightning/mod.rs | 22 + .../src/lightning/routing/network_graph.rs | 404 ++- .../src/lightning/routing/router.rs | 164 +- .../src/lightning/routing/scoring.rs | 344 ++- .../src/lightning/util/config.rs | 38 +- .../src/lightning/util/events.rs | 80 +- .../src/lightning/util/invoice.rs | 27 + .../src/lightning/util/mod.rs | 23 + .../src/lightning_invoice/mod.rs | 176 +- .../src/lightning_invoice/payment.rs | 18 +- .../src/lightning_invoice/utils.rs | 46 +- 19 files changed, 5936 insertions(+), 1325 deletions(-) create mode 100644 lightning-c-bindings/src/lightning/util/invoice.rs diff --git a/lightning-c-bindings/include/ldk_rust_types.h b/lightning-c-bindings/include/ldk_rust_types.h index 7ef9dd9..eb35dae 100644 --- a/lightning-c-bindings/include/ldk_rust_types.h +++ b/lightning-c-bindings/include/ldk_rust_types.h @@ -10,6 +10,8 @@ #else #define NONNULL_PTR #endif +struct nativeCounterpartyCommitmentSecretsOpaque; +typedef struct nativeCounterpartyCommitmentSecretsOpaque LDKnativeCounterpartyCommitmentSecrets; struct nativeTxCreationKeysOpaque; typedef struct nativeTxCreationKeysOpaque LDKnativeTxCreationKeys; struct nativeChannelPublicKeysOpaque; @@ -46,8 +48,8 @@ struct nativeRouteOpaque; typedef struct nativeRouteOpaque LDKnativeRoute; struct nativeRouteParametersOpaque; typedef struct nativeRouteParametersOpaque LDKnativeRouteParameters; -struct nativePayeeOpaque; -typedef struct nativePayeeOpaque LDKnativePayee; +struct nativePaymentParametersOpaque; +typedef struct nativePaymentParametersOpaque LDKnativePaymentParameters; struct nativeRouteHintOpaque; typedef struct nativeRouteHintOpaque LDKnativeRouteHint; struct nativeRouteHintHopOpaque; @@ -58,10 +60,14 @@ struct nativeWatchedOutputOpaque; typedef struct nativeWatchedOutputOpaque LDKnativeWatchedOutput; struct nativeMultiThreadedLockableScoreOpaque; typedef struct nativeMultiThreadedLockableScoreOpaque LDKnativeMultiThreadedLockableScore; +struct nativeFixedPenaltyScorerOpaque; +typedef struct nativeFixedPenaltyScorerOpaque LDKnativeFixedPenaltyScorer; struct nativeScorerOpaque; typedef struct nativeScorerOpaque LDKnativeScorer; struct nativeScoringParametersOpaque; typedef struct nativeScoringParametersOpaque LDKnativeScoringParameters; +struct nativeProbabilisticScoringParametersOpaque; +typedef struct nativeProbabilisticScoringParametersOpaque LDKnativeProbabilisticScoringParameters; struct nativeInitFeaturesOpaque; typedef struct nativeInitFeaturesOpaque LDKnativeInitFeatures; struct nativeNodeFeaturesOpaque; @@ -81,6 +87,8 @@ struct nativeInMemorySignerOpaque; typedef struct nativeInMemorySignerOpaque LDKnativeInMemorySigner; struct nativeKeysManagerOpaque; typedef struct nativeKeysManagerOpaque LDKnativeKeysManager; +struct nativePhantomKeysManagerOpaque; +typedef struct nativePhantomKeysManagerOpaque LDKnativePhantomKeysManager; struct nativeFilesystemPersisterOpaque; typedef struct nativeFilesystemPersisterOpaque LDKnativeFilesystemPersister; struct nativeChannelManagerOpaque; @@ -93,6 +101,8 @@ struct nativeChannelCounterpartyOpaque; typedef struct nativeChannelCounterpartyOpaque LDKnativeChannelCounterparty; struct nativeChannelDetailsOpaque; typedef struct nativeChannelDetailsOpaque LDKnativeChannelDetails; +struct nativePhantomRouteHintsOpaque; +typedef struct nativePhantomRouteHintsOpaque LDKnativePhantomRouteHints; struct nativeChannelManagerReadArgsOpaque; typedef struct nativeChannelManagerReadArgsOpaque LDKnativeChannelManagerReadArgs; struct nativeChannelHandshakeConfigOpaque; @@ -157,10 +167,12 @@ struct nativeReadOnlyNetworkGraphOpaque; typedef struct nativeReadOnlyNetworkGraphOpaque LDKnativeReadOnlyNetworkGraph; struct nativeNetGraphMsgHandlerOpaque; typedef struct nativeNetGraphMsgHandlerOpaque LDKnativeNetGraphMsgHandler; -struct nativeDirectionalChannelInfoOpaque; -typedef struct nativeDirectionalChannelInfoOpaque LDKnativeDirectionalChannelInfo; +struct nativeChannelUpdateInfoOpaque; +typedef struct nativeChannelUpdateInfoOpaque LDKnativeChannelUpdateInfo; struct nativeChannelInfoOpaque; typedef struct nativeChannelInfoOpaque LDKnativeChannelInfo; +struct nativeDirectedChannelInfoOpaque; +typedef struct nativeDirectedChannelInfoOpaque LDKnativeDirectedChannelInfo; struct nativeRoutingFeesOpaque; typedef struct nativeRoutingFeesOpaque LDKnativeRoutingFees; struct nativeNodeAnnouncementInfoOpaque; @@ -173,6 +185,8 @@ struct nativeInitOpaque; typedef struct nativeInitOpaque LDKnativeInit; struct nativeErrorMessageOpaque; typedef struct nativeErrorMessageOpaque LDKnativeErrorMessage; +struct nativeWarningMessageOpaque; +typedef struct nativeWarningMessageOpaque LDKnativeWarningMessage; struct nativePingOpaque; typedef struct nativePingOpaque LDKnativePing; struct nativePongOpaque; diff --git a/lightning-c-bindings/include/lightning.h b/lightning-c-bindings/include/lightning.h index 7c5d88d..f00bbc2 100644 --- a/lightning-c-bindings/include/lightning.h +++ b/lightning-c-bindings/include/lightning.h @@ -156,17 +156,20 @@ typedef enum LDKCreationError { */ LDKCreationError_RouteTooLong, /** - * The unix timestamp of the supplied date is <0 or can't be represented as `SystemTime` + * The Unix timestamp of the supplied date is less than zero or greater than 35-bits */ LDKCreationError_TimestampOutOfBounds, - /** - * The supplied expiry time could cause an overflow if added to a `PositiveTimestamp` - */ - LDKCreationError_ExpiryTimeOutOfBounds, /** * The supplied millisatoshi amount was greater than the total bitcoin supply. */ LDKCreationError_InvalidAmount, + /** + * Route hints were required for this invoice and were missing. Applies to + * [phantom invoices]. + * + * [phantom invoices]: crate::utils::create_phantom_invoice + */ + LDKCreationError_MissingRouteHints, /** * Must be last for serialization purposes */ @@ -291,6 +294,28 @@ typedef enum LDKNetwork { LDKNetwork_Sentinel, } LDKNetwork; +/** + * Specifies the recipient of an invoice, to indicate to [`KeysInterface::sign_invoice`] what node + * secret key should be used to sign the invoice. + */ +typedef enum LDKRecipient { + /** + * The invoice should be signed with the local node secret key. + */ + LDKRecipient_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 + */ + LDKRecipient_PhantomNode, + /** + * Must be last for serialization purposes + */ + LDKRecipient_Sentinel, +} LDKRecipient; + /** * Represents an error returned from libsecp256k1 during validation of some secp256k1 data */ @@ -497,6 +522,114 @@ typedef struct LDKTxOut { uint64_t value; } LDKTxOut; +/** + * The contents of CResult_NoneNoneZ + */ +typedef union LDKCResult_NoneNoneZPtr { + /** + * Note that this value is always NULL, as there are no contents in the OK variant + */ + void *result; + /** + * Note that this value is always NULL, as there are no contents in the Err variant + */ + void *err; +} LDKCResult_NoneNoneZPtr; + +/** + * A CResult_NoneNoneZ represents the result of a fallible operation, + * containing a () on success and a () on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_NoneNoneZ { + /** + * The contents of this CResult_NoneNoneZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_NoneNoneZPtr contents; + /** + * Whether this CResult_NoneNoneZ represents a success state. + */ + bool result_ok; +} LDKCResult_NoneNoneZ; + + + +/** + * Implements the per-commitment secret storage scheme from + * [BOLT 3](https://github.com/lightningnetwork/lightning-rfc/blob/dcbf8583976df087c79c3ce0b535311212e6812d/03-transactions.md#efficient-per-commitment-secret-storage). + * + * Allows us to keep track of all of the revocation secrets of our counterparty in just 50*32 bytes + * or so. + */ +typedef struct MUST_USE_STRUCT LDKCounterpartyCommitmentSecrets { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeCounterpartyCommitmentSecrets *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKCounterpartyCommitmentSecrets; + + + +/** + * An error in decoding a message or struct. + */ +typedef struct MUST_USE_STRUCT LDKDecodeError { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeDecodeError *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; +} LDKDecodeError; + +/** + * The contents of CResult_CounterpartyCommitmentSecretsDecodeErrorZ + */ +typedef union LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKCounterpartyCommitmentSecrets *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + struct LDKDecodeError *err; +} LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZPtr; + +/** + * A CResult_CounterpartyCommitmentSecretsDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::chan_utils::CounterpartyCommitmentSecrets on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ { + /** + * The contents of this CResult_CounterpartyCommitmentSecretsDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZPtr contents; + /** + * Whether this CResult_CounterpartyCommitmentSecretsDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ; + /** * Represents a valid secp256k1 secret key serialized as a 32 byte array. */ @@ -613,26 +746,6 @@ typedef struct MUST_USE_STRUCT LDKTxCreationKeys { bool is_owned; } LDKTxCreationKeys; - - -/** - * An error in decoding a message or struct. - */ -typedef struct MUST_USE_STRUCT LDKDecodeError { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeDecodeError *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; -} LDKDecodeError; - /** * The contents of CResult_TxCreationKeysDecodeErrorZ */ @@ -1562,7 +1675,7 @@ typedef struct LDKCResult_RouteDecodeErrorZ { /** - * Parameters needed to find a [`Route`] for paying a [`Payee`]. + * Parameters needed to find a [`Route`]. * * Passed to [`find_route`] and also provided in [`Event::PaymentPathFailed`] for retrying a failed * payment path. @@ -1685,53 +1798,53 @@ typedef struct LDKCOption_u64Z { /** * The recipient of a payment. */ -typedef struct MUST_USE_STRUCT LDKPayee { +typedef struct MUST_USE_STRUCT LDKPaymentParameters { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativePayee *inner; + LDKnativePaymentParameters *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; -} LDKPayee; +} LDKPaymentParameters; /** - * The contents of CResult_PayeeDecodeErrorZ + * The contents of CResult_PaymentParametersDecodeErrorZ */ -typedef union LDKCResult_PayeeDecodeErrorZPtr { +typedef union LDKCResult_PaymentParametersDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKPayee *result; + struct LDKPaymentParameters *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_PayeeDecodeErrorZPtr; +} LDKCResult_PaymentParametersDecodeErrorZPtr; /** - * A CResult_PayeeDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::routing::router::Payee on success and a crate::lightning::ln::msgs::DecodeError on failure. + * 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`. */ -typedef struct LDKCResult_PayeeDecodeErrorZ { +typedef struct LDKCResult_PaymentParametersDecodeErrorZ { /** - * The contents of this CResult_PayeeDecodeErrorZ, accessible via either + * The contents of this CResult_PaymentParametersDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_PayeeDecodeErrorZPtr contents; + union LDKCResult_PaymentParametersDecodeErrorZPtr contents; /** - * Whether this CResult_PayeeDecodeErrorZ represents a success state. + * Whether this CResult_PaymentParametersDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_PayeeDecodeErrorZ; +} LDKCResult_PaymentParametersDecodeErrorZ; @@ -2707,7 +2820,7 @@ typedef enum LDKEvent_Tag { * Note that this does *not* indicate that all paths for an MPP payment have failed, see * [`Event::PaymentFailed`] and [`all_paths_failed`]. * - * [`all_paths_failed`]: Self::all_paths_failed + * [`all_paths_failed`]: Self::PaymentPathFailed::all_paths_failed */ LDKEvent_PaymentPathFailed, /** @@ -2757,6 +2870,20 @@ typedef enum LDKEvent_Tag { * [`Event::PaymentSent`] for obtaining the payment preimage. */ LDKEvent_PaymentPathSuccessful, + /** + * 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_channel`]. + * + * 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_channel`]: crate::ln::channelmanager::ChannelManager::force_close_channel + * [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels + */ + LDKEvent_OpenChannelRequest, /** * Must be last for serialization purposes */ @@ -3034,6 +3161,32 @@ typedef struct LDKEvent_LDKPaymentPathSuccessful_Body { struct LDKCVec_RouteHopZ path; } LDKEvent_LDKPaymentPathSuccessful_Body; +typedef struct LDKEvent_LDKOpenChannelRequest_Body { + /** + * The temporary channel ID of the channel requested to be opened. + * + * When responding to the request, the `temporary_channel_id` should be passed + * back to the ChannelManager with [`ChannelManager::accept_inbound_channel`] to accept, + * or to [`ChannelManager::force_close_channel`] to reject. + * + * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel + * [`ChannelManager::force_close_channel`]: crate::ln::channelmanager::ChannelManager::force_close_channel + */ + struct LDKThirtyTwoBytes temporary_channel_id; + /** + * The node_id of the counterparty requesting to open the channel. + */ + struct LDKPublicKey counterparty_node_id; + /** + * The channel value of the requested channel. + */ + uint64_t funding_satoshis; + /** + * Our starting balance in the channel if the request is accepted, in milli-satoshi. + */ + uint64_t push_msat; +} LDKEvent_LDKOpenChannelRequest_Body; + typedef struct MUST_USE_STRUCT LDKEvent { LDKEvent_Tag tag; union { @@ -3048,6 +3201,7 @@ typedef struct MUST_USE_STRUCT LDKEvent { LDKEvent_LDKChannelClosed_Body channel_closed; LDKEvent_LDKDiscardFunding_Body discard_funding; LDKEvent_LDKPaymentPathSuccessful_Body payment_path_successful; + LDKEvent_LDKOpenChannelRequest_Body open_channel_request; }; } LDKEvent; @@ -3392,6 +3546,26 @@ typedef struct MUST_USE_STRUCT LDKErrorMessage { bool is_owned; } LDKErrorMessage; + + +/** + * A warning message to be sent or received from a peer + */ +typedef struct MUST_USE_STRUCT LDKWarningMessage { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeWarningMessage *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKWarningMessage; + /** * Used to put an error message in a LightningError */ @@ -3419,6 +3593,10 @@ typedef enum LDKErrorAction_Tag { * The peer did something incorrect. Tell them. */ LDKErrorAction_SendErrorMessage, + /** + * The peer did something incorrect. Tell them without closing any channels. + */ + LDKErrorAction_SendWarningMessage, /** * Must be last for serialization purposes */ @@ -3441,6 +3619,19 @@ typedef struct LDKErrorAction_LDKSendErrorMessage_Body { struct LDKErrorMessage msg; } LDKErrorAction_LDKSendErrorMessage_Body; +typedef struct LDKErrorAction_LDKSendWarningMessage_Body { + /** + * The message to send. + */ + struct LDKWarningMessage msg; + /** + * The peer may have done something harmless that we weren't able to meaningfully process, + * though we should still tell them about it. + * If this event is logged, log it at the given level. + */ + enum LDKLevel log_level; +} LDKErrorAction_LDKSendWarningMessage_Body; + typedef struct MUST_USE_STRUCT LDKErrorAction { LDKErrorAction_Tag tag; union { @@ -3449,6 +3640,7 @@ typedef struct MUST_USE_STRUCT LDKErrorAction { enum LDKLevel ignore_and_log; }; LDKErrorAction_LDKSendErrorMessage_Body send_error_message; + LDKErrorAction_LDKSendWarningMessage_Body send_warning_message; }; } LDKErrorAction; @@ -3874,6 +4066,59 @@ typedef struct LDKCVec_MessageSendEventZ { +/** + * [`Score`] implementation that uses a fixed penalty. + */ +typedef struct MUST_USE_STRUCT LDKFixedPenaltyScorer { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeFixedPenaltyScorer *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKFixedPenaltyScorer; + +/** + * The contents of CResult_FixedPenaltyScorerDecodeErrorZ + */ +typedef union LDKCResult_FixedPenaltyScorerDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKFixedPenaltyScorer *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + struct LDKDecodeError *err; +} LDKCResult_FixedPenaltyScorerDecodeErrorZPtr; + +/** + * A CResult_FixedPenaltyScorerDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::routing::scoring::FixedPenaltyScorer on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_FixedPenaltyScorerDecodeErrorZ { + /** + * The contents of this CResult_FixedPenaltyScorerDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_FixedPenaltyScorerDecodeErrorZPtr contents; + /** + * Whether this CResult_FixedPenaltyScorerDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_FixedPenaltyScorerDecodeErrorZ; + + + /** * Parameters for configuring [`Scorer`]. */ @@ -3933,7 +4178,12 @@ typedef struct LDKCResult_ScoringParametersDecodeErrorZ { * Used to apply a fixed penalty to each channel, thus avoiding long paths when shorter paths with * slightly higher fees are available. Will further penalize channels that fail to relay payments. * - * See [module-level documentation] for usage. + * See [module-level documentation] for usage and [`ScoringParameters`] for customization. + * + * # Note + * + * Mixing the `no-std` feature between serialization and deserialization results in undefined + * behavior. * * [module-level documentation]: crate::routing::scoring */ @@ -3987,6 +4237,59 @@ typedef struct LDKCResult_ScorerDecodeErrorZ { +/** + * Parameters for configuring [`ProbabilisticScorer`]. + */ +typedef struct MUST_USE_STRUCT LDKProbabilisticScoringParameters { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeProbabilisticScoringParameters *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKProbabilisticScoringParameters; + +/** + * The contents of CResult_ProbabilisticScoringParametersDecodeErrorZ + */ +typedef union LDKCResult_ProbabilisticScoringParametersDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKProbabilisticScoringParameters *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_ProbabilisticScoringParametersDecodeErrorZPtr; + +/** + * A CResult_ProbabilisticScoringParametersDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::routing::scoring::ProbabilisticScoringParameters 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_ProbabilisticScoringParametersDecodeErrorZ { + /** + * The contents of this CResult_ProbabilisticScoringParametersDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_ProbabilisticScoringParametersDecodeErrorZPtr contents; + /** + * Whether this CResult_ProbabilisticScoringParametersDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_ProbabilisticScoringParametersDecodeErrorZ; + + + /** * Features used within an `init` message. */ @@ -4359,35 +4662,20 @@ typedef struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ { } LDKCResult_SpendableOutputDescriptorDecodeErrorZ; /** - * The contents of CResult_NoneNoneZ + * A dynamically-allocated array of crate::c_types::ThirtyTwoBytess of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef union LDKCResult_NoneNoneZPtr { +typedef struct LDKCVec_PaymentPreimageZ { /** - * Note that this value is always NULL, as there are no contents in the OK variant + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - void *result; + struct LDKThirtyTwoBytes *data; /** - * Note that this value is always NULL, as there are no contents in the Err variant - */ - void *err; -} LDKCResult_NoneNoneZPtr; - -/** - * A CResult_NoneNoneZ represents the result of a fallible operation, - * containing a () on success and a () on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_NoneNoneZ { - /** - * The contents of this CResult_NoneNoneZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. - */ - union LDKCResult_NoneNoneZPtr contents; - /** - * Whether this CResult_NoneNoneZ represents a success state. + * The number of elements pointed to by `data`. */ - bool result_ok; -} LDKCResult_NoneNoneZ; + uintptr_t datalen; +} LDKCVec_PaymentPreimageZ; /** * A tuple of 2 elements. See the individual fields for the types contained. @@ -4467,6 +4755,84 @@ typedef struct LDKCResult_SignatureNoneZ { bool result_ok; } LDKCResult_SignatureNoneZ; +/** + * A tuple of 2 elements. See the individual fields for the types contained. + */ +typedef struct LDKC2Tuple_SignatureSignatureZ { + /** + * The element at position 0 + */ + struct LDKSignature a; + /** + * The element at position 1 + */ + struct LDKSignature b; +} LDKC2Tuple_SignatureSignatureZ; + +/** + * The contents of CResult_C2Tuple_SignatureSignatureZNoneZ + */ +typedef union LDKCResult_C2Tuple_SignatureSignatureZNoneZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKC2Tuple_SignatureSignatureZ *result; + /** + * Note that this value is always NULL, as there are no contents in the Err variant + */ + void *err; +} LDKCResult_C2Tuple_SignatureSignatureZNoneZPtr; + +/** + * A CResult_C2Tuple_SignatureSignatureZNoneZ represents the result of a fallible operation, + * containing a crate::c_types::derived::C2Tuple_SignatureSignatureZ on success and a () on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_C2Tuple_SignatureSignatureZNoneZ { + /** + * The contents of this CResult_C2Tuple_SignatureSignatureZNoneZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_C2Tuple_SignatureSignatureZNoneZPtr contents; + /** + * Whether this CResult_C2Tuple_SignatureSignatureZNoneZ represents a success state. + */ + bool result_ok; +} LDKCResult_C2Tuple_SignatureSignatureZNoneZ; + +/** + * The contents of CResult_SecretKeyNoneZ + */ +typedef union LDKCResult_SecretKeyNoneZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKSecretKey *result; + /** + * Note that this value is always NULL, as there are no contents in the Err variant + */ + void *err; +} LDKCResult_SecretKeyNoneZPtr; + +/** + * A CResult_SecretKeyNoneZ represents the result of a fallible operation, + * containing a crate::c_types::SecretKey on success and a () on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_SecretKeyNoneZ { + /** + * The contents of this CResult_SecretKeyNoneZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_SecretKeyNoneZPtr contents; + /** + * Whether this CResult_SecretKeyNoneZ represents a success state. + */ + bool result_ok; +} LDKCResult_SecretKeyNoneZ; + /** @@ -4560,8 +4926,15 @@ typedef struct LDKBaseSign { * 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: all the relevant preimages will be provided, but there may also be additional + * irrelevant or duplicate preimages. */ - struct LDKCResult_NoneNoneZ (*validate_holder_commitment)(const void *this_arg, const struct LDKHolderCommitmentTransaction *NONNULL_PTR holder_tx); + struct LDKCResult_NoneNoneZ (*validate_holder_commitment)(const void *this_arg, const struct LDKHolderCommitmentTransaction *NONNULL_PTR holder_tx, struct LDKCVec_PaymentPreimageZ preimages); /** * Gets the holder's channel public keys and basepoints */ @@ -4585,8 +4958,15 @@ typedef struct LDKBaseSign { * * 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: all the relevant preimages will be provided, but there may also be additional + * irrelevant or duplicate preimages. */ - struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ (*sign_counterparty_commitment)(const void *this_arg, const struct LDKCommitmentTransaction *NONNULL_PTR commitment_tx); + struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ (*sign_counterparty_commitment)(const void *this_arg, const struct LDKCommitmentTransaction *NONNULL_PTR commitment_tx, struct LDKCVec_PaymentPreimageZ preimages); /** * Validate the counterparty's revocation. * @@ -4673,14 +5053,17 @@ typedef struct LDKBaseSign { */ struct LDKCResult_SignatureNoneZ (*sign_closing_transaction)(const void *this_arg, const struct LDKClosingTransaction *NONNULL_PTR closing_tx); /** - * Signs a channel announcement message with our funding key, proving it comes from one - * of the channel participants. + * Signs a channel announcement message with our funding key and our node secret key (aka + * node_id or network_key), proving it comes from one of the channel participants. + * + * The first returned signature should be from our node secret key, the second from our + * funding key. * * Note that if this fails or is rejected, the channel will not be publicly announced and * our counterparty may (though likely will not) close the channel on us for violating the * protocol. */ - struct LDKCResult_SignatureNoneZ (*sign_channel_announcement)(const void *this_arg, const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR msg); + struct LDKCResult_C2Tuple_SignatureSignatureZNoneZ (*sign_channel_announcement)(const void *this_arg, const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR msg); /** * Set the counterparty static channel data, including basepoints, * counterparty_selected/holder_selected_contest_delay and funding outpoint. @@ -4768,6 +5151,29 @@ typedef struct LDKCResult_SignDecodeErrorZ { bool result_ok; } LDKCResult_SignDecodeErrorZ; +/** + * Integer in the range `0..32` + */ +typedef struct LDKu5 { + uint8_t _0; +} LDKu5; + +/** + * A dynamically-allocated array of crate::c_types::u5s of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_u5Z { + /** + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + */ + struct LDKu5 *data; + /** + * The number of elements pointed to by `data`. + */ + uintptr_t datalen; +} LDKCVec_u5Z; + /** * Represents a secp256k1 signature serialized as two 32-byte numbers as well as a tag which * allows recovering the exact public key which created the signature given the message. @@ -5788,6 +6194,201 @@ typedef struct LDKCResult_PaymentPreimageAPIErrorZ { bool result_ok; } LDKCResult_PaymentPreimageAPIErrorZ; + + +/** + * Information needed for constructing an invoice route hint for this channel. + */ +typedef struct MUST_USE_STRUCT LDKCounterpartyForwardingInfo { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeCounterpartyForwardingInfo *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKCounterpartyForwardingInfo; + +/** + * The contents of CResult_CounterpartyForwardingInfoDecodeErrorZ + */ +typedef union LDKCResult_CounterpartyForwardingInfoDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKCounterpartyForwardingInfo *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + struct LDKDecodeError *err; +} LDKCResult_CounterpartyForwardingInfoDecodeErrorZPtr; + +/** + * A CResult_CounterpartyForwardingInfoDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::channelmanager::CounterpartyForwardingInfo on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_CounterpartyForwardingInfoDecodeErrorZ { + /** + * The contents of this CResult_CounterpartyForwardingInfoDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_CounterpartyForwardingInfoDecodeErrorZPtr contents; + /** + * Whether this CResult_CounterpartyForwardingInfoDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_CounterpartyForwardingInfoDecodeErrorZ; + + + +/** + * Channel parameters which apply to our counterparty. These are split out from [`ChannelDetails`] + * to better separate parameters. + */ +typedef struct MUST_USE_STRUCT LDKChannelCounterparty { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeChannelCounterparty *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKChannelCounterparty; + +/** + * The contents of CResult_ChannelCounterpartyDecodeErrorZ + */ +typedef union LDKCResult_ChannelCounterpartyDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKChannelCounterparty *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + struct LDKDecodeError *err; +} LDKCResult_ChannelCounterpartyDecodeErrorZPtr; + +/** + * A CResult_ChannelCounterpartyDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::channelmanager::ChannelCounterparty on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_ChannelCounterpartyDecodeErrorZ { + /** + * The contents of this CResult_ChannelCounterpartyDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_ChannelCounterpartyDecodeErrorZPtr contents; + /** + * Whether this CResult_ChannelCounterpartyDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_ChannelCounterpartyDecodeErrorZ; + +/** + * The contents of CResult_ChannelDetailsDecodeErrorZ + */ +typedef union LDKCResult_ChannelDetailsDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKChannelDetails *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + struct LDKDecodeError *err; +} LDKCResult_ChannelDetailsDecodeErrorZPtr; + +/** + * A CResult_ChannelDetailsDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::channelmanager::ChannelDetails on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_ChannelDetailsDecodeErrorZ { + /** + * The contents of this CResult_ChannelDetailsDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_ChannelDetailsDecodeErrorZPtr contents; + /** + * Whether this CResult_ChannelDetailsDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_ChannelDetailsDecodeErrorZ; + + + +/** + * Route hints used in constructing invoices for [phantom node payents]. + * + * [phantom node payments]: crate::chain::keysinterface::PhantomKeysManager + */ +typedef struct MUST_USE_STRUCT LDKPhantomRouteHints { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativePhantomRouteHints *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKPhantomRouteHints; + +/** + * The contents of CResult_PhantomRouteHintsDecodeErrorZ + */ +typedef union LDKCResult_PhantomRouteHintsDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKPhantomRouteHints *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_PhantomRouteHintsDecodeErrorZPtr; + +/** + * A CResult_PhantomRouteHintsDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::channelmanager::PhantomRouteHints on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_PhantomRouteHintsDecodeErrorZ { + /** + * The contents of this CResult_PhantomRouteHintsDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_PhantomRouteHintsDecodeErrorZPtr contents; + /** + * Whether this CResult_PhantomRouteHintsDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_PhantomRouteHintsDecodeErrorZ; + /** * A dynamically-allocated array of crate::lightning::chain::channelmonitor::ChannelMonitors of arbitrary size. * This corresponds to std::vector in C++ @@ -5940,11 +6541,12 @@ typedef struct LDKKeysInterface { */ void *this_arg; /** - * Get node secret key (aka node_id or network_key). + * Get node secret key (aka node_id or network_key) based on the provided [`Recipient`]. * - * This method must return the same value each time it is called. + * This method must return the same value each time it is called with a given `Recipient` + * parameter. */ - struct LDKSecretKey (*get_node_secret)(const void *this_arg); + struct LDKCResult_SecretKeyNoneZ (*get_node_secret)(const void *this_arg, enum LDKRecipient recipient); /** * Get a script pubkey which we send funds to when claiming on-chain contestable outputs. * @@ -5984,16 +6586,25 @@ typedef struct LDKKeysInterface { */ struct LDKCResult_SignDecodeErrorZ (*read_chan_signer)(const void *this_arg, struct LDKu8slice reader); /** - * Sign an invoice's preimage (note that this is the preimage of the invoice, not the HTLC's - * preimage). By parameterizing by the preimage instead of the hash, we allow implementors of + * 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 is ascii bytes, while the invoice data is base32. + * + * The secret key used to sign the invoice is dependent on the [`Recipient`]. */ - struct LDKCResult_RecoverableSignatureNoneZ (*sign_invoice)(const void *this_arg, struct LDKCVec_u8Z invoice_preimage); + struct LDKCResult_RecoverableSignatureNoneZ (*sign_invoice)(const void *this_arg, struct LDKu8slice hrp_bytes, struct LDKCVec_u5Z invoice_data, enum LDKRecipient receipient); /** * Get secret key material as bytes for use in encrypting and decrypting inbound payment data. * + * If the implementor of this trait supports [phantom node payments], then every node that is + * intended to be included in the phantom invoice route hints must return the same value from + * this method. + * * This method must return the same value each time it is called. + * + * [phantom node payments]: PhantomKeysManager */ struct LDKThirtyTwoBytes (*get_inbound_payment_key_material)(const void *this_arg); /** @@ -6727,12 +7338,12 @@ typedef struct LDKCVec_PrivateRouteZ { /** - * A timestamp that refers to a date after 1 January 1970 which means its representation as UNIX - * timestamp is positive. + * A timestamp that refers to a date after 1 January 1970. * * # Invariants - * The UNIX timestamp representing the stored time has to be positive and small enough so that - * a `EpiryTime` can be added to it without an overflow. + * + * The Unix timestamp representing the stored time has to be positive and no greater than + * [`MAX_TIMESTAMP`]. */ typedef struct MUST_USE_STRUCT LDKPositiveTimestamp { /** @@ -6903,65 +7514,6 @@ typedef struct LDKCResult_DescriptionCreationErrorZ { bool result_ok; } LDKCResult_DescriptionCreationErrorZ; - - -/** - * Positive duration that defines when (relatively to the timestamp) in the future the invoice - * expires - * - * # Invariants - * The number of seconds this expiry time represents has to be in the range - * `0...(SYSTEM_TIME_MAX_UNIX_TIMESTAMP - MAX_EXPIRY_TIME)` to avoid overflows when adding it to a - * timestamp - */ -typedef struct MUST_USE_STRUCT LDKExpiryTime { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeExpiryTime *inner; - /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. - */ - bool is_owned; -} LDKExpiryTime; - -/** - * The contents of CResult_ExpiryTimeCreationErrorZ - */ -typedef union LDKCResult_ExpiryTimeCreationErrorZPtr { - /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. - */ - struct LDKExpiryTime *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_ExpiryTimeCreationErrorZPtr; - -/** - * A CResult_ExpiryTimeCreationErrorZ represents the result of a fallible operation, - * containing a crate::lightning_invoice::ExpiryTime 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_ExpiryTimeCreationErrorZ { - /** - * The contents of this CResult_ExpiryTimeCreationErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. - */ - union LDKCResult_ExpiryTimeCreationErrorZPtr contents; - /** - * Whether this CResult_ExpiryTimeCreationErrorZ represents a success state. - */ - bool result_ok; -} LDKCResult_ExpiryTimeCreationErrorZ; - /** * The contents of CResult_PrivateRouteCreationErrorZ */ @@ -7888,56 +8440,55 @@ typedef struct LDKCOption_AccessZ { /** - * Details about one direction of a channel. Received - * within a channel update. + * Details about one direction of a channel as received within a [`ChannelUpdate`]. */ -typedef struct MUST_USE_STRUCT LDKDirectionalChannelInfo { +typedef struct MUST_USE_STRUCT LDKChannelUpdateInfo { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeDirectionalChannelInfo *inner; + LDKnativeChannelUpdateInfo *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKDirectionalChannelInfo; +} LDKChannelUpdateInfo; /** - * The contents of CResult_DirectionalChannelInfoDecodeErrorZ + * The contents of CResult_ChannelUpdateInfoDecodeErrorZ */ -typedef union LDKCResult_DirectionalChannelInfoDecodeErrorZPtr { +typedef union LDKCResult_ChannelUpdateInfoDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKDirectionalChannelInfo *result; + struct LDKChannelUpdateInfo *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_DirectionalChannelInfoDecodeErrorZPtr; +} LDKCResult_ChannelUpdateInfoDecodeErrorZPtr; /** - * A CResult_DirectionalChannelInfoDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::routing::network_graph::DirectionalChannelInfo on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_ChannelUpdateInfoDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::routing::network_graph::ChannelUpdateInfo on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_DirectionalChannelInfoDecodeErrorZ { +typedef struct LDKCResult_ChannelUpdateInfoDecodeErrorZ { /** - * The contents of this CResult_DirectionalChannelInfoDecodeErrorZ, accessible via either + * The contents of this CResult_ChannelUpdateInfoDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_DirectionalChannelInfoDecodeErrorZPtr contents; + union LDKCResult_ChannelUpdateInfoDecodeErrorZPtr contents; /** - * Whether this CResult_DirectionalChannelInfoDecodeErrorZ represents a success state. + * Whether this CResult_ChannelUpdateInfoDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_DirectionalChannelInfoDecodeErrorZ; +} LDKCResult_ChannelUpdateInfoDecodeErrorZ; @@ -9392,6 +9943,39 @@ typedef struct LDKCResult_ErrorMessageDecodeErrorZ { bool result_ok; } LDKCResult_ErrorMessageDecodeErrorZ; +/** + * The contents of CResult_WarningMessageDecodeErrorZ + */ +typedef union LDKCResult_WarningMessageDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKWarningMessage *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_WarningMessageDecodeErrorZPtr; + +/** + * A CResult_WarningMessageDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::WarningMessage on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_WarningMessageDecodeErrorZ { + /** + * The contents of this CResult_WarningMessageDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_WarningMessageDecodeErrorZPtr contents; + /** + * Whether this CResult_WarningMessageDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_WarningMessageDecodeErrorZ; + /** @@ -9688,6 +10272,22 @@ typedef struct LDKCResult_GossipTimestampFilterDecodeErrorZ { bool result_ok; } LDKCResult_GossipTimestampFilterDecodeErrorZ; +/** + * A dynamically-allocated array of crate::lightning::ln::channelmanager::PhantomRouteHintss of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_PhantomRouteHintsZ { + /** + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + */ + struct LDKPhantomRouteHints *data; + /** + * The number of elements pointed to by `data`. + */ + uintptr_t datalen; +} LDKCVec_PhantomRouteHintsZ; + /** * When signing using a fallible method either an user-supplied `SignError` or a `CreationError` * may occur. @@ -10389,6 +10989,12 @@ typedef struct MUST_USE_STRUCT LDKChainMonitor { * ChannelMonitor closes may use seed/1' * Cooperative closes may use seed/2' * The two close keys may be needed to claim on-chain funds! + * + * This struct cannot be used for nodes that wish to support receiving phantom payments; + * [`PhantomKeysManager`] must be used instead. + * + * Note that switching between this struct and [`PhantomKeysManager`] will invalidate any + * previously issued invoices and attempts to pay previous invoices will fail. */ typedef struct MUST_USE_STRUCT LDKKeysManager { /** @@ -10408,67 +11014,60 @@ typedef struct MUST_USE_STRUCT LDKKeysManager { /** - * Chain-related parameters used to construct a new `ChannelManager`. + * Similar to [`KeysManager`], but allows the node using this struct to receive phantom node + * payments. * - * Typically, the block-specific parameters are derived from the best block hash for the network, - * as a newly constructed `ChannelManager` will not have created any channels yet. These parameters - * are not needed when deserializing a previously constructed `ChannelManager`. - */ -typedef struct MUST_USE_STRUCT LDKChainParameters { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeChainParameters *inner; - /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. - */ - bool is_owned; -} LDKChainParameters; - - - -/** - * Information needed for constructing an invoice route hint for this channel. + * A phantom node payment is a payment made to a phantom invoice, which is an invoice that can be + * paid to one of multiple nodes. This works because we encode the invoice route hints such that + * LDK will recognize an incoming payment as destined for a phantom node, and collect the payment + * itself without ever needing to forward to this fake node. + * + * Phantom node payments are useful for load balancing between multiple LDK nodes. They also + * provide some fault tolerance, because payers will automatically retry paying other provided + * nodes in the case that one node goes down. + * + * Note that multi-path payments are not supported in phantom invoices for security reasons. + * Switching between this struct and [`KeysManager`] will invalidate any previously issued + * invoices and attempts to pay previous invoices will fail. */ -typedef struct MUST_USE_STRUCT LDKCounterpartyForwardingInfo { +typedef struct MUST_USE_STRUCT LDKPhantomKeysManager { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeCounterpartyForwardingInfo *inner; + LDKnativePhantomKeysManager *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKCounterpartyForwardingInfo; +} LDKPhantomKeysManager; /** - * Channel parameters which apply to our counterparty. These are split out from [`ChannelDetails`] - * to better separate parameters. + * Chain-related parameters used to construct a new `ChannelManager`. + * + * Typically, the block-specific parameters are derived from the best block hash for the network, + * as a newly constructed `ChannelManager` will not have created any channels yet. These parameters + * are not needed when deserializing a previously constructed `ChannelManager`. */ -typedef struct MUST_USE_STRUCT LDKChannelCounterparty { +typedef struct MUST_USE_STRUCT LDKChainParameters { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeChannelCounterparty *inner; + LDKnativeChainParameters *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKChannelCounterparty; +} LDKChainParameters; /** * A 3-byte byte array. @@ -11041,6 +11640,94 @@ typedef struct MUST_USE_STRUCT LDKNetGraphMsgHandler { bool is_owned; } LDKNetGraphMsgHandler; + + +/** + * A wrapper around [`ChannelInfo`] representing information about the channel as directed from a + * source node to a target node. + */ +typedef struct MUST_USE_STRUCT LDKDirectedChannelInfo { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeDirectedChannelInfo *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKDirectedChannelInfo; + +/** + * The effective capacity of a channel for routing purposes. + * + * While this may be smaller than the actual channel capacity, amounts greater than + * [`Self::as_msat`] should not be routed through the channel. + */ +typedef enum LDKEffectiveCapacity_Tag { + /** + * The available liquidity in the channel known from being a channel counterparty, and thus a + * direct hop. + */ + LDKEffectiveCapacity_ExactLiquidity, + /** + * The maximum HTLC amount in one direction as advertised on the gossip network. + */ + LDKEffectiveCapacity_MaximumHTLC, + /** + * The total capacity of the channel as determined by the funding transaction. + */ + LDKEffectiveCapacity_Total, + /** + * A capacity sufficient to route any payment, typically used for private channels provided by + * an invoice. + */ + LDKEffectiveCapacity_Infinite, + /** + * A capacity that is unknown possibly because either the chain state is unavailable to know + * the total capacity or the `htlc_maximum_msat` was not advertised on the gossip network. + */ + LDKEffectiveCapacity_Unknown, + /** + * Must be last for serialization purposes + */ + LDKEffectiveCapacity_Sentinel, +} LDKEffectiveCapacity_Tag; + +typedef struct LDKEffectiveCapacity_LDKExactLiquidity_Body { + /** + * Either the inbound or outbound liquidity depending on the direction, denominated in + * millisatoshi. + */ + uint64_t liquidity_msat; +} LDKEffectiveCapacity_LDKExactLiquidity_Body; + +typedef struct LDKEffectiveCapacity_LDKMaximumHTLC_Body { + /** + * The maximum HTLC amount denominated in millisatoshi. + */ + uint64_t amount_msat; +} LDKEffectiveCapacity_LDKMaximumHTLC_Body; + +typedef struct LDKEffectiveCapacity_LDKTotal_Body { + /** + * The funding amount denominated in millisatoshi. + */ + uint64_t capacity_msat; +} LDKEffectiveCapacity_LDKTotal_Body; + +typedef struct MUST_USE_STRUCT LDKEffectiveCapacity { + LDKEffectiveCapacity_Tag tag; + union { + LDKEffectiveCapacity_LDKExactLiquidity_Body exact_liquidity; + LDKEffectiveCapacity_LDKMaximumHTLC_Body maximum_htlc; + LDKEffectiveCapacity_LDKTotal_Body total; + }; +} LDKEffectiveCapacity; + /** * An interface used to score payment channels for path finding. * @@ -11056,17 +11743,13 @@ typedef struct LDKScore { * 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 which are also being considered for use in - * the same payment) is given by `channel_capacity_msat`. It may be guessed from various - * sources or assumed from no data at all. - * - * For hints provided in the invoice, we assume the channel has sufficient capacity to accept - * the invoice's full amount, and provide a `channel_capacity_msat` of `None`. In all other - * cases it is set to `Some`, even if we're guessing at the channel value. - * - * Your code should be overflow-safe through a `channel_capacity_msat` of 21 million BTC. + * 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, uint64_t send_amt_msat, struct LDKCOption_u64Z channel_capacity_msat, const struct LDKNodeId *NONNULL_PTR source, const struct LDKNodeId *NONNULL_PTR target); + uint64_t (*channel_penalty_msat)(const void *this_arg, uint64_t short_channel_id, uint64_t send_amt_msat, uint64_t capacity_msat, const struct LDKNodeId *NONNULL_PTR source, const struct LDKNodeId *NONNULL_PTR target); /** * Handles updating channel penalties after failing to route through a channel. */ @@ -11275,6 +11958,27 @@ typedef struct MUST_USE_STRUCT LDKSha256 { +/** + * Positive duration that defines when (relatively to the timestamp) in the future the invoice + * expires + */ +typedef struct MUST_USE_STRUCT LDKExpiryTime { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeExpiryTime *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKExpiryTime; + + + /** * `min_final_cltv_expiry` to use for the last HTLC in the route */ @@ -11293,13 +11997,6 @@ typedef struct MUST_USE_STRUCT LDKMinFinalCltvExpiry { bool is_owned; } LDKMinFinalCltvExpiry; -/** - * Integer in the range `0..32` - */ -typedef struct LDKu5 { - uint8_t _0; -} LDKu5; - /** * A 20-byte byte array. */ @@ -11397,7 +12094,7 @@ typedef struct LDKRouter { * * Note that first_hops (or a relevant inner pointer) may be NULL or all-0s to represent None */ - struct LDKCResult_RouteLightningErrorZ (*find_route)(const void *this_arg, struct LDKPublicKey payer, const struct LDKRouteParameters *NONNULL_PTR params, const uint8_t (*payment_hash)[32], struct LDKCVec_ChannelDetailsZ *first_hops, const struct LDKScore *NONNULL_PTR scorer); + struct LDKCResult_RouteLightningErrorZ (*find_route)(const void *this_arg, struct LDKPublicKey payer, const struct LDKRouteParameters *NONNULL_PTR route_params, const uint8_t (*payment_hash)[32], struct LDKCVec_ChannelDetailsZ *first_hops, const struct LDKScore *NONNULL_PTR scorer); /** * 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. @@ -11489,6 +12186,12 @@ extern const uint32_t MIN_FINAL_CLTV_EXPIRY; extern const uintptr_t REVOKEABLE_REDEEMSCRIPT_MAX_LENGTH; +extern const uint64_t UNKNOWN_CHANNEL_CAPACITY_MSAT; + +extern const uint32_t DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA; + +extern const uint64_t MAX_TIMESTAMP; + extern const uint64_t DEFAULT_EXPIRY_TIME; extern const uint64_t DEFAULT_MIN_FINAL_CLTV_EXPIRY; @@ -11550,6 +12253,58 @@ void Str_free(struct LDKStr _res); const void *__unmangle_inner_ptr(const void *ptr); #endif +/** + * Creates a new CResult_NoneNoneZ in the success state. + */ +struct LDKCResult_NoneNoneZ CResult_NoneNoneZ_ok(void); + +/** + * Creates a new CResult_NoneNoneZ in the error state. + */ +struct LDKCResult_NoneNoneZ CResult_NoneNoneZ_err(void); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_NoneNoneZ_is_ok(const struct LDKCResult_NoneNoneZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_NoneNoneZ. + */ +void CResult_NoneNoneZ_free(struct LDKCResult_NoneNoneZ _res); + +/** + * Creates a new CResult_NoneNoneZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_NoneNoneZ CResult_NoneNoneZ_clone(const struct LDKCResult_NoneNoneZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_CounterpartyCommitmentSecretsDecodeErrorZ in the success state. + */ +struct LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok(struct LDKCounterpartyCommitmentSecrets o); + +/** + * Creates a new CResult_CounterpartyCommitmentSecretsDecodeErrorZ in the error state. + */ +struct LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok(const struct LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_CounterpartyCommitmentSecretsDecodeErrorZ. + */ +void CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free(struct LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ _res); + +/** + * Creates a new CResult_CounterpartyCommitmentSecretsDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(const struct LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR orig); + /** * Creates a new CResult_SecretKeyErrorZ in the success state. */ @@ -12130,30 +12885,30 @@ void COption_u64Z_free(struct LDKCOption_u64Z _res); struct LDKCOption_u64Z COption_u64Z_clone(const struct LDKCOption_u64Z *NONNULL_PTR orig); /** - * Creates a new CResult_PayeeDecodeErrorZ in the success state. + * Creates a new CResult_PaymentParametersDecodeErrorZ in the success state. */ -struct LDKCResult_PayeeDecodeErrorZ CResult_PayeeDecodeErrorZ_ok(struct LDKPayee o); +struct LDKCResult_PaymentParametersDecodeErrorZ CResult_PaymentParametersDecodeErrorZ_ok(struct LDKPaymentParameters o); /** - * Creates a new CResult_PayeeDecodeErrorZ in the error state. + * Creates a new CResult_PaymentParametersDecodeErrorZ in the error state. */ -struct LDKCResult_PayeeDecodeErrorZ CResult_PayeeDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_PaymentParametersDecodeErrorZ CResult_PaymentParametersDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_PayeeDecodeErrorZ_is_ok(const struct LDKCResult_PayeeDecodeErrorZ *NONNULL_PTR o); +bool CResult_PaymentParametersDecodeErrorZ_is_ok(const struct LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_PayeeDecodeErrorZ. + * Frees any resources used by the CResult_PaymentParametersDecodeErrorZ. */ -void CResult_PayeeDecodeErrorZ_free(struct LDKCResult_PayeeDecodeErrorZ _res); +void CResult_PaymentParametersDecodeErrorZ_free(struct LDKCResult_PaymentParametersDecodeErrorZ _res); /** - * Creates a new CResult_PayeeDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_PaymentParametersDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_PayeeDecodeErrorZ CResult_PayeeDecodeErrorZ_clone(const struct LDKCResult_PayeeDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_PaymentParametersDecodeErrorZ CResult_PaymentParametersDecodeErrorZ_clone(const struct LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR orig); /** * Frees the buffer pointed to by `data` if `datalen` is non-0. @@ -12472,6 +13227,26 @@ struct LDKCResult_COption_EventZDecodeErrorZ CResult_COption_EventZDecodeErrorZ_ */ void CVec_MessageSendEventZ_free(struct LDKCVec_MessageSendEventZ _res); +/** + * Creates a new CResult_FixedPenaltyScorerDecodeErrorZ in the success state. + */ +struct LDKCResult_FixedPenaltyScorerDecodeErrorZ CResult_FixedPenaltyScorerDecodeErrorZ_ok(struct LDKFixedPenaltyScorer o); + +/** + * Creates a new CResult_FixedPenaltyScorerDecodeErrorZ in the error state. + */ +struct LDKCResult_FixedPenaltyScorerDecodeErrorZ CResult_FixedPenaltyScorerDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(const struct LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_FixedPenaltyScorerDecodeErrorZ. + */ +void CResult_FixedPenaltyScorerDecodeErrorZ_free(struct LDKCResult_FixedPenaltyScorerDecodeErrorZ _res); + /** * Creates a new CResult_ScoringParametersDecodeErrorZ in the success state. */ @@ -12512,6 +13287,32 @@ bool CResult_ScorerDecodeErrorZ_is_ok(const struct LDKCResult_ScorerDecodeErrorZ */ void CResult_ScorerDecodeErrorZ_free(struct LDKCResult_ScorerDecodeErrorZ _res); +/** + * Creates a new CResult_ProbabilisticScoringParametersDecodeErrorZ in the success state. + */ +struct LDKCResult_ProbabilisticScoringParametersDecodeErrorZ CResult_ProbabilisticScoringParametersDecodeErrorZ_ok(struct LDKProbabilisticScoringParameters o); + +/** + * Creates a new CResult_ProbabilisticScoringParametersDecodeErrorZ in the error state. + */ +struct LDKCResult_ProbabilisticScoringParametersDecodeErrorZ CResult_ProbabilisticScoringParametersDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_ProbabilisticScoringParametersDecodeErrorZ_is_ok(const struct LDKCResult_ProbabilisticScoringParametersDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_ProbabilisticScoringParametersDecodeErrorZ. + */ +void CResult_ProbabilisticScoringParametersDecodeErrorZ_free(struct LDKCResult_ProbabilisticScoringParametersDecodeErrorZ _res); + +/** + * Creates a new CResult_ProbabilisticScoringParametersDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_ProbabilisticScoringParametersDecodeErrorZ CResult_ProbabilisticScoringParametersDecodeErrorZ_clone(const struct LDKCResult_ProbabilisticScoringParametersDecodeErrorZ *NONNULL_PTR orig); + /** * Creates a new CResult_InitFeaturesDecodeErrorZ in the success state. */ @@ -12691,98 +13492,139 @@ void CResult_SpendableOutputDescriptorDecodeErrorZ_free(struct LDKCResult_Spenda struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ CResult_SpendableOutputDescriptorDecodeErrorZ_clone(const struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_NoneNoneZ in the success state. + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -struct LDKCResult_NoneNoneZ CResult_NoneNoneZ_ok(void); +void CVec_PaymentPreimageZ_free(struct LDKCVec_PaymentPreimageZ _res); /** - * Creates a new CResult_NoneNoneZ in the error state. + * Creates a new tuple which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_NoneNoneZ CResult_NoneNoneZ_err(void); +struct LDKC2Tuple_SignatureCVec_SignatureZZ C2Tuple_SignatureCVec_SignatureZZ_clone(const struct LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR orig); + +/** + * Creates a new C2Tuple_SignatureCVec_SignatureZZ from the contained elements. + */ +struct LDKC2Tuple_SignatureCVec_SignatureZZ C2Tuple_SignatureCVec_SignatureZZ_new(struct LDKSignature a, struct LDKCVec_SignatureZ b); + +/** + * Frees any resources used by the C2Tuple_SignatureCVec_SignatureZZ. + */ +void C2Tuple_SignatureCVec_SignatureZZ_free(struct LDKC2Tuple_SignatureCVec_SignatureZZ _res); + +/** + * Creates a new CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ in the success state. + */ +struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(struct LDKC2Tuple_SignatureCVec_SignatureZZ o); + +/** + * Creates a new CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ in the error state. + */ +struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err(void); /** * Checks if the given object is currently in the success state */ -bool CResult_NoneNoneZ_is_ok(const struct LDKCResult_NoneNoneZ *NONNULL_PTR o); +bool CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(const struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_NoneNoneZ. + * Frees any resources used by the CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ. */ -void CResult_NoneNoneZ_free(struct LDKCResult_NoneNoneZ _res); +void CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res); /** - * Creates a new CResult_NoneNoneZ 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. */ -struct LDKCResult_NoneNoneZ CResult_NoneNoneZ_clone(const struct LDKCResult_NoneNoneZ *NONNULL_PTR orig); +struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(const struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_SignatureNoneZ in the success state. + */ +struct LDKCResult_SignatureNoneZ CResult_SignatureNoneZ_ok(struct LDKSignature o); + +/** + * Creates a new CResult_SignatureNoneZ in the error state. + */ +struct LDKCResult_SignatureNoneZ CResult_SignatureNoneZ_err(void); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_SignatureNoneZ_is_ok(const struct LDKCResult_SignatureNoneZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_SignatureNoneZ. + */ +void CResult_SignatureNoneZ_free(struct LDKCResult_SignatureNoneZ _res); + +/** + * Creates a new CResult_SignatureNoneZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_SignatureNoneZ CResult_SignatureNoneZ_clone(const struct LDKCResult_SignatureNoneZ *NONNULL_PTR orig); /** * Creates a new tuple which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKC2Tuple_SignatureCVec_SignatureZZ C2Tuple_SignatureCVec_SignatureZZ_clone(const struct LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR orig); +struct LDKC2Tuple_SignatureSignatureZ C2Tuple_SignatureSignatureZ_clone(const struct LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR orig); /** - * Creates a new C2Tuple_SignatureCVec_SignatureZZ from the contained elements. + * Creates a new C2Tuple_SignatureSignatureZ from the contained elements. */ -struct LDKC2Tuple_SignatureCVec_SignatureZZ C2Tuple_SignatureCVec_SignatureZZ_new(struct LDKSignature a, struct LDKCVec_SignatureZ b); +struct LDKC2Tuple_SignatureSignatureZ C2Tuple_SignatureSignatureZ_new(struct LDKSignature a, struct LDKSignature b); /** - * Frees any resources used by the C2Tuple_SignatureCVec_SignatureZZ. + * Frees any resources used by the C2Tuple_SignatureSignatureZ. */ -void C2Tuple_SignatureCVec_SignatureZZ_free(struct LDKC2Tuple_SignatureCVec_SignatureZZ _res); +void C2Tuple_SignatureSignatureZ_free(struct LDKC2Tuple_SignatureSignatureZ _res); /** - * Creates a new CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ in the success state. + * Creates a new CResult_C2Tuple_SignatureSignatureZNoneZ in the success state. */ -struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(struct LDKC2Tuple_SignatureCVec_SignatureZZ o); +struct LDKCResult_C2Tuple_SignatureSignatureZNoneZ CResult_C2Tuple_SignatureSignatureZNoneZ_ok(struct LDKC2Tuple_SignatureSignatureZ o); /** - * Creates a new CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ in the error state. + * Creates a new CResult_C2Tuple_SignatureSignatureZNoneZ in the error state. */ -struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err(void); +struct LDKCResult_C2Tuple_SignatureSignatureZNoneZ CResult_C2Tuple_SignatureSignatureZNoneZ_err(void); /** * Checks if the given object is currently in the success state */ -bool CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(const struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR o); +bool CResult_C2Tuple_SignatureSignatureZNoneZ_is_ok(const struct LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ. + * Frees any resources used by the CResult_C2Tuple_SignatureSignatureZNoneZ. */ -void CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res); +void CResult_C2Tuple_SignatureSignatureZNoneZ_free(struct LDKCResult_C2Tuple_SignatureSignatureZNoneZ _res); /** - * Creates a new CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ which has the same data as `orig` + * Creates a new CResult_C2Tuple_SignatureSignatureZNoneZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(const struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR orig); +struct LDKCResult_C2Tuple_SignatureSignatureZNoneZ CResult_C2Tuple_SignatureSignatureZNoneZ_clone(const struct LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR orig); /** - * Creates a new CResult_SignatureNoneZ in the success state. + * Creates a new CResult_SecretKeyNoneZ in the success state. */ -struct LDKCResult_SignatureNoneZ CResult_SignatureNoneZ_ok(struct LDKSignature o); +struct LDKCResult_SecretKeyNoneZ CResult_SecretKeyNoneZ_ok(struct LDKSecretKey o); /** - * Creates a new CResult_SignatureNoneZ in the error state. + * Creates a new CResult_SecretKeyNoneZ in the error state. */ -struct LDKCResult_SignatureNoneZ CResult_SignatureNoneZ_err(void); +struct LDKCResult_SecretKeyNoneZ CResult_SecretKeyNoneZ_err(void); /** * Checks if the given object is currently in the success state */ -bool CResult_SignatureNoneZ_is_ok(const struct LDKCResult_SignatureNoneZ *NONNULL_PTR o); - -/** - * Frees any resources used by the CResult_SignatureNoneZ. - */ -void CResult_SignatureNoneZ_free(struct LDKCResult_SignatureNoneZ _res); +bool CResult_SecretKeyNoneZ_is_ok(const struct LDKCResult_SecretKeyNoneZ *NONNULL_PTR o); /** - * Creates a new CResult_SignatureNoneZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Frees any resources used by the CResult_SecretKeyNoneZ. */ -struct LDKCResult_SignatureNoneZ CResult_SignatureNoneZ_clone(const struct LDKCResult_SignatureNoneZ *NONNULL_PTR orig); +void CResult_SecretKeyNoneZ_free(struct LDKCResult_SecretKeyNoneZ _res); /** * Creates a new CResult_SignDecodeErrorZ in the success state. @@ -12813,7 +13655,7 @@ struct LDKCResult_SignDecodeErrorZ CResult_SignDecodeErrorZ_clone(const struct L /** * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -void CVec_u8Z_free(struct LDKCVec_u8Z _res); +void CVec_u5Z_free(struct LDKCVec_u5Z _res); /** * Creates a new CResult_RecoverableSignatureNoneZ in the success state. @@ -12841,6 +13683,11 @@ void CResult_RecoverableSignatureNoneZ_free(struct LDKCResult_RecoverableSignatu */ struct LDKCResult_RecoverableSignatureNoneZ CResult_RecoverableSignatureNoneZ_clone(const struct LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR orig); +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_u8Z_free(struct LDKCVec_u8Z _res); + /** * Frees the buffer pointed to by `data` if `datalen` is non-0. */ @@ -13292,6 +14139,104 @@ void CResult_PaymentPreimageAPIErrorZ_free(struct LDKCResult_PaymentPreimageAPIE */ struct LDKCResult_PaymentPreimageAPIErrorZ CResult_PaymentPreimageAPIErrorZ_clone(const struct LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR orig); +/** + * Creates a new CResult_CounterpartyForwardingInfoDecodeErrorZ in the success state. + */ +struct LDKCResult_CounterpartyForwardingInfoDecodeErrorZ CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(struct LDKCounterpartyForwardingInfo o); + +/** + * Creates a new CResult_CounterpartyForwardingInfoDecodeErrorZ in the error state. + */ +struct LDKCResult_CounterpartyForwardingInfoDecodeErrorZ CResult_CounterpartyForwardingInfoDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(const struct LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_CounterpartyForwardingInfoDecodeErrorZ. + */ +void CResult_CounterpartyForwardingInfoDecodeErrorZ_free(struct LDKCResult_CounterpartyForwardingInfoDecodeErrorZ _res); + +/** + * Creates a new CResult_CounterpartyForwardingInfoDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_CounterpartyForwardingInfoDecodeErrorZ CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(const struct LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_ChannelCounterpartyDecodeErrorZ in the success state. + */ +struct LDKCResult_ChannelCounterpartyDecodeErrorZ CResult_ChannelCounterpartyDecodeErrorZ_ok(struct LDKChannelCounterparty o); + +/** + * Creates a new CResult_ChannelCounterpartyDecodeErrorZ in the error state. + */ +struct LDKCResult_ChannelCounterpartyDecodeErrorZ CResult_ChannelCounterpartyDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_ChannelCounterpartyDecodeErrorZ_is_ok(const struct LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_ChannelCounterpartyDecodeErrorZ. + */ +void CResult_ChannelCounterpartyDecodeErrorZ_free(struct LDKCResult_ChannelCounterpartyDecodeErrorZ _res); + +/** + * Creates a new CResult_ChannelCounterpartyDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_ChannelCounterpartyDecodeErrorZ CResult_ChannelCounterpartyDecodeErrorZ_clone(const struct LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_ChannelDetailsDecodeErrorZ in the success state. + */ +struct LDKCResult_ChannelDetailsDecodeErrorZ CResult_ChannelDetailsDecodeErrorZ_ok(struct LDKChannelDetails o); + +/** + * Creates a new CResult_ChannelDetailsDecodeErrorZ in the error state. + */ +struct LDKCResult_ChannelDetailsDecodeErrorZ CResult_ChannelDetailsDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_ChannelDetailsDecodeErrorZ_is_ok(const struct LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_ChannelDetailsDecodeErrorZ. + */ +void CResult_ChannelDetailsDecodeErrorZ_free(struct LDKCResult_ChannelDetailsDecodeErrorZ _res); + +/** + * Creates a new CResult_ChannelDetailsDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_ChannelDetailsDecodeErrorZ CResult_ChannelDetailsDecodeErrorZ_clone(const struct LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_PhantomRouteHintsDecodeErrorZ in the success state. + */ +struct LDKCResult_PhantomRouteHintsDecodeErrorZ CResult_PhantomRouteHintsDecodeErrorZ_ok(struct LDKPhantomRouteHints o); + +/** + * Creates a new CResult_PhantomRouteHintsDecodeErrorZ in the error state. + */ +struct LDKCResult_PhantomRouteHintsDecodeErrorZ CResult_PhantomRouteHintsDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_PhantomRouteHintsDecodeErrorZ_is_ok(const struct LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_PhantomRouteHintsDecodeErrorZ. + */ +void CResult_PhantomRouteHintsDecodeErrorZ_free(struct LDKCResult_PhantomRouteHintsDecodeErrorZ _res); + /** * Frees the buffer pointed to by `data` if `datalen` is non-0. */ @@ -13669,32 +14614,6 @@ void CResult_DescriptionCreationErrorZ_free(struct LDKCResult_DescriptionCreatio */ struct LDKCResult_DescriptionCreationErrorZ CResult_DescriptionCreationErrorZ_clone(const struct LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR orig); -/** - * Creates a new CResult_ExpiryTimeCreationErrorZ in the success state. - */ -struct LDKCResult_ExpiryTimeCreationErrorZ CResult_ExpiryTimeCreationErrorZ_ok(struct LDKExpiryTime o); - -/** - * Creates a new CResult_ExpiryTimeCreationErrorZ in the error state. - */ -struct LDKCResult_ExpiryTimeCreationErrorZ CResult_ExpiryTimeCreationErrorZ_err(enum LDKCreationError e); - -/** - * Checks if the given object is currently in the success state - */ -bool CResult_ExpiryTimeCreationErrorZ_is_ok(const struct LDKCResult_ExpiryTimeCreationErrorZ *NONNULL_PTR o); - -/** - * Frees any resources used by the CResult_ExpiryTimeCreationErrorZ. - */ -void CResult_ExpiryTimeCreationErrorZ_free(struct LDKCResult_ExpiryTimeCreationErrorZ _res); - -/** - * Creates a new CResult_ExpiryTimeCreationErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKCResult_ExpiryTimeCreationErrorZ CResult_ExpiryTimeCreationErrorZ_clone(const struct LDKCResult_ExpiryTimeCreationErrorZ *NONNULL_PTR orig); - /** * Creates a new CResult_PrivateRouteCreationErrorZ in the success state. */ @@ -14219,30 +15138,30 @@ struct LDKCOption_AccessZ COption_AccessZ_none(void); void COption_AccessZ_free(struct LDKCOption_AccessZ _res); /** - * Creates a new CResult_DirectionalChannelInfoDecodeErrorZ in the success state. + * Creates a new CResult_ChannelUpdateInfoDecodeErrorZ in the success state. */ -struct LDKCResult_DirectionalChannelInfoDecodeErrorZ CResult_DirectionalChannelInfoDecodeErrorZ_ok(struct LDKDirectionalChannelInfo o); +struct LDKCResult_ChannelUpdateInfoDecodeErrorZ CResult_ChannelUpdateInfoDecodeErrorZ_ok(struct LDKChannelUpdateInfo o); /** - * Creates a new CResult_DirectionalChannelInfoDecodeErrorZ in the error state. + * Creates a new CResult_ChannelUpdateInfoDecodeErrorZ in the error state. */ -struct LDKCResult_DirectionalChannelInfoDecodeErrorZ CResult_DirectionalChannelInfoDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_ChannelUpdateInfoDecodeErrorZ CResult_ChannelUpdateInfoDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_DirectionalChannelInfoDecodeErrorZ_is_ok(const struct LDKCResult_DirectionalChannelInfoDecodeErrorZ *NONNULL_PTR o); +bool CResult_ChannelUpdateInfoDecodeErrorZ_is_ok(const struct LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_DirectionalChannelInfoDecodeErrorZ. + * Frees any resources used by the CResult_ChannelUpdateInfoDecodeErrorZ. */ -void CResult_DirectionalChannelInfoDecodeErrorZ_free(struct LDKCResult_DirectionalChannelInfoDecodeErrorZ _res); +void CResult_ChannelUpdateInfoDecodeErrorZ_free(struct LDKCResult_ChannelUpdateInfoDecodeErrorZ _res); /** - * Creates a new CResult_DirectionalChannelInfoDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_ChannelUpdateInfoDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_DirectionalChannelInfoDecodeErrorZ CResult_DirectionalChannelInfoDecodeErrorZ_clone(const struct LDKCResult_DirectionalChannelInfoDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_ChannelUpdateInfoDecodeErrorZ CResult_ChannelUpdateInfoDecodeErrorZ_clone(const struct LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR orig); /** * Creates a new CResult_ChannelInfoDecodeErrorZ in the success state. @@ -15096,6 +16015,32 @@ void CResult_ErrorMessageDecodeErrorZ_free(struct LDKCResult_ErrorMessageDecodeE */ struct LDKCResult_ErrorMessageDecodeErrorZ CResult_ErrorMessageDecodeErrorZ_clone(const struct LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR orig); +/** + * Creates a new CResult_WarningMessageDecodeErrorZ in the success state. + */ +struct LDKCResult_WarningMessageDecodeErrorZ CResult_WarningMessageDecodeErrorZ_ok(struct LDKWarningMessage o); + +/** + * Creates a new CResult_WarningMessageDecodeErrorZ in the error state. + */ +struct LDKCResult_WarningMessageDecodeErrorZ CResult_WarningMessageDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_WarningMessageDecodeErrorZ_is_ok(const struct LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_WarningMessageDecodeErrorZ. + */ +void CResult_WarningMessageDecodeErrorZ_free(struct LDKCResult_WarningMessageDecodeErrorZ _res); + +/** + * Creates a new CResult_WarningMessageDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_WarningMessageDecodeErrorZ CResult_WarningMessageDecodeErrorZ_clone(const struct LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR orig); + /** * Creates a new CResult_UnsignedNodeAnnouncementDecodeErrorZ in the success state. */ @@ -15278,6 +16223,11 @@ void CResult_GossipTimestampFilterDecodeErrorZ_free(struct LDKCResult_GossipTime */ struct LDKCResult_GossipTimestampFilterDecodeErrorZ CResult_GossipTimestampFilterDecodeErrorZ_clone(const struct LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR orig); +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_PhantomRouteHintsZ_free(struct LDKCVec_PhantomRouteHintsZ _res); + /** * Creates a new CResult_InvoiceSignOrCreationErrorZ in the success state. */ @@ -15489,6 +16439,11 @@ struct LDKEvent Event_discard_funding(struct LDKThirtyTwoBytes channel_id, struc */ struct LDKEvent Event_payment_path_successful(struct LDKThirtyTwoBytes payment_id, struct LDKThirtyTwoBytes payment_hash, struct LDKCVec_RouteHopZ path); +/** + * Utility method to constructs a new OpenChannelRequest-variant Event + */ +struct LDKEvent Event_open_channel_request(struct LDKThirtyTwoBytes temporary_channel_id, struct LDKPublicKey counterparty_node_id, uint64_t funding_satoshis, uint64_t push_msat); + /** * Serialize the Event object into a byte array which can be read by Event_read */ @@ -15677,6 +16632,11 @@ struct LDKCResult_PublicKeyErrorZ recover_pk(struct LDKu8slice msg, struct LDKSt */ bool verify(struct LDKu8slice msg, struct LDKStr sig, struct LDKPublicKey pk); +/** + * Construct the invoice's HRP and signatureless data into a preimage to be hashed. + */ +struct LDKCVec_u8Z construct_invoice_preimage(struct LDKu8slice hrp_bytes, struct LDKCVec_u5Z data_without_signature); + /** * Creates a copy of the Level */ @@ -16424,10 +17384,44 @@ bool UserConfig_get_accept_inbound_channels(const struct LDKUserConfig *NONNULL_ */ void UserConfig_set_accept_inbound_channels(struct LDKUserConfig *NONNULL_PTR this_ptr, bool val); +/** + * If this is set to true, the user needs to manually accept inbound requests to open a new + * channel. + * + * When set to true, [`Event::OpenChannelRequest`] will be triggered once a request to open a + * new inbound channel is received through a [`msgs::OpenChannel`] message. In that case, a + * [`msgs::AcceptChannel`] message will not be sent back to the counterparty node unless the + * user explicitly chooses to accept the request. + * + * Default value: false. + * + * [`Event::OpenChannelRequest`]: crate::util::events::Event::OpenChannelRequest + * [`msgs::OpenChannel`]: crate::ln::msgs::OpenChannel + * [`msgs::AcceptChannel`]: crate::ln::msgs::AcceptChannel + */ +bool UserConfig_get_manually_accept_inbound_channels(const struct LDKUserConfig *NONNULL_PTR this_ptr); + +/** + * If this is set to true, the user needs to manually accept inbound requests to open a new + * channel. + * + * When set to true, [`Event::OpenChannelRequest`] will be triggered once a request to open a + * new inbound channel is received through a [`msgs::OpenChannel`] message. In that case, a + * [`msgs::AcceptChannel`] message will not be sent back to the counterparty node unless the + * user explicitly chooses to accept the request. + * + * Default value: false. + * + * [`Event::OpenChannelRequest`]: crate::util::events::Event::OpenChannelRequest + * [`msgs::OpenChannel`]: crate::ln::msgs::OpenChannel + * [`msgs::AcceptChannel`]: crate::ln::msgs::AcceptChannel + */ +void UserConfig_set_manually_accept_inbound_channels(struct LDKUserConfig *NONNULL_PTR this_ptr, bool val); + /** * Constructs a new UserConfig given each field */ -MUST_USE_RES struct LDKUserConfig UserConfig_new(struct LDKChannelHandshakeConfig own_channel_config_arg, struct LDKChannelHandshakeLimits peer_channel_config_limits_arg, struct LDKChannelConfig channel_options_arg, bool accept_forwards_to_priv_channels_arg, bool accept_inbound_channels_arg); +MUST_USE_RES struct LDKUserConfig UserConfig_new(struct LDKChannelHandshakeConfig own_channel_config_arg, struct LDKChannelHandshakeLimits peer_channel_config_limits_arg, struct LDKChannelConfig channel_options_arg, bool accept_forwards_to_priv_channels_arg, bool accept_inbound_channels_arg, bool manually_accept_inbound_channels_arg); /** * Creates a copy of the UserConfig @@ -17312,6 +18306,21 @@ struct LDKSign Sign_clone(const struct LDKSign *NONNULL_PTR orig); */ void Sign_free(struct LDKSign this_ptr); +/** + * Creates a copy of the Recipient + */ +enum LDKRecipient Recipient_clone(const enum LDKRecipient *NONNULL_PTR orig); + +/** + * Utility method to constructs a new Node-variant Recipient + */ +enum LDKRecipient Recipient_node(void); + +/** + * Utility method to constructs a new PhantomNode-variant Recipient + */ +enum LDKRecipient Recipient_phantom_node(void); + /** * Calls the free function if one is set */ @@ -17390,7 +18399,7 @@ struct LDKInMemorySigner InMemorySigner_clone(const struct LDKInMemorySigner *NO /** * Create a new InMemorySigner */ -MUST_USE_RES struct LDKInMemorySigner InMemorySigner_new(struct LDKSecretKey funding_key, struct LDKSecretKey revocation_base_key, struct LDKSecretKey payment_key, struct LDKSecretKey delayed_payment_base_key, struct LDKSecretKey htlc_base_key, struct LDKThirtyTwoBytes commitment_seed, uint64_t channel_value_satoshis, struct LDKThirtyTwoBytes channel_keys_id); +MUST_USE_RES struct LDKInMemorySigner InMemorySigner_new(struct LDKSecretKey node_secret, struct LDKSecretKey funding_key, struct LDKSecretKey revocation_base_key, struct LDKSecretKey payment_key, struct LDKSecretKey delayed_payment_base_key, struct LDKSecretKey htlc_base_key, struct LDKThirtyTwoBytes commitment_seed, uint64_t channel_value_satoshis, struct LDKThirtyTwoBytes channel_keys_id); /** * Counterparty pubkeys. @@ -17445,7 +18454,8 @@ MUST_USE_RES bool InMemorySigner_opt_anchors(const struct LDKInMemorySigner *NON * described by descriptor, returning the witness stack for the input. * * Returns an Err if the input at input_idx does not exist, has a non-empty script_sig, - * or is not spending the outpoint described by `descriptor.outpoint`. + * is not spending the outpoint described by `descriptor.outpoint`, + * or if an output descriptor script_pubkey does not match the one we can spend. */ MUST_USE_RES struct LDKCResult_CVec_CVec_u8ZZNoneZ InMemorySigner_sign_counterparty_payment_input(const struct LDKInMemorySigner *NONNULL_PTR this_arg, struct LDKTransaction spend_tx, uintptr_t input_idx, const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR descriptor); @@ -17454,8 +18464,9 @@ MUST_USE_RES struct LDKCResult_CVec_CVec_u8ZZNoneZ InMemorySigner_sign_counterpa * described by descriptor, returning the witness stack for the input. * * Returns an Err 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 does not have a - * sequence set to `descriptor.to_self_delay`. + * 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. */ MUST_USE_RES struct LDKCResult_CVec_CVec_u8ZZNoneZ InMemorySigner_sign_dynamic_p2wsh_input(const struct LDKInMemorySigner *NONNULL_PTR this_arg, struct LDKTransaction spend_tx, uintptr_t input_idx, const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR descriptor); @@ -17479,7 +18490,7 @@ struct LDKCVec_u8Z InMemorySigner_write(const struct LDKInMemorySigner *NONNULL_ /** * Read a InMemorySigner from a byte array, created by InMemorySigner_write */ -struct LDKCResult_InMemorySignerDecodeErrorZ InMemorySigner_read(struct LDKu8slice ser); +struct LDKCResult_InMemorySignerDecodeErrorZ InMemorySigner_read(struct LDKu8slice ser, struct LDKSecretKey arg); /** * Frees any resources used by the KeysManager, if is_owned is set and inner is non-NULL. @@ -17523,8 +18534,9 @@ MUST_USE_RES struct LDKInMemorySigner KeysManager_derive_channel_keys(const stru * 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 or - * if a descriptor was duplicated. + * 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. * @@ -17539,6 +18551,41 @@ MUST_USE_RES struct LDKCResult_TransactionNoneZ KeysManager_spend_spendable_outp */ struct LDKKeysInterface KeysManager_as_KeysInterface(const struct LDKKeysManager *NONNULL_PTR this_arg); +/** + * Frees any resources used by the PhantomKeysManager, if is_owned is set and inner is non-NULL. + */ +void PhantomKeysManager_free(struct LDKPhantomKeysManager this_obj); + +/** + * Constructs a new KeysInterface which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned KeysInterface must be freed before this_arg is + */ +struct LDKKeysInterface PhantomKeysManager_as_KeysInterface(const struct LDKPhantomKeysManager *NONNULL_PTR this_arg); + +/** + * Constructs a `PhantomKeysManager` given a 32-byte seed and an additional `cross_node_seed` + * that is shared across all nodes that intend to participate in [phantom node payments] together. + * + * 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_RES struct LDKPhantomKeysManager PhantomKeysManager_new(const uint8_t (*seed)[32], uint64_t starting_time_secs, uint32_t starting_time_nanos, const uint8_t (*cross_node_seed)[32]); + +/** + * See [`KeysManager::spend_spendable_outputs`] for documentation on this method. + */ +MUST_USE_RES struct LDKCResult_TransactionNoneZ PhantomKeysManager_spend_spendable_outputs(const struct LDKPhantomKeysManager *NONNULL_PTR this_arg, struct LDKCVec_SpendableOutputDescriptorZ descriptors, struct LDKCVec_TxOutZ outputs, struct LDKCVec_u8Z change_destination_script, uint32_t feerate_sat_per_1000_weight); + +/** + * See [`KeysManager::derive_channel_keys`] for documentation on this method. + */ +MUST_USE_RES struct LDKInMemorySigner PhantomKeysManager_derive_channel_keys(const struct LDKPhantomKeysManager *NONNULL_PTR this_arg, uint64_t channel_value_satoshis, const uint8_t (*params)[32]); + /** * Frees any resources used by the ChannelManager, if is_owned is set and inner is non-NULL. */ @@ -18052,6 +19099,48 @@ struct LDKPaymentSendFailure PaymentSendFailure_all_failed_retry_safe(struct LDK */ struct LDKPaymentSendFailure PaymentSendFailure_partial_failure(struct LDKCVec_CResult_NoneAPIErrorZZ results, struct LDKRouteParameters failed_paths_retry, struct LDKThirtyTwoBytes payment_id); +/** + * Frees any resources used by the PhantomRouteHints, if is_owned is set and inner is non-NULL. + */ +void PhantomRouteHints_free(struct LDKPhantomRouteHints this_obj); + +/** + * The list of channels to be included in the invoice route hints. + */ +struct LDKCVec_ChannelDetailsZ PhantomRouteHints_get_channels(const struct LDKPhantomRouteHints *NONNULL_PTR this_ptr); + +/** + * The list of channels to be included in the invoice route hints. + */ +void PhantomRouteHints_set_channels(struct LDKPhantomRouteHints *NONNULL_PTR this_ptr, struct LDKCVec_ChannelDetailsZ val); + +/** + * A fake scid used for representing the phantom node's fake channel in generating the invoice + * route hints. + */ +uint64_t PhantomRouteHints_get_phantom_scid(const struct LDKPhantomRouteHints *NONNULL_PTR this_ptr); + +/** + * A fake scid used for representing the phantom node's fake channel in generating the invoice + * route hints. + */ +void PhantomRouteHints_set_phantom_scid(struct LDKPhantomRouteHints *NONNULL_PTR this_ptr, uint64_t val); + +/** + * The pubkey of the real backing node that would ultimately receive the payment. + */ +struct LDKPublicKey PhantomRouteHints_get_real_node_pubkey(const struct LDKPhantomRouteHints *NONNULL_PTR this_ptr); + +/** + * The pubkey of the real backing node that would ultimately receive the payment. + */ +void PhantomRouteHints_set_real_node_pubkey(struct LDKPhantomRouteHints *NONNULL_PTR this_ptr, struct LDKPublicKey val); + +/** + * Constructs a new PhantomRouteHints given each field + */ +MUST_USE_RES struct LDKPhantomRouteHints PhantomRouteHints_new(struct LDKCVec_ChannelDetailsZ channels_arg, uint64_t phantom_scid_arg, struct LDKPublicKey real_node_pubkey_arg); + /** * Constructs a new ChannelManager to hold several channels and route between them. * @@ -18377,6 +19466,16 @@ MUST_USE_RES bool ChannelManager_claim_funds(const struct LDKChannelManager *NON */ MUST_USE_RES struct LDKPublicKey ChannelManager_get_our_node_id(const struct LDKChannelManager *NONNULL_PTR this_arg); +/** + * Called to accept a request to open a channel after [`Event::OpenChannelRequest`] has been + * triggered. + * + * The `temporary_channel_id` parameter indicates which inbound channel should be accepted. + * + * [`Event::OpenChannelRequest`]: crate::util::events::Event::OpenChannelRequest + */ +MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_accept_inbound_channel(const struct LDKChannelManager *NONNULL_PTR this_arg, const uint8_t (*temporary_channel_id)[32]); + /** * Gets a payment secret and payment hash for use in an invoice given to a third party wishing * to pay us. @@ -18486,6 +19585,21 @@ MUST_USE_RES struct LDKCResult_PaymentSecretAPIErrorZ ChannelManager_create_inbo */ MUST_USE_RES struct LDKCResult_PaymentPreimageAPIErrorZ ChannelManager_get_payment_preimage(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes payment_hash, struct LDKThirtyTwoBytes payment_secret); +/** + * 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 + */ +MUST_USE_RES uint64_t ChannelManager_get_phantom_scid(const struct LDKChannelManager *NONNULL_PTR this_arg); + +/** + * Gets route hints for use in receiving [phantom node payments]. + * + * [phantom node payments]: crate::chain::keysinterface::PhantomKeysManager + */ +MUST_USE_RES struct LDKPhantomRouteHints ChannelManager_get_phantom_route_hints(const struct LDKChannelManager *NONNULL_PTR this_arg); + /** * Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg. * This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is @@ -18518,26 +19632,66 @@ struct LDKConfirm ChannelManager_as_Confirm(const struct LDKChannelManager *NONN * * Note that this method is not available with the `no-std` feature. */ -MUST_USE_RES bool ChannelManager_await_persistable_update_timeout(const struct LDKChannelManager *NONNULL_PTR this_arg, uint64_t max_wait); +MUST_USE_RES bool ChannelManager_await_persistable_update_timeout(const struct LDKChannelManager *NONNULL_PTR this_arg, uint64_t max_wait); + +/** + * Blocks until ChannelManager needs to be persisted. Only one listener on + * `await_persistable_update` or `await_persistable_update_timeout` is guaranteed to be woken + * up. + */ +void ChannelManager_await_persistable_update(const struct LDKChannelManager *NONNULL_PTR this_arg); + +/** + * Gets the latest best block which was connected either via the [`chain::Listen`] or + * [`chain::Confirm`] interfaces. + */ +MUST_USE_RES struct LDKBestBlock ChannelManager_current_best_block(const struct LDKChannelManager *NONNULL_PTR this_arg); + +/** + * Constructs a new ChannelMessageHandler which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned ChannelMessageHandler must be freed before this_arg is + */ +struct LDKChannelMessageHandler ChannelManager_as_ChannelMessageHandler(const struct LDKChannelManager *NONNULL_PTR this_arg); + +/** + * Serialize the CounterpartyForwardingInfo object into a byte array which can be read by CounterpartyForwardingInfo_read + */ +struct LDKCVec_u8Z CounterpartyForwardingInfo_write(const struct LDKCounterpartyForwardingInfo *NONNULL_PTR obj); + +/** + * Read a CounterpartyForwardingInfo from a byte array, created by CounterpartyForwardingInfo_write + */ +struct LDKCResult_CounterpartyForwardingInfoDecodeErrorZ CounterpartyForwardingInfo_read(struct LDKu8slice ser); + +/** + * Serialize the ChannelCounterparty object into a byte array which can be read by ChannelCounterparty_read + */ +struct LDKCVec_u8Z ChannelCounterparty_write(const struct LDKChannelCounterparty *NONNULL_PTR obj); + +/** + * Read a ChannelCounterparty from a byte array, created by ChannelCounterparty_write + */ +struct LDKCResult_ChannelCounterpartyDecodeErrorZ ChannelCounterparty_read(struct LDKu8slice ser); /** - * Blocks until ChannelManager needs to be persisted. Only one listener on - * `await_persistable_update` or `await_persistable_update_timeout` is guaranteed to be woken - * up. + * Serialize the ChannelDetails object into a byte array which can be read by ChannelDetails_read */ -void ChannelManager_await_persistable_update(const struct LDKChannelManager *NONNULL_PTR this_arg); +struct LDKCVec_u8Z ChannelDetails_write(const struct LDKChannelDetails *NONNULL_PTR obj); /** - * Gets the latest best block which was connected either via the [`chain::Listen`] or - * [`chain::Confirm`] interfaces. + * Read a ChannelDetails from a byte array, created by ChannelDetails_write */ -MUST_USE_RES struct LDKBestBlock ChannelManager_current_best_block(const struct LDKChannelManager *NONNULL_PTR this_arg); +struct LDKCResult_ChannelDetailsDecodeErrorZ ChannelDetails_read(struct LDKu8slice ser); /** - * Constructs a new ChannelMessageHandler which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned ChannelMessageHandler must be freed before this_arg is + * Serialize the PhantomRouteHints object into a byte array which can be read by PhantomRouteHints_read */ -struct LDKChannelMessageHandler ChannelManager_as_ChannelMessageHandler(const struct LDKChannelManager *NONNULL_PTR this_arg); +struct LDKCVec_u8Z PhantomRouteHints_write(const struct LDKPhantomRouteHints *NONNULL_PTR obj); + +/** + * Read a PhantomRouteHints from a byte array, created by PhantomRouteHints_write + */ +struct LDKCResult_PhantomRouteHintsDecodeErrorZ PhantomRouteHints_read(struct LDKu8slice ser); /** * Serialize the ChannelManager object into a byte array which can be read by ChannelManager_read @@ -18686,28 +19840,34 @@ struct LDKInit Init_clone(const struct LDKInit *NONNULL_PTR orig); void ErrorMessage_free(struct LDKErrorMessage this_obj); /** - * The channel ID involved in the error + * The channel ID involved in the error. + * + * All-0s indicates a general error unrelated to a specific channel, after which all channels + * with the sending peer should be closed. */ const uint8_t (*ErrorMessage_get_channel_id(const struct LDKErrorMessage *NONNULL_PTR this_ptr))[32]; /** - * The channel ID involved in the error + * The channel ID involved in the error. + * + * All-0s indicates a general error unrelated to a specific channel, after which all channels + * with the sending peer should be closed. */ void ErrorMessage_set_channel_id(struct LDKErrorMessage *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** * A possibly human-readable error description. - * The string should be sanitized before it is used (e.g. emitted to logs - * or printed to stdout). Otherwise, a well crafted error message may trigger a security - * vulnerability in the terminal emulator or the logging subsystem. + * The string should be sanitized before it is used (e.g. emitted to logs or printed to + * stdout). Otherwise, a well crafted error message may trigger a security vulnerability in + * the terminal emulator or the logging subsystem. */ struct LDKStr ErrorMessage_get_data(const struct LDKErrorMessage *NONNULL_PTR this_ptr); /** * A possibly human-readable error description. - * The string should be sanitized before it is used (e.g. emitted to logs - * or printed to stdout). Otherwise, a well crafted error message may trigger a security - * vulnerability in the terminal emulator or the logging subsystem. + * The string should be sanitized before it is used (e.g. emitted to logs or printed to + * stdout). Otherwise, a well crafted error message may trigger a security vulnerability in + * the terminal emulator or the logging subsystem. */ void ErrorMessage_set_data(struct LDKErrorMessage *NONNULL_PTR this_ptr, struct LDKStr val); @@ -18721,6 +19881,51 @@ MUST_USE_RES struct LDKErrorMessage ErrorMessage_new(struct LDKThirtyTwoBytes ch */ struct LDKErrorMessage ErrorMessage_clone(const struct LDKErrorMessage *NONNULL_PTR orig); +/** + * Frees any resources used by the WarningMessage, if is_owned is set and inner is non-NULL. + */ +void WarningMessage_free(struct LDKWarningMessage this_obj); + +/** + * The channel ID involved in the warning. + * + * All-0s indicates a warning unrelated to a specific channel. + */ +const uint8_t (*WarningMessage_get_channel_id(const struct LDKWarningMessage *NONNULL_PTR this_ptr))[32]; + +/** + * The channel ID involved in the warning. + * + * All-0s indicates a warning unrelated to a specific channel. + */ +void WarningMessage_set_channel_id(struct LDKWarningMessage *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); + +/** + * A possibly human-readable warning description. + * The string should be sanitized before it is used (e.g. emitted to logs or printed to + * stdout). Otherwise, a well crafted error message may trigger a security vulnerability in + * the terminal emulator or the logging subsystem. + */ +struct LDKStr WarningMessage_get_data(const struct LDKWarningMessage *NONNULL_PTR this_ptr); + +/** + * A possibly human-readable warning description. + * The string should be sanitized before it is used (e.g. emitted to logs or printed to + * stdout). Otherwise, a well crafted error message may trigger a security vulnerability in + * the terminal emulator or the logging subsystem. + */ +void WarningMessage_set_data(struct LDKWarningMessage *NONNULL_PTR this_ptr, struct LDKStr val); + +/** + * Constructs a new WarningMessage given each field + */ +MUST_USE_RES struct LDKWarningMessage WarningMessage_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKStr data_arg); + +/** + * Creates a copy of the WarningMessage + */ +struct LDKWarningMessage WarningMessage_clone(const struct LDKWarningMessage *NONNULL_PTR orig); + /** * Frees any resources used by the Ping, if is_owned is set and inner is non-NULL. */ @@ -19138,6 +20343,28 @@ struct LDKPublicKey AcceptChannel_get_first_per_commitment_point(const struct LD */ void AcceptChannel_set_first_per_commitment_point(struct LDKAcceptChannel *NONNULL_PTR this_ptr, struct LDKPublicKey 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 [`OpenChannel::channel_type`]. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +struct LDKChannelTypeFeatures AcceptChannel_get_channel_type(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); + +/** + * The channel type that this channel will represent. If none is set, we derive the channel + * type from the intersection of our feature bits with our counterparty's feature bits from + * the Init message. + * + * This is required to match the equivalent field in [`OpenChannel::channel_type`]. + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +void AcceptChannel_set_channel_type(struct LDKAcceptChannel *NONNULL_PTR this_ptr, struct LDKChannelTypeFeatures val); + /** * Creates a copy of the AcceptChannel */ @@ -20512,6 +21739,11 @@ struct LDKErrorAction ErrorAction_ignore_duplicate_gossip(void); */ struct LDKErrorAction ErrorAction_send_error_message(struct LDKErrorMessage msg); +/** + * Utility method to constructs a new SendWarningMessage-variant ErrorAction + */ +struct LDKErrorAction ErrorAction_send_warning_message(struct LDKWarningMessage msg, enum LDKLevel log_level); + /** * Frees any resources used by the LightningError, if is_owned is set and inner is non-NULL. */ @@ -20886,6 +22118,16 @@ struct LDKCVec_u8Z ErrorMessage_write(const struct LDKErrorMessage *NONNULL_PTR */ struct LDKCResult_ErrorMessageDecodeErrorZ ErrorMessage_read(struct LDKu8slice ser); +/** + * Serialize the WarningMessage object into a byte array which can be read by WarningMessage_read + */ +struct LDKCVec_u8Z WarningMessage_write(const struct LDKWarningMessage *NONNULL_PTR obj); + +/** + * Read a WarningMessage from a byte array, created by WarningMessage_write + */ +struct LDKCResult_WarningMessageDecodeErrorZ WarningMessage_read(struct LDKu8slice ser); + /** * Serialize the UnsignedNodeAnnouncement object into a byte array which can be read by UnsignedNodeAnnouncement_read */ @@ -21264,6 +22506,51 @@ struct LDKThirtyTwoBytes build_commitment_secret(const uint8_t (*commitment_seed */ struct LDKTransaction build_closing_transaction(uint64_t to_holder_value_sat, uint64_t to_counterparty_value_sat, struct LDKCVec_u8Z to_holder_script, struct LDKCVec_u8Z to_counterparty_script, struct LDKOutPoint funding_outpoint); +/** + * Frees any resources used by the CounterpartyCommitmentSecrets, if is_owned is set and inner is non-NULL. + */ +void CounterpartyCommitmentSecrets_free(struct LDKCounterpartyCommitmentSecrets this_obj); + +/** + * Creates a copy of the CounterpartyCommitmentSecrets + */ +struct LDKCounterpartyCommitmentSecrets CounterpartyCommitmentSecrets_clone(const struct LDKCounterpartyCommitmentSecrets *NONNULL_PTR orig); + +/** + * Creates a new empty `CounterpartyCommitmentSecrets` structure. + */ +MUST_USE_RES struct LDKCounterpartyCommitmentSecrets CounterpartyCommitmentSecrets_new(void); + +/** + * Returns the minimum index of all stored secrets. Note that indexes start + * at 1 << 48 and get decremented by one for each new secret. + */ +MUST_USE_RES uint64_t CounterpartyCommitmentSecrets_get_min_seen_secret(const struct LDKCounterpartyCommitmentSecrets *NONNULL_PTR this_arg); + +/** + * Inserts the `secret` at `idx`. Returns `Ok(())` if the secret + * was generated in accordance with BOLT 3 and is consistent with previous secrets. + */ +MUST_USE_RES struct LDKCResult_NoneNoneZ CounterpartyCommitmentSecrets_provide_secret(struct LDKCounterpartyCommitmentSecrets *NONNULL_PTR this_arg, uint64_t idx, struct LDKThirtyTwoBytes secret); + +/** + * Returns the secret at `idx`. + * Returns `None` if `idx` is < [`CounterpartyCommitmentSecrets::get_min_seen_secret`]. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +MUST_USE_RES struct LDKThirtyTwoBytes CounterpartyCommitmentSecrets_get_secret(const struct LDKCounterpartyCommitmentSecrets *NONNULL_PTR this_arg, uint64_t idx); + +/** + * Serialize the CounterpartyCommitmentSecrets object into a byte array which can be read by CounterpartyCommitmentSecrets_read + */ +struct LDKCVec_u8Z CounterpartyCommitmentSecrets_write(const struct LDKCounterpartyCommitmentSecrets *NONNULL_PTR obj); + +/** + * Read a CounterpartyCommitmentSecrets from a byte array, created by CounterpartyCommitmentSecrets_write + */ +struct LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ CounterpartyCommitmentSecrets_read(struct LDKu8slice ser); + /** * Derives a per-commitment-transaction private key (eg an htlc key or delayed_payment key) * from the base secret and the per_commitment_point. @@ -22102,6 +23389,8 @@ MUST_USE_RES bool TrustedCommitmentTransaction_opt_anchors(const struct LDKTrust * which HTLCOutputInCommitment::transaction_output_index.is_some()). * * The returned Vec has one entry for each HTLC, and in the same order. + * + * This function is only valid in the holder commitment context, it always uses SigHashType::All. */ MUST_USE_RES struct LDKCResult_CVec_SignatureZNoneZ TrustedCommitmentTransaction_get_htlc_sigs(const struct LDKTrustedCommitmentTransaction *NONNULL_PTR this_arg, const uint8_t (*htlc_base_key)[32], const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR channel_parameters); @@ -22555,71 +23844,71 @@ struct LDKRoutingMessageHandler NetGraphMsgHandler_as_RoutingMessageHandler(cons struct LDKMessageSendEventsProvider NetGraphMsgHandler_as_MessageSendEventsProvider(const struct LDKNetGraphMsgHandler *NONNULL_PTR this_arg); /** - * Frees any resources used by the DirectionalChannelInfo, if is_owned is set and inner is non-NULL. + * Frees any resources used by the ChannelUpdateInfo, if is_owned is set and inner is non-NULL. */ -void DirectionalChannelInfo_free(struct LDKDirectionalChannelInfo this_obj); +void ChannelUpdateInfo_free(struct LDKChannelUpdateInfo this_obj); /** * When the last update to the channel direction was issued. * Value is opaque, as set in the announcement. */ -uint32_t DirectionalChannelInfo_get_last_update(const struct LDKDirectionalChannelInfo *NONNULL_PTR this_ptr); +uint32_t ChannelUpdateInfo_get_last_update(const struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr); /** * When the last update to the channel direction was issued. * Value is opaque, as set in the announcement. */ -void DirectionalChannelInfo_set_last_update(struct LDKDirectionalChannelInfo *NONNULL_PTR this_ptr, uint32_t val); +void ChannelUpdateInfo_set_last_update(struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr, uint32_t val); /** * Whether the channel can be currently used for payments (in this one direction). */ -bool DirectionalChannelInfo_get_enabled(const struct LDKDirectionalChannelInfo *NONNULL_PTR this_ptr); +bool ChannelUpdateInfo_get_enabled(const struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr); /** * Whether the channel can be currently used for payments (in this one direction). */ -void DirectionalChannelInfo_set_enabled(struct LDKDirectionalChannelInfo *NONNULL_PTR this_ptr, bool val); +void ChannelUpdateInfo_set_enabled(struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr, bool val); /** * The difference in CLTV values that you must have when routing through this channel. */ -uint16_t DirectionalChannelInfo_get_cltv_expiry_delta(const struct LDKDirectionalChannelInfo *NONNULL_PTR this_ptr); +uint16_t ChannelUpdateInfo_get_cltv_expiry_delta(const struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr); /** * The difference in CLTV values that you must have when routing through this channel. */ -void DirectionalChannelInfo_set_cltv_expiry_delta(struct LDKDirectionalChannelInfo *NONNULL_PTR this_ptr, uint16_t val); +void ChannelUpdateInfo_set_cltv_expiry_delta(struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr, uint16_t val); /** * The minimum value, which must be relayed to the next hop via the channel */ -uint64_t DirectionalChannelInfo_get_htlc_minimum_msat(const struct LDKDirectionalChannelInfo *NONNULL_PTR this_ptr); +uint64_t ChannelUpdateInfo_get_htlc_minimum_msat(const struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr); /** * The minimum value, which must be relayed to the next hop via the channel */ -void DirectionalChannelInfo_set_htlc_minimum_msat(struct LDKDirectionalChannelInfo *NONNULL_PTR this_ptr, uint64_t val); +void ChannelUpdateInfo_set_htlc_minimum_msat(struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr, uint64_t val); /** * The maximum value which may be relayed to the next hop via the channel. */ -struct LDKCOption_u64Z DirectionalChannelInfo_get_htlc_maximum_msat(const struct LDKDirectionalChannelInfo *NONNULL_PTR this_ptr); +struct LDKCOption_u64Z ChannelUpdateInfo_get_htlc_maximum_msat(const struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr); /** * The maximum value which may be relayed to the next hop via the channel. */ -void DirectionalChannelInfo_set_htlc_maximum_msat(struct LDKDirectionalChannelInfo *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); +void ChannelUpdateInfo_set_htlc_maximum_msat(struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); /** * Fees charged when the channel is used for routing */ -struct LDKRoutingFees DirectionalChannelInfo_get_fees(const struct LDKDirectionalChannelInfo *NONNULL_PTR this_ptr); +struct LDKRoutingFees ChannelUpdateInfo_get_fees(const struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr); /** * Fees charged when the channel is used for routing */ -void DirectionalChannelInfo_set_fees(struct LDKDirectionalChannelInfo *NONNULL_PTR this_ptr, struct LDKRoutingFees val); +void ChannelUpdateInfo_set_fees(struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr, struct LDKRoutingFees val); /** * Most recent update for the channel received from the network @@ -22629,7 +23918,7 @@ void DirectionalChannelInfo_set_fees(struct LDKDirectionalChannelInfo *NONNULL_P * * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKChannelUpdate DirectionalChannelInfo_get_last_update_message(const struct LDKDirectionalChannelInfo *NONNULL_PTR this_ptr); +struct LDKChannelUpdate ChannelUpdateInfo_get_last_update_message(const struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr); /** * Most recent update for the channel received from the network @@ -22639,27 +23928,27 @@ struct LDKChannelUpdate DirectionalChannelInfo_get_last_update_message(const str * * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void DirectionalChannelInfo_set_last_update_message(struct LDKDirectionalChannelInfo *NONNULL_PTR this_ptr, struct LDKChannelUpdate val); +void ChannelUpdateInfo_set_last_update_message(struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr, struct LDKChannelUpdate val); /** - * Constructs a new DirectionalChannelInfo given each field + * Constructs a new ChannelUpdateInfo given each field */ -MUST_USE_RES struct LDKDirectionalChannelInfo DirectionalChannelInfo_new(uint32_t last_update_arg, bool enabled_arg, uint16_t cltv_expiry_delta_arg, uint64_t htlc_minimum_msat_arg, struct LDKCOption_u64Z htlc_maximum_msat_arg, struct LDKRoutingFees fees_arg, struct LDKChannelUpdate last_update_message_arg); +MUST_USE_RES struct LDKChannelUpdateInfo ChannelUpdateInfo_new(uint32_t last_update_arg, bool enabled_arg, uint16_t cltv_expiry_delta_arg, uint64_t htlc_minimum_msat_arg, struct LDKCOption_u64Z htlc_maximum_msat_arg, struct LDKRoutingFees fees_arg, struct LDKChannelUpdate last_update_message_arg); /** - * Creates a copy of the DirectionalChannelInfo + * Creates a copy of the ChannelUpdateInfo */ -struct LDKDirectionalChannelInfo DirectionalChannelInfo_clone(const struct LDKDirectionalChannelInfo *NONNULL_PTR orig); +struct LDKChannelUpdateInfo ChannelUpdateInfo_clone(const struct LDKChannelUpdateInfo *NONNULL_PTR orig); /** - * Serialize the DirectionalChannelInfo object into a byte array which can be read by DirectionalChannelInfo_read + * Serialize the ChannelUpdateInfo object into a byte array which can be read by ChannelUpdateInfo_read */ -struct LDKCVec_u8Z DirectionalChannelInfo_write(const struct LDKDirectionalChannelInfo *NONNULL_PTR obj); +struct LDKCVec_u8Z ChannelUpdateInfo_write(const struct LDKChannelUpdateInfo *NONNULL_PTR obj); /** - * Read a DirectionalChannelInfo from a byte array, created by DirectionalChannelInfo_write + * Read a ChannelUpdateInfo from a byte array, created by ChannelUpdateInfo_write */ -struct LDKCResult_DirectionalChannelInfoDecodeErrorZ DirectionalChannelInfo_read(struct LDKu8slice ser); +struct LDKCResult_ChannelUpdateInfoDecodeErrorZ ChannelUpdateInfo_read(struct LDKu8slice ser); /** * Frees any resources used by the ChannelInfo, if is_owned is set and inner is non-NULL. @@ -22691,14 +23980,14 @@ void ChannelInfo_set_node_one(struct LDKChannelInfo *NONNULL_PTR this_ptr, struc * * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKDirectionalChannelInfo ChannelInfo_get_one_to_two(const struct LDKChannelInfo *NONNULL_PTR this_ptr); +struct LDKChannelUpdateInfo ChannelInfo_get_one_to_two(const struct LDKChannelInfo *NONNULL_PTR this_ptr); /** * Details about the first direction of a channel * * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void ChannelInfo_set_one_to_two(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKDirectionalChannelInfo val); +void ChannelInfo_set_one_to_two(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKChannelUpdateInfo val); /** * Source node of the second direction of a channel @@ -22715,14 +24004,14 @@ void ChannelInfo_set_node_two(struct LDKChannelInfo *NONNULL_PTR this_ptr, struc * * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKDirectionalChannelInfo ChannelInfo_get_two_to_one(const struct LDKChannelInfo *NONNULL_PTR this_ptr); +struct LDKChannelUpdateInfo ChannelInfo_get_two_to_one(const struct LDKChannelInfo *NONNULL_PTR this_ptr); /** * Details about the second direction of a channel * * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void ChannelInfo_set_two_to_one(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKDirectionalChannelInfo val); +void ChannelInfo_set_two_to_one(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKChannelUpdateInfo val); /** * The channel capacity as seen on-chain, if chain lookup is available. @@ -22769,6 +24058,77 @@ struct LDKCVec_u8Z ChannelInfo_write(const struct LDKChannelInfo *NONNULL_PTR ob */ struct LDKCResult_ChannelInfoDecodeErrorZ ChannelInfo_read(struct LDKu8slice ser); +/** + * Frees any resources used by the DirectedChannelInfo, if is_owned is set and inner is non-NULL. + */ +void DirectedChannelInfo_free(struct LDKDirectedChannelInfo this_obj); + +/** + * Creates a copy of the DirectedChannelInfo + */ +struct LDKDirectedChannelInfo DirectedChannelInfo_clone(const struct LDKDirectedChannelInfo *NONNULL_PTR orig); + +/** + * Returns information for the channel. + */ +MUST_USE_RES struct LDKChannelInfo DirectedChannelInfo_channel(const struct LDKDirectedChannelInfo *NONNULL_PTR this_arg); + +/** + * Returns information for the direction. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +MUST_USE_RES struct LDKChannelUpdateInfo DirectedChannelInfo_direction(const struct LDKDirectedChannelInfo *NONNULL_PTR this_arg); + +/** + * Returns the [`EffectiveCapacity`] of the channel in the direction. + * + * This is either the total capacity from the funding transaction, if known, or the + * `htlc_maximum_msat` for the direction as advertised by the gossip network, if known, + * whichever is smaller. + */ +MUST_USE_RES struct LDKEffectiveCapacity DirectedChannelInfo_effective_capacity(const struct LDKDirectedChannelInfo *NONNULL_PTR this_arg); + +/** + * Frees any resources used by the EffectiveCapacity + */ +void EffectiveCapacity_free(struct LDKEffectiveCapacity this_ptr); + +/** + * Creates a copy of the EffectiveCapacity + */ +struct LDKEffectiveCapacity EffectiveCapacity_clone(const struct LDKEffectiveCapacity *NONNULL_PTR orig); + +/** + * Utility method to constructs a new ExactLiquidity-variant EffectiveCapacity + */ +struct LDKEffectiveCapacity EffectiveCapacity_exact_liquidity(uint64_t liquidity_msat); + +/** + * Utility method to constructs a new MaximumHTLC-variant EffectiveCapacity + */ +struct LDKEffectiveCapacity EffectiveCapacity_maximum_htlc(uint64_t amount_msat); + +/** + * Utility method to constructs a new Total-variant EffectiveCapacity + */ +struct LDKEffectiveCapacity EffectiveCapacity_total(uint64_t capacity_msat); + +/** + * Utility method to constructs a new Infinite-variant EffectiveCapacity + */ +struct LDKEffectiveCapacity EffectiveCapacity_infinite(void); + +/** + * Utility method to constructs a new Unknown-variant EffectiveCapacity + */ +struct LDKEffectiveCapacity EffectiveCapacity_unknown(void); + +/** + * Returns the effective capacity denominated in millisatoshi. + */ +MUST_USE_RES uint64_t EffectiveCapacity_as_msat(const struct LDKEffectiveCapacity *NONNULL_PTR this_arg); + /** * Frees any resources used by the RoutingFees, if is_owned is set and inner is non-NULL. */ @@ -23063,6 +24423,23 @@ void NetworkGraph_close_channel_from_update(const struct LDKNetworkGraph *NONNUL */ void NetworkGraph_fail_node(const struct LDKNetworkGraph *NONNULL_PTR this_arg, struct LDKPublicKey _node_id, bool is_permanent); +/** + * 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 is only available with the `std` feature. See + * [`NetworkGraph::remove_stale_channels_with_time`] for `no-std` use. + */ +void NetworkGraph_remove_stale_channels(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 @@ -23240,7 +24617,7 @@ struct LDKCVec_CVec_RouteHopZZ Route_get_paths(const struct LDKRoute *NONNULL_PT void Route_set_paths(struct LDKRoute *NONNULL_PTR this_ptr, struct LDKCVec_CVec_RouteHopZZ val); /** - * The `payee` parameter passed to [`find_route`]. + * 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`]. * @@ -23248,10 +24625,10 @@ void Route_set_paths(struct LDKRoute *NONNULL_PTR this_ptr, struct LDKCVec_CVec_ * * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKPayee Route_get_payee(const struct LDKRoute *NONNULL_PTR this_ptr); +struct LDKPaymentParameters Route_get_payment_params(const struct LDKRoute *NONNULL_PTR this_ptr); /** - * The `payee` parameter passed to [`find_route`]. + * 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`]. * @@ -23259,12 +24636,12 @@ struct LDKPayee Route_get_payee(const struct LDKRoute *NONNULL_PTR this_ptr); * * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void Route_set_payee(struct LDKRoute *NONNULL_PTR this_ptr, struct LDKPayee val); +void Route_set_payment_params(struct LDKRoute *NONNULL_PTR this_ptr, struct LDKPaymentParameters val); /** * Constructs a new Route given each field */ -MUST_USE_RES struct LDKRoute Route_new(struct LDKCVec_CVec_RouteHopZZ paths_arg, struct LDKPayee payee_arg); +MUST_USE_RES struct LDKRoute Route_new(struct LDKCVec_CVec_RouteHopZZ paths_arg, struct LDKPaymentParameters payment_params_arg); /** * Creates a copy of the Route @@ -23312,14 +24689,14 @@ struct LDKCResult_RouteDecodeErrorZ Route_read(struct LDKu8slice ser); void RouteParameters_free(struct LDKRouteParameters this_obj); /** - * The recipient of the failed payment path. + * The parameters of the failed payment path. */ -struct LDKPayee RouteParameters_get_payee(const struct LDKRouteParameters *NONNULL_PTR this_ptr); +struct LDKPaymentParameters RouteParameters_get_payment_params(const struct LDKRouteParameters *NONNULL_PTR this_ptr); /** - * The recipient of the failed payment path. + * The parameters of the failed payment path. */ -void RouteParameters_set_payee(struct LDKRouteParameters *NONNULL_PTR this_ptr, struct LDKPayee val); +void RouteParameters_set_payment_params(struct LDKRouteParameters *NONNULL_PTR this_ptr, struct LDKPaymentParameters val); /** * The amount in msats sent on the failed payment path. @@ -23344,7 +24721,7 @@ void RouteParameters_set_final_cltv_expiry_delta(struct LDKRouteParameters *NONN /** * Constructs a new RouteParameters given each field */ -MUST_USE_RES struct LDKRouteParameters RouteParameters_new(struct LDKPayee payee_arg, uint64_t final_value_msat_arg, uint32_t final_cltv_expiry_delta_arg); +MUST_USE_RES struct LDKRouteParameters RouteParameters_new(struct LDKPaymentParameters payment_params_arg, uint64_t final_value_msat_arg, uint32_t final_cltv_expiry_delta_arg); /** * Creates a copy of the RouteParameters @@ -23362,19 +24739,19 @@ struct LDKCVec_u8Z RouteParameters_write(const struct LDKRouteParameters *NONNUL struct LDKCResult_RouteParametersDecodeErrorZ RouteParameters_read(struct LDKu8slice ser); /** - * Frees any resources used by the Payee, if is_owned is set and inner is non-NULL. + * Frees any resources used by the PaymentParameters, if is_owned is set and inner is non-NULL. */ -void Payee_free(struct LDKPayee this_obj); +void PaymentParameters_free(struct LDKPaymentParameters this_obj); /** * The node id of the payee. */ -struct LDKPublicKey Payee_get_pubkey(const struct LDKPayee *NONNULL_PTR this_ptr); +struct LDKPublicKey PaymentParameters_get_payee_pubkey(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); /** * The node id of the payee. */ -void Payee_set_pubkey(struct LDKPayee *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void PaymentParameters_set_payee_pubkey(struct LDKPaymentParameters *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** * Features supported by the payee. @@ -23386,7 +24763,7 @@ void Payee_set_pubkey(struct LDKPayee *NONNULL_PTR this_ptr, struct LDKPublicKey * * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKInvoiceFeatures Payee_get_features(const struct LDKPayee *NONNULL_PTR this_ptr); +struct LDKInvoiceFeatures PaymentParameters_get_features(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); /** * Features supported by the payee. @@ -23398,69 +24775,79 @@ struct LDKInvoiceFeatures Payee_get_features(const struct LDKPayee *NONNULL_PTR * * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void Payee_set_features(struct LDKPayee *NONNULL_PTR this_ptr, struct LDKInvoiceFeatures val); +void PaymentParameters_set_features(struct LDKPaymentParameters *NONNULL_PTR this_ptr, struct LDKInvoiceFeatures val); /** * Hints for routing to the payee, containing channels connecting the payee to public nodes. */ -struct LDKCVec_RouteHintZ Payee_get_route_hints(const struct LDKPayee *NONNULL_PTR this_ptr); +struct LDKCVec_RouteHintZ PaymentParameters_get_route_hints(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); /** * Hints for routing to the payee, containing channels connecting the payee to public nodes. */ -void Payee_set_route_hints(struct LDKPayee *NONNULL_PTR this_ptr, struct LDKCVec_RouteHintZ val); +void PaymentParameters_set_route_hints(struct LDKPaymentParameters *NONNULL_PTR this_ptr, struct LDKCVec_RouteHintZ val); /** * Expiration of a payment to the payee, in seconds relative to the UNIX epoch. */ -struct LDKCOption_u64Z Payee_get_expiry_time(const struct LDKPayee *NONNULL_PTR this_ptr); +struct LDKCOption_u64Z PaymentParameters_get_expiry_time(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); /** * Expiration of a payment to the payee, in seconds relative to the UNIX epoch. */ -void Payee_set_expiry_time(struct LDKPayee *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); +void PaymentParameters_set_expiry_time(struct LDKPaymentParameters *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); + +/** + * The maximum total CLTV delta we accept for the route. + */ +uint32_t PaymentParameters_get_max_total_cltv_expiry_delta(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); + +/** + * The maximum total CLTV delta we accept for the route. + */ +void PaymentParameters_set_max_total_cltv_expiry_delta(struct LDKPaymentParameters *NONNULL_PTR this_ptr, uint32_t val); /** - * Constructs a new Payee given each field + * Constructs a new PaymentParameters given each field */ -MUST_USE_RES struct LDKPayee Payee_new(struct LDKPublicKey pubkey_arg, struct LDKInvoiceFeatures features_arg, struct LDKCVec_RouteHintZ route_hints_arg, struct LDKCOption_u64Z expiry_time_arg); +MUST_USE_RES struct LDKPaymentParameters PaymentParameters_new(struct LDKPublicKey payee_pubkey_arg, struct LDKInvoiceFeatures features_arg, struct LDKCVec_RouteHintZ route_hints_arg, struct LDKCOption_u64Z expiry_time_arg, uint32_t max_total_cltv_expiry_delta_arg); /** - * Creates a copy of the Payee + * Creates a copy of the PaymentParameters */ -struct LDKPayee Payee_clone(const struct LDKPayee *NONNULL_PTR orig); +struct LDKPaymentParameters PaymentParameters_clone(const struct LDKPaymentParameters *NONNULL_PTR orig); /** - * Checks if two Payees contain equal inner contents. + * Checks if two PaymentParameterss contain equal inner contents. */ -uint64_t Payee_hash(const struct LDKPayee *NONNULL_PTR o); +uint64_t PaymentParameters_hash(const struct LDKPaymentParameters *NONNULL_PTR o); /** - * Checks if two Payees contain equal inner contents. + * Checks if two PaymentParameterss contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. * Two objects with NULL inner values will be considered "equal" here. */ -bool Payee_eq(const struct LDKPayee *NONNULL_PTR a, const struct LDKPayee *NONNULL_PTR b); +bool PaymentParameters_eq(const struct LDKPaymentParameters *NONNULL_PTR a, const struct LDKPaymentParameters *NONNULL_PTR b); /** - * Serialize the Payee object into a byte array which can be read by Payee_read + * Serialize the PaymentParameters object into a byte array which can be read by PaymentParameters_read */ -struct LDKCVec_u8Z Payee_write(const struct LDKPayee *NONNULL_PTR obj); +struct LDKCVec_u8Z PaymentParameters_write(const struct LDKPaymentParameters *NONNULL_PTR obj); /** - * Read a Payee from a byte array, created by Payee_write + * Read a PaymentParameters from a byte array, created by PaymentParameters_write */ -struct LDKCResult_PayeeDecodeErrorZ Payee_read(struct LDKu8slice ser); +struct LDKCResult_PaymentParametersDecodeErrorZ PaymentParameters_read(struct LDKu8slice ser); /** * Creates a payee with the node id of the given `pubkey`. */ -MUST_USE_RES struct LDKPayee Payee_from_node_id(struct LDKPublicKey pubkey); +MUST_USE_RES struct LDKPaymentParameters PaymentParameters_from_node_id(struct LDKPublicKey payee_pubkey); /** * Creates a payee with the node id of the given `pubkey` to use for keysend payments. */ -MUST_USE_RES struct LDKPayee Payee_for_keysend(struct LDKPublicKey pubkey); +MUST_USE_RES struct LDKPaymentParameters PaymentParameters_for_keysend(struct LDKPublicKey payee_pubkey); /** * Frees any resources used by the RouteHint, if is_owned is set and inner is non-NULL. @@ -23632,7 +25019,7 @@ struct LDKCResult_RouteHintHopDecodeErrorZ RouteHintHop_read(struct LDKu8slice s * * Note that first_hops (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKCResult_RouteLightningErrorZ find_route(struct LDKPublicKey our_node_pubkey, const struct LDKRouteParameters *NONNULL_PTR params, const struct LDKNetworkGraph *NONNULL_PTR network, struct LDKCVec_ChannelDetailsZ *first_hops, struct LDKLogger logger, const struct LDKScore *NONNULL_PTR scorer); +struct LDKCResult_RouteLightningErrorZ find_route(struct LDKPublicKey our_node_pubkey, const struct LDKRouteParameters *NONNULL_PTR route_params, const struct LDKNetworkGraph *NONNULL_PTR network, struct LDKCVec_ChannelDetailsZ *first_hops, struct LDKLogger logger, const struct LDKScore *NONNULL_PTR scorer); /** * Calls the free function if one is set @@ -23654,6 +25041,32 @@ void MultiThreadedLockableScore_free(struct LDKMultiThreadedLockableScore this_o */ MUST_USE_RES struct LDKMultiThreadedLockableScore MultiThreadedLockableScore_new(struct LDKScore score); +/** + * Frees any resources used by the FixedPenaltyScorer, if is_owned is set and inner is non-NULL. + */ +void FixedPenaltyScorer_free(struct LDKFixedPenaltyScorer this_obj); + +/** + * Serialize the FixedPenaltyScorer object into a byte array which can be read by FixedPenaltyScorer_read + */ +struct LDKCVec_u8Z FixedPenaltyScorer_write(const struct LDKFixedPenaltyScorer *NONNULL_PTR obj); + +/** + * Read a FixedPenaltyScorer from a byte array, created by FixedPenaltyScorer_write + */ +struct LDKCResult_FixedPenaltyScorerDecodeErrorZ FixedPenaltyScorer_read(struct LDKu8slice ser); + +/** + * Creates a new scorer using `penalty_msat`. + */ +MUST_USE_RES struct LDKFixedPenaltyScorer FixedPenaltyScorer_with_penalty(uint64_t penalty_msat); + +/** + * Constructs a new Score which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned Score must be freed before this_arg is + */ +struct LDKScore FixedPenaltyScorer_as_Score(const struct LDKFixedPenaltyScorer *NONNULL_PTR this_arg); + /** * Frees any resources used by the Scorer, if is_owned is set and inner is non-NULL. */ @@ -23750,6 +25163,8 @@ void ScoringParameters_set_overuse_penalty_msat_per_1024th(struct LDKScoringPara * * Successfully routing through a channel will immediately cut the penalty in half as well. * + * Default value: 1 hour + * * # Note * * When built with the `no-std` feature, time will never elapse. Therefore, this penalty will @@ -23765,6 +25180,8 @@ uint64_t ScoringParameters_get_failure_penalty_half_life(const struct LDKScoring * * Successfully routing through a channel will immediately cut the penalty in half as well. * + * Default value: 1 hour + * * # Note * * When built with the `no-std` feature, time will never elapse. Therefore, this penalty will @@ -23820,6 +25237,104 @@ struct LDKCVec_u8Z Scorer_write(const struct LDKScorer *NONNULL_PTR obj); */ struct LDKCResult_ScorerDecodeErrorZ Scorer_read(struct LDKu8slice ser); +/** + * Frees any resources used by the ProbabilisticScoringParameters, if is_owned is set and inner is non-NULL. + */ +void ProbabilisticScoringParameters_free(struct LDKProbabilisticScoringParameters this_obj); + +/** + * A multiplier used to determine the amount in msats willing to be paid to avoid routing + * through a channel, as per multiplying by the negative `log10` of the channel's success + * probability for a payment. + * + * The success probability is determined by the effective channel capacity, the payment amount, + * and knowledge learned from prior successful and unsuccessful payments. The lower bound of + * the success probability is 0.01, effectively limiting the penalty to the range + * `0..=2*liquidity_penalty_multiplier_msat`. The knowledge learned is decayed over time based + * on [`liquidity_offset_half_life`]. + * + * Default value: 10,000 msat + * + * [`liquidity_offset_half_life`]: Self::liquidity_offset_half_life + */ +uint64_t ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat(const struct LDKProbabilisticScoringParameters *NONNULL_PTR this_ptr); + +/** + * A multiplier used to determine the amount in msats willing to be paid to avoid routing + * through a channel, as per multiplying by the negative `log10` of the channel's success + * probability for a payment. + * + * The success probability is determined by the effective channel capacity, the payment amount, + * and knowledge learned from prior successful and unsuccessful payments. The lower bound of + * the success probability is 0.01, effectively limiting the penalty to the range + * `0..=2*liquidity_penalty_multiplier_msat`. The knowledge learned is decayed over time based + * on [`liquidity_offset_half_life`]. + * + * Default value: 10,000 msat + * + * [`liquidity_offset_half_life`]: Self::liquidity_offset_half_life + */ +void ProbabilisticScoringParameters_set_liquidity_penalty_multiplier_msat(struct LDKProbabilisticScoringParameters *NONNULL_PTR this_ptr, uint64_t val); + +/** + * The time required to elapse before any knowledge learned about channel liquidity balances is + * cut in half. + * + * The bounds are defined in terms of offsets and are initially zero. Increasing the offsets + * gives tighter bounds on the channel liquidity balance. Thus, halving the offsets decreases + * the certainty of the channel liquidity balance. + * + * Default value: 1 hour + * + * # 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. + */ +uint64_t ProbabilisticScoringParameters_get_liquidity_offset_half_life(const struct LDKProbabilisticScoringParameters *NONNULL_PTR this_ptr); + +/** + * The time required to elapse before any knowledge learned about channel liquidity balances is + * cut in half. + * + * The bounds are defined in terms of offsets and are initially zero. Increasing the offsets + * gives tighter bounds on the channel liquidity balance. Thus, halving the offsets decreases + * the certainty of the channel liquidity balance. + * + * Default value: 1 hour + * + * # Note + * + * When built with the `no-std` feature, time will never elapse. Therefore, the channel + * liquidity knowledge will never decay except when the bounds cross. + */ +void ProbabilisticScoringParameters_set_liquidity_offset_half_life(struct LDKProbabilisticScoringParameters *NONNULL_PTR this_ptr, uint64_t val); + +/** + * Constructs a new ProbabilisticScoringParameters given each field + */ +MUST_USE_RES struct LDKProbabilisticScoringParameters ProbabilisticScoringParameters_new(uint64_t liquidity_penalty_multiplier_msat_arg, uint64_t liquidity_offset_half_life_arg); + +/** + * Creates a copy of the ProbabilisticScoringParameters + */ +struct LDKProbabilisticScoringParameters ProbabilisticScoringParameters_clone(const struct LDKProbabilisticScoringParameters *NONNULL_PTR orig); + +/** + * Serialize the ProbabilisticScoringParameters object into a byte array which can be read by ProbabilisticScoringParameters_read + */ +struct LDKCVec_u8Z ProbabilisticScoringParameters_write(const struct LDKProbabilisticScoringParameters *NONNULL_PTR obj); + +/** + * Read a ProbabilisticScoringParameters from a byte array, created by ProbabilisticScoringParameters_write + */ +struct LDKCResult_ProbabilisticScoringParametersDecodeErrorZ ProbabilisticScoringParameters_read(struct LDKu8slice ser); + +/** + * Creates a "default" ProbabilisticScoringParameters. See struct and individual field documentaiton for details on which values are used. + */ +MUST_USE_RES struct LDKProbabilisticScoringParameters ProbabilisticScoringParameters_default(void); + /** * Frees any resources used by the FilesystemPersister, if is_owned is set and inner is non-NULL. */ @@ -23927,23 +25442,6 @@ MUST_USE_RES struct LDKCResult_NoneErrorZ BackgroundProcessor_join(struct LDKBac */ MUST_USE_RES struct LDKCResult_NoneErrorZ BackgroundProcessor_stop(struct LDKBackgroundProcessor this_arg); -/** - * **Call this function on startup to ensure that all assumptions about the platform are valid.** - * - * Unfortunately we have to make assumptions about the upper bounds of the `SystemTime` type on - * your platform which we can't fully verify at compile time and which isn't part of it's contract. - * To our best knowledge our assumptions hold for all platforms officially supported by rust, but - * since this check is fast we recommend to do it anyway. - * - * If this function fails this is considered a bug. Please open an issue describing your - * platform and stating your current system time. - * - * # Panics - * If the check fails this function panics. By calling this function on startup you ensure that - * this wont happen at an arbitrary later point in time. - */ -void check_platform(void); - /** * Frees any resources used by the Invoice, if is_owned is set and inner is non-NULL. */ @@ -24424,26 +25922,40 @@ MUST_USE_RES struct LDKCOption_u64Z RawInvoice_amount_pico_btc(const struct LDKR MUST_USE_RES enum LDKCurrency RawInvoice_currency(const struct LDKRawInvoice *NONNULL_PTR this_arg); /** - * Create a new `PositiveTimestamp` from a unix timestamp in the Range - * `0...SYSTEM_TIME_MAX_UNIX_TIMESTAMP - MAX_EXPIRY_TIME`, otherwise return a - * `CreationError::TimestampOutOfBounds`. + * Creates a `PositiveTimestamp` from a Unix timestamp in the range `0..=MAX_TIMESTAMP`. + * + * Otherwise, returns a [`CreationError::TimestampOutOfBounds`]. */ MUST_USE_RES struct LDKCResult_PositiveTimestampCreationErrorZ PositiveTimestamp_from_unix_timestamp(uint64_t unix_seconds); /** - * Create a new `PositiveTimestamp` from a `SystemTime` with a corresponding unix timestamp in - * the Range `0...SYSTEM_TIME_MAX_UNIX_TIMESTAMP - MAX_EXPIRY_TIME`, otherwise return a - * `CreationError::TimestampOutOfBounds`. + * Creates a `PositiveTimestamp` from a [`SystemTime`] with a corresponding Unix timestamp in + * the range `0..=MAX_TIMESTAMP`. + * + * Otherwise, returns a [`CreationError::TimestampOutOfBounds`]. */ MUST_USE_RES struct LDKCResult_PositiveTimestampCreationErrorZ PositiveTimestamp_from_system_time(uint64_t time); /** - * Returns the UNIX timestamp representing the stored time + * Creates a `PositiveTimestamp` from a [`Duration`] since the Unix epoch in the range + * `0..=MAX_TIMESTAMP`. + * + * Otherwise, returns a [`CreationError::TimestampOutOfBounds`]. + */ +MUST_USE_RES struct LDKCResult_PositiveTimestampCreationErrorZ PositiveTimestamp_from_duration_since_epoch(uint64_t duration); + +/** + * Returns the Unix timestamp representing the stored time */ MUST_USE_RES uint64_t PositiveTimestamp_as_unix_timestamp(const struct LDKPositiveTimestamp *NONNULL_PTR this_arg); /** - * Returns a reference to the internal `SystemTime` time representation + * Returns the duration of the stored time since the Unix epoch + */ +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); @@ -24482,10 +25994,15 @@ 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 it's creation time) + * 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 + */ +MUST_USE_RES uint64_t Invoice_duration_since_epoch(const struct LDKInvoice *NONNULL_PTR this_arg); + /** * Returns the hash to which we will receive the preimage on completion of the payment */ @@ -24525,6 +26042,12 @@ MUST_USE_RES uint64_t Invoice_expiry_time(const struct LDKInvoice *NONNULL_PTR t */ MUST_USE_RES bool Invoice_is_expired(const struct LDKInvoice *NONNULL_PTR this_arg); +/** + * Returns whether the expiry time would pass at the given point in time. + * `at_time` is the timestamp as a duration since the Unix epoch. + */ +MUST_USE_RES bool Invoice_would_expire(const struct LDKInvoice *NONNULL_PTR this_arg, uint64_t at_time); + /** * Returns the invoice's `min_final_cltv_expiry` time, if present, otherwise * [`DEFAULT_MIN_FINAL_CLTV_EXPIRY`]. @@ -24565,18 +26088,14 @@ MUST_USE_RES struct LDKCResult_DescriptionCreationErrorZ Description_new(struct MUST_USE_RES struct LDKStr Description_into_inner(struct LDKDescription this_arg); /** - * Construct an `ExpiryTime` from seconds. If there exists a `PositiveTimestamp` which would - * overflow on adding the `EpiryTime` to it then this function will return a - * `CreationError::ExpiryTimeOutOfBounds`. + * Construct an `ExpiryTime` from seconds. */ -MUST_USE_RES struct LDKCResult_ExpiryTimeCreationErrorZ ExpiryTime_from_seconds(uint64_t seconds); +MUST_USE_RES struct LDKExpiryTime ExpiryTime_from_seconds(uint64_t seconds); /** - * Construct an `ExpiryTime` from a `Duration`. If there exists a `PositiveTimestamp` which - * would overflow on adding the `EpiryTime` to it then this function will return a - * `CreationError::ExpiryTimeOutOfBounds`. + * Construct an `ExpiryTime` from a `Duration`. */ -MUST_USE_RES struct LDKCResult_ExpiryTimeCreationErrorZ ExpiryTime_from_duration(uint64_t duration); +MUST_USE_RES struct LDKExpiryTime ExpiryTime_from_duration(uint64_t duration); /** * Returns the expiry time in seconds @@ -24619,14 +26138,14 @@ enum LDKCreationError CreationError_route_too_long(void); enum LDKCreationError CreationError_timestamp_out_of_bounds(void); /** - * Utility method to constructs a new ExpiryTimeOutOfBounds-variant CreationError + * Utility method to constructs a new InvalidAmount-variant CreationError */ -enum LDKCreationError CreationError_expiry_time_out_of_bounds(void); +enum LDKCreationError CreationError_invalid_amount(void); /** - * Utility method to constructs a new InvalidAmount-variant CreationError + * Utility method to constructs a new MissingRouteHints-variant CreationError */ -enum LDKCreationError CreationError_invalid_amount(void); +enum LDKCreationError CreationError_missing_route_hints(void); /** * Checks if two CreationErrors contain equal inner contents. @@ -24857,6 +26376,34 @@ void InvoicePayer_remove_cached_payment(const struct LDKInvoicePayer *NONNULL_PT */ struct LDKEventHandler InvoicePayer_as_EventHandler(const struct LDKInvoicePayer *NONNULL_PTR this_arg); +/** + * Utility to create an invoice that can be paid to one of multiple nodes, or a \"phantom invoice.\" + * See [`PhantomKeysManager`] for more information on phantom node payments. + * + * `phantom_route_hints` parameter: + * * Contains channel info for all nodes participating in the phantom invoice + * * Entries are retrieved from a call to [`ChannelManager::get_phantom_route_hints`] on each + * participating node + * * It is fine to cache `phantom_route_hints` and reuse it across invoices, as long as the data is + * updated when a channel becomes disabled or closes + * * Note that if too many channels are included in [`PhantomRouteHints::channels`], the invoice + * may be too long for QR code scanning. To fix this, `PhantomRouteHints::channels` may be pared + * down + * + * `payment_hash` and `payment_secret` come from [`ChannelManager::create_inbound_payment`] or + * [`ChannelManager::create_inbound_payment_for_hash`]. These values can be retrieved from any + * participating node. + * + * Note that the provided `keys_manager`'s `KeysInterface` implementation must support phantom + * invoices in its `sign_invoice` implementation ([`PhantomKeysManager`] satisfies this + * requirement). + * + * [`PhantomKeysManager`]: lightning::chain::keysinterface::PhantomKeysManager + * [`ChannelManager::get_phantom_route_hints`]: lightning::ln::channelmanager::ChannelManager::get_phantom_route_hints + * [`PhantomRouteHints::channels`]: lightning::ln::channelmanager::PhantomRouteHints::channels + */ +struct LDKCResult_InvoiceSignOrCreationErrorZ create_phantom_invoice(struct LDKCOption_u64Z amt_msat, struct LDKStr description, struct LDKThirtyTwoBytes payment_hash, struct LDKThirtyTwoBytes payment_secret, struct LDKCVec_PhantomRouteHintsZ phantom_route_hints, struct LDKKeysInterface keys_manager, enum LDKCurrency network); + /** * 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 @@ -24866,6 +26413,13 @@ struct LDKEventHandler InvoicePayer_as_EventHandler(const struct LDKInvoicePayer */ struct LDKCResult_InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager(const struct LDKChannelManager *NONNULL_PTR channelmanager, struct LDKKeysInterface keys_manager, enum LDKCurrency network, struct LDKCOption_u64Z amt_msat, struct LDKStr description); +/** + * See [`create_invoice_from_channelmanager`] + * This version can be used in a `no_std` environment, where [`std::time::SystemTime`] is not + * available and the current time is supplied by the caller. + */ +struct LDKCResult_InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager_and_duration_since_epoch(const struct LDKChannelManager *NONNULL_PTR channelmanager, struct LDKKeysInterface keys_manager, enum LDKCurrency network, struct LDKCOption_u64Z amt_msat, struct LDKStr description, uint64_t duration_since_epoch); + /** * Frees any resources used by the DefaultRouter, if is_owned is set and inner is non-NULL. */ diff --git a/lightning-c-bindings/include/lightningpp.hpp b/lightning-c-bindings/include/lightningpp.hpp index 0b964d7..5092728 100644 --- a/lightning-c-bindings/include/lightningpp.hpp +++ b/lightning-c-bindings/include/lightningpp.hpp @@ -2,6 +2,7 @@ namespace LDK { // Forward declarations class Str; +class CounterpartyCommitmentSecrets; class TxCreationKeys; class ChannelPublicKeys; class HTLCOutputInCommitment; @@ -21,7 +22,7 @@ class ChannelManagerPersister; class RouteHop; class Route; class RouteParameters; -class Payee; +class PaymentParameters; class RouteHint; class RouteHintHop; class BroadcasterInterface; @@ -46,8 +47,10 @@ class EventHandler; class Score; class LockableScore; class MultiThreadedLockableScore; +class FixedPenaltyScorer; class Scorer; class ScoringParameters; +class ProbabilisticScoringParameters; class InitFeatures; class NodeFeatures; class ChannelFeatures; @@ -58,9 +61,11 @@ class StaticPaymentOutputDescriptor; class SpendableOutputDescriptor; class BaseSign; class Sign; +class Recipient; class KeysInterface; class InMemorySigner; class KeysManager; +class PhantomKeysManager; class FilesystemPersister; class ChannelManager; class ChainParameters; @@ -68,6 +73,7 @@ class CounterpartyForwardingInfo; class ChannelCounterparty; class ChannelDetails; class PaymentSendFailure; +class PhantomRouteHints; class ChannelManagerReadArgs; class ChannelHandshakeConfig; class ChannelHandshakeLimits; @@ -117,14 +123,17 @@ class NetworkGraph; class ReadOnlyNetworkGraph; class NetworkUpdate; class NetGraphMsgHandler; -class DirectionalChannelInfo; +class ChannelUpdateInfo; class ChannelInfo; +class DirectedChannelInfo; +class EffectiveCapacity; class RoutingFees; class NodeAnnouncementInfo; class NodeInfo; class DecodeError; class Init; class ErrorMessage; +class WarningMessage; class Ping; class Pong; class OpenChannel; @@ -172,6 +181,7 @@ class LockedChannelMonitor; class ChainMonitor; class CVec_SpendableOutputDescriptorZ; class CResult_LockedChannelMonitorNoneZ; +class CResult_PhantomRouteHintsDecodeErrorZ; class CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ; class CResult_ScoringParametersDecodeErrorZ; class CResult_HTLCUpdateDecodeErrorZ; @@ -198,24 +208,24 @@ class CResult_ChannelReestablishDecodeErrorZ; class CResult_CommitmentSignedDecodeErrorZ; class CVec_UpdateAddHTLCZ; class CResult_UnsignedNodeAnnouncementDecodeErrorZ; -class CResult_StaticPaymentOutputDescriptorDecodeErrorZ; class COption_u32Z; class CResult_InitFeaturesDecodeErrorZ; +class CResult_StaticPaymentOutputDescriptorDecodeErrorZ; class CResult_PaymentIdPaymentSendFailureZ; class CResult_ReplyChannelRangeDecodeErrorZ; class CResult_CommitmentTransactionDecodeErrorZ; class COption_C2Tuple_usizeTransactionZZ; class CResult_TransactionNoneZ; class CResult_SignedRawInvoiceNoneZ; -class CResult_ExpiryTimeCreationErrorZ; class CResult_ClosingSignedFeeRangeDecodeErrorZ; class CResult_PingDecodeErrorZ; class CResult_GossipTimestampFilterDecodeErrorZ; +class CResult_InvoiceSignOrCreationErrorZ; class CVec_TransactionOutputsZ; class CResult_ErrorMessageDecodeErrorZ; class CResult_OpenChannelDecodeErrorZ; class CVec_CVec_u8ZZ; -class CResult_InvoiceSignOrCreationErrorZ; +class COption_FilterZ; class CResult_SecretKeyErrorZ; class CResult_ShutdownScriptDecodeErrorZ; class CResult_InvoiceNoneZ; @@ -241,7 +251,6 @@ class CResult_NodeAnnouncementInfoDecodeErrorZ; class C3Tuple_RawInvoice_u832InvoiceSignatureZ; class CVec_UpdateFailMalformedHTLCZ; class CResult_FundingSignedDecodeErrorZ; -class COption_FilterZ; class CResult_NetworkGraphDecodeErrorZ; class CVec_RouteHopZ; class CVec_C2Tuple_BlockHashChannelMonitorZZ; @@ -253,10 +262,15 @@ class CResult_NodeInfoDecodeErrorZ; class CResult_ClosingSignedDecodeErrorZ; class CResult_HolderCommitmentTransactionDecodeErrorZ; class CVec_CResult_NoneAPIErrorZZ; +class CResult_CounterpartyCommitmentSecretsDecodeErrorZ; +class CResult_ChannelCounterpartyDecodeErrorZ; +class CResult_WarningMessageDecodeErrorZ; class CResult_SignatureNoneZ; class CVec_RouteHintHopZ; +class CResult_SecretKeyNoneZ; class CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ; class C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ; +class CResult_PaymentParametersDecodeErrorZ; class CResult_InitDecodeErrorZ; class CResult_OutPointDecodeErrorZ; class CVec_ChannelDetailsZ; @@ -264,8 +278,9 @@ class CResult_SignDecodeErrorZ; class CVec_MessageSendEventZ; class C2Tuple_OutPointScriptZ; class CResult_RouteHintHopDecodeErrorZ; -class CResult_UpdateFailMalformedHTLCDecodeErrorZ; +class CResult_C2Tuple_SignatureSignatureZNoneZ; class CVec_NodeAnnouncementZ; +class CResult_UpdateFailMalformedHTLCDecodeErrorZ; class CResult_UnsignedChannelAnnouncementDecodeErrorZ; class CVec_TxidZ; class COption_AccessZ; @@ -273,11 +288,11 @@ class CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ; class CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ; class CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ; class CResult_CVec_CVec_u8ZZNoneZ; +class C2Tuple_SignatureSignatureZ; class C2Tuple_PaymentHashPaymentSecretZ; -class CResult_AcceptChannelDecodeErrorZ; class C2Tuple_BlockHashChannelManagerZ; class CResult_ChannelTransactionParametersDecodeErrorZ; -class CResult_PongDecodeErrorZ; +class CResult_AcceptChannelDecodeErrorZ; class CVec_SignatureZ; class CVec_u64Z; class CResult_ScorerDecodeErrorZ; @@ -287,6 +302,7 @@ class CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ; class CResult_NoneErrorZ; class CResult_StringErrorZ; class C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ; +class CResult_PongDecodeErrorZ; class CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ; class COption_EventZ; class CResult_ChannelTypeFeaturesDecodeErrorZ; @@ -294,11 +310,11 @@ class CVec_RouteHintZ; class COption_u16Z; class CVec_CVec_RouteHopZZ; class CResult_TrustedCommitmentTransactionNoneZ; +class CResult_FixedPenaltyScorerDecodeErrorZ; class CResult_NoneLightningErrorZ; class CResult_NonePeerHandleErrorZ; class CResult_COption_EventZDecodeErrorZ; class CResult_CVec_SignatureZNoneZ; -class CResult_PayeeDecodeErrorZ; class COption_CVec_NetAddressZZ; class CResult__u832APIErrorZ; class CResult_PaymentIdPaymentErrorZ; @@ -310,15 +326,16 @@ class CResult_RoutingFeesDecodeErrorZ; class CResult_QueryShortChannelIdsDecodeErrorZ; class CResult_InvoiceSemanticErrorZ; class CResult_UpdateAddHTLCDecodeErrorZ; +class CVec_PhantomRouteHintsZ; class CResult_CounterpartyChannelTransactionParametersDecodeErrorZ; class CResult_NoneAPIErrorZ; class CVec_NetAddressZ; +class CResult_ChannelDetailsDecodeErrorZ; class CVec_C2Tuple_usizeTransactionZZ; class CVec_PublicKeyZ; class COption_MonitorEventZ; class COption_TypeZ; class CResult_COption_TypeZDecodeErrorZ; -class CResult_DirectionalChannelInfoDecodeErrorZ; class C2Tuple_u32TxOutZ; class CResult_UpdateFailHTLCDecodeErrorZ; class CResult_PaymentSecretNoneZ; @@ -331,15 +348,16 @@ class CResult_ShutdownDecodeErrorZ; class CVec_EventZ; class CResult_NoneSemanticErrorZ; class CVec_MonitorEventZ; +class CVec_PaymentPreimageZ; class CVec_C2Tuple_u32ScriptZZ; class CResult_NoneChannelMonitorUpdateErrZ; class CResult_COption_ClosureReasonZDecodeErrorZ; class CResult_SiPrefixNoneZ; class CResult_PublicKeyErrorZ; class C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ; +class CResult_NoneNoneZ; class CResult_RouteParametersDecodeErrorZ; class COption_ClosureReasonZ; -class CResult_NoneNoneZ; class CVec_APIErrorZ; class CResult_PrivateRouteCreationErrorZ; class CResult_boolPeerHandleErrorZ; @@ -348,15 +366,19 @@ class CVec_UpdateFulfillHTLCZ; class CResult_AnnouncementSignaturesDecodeErrorZ; class CResult_UpdateFulfillHTLCDecodeErrorZ; class CResult_NodeFeaturesDecodeErrorZ; +class CVec_u5Z; class CResult_InMemorySignerDecodeErrorZ; class CResult_PaymentSecretAPIErrorZ; +class CResult_CounterpartyForwardingInfoDecodeErrorZ; class C2Tuple_u32ScriptZ; class CResult_ReplyShortChannelIdsEndDecodeErrorZ; class CResult_RouteDecodeErrorZ; class CResult_BuiltCommitmentTransactionDecodeErrorZ; class COption_NoneZ; class CVec_TxOutZ; +class CResult_ProbabilisticScoringParametersDecodeErrorZ; class CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ; +class CResult_ChannelUpdateInfoDecodeErrorZ; class CVec_UpdateFailHTLCZ; class CResult_FundingLockedDecodeErrorZ; @@ -375,6 +397,21 @@ public: const LDKStr* operator &() const { return &self; } const LDKStr* operator ->() const { return &self; } }; +class CounterpartyCommitmentSecrets { +private: + LDKCounterpartyCommitmentSecrets self; +public: + CounterpartyCommitmentSecrets(const CounterpartyCommitmentSecrets&) = delete; + CounterpartyCommitmentSecrets(CounterpartyCommitmentSecrets&& o) : self(o.self) { memset(&o, 0, sizeof(CounterpartyCommitmentSecrets)); } + CounterpartyCommitmentSecrets(LDKCounterpartyCommitmentSecrets&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCounterpartyCommitmentSecrets)); } + operator LDKCounterpartyCommitmentSecrets() && { LDKCounterpartyCommitmentSecrets res = self; memset(&self, 0, sizeof(LDKCounterpartyCommitmentSecrets)); return res; } + ~CounterpartyCommitmentSecrets() { CounterpartyCommitmentSecrets_free(self); } + CounterpartyCommitmentSecrets& operator=(CounterpartyCommitmentSecrets&& o) { CounterpartyCommitmentSecrets_free(self); self = o.self; memset(&o, 0, sizeof(CounterpartyCommitmentSecrets)); return *this; } + LDKCounterpartyCommitmentSecrets* operator &() { return &self; } + LDKCounterpartyCommitmentSecrets* operator ->() { return &self; } + const LDKCounterpartyCommitmentSecrets* operator &() const { return &self; } + const LDKCounterpartyCommitmentSecrets* operator ->() const { return &self; } +}; class TxCreationKeys { private: LDKTxCreationKeys self; @@ -667,20 +704,20 @@ public: const LDKRouteParameters* operator &() const { return &self; } const LDKRouteParameters* operator ->() const { return &self; } }; -class Payee { +class PaymentParameters { private: - LDKPayee self; + LDKPaymentParameters self; public: - Payee(const Payee&) = delete; - Payee(Payee&& o) : self(o.self) { memset(&o, 0, sizeof(Payee)); } - Payee(LDKPayee&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPayee)); } - operator LDKPayee() && { LDKPayee res = self; memset(&self, 0, sizeof(LDKPayee)); return res; } - ~Payee() { Payee_free(self); } - Payee& operator=(Payee&& o) { Payee_free(self); self = o.self; memset(&o, 0, sizeof(Payee)); return *this; } - LDKPayee* operator &() { return &self; } - LDKPayee* operator ->() { return &self; } - const LDKPayee* operator &() const { return &self; } - const LDKPayee* operator ->() const { return &self; } + PaymentParameters(const PaymentParameters&) = delete; + PaymentParameters(PaymentParameters&& o) : self(o.self) { memset(&o, 0, sizeof(PaymentParameters)); } + PaymentParameters(LDKPaymentParameters&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPaymentParameters)); } + operator LDKPaymentParameters() && { LDKPaymentParameters res = self; memset(&self, 0, sizeof(LDKPaymentParameters)); return res; } + ~PaymentParameters() { PaymentParameters_free(self); } + PaymentParameters& operator=(PaymentParameters&& o) { PaymentParameters_free(self); self = o.self; memset(&o, 0, sizeof(PaymentParameters)); return *this; } + LDKPaymentParameters* operator &() { return &self; } + LDKPaymentParameters* operator ->() { return &self; } + const LDKPaymentParameters* operator &() const { return &self; } + const LDKPaymentParameters* operator ->() const { return &self; } }; class RouteHint { private: @@ -1165,17 +1202,13 @@ public: * 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 which are also being considered for use in - * the same payment) is given by `channel_capacity_msat`. It may be guessed from various - * sources or assumed from no data at all. - * - * For hints provided in the invoice, we assume the channel has sufficient capacity to accept - * the invoice's full amount, and provide a `channel_capacity_msat` of `None`. In all other - * cases it is set to `Some`, even if we're guessing at the channel value. - * - * Your code should be overflow-safe through a `channel_capacity_msat` of 21 million BTC. + * The channel's capacity (less any other MPP parts that are also being considered for use in + * the same payment) is given by `capacity_msat`. It may be determined from various sources + * such as a chain data, network gossip, or invoice hints. For invoice hints, a capacity near + * [`u64::max_value`] is given to indicate sufficient capacity for the invoice's full amount. + * Thus, implementations should be overflow-safe. */ - inline uint64_t channel_penalty_msat(uint64_t short_channel_id, uint64_t send_amt_msat, struct LDKCOption_u64Z channel_capacity_msat, const struct LDKNodeId *NONNULL_PTR source, const struct LDKNodeId *NONNULL_PTR target); + inline uint64_t channel_penalty_msat(uint64_t short_channel_id, uint64_t send_amt_msat, uint64_t capacity_msat, const struct LDKNodeId *NONNULL_PTR source, const struct LDKNodeId *NONNULL_PTR target); /** * Handles updating channel penalties after failing to route through a channel. */ @@ -1219,6 +1252,21 @@ public: const LDKMultiThreadedLockableScore* operator &() const { return &self; } const LDKMultiThreadedLockableScore* operator ->() const { return &self; } }; +class FixedPenaltyScorer { +private: + LDKFixedPenaltyScorer self; +public: + FixedPenaltyScorer(const FixedPenaltyScorer&) = delete; + FixedPenaltyScorer(FixedPenaltyScorer&& o) : self(o.self) { memset(&o, 0, sizeof(FixedPenaltyScorer)); } + FixedPenaltyScorer(LDKFixedPenaltyScorer&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKFixedPenaltyScorer)); } + operator LDKFixedPenaltyScorer() && { LDKFixedPenaltyScorer res = self; memset(&self, 0, sizeof(LDKFixedPenaltyScorer)); return res; } + ~FixedPenaltyScorer() { FixedPenaltyScorer_free(self); } + FixedPenaltyScorer& operator=(FixedPenaltyScorer&& o) { FixedPenaltyScorer_free(self); self = o.self; memset(&o, 0, sizeof(FixedPenaltyScorer)); return *this; } + LDKFixedPenaltyScorer* operator &() { return &self; } + LDKFixedPenaltyScorer* operator ->() { return &self; } + const LDKFixedPenaltyScorer* operator &() const { return &self; } + const LDKFixedPenaltyScorer* operator ->() const { return &self; } +}; class Scorer { private: LDKScorer self; @@ -1249,6 +1297,21 @@ public: const LDKScoringParameters* operator &() const { return &self; } const LDKScoringParameters* operator ->() const { return &self; } }; +class ProbabilisticScoringParameters { +private: + LDKProbabilisticScoringParameters self; +public: + ProbabilisticScoringParameters(const ProbabilisticScoringParameters&) = delete; + ProbabilisticScoringParameters(ProbabilisticScoringParameters&& o) : self(o.self) { memset(&o, 0, sizeof(ProbabilisticScoringParameters)); } + ProbabilisticScoringParameters(LDKProbabilisticScoringParameters&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKProbabilisticScoringParameters)); } + operator LDKProbabilisticScoringParameters() && { LDKProbabilisticScoringParameters res = self; memset(&self, 0, sizeof(LDKProbabilisticScoringParameters)); return res; } + ~ProbabilisticScoringParameters() { ProbabilisticScoringParameters_free(self); } + ProbabilisticScoringParameters& operator=(ProbabilisticScoringParameters&& o) { ProbabilisticScoringParameters_free(self); self = o.self; memset(&o, 0, sizeof(ProbabilisticScoringParameters)); return *this; } + LDKProbabilisticScoringParameters* operator &() { return &self; } + LDKProbabilisticScoringParameters* operator ->() { return &self; } + const LDKProbabilisticScoringParameters* operator &() const { return &self; } + const LDKProbabilisticScoringParameters* operator ->() const { return &self; } +}; class InitFeatures { private: LDKInitFeatures self; @@ -1407,8 +1470,15 @@ public: * 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: all the relevant preimages will be provided, but there may also be additional + * irrelevant or duplicate preimages. */ - inline LDK::CResult_NoneNoneZ validate_holder_commitment(const struct LDKHolderCommitmentTransaction *NONNULL_PTR holder_tx); + inline LDK::CResult_NoneNoneZ validate_holder_commitment(const struct LDKHolderCommitmentTransaction *NONNULL_PTR holder_tx, struct LDKCVec_PaymentPreimageZ preimages); /** * Gets 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 @@ -1422,8 +1492,15 @@ public: * * 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: all the relevant preimages will be provided, but there may also be additional + * irrelevant or duplicate preimages. */ - inline LDK::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment(const struct LDKCommitmentTransaction *NONNULL_PTR commitment_tx); + inline LDK::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment(const struct LDKCommitmentTransaction *NONNULL_PTR commitment_tx, struct LDKCVec_PaymentPreimageZ preimages); /** * Validate the counterparty's revocation. * @@ -1510,14 +1587,17 @@ public: */ inline LDK::CResult_SignatureNoneZ sign_closing_transaction(const struct LDKClosingTransaction *NONNULL_PTR closing_tx); /** - * Signs a channel announcement message with our funding key, proving it comes from one - * of the channel participants. + * Signs a channel announcement message with our funding key and our node secret key (aka + * node_id or network_key), proving it comes from one of the channel participants. + * + * The first returned signature should be from our node secret key, the second from our + * funding key. * * Note that if this fails or is rejected, the channel will not be publicly announced and * our counterparty may (though likely will not) close the channel on us for violating the * protocol. */ - inline LDK::CResult_SignatureNoneZ sign_channel_announcement(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR msg); + inline LDK::CResult_C2Tuple_SignatureSignatureZNoneZ sign_channel_announcement(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR msg); /** * Set the counterparty static channel data, including basepoints, * counterparty_selected/holder_selected_contest_delay and funding outpoint. @@ -1547,6 +1627,20 @@ public: const LDKSign* operator &() const { return &self; } const LDKSign* operator ->() const { return &self; } }; +class Recipient { +private: + LDKRecipient self; +public: + Recipient(const Recipient&) = delete; + Recipient(Recipient&& o) : self(o.self) { memset(&o, 0, sizeof(Recipient)); } + Recipient(LDKRecipient&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKRecipient)); } + operator LDKRecipient() && { LDKRecipient res = self; memset(&self, 0, sizeof(LDKRecipient)); return res; } + Recipient& operator=(Recipient&& o) { self = o.self; memset(&o, 0, sizeof(Recipient)); return *this; } + LDKRecipient* operator &() { return &self; } + LDKRecipient* operator ->() { return &self; } + const LDKRecipient* operator &() const { return &self; } + const LDKRecipient* operator ->() const { return &self; } +}; class KeysInterface { private: LDKKeysInterface self; @@ -1562,11 +1656,12 @@ public: const LDKKeysInterface* operator &() const { return &self; } const LDKKeysInterface* operator ->() const { return &self; } /** - * Get node secret key (aka node_id or network_key). + * Get node secret key (aka node_id or network_key) based on the provided [`Recipient`]. * - * This method must return the same value each time it is called. + * This method must return the same value each time it is called with a given `Recipient` + * parameter. */ - inline LDKSecretKey get_node_secret(); + inline LDK::CResult_SecretKeyNoneZ get_node_secret(enum LDKRecipient recipient); /** * Get a script pubkey which we send funds to when claiming on-chain contestable outputs. * @@ -1606,16 +1701,25 @@ public: */ inline LDK::CResult_SignDecodeErrorZ read_chan_signer(struct LDKu8slice reader); /** - * Sign an invoice's preimage (note that this is the preimage of the invoice, not the HTLC's - * preimage). By parameterizing by the preimage instead of the hash, we allow implementors of + * 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 is ascii bytes, while the invoice data is base32. + * + * The secret key used to sign the invoice is dependent on the [`Recipient`]. */ - inline LDK::CResult_RecoverableSignatureNoneZ sign_invoice(struct LDKCVec_u8Z invoice_preimage); + inline LDK::CResult_RecoverableSignatureNoneZ sign_invoice(struct LDKu8slice hrp_bytes, struct LDKCVec_u5Z invoice_data, enum LDKRecipient receipient); /** * Get secret key material as bytes for use in encrypting and decrypting inbound payment data. * + * If the implementor of this trait supports [phantom node payments], then every node that is + * intended to be included in the phantom invoice route hints must return the same value from + * this method. + * * This method must return the same value each time it is called. + * + * [phantom node payments]: PhantomKeysManager */ inline LDKThirtyTwoBytes get_inbound_payment_key_material(); }; @@ -1649,6 +1753,21 @@ public: const LDKKeysManager* operator &() const { return &self; } const LDKKeysManager* operator ->() const { return &self; } }; +class PhantomKeysManager { +private: + LDKPhantomKeysManager self; +public: + PhantomKeysManager(const PhantomKeysManager&) = delete; + PhantomKeysManager(PhantomKeysManager&& o) : self(o.self) { memset(&o, 0, sizeof(PhantomKeysManager)); } + PhantomKeysManager(LDKPhantomKeysManager&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPhantomKeysManager)); } + operator LDKPhantomKeysManager() && { LDKPhantomKeysManager res = self; memset(&self, 0, sizeof(LDKPhantomKeysManager)); return res; } + ~PhantomKeysManager() { PhantomKeysManager_free(self); } + PhantomKeysManager& operator=(PhantomKeysManager&& o) { PhantomKeysManager_free(self); self = o.self; memset(&o, 0, sizeof(PhantomKeysManager)); return *this; } + LDKPhantomKeysManager* operator &() { return &self; } + LDKPhantomKeysManager* operator ->() { return &self; } + const LDKPhantomKeysManager* operator &() const { return &self; } + const LDKPhantomKeysManager* operator ->() const { return &self; } +}; class FilesystemPersister { private: LDKFilesystemPersister self; @@ -1754,6 +1873,21 @@ public: const LDKPaymentSendFailure* operator &() const { return &self; } const LDKPaymentSendFailure* operator ->() const { return &self; } }; +class PhantomRouteHints { +private: + LDKPhantomRouteHints self; +public: + PhantomRouteHints(const PhantomRouteHints&) = delete; + PhantomRouteHints(PhantomRouteHints&& o) : self(o.self) { memset(&o, 0, sizeof(PhantomRouteHints)); } + PhantomRouteHints(LDKPhantomRouteHints&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPhantomRouteHints)); } + operator LDKPhantomRouteHints() && { LDKPhantomRouteHints res = self; memset(&self, 0, sizeof(LDKPhantomRouteHints)); return res; } + ~PhantomRouteHints() { PhantomRouteHints_free(self); } + PhantomRouteHints& operator=(PhantomRouteHints&& o) { PhantomRouteHints_free(self); self = o.self; memset(&o, 0, sizeof(PhantomRouteHints)); return *this; } + LDKPhantomRouteHints* operator &() { return &self; } + LDKPhantomRouteHints* operator ->() { return &self; } + const LDKPhantomRouteHints* operator &() const { return &self; } + const LDKPhantomRouteHints* operator ->() const { return &self; } +}; class ChannelManagerReadArgs { private: LDKChannelManagerReadArgs self; @@ -1979,7 +2113,7 @@ public: * * Note that first_hops (or a relevant inner pointer) may be NULL or all-0s to represent None */ - inline LDK::CResult_RouteLightningErrorZ find_route(struct LDKPublicKey payer, const struct LDKRouteParameters *NONNULL_PTR params, const uint8_t (*payment_hash)[32], struct LDKCVec_ChannelDetailsZ *first_hops, const struct LDKScore *NONNULL_PTR scorer); + inline LDK::CResult_RouteLightningErrorZ find_route(struct LDKPublicKey payer, const struct LDKRouteParameters *NONNULL_PTR route_params, const uint8_t (*payment_hash)[32], struct LDKCVec_ChannelDetailsZ *first_hops, const struct LDKScore *NONNULL_PTR scorer); }; class RetryAttempts { private: @@ -2578,20 +2712,20 @@ public: const LDKNetGraphMsgHandler* operator &() const { return &self; } const LDKNetGraphMsgHandler* operator ->() const { return &self; } }; -class DirectionalChannelInfo { +class ChannelUpdateInfo { private: - LDKDirectionalChannelInfo self; + LDKChannelUpdateInfo self; public: - DirectionalChannelInfo(const DirectionalChannelInfo&) = delete; - DirectionalChannelInfo(DirectionalChannelInfo&& o) : self(o.self) { memset(&o, 0, sizeof(DirectionalChannelInfo)); } - DirectionalChannelInfo(LDKDirectionalChannelInfo&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKDirectionalChannelInfo)); } - operator LDKDirectionalChannelInfo() && { LDKDirectionalChannelInfo res = self; memset(&self, 0, sizeof(LDKDirectionalChannelInfo)); return res; } - ~DirectionalChannelInfo() { DirectionalChannelInfo_free(self); } - DirectionalChannelInfo& operator=(DirectionalChannelInfo&& o) { DirectionalChannelInfo_free(self); self = o.self; memset(&o, 0, sizeof(DirectionalChannelInfo)); return *this; } - LDKDirectionalChannelInfo* operator &() { return &self; } - LDKDirectionalChannelInfo* operator ->() { return &self; } - const LDKDirectionalChannelInfo* operator &() const { return &self; } - const LDKDirectionalChannelInfo* operator ->() const { return &self; } + ChannelUpdateInfo(const ChannelUpdateInfo&) = delete; + ChannelUpdateInfo(ChannelUpdateInfo&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelUpdateInfo)); } + ChannelUpdateInfo(LDKChannelUpdateInfo&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelUpdateInfo)); } + operator LDKChannelUpdateInfo() && { LDKChannelUpdateInfo res = self; memset(&self, 0, sizeof(LDKChannelUpdateInfo)); return res; } + ~ChannelUpdateInfo() { ChannelUpdateInfo_free(self); } + ChannelUpdateInfo& operator=(ChannelUpdateInfo&& o) { ChannelUpdateInfo_free(self); self = o.self; memset(&o, 0, sizeof(ChannelUpdateInfo)); return *this; } + LDKChannelUpdateInfo* operator &() { return &self; } + LDKChannelUpdateInfo* operator ->() { return &self; } + const LDKChannelUpdateInfo* operator &() const { return &self; } + const LDKChannelUpdateInfo* operator ->() const { return &self; } }; class ChannelInfo { private: @@ -2608,6 +2742,36 @@ public: const LDKChannelInfo* operator &() const { return &self; } const LDKChannelInfo* operator ->() const { return &self; } }; +class DirectedChannelInfo { +private: + LDKDirectedChannelInfo self; +public: + DirectedChannelInfo(const DirectedChannelInfo&) = delete; + DirectedChannelInfo(DirectedChannelInfo&& o) : self(o.self) { memset(&o, 0, sizeof(DirectedChannelInfo)); } + DirectedChannelInfo(LDKDirectedChannelInfo&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKDirectedChannelInfo)); } + operator LDKDirectedChannelInfo() && { LDKDirectedChannelInfo res = self; memset(&self, 0, sizeof(LDKDirectedChannelInfo)); return res; } + ~DirectedChannelInfo() { DirectedChannelInfo_free(self); } + DirectedChannelInfo& operator=(DirectedChannelInfo&& o) { DirectedChannelInfo_free(self); self = o.self; memset(&o, 0, sizeof(DirectedChannelInfo)); return *this; } + LDKDirectedChannelInfo* operator &() { return &self; } + LDKDirectedChannelInfo* operator ->() { return &self; } + const LDKDirectedChannelInfo* operator &() const { return &self; } + const LDKDirectedChannelInfo* operator ->() const { return &self; } +}; +class EffectiveCapacity { +private: + LDKEffectiveCapacity self; +public: + EffectiveCapacity(const EffectiveCapacity&) = delete; + EffectiveCapacity(EffectiveCapacity&& o) : self(o.self) { memset(&o, 0, sizeof(EffectiveCapacity)); } + EffectiveCapacity(LDKEffectiveCapacity&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKEffectiveCapacity)); } + operator LDKEffectiveCapacity() && { LDKEffectiveCapacity res = self; memset(&self, 0, sizeof(LDKEffectiveCapacity)); return res; } + ~EffectiveCapacity() { EffectiveCapacity_free(self); } + EffectiveCapacity& operator=(EffectiveCapacity&& o) { EffectiveCapacity_free(self); self = o.self; memset(&o, 0, sizeof(EffectiveCapacity)); return *this; } + LDKEffectiveCapacity* operator &() { return &self; } + LDKEffectiveCapacity* operator ->() { return &self; } + const LDKEffectiveCapacity* operator &() const { return &self; } + const LDKEffectiveCapacity* operator ->() const { return &self; } +}; class RoutingFees { private: LDKRoutingFees self; @@ -2698,6 +2862,21 @@ public: 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; @@ -3604,6 +3783,21 @@ public: const LDKCResult_LockedChannelMonitorNoneZ* operator &() const { return &self; } const LDKCResult_LockedChannelMonitorNoneZ* operator ->() const { return &self; } }; +class CResult_PhantomRouteHintsDecodeErrorZ { +private: + LDKCResult_PhantomRouteHintsDecodeErrorZ self; +public: + CResult_PhantomRouteHintsDecodeErrorZ(const CResult_PhantomRouteHintsDecodeErrorZ&) = delete; + CResult_PhantomRouteHintsDecodeErrorZ(CResult_PhantomRouteHintsDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_PhantomRouteHintsDecodeErrorZ)); } + CResult_PhantomRouteHintsDecodeErrorZ(LDKCResult_PhantomRouteHintsDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ)); } + operator LDKCResult_PhantomRouteHintsDecodeErrorZ() && { LDKCResult_PhantomRouteHintsDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ)); return res; } + ~CResult_PhantomRouteHintsDecodeErrorZ() { CResult_PhantomRouteHintsDecodeErrorZ_free(self); } + CResult_PhantomRouteHintsDecodeErrorZ& operator=(CResult_PhantomRouteHintsDecodeErrorZ&& o) { CResult_PhantomRouteHintsDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_PhantomRouteHintsDecodeErrorZ)); return *this; } + LDKCResult_PhantomRouteHintsDecodeErrorZ* operator &() { return &self; } + LDKCResult_PhantomRouteHintsDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_PhantomRouteHintsDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_PhantomRouteHintsDecodeErrorZ* operator ->() const { return &self; } +}; class CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ { private: LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ self; @@ -3994,21 +4188,6 @@ public: const LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* operator &() const { return &self; } const LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* operator ->() const { return &self; } }; -class CResult_StaticPaymentOutputDescriptorDecodeErrorZ { -private: - LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ self; -public: - CResult_StaticPaymentOutputDescriptorDecodeErrorZ(const CResult_StaticPaymentOutputDescriptorDecodeErrorZ&) = delete; - CResult_StaticPaymentOutputDescriptorDecodeErrorZ(CResult_StaticPaymentOutputDescriptorDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_StaticPaymentOutputDescriptorDecodeErrorZ)); } - CResult_StaticPaymentOutputDescriptorDecodeErrorZ(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ)); } - operator LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ() && { LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ)); return res; } - ~CResult_StaticPaymentOutputDescriptorDecodeErrorZ() { CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(self); } - CResult_StaticPaymentOutputDescriptorDecodeErrorZ& operator=(CResult_StaticPaymentOutputDescriptorDecodeErrorZ&& o) { CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_StaticPaymentOutputDescriptorDecodeErrorZ)); return *this; } - LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* operator &() { return &self; } - LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* operator ->() const { return &self; } -}; class COption_u32Z { private: LDKCOption_u32Z self; @@ -4039,6 +4218,21 @@ public: const LDKCResult_InitFeaturesDecodeErrorZ* operator &() const { return &self; } const LDKCResult_InitFeaturesDecodeErrorZ* operator ->() const { return &self; } }; +class CResult_StaticPaymentOutputDescriptorDecodeErrorZ { +private: + LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ self; +public: + CResult_StaticPaymentOutputDescriptorDecodeErrorZ(const CResult_StaticPaymentOutputDescriptorDecodeErrorZ&) = delete; + CResult_StaticPaymentOutputDescriptorDecodeErrorZ(CResult_StaticPaymentOutputDescriptorDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_StaticPaymentOutputDescriptorDecodeErrorZ)); } + CResult_StaticPaymentOutputDescriptorDecodeErrorZ(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ)); } + operator LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ() && { LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ)); return res; } + ~CResult_StaticPaymentOutputDescriptorDecodeErrorZ() { CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(self); } + CResult_StaticPaymentOutputDescriptorDecodeErrorZ& operator=(CResult_StaticPaymentOutputDescriptorDecodeErrorZ&& o) { CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_StaticPaymentOutputDescriptorDecodeErrorZ)); return *this; } + LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* operator &() { return &self; } + LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* operator ->() const { return &self; } +}; class CResult_PaymentIdPaymentSendFailureZ { private: LDKCResult_PaymentIdPaymentSendFailureZ self; @@ -4129,21 +4323,6 @@ public: const LDKCResult_SignedRawInvoiceNoneZ* operator &() const { return &self; } const LDKCResult_SignedRawInvoiceNoneZ* operator ->() const { return &self; } }; -class CResult_ExpiryTimeCreationErrorZ { -private: - LDKCResult_ExpiryTimeCreationErrorZ self; -public: - CResult_ExpiryTimeCreationErrorZ(const CResult_ExpiryTimeCreationErrorZ&) = delete; - CResult_ExpiryTimeCreationErrorZ(CResult_ExpiryTimeCreationErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_ExpiryTimeCreationErrorZ)); } - CResult_ExpiryTimeCreationErrorZ(LDKCResult_ExpiryTimeCreationErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_ExpiryTimeCreationErrorZ)); } - operator LDKCResult_ExpiryTimeCreationErrorZ() && { LDKCResult_ExpiryTimeCreationErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_ExpiryTimeCreationErrorZ)); return res; } - ~CResult_ExpiryTimeCreationErrorZ() { CResult_ExpiryTimeCreationErrorZ_free(self); } - CResult_ExpiryTimeCreationErrorZ& operator=(CResult_ExpiryTimeCreationErrorZ&& o) { CResult_ExpiryTimeCreationErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_ExpiryTimeCreationErrorZ)); return *this; } - LDKCResult_ExpiryTimeCreationErrorZ* operator &() { return &self; } - LDKCResult_ExpiryTimeCreationErrorZ* operator ->() { return &self; } - const LDKCResult_ExpiryTimeCreationErrorZ* operator &() const { return &self; } - const LDKCResult_ExpiryTimeCreationErrorZ* operator ->() const { return &self; } -}; class CResult_ClosingSignedFeeRangeDecodeErrorZ { private: LDKCResult_ClosingSignedFeeRangeDecodeErrorZ self; @@ -4189,6 +4368,21 @@ public: const LDKCResult_GossipTimestampFilterDecodeErrorZ* operator &() const { return &self; } const LDKCResult_GossipTimestampFilterDecodeErrorZ* operator ->() const { return &self; } }; +class CResult_InvoiceSignOrCreationErrorZ { +private: + LDKCResult_InvoiceSignOrCreationErrorZ self; +public: + CResult_InvoiceSignOrCreationErrorZ(const CResult_InvoiceSignOrCreationErrorZ&) = delete; + CResult_InvoiceSignOrCreationErrorZ(CResult_InvoiceSignOrCreationErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_InvoiceSignOrCreationErrorZ)); } + CResult_InvoiceSignOrCreationErrorZ(LDKCResult_InvoiceSignOrCreationErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_InvoiceSignOrCreationErrorZ)); } + operator LDKCResult_InvoiceSignOrCreationErrorZ() && { LDKCResult_InvoiceSignOrCreationErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_InvoiceSignOrCreationErrorZ)); return res; } + ~CResult_InvoiceSignOrCreationErrorZ() { CResult_InvoiceSignOrCreationErrorZ_free(self); } + CResult_InvoiceSignOrCreationErrorZ& operator=(CResult_InvoiceSignOrCreationErrorZ&& o) { CResult_InvoiceSignOrCreationErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_InvoiceSignOrCreationErrorZ)); return *this; } + LDKCResult_InvoiceSignOrCreationErrorZ* operator &() { return &self; } + LDKCResult_InvoiceSignOrCreationErrorZ* operator ->() { return &self; } + const LDKCResult_InvoiceSignOrCreationErrorZ* operator &() const { return &self; } + const LDKCResult_InvoiceSignOrCreationErrorZ* operator ->() const { return &self; } +}; class CVec_TransactionOutputsZ { private: LDKCVec_TransactionOutputsZ self; @@ -4249,20 +4443,20 @@ public: const LDKCVec_CVec_u8ZZ* operator &() const { return &self; } const LDKCVec_CVec_u8ZZ* operator ->() const { return &self; } }; -class CResult_InvoiceSignOrCreationErrorZ { +class COption_FilterZ { private: - LDKCResult_InvoiceSignOrCreationErrorZ self; + LDKCOption_FilterZ self; public: - CResult_InvoiceSignOrCreationErrorZ(const CResult_InvoiceSignOrCreationErrorZ&) = delete; - CResult_InvoiceSignOrCreationErrorZ(CResult_InvoiceSignOrCreationErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_InvoiceSignOrCreationErrorZ)); } - CResult_InvoiceSignOrCreationErrorZ(LDKCResult_InvoiceSignOrCreationErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_InvoiceSignOrCreationErrorZ)); } - operator LDKCResult_InvoiceSignOrCreationErrorZ() && { LDKCResult_InvoiceSignOrCreationErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_InvoiceSignOrCreationErrorZ)); return res; } - ~CResult_InvoiceSignOrCreationErrorZ() { CResult_InvoiceSignOrCreationErrorZ_free(self); } - CResult_InvoiceSignOrCreationErrorZ& operator=(CResult_InvoiceSignOrCreationErrorZ&& o) { CResult_InvoiceSignOrCreationErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_InvoiceSignOrCreationErrorZ)); return *this; } - LDKCResult_InvoiceSignOrCreationErrorZ* operator &() { return &self; } - LDKCResult_InvoiceSignOrCreationErrorZ* operator ->() { return &self; } - const LDKCResult_InvoiceSignOrCreationErrorZ* operator &() const { return &self; } - const LDKCResult_InvoiceSignOrCreationErrorZ* operator ->() const { return &self; } + COption_FilterZ(const COption_FilterZ&) = delete; + COption_FilterZ(COption_FilterZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_FilterZ)); } + COption_FilterZ(LDKCOption_FilterZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_FilterZ)); } + operator LDKCOption_FilterZ() && { LDKCOption_FilterZ res = self; memset(&self, 0, sizeof(LDKCOption_FilterZ)); return res; } + ~COption_FilterZ() { COption_FilterZ_free(self); } + COption_FilterZ& operator=(COption_FilterZ&& o) { COption_FilterZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_FilterZ)); return *this; } + LDKCOption_FilterZ* operator &() { return &self; } + LDKCOption_FilterZ* operator ->() { return &self; } + const LDKCOption_FilterZ* operator &() const { return &self; } + const LDKCOption_FilterZ* operator ->() const { return &self; } }; class CResult_SecretKeyErrorZ { private: @@ -4639,21 +4833,6 @@ public: const LDKCResult_FundingSignedDecodeErrorZ* operator &() const { return &self; } const LDKCResult_FundingSignedDecodeErrorZ* operator ->() const { return &self; } }; -class COption_FilterZ { -private: - LDKCOption_FilterZ self; -public: - COption_FilterZ(const COption_FilterZ&) = delete; - COption_FilterZ(COption_FilterZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_FilterZ)); } - COption_FilterZ(LDKCOption_FilterZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_FilterZ)); } - operator LDKCOption_FilterZ() && { LDKCOption_FilterZ res = self; memset(&self, 0, sizeof(LDKCOption_FilterZ)); return res; } - ~COption_FilterZ() { COption_FilterZ_free(self); } - COption_FilterZ& operator=(COption_FilterZ&& o) { COption_FilterZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_FilterZ)); return *this; } - LDKCOption_FilterZ* operator &() { return &self; } - LDKCOption_FilterZ* operator ->() { return &self; } - const LDKCOption_FilterZ* operator &() const { return &self; } - const LDKCOption_FilterZ* operator ->() const { return &self; } -}; class CResult_NetworkGraphDecodeErrorZ { private: LDKCResult_NetworkGraphDecodeErrorZ self; @@ -4819,6 +4998,51 @@ public: const LDKCVec_CResult_NoneAPIErrorZZ* operator &() const { return &self; } const LDKCVec_CResult_NoneAPIErrorZZ* operator ->() const { return &self; } }; +class CResult_CounterpartyCommitmentSecretsDecodeErrorZ { +private: + LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ self; +public: + CResult_CounterpartyCommitmentSecretsDecodeErrorZ(const CResult_CounterpartyCommitmentSecretsDecodeErrorZ&) = delete; + CResult_CounterpartyCommitmentSecretsDecodeErrorZ(CResult_CounterpartyCommitmentSecretsDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_CounterpartyCommitmentSecretsDecodeErrorZ)); } + CResult_CounterpartyCommitmentSecretsDecodeErrorZ(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ)); } + operator LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ() && { LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ)); return res; } + ~CResult_CounterpartyCommitmentSecretsDecodeErrorZ() { CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free(self); } + CResult_CounterpartyCommitmentSecretsDecodeErrorZ& operator=(CResult_CounterpartyCommitmentSecretsDecodeErrorZ&& o) { CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_CounterpartyCommitmentSecretsDecodeErrorZ)); return *this; } + LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* operator &() { return &self; } + LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* operator ->() const { return &self; } +}; +class CResult_ChannelCounterpartyDecodeErrorZ { +private: + LDKCResult_ChannelCounterpartyDecodeErrorZ self; +public: + CResult_ChannelCounterpartyDecodeErrorZ(const CResult_ChannelCounterpartyDecodeErrorZ&) = delete; + CResult_ChannelCounterpartyDecodeErrorZ(CResult_ChannelCounterpartyDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_ChannelCounterpartyDecodeErrorZ)); } + CResult_ChannelCounterpartyDecodeErrorZ(LDKCResult_ChannelCounterpartyDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ)); } + operator LDKCResult_ChannelCounterpartyDecodeErrorZ() && { LDKCResult_ChannelCounterpartyDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ)); return res; } + ~CResult_ChannelCounterpartyDecodeErrorZ() { CResult_ChannelCounterpartyDecodeErrorZ_free(self); } + CResult_ChannelCounterpartyDecodeErrorZ& operator=(CResult_ChannelCounterpartyDecodeErrorZ&& o) { CResult_ChannelCounterpartyDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_ChannelCounterpartyDecodeErrorZ)); return *this; } + LDKCResult_ChannelCounterpartyDecodeErrorZ* operator &() { return &self; } + LDKCResult_ChannelCounterpartyDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_ChannelCounterpartyDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_ChannelCounterpartyDecodeErrorZ* operator ->() const { return &self; } +}; +class CResult_WarningMessageDecodeErrorZ { +private: + LDKCResult_WarningMessageDecodeErrorZ self; +public: + CResult_WarningMessageDecodeErrorZ(const CResult_WarningMessageDecodeErrorZ&) = delete; + CResult_WarningMessageDecodeErrorZ(CResult_WarningMessageDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_WarningMessageDecodeErrorZ)); } + CResult_WarningMessageDecodeErrorZ(LDKCResult_WarningMessageDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_WarningMessageDecodeErrorZ)); } + operator LDKCResult_WarningMessageDecodeErrorZ() && { LDKCResult_WarningMessageDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_WarningMessageDecodeErrorZ)); return res; } + ~CResult_WarningMessageDecodeErrorZ() { CResult_WarningMessageDecodeErrorZ_free(self); } + CResult_WarningMessageDecodeErrorZ& operator=(CResult_WarningMessageDecodeErrorZ&& o) { CResult_WarningMessageDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_WarningMessageDecodeErrorZ)); return *this; } + LDKCResult_WarningMessageDecodeErrorZ* operator &() { return &self; } + LDKCResult_WarningMessageDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_WarningMessageDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_WarningMessageDecodeErrorZ* operator ->() const { return &self; } +}; class CResult_SignatureNoneZ { private: LDKCResult_SignatureNoneZ self; @@ -4849,6 +5073,21 @@ public: const LDKCVec_RouteHintHopZ* operator &() const { return &self; } const LDKCVec_RouteHintHopZ* operator ->() const { return &self; } }; +class CResult_SecretKeyNoneZ { +private: + LDKCResult_SecretKeyNoneZ self; +public: + CResult_SecretKeyNoneZ(const CResult_SecretKeyNoneZ&) = delete; + CResult_SecretKeyNoneZ(CResult_SecretKeyNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_SecretKeyNoneZ)); } + CResult_SecretKeyNoneZ(LDKCResult_SecretKeyNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_SecretKeyNoneZ)); } + operator LDKCResult_SecretKeyNoneZ() && { LDKCResult_SecretKeyNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_SecretKeyNoneZ)); return res; } + ~CResult_SecretKeyNoneZ() { CResult_SecretKeyNoneZ_free(self); } + CResult_SecretKeyNoneZ& operator=(CResult_SecretKeyNoneZ&& o) { CResult_SecretKeyNoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_SecretKeyNoneZ)); return *this; } + LDKCResult_SecretKeyNoneZ* operator &() { return &self; } + LDKCResult_SecretKeyNoneZ* operator ->() { return &self; } + const LDKCResult_SecretKeyNoneZ* operator &() const { return &self; } + const LDKCResult_SecretKeyNoneZ* operator ->() const { return &self; } +}; class CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ { private: LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ self; @@ -4879,6 +5118,21 @@ public: const LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* operator &() const { return &self; } const LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* operator ->() const { return &self; } }; +class CResult_PaymentParametersDecodeErrorZ { +private: + LDKCResult_PaymentParametersDecodeErrorZ self; +public: + CResult_PaymentParametersDecodeErrorZ(const CResult_PaymentParametersDecodeErrorZ&) = delete; + CResult_PaymentParametersDecodeErrorZ(CResult_PaymentParametersDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_PaymentParametersDecodeErrorZ)); } + CResult_PaymentParametersDecodeErrorZ(LDKCResult_PaymentParametersDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_PaymentParametersDecodeErrorZ)); } + operator LDKCResult_PaymentParametersDecodeErrorZ() && { LDKCResult_PaymentParametersDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_PaymentParametersDecodeErrorZ)); return res; } + ~CResult_PaymentParametersDecodeErrorZ() { CResult_PaymentParametersDecodeErrorZ_free(self); } + CResult_PaymentParametersDecodeErrorZ& operator=(CResult_PaymentParametersDecodeErrorZ&& o) { CResult_PaymentParametersDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_PaymentParametersDecodeErrorZ)); return *this; } + LDKCResult_PaymentParametersDecodeErrorZ* operator &() { return &self; } + LDKCResult_PaymentParametersDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_PaymentParametersDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_PaymentParametersDecodeErrorZ* operator ->() const { return &self; } +}; class CResult_InitDecodeErrorZ { private: LDKCResult_InitDecodeErrorZ self; @@ -4984,20 +5238,20 @@ public: const LDKCResult_RouteHintHopDecodeErrorZ* operator &() const { return &self; } const LDKCResult_RouteHintHopDecodeErrorZ* operator ->() const { return &self; } }; -class CResult_UpdateFailMalformedHTLCDecodeErrorZ { +class CResult_C2Tuple_SignatureSignatureZNoneZ { private: - LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ self; + LDKCResult_C2Tuple_SignatureSignatureZNoneZ self; public: - CResult_UpdateFailMalformedHTLCDecodeErrorZ(const CResult_UpdateFailMalformedHTLCDecodeErrorZ&) = delete; - CResult_UpdateFailMalformedHTLCDecodeErrorZ(CResult_UpdateFailMalformedHTLCDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_UpdateFailMalformedHTLCDecodeErrorZ)); } - CResult_UpdateFailMalformedHTLCDecodeErrorZ(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ)); } - operator LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ() && { LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ)); return res; } - ~CResult_UpdateFailMalformedHTLCDecodeErrorZ() { CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(self); } - CResult_UpdateFailMalformedHTLCDecodeErrorZ& operator=(CResult_UpdateFailMalformedHTLCDecodeErrorZ&& o) { CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_UpdateFailMalformedHTLCDecodeErrorZ)); return *this; } - LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* operator &() { return &self; } - LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* operator ->() const { return &self; } + CResult_C2Tuple_SignatureSignatureZNoneZ(const CResult_C2Tuple_SignatureSignatureZNoneZ&) = delete; + CResult_C2Tuple_SignatureSignatureZNoneZ(CResult_C2Tuple_SignatureSignatureZNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_C2Tuple_SignatureSignatureZNoneZ)); } + CResult_C2Tuple_SignatureSignatureZNoneZ(LDKCResult_C2Tuple_SignatureSignatureZNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ)); } + operator LDKCResult_C2Tuple_SignatureSignatureZNoneZ() && { LDKCResult_C2Tuple_SignatureSignatureZNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ)); return res; } + ~CResult_C2Tuple_SignatureSignatureZNoneZ() { CResult_C2Tuple_SignatureSignatureZNoneZ_free(self); } + CResult_C2Tuple_SignatureSignatureZNoneZ& operator=(CResult_C2Tuple_SignatureSignatureZNoneZ&& o) { CResult_C2Tuple_SignatureSignatureZNoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_C2Tuple_SignatureSignatureZNoneZ)); return *this; } + LDKCResult_C2Tuple_SignatureSignatureZNoneZ* operator &() { return &self; } + LDKCResult_C2Tuple_SignatureSignatureZNoneZ* operator ->() { return &self; } + const LDKCResult_C2Tuple_SignatureSignatureZNoneZ* operator &() const { return &self; } + const LDKCResult_C2Tuple_SignatureSignatureZNoneZ* operator ->() const { return &self; } }; class CVec_NodeAnnouncementZ { private: @@ -5014,6 +5268,21 @@ public: const LDKCVec_NodeAnnouncementZ* operator &() const { return &self; } const LDKCVec_NodeAnnouncementZ* operator ->() const { return &self; } }; +class CResult_UpdateFailMalformedHTLCDecodeErrorZ { +private: + LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ self; +public: + CResult_UpdateFailMalformedHTLCDecodeErrorZ(const CResult_UpdateFailMalformedHTLCDecodeErrorZ&) = delete; + CResult_UpdateFailMalformedHTLCDecodeErrorZ(CResult_UpdateFailMalformedHTLCDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_UpdateFailMalformedHTLCDecodeErrorZ)); } + CResult_UpdateFailMalformedHTLCDecodeErrorZ(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ)); } + operator LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ() && { LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ)); return res; } + ~CResult_UpdateFailMalformedHTLCDecodeErrorZ() { CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(self); } + CResult_UpdateFailMalformedHTLCDecodeErrorZ& operator=(CResult_UpdateFailMalformedHTLCDecodeErrorZ&& o) { CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_UpdateFailMalformedHTLCDecodeErrorZ)); return *this; } + LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* operator &() { return &self; } + LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* operator ->() const { return &self; } +}; class CResult_UnsignedChannelAnnouncementDecodeErrorZ { private: LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ self; @@ -5119,6 +5388,21 @@ public: const LDKCResult_CVec_CVec_u8ZZNoneZ* operator &() const { return &self; } const LDKCResult_CVec_CVec_u8ZZNoneZ* operator ->() const { return &self; } }; +class C2Tuple_SignatureSignatureZ { +private: + LDKC2Tuple_SignatureSignatureZ self; +public: + C2Tuple_SignatureSignatureZ(const C2Tuple_SignatureSignatureZ&) = delete; + C2Tuple_SignatureSignatureZ(C2Tuple_SignatureSignatureZ&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_SignatureSignatureZ)); } + C2Tuple_SignatureSignatureZ(LDKC2Tuple_SignatureSignatureZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_SignatureSignatureZ)); } + operator LDKC2Tuple_SignatureSignatureZ() && { LDKC2Tuple_SignatureSignatureZ res = self; memset(&self, 0, sizeof(LDKC2Tuple_SignatureSignatureZ)); return res; } + ~C2Tuple_SignatureSignatureZ() { C2Tuple_SignatureSignatureZ_free(self); } + C2Tuple_SignatureSignatureZ& operator=(C2Tuple_SignatureSignatureZ&& o) { C2Tuple_SignatureSignatureZ_free(self); self = o.self; memset(&o, 0, sizeof(C2Tuple_SignatureSignatureZ)); return *this; } + LDKC2Tuple_SignatureSignatureZ* operator &() { return &self; } + LDKC2Tuple_SignatureSignatureZ* operator ->() { return &self; } + const LDKC2Tuple_SignatureSignatureZ* operator &() const { return &self; } + const LDKC2Tuple_SignatureSignatureZ* operator ->() const { return &self; } +}; class C2Tuple_PaymentHashPaymentSecretZ { private: LDKC2Tuple_PaymentHashPaymentSecretZ self; @@ -5134,21 +5418,6 @@ public: const LDKC2Tuple_PaymentHashPaymentSecretZ* operator &() const { return &self; } const LDKC2Tuple_PaymentHashPaymentSecretZ* operator ->() const { return &self; } }; -class CResult_AcceptChannelDecodeErrorZ { -private: - LDKCResult_AcceptChannelDecodeErrorZ self; -public: - CResult_AcceptChannelDecodeErrorZ(const CResult_AcceptChannelDecodeErrorZ&) = delete; - CResult_AcceptChannelDecodeErrorZ(CResult_AcceptChannelDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_AcceptChannelDecodeErrorZ)); } - CResult_AcceptChannelDecodeErrorZ(LDKCResult_AcceptChannelDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_AcceptChannelDecodeErrorZ)); } - operator LDKCResult_AcceptChannelDecodeErrorZ() && { LDKCResult_AcceptChannelDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_AcceptChannelDecodeErrorZ)); return res; } - ~CResult_AcceptChannelDecodeErrorZ() { CResult_AcceptChannelDecodeErrorZ_free(self); } - CResult_AcceptChannelDecodeErrorZ& operator=(CResult_AcceptChannelDecodeErrorZ&& o) { CResult_AcceptChannelDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_AcceptChannelDecodeErrorZ)); return *this; } - LDKCResult_AcceptChannelDecodeErrorZ* operator &() { return &self; } - LDKCResult_AcceptChannelDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_AcceptChannelDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_AcceptChannelDecodeErrorZ* operator ->() const { return &self; } -}; class C2Tuple_BlockHashChannelManagerZ { private: LDKC2Tuple_BlockHashChannelManagerZ self; @@ -5179,20 +5448,20 @@ public: const LDKCResult_ChannelTransactionParametersDecodeErrorZ* operator &() const { return &self; } const LDKCResult_ChannelTransactionParametersDecodeErrorZ* operator ->() const { return &self; } }; -class CResult_PongDecodeErrorZ { +class CResult_AcceptChannelDecodeErrorZ { private: - LDKCResult_PongDecodeErrorZ self; + LDKCResult_AcceptChannelDecodeErrorZ self; public: - CResult_PongDecodeErrorZ(const CResult_PongDecodeErrorZ&) = delete; - CResult_PongDecodeErrorZ(CResult_PongDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_PongDecodeErrorZ)); } - CResult_PongDecodeErrorZ(LDKCResult_PongDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_PongDecodeErrorZ)); } - operator LDKCResult_PongDecodeErrorZ() && { LDKCResult_PongDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_PongDecodeErrorZ)); return res; } - ~CResult_PongDecodeErrorZ() { CResult_PongDecodeErrorZ_free(self); } - CResult_PongDecodeErrorZ& operator=(CResult_PongDecodeErrorZ&& o) { CResult_PongDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_PongDecodeErrorZ)); return *this; } - LDKCResult_PongDecodeErrorZ* operator &() { return &self; } - LDKCResult_PongDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_PongDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_PongDecodeErrorZ* operator ->() const { return &self; } + CResult_AcceptChannelDecodeErrorZ(const CResult_AcceptChannelDecodeErrorZ&) = delete; + CResult_AcceptChannelDecodeErrorZ(CResult_AcceptChannelDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_AcceptChannelDecodeErrorZ)); } + CResult_AcceptChannelDecodeErrorZ(LDKCResult_AcceptChannelDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_AcceptChannelDecodeErrorZ)); } + operator LDKCResult_AcceptChannelDecodeErrorZ() && { LDKCResult_AcceptChannelDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_AcceptChannelDecodeErrorZ)); return res; } + ~CResult_AcceptChannelDecodeErrorZ() { CResult_AcceptChannelDecodeErrorZ_free(self); } + CResult_AcceptChannelDecodeErrorZ& operator=(CResult_AcceptChannelDecodeErrorZ&& o) { CResult_AcceptChannelDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_AcceptChannelDecodeErrorZ)); return *this; } + LDKCResult_AcceptChannelDecodeErrorZ* operator &() { return &self; } + LDKCResult_AcceptChannelDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_AcceptChannelDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_AcceptChannelDecodeErrorZ* operator ->() const { return &self; } }; class CVec_SignatureZ { private: @@ -5329,6 +5598,21 @@ public: const LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* operator &() const { return &self; } const LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* operator ->() const { return &self; } }; +class CResult_PongDecodeErrorZ { +private: + LDKCResult_PongDecodeErrorZ self; +public: + CResult_PongDecodeErrorZ(const CResult_PongDecodeErrorZ&) = delete; + CResult_PongDecodeErrorZ(CResult_PongDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_PongDecodeErrorZ)); } + CResult_PongDecodeErrorZ(LDKCResult_PongDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_PongDecodeErrorZ)); } + operator LDKCResult_PongDecodeErrorZ() && { LDKCResult_PongDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_PongDecodeErrorZ)); return res; } + ~CResult_PongDecodeErrorZ() { CResult_PongDecodeErrorZ_free(self); } + CResult_PongDecodeErrorZ& operator=(CResult_PongDecodeErrorZ&& o) { CResult_PongDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_PongDecodeErrorZ)); return *this; } + LDKCResult_PongDecodeErrorZ* operator &() { return &self; } + LDKCResult_PongDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_PongDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_PongDecodeErrorZ* operator ->() const { return &self; } +}; class CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ { private: LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ self; @@ -5434,6 +5718,21 @@ public: const LDKCResult_TrustedCommitmentTransactionNoneZ* operator &() const { return &self; } const LDKCResult_TrustedCommitmentTransactionNoneZ* operator ->() const { return &self; } }; +class CResult_FixedPenaltyScorerDecodeErrorZ { +private: + LDKCResult_FixedPenaltyScorerDecodeErrorZ self; +public: + CResult_FixedPenaltyScorerDecodeErrorZ(const CResult_FixedPenaltyScorerDecodeErrorZ&) = delete; + CResult_FixedPenaltyScorerDecodeErrorZ(CResult_FixedPenaltyScorerDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_FixedPenaltyScorerDecodeErrorZ)); } + CResult_FixedPenaltyScorerDecodeErrorZ(LDKCResult_FixedPenaltyScorerDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ)); } + operator LDKCResult_FixedPenaltyScorerDecodeErrorZ() && { LDKCResult_FixedPenaltyScorerDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ)); return res; } + ~CResult_FixedPenaltyScorerDecodeErrorZ() { CResult_FixedPenaltyScorerDecodeErrorZ_free(self); } + CResult_FixedPenaltyScorerDecodeErrorZ& operator=(CResult_FixedPenaltyScorerDecodeErrorZ&& o) { CResult_FixedPenaltyScorerDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_FixedPenaltyScorerDecodeErrorZ)); return *this; } + LDKCResult_FixedPenaltyScorerDecodeErrorZ* operator &() { return &self; } + LDKCResult_FixedPenaltyScorerDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_FixedPenaltyScorerDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_FixedPenaltyScorerDecodeErrorZ* operator ->() const { return &self; } +}; class CResult_NoneLightningErrorZ { private: LDKCResult_NoneLightningErrorZ self; @@ -5494,21 +5793,6 @@ public: const LDKCResult_CVec_SignatureZNoneZ* operator &() const { return &self; } const LDKCResult_CVec_SignatureZNoneZ* operator ->() const { return &self; } }; -class CResult_PayeeDecodeErrorZ { -private: - LDKCResult_PayeeDecodeErrorZ self; -public: - CResult_PayeeDecodeErrorZ(const CResult_PayeeDecodeErrorZ&) = delete; - CResult_PayeeDecodeErrorZ(CResult_PayeeDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_PayeeDecodeErrorZ)); } - CResult_PayeeDecodeErrorZ(LDKCResult_PayeeDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_PayeeDecodeErrorZ)); } - operator LDKCResult_PayeeDecodeErrorZ() && { LDKCResult_PayeeDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_PayeeDecodeErrorZ)); return res; } - ~CResult_PayeeDecodeErrorZ() { CResult_PayeeDecodeErrorZ_free(self); } - CResult_PayeeDecodeErrorZ& operator=(CResult_PayeeDecodeErrorZ&& o) { CResult_PayeeDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_PayeeDecodeErrorZ)); return *this; } - LDKCResult_PayeeDecodeErrorZ* operator &() { return &self; } - LDKCResult_PayeeDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_PayeeDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_PayeeDecodeErrorZ* operator ->() const { return &self; } -}; class COption_CVec_NetAddressZZ { private: LDKCOption_CVec_NetAddressZZ self; @@ -5674,6 +5958,21 @@ public: const LDKCResult_UpdateAddHTLCDecodeErrorZ* operator &() const { return &self; } const LDKCResult_UpdateAddHTLCDecodeErrorZ* operator ->() const { return &self; } }; +class CVec_PhantomRouteHintsZ { +private: + LDKCVec_PhantomRouteHintsZ self; +public: + CVec_PhantomRouteHintsZ(const CVec_PhantomRouteHintsZ&) = delete; + CVec_PhantomRouteHintsZ(CVec_PhantomRouteHintsZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_PhantomRouteHintsZ)); } + CVec_PhantomRouteHintsZ(LDKCVec_PhantomRouteHintsZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_PhantomRouteHintsZ)); } + operator LDKCVec_PhantomRouteHintsZ() && { LDKCVec_PhantomRouteHintsZ res = self; memset(&self, 0, sizeof(LDKCVec_PhantomRouteHintsZ)); return res; } + ~CVec_PhantomRouteHintsZ() { CVec_PhantomRouteHintsZ_free(self); } + CVec_PhantomRouteHintsZ& operator=(CVec_PhantomRouteHintsZ&& o) { CVec_PhantomRouteHintsZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_PhantomRouteHintsZ)); return *this; } + LDKCVec_PhantomRouteHintsZ* operator &() { return &self; } + LDKCVec_PhantomRouteHintsZ* operator ->() { return &self; } + const LDKCVec_PhantomRouteHintsZ* operator &() const { return &self; } + const LDKCVec_PhantomRouteHintsZ* operator ->() const { return &self; } +}; class CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { private: LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ self; @@ -5719,6 +6018,21 @@ public: const LDKCVec_NetAddressZ* operator &() const { return &self; } const LDKCVec_NetAddressZ* operator ->() const { return &self; } }; +class CResult_ChannelDetailsDecodeErrorZ { +private: + LDKCResult_ChannelDetailsDecodeErrorZ self; +public: + CResult_ChannelDetailsDecodeErrorZ(const CResult_ChannelDetailsDecodeErrorZ&) = delete; + CResult_ChannelDetailsDecodeErrorZ(CResult_ChannelDetailsDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_ChannelDetailsDecodeErrorZ)); } + CResult_ChannelDetailsDecodeErrorZ(LDKCResult_ChannelDetailsDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_ChannelDetailsDecodeErrorZ)); } + operator LDKCResult_ChannelDetailsDecodeErrorZ() && { LDKCResult_ChannelDetailsDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_ChannelDetailsDecodeErrorZ)); return res; } + ~CResult_ChannelDetailsDecodeErrorZ() { CResult_ChannelDetailsDecodeErrorZ_free(self); } + CResult_ChannelDetailsDecodeErrorZ& operator=(CResult_ChannelDetailsDecodeErrorZ&& o) { CResult_ChannelDetailsDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_ChannelDetailsDecodeErrorZ)); return *this; } + LDKCResult_ChannelDetailsDecodeErrorZ* operator &() { return &self; } + LDKCResult_ChannelDetailsDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_ChannelDetailsDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_ChannelDetailsDecodeErrorZ* operator ->() const { return &self; } +}; class CVec_C2Tuple_usizeTransactionZZ { private: LDKCVec_C2Tuple_usizeTransactionZZ self; @@ -5794,21 +6108,6 @@ public: const LDKCResult_COption_TypeZDecodeErrorZ* operator &() const { return &self; } const LDKCResult_COption_TypeZDecodeErrorZ* operator ->() const { return &self; } }; -class CResult_DirectionalChannelInfoDecodeErrorZ { -private: - LDKCResult_DirectionalChannelInfoDecodeErrorZ self; -public: - CResult_DirectionalChannelInfoDecodeErrorZ(const CResult_DirectionalChannelInfoDecodeErrorZ&) = delete; - CResult_DirectionalChannelInfoDecodeErrorZ(CResult_DirectionalChannelInfoDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_DirectionalChannelInfoDecodeErrorZ)); } - CResult_DirectionalChannelInfoDecodeErrorZ(LDKCResult_DirectionalChannelInfoDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ)); } - operator LDKCResult_DirectionalChannelInfoDecodeErrorZ() && { LDKCResult_DirectionalChannelInfoDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ)); return res; } - ~CResult_DirectionalChannelInfoDecodeErrorZ() { CResult_DirectionalChannelInfoDecodeErrorZ_free(self); } - CResult_DirectionalChannelInfoDecodeErrorZ& operator=(CResult_DirectionalChannelInfoDecodeErrorZ&& o) { CResult_DirectionalChannelInfoDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_DirectionalChannelInfoDecodeErrorZ)); return *this; } - LDKCResult_DirectionalChannelInfoDecodeErrorZ* operator &() { return &self; } - LDKCResult_DirectionalChannelInfoDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_DirectionalChannelInfoDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_DirectionalChannelInfoDecodeErrorZ* operator ->() const { return &self; } -}; class C2Tuple_u32TxOutZ { private: LDKC2Tuple_u32TxOutZ self; @@ -5989,6 +6288,21 @@ public: const LDKCVec_MonitorEventZ* operator &() const { return &self; } const LDKCVec_MonitorEventZ* operator ->() const { return &self; } }; +class CVec_PaymentPreimageZ { +private: + LDKCVec_PaymentPreimageZ self; +public: + CVec_PaymentPreimageZ(const CVec_PaymentPreimageZ&) = delete; + CVec_PaymentPreimageZ(CVec_PaymentPreimageZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_PaymentPreimageZ)); } + CVec_PaymentPreimageZ(LDKCVec_PaymentPreimageZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_PaymentPreimageZ)); } + operator LDKCVec_PaymentPreimageZ() && { LDKCVec_PaymentPreimageZ res = self; memset(&self, 0, sizeof(LDKCVec_PaymentPreimageZ)); return res; } + ~CVec_PaymentPreimageZ() { CVec_PaymentPreimageZ_free(self); } + CVec_PaymentPreimageZ& operator=(CVec_PaymentPreimageZ&& o) { CVec_PaymentPreimageZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_PaymentPreimageZ)); return *this; } + LDKCVec_PaymentPreimageZ* operator &() { return &self; } + LDKCVec_PaymentPreimageZ* operator ->() { return &self; } + const LDKCVec_PaymentPreimageZ* operator &() const { return &self; } + const LDKCVec_PaymentPreimageZ* operator ->() const { return &self; } +}; class CVec_C2Tuple_u32ScriptZZ { private: LDKCVec_C2Tuple_u32ScriptZZ self; @@ -6079,6 +6393,21 @@ public: const LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* operator &() const { return &self; } const LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* operator ->() const { return &self; } }; +class CResult_NoneNoneZ { +private: + LDKCResult_NoneNoneZ self; +public: + CResult_NoneNoneZ(const CResult_NoneNoneZ&) = delete; + CResult_NoneNoneZ(CResult_NoneNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_NoneNoneZ)); } + CResult_NoneNoneZ(LDKCResult_NoneNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_NoneNoneZ)); } + operator LDKCResult_NoneNoneZ() && { LDKCResult_NoneNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_NoneNoneZ)); return res; } + ~CResult_NoneNoneZ() { CResult_NoneNoneZ_free(self); } + CResult_NoneNoneZ& operator=(CResult_NoneNoneZ&& o) { CResult_NoneNoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_NoneNoneZ)); return *this; } + LDKCResult_NoneNoneZ* operator &() { return &self; } + LDKCResult_NoneNoneZ* operator ->() { return &self; } + const LDKCResult_NoneNoneZ* operator &() const { return &self; } + const LDKCResult_NoneNoneZ* operator ->() const { return &self; } +}; class CResult_RouteParametersDecodeErrorZ { private: LDKCResult_RouteParametersDecodeErrorZ self; @@ -6109,21 +6438,6 @@ public: const LDKCOption_ClosureReasonZ* operator &() const { return &self; } const LDKCOption_ClosureReasonZ* operator ->() const { return &self; } }; -class CResult_NoneNoneZ { -private: - LDKCResult_NoneNoneZ self; -public: - CResult_NoneNoneZ(const CResult_NoneNoneZ&) = delete; - CResult_NoneNoneZ(CResult_NoneNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_NoneNoneZ)); } - CResult_NoneNoneZ(LDKCResult_NoneNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_NoneNoneZ)); } - operator LDKCResult_NoneNoneZ() && { LDKCResult_NoneNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_NoneNoneZ)); return res; } - ~CResult_NoneNoneZ() { CResult_NoneNoneZ_free(self); } - CResult_NoneNoneZ& operator=(CResult_NoneNoneZ&& o) { CResult_NoneNoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_NoneNoneZ)); return *this; } - LDKCResult_NoneNoneZ* operator &() { return &self; } - LDKCResult_NoneNoneZ* operator ->() { return &self; } - const LDKCResult_NoneNoneZ* operator &() const { return &self; } - const LDKCResult_NoneNoneZ* operator ->() const { return &self; } -}; class CVec_APIErrorZ { private: LDKCVec_APIErrorZ self; @@ -6244,6 +6558,21 @@ public: const LDKCResult_NodeFeaturesDecodeErrorZ* operator &() const { return &self; } const LDKCResult_NodeFeaturesDecodeErrorZ* operator ->() const { return &self; } }; +class CVec_u5Z { +private: + LDKCVec_u5Z self; +public: + CVec_u5Z(const CVec_u5Z&) = delete; + CVec_u5Z(CVec_u5Z&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_u5Z)); } + CVec_u5Z(LDKCVec_u5Z&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_u5Z)); } + operator LDKCVec_u5Z() && { LDKCVec_u5Z res = self; memset(&self, 0, sizeof(LDKCVec_u5Z)); return res; } + ~CVec_u5Z() { CVec_u5Z_free(self); } + CVec_u5Z& operator=(CVec_u5Z&& o) { CVec_u5Z_free(self); self = o.self; memset(&o, 0, sizeof(CVec_u5Z)); return *this; } + LDKCVec_u5Z* operator &() { return &self; } + LDKCVec_u5Z* operator ->() { return &self; } + const LDKCVec_u5Z* operator &() const { return &self; } + const LDKCVec_u5Z* operator ->() const { return &self; } +}; class CResult_InMemorySignerDecodeErrorZ { private: LDKCResult_InMemorySignerDecodeErrorZ self; @@ -6274,6 +6603,21 @@ public: const LDKCResult_PaymentSecretAPIErrorZ* operator &() const { return &self; } const LDKCResult_PaymentSecretAPIErrorZ* operator ->() const { return &self; } }; +class CResult_CounterpartyForwardingInfoDecodeErrorZ { +private: + LDKCResult_CounterpartyForwardingInfoDecodeErrorZ self; +public: + CResult_CounterpartyForwardingInfoDecodeErrorZ(const CResult_CounterpartyForwardingInfoDecodeErrorZ&) = delete; + CResult_CounterpartyForwardingInfoDecodeErrorZ(CResult_CounterpartyForwardingInfoDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_CounterpartyForwardingInfoDecodeErrorZ)); } + CResult_CounterpartyForwardingInfoDecodeErrorZ(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ)); } + operator LDKCResult_CounterpartyForwardingInfoDecodeErrorZ() && { LDKCResult_CounterpartyForwardingInfoDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ)); return res; } + ~CResult_CounterpartyForwardingInfoDecodeErrorZ() { CResult_CounterpartyForwardingInfoDecodeErrorZ_free(self); } + CResult_CounterpartyForwardingInfoDecodeErrorZ& operator=(CResult_CounterpartyForwardingInfoDecodeErrorZ&& o) { CResult_CounterpartyForwardingInfoDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_CounterpartyForwardingInfoDecodeErrorZ)); return *this; } + LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* operator &() { return &self; } + LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* operator ->() const { return &self; } +}; class C2Tuple_u32ScriptZ { private: LDKC2Tuple_u32ScriptZ self; @@ -6364,6 +6708,21 @@ public: const LDKCVec_TxOutZ* operator &() const { return &self; } const LDKCVec_TxOutZ* operator ->() const { return &self; } }; +class CResult_ProbabilisticScoringParametersDecodeErrorZ { +private: + LDKCResult_ProbabilisticScoringParametersDecodeErrorZ self; +public: + CResult_ProbabilisticScoringParametersDecodeErrorZ(const CResult_ProbabilisticScoringParametersDecodeErrorZ&) = delete; + CResult_ProbabilisticScoringParametersDecodeErrorZ(CResult_ProbabilisticScoringParametersDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_ProbabilisticScoringParametersDecodeErrorZ)); } + CResult_ProbabilisticScoringParametersDecodeErrorZ(LDKCResult_ProbabilisticScoringParametersDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_ProbabilisticScoringParametersDecodeErrorZ)); } + operator LDKCResult_ProbabilisticScoringParametersDecodeErrorZ() && { LDKCResult_ProbabilisticScoringParametersDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_ProbabilisticScoringParametersDecodeErrorZ)); return res; } + ~CResult_ProbabilisticScoringParametersDecodeErrorZ() { CResult_ProbabilisticScoringParametersDecodeErrorZ_free(self); } + CResult_ProbabilisticScoringParametersDecodeErrorZ& operator=(CResult_ProbabilisticScoringParametersDecodeErrorZ&& o) { CResult_ProbabilisticScoringParametersDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_ProbabilisticScoringParametersDecodeErrorZ)); return *this; } + LDKCResult_ProbabilisticScoringParametersDecodeErrorZ* operator &() { return &self; } + LDKCResult_ProbabilisticScoringParametersDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_ProbabilisticScoringParametersDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_ProbabilisticScoringParametersDecodeErrorZ* operator ->() const { return &self; } +}; class CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ { private: LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ self; @@ -6379,6 +6738,21 @@ public: const LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* operator &() const { return &self; } const LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* operator ->() const { return &self; } }; +class CResult_ChannelUpdateInfoDecodeErrorZ { +private: + LDKCResult_ChannelUpdateInfoDecodeErrorZ self; +public: + CResult_ChannelUpdateInfoDecodeErrorZ(const CResult_ChannelUpdateInfoDecodeErrorZ&) = delete; + CResult_ChannelUpdateInfoDecodeErrorZ(CResult_ChannelUpdateInfoDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_ChannelUpdateInfoDecodeErrorZ)); } + CResult_ChannelUpdateInfoDecodeErrorZ(LDKCResult_ChannelUpdateInfoDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ)); } + operator LDKCResult_ChannelUpdateInfoDecodeErrorZ() && { LDKCResult_ChannelUpdateInfoDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ)); return res; } + ~CResult_ChannelUpdateInfoDecodeErrorZ() { CResult_ChannelUpdateInfoDecodeErrorZ_free(self); } + CResult_ChannelUpdateInfoDecodeErrorZ& operator=(CResult_ChannelUpdateInfoDecodeErrorZ&& o) { CResult_ChannelUpdateInfoDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_ChannelUpdateInfoDecodeErrorZ)); return *this; } + LDKCResult_ChannelUpdateInfoDecodeErrorZ* operator &() { return &self; } + LDKCResult_ChannelUpdateInfoDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_ChannelUpdateInfoDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_ChannelUpdateInfoDecodeErrorZ* operator ->() const { return &self; } +}; class CVec_UpdateFailHTLCZ { private: LDKCVec_UpdateFailHTLCZ self; @@ -6473,8 +6847,8 @@ inline void EventsProvider::process_pending_events(struct LDKEventHandler handle inline void EventHandler::handle_event(const struct LDKEvent *NONNULL_PTR event) { (self.handle_event)(self.this_arg, event); } -inline uint64_t Score::channel_penalty_msat(uint64_t short_channel_id, uint64_t send_amt_msat, struct LDKCOption_u64Z channel_capacity_msat, const struct LDKNodeId *NONNULL_PTR source, const struct LDKNodeId *NONNULL_PTR target) { - uint64_t ret = (self.channel_penalty_msat)(self.this_arg, short_channel_id, send_amt_msat, channel_capacity_msat, source, target); +inline uint64_t Score::channel_penalty_msat(uint64_t short_channel_id, uint64_t send_amt_msat, uint64_t capacity_msat, const struct LDKNodeId *NONNULL_PTR source, const struct LDKNodeId *NONNULL_PTR target) { + uint64_t ret = (self.channel_penalty_msat)(self.this_arg, short_channel_id, send_amt_msat, capacity_msat, source, target); return ret; } inline void Score::payment_path_failed(struct LDKCVec_RouteHopZ path, uint64_t short_channel_id) { @@ -6495,16 +6869,16 @@ inline LDKThirtyTwoBytes BaseSign::release_commitment_secret(uint64_t idx) { LDKThirtyTwoBytes ret = (self.release_commitment_secret)(self.this_arg, idx); return ret; } -inline LDK::CResult_NoneNoneZ BaseSign::validate_holder_commitment(const struct LDKHolderCommitmentTransaction *NONNULL_PTR holder_tx) { - LDK::CResult_NoneNoneZ ret = (self.validate_holder_commitment)(self.this_arg, holder_tx); +inline LDK::CResult_NoneNoneZ BaseSign::validate_holder_commitment(const struct LDKHolderCommitmentTransaction *NONNULL_PTR holder_tx, struct LDKCVec_PaymentPreimageZ preimages) { + LDK::CResult_NoneNoneZ ret = (self.validate_holder_commitment)(self.this_arg, holder_tx, preimages); return ret; } inline LDKThirtyTwoBytes BaseSign::channel_keys_id() { LDKThirtyTwoBytes ret = (self.channel_keys_id)(self.this_arg); return ret; } -inline LDK::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ BaseSign::sign_counterparty_commitment(const struct LDKCommitmentTransaction *NONNULL_PTR commitment_tx) { - LDK::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret = (self.sign_counterparty_commitment)(self.this_arg, commitment_tx); +inline LDK::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ BaseSign::sign_counterparty_commitment(const struct LDKCommitmentTransaction *NONNULL_PTR commitment_tx, struct LDKCVec_PaymentPreimageZ preimages) { + LDK::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret = (self.sign_counterparty_commitment)(self.this_arg, commitment_tx, preimages); return ret; } inline LDK::CResult_NoneNoneZ BaseSign::validate_counterparty_revocation(uint64_t idx, const uint8_t (*secret)[32]) { @@ -6531,15 +6905,15 @@ inline LDK::CResult_SignatureNoneZ BaseSign::sign_closing_transaction(const stru LDK::CResult_SignatureNoneZ ret = (self.sign_closing_transaction)(self.this_arg, closing_tx); return ret; } -inline LDK::CResult_SignatureNoneZ BaseSign::sign_channel_announcement(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR msg) { - LDK::CResult_SignatureNoneZ ret = (self.sign_channel_announcement)(self.this_arg, msg); +inline LDK::CResult_C2Tuple_SignatureSignatureZNoneZ BaseSign::sign_channel_announcement(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR msg) { + LDK::CResult_C2Tuple_SignatureSignatureZNoneZ ret = (self.sign_channel_announcement)(self.this_arg, msg); return ret; } inline void BaseSign::ready_channel(const struct LDKChannelTransactionParameters *NONNULL_PTR channel_parameters) { (self.ready_channel)(self.this_arg, channel_parameters); } -inline LDKSecretKey KeysInterface::get_node_secret() { - LDKSecretKey ret = (self.get_node_secret)(self.this_arg); +inline LDK::CResult_SecretKeyNoneZ KeysInterface::get_node_secret(enum LDKRecipient recipient) { + LDK::CResult_SecretKeyNoneZ ret = (self.get_node_secret)(self.this_arg, recipient); return ret; } inline LDK::CVec_u8Z KeysInterface::get_destination_script() { @@ -6562,8 +6936,8 @@ inline LDK::CResult_SignDecodeErrorZ KeysInterface::read_chan_signer(struct LDKu LDK::CResult_SignDecodeErrorZ ret = (self.read_chan_signer)(self.this_arg, reader); return ret; } -inline LDK::CResult_RecoverableSignatureNoneZ KeysInterface::sign_invoice(struct LDKCVec_u8Z invoice_preimage) { - LDK::CResult_RecoverableSignatureNoneZ ret = (self.sign_invoice)(self.this_arg, invoice_preimage); +inline LDK::CResult_RecoverableSignatureNoneZ KeysInterface::sign_invoice(struct LDKu8slice hrp_bytes, struct LDKCVec_u5Z invoice_data, enum LDKRecipient receipient) { + LDK::CResult_RecoverableSignatureNoneZ ret = (self.sign_invoice)(self.this_arg, hrp_bytes, invoice_data, receipient); return ret; } inline LDKThirtyTwoBytes KeysInterface::get_inbound_payment_key_material() { @@ -6605,8 +6979,8 @@ inline LDK::CResult_NonePaymentSendFailureZ Payer::retry_payment(const struct LD inline void Payer::abandon_payment(struct LDKThirtyTwoBytes payment_id) { (self.abandon_payment)(self.this_arg, payment_id); } -inline LDK::CResult_RouteLightningErrorZ Router::find_route(struct LDKPublicKey payer, const struct LDKRouteParameters *NONNULL_PTR params, const uint8_t (*payment_hash)[32], struct LDKCVec_ChannelDetailsZ *first_hops, const struct LDKScore *NONNULL_PTR scorer) { - LDK::CResult_RouteLightningErrorZ ret = (self.find_route)(self.this_arg, payer, params, payment_hash, first_hops, scorer); +inline LDK::CResult_RouteLightningErrorZ Router::find_route(struct LDKPublicKey payer, const struct LDKRouteParameters *NONNULL_PTR route_params, const uint8_t (*payment_hash)[32], struct LDKCVec_ChannelDetailsZ *first_hops, const struct LDKScore *NONNULL_PTR scorer) { + LDK::CResult_RouteLightningErrorZ ret = (self.find_route)(self.this_arg, payer, route_params, payment_hash, first_hops, scorer); return ret; } inline LDK::CResult_NoneLightningErrorZ CustomMessageHandler::handle_custom_message(struct LDKType msg, struct LDKPublicKey sender_node_id) { diff --git a/lightning-c-bindings/src/c_types/derived.rs b/lightning-c-bindings/src/c_types/derived.rs index c8b0a5b..b531374 100644 --- a/lightning-c-bindings/src/c_types/derived.rs +++ b/lightning-c-bindings/src/c_types/derived.rs @@ -7,6 +7,190 @@ use crate::c_types::*; #[cfg(feature="no-std")] use alloc::{vec::Vec, boxed::Box}; +#[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, +} +#[repr(C)] +/// A CResult_NoneNoneZ represents the result of a fallible operation, +/// containing a () on success and a () on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_NoneNoneZ { + /// The contents of this CResult_NoneNoneZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_NoneNoneZPtr, + /// Whether this CResult_NoneNoneZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_NoneNoneZ in the success state. +pub extern "C" fn CResult_NoneNoneZ_ok() -> CResult_NoneNoneZ { + CResult_NoneNoneZ { + contents: CResult_NoneNoneZPtr { + result: core::ptr::null_mut(), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_NoneNoneZ in the error state. +pub extern "C" fn CResult_NoneNoneZ_err() -> CResult_NoneNoneZ { + CResult_NoneNoneZ { + contents: CResult_NoneNoneZPtr { + err: core::ptr::null_mut(), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_NoneNoneZ_is_ok(o: &CResult_NoneNoneZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_NoneNoneZ. +pub extern "C" fn CResult_NoneNoneZ_free(_res: CResult_NoneNoneZ) { } +impl Drop for CResult_NoneNoneZ { + fn drop(&mut self) { + if self.result_ok { + } else { + } + } +} +impl From> for CResult_NoneNoneZ { + fn from(mut o: crate::c_types::CResultTempl<(), ()>) -> Self { + let contents = if o.result_ok { + let _ = unsafe { Box::from_raw(o.contents.result) }; + o.contents.result = core::ptr::null_mut(); + CResult_NoneNoneZPtr { result: core::ptr::null_mut() } + } else { + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_NoneNoneZPtr { err: core::ptr::null_mut() } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_NoneNoneZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_NoneNoneZPtr { + result: core::ptr::null_mut() + } } + } else { + Self { result_ok: false, contents: CResult_NoneNoneZPtr { + err: core::ptr::null_mut() + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_NoneNoneZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_NoneNoneZ_clone(orig: &CResult_NoneNoneZ) -> CResult_NoneNoneZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_CounterpartyCommitmentSecretsDecodeErrorZ +pub union CResult_CounterpartyCommitmentSecretsDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::chan_utils::CounterpartyCommitmentSecrets, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_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_CounterpartyCommitmentSecretsDecodeErrorZ { + /// The contents of this CResult_CounterpartyCommitmentSecretsDecodeErrorZ, 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 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 { + 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 { + 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_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok(o: &CResult_CounterpartyCommitmentSecretsDecodeErrorZ) -> 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 { + 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_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_CounterpartyCommitmentSecretsDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_CounterpartyCommitmentSecretsDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_CounterpartyCommitmentSecretsDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + 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_CounterpartyCommitmentSecretsDecodeErrorZPtr { + 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` +/// 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) } #[repr(C)] /// The contents of CResult_SecretKeyErrorZ pub union CResult_SecretKeyErrorZPtr { @@ -2148,41 +2332,41 @@ 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_PayeeDecodeErrorZ -pub union CResult_PayeeDecodeErrorZPtr { +/// 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::Payee, + 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, } #[repr(C)] -/// A CResult_PayeeDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::routing::router::Payee on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// 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_PayeeDecodeErrorZ { - /// The contents of this CResult_PayeeDecodeErrorZ, accessible via either +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_PayeeDecodeErrorZPtr, - /// Whether this CResult_PayeeDecodeErrorZ represents a success state. + pub contents: CResult_PaymentParametersDecodeErrorZPtr, + /// Whether this CResult_PaymentParametersDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_PayeeDecodeErrorZ in the success state. -pub extern "C" fn CResult_PayeeDecodeErrorZ_ok(o: crate::lightning::routing::router::Payee) -> CResult_PayeeDecodeErrorZ { - CResult_PayeeDecodeErrorZ { - contents: CResult_PayeeDecodeErrorZPtr { +/// 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, } } #[no_mangle] -/// Creates a new CResult_PayeeDecodeErrorZ in the error state. -pub extern "C" fn CResult_PayeeDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_PayeeDecodeErrorZ { - CResult_PayeeDecodeErrorZ { - contents: CResult_PayeeDecodeErrorZPtr { +/// 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, @@ -2190,13 +2374,13 @@ pub extern "C" fn CResult_PayeeDecodeErrorZ_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_PayeeDecodeErrorZ_is_ok(o: &CResult_PayeeDecodeErrorZ) -> bool { +pub extern "C" fn CResult_PaymentParametersDecodeErrorZ_is_ok(o: &CResult_PaymentParametersDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_PayeeDecodeErrorZ. -pub extern "C" fn CResult_PayeeDecodeErrorZ_free(_res: CResult_PayeeDecodeErrorZ) { } -impl Drop for CResult_PayeeDecodeErrorZ { +/// 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() } { @@ -2209,16 +2393,16 @@ impl Drop for CResult_PayeeDecodeErrorZ { } } } -impl From> for CResult_PayeeDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +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_PayeeDecodeErrorZPtr { result } + CResult_PaymentParametersDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_PayeeDecodeErrorZPtr { err } + CResult_PaymentParametersDecodeErrorZPtr { err } }; Self { contents, @@ -2226,23 +2410,23 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_PayeeDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + 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_PayeeDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_PaymentParametersDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_PayeeDecodeErrorZ which has the same data as `orig` +/// 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_PayeeDecodeErrorZ_clone(orig: &CResult_PayeeDecodeErrorZ) -> CResult_PayeeDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_PaymentParametersDecodeErrorZ_clone(orig: &CResult_PaymentParametersDecodeErrorZ) -> CResult_PaymentParametersDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] /// A dynamically-allocated array of crate::lightning::routing::router::RouteHintHops of arbitrary size. /// This corresponds to std::vector in C++ @@ -3424,6 +3608,85 @@ impl Clone for CVec_MessageSendEventZ { } } #[repr(C)] +/// The contents of CResult_FixedPenaltyScorerDecodeErrorZ +pub union CResult_FixedPenaltyScorerDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::routing::scoring::FixedPenaltyScorer, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_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] +/// 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] +pub extern "C" fn CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(o: &CResult_FixedPenaltyScorerDecodeErrorZ) -> 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 { + 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, + } + } +} +#[repr(C)] /// The contents of CResult_ScoringParametersDecodeErrorZ pub union CResult_ScoringParametersDecodeErrorZPtr { /// A pointer to the contents in the success state. @@ -3582,41 +3845,41 @@ impl From CResult_InitFeaturesDecodeErrorZ { - CResult_InitFeaturesDecodeErrorZ { - contents: CResult_InitFeaturesDecodeErrorZPtr { +/// Creates a new CResult_ProbabilisticScoringParametersDecodeErrorZ in the success state. +pub extern "C" fn CResult_ProbabilisticScoringParametersDecodeErrorZ_ok(o: crate::lightning::routing::scoring::ProbabilisticScoringParameters) -> CResult_ProbabilisticScoringParametersDecodeErrorZ { + CResult_ProbabilisticScoringParametersDecodeErrorZ { + contents: CResult_ProbabilisticScoringParametersDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_InitFeaturesDecodeErrorZ in the error state. -pub extern "C" fn CResult_InitFeaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_InitFeaturesDecodeErrorZ { - CResult_InitFeaturesDecodeErrorZ { - contents: CResult_InitFeaturesDecodeErrorZPtr { +/// Creates a new CResult_ProbabilisticScoringParametersDecodeErrorZ in the error state. +pub extern "C" fn CResult_ProbabilisticScoringParametersDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ProbabilisticScoringParametersDecodeErrorZ { + CResult_ProbabilisticScoringParametersDecodeErrorZ { + contents: CResult_ProbabilisticScoringParametersDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -3624,13 +3887,13 @@ pub extern "C" fn CResult_InitFeaturesDecodeErrorZ_err(e: crate::lightning::ln:: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_InitFeaturesDecodeErrorZ_is_ok(o: &CResult_InitFeaturesDecodeErrorZ) -> bool { +pub extern "C" fn CResult_ProbabilisticScoringParametersDecodeErrorZ_is_ok(o: &CResult_ProbabilisticScoringParametersDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_InitFeaturesDecodeErrorZ. -pub extern "C" fn CResult_InitFeaturesDecodeErrorZ_free(_res: CResult_InitFeaturesDecodeErrorZ) { } -impl Drop for CResult_InitFeaturesDecodeErrorZ { +/// Frees any resources used by the CResult_ProbabilisticScoringParametersDecodeErrorZ. +pub extern "C" fn CResult_ProbabilisticScoringParametersDecodeErrorZ_free(_res: CResult_ProbabilisticScoringParametersDecodeErrorZ) { } +impl Drop for CResult_ProbabilisticScoringParametersDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -3643,16 +3906,16 @@ impl Drop for CResult_InitFeaturesDecodeErrorZ { } } } -impl From> for CResult_InitFeaturesDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ProbabilisticScoringParametersDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_InitFeaturesDecodeErrorZPtr { result } + CResult_ProbabilisticScoringParametersDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_InitFeaturesDecodeErrorZPtr { err } + CResult_ProbabilisticScoringParametersDecodeErrorZPtr { err } }; Self { contents, @@ -3660,23 +3923,119 @@ impl From Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_ProbabilisticScoringParametersDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_ProbabilisticScoringParametersDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_ProbabilisticScoringParametersDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_ProbabilisticScoringParametersDecodeErrorZ_clone(orig: &CResult_ProbabilisticScoringParametersDecodeErrorZ) -> CResult_ProbabilisticScoringParametersDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_ChannelFeaturesDecodeErrorZ -pub union CResult_ChannelFeaturesDecodeErrorZPtr { +/// 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::ChannelFeatures, + 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_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_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_ChannelFeaturesDecodeErrorZ { - /// The contents of this CResult_ChannelFeaturesDecodeErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. +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] +/// 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_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, + } +} +/// 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 +} +#[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 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 } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +#[repr(C)] +/// The contents of CResult_ChannelFeaturesDecodeErrorZ +pub union CResult_ChannelFeaturesDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::features::ChannelFeatures, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_ChannelFeaturesDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::features::ChannelFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_ChannelFeaturesDecodeErrorZ { + /// The contents of this CResult_ChannelFeaturesDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. pub contents: CResult_ChannelFeaturesDecodeErrorZPtr, /// Whether this CResult_ChannelFeaturesDecodeErrorZ represents a success state. pub result_ok: bool, @@ -4265,93 +4624,51 @@ impl Clone for CResult_SpendableOutputDescriptorDecodeErrorZ { /// 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) } #[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, -} -#[repr(C)] -/// A CResult_NoneNoneZ represents the result of a fallible operation, -/// containing a () on success and a () on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_NoneNoneZ { - /// The contents of this CResult_NoneNoneZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_NoneNoneZPtr, - /// Whether this CResult_NoneNoneZ represents a success state. - pub result_ok: bool, +/// 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 } -#[no_mangle] -/// Creates a new CResult_NoneNoneZ in the success state. -pub extern "C" fn CResult_NoneNoneZ_ok() -> CResult_NoneNoneZ { - CResult_NoneNoneZ { - contents: CResult_NoneNoneZPtr { - result: core::ptr::null_mut(), - }, - result_ok: true, +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 } -} -#[no_mangle] -/// Creates a new CResult_NoneNoneZ in the error state. -pub extern "C" fn CResult_NoneNoneZ_err() -> CResult_NoneNoneZ { - CResult_NoneNoneZ { - contents: CResult_NoneNoneZPtr { - err: core::ptr::null_mut(), - }, - result_ok: false, + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::ThirtyTwoBytes] { + 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_NoneNoneZ_is_ok(o: &CResult_NoneNoneZ) -> bool { - o.result_ok +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] -/// Frees any resources used by the CResult_NoneNoneZ. -pub extern "C" fn CResult_NoneNoneZ_free(_res: CResult_NoneNoneZ) { } -impl Drop for CResult_NoneNoneZ { +/// 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.result_ok { - } else { - } - } -} -impl From> for CResult_NoneNoneZ { - fn from(mut o: crate::c_types::CResultTempl<(), ()>) -> Self { - let contents = if o.result_ok { - let _ = unsafe { Box::from_raw(o.contents.result) }; - o.contents.result = core::ptr::null_mut(); - CResult_NoneNoneZPtr { result: core::ptr::null_mut() } - } else { - let _ = unsafe { Box::from_raw(o.contents.err) }; - o.contents.err = core::ptr::null_mut(); - CResult_NoneNoneZPtr { err: core::ptr::null_mut() } - }; - Self { - contents, - result_ok: o.result_ok, - } + if self.datalen == 0 { return; } + unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl Clone for CResult_NoneNoneZ { +impl Clone for CVec_PaymentPreimageZ { fn clone(&self) -> Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_NoneNoneZPtr { - result: core::ptr::null_mut() - } } - } else { - Self { result_ok: false, contents: CResult_NoneNoneZPtr { - err: core::ptr::null_mut() - } } - } + 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_NoneNoneZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_NoneNoneZ_clone(orig: &CResult_NoneNoneZ) -> CResult_NoneNoneZ { Clone::clone(&orig) } #[repr(C)] /// A tuple of 2 elements. See the individual fields for the types contained. pub struct C2Tuple_SignatureCVec_SignatureZZ { @@ -4579,77 +4896,115 @@ impl Clone for CResult_SignatureNoneZ { /// 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) } #[repr(C)] -/// The contents of CResult_SignDecodeErrorZ -pub union CResult_SignDecodeErrorZPtr { +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_SignatureSignatureZ { + /// The element at position 0 + pub a: crate::c_types::Signature, + /// The element at position 1 + pub b: crate::c_types::Signature, +} +impl From<(crate::c_types::Signature, crate::c_types::Signature)> for C2Tuple_SignatureSignatureZ { + fn from (tup: (crate::c_types::Signature, crate::c_types::Signature)) -> Self { + Self { + a: tup.0, + b: tup.1, + } + } +} +impl C2Tuple_SignatureSignatureZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::Signature, crate::c_types::Signature) { + (self.a, self.b) + } +} +impl Clone for C2Tuple_SignatureSignatureZ { + 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_SignatureSignatureZ_clone(orig: &C2Tuple_SignatureSignatureZ) -> C2Tuple_SignatureSignatureZ { Clone::clone(&orig) } +/// Creates a new C2Tuple_SignatureSignatureZ from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_SignatureSignatureZ_new(a: crate::c_types::Signature, b: crate::c_types::Signature) -> C2Tuple_SignatureSignatureZ { + C2Tuple_SignatureSignatureZ { a, b, } +} + +#[no_mangle] +/// Frees any resources used by the C2Tuple_SignatureSignatureZ. +pub extern "C" fn C2Tuple_SignatureSignatureZ_free(_res: C2Tuple_SignatureSignatureZ) { } +#[repr(C)] +/// The contents of CResult_C2Tuple_SignatureSignatureZNoneZ +pub union CResult_C2Tuple_SignatureSignatureZNoneZPtr { /// A pointer 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::Sign, - /// A pointer to the 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_SignatureSignatureZ, + /// 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_SignDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::chain::keysinterface::Sign on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_C2Tuple_SignatureSignatureZNoneZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::C2Tuple_SignatureSignatureZ on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_SignDecodeErrorZ { - /// The contents of this CResult_SignDecodeErrorZ, accessible via either +pub struct CResult_C2Tuple_SignatureSignatureZNoneZ { + /// The contents of this CResult_C2Tuple_SignatureSignatureZNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_SignDecodeErrorZPtr, - /// Whether this CResult_SignDecodeErrorZ represents a success state. + pub contents: CResult_C2Tuple_SignatureSignatureZNoneZPtr, + /// Whether this CResult_C2Tuple_SignatureSignatureZNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_SignDecodeErrorZ in the success state. -pub extern "C" fn CResult_SignDecodeErrorZ_ok(o: crate::lightning::chain::keysinterface::Sign) -> CResult_SignDecodeErrorZ { - CResult_SignDecodeErrorZ { - contents: CResult_SignDecodeErrorZPtr { +/// Creates a new CResult_C2Tuple_SignatureSignatureZNoneZ in the success state. +pub extern "C" fn CResult_C2Tuple_SignatureSignatureZNoneZ_ok(o: crate::c_types::derived::C2Tuple_SignatureSignatureZ) -> CResult_C2Tuple_SignatureSignatureZNoneZ { + CResult_C2Tuple_SignatureSignatureZNoneZ { + contents: CResult_C2Tuple_SignatureSignatureZNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_SignDecodeErrorZ in the error state. -pub extern "C" fn CResult_SignDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_SignDecodeErrorZ { - CResult_SignDecodeErrorZ { - contents: CResult_SignDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), +/// Creates a new CResult_C2Tuple_SignatureSignatureZNoneZ in the error state. +pub extern "C" fn CResult_C2Tuple_SignatureSignatureZNoneZ_err() -> CResult_C2Tuple_SignatureSignatureZNoneZ { + CResult_C2Tuple_SignatureSignatureZNoneZ { + contents: CResult_C2Tuple_SignatureSignatureZNoneZPtr { + 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_SignDecodeErrorZ_is_ok(o: &CResult_SignDecodeErrorZ) -> bool { +pub extern "C" fn CResult_C2Tuple_SignatureSignatureZNoneZ_is_ok(o: &CResult_C2Tuple_SignatureSignatureZNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_SignDecodeErrorZ. -pub extern "C" fn CResult_SignDecodeErrorZ_free(_res: CResult_SignDecodeErrorZ) { } -impl Drop for CResult_SignDecodeErrorZ { +/// Frees any resources used by the CResult_C2Tuple_SignatureSignatureZNoneZ. +pub extern "C" fn CResult_C2Tuple_SignatureSignatureZNoneZ_free(_res: CResult_C2Tuple_SignatureSignatureZNoneZ) { } +impl Drop for CResult_C2Tuple_SignatureSignatureZNoneZ { 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_SignDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_C2Tuple_SignatureSignatureZNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_SignDecodeErrorZPtr { result } + CResult_C2Tuple_SignatureSignatureZNoneZPtr { result } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_SignDecodeErrorZPtr { err } + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_C2Tuple_SignatureSignatureZNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -4657,14 +5012,185 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_SignDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_C2Tuple_SignatureSignatureZNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_SignDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_C2Tuple_SignatureSignatureZNoneZPtr { + err: core::ptr::null_mut() + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_C2Tuple_SignatureSignatureZNoneZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_C2Tuple_SignatureSignatureZNoneZ_clone(orig: &CResult_C2Tuple_SignatureSignatureZNoneZ) -> CResult_C2Tuple_SignatureSignatureZNoneZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_SecretKeyNoneZ +pub union CResult_SecretKeyNoneZPtr { + /// A 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::SecretKey, + /// 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_SecretKeyNoneZ represents the result of a fallible operation, +/// containing a crate::c_types::SecretKey on success and a () on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_SecretKeyNoneZ { + /// The contents of this CResult_SecretKeyNoneZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_SecretKeyNoneZPtr, + /// Whether this CResult_SecretKeyNoneZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_SecretKeyNoneZ in the success state. +pub extern "C" fn CResult_SecretKeyNoneZ_ok(o: crate::c_types::SecretKey) -> CResult_SecretKeyNoneZ { + CResult_SecretKeyNoneZ { + contents: CResult_SecretKeyNoneZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_SecretKeyNoneZ in the error state. +pub extern "C" fn CResult_SecretKeyNoneZ_err() -> CResult_SecretKeyNoneZ { + CResult_SecretKeyNoneZ { + contents: CResult_SecretKeyNoneZPtr { + 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_SecretKeyNoneZ_is_ok(o: &CResult_SecretKeyNoneZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_SecretKeyNoneZ. +pub extern "C" fn CResult_SecretKeyNoneZ_free(_res: CResult_SecretKeyNoneZ) { } +impl Drop for CResult_SecretKeyNoneZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + } + } +} +impl From> for CResult_SecretKeyNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_SecretKeyNoneZPtr { result } + } else { + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_SecretKeyNoneZPtr { err: core::ptr::null_mut() } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +#[repr(C)] +/// The contents of CResult_SignDecodeErrorZ +pub union CResult_SignDecodeErrorZPtr { + /// A pointer 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::Sign, + /// A pointer to the 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_SignDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::chain::keysinterface::Sign on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_SignDecodeErrorZ { + /// The contents of this CResult_SignDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_SignDecodeErrorZPtr, + /// Whether this CResult_SignDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_SignDecodeErrorZ in the success state. +pub extern "C" fn CResult_SignDecodeErrorZ_ok(o: crate::lightning::chain::keysinterface::Sign) -> CResult_SignDecodeErrorZ { + CResult_SignDecodeErrorZ { + contents: CResult_SignDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_SignDecodeErrorZ in the error state. +pub extern "C" fn CResult_SignDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_SignDecodeErrorZ { + CResult_SignDecodeErrorZ { + contents: CResult_SignDecodeErrorZPtr { + 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_SignDecodeErrorZ_is_ok(o: &CResult_SignDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_SignDecodeErrorZ. +pub extern "C" fn CResult_SignDecodeErrorZ_free(_res: CResult_SignDecodeErrorZ) { } +impl Drop for CResult_SignDecodeErrorZ { + 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_SignDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_SignDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_SignDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_SignDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_SignDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_SignDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } @@ -4675,29 +5201,29 @@ impl Clone for CResult_SignDecodeErrorZ { /// but with all dynamically-allocated buffers duplicated in new buffers. pub extern "C" fn CResult_SignDecodeErrorZ_clone(orig: &CResult_SignDecodeErrorZ) -> CResult_SignDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// A dynamically-allocated array of u8s of arbitrary size. +/// A dynamically-allocated array of crate::c_types::u5s of arbitrary size. /// This corresponds to std::vector in C++ -pub struct CVec_u8Z { +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 u8, + pub data: *mut crate::c_types::u5, /// The number of elements pointed to by `data`. pub datalen: usize } -impl CVec_u8Z { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { +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) -> &[u8] { + #[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_u8Z { - fn from(v: Vec) -> Self { +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() } } @@ -4705,14 +5231,14 @@ impl From> for CVec_u8Z { } #[no_mangle] /// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_u8Z_free(_res: CVec_u8Z) { } -impl Drop for CVec_u8Z { +pub extern "C" fn CVec_u5Z_free(_res: CVec_u5Z) { } +impl Drop for CVec_u5Z { fn drop(&mut self) { if self.datalen == 0 { return; } unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl Clone for CVec_u8Z { +impl Clone for CVec_u5Z { fn clone(&self) -> Self { let mut res = Vec::new(); if self.datalen == 0 { return Self::from(res); } @@ -4813,6 +5339,52 @@ impl Clone for CResult_RecoverableSignatureNoneZ { /// 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)] +/// A dynamically-allocated array of u8s of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_u8Z { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut u8, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_u8Z { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[u8] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_u8Z { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_u8Z_free(_res: CVec_u8Z) { } +impl Drop for CVec_u8Z { + fn drop(&mut self) { + if self.datalen == 0 { return; } + unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_u8Z { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] /// A dynamically-allocated array of crate::c_types::derived::CVec_u8Zs of arbitrary size. /// This corresponds to std::vector in C++ pub struct CVec_CVec_u8ZZ { @@ -6308,16 +6880,400 @@ impl Drop for CResult_PaymentSecretNoneZ { } } } -impl From> for CResult_PaymentSecretNoneZ { - 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_PaymentSecretNoneZPtr { result } + } else { + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_PaymentSecretNoneZPtr { err: core::ptr::null_mut() } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_PaymentSecretNoneZ { + 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 }))) + } } + } else { + Self { result_ok: false, contents: CResult_PaymentSecretNoneZPtr { + err: core::ptr::null_mut() + } } + } + } +} +#[no_mangle] +/// 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_PaymentSecretNoneZ_clone(orig: &CResult_PaymentSecretNoneZ) -> CResult_PaymentSecretNoneZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_PaymentSecretAPIErrorZ +pub union CResult_PaymentSecretAPIErrorZPtr { + /// A 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::util::errors::APIError, +} +#[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. +/// `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 + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_PaymentSecretAPIErrorZPtr, + /// Whether this CResult_PaymentSecretAPIErrorZ 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 { + 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 { + 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_PaymentSecretAPIErrorZ_is_ok(o: &CResult_PaymentSecretAPIErrorZ) -> 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 { + 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_PaymentSecretAPIErrorZ { + fn from(mut o: crate::c_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 } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_PaymentSecretAPIErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_PaymentSecretAPIErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_PaymentSecretAPIErrorZPtr { + 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 }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_PaymentSecretAPIErrorZ 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) } +#[repr(C)] +/// 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::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_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_PaymentPreimageAPIErrorZ { + /// The contents of this CResult_PaymentPreimageAPIErrorZ, 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 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 { + 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 { + 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_PaymentPreimageAPIErrorZ_is_ok(o: &CResult_PaymentPreimageAPIErrorZ) -> 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 { + 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_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_PaymentPreimageAPIErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_PaymentPreimageAPIErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_PaymentPreimageAPIErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + 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_PaymentPreimageAPIErrorZPtr { + 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` +/// 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) } +#[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, +} +#[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, +} +#[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, + } +} +#[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, + } +} +/// 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 +} +#[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) }; + } + } + } +} +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 } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +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] +/// 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 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, +} +#[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, +} +#[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, + } +} +#[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, + } +} +/// 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 +} +#[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 { + 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_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_PaymentSecretNoneZPtr { result } + CResult_ChannelCounterpartyDecodeErrorZPtr { 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_ChannelCounterpartyDecodeErrorZPtr { err } }; Self { contents, @@ -6325,59 +7281,59 @@ impl From> for } } } -impl Clone for CResult_PaymentSecretNoneZ { +impl Clone for CResult_ChannelCounterpartyDecodeErrorZ { 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_ChannelCounterpartyDecodeErrorZPtr { + 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_ChannelCounterpartyDecodeErrorZPtr { + 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_ChannelCounterpartyDecodeErrorZ 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_ChannelCounterpartyDecodeErrorZ_clone(orig: &CResult_ChannelCounterpartyDecodeErrorZ) -> CResult_ChannelCounterpartyDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_PaymentSecretAPIErrorZ -pub union CResult_PaymentSecretAPIErrorZPtr { +/// 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::c_types::ThirtyTwoBytes, + 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::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_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_PaymentSecretAPIErrorZ { - /// The contents of this CResult_PaymentSecretAPIErrorZ, 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_PaymentSecretAPIErrorZPtr, - /// Whether this CResult_PaymentSecretAPIErrorZ 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_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_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_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_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, @@ -6385,13 +7341,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_ChannelDetailsDecodeErrorZ_is_ok(o: &CResult_ChannelDetailsDecodeErrorZ) -> 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_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() } { @@ -6404,16 +7360,16 @@ impl Drop for CResult_PaymentSecretAPIErrorZ { } } } -impl From> for CResult_PaymentSecretAPIErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +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_PaymentSecretAPIErrorZPtr { result } + CResult_ChannelDetailsDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_PaymentSecretAPIErrorZPtr { err } + CResult_ChannelDetailsDecodeErrorZPtr { err } }; Self { contents, @@ -6421,59 +7377,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_ChannelDetailsDecodeErrorZPtr { + 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_ChannelDetailsDecodeErrorZPtr { + 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_ChannelDetailsDecodeErrorZ 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_ChannelDetailsDecodeErrorZ_clone(orig: &CResult_ChannelDetailsDecodeErrorZ) -> CResult_ChannelDetailsDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_PaymentPreimageAPIErrorZ -pub union CResult_PaymentPreimageAPIErrorZPtr { +/// 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::c_types::ThirtyTwoBytes, + 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::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_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_PaymentPreimageAPIErrorZ { - /// The contents of this CResult_PaymentPreimageAPIErrorZ, 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_PaymentPreimageAPIErrorZPtr, - /// Whether this CResult_PaymentPreimageAPIErrorZ 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_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_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_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_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, @@ -6481,13 +7437,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_PhantomRouteHintsDecodeErrorZ_is_ok(o: &CResult_PhantomRouteHintsDecodeErrorZ) -> 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_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() } { @@ -6500,16 +7456,16 @@ impl Drop for CResult_PaymentPreimageAPIErrorZ { } } } -impl From> for CResult_PaymentPreimageAPIErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +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_PaymentPreimageAPIErrorZPtr { result } + CResult_PhantomRouteHintsDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_PaymentPreimageAPIErrorZPtr { err } + CResult_PhantomRouteHintsDecodeErrorZPtr { err } }; Self { contents, @@ -6517,23 +7473,6 @@ 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 }))) - } } - } else { - Self { result_ok: false, contents: CResult_PaymentPreimageAPIErrorZPtr { - 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` -/// 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) } #[repr(C)] /// A dynamically-allocated array of crate::lightning::chain::channelmonitor::ChannelMonitors of arbitrary size. /// This corresponds to std::vector in C++ @@ -7925,102 +8864,6 @@ impl Clone for CResult_DescriptionCreationErrorZ { /// 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) } #[repr(C)] -/// The contents of CResult_ExpiryTimeCreationErrorZ -pub union CResult_ExpiryTimeCreationErrorZPtr { - /// A pointer 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::ExpiryTime, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning_invoice::CreationError, -} -#[repr(C)] -/// A CResult_ExpiryTimeCreationErrorZ represents the result of a fallible operation, -/// containing a crate::lightning_invoice::ExpiryTime 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_ExpiryTimeCreationErrorZ { - /// The contents of this CResult_ExpiryTimeCreationErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ExpiryTimeCreationErrorZPtr, - /// Whether this CResult_ExpiryTimeCreationErrorZ represents a success state. - pub result_ok: bool, -} -#[no_mangle] -/// Creates a new CResult_ExpiryTimeCreationErrorZ in the success state. -pub extern "C" fn CResult_ExpiryTimeCreationErrorZ_ok(o: crate::lightning_invoice::ExpiryTime) -> CResult_ExpiryTimeCreationErrorZ { - CResult_ExpiryTimeCreationErrorZ { - contents: CResult_ExpiryTimeCreationErrorZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, - } -} -#[no_mangle] -/// Creates a new CResult_ExpiryTimeCreationErrorZ in the error state. -pub extern "C" fn CResult_ExpiryTimeCreationErrorZ_err(e: crate::lightning_invoice::CreationError) -> CResult_ExpiryTimeCreationErrorZ { - CResult_ExpiryTimeCreationErrorZ { - contents: CResult_ExpiryTimeCreationErrorZPtr { - 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_ExpiryTimeCreationErrorZ_is_ok(o: &CResult_ExpiryTimeCreationErrorZ) -> bool { - o.result_ok -} -#[no_mangle] -/// Frees any resources used by the CResult_ExpiryTimeCreationErrorZ. -pub extern "C" fn CResult_ExpiryTimeCreationErrorZ_free(_res: CResult_ExpiryTimeCreationErrorZ) { } -impl Drop for CResult_ExpiryTimeCreationErrorZ { - 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_ExpiryTimeCreationErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { - let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ExpiryTimeCreationErrorZPtr { result } - } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ExpiryTimeCreationErrorZPtr { err } - }; - Self { - contents, - result_ok: o.result_ok, - } - } -} -impl Clone for CResult_ExpiryTimeCreationErrorZ { - fn clone(&self) -> Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_ExpiryTimeCreationErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_ExpiryTimeCreationErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } - } - } -} -#[no_mangle] -/// Creates a new CResult_ExpiryTimeCreationErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ExpiryTimeCreationErrorZ_clone(orig: &CResult_ExpiryTimeCreationErrorZ) -> CResult_ExpiryTimeCreationErrorZ { Clone::clone(&orig) } -#[repr(C)] /// The contents of CResult_PrivateRouteCreationErrorZ pub union CResult_PrivateRouteCreationErrorZPtr { /// A pointer to the contents in the success state. @@ -10080,41 +10923,41 @@ pub extern "C" fn COption_AccessZ_none() -> COption_AccessZ { /// Frees any resources associated with the crate::lightning::chain::Access, if we are in the Some state pub extern "C" fn COption_AccessZ_free(_res: COption_AccessZ) { } #[repr(C)] -/// The contents of CResult_DirectionalChannelInfoDecodeErrorZ -pub union CResult_DirectionalChannelInfoDecodeErrorZPtr { +/// The contents of CResult_ChannelUpdateInfoDecodeErrorZ +pub union CResult_ChannelUpdateInfoDecodeErrorZPtr { /// A pointer 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::network_graph::DirectionalChannelInfo, + pub result: *mut crate::lightning::routing::network_graph::ChannelUpdateInfo, /// A pointer to the 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_DirectionalChannelInfoDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::routing::network_graph::DirectionalChannelInfo on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_ChannelUpdateInfoDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::routing::network_graph::ChannelUpdateInfo on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_DirectionalChannelInfoDecodeErrorZ { - /// The contents of this CResult_DirectionalChannelInfoDecodeErrorZ, accessible via either +pub struct CResult_ChannelUpdateInfoDecodeErrorZ { + /// The contents of this CResult_ChannelUpdateInfoDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_DirectionalChannelInfoDecodeErrorZPtr, - /// Whether this CResult_DirectionalChannelInfoDecodeErrorZ represents a success state. + pub contents: CResult_ChannelUpdateInfoDecodeErrorZPtr, + /// Whether this CResult_ChannelUpdateInfoDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_DirectionalChannelInfoDecodeErrorZ in the success state. -pub extern "C" fn CResult_DirectionalChannelInfoDecodeErrorZ_ok(o: crate::lightning::routing::network_graph::DirectionalChannelInfo) -> CResult_DirectionalChannelInfoDecodeErrorZ { - CResult_DirectionalChannelInfoDecodeErrorZ { - contents: CResult_DirectionalChannelInfoDecodeErrorZPtr { +/// Creates a new CResult_ChannelUpdateInfoDecodeErrorZ in the success state. +pub extern "C" fn CResult_ChannelUpdateInfoDecodeErrorZ_ok(o: crate::lightning::routing::network_graph::ChannelUpdateInfo) -> CResult_ChannelUpdateInfoDecodeErrorZ { + CResult_ChannelUpdateInfoDecodeErrorZ { + contents: CResult_ChannelUpdateInfoDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_DirectionalChannelInfoDecodeErrorZ in the error state. -pub extern "C" fn CResult_DirectionalChannelInfoDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_DirectionalChannelInfoDecodeErrorZ { - CResult_DirectionalChannelInfoDecodeErrorZ { - contents: CResult_DirectionalChannelInfoDecodeErrorZPtr { +/// Creates a new CResult_ChannelUpdateInfoDecodeErrorZ in the error state. +pub extern "C" fn CResult_ChannelUpdateInfoDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelUpdateInfoDecodeErrorZ { + CResult_ChannelUpdateInfoDecodeErrorZ { + contents: CResult_ChannelUpdateInfoDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -10122,13 +10965,13 @@ pub extern "C" fn CResult_DirectionalChannelInfoDecodeErrorZ_err(e: crate::light } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_DirectionalChannelInfoDecodeErrorZ_is_ok(o: &CResult_DirectionalChannelInfoDecodeErrorZ) -> bool { +pub extern "C" fn CResult_ChannelUpdateInfoDecodeErrorZ_is_ok(o: &CResult_ChannelUpdateInfoDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_DirectionalChannelInfoDecodeErrorZ. -pub extern "C" fn CResult_DirectionalChannelInfoDecodeErrorZ_free(_res: CResult_DirectionalChannelInfoDecodeErrorZ) { } -impl Drop for CResult_DirectionalChannelInfoDecodeErrorZ { +/// Frees any resources used by the CResult_ChannelUpdateInfoDecodeErrorZ. +pub extern "C" fn CResult_ChannelUpdateInfoDecodeErrorZ_free(_res: CResult_ChannelUpdateInfoDecodeErrorZ) { } +impl Drop for CResult_ChannelUpdateInfoDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -10141,16 +10984,16 @@ impl Drop for CResult_DirectionalChannelInfoDecodeErrorZ { } } } -impl From> for CResult_DirectionalChannelInfoDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ChannelUpdateInfoDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_DirectionalChannelInfoDecodeErrorZPtr { result } + CResult_ChannelUpdateInfoDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_DirectionalChannelInfoDecodeErrorZPtr { err } + CResult_ChannelUpdateInfoDecodeErrorZPtr { err } }; Self { contents, @@ -10158,23 +11001,23 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_DirectionalChannelInfoDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_ChannelUpdateInfoDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_DirectionalChannelInfoDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_ChannelUpdateInfoDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_DirectionalChannelInfoDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_ChannelUpdateInfoDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_DirectionalChannelInfoDecodeErrorZ_clone(orig: &CResult_DirectionalChannelInfoDecodeErrorZ) -> CResult_DirectionalChannelInfoDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_ChannelUpdateInfoDecodeErrorZ_clone(orig: &CResult_ChannelUpdateInfoDecodeErrorZ) -> CResult_ChannelUpdateInfoDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] /// The contents of CResult_ChannelInfoDecodeErrorZ pub union CResult_ChannelInfoDecodeErrorZPtr { @@ -13419,6 +14262,102 @@ impl Clone for CResult_ErrorMessageDecodeErrorZ { /// 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_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, + /// A pointer to the 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_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_WarningMessageDecodeErrorZ { + /// The contents of this CResult_WarningMessageDecodeErrorZ, 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 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)), + }, + 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 { + 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_WarningMessageDecodeErrorZ_is_ok(o: &CResult_WarningMessageDecodeErrorZ) -> 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 { + 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_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_WarningMessageDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_WarningMessageDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +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] +/// 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 CResult_WarningMessageDecodeErrorZ_clone(orig: &CResult_WarningMessageDecodeErrorZ) -> CResult_WarningMessageDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] /// The contents of CResult_UnsignedNodeAnnouncementDecodeErrorZ pub union CResult_UnsignedNodeAnnouncementDecodeErrorZPtr { /// A pointer to the contents in the success state. @@ -14091,6 +15030,44 @@ impl Clone for CResult_GossipTimestampFilterDecodeErrorZ { /// but with all dynamically-allocated buffers duplicated in new buffers. pub extern "C" fn CResult_GossipTimestampFilterDecodeErrorZ_clone(orig: &CResult_GossipTimestampFilterDecodeErrorZ) -> CResult_GossipTimestampFilterDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] +/// A dynamically-allocated array of crate::lightning::ln::channelmanager::PhantomRouteHintss of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_PhantomRouteHintsZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::ln::channelmanager::PhantomRouteHints, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +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; } + unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +#[repr(C)] /// The contents of CResult_InvoiceSignOrCreationErrorZ pub union CResult_InvoiceSignOrCreationErrorZPtr { /// A pointer to the contents in the success state. diff --git a/lightning-c-bindings/src/lightning/chain/keysinterface.rs b/lightning-c-bindings/src/lightning/chain/keysinterface.rs index 9ee852b..bb0b207 100644 --- a/lightning-c-bindings/src/lightning/chain/keysinterface.rs +++ b/lightning-c-bindings/src/lightning/chain/keysinterface.rs @@ -572,8 +572,15 @@ pub struct BaseSign { /// 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: 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) -> crate::c_types::derived::CResult_NoneNoneZ, + 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, /// Gets the holder's channel public keys and basepoints pub pubkeys: crate::lightning::ln::chan_utils::ChannelPublicKeys, /// Fill in the pubkeys field as a reference to it will be given to Rust after this returns @@ -591,8 +598,15 @@ pub struct BaseSign { /// /// 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: 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) -> crate::c_types::derived::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ, + 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 @@ -672,14 +686,17 @@ pub struct BaseSign { /// 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, - /// Signs a channel announcement message with our funding key, proving it comes from one - /// of the channel participants. + /// Signs a channel announcement message with our funding key and our node secret key (aka + /// node_id or network_key), proving it comes from one of the channel participants. + /// + /// The first returned signature should be from our node secret key, the second from our + /// funding key. /// /// 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: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::UnsignedChannelAnnouncement) -> crate::c_types::derived::CResult_SignatureNoneZ, + pub sign_channel_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::UnsignedChannelAnnouncement) -> crate::c_types::derived::CResult_C2Tuple_SignatureSignatureZNoneZ, /// Set the counterparty static channel data, including basepoints, /// counterparty_selected/holder_selected_contest_delay and funding outpoint. /// This is done as soon as the funding outpoint is known. Since these are static channel data, @@ -730,8 +747,9 @@ impl rustBaseSign for BaseSign { 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) -> Result<(), ()> { - 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 }); + 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 } @@ -745,8 +763,9 @@ impl rustBaseSign for BaseSign { let mut ret = (self.channel_keys_id)(self.this_arg); ret.data } - fn sign_counterparty_commitment(&self, mut commitment_tx: &lightning::ln::chan_utils::CommitmentTransaction, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result<(bitcoin::secp256k1::Signature, Vec), ()> { - 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 }); + 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::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 } @@ -780,9 +799,9 @@ impl rustBaseSign for BaseSign { 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(&self, mut msg: &lightning::ln::msgs::UnsignedChannelAnnouncement, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { + fn sign_channel_announcement(&self, mut msg: &lightning::ln::msgs::UnsignedChannelAnnouncement, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result<(bitcoin::secp256k1::Signature, bitcoin::secp256k1::Signature), ()> { let mut ret = (self.sign_channel_announcement)(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)) })*/ })}; + 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_ret_0 = (orig_ret_0_0.into_rust(), orig_ret_0_1.into_rust()); local_ret_0 }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; local_ret } fn ready_channel(&mut self, mut channel_parameters: &lightning::ln::chan_utils::ChannelTransactionParameters) { @@ -851,8 +870,9 @@ impl lightning::chain::keysinterface::BaseSign for Sign { let mut ret = (self.BaseSign.release_commitment_secret)(self.BaseSign.this_arg, idx); ret.data } - fn validate_holder_commitment(&self, mut holder_tx: &lightning::ln::chan_utils::HolderCommitmentTransaction) -> Result<(), ()> { - let mut ret = (self.BaseSign.validate_holder_commitment)(self.BaseSign.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 }); + 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.BaseSign.validate_holder_commitment)(self.BaseSign.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 } @@ -866,8 +886,9 @@ impl lightning::chain::keysinterface::BaseSign for Sign { let mut ret = (self.BaseSign.channel_keys_id)(self.BaseSign.this_arg); ret.data } - fn sign_counterparty_commitment(&self, mut commitment_tx: &lightning::ln::chan_utils::CommitmentTransaction, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result<(bitcoin::secp256k1::Signature, Vec), ()> { - let mut ret = (self.BaseSign.sign_counterparty_commitment)(self.BaseSign.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 }); + 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::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.BaseSign.sign_counterparty_commitment)(self.BaseSign.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 } @@ -901,9 +922,9 @@ impl lightning::chain::keysinterface::BaseSign for Sign { 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(&self, mut msg: &lightning::ln::msgs::UnsignedChannelAnnouncement, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { + fn sign_channel_announcement(&self, mut msg: &lightning::ln::msgs::UnsignedChannelAnnouncement, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result<(bitcoin::secp256k1::Signature, bitcoin::secp256k1::Signature), ()> { let mut ret = (self.BaseSign.sign_channel_announcement)(self.BaseSign.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)) })*/ })}; + 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_ret_0 = (orig_ret_0_0.into_rust(), orig_ret_0_1.into_rust()); local_ret_0 }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; local_ret } fn ready_channel(&mut self, mut channel_parameters: &lightning::ln::chan_utils::ChannelTransactionParameters) { @@ -951,17 +972,76 @@ impl Drop for Sign { } } } +/// Specifies the recipient of an invoice, to indicate to [`KeysInterface::sign_invoice`] what node +/// secret key should be used to sign the invoice. +#[must_use] +#[derive(Clone)] +#[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 nativeRecipient; +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 to describe an object which can get user secrets and key material. #[repr(C)] pub struct KeysInterface { /// 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 node secret key (aka node_id or network_key). + /// Get node secret key (aka node_id or network_key) based on the provided [`Recipient`]. /// - /// This method must return the same value each time it is called. + /// This method must return the same value each time it is called with a given `Recipient` + /// parameter. #[must_use] - pub get_node_secret: extern "C" fn (this_arg: *const c_void) -> crate::c_types::SecretKey, + pub get_node_secret: extern "C" fn (this_arg: *const c_void, recipient: crate::lightning::chain::keysinterface::Recipient) -> crate::c_types::derived::CResult_SecretKeyNoneZ, /// 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 @@ -995,15 +1075,24 @@ pub struct KeysInterface { /// you've read all of the provided bytes to ensure no corruption occurred. #[must_use] pub read_chan_signer: extern "C" fn (this_arg: *const c_void, reader: crate::c_types::u8slice) -> crate::c_types::derived::CResult_SignDecodeErrorZ, - /// Sign an invoice's preimage (note that this is the preimage of the invoice, not the HTLC's - /// preimage). By parameterizing by the preimage instead of the hash, we allow implementors of + /// 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 is ascii bytes, while the invoice data is base32. + /// + /// The secret key used to sign the invoice is dependent on the [`Recipient`]. #[must_use] - pub sign_invoice: extern "C" fn (this_arg: *const c_void, invoice_preimage: crate::c_types::derived::CVec_u8Z) -> crate::c_types::derived::CResult_RecoverableSignatureNoneZ, + 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, receipient: crate::lightning::chain::keysinterface::Recipient) -> crate::c_types::derived::CResult_RecoverableSignatureNoneZ, /// 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, /// Frees any resources associated with this object given its this_arg pointer. @@ -1031,9 +1120,10 @@ pub(crate) extern "C" fn KeysInterface_clone_fields(orig: &KeysInterface) -> Key use lightning::chain::keysinterface::KeysInterface as rustKeysInterface; impl rustKeysInterface for KeysInterface { type Signer = crate::lightning::chain::keysinterface::Sign; - fn get_node_secret(&self) -> bitcoin::secp256k1::key::SecretKey { - let mut ret = (self.get_node_secret)(self.this_arg); - ret.into_rust() + fn get_node_secret(&self, mut recipient: lightning::chain::keysinterface::Recipient) -> Result { + let mut ret = (self.get_node_secret)(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 get_destination_script(&self) -> bitcoin::blockdata::script::Script { let mut ret = (self.get_destination_script)(self.this_arg); @@ -1057,9 +1147,10 @@ impl rustKeysInterface for KeysInterface { let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }) }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })}; local_ret } - fn sign_invoice(&self, mut invoice_preimage: Vec) -> Result { - let mut local_invoice_preimage = Vec::new(); for mut item in invoice_preimage.drain(..) { local_invoice_preimage.push( { item }); }; - let mut ret = (self.sign_invoice)(self.this_arg, local_invoice_preimage.into()); + fn sign_invoice(&self, mut hrp_bytes: &[u8], mut invoice_data: &[bitcoin::bech32::u5], mut receipient: 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(receipient)); 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 } @@ -1229,8 +1320,8 @@ pub extern "C" fn InMemorySigner_clone(orig: &InMemorySigner) -> InMemorySigner /// Create a new InMemorySigner #[must_use] #[no_mangle] -pub extern "C" fn InMemorySigner_new(mut funding_key: crate::c_types::SecretKey, mut revocation_base_key: crate::c_types::SecretKey, mut payment_key: crate::c_types::SecretKey, mut delayed_payment_base_key: crate::c_types::SecretKey, mut htlc_base_key: crate::c_types::SecretKey, mut commitment_seed: crate::c_types::ThirtyTwoBytes, mut channel_value_satoshis: u64, mut channel_keys_id: crate::c_types::ThirtyTwoBytes) -> crate::lightning::chain::keysinterface::InMemorySigner { - let mut ret = lightning::chain::keysinterface::InMemorySigner::new(secp256k1::SECP256K1, funding_key.into_rust(), revocation_base_key.into_rust(), payment_key.into_rust(), delayed_payment_base_key.into_rust(), htlc_base_key.into_rust(), commitment_seed.data, channel_value_satoshis, channel_keys_id.data); +pub extern "C" fn InMemorySigner_new(mut node_secret: crate::c_types::SecretKey, mut funding_key: crate::c_types::SecretKey, mut revocation_base_key: crate::c_types::SecretKey, mut payment_key: crate::c_types::SecretKey, mut delayed_payment_base_key: crate::c_types::SecretKey, mut htlc_base_key: crate::c_types::SecretKey, mut commitment_seed: crate::c_types::ThirtyTwoBytes, mut channel_value_satoshis: u64, mut channel_keys_id: crate::c_types::ThirtyTwoBytes) -> crate::lightning::chain::keysinterface::InMemorySigner { + let mut ret = lightning::chain::keysinterface::InMemorySigner::new(secp256k1::SECP256K1, node_secret.into_rust(), 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); crate::lightning::chain::keysinterface::InMemorySigner { inner: ObjOps::heap_alloc(ret), is_owned: true } } @@ -1307,7 +1398,8 @@ pub extern "C" fn InMemorySigner_opt_anchors(this_arg: &InMemorySigner) -> bool /// described by descriptor, returning the witness stack for the input. /// /// Returns an Err if the input at input_idx does not exist, has a non-empty script_sig, -/// or is not spending the outpoint described by `descriptor.outpoint`. +/// is not spending the outpoint described by `descriptor.outpoint`, +/// or if an output descriptor script_pubkey does not match the one we can spend. #[must_use] #[no_mangle] pub extern "C" fn InMemorySigner_sign_counterparty_payment_input(this_arg: &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 { @@ -1320,8 +1412,9 @@ pub extern "C" fn InMemorySigner_sign_counterparty_payment_input(this_arg: &InMe /// described by descriptor, returning the witness stack for the input. /// /// Returns an Err 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 does not have a -/// sequence set to `descriptor.to_self_delay`. +/// 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. #[must_use] #[no_mangle] pub extern "C" fn InMemorySigner_sign_dynamic_p2wsh_input(this_arg: &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 { @@ -1377,8 +1470,9 @@ extern "C" fn InMemorySigner_BaseSign_release_commitment_secret(this_arg: *const crate::c_types::ThirtyTwoBytes { data: ret } } #[must_use] -extern "C" fn InMemorySigner_BaseSign_validate_holder_commitment(this_arg: *const c_void, _holder_tx: &crate::lightning::ln::chan_utils::HolderCommitmentTransaction) -> crate::c_types::derived::CResult_NoneNoneZ { - let mut ret = >::validate_holder_commitment(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, _holder_tx.get_native_ref()); +extern "C" fn InMemorySigner_BaseSign_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 } @@ -1400,8 +1494,9 @@ extern "C" fn InMemorySigner_BaseSign_channel_keys_id(this_arg: *const c_void) - crate::c_types::ThirtyTwoBytes { data: ret } } #[must_use] -extern "C" fn InMemorySigner_BaseSign_sign_counterparty_commitment(this_arg: *const c_void, commitment_tx: &crate::lightning::ln::chan_utils::CommitmentTransaction) -> crate::c_types::derived::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { - let mut ret = >::sign_counterparty_commitment(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, commitment_tx.get_native_ref(), secp256k1::SECP256K1); +extern "C" fn InMemorySigner_BaseSign_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::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 } @@ -1442,9 +1537,9 @@ extern "C" fn InMemorySigner_BaseSign_sign_closing_transaction(this_arg: *const local_ret } #[must_use] -extern "C" fn InMemorySigner_BaseSign_sign_channel_announcement(this_arg: *const c_void, msg: &crate::lightning::ln::msgs::UnsignedChannelAnnouncement) -> crate::c_types::derived::CResult_SignatureNoneZ { +extern "C" fn InMemorySigner_BaseSign_sign_channel_announcement(this_arg: *const c_void, msg: &crate::lightning::ln::msgs::UnsignedChannelAnnouncement) -> crate::c_types::derived::CResult_C2Tuple_SignatureSignatureZNoneZ { let mut ret = >::sign_channel_announcement(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, msg.get_native_ref(), secp256k1::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() }; + 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::Signature::from_rust(&orig_ret_0_0), crate::c_types::Signature::from_rust(&orig_ret_0_1)).into(); local_ret_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; local_ret } extern "C" fn InMemorySigner_BaseSign_ready_channel(this_arg: *mut c_void, channel_parameters: &crate::lightning::ln::chan_utils::ChannelTransactionParameters) { @@ -1511,8 +1606,9 @@ pub(crate) extern "C" fn InMemorySigner_write_void(obj: *const c_void) -> crate: } #[no_mangle] /// Read a InMemorySigner from a byte array, created by InMemorySigner_write -pub extern "C" fn InMemorySigner_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_InMemorySignerDecodeErrorZ { - let res: Result = crate::c_types::deserialize_obj(ser); +pub extern "C" fn InMemorySigner_read(ser: crate::c_types::u8slice, arg: crate::c_types::SecretKey) -> crate::c_types::derived::CResult_InMemorySignerDecodeErrorZ { + let arg_conv = arg.into_rust(); + 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 { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; local_res } @@ -1527,6 +1623,12 @@ pub(crate) type nativeKeysManager = nativeKeysManagerImport; /// ChannelMonitor 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 { @@ -1615,8 +1717,9 @@ pub extern "C" fn KeysManager_derive_channel_keys(this_arg: &KeysManager, mut ch /// 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 or -/// if a descriptor was duplicated. +/// 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. /// @@ -1661,9 +1764,10 @@ pub extern "C" fn KeysManager_as_KeysInterface(this_arg: &KeysManager) -> crate: } #[must_use] -extern "C" fn KeysManager_KeysInterface_get_node_secret(this_arg: *const c_void) -> crate::c_types::SecretKey { - let mut ret = >::get_node_secret(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, ); - crate::c_types::SecretKey::from_rust(ret) +extern "C" fn KeysManager_KeysInterface_get_node_secret(this_arg: *const c_void, mut recipient: crate::lightning::chain::keysinterface::Recipient) -> crate::c_types::derived::CResult_SecretKeyNoneZ { + let mut ret = >::get_node_secret(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::SecretKey::from_rust(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret } #[must_use] extern "C" fn KeysManager_KeysInterface_get_inbound_payment_key_material(this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes { @@ -1697,10 +1801,184 @@ extern "C" fn KeysManager_KeysInterface_read_chan_signer(this_arg: *const c_void local_ret } #[must_use] -extern "C" fn KeysManager_KeysInterface_sign_invoice(this_arg: *const c_void, mut invoice_preimage: crate::c_types::derived::CVec_u8Z) -> crate::c_types::derived::CResult_RecoverableSignatureNoneZ { - let mut local_invoice_preimage = Vec::new(); for mut item in invoice_preimage.into_rust().drain(..) { local_invoice_preimage.push( { item }); }; - let mut ret = >::sign_invoice(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, local_invoice_preimage); +extern "C" fn KeysManager_KeysInterface_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 } + +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) { + unsafe { let _ = 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::KeysInterface { + fn from(obj: nativePhantomKeysManager) -> Self { + let mut rust_obj = PhantomKeysManager { inner: ObjOps::heap_alloc(obj), is_owned: true }; + let mut ret = PhantomKeysManager_as_KeysInterface(&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 KeysInterface which calls the relevant methods on this_arg. +/// This copies the `inner` pointer in this_arg and thus the returned KeysInterface must be freed before this_arg is +#[no_mangle] +pub extern "C" fn PhantomKeysManager_as_KeysInterface(this_arg: &PhantomKeysManager) -> crate::lightning::chain::keysinterface::KeysInterface { + crate::lightning::chain::keysinterface::KeysInterface { + this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, + free: None, + get_node_secret: PhantomKeysManager_KeysInterface_get_node_secret, + get_destination_script: PhantomKeysManager_KeysInterface_get_destination_script, + get_shutdown_scriptpubkey: PhantomKeysManager_KeysInterface_get_shutdown_scriptpubkey, + get_channel_signer: PhantomKeysManager_KeysInterface_get_channel_signer, + get_secure_random_bytes: PhantomKeysManager_KeysInterface_get_secure_random_bytes, + read_chan_signer: PhantomKeysManager_KeysInterface_read_chan_signer, + sign_invoice: PhantomKeysManager_KeysInterface_sign_invoice, + get_inbound_payment_key_material: PhantomKeysManager_KeysInterface_get_inbound_payment_key_material, + } +} + +#[must_use] +extern "C" fn PhantomKeysManager_KeysInterface_get_node_secret(this_arg: *const c_void, mut recipient: crate::lightning::chain::keysinterface::Recipient) -> crate::c_types::derived::CResult_SecretKeyNoneZ { + let mut ret = >::get_node_secret(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::SecretKey::from_rust(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} +#[must_use] +extern "C" fn PhantomKeysManager_KeysInterface_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_KeysInterface_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_KeysInterface_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 } +} +#[must_use] +extern "C" fn PhantomKeysManager_KeysInterface_get_channel_signer(this_arg: *const c_void, mut inbound: bool, mut channel_value_satoshis: u64) -> crate::lightning::chain::keysinterface::Sign { + let mut ret = >::get_channel_signer(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, inbound, channel_value_satoshis); + Into::into(ret) +} +#[must_use] +extern "C" fn PhantomKeysManager_KeysInterface_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 } +} +#[must_use] +extern "C" fn PhantomKeysManager_KeysInterface_read_chan_signer(this_arg: *const c_void, mut reader: crate::c_types::u8slice) -> crate::c_types::derived::CResult_SignDecodeErrorZ { + 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 { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; + local_ret +} +#[must_use] +extern "C" fn PhantomKeysManager_KeysInterface_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 +} + +/// 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]) -> PhantomKeysManager { + let mut ret = lightning::chain::keysinterface::PhantomKeysManager::new(unsafe { &*seed}, starting_time_secs, starting_time_nanos, unsafe { &*cross_node_seed}); + 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: &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::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: &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 } +} + diff --git a/lightning-c-bindings/src/lightning/ln/chan_utils.rs b/lightning-c-bindings/src/lightning/ln/chan_utils.rs index 9874c87..225dfbb 100644 --- a/lightning-c-bindings/src/lightning/ln/chan_utils.rs +++ b/lightning-c-bindings/src/lightning/ln/chan_utils.rs @@ -45,6 +45,135 @@ pub extern "C" fn build_closing_transaction(mut to_holder_value_sat: u64, mut to crate::c_types::Transaction::from_bitcoin(&ret) } + +use lightning::ln::chan_utils::CounterpartyCommitmentSecrets as nativeCounterpartyCommitmentSecretsImport; +pub(crate) type nativeCounterpartyCommitmentSecrets = nativeCounterpartyCommitmentSecretsImport; + +/// Implements the per-commitment secret storage scheme from +/// [BOLT 3](https://github.com/lightningnetwork/lightning-rfc/blob/dcbf8583976df087c79c3ce0b535311212e6812d/03-transactions.md#efficient-per-commitment-secret-storage). +/// +/// Allows us to keep track of all of the revocation secrets of our counterparty in just 50*32 bytes +/// or so. +#[must_use] +#[repr(C)] +pub struct CounterpartyCommitmentSecrets { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, 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 nativeCounterpartyCommitmentSecrets, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust 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 CounterpartyCommitmentSecrets { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeCounterpartyCommitmentSecrets>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the CounterpartyCommitmentSecrets, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn CounterpartyCommitmentSecrets_free(this_obj: CounterpartyCommitmentSecrets) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn CounterpartyCommitmentSecrets_free_void(this_ptr: *mut c_void) { + unsafe { let _ = Box::from_raw(this_ptr as *mut nativeCounterpartyCommitmentSecrets); } +} +#[allow(unused)] +impl CounterpartyCommitmentSecrets { + pub(crate) fn get_native_ref(&self) -> &'static nativeCounterpartyCommitmentSecrets { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCounterpartyCommitmentSecrets { + 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 nativeCounterpartyCommitmentSecrets { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +impl Clone for CounterpartyCommitmentSecrets { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeCounterpartyCommitmentSecrets>::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 CounterpartyCommitmentSecrets_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeCounterpartyCommitmentSecrets)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the CounterpartyCommitmentSecrets +pub extern "C" fn CounterpartyCommitmentSecrets_clone(orig: &CounterpartyCommitmentSecrets) -> CounterpartyCommitmentSecrets { + orig.clone() +} +/// Creates a new empty `CounterpartyCommitmentSecrets` structure. +#[must_use] +#[no_mangle] +pub extern "C" fn CounterpartyCommitmentSecrets_new() -> CounterpartyCommitmentSecrets { + let mut ret = lightning::ln::chan_utils::CounterpartyCommitmentSecrets::new(); + CounterpartyCommitmentSecrets { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Returns the minimum index of all stored secrets. Note that indexes start +/// at 1 << 48 and get decremented by one for each new secret. +#[must_use] +#[no_mangle] +pub extern "C" fn CounterpartyCommitmentSecrets_get_min_seen_secret(this_arg: &CounterpartyCommitmentSecrets) -> u64 { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_min_seen_secret(); + ret +} + +/// Inserts the `secret` at `idx`. Returns `Ok(())` if the secret +/// was generated in accordance with BOLT 3 and is consistent with previous secrets. +#[must_use] +#[no_mangle] +pub extern "C" fn CounterpartyCommitmentSecrets_provide_secret(this_arg: &mut CounterpartyCommitmentSecrets, mut idx: u64, mut secret: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut nativeCounterpartyCommitmentSecrets)) }.provide_secret(idx, secret.data); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Returns the secret at `idx`. +/// Returns `None` if `idx` is < [`CounterpartyCommitmentSecrets::get_min_seen_secret`]. +/// +/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None +#[must_use] +#[no_mangle] +pub extern "C" fn CounterpartyCommitmentSecrets_get_secret(this_arg: &CounterpartyCommitmentSecrets, mut idx: u64) -> crate::c_types::ThirtyTwoBytes { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_secret(idx); + let mut local_ret = if ret.is_none() { crate::c_types::ThirtyTwoBytes { data: [0; 32] } } else { { crate::c_types::ThirtyTwoBytes { data: (ret.unwrap()) } } }; + local_ret +} + +#[no_mangle] +/// Serialize the CounterpartyCommitmentSecrets object into a byte array which can be read by CounterpartyCommitmentSecrets_read +pub extern "C" fn CounterpartyCommitmentSecrets_write(obj: &CounterpartyCommitmentSecrets) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[no_mangle] +pub(crate) extern "C" fn CounterpartyCommitmentSecrets_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeCounterpartyCommitmentSecrets) }) +} +#[no_mangle] +/// Read a CounterpartyCommitmentSecrets from a byte array, created by CounterpartyCommitmentSecrets_write +pub extern "C" fn CounterpartyCommitmentSecrets_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_CounterpartyCommitmentSecretsDecodeErrorZ { + 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::chan_utils::CounterpartyCommitmentSecrets { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; + local_res +} /// Derives a per-commitment-transaction private key (eg an htlc key or delayed_payment key) /// from the base secret and the per_commitment_point. /// @@ -1861,6 +1990,8 @@ pub extern "C" fn TrustedCommitmentTransaction_opt_anchors(this_arg: &TrustedCom /// which HTLCOutputInCommitment::transaction_output_index.is_some()). /// /// The returned Vec has one entry for each HTLC, and in the same order. +/// +/// This function is only valid in the holder commitment context, it always uses SigHashType::All. #[must_use] #[no_mangle] pub extern "C" fn TrustedCommitmentTransaction_get_htlc_sigs(this_arg: &TrustedCommitmentTransaction, htlc_base_key: *const [u8; 32], channel_parameters: &crate::lightning::ln::chan_utils::DirectedChannelTransactionParameters) -> crate::c_types::derived::CResult_CVec_SignatureZNoneZ { diff --git a/lightning-c-bindings/src/lightning/ln/channelmanager.rs b/lightning-c-bindings/src/lightning/ln/channelmanager.rs index 3910df3..a7ff44b 100644 --- a/lightning-c-bindings/src/lightning/ln/channelmanager.rs +++ b/lightning-c-bindings/src/lightning/ln/channelmanager.rs @@ -1164,6 +1164,107 @@ pub extern "C" fn PaymentSendFailure_partial_failure(results: crate::c_types::de payment_id, } } + +use lightning::ln::channelmanager::PhantomRouteHints as nativePhantomRouteHintsImport; +pub(crate) type nativePhantomRouteHints = nativePhantomRouteHintsImport; + +/// Route hints used in constructing invoices for [phantom node payents]. +/// +/// [phantom node payments]: crate::chain::keysinterface::PhantomKeysManager +#[must_use] +#[repr(C)] +pub struct PhantomRouteHints { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, 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 nativePhantomRouteHints, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust 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 PhantomRouteHints { + fn drop(&mut self) { + if self.is_owned && !<*mut nativePhantomRouteHints>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the PhantomRouteHints, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn PhantomRouteHints_free(this_obj: PhantomRouteHints) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn PhantomRouteHints_free_void(this_ptr: *mut c_void) { + unsafe { let _ = Box::from_raw(this_ptr as *mut nativePhantomRouteHints); } +} +#[allow(unused)] +impl PhantomRouteHints { + pub(crate) fn get_native_ref(&self) -> &'static nativePhantomRouteHints { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePhantomRouteHints { + 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 nativePhantomRouteHints { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +/// The list of channels to be included in the invoice route hints. +#[no_mangle] +pub extern "C" fn PhantomRouteHints_get_channels(this_ptr: &PhantomRouteHints) -> crate::c_types::derived::CVec_ChannelDetailsZ { + let mut inner_val = &mut this_ptr.get_native_mut_ref().channels; + let mut local_inner_val = Vec::new(); for item in inner_val.iter() { local_inner_val.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_inner_val.into() +} +/// The list of channels to be included in the invoice route hints. +#[no_mangle] +pub extern "C" fn PhantomRouteHints_set_channels(this_ptr: &mut PhantomRouteHints, mut val: crate::c_types::derived::CVec_ChannelDetailsZ) { + 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) }.channels = local_val; +} +/// A fake scid used for representing the phantom node's fake channel in generating the invoice +/// route hints. +#[no_mangle] +pub extern "C" fn PhantomRouteHints_get_phantom_scid(this_ptr: &PhantomRouteHints) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().phantom_scid; + *inner_val +} +/// A fake scid used for representing the phantom node's fake channel in generating the invoice +/// route hints. +#[no_mangle] +pub extern "C" fn PhantomRouteHints_set_phantom_scid(this_ptr: &mut PhantomRouteHints, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.phantom_scid = val; +} +/// The pubkey of the real backing node that would ultimately receive the payment. +#[no_mangle] +pub extern "C" fn PhantomRouteHints_get_real_node_pubkey(this_ptr: &PhantomRouteHints) -> crate::c_types::PublicKey { + let mut inner_val = &mut this_ptr.get_native_mut_ref().real_node_pubkey; + crate::c_types::PublicKey::from_rust(&inner_val) +} +/// The pubkey of the real backing node that would ultimately receive the payment. +#[no_mangle] +pub extern "C" fn PhantomRouteHints_set_real_node_pubkey(this_ptr: &mut PhantomRouteHints, mut val: crate::c_types::PublicKey) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.real_node_pubkey = val.into_rust(); +} +/// Constructs a new PhantomRouteHints given each field +#[must_use] +#[no_mangle] +pub extern "C" fn PhantomRouteHints_new(mut channels_arg: crate::c_types::derived::CVec_ChannelDetailsZ, mut phantom_scid_arg: u64, mut real_node_pubkey_arg: crate::c_types::PublicKey) -> PhantomRouteHints { + let mut local_channels_arg = Vec::new(); for mut item in channels_arg.into_rust().drain(..) { local_channels_arg.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; + PhantomRouteHints { inner: ObjOps::heap_alloc(nativePhantomRouteHints { + channels: local_channels_arg, + phantom_scid: phantom_scid_arg, + real_node_pubkey: real_node_pubkey_arg.into_rust(), + }), is_owned: true } +} /// Constructs a new ChannelManager to hold several channels and route between them. /// /// This is the main \"logic hub\" for all channel-related actions, and implements @@ -1553,6 +1654,20 @@ pub extern "C" fn ChannelManager_get_our_node_id(this_arg: &ChannelManager) -> c crate::c_types::PublicKey::from_rust(&ret) } +/// Called to accept a request to open a channel after [`Event::OpenChannelRequest`] has been +/// triggered. +/// +/// The `temporary_channel_id` parameter indicates which inbound channel should be accepted. +/// +/// [`Event::OpenChannelRequest`]: crate::util::events::Event::OpenChannelRequest +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelManager_accept_inbound_channel(this_arg: &ChannelManager, temporary_channel_id: *const [u8; 32]) -> crate::c_types::derived::CResult_NoneAPIErrorZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.accept_inbound_channel(unsafe { &*temporary_channel_id}); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() }; + local_ret +} + /// Gets a payment secret and payment hash for use in an invoice given to a third party wishing /// to pay us. /// @@ -1686,6 +1801,27 @@ pub extern "C" fn ChannelManager_get_payment_preimage(this_arg: &ChannelManager, local_ret } +/// 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 +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelManager_get_phantom_scid(this_arg: &ChannelManager) -> u64 { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_phantom_scid(); + ret +} + +/// Gets route hints for use in receiving [phantom node payments]. +/// +/// [phantom node payments]: crate::chain::keysinterface::PhantomKeysManager +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelManager_get_phantom_route_hints(this_arg: &ChannelManager) -> crate::lightning::ln::channelmanager::PhantomRouteHints { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_phantom_route_hints(); + crate::lightning::ln::channelmanager::PhantomRouteHints { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + impl From for crate::lightning::util::events::MessageSendEventsProvider { fn from(obj: nativeChannelManager) -> Self { let mut rust_obj = ChannelManager { inner: ObjOps::heap_alloc(obj), is_owned: true }; @@ -1945,6 +2081,70 @@ extern "C" fn ChannelManager_ChannelMessageHandler_handle_error(this_arg: *const >::handle_error(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), msg.get_native_ref()) } +#[no_mangle] +/// Serialize the CounterpartyForwardingInfo object into a byte array which can be read by CounterpartyForwardingInfo_read +pub extern "C" fn CounterpartyForwardingInfo_write(obj: &CounterpartyForwardingInfo) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[no_mangle] +pub(crate) extern "C" fn CounterpartyForwardingInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeCounterpartyForwardingInfo) }) +} +#[no_mangle] +/// Read a CounterpartyForwardingInfo from a byte array, created by CounterpartyForwardingInfo_write +pub extern "C" fn CounterpartyForwardingInfo_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_CounterpartyForwardingInfoDecodeErrorZ { + 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::CounterpartyForwardingInfo { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; + local_res +} +#[no_mangle] +/// Serialize the ChannelCounterparty object into a byte array which can be read by ChannelCounterparty_read +pub extern "C" fn ChannelCounterparty_write(obj: &ChannelCounterparty) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[no_mangle] +pub(crate) extern "C" fn ChannelCounterparty_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelCounterparty) }) +} +#[no_mangle] +/// Read a ChannelCounterparty from a byte array, created by ChannelCounterparty_write +pub extern "C" fn ChannelCounterparty_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelCounterpartyDecodeErrorZ { + 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::ChannelCounterparty { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; + local_res +} +#[no_mangle] +/// Serialize the ChannelDetails object into a byte array which can be read by ChannelDetails_read +pub extern "C" fn ChannelDetails_write(obj: &ChannelDetails) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[no_mangle] +pub(crate) extern "C" fn ChannelDetails_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelDetails) }) +} +#[no_mangle] +/// Read a ChannelDetails from a byte array, created by ChannelDetails_write +pub extern "C" fn ChannelDetails_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelDetailsDecodeErrorZ { + 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::ChannelDetails { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; + local_res +} +#[no_mangle] +/// Serialize the PhantomRouteHints object into a byte array which can be read by PhantomRouteHints_read +pub extern "C" fn PhantomRouteHints_write(obj: &PhantomRouteHints) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[no_mangle] +pub(crate) extern "C" fn PhantomRouteHints_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePhantomRouteHints) }) +} +#[no_mangle] +/// Read a PhantomRouteHints from a byte array, created by PhantomRouteHints_write +pub extern "C" fn PhantomRouteHints_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PhantomRouteHintsDecodeErrorZ { + 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::PhantomRouteHints { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; + local_res +} #[no_mangle] /// Serialize the ChannelManager object into a byte array which can be read by ChannelManager_read pub extern "C" fn ChannelManager_write(obj: &ChannelManager) -> crate::c_types::derived::CVec_u8Z { diff --git a/lightning-c-bindings/src/lightning/ln/msgs.rs b/lightning-c-bindings/src/lightning/ln/msgs.rs index 67ca95f..1976040 100644 --- a/lightning-c-bindings/src/lightning/ln/msgs.rs +++ b/lightning-c-bindings/src/lightning/ln/msgs.rs @@ -241,30 +241,36 @@ impl ErrorMessage { ret } } -/// The channel ID involved in the error +/// The channel ID involved in the error. +/// +/// All-0s indicates a general error unrelated to a specific channel, after which all channels +/// with the sending peer should be closed. #[no_mangle] pub extern "C" fn ErrorMessage_get_channel_id(this_ptr: &ErrorMessage) -> *const [u8; 32] { let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id; inner_val } -/// The channel ID involved in the error +/// The channel ID involved in the error. +/// +/// All-0s indicates a general error unrelated to a specific channel, after which all channels +/// with the sending peer should be closed. #[no_mangle] pub extern "C" fn ErrorMessage_set_channel_id(this_ptr: &mut ErrorMessage, mut val: crate::c_types::ThirtyTwoBytes) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data; } /// A possibly human-readable error description. -/// The string should be sanitized before it is used (e.g. emitted to logs -/// or printed to stdout). Otherwise, a well crafted error message may trigger a security -/// vulnerability in the terminal emulator or the logging subsystem. +/// The string should be sanitized before it is used (e.g. emitted to logs or printed to +/// stdout). Otherwise, a well crafted error message may trigger a security vulnerability in +/// the terminal emulator or the logging subsystem. #[no_mangle] pub extern "C" fn ErrorMessage_get_data(this_ptr: &ErrorMessage) -> crate::c_types::Str { let mut inner_val = &mut this_ptr.get_native_mut_ref().data; inner_val.as_str().into() } /// A possibly human-readable error description. -/// The string should be sanitized before it is used (e.g. emitted to logs -/// or printed to stdout). Otherwise, a well crafted error message may trigger a security -/// vulnerability in the terminal emulator or the logging subsystem. +/// The string should be sanitized before it is used (e.g. emitted to logs or printed to +/// stdout). Otherwise, a well crafted error message may trigger a security vulnerability in +/// the terminal emulator or the logging subsystem. #[no_mangle] pub extern "C" fn ErrorMessage_set_data(this_ptr: &mut ErrorMessage, mut val: crate::c_types::Str) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.data = val.into_string(); @@ -298,6 +304,117 @@ pub extern "C" fn ErrorMessage_clone(orig: &ErrorMessage) -> ErrorMessage { orig.clone() } +use lightning::ln::msgs::WarningMessage as nativeWarningMessageImport; +pub(crate) type nativeWarningMessage = nativeWarningMessageImport; + +/// A warning message to be sent or received from a peer +#[must_use] +#[repr(C)] +pub struct WarningMessage { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, 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 nativeWarningMessage, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust 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 WarningMessage { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeWarningMessage>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the WarningMessage, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn WarningMessage_free(this_obj: WarningMessage) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn WarningMessage_free_void(this_ptr: *mut c_void) { + unsafe { let _ = Box::from_raw(this_ptr as *mut nativeWarningMessage); } +} +#[allow(unused)] +impl WarningMessage { + pub(crate) fn get_native_ref(&self) -> &'static nativeWarningMessage { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeWarningMessage { + 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 nativeWarningMessage { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +/// The channel ID involved in the warning. +/// +/// All-0s indicates a warning unrelated to a specific channel. +#[no_mangle] +pub extern "C" fn WarningMessage_get_channel_id(this_ptr: &WarningMessage) -> *const [u8; 32] { + let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id; + inner_val +} +/// The channel ID involved in the warning. +/// +/// All-0s indicates a warning unrelated to a specific channel. +#[no_mangle] +pub extern "C" fn WarningMessage_set_channel_id(this_ptr: &mut WarningMessage, mut val: crate::c_types::ThirtyTwoBytes) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data; +} +/// A possibly human-readable warning description. +/// The string should be sanitized before it is used (e.g. emitted to logs or printed to +/// stdout). Otherwise, a well crafted error message may trigger a security vulnerability in +/// the terminal emulator or the logging subsystem. +#[no_mangle] +pub extern "C" fn WarningMessage_get_data(this_ptr: &WarningMessage) -> crate::c_types::Str { + let mut inner_val = &mut this_ptr.get_native_mut_ref().data; + inner_val.as_str().into() +} +/// A possibly human-readable warning description. +/// The string should be sanitized before it is used (e.g. emitted to logs or printed to +/// stdout). Otherwise, a well crafted error message may trigger a security vulnerability in +/// the terminal emulator or the logging subsystem. +#[no_mangle] +pub extern "C" fn WarningMessage_set_data(this_ptr: &mut WarningMessage, mut val: crate::c_types::Str) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.data = val.into_string(); +} +/// Constructs a new WarningMessage given each field +#[must_use] +#[no_mangle] +pub extern "C" fn WarningMessage_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut data_arg: crate::c_types::Str) -> WarningMessage { + WarningMessage { inner: ObjOps::heap_alloc(nativeWarningMessage { + channel_id: channel_id_arg.data, + data: data_arg.into_string(), + }), is_owned: true } +} +impl Clone for WarningMessage { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeWarningMessage>::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 WarningMessage_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeWarningMessage)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the WarningMessage +pub extern "C" fn WarningMessage_clone(orig: &WarningMessage) -> WarningMessage { + orig.clone() +} + use lightning::ln::msgs::Ping as nativePingImport; pub(crate) type nativePing = nativePingImport; @@ -985,6 +1102,31 @@ 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(); } +/// 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 [`OpenChannel::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 AcceptChannel_get_channel_type(this_ptr: &AcceptChannel) -> 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 [`OpenChannel::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 AcceptChannel_set_channel_type(this_ptr: &mut AcceptChannel, 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; +} impl Clone for AcceptChannel { fn clone(&self) -> Self { Self { @@ -4394,6 +4536,15 @@ pub enum ErrorAction { /// The message to send. msg: crate::lightning::ln::msgs::ErrorMessage, }, + /// The peer did something incorrect. Tell them without closing any channels. + SendWarningMessage { + /// The message to send. + msg: crate::lightning::ln::msgs::WarningMessage, + /// The peer may have done something harmless that we weren't able to meaningfully process, + /// though we should still tell them about it. + /// If this event is logged, log it at the given level. + log_level: crate::lightning::util::logger::Level, + }, } use lightning::ln::msgs::ErrorAction as nativeErrorAction; impl ErrorAction { @@ -4421,6 +4572,14 @@ impl ErrorAction { msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, } }, + ErrorAction::SendWarningMessage {ref msg, ref log_level, } => { + let mut msg_nonref = (*msg).clone(); + let mut log_level_nonref = (*log_level).clone(); + nativeErrorAction::SendWarningMessage { + msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, + log_level: log_level_nonref.into_native(), + } + }, } } #[allow(unused)] @@ -4444,6 +4603,12 @@ impl ErrorAction { msg: *unsafe { Box::from_raw(msg.take_inner()) }, } }, + ErrorAction::SendWarningMessage {mut msg, mut log_level, } => { + nativeErrorAction::SendWarningMessage { + msg: *unsafe { Box::from_raw(msg.take_inner()) }, + log_level: log_level.into_native(), + } + }, } } #[allow(unused)] @@ -4470,6 +4635,14 @@ impl ErrorAction { msg: crate::lightning::ln::msgs::ErrorMessage { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, } }, + nativeErrorAction::SendWarningMessage {ref msg, ref log_level, } => { + let mut msg_nonref = (*msg).clone(); + let mut log_level_nonref = (*log_level).clone(); + ErrorAction::SendWarningMessage { + msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, + log_level: crate::lightning::util::logger::Level::native_into(log_level_nonref), + } + }, } } #[allow(unused)] @@ -4493,6 +4666,12 @@ impl ErrorAction { msg: crate::lightning::ln::msgs::ErrorMessage { inner: ObjOps::heap_alloc(msg), is_owned: true }, } }, + nativeErrorAction::SendWarningMessage {mut msg, mut log_level, } => { + ErrorAction::SendWarningMessage { + msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg), is_owned: true }, + log_level: crate::lightning::util::logger::Level::native_into(log_level), + } + }, } } } @@ -4531,6 +4710,14 @@ pub extern "C" fn ErrorAction_send_error_message(msg: crate::lightning::ln::msgs msg, } } +#[no_mangle] +/// Utility method to constructs a new SendWarningMessage-variant ErrorAction +pub extern "C" fn ErrorAction_send_warning_message(msg: crate::lightning::ln::msgs::WarningMessage, log_level: crate::lightning::util::logger::Level) -> ErrorAction { + ErrorAction::SendWarningMessage { + msg, + log_level, + } +} use lightning::ln::msgs::LightningError as nativeLightningErrorImport; pub(crate) type nativeLightningError = nativeLightningErrorImport; @@ -5556,6 +5743,22 @@ pub extern "C" fn ErrorMessage_read(ser: crate::c_types::u8slice) -> crate::c_ty local_res } #[no_mangle] +/// Serialize the WarningMessage object into a byte array which can be read by WarningMessage_read +pub extern "C" fn WarningMessage_write(obj: &WarningMessage) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[no_mangle] +pub(crate) extern "C" fn WarningMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeWarningMessage) }) +} +#[no_mangle] +/// Read a WarningMessage from a byte array, created by WarningMessage_write +pub extern "C" fn WarningMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_WarningMessageDecodeErrorZ { + 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::WarningMessage { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; + local_res +} +#[no_mangle] /// Serialize the UnsignedNodeAnnouncement object into a byte array which can be read by UnsignedNodeAnnouncement_read pub extern "C" fn UnsignedNodeAnnouncement_write(obj: &UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) diff --git a/lightning-c-bindings/src/lightning/mod.rs b/lightning-c-bindings/src/lightning/mod.rs index 7fbf935..d208a6f 100644 --- a/lightning-c-bindings/src/lightning/mod.rs +++ b/lightning-c-bindings/src/lightning/mod.rs @@ -28,6 +28,17 @@ pub mod util; pub mod chain; pub mod ln; pub mod routing; +mod io_extras { + +use alloc::str::FromStr; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + +} mod prelude { use alloc::str::FromStr; @@ -39,3 +50,14 @@ use crate::c_types::*; use alloc::{vec::Vec, boxed::Box}; } +mod sync { + +use alloc::str::FromStr; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + +} diff --git a/lightning-c-bindings/src/lightning/routing/network_graph.rs b/lightning-c-bindings/src/lightning/routing/network_graph.rs index 15fd9c4..4b278a9 100644 --- a/lightning-c-bindings/src/lightning/routing/network_graph.rs +++ b/lightning-c-bindings/src/lightning/routing/network_graph.rs @@ -655,19 +655,18 @@ extern "C" fn NetGraphMsgHandler_MessageSendEventsProvider_get_and_clear_pending } -use lightning::routing::network_graph::DirectionalChannelInfo as nativeDirectionalChannelInfoImport; -pub(crate) type nativeDirectionalChannelInfo = nativeDirectionalChannelInfoImport; +use lightning::routing::network_graph::ChannelUpdateInfo as nativeChannelUpdateInfoImport; +pub(crate) type nativeChannelUpdateInfo = nativeChannelUpdateInfoImport; -/// Details about one direction of a channel. Received -/// within a channel update. +/// Details about one direction of a channel as received within a [`ChannelUpdate`]. #[must_use] #[repr(C)] -pub struct DirectionalChannelInfo { +pub struct ChannelUpdateInfo { /// A pointer to the opaque Rust object. /// Nearly everywhere, 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 nativeDirectionalChannelInfo, + pub inner: *mut nativeChannelUpdateInfo, /// Indicates that this is the only struct which contains the same pointer. /// Rust functions which take ownership of an object provided via an argument require @@ -675,31 +674,31 @@ pub struct DirectionalChannelInfo { pub is_owned: bool, } -impl Drop for DirectionalChannelInfo { +impl Drop for ChannelUpdateInfo { fn drop(&mut self) { - if self.is_owned && !<*mut nativeDirectionalChannelInfo>::is_null(self.inner) { + if self.is_owned && !<*mut nativeChannelUpdateInfo>::is_null(self.inner) { let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; } } } -/// Frees any resources used by the DirectionalChannelInfo, if is_owned is set and inner is non-NULL. +/// Frees any resources used by the ChannelUpdateInfo, if is_owned is set and inner is non-NULL. #[no_mangle] -pub extern "C" fn DirectionalChannelInfo_free(this_obj: DirectionalChannelInfo) { } +pub extern "C" fn ChannelUpdateInfo_free(this_obj: ChannelUpdateInfo) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn DirectionalChannelInfo_free_void(this_ptr: *mut c_void) { - unsafe { let _ = Box::from_raw(this_ptr as *mut nativeDirectionalChannelInfo); } +pub(crate) extern "C" fn ChannelUpdateInfo_free_void(this_ptr: *mut c_void) { + unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelUpdateInfo); } } #[allow(unused)] -impl DirectionalChannelInfo { - pub(crate) fn get_native_ref(&self) -> &'static nativeDirectionalChannelInfo { +impl ChannelUpdateInfo { + pub(crate) fn get_native_ref(&self) -> &'static nativeChannelUpdateInfo { unsafe { &*ObjOps::untweak_ptr(self.inner) } } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeDirectionalChannelInfo { + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelUpdateInfo { 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 nativeDirectionalChannelInfo { + pub(crate) fn take_inner(mut self) -> *mut nativeChannelUpdateInfo { assert!(self.is_owned); let ret = ObjOps::untweak_ptr(self.inner); self.inner = core::ptr::null_mut(); @@ -709,71 +708,71 @@ impl DirectionalChannelInfo { /// When the last update to the channel direction was issued. /// Value is opaque, as set in the announcement. #[no_mangle] -pub extern "C" fn DirectionalChannelInfo_get_last_update(this_ptr: &DirectionalChannelInfo) -> u32 { +pub extern "C" fn ChannelUpdateInfo_get_last_update(this_ptr: &ChannelUpdateInfo) -> u32 { let mut inner_val = &mut this_ptr.get_native_mut_ref().last_update; *inner_val } /// When the last update to the channel direction was issued. /// Value is opaque, as set in the announcement. #[no_mangle] -pub extern "C" fn DirectionalChannelInfo_set_last_update(this_ptr: &mut DirectionalChannelInfo, mut val: u32) { +pub extern "C" fn ChannelUpdateInfo_set_last_update(this_ptr: &mut ChannelUpdateInfo, mut val: u32) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.last_update = val; } /// Whether the channel can be currently used for payments (in this one direction). #[no_mangle] -pub extern "C" fn DirectionalChannelInfo_get_enabled(this_ptr: &DirectionalChannelInfo) -> bool { +pub extern "C" fn ChannelUpdateInfo_get_enabled(this_ptr: &ChannelUpdateInfo) -> bool { let mut inner_val = &mut this_ptr.get_native_mut_ref().enabled; *inner_val } /// Whether the channel can be currently used for payments (in this one direction). #[no_mangle] -pub extern "C" fn DirectionalChannelInfo_set_enabled(this_ptr: &mut DirectionalChannelInfo, mut val: bool) { +pub extern "C" fn ChannelUpdateInfo_set_enabled(this_ptr: &mut ChannelUpdateInfo, mut val: bool) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.enabled = val; } /// The difference in CLTV values that you must have when routing through this channel. #[no_mangle] -pub extern "C" fn DirectionalChannelInfo_get_cltv_expiry_delta(this_ptr: &DirectionalChannelInfo) -> u16 { +pub extern "C" fn ChannelUpdateInfo_get_cltv_expiry_delta(this_ptr: &ChannelUpdateInfo) -> u16 { let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta; *inner_val } /// The difference in CLTV values that you must have when routing through this channel. #[no_mangle] -pub extern "C" fn DirectionalChannelInfo_set_cltv_expiry_delta(this_ptr: &mut DirectionalChannelInfo, mut val: u16) { +pub extern "C" fn ChannelUpdateInfo_set_cltv_expiry_delta(this_ptr: &mut ChannelUpdateInfo, mut val: u16) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val; } /// The minimum value, which must be relayed to the next hop via the channel #[no_mangle] -pub extern "C" fn DirectionalChannelInfo_get_htlc_minimum_msat(this_ptr: &DirectionalChannelInfo) -> u64 { +pub extern "C" fn ChannelUpdateInfo_get_htlc_minimum_msat(this_ptr: &ChannelUpdateInfo) -> u64 { let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat; *inner_val } /// The minimum value, which must be relayed to the next hop via the channel #[no_mangle] -pub extern "C" fn DirectionalChannelInfo_set_htlc_minimum_msat(this_ptr: &mut DirectionalChannelInfo, mut val: u64) { +pub extern "C" fn ChannelUpdateInfo_set_htlc_minimum_msat(this_ptr: &mut ChannelUpdateInfo, mut val: u64) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val; } /// The maximum value which may be relayed to the next hop via the channel. #[no_mangle] -pub extern "C" fn DirectionalChannelInfo_get_htlc_maximum_msat(this_ptr: &DirectionalChannelInfo) -> crate::c_types::derived::COption_u64Z { +pub extern "C" fn ChannelUpdateInfo_get_htlc_maximum_msat(this_ptr: &ChannelUpdateInfo) -> crate::c_types::derived::COption_u64Z { let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_maximum_msat; let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) }; local_inner_val } /// The maximum value which may be relayed to the next hop via the channel. #[no_mangle] -pub extern "C" fn DirectionalChannelInfo_set_htlc_maximum_msat(this_ptr: &mut DirectionalChannelInfo, mut val: crate::c_types::derived::COption_u64Z) { +pub extern "C" fn ChannelUpdateInfo_set_htlc_maximum_msat(this_ptr: &mut ChannelUpdateInfo, mut val: crate::c_types::derived::COption_u64Z) { let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_maximum_msat = local_val; } /// Fees charged when the channel is used for routing #[no_mangle] -pub extern "C" fn DirectionalChannelInfo_get_fees(this_ptr: &DirectionalChannelInfo) -> crate::lightning::routing::network_graph::RoutingFees { +pub extern "C" fn ChannelUpdateInfo_get_fees(this_ptr: &ChannelUpdateInfo) -> crate::lightning::routing::network_graph::RoutingFees { let mut inner_val = &mut this_ptr.get_native_mut_ref().fees; crate::lightning::routing::network_graph::RoutingFees { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::routing::network_graph::RoutingFees<>) as *mut _) }, is_owned: false } } /// Fees charged when the channel is used for routing #[no_mangle] -pub extern "C" fn DirectionalChannelInfo_set_fees(this_ptr: &mut DirectionalChannelInfo, mut val: crate::lightning::routing::network_graph::RoutingFees) { +pub extern "C" fn ChannelUpdateInfo_set_fees(this_ptr: &mut ChannelUpdateInfo, mut val: crate::lightning::routing::network_graph::RoutingFees) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fees = *unsafe { Box::from_raw(val.take_inner()) }; } /// Most recent update for the channel received from the network @@ -783,7 +782,7 @@ pub extern "C" fn DirectionalChannelInfo_set_fees(this_ptr: &mut DirectionalChan /// /// 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 DirectionalChannelInfo_get_last_update_message(this_ptr: &DirectionalChannelInfo) -> crate::lightning::ln::msgs::ChannelUpdate { +pub extern "C" fn ChannelUpdateInfo_get_last_update_message(this_ptr: &ChannelUpdateInfo) -> crate::lightning::ln::msgs::ChannelUpdate { let mut inner_val = &mut this_ptr.get_native_mut_ref().last_update_message; let mut local_inner_val = crate::lightning::ln::msgs::ChannelUpdate { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::msgs::ChannelUpdate<>) as *mut _ }, is_owned: false }; local_inner_val @@ -795,17 +794,17 @@ pub extern "C" fn DirectionalChannelInfo_get_last_update_message(this_ptr: &Dire /// /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None #[no_mangle] -pub extern "C" fn DirectionalChannelInfo_set_last_update_message(this_ptr: &mut DirectionalChannelInfo, mut val: crate::lightning::ln::msgs::ChannelUpdate) { +pub extern "C" fn ChannelUpdateInfo_set_last_update_message(this_ptr: &mut ChannelUpdateInfo, mut val: crate::lightning::ln::msgs::ChannelUpdate) { 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) }.last_update_message = local_val; } -/// Constructs a new DirectionalChannelInfo given each field +/// Constructs a new ChannelUpdateInfo given each field #[must_use] #[no_mangle] -pub extern "C" fn DirectionalChannelInfo_new(mut last_update_arg: u32, mut enabled_arg: bool, mut cltv_expiry_delta_arg: u16, mut htlc_minimum_msat_arg: u64, mut htlc_maximum_msat_arg: crate::c_types::derived::COption_u64Z, mut fees_arg: crate::lightning::routing::network_graph::RoutingFees, mut last_update_message_arg: crate::lightning::ln::msgs::ChannelUpdate) -> DirectionalChannelInfo { +pub extern "C" fn ChannelUpdateInfo_new(mut last_update_arg: u32, mut enabled_arg: bool, mut cltv_expiry_delta_arg: u16, mut htlc_minimum_msat_arg: u64, mut htlc_maximum_msat_arg: crate::c_types::derived::COption_u64Z, mut fees_arg: crate::lightning::routing::network_graph::RoutingFees, mut last_update_message_arg: crate::lightning::ln::msgs::ChannelUpdate) -> ChannelUpdateInfo { let mut local_htlc_maximum_msat_arg = if htlc_maximum_msat_arg.is_some() { Some( { htlc_maximum_msat_arg.take() }) } else { None }; let mut local_last_update_message_arg = if last_update_message_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(last_update_message_arg.take_inner()) } }) }; - DirectionalChannelInfo { inner: ObjOps::heap_alloc(nativeDirectionalChannelInfo { + ChannelUpdateInfo { inner: ObjOps::heap_alloc(nativeChannelUpdateInfo { last_update: last_update_arg, enabled: enabled_arg, cltv_expiry_delta: cltv_expiry_delta_arg, @@ -815,10 +814,10 @@ pub extern "C" fn DirectionalChannelInfo_new(mut last_update_arg: u32, mut enabl last_update_message: local_last_update_message_arg, }), is_owned: true } } -impl Clone for DirectionalChannelInfo { +impl Clone for ChannelUpdateInfo { fn clone(&self) -> Self { Self { - inner: if <*mut nativeDirectionalChannelInfo>::is_null(self.inner) { core::ptr::null_mut() } else { + inner: if <*mut nativeChannelUpdateInfo>::is_null(self.inner) { core::ptr::null_mut() } else { ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, is_owned: true, } @@ -826,28 +825,28 @@ impl Clone for DirectionalChannelInfo { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn DirectionalChannelInfo_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeDirectionalChannelInfo)).clone() })) as *mut c_void +pub(crate) extern "C" fn ChannelUpdateInfo_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelUpdateInfo)).clone() })) as *mut c_void } #[no_mangle] -/// Creates a copy of the DirectionalChannelInfo -pub extern "C" fn DirectionalChannelInfo_clone(orig: &DirectionalChannelInfo) -> DirectionalChannelInfo { +/// Creates a copy of the ChannelUpdateInfo +pub extern "C" fn ChannelUpdateInfo_clone(orig: &ChannelUpdateInfo) -> ChannelUpdateInfo { orig.clone() } #[no_mangle] -/// Serialize the DirectionalChannelInfo object into a byte array which can be read by DirectionalChannelInfo_read -pub extern "C" fn DirectionalChannelInfo_write(obj: &DirectionalChannelInfo) -> crate::c_types::derived::CVec_u8Z { +/// Serialize the ChannelUpdateInfo object into a byte array which can be read by ChannelUpdateInfo_read +pub extern "C" fn ChannelUpdateInfo_write(obj: &ChannelUpdateInfo) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) } #[no_mangle] -pub(crate) extern "C" fn DirectionalChannelInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeDirectionalChannelInfo) }) +pub(crate) extern "C" fn ChannelUpdateInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelUpdateInfo) }) } #[no_mangle] -/// Read a DirectionalChannelInfo from a byte array, created by DirectionalChannelInfo_write -pub extern "C" fn DirectionalChannelInfo_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_DirectionalChannelInfoDecodeErrorZ { - let res: Result = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::network_graph::DirectionalChannelInfo { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; +/// Read a ChannelUpdateInfo from a byte array, created by ChannelUpdateInfo_write +pub extern "C" fn ChannelUpdateInfo_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelUpdateInfoDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::network_graph::ChannelUpdateInfo { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; local_res } @@ -928,16 +927,16 @@ pub extern "C" fn ChannelInfo_set_node_one(this_ptr: &mut ChannelInfo, mut val: /// /// 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 ChannelInfo_get_one_to_two(this_ptr: &ChannelInfo) -> crate::lightning::routing::network_graph::DirectionalChannelInfo { +pub extern "C" fn ChannelInfo_get_one_to_two(this_ptr: &ChannelInfo) -> crate::lightning::routing::network_graph::ChannelUpdateInfo { let mut inner_val = &mut this_ptr.get_native_mut_ref().one_to_two; - let mut local_inner_val = crate::lightning::routing::network_graph::DirectionalChannelInfo { 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::network_graph::DirectionalChannelInfo<>) as *mut _ }, is_owned: false }; + let mut local_inner_val = crate::lightning::routing::network_graph::ChannelUpdateInfo { 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::network_graph::ChannelUpdateInfo<>) as *mut _ }, is_owned: false }; local_inner_val } /// Details about the first direction of a channel /// /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None #[no_mangle] -pub extern "C" fn ChannelInfo_set_one_to_two(this_ptr: &mut ChannelInfo, mut val: crate::lightning::routing::network_graph::DirectionalChannelInfo) { +pub extern "C" fn ChannelInfo_set_one_to_two(this_ptr: &mut ChannelInfo, mut val: crate::lightning::routing::network_graph::ChannelUpdateInfo) { let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.one_to_two = local_val; } @@ -956,16 +955,16 @@ pub extern "C" fn ChannelInfo_set_node_two(this_ptr: &mut ChannelInfo, mut val: /// /// 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 ChannelInfo_get_two_to_one(this_ptr: &ChannelInfo) -> crate::lightning::routing::network_graph::DirectionalChannelInfo { +pub extern "C" fn ChannelInfo_get_two_to_one(this_ptr: &ChannelInfo) -> crate::lightning::routing::network_graph::ChannelUpdateInfo { let mut inner_val = &mut this_ptr.get_native_mut_ref().two_to_one; - let mut local_inner_val = crate::lightning::routing::network_graph::DirectionalChannelInfo { 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::network_graph::DirectionalChannelInfo<>) as *mut _ }, is_owned: false }; + let mut local_inner_val = crate::lightning::routing::network_graph::ChannelUpdateInfo { 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::network_graph::ChannelUpdateInfo<>) as *mut _ }, is_owned: false }; local_inner_val } /// Details about the second direction of a channel /// /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None #[no_mangle] -pub extern "C" fn ChannelInfo_set_two_to_one(this_ptr: &mut ChannelInfo, mut val: crate::lightning::routing::network_graph::DirectionalChannelInfo) { +pub extern "C" fn ChannelInfo_set_two_to_one(this_ptr: &mut ChannelInfo, mut val: crate::lightning::routing::network_graph::ChannelUpdateInfo) { let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.two_to_one = local_val; } @@ -1041,6 +1040,287 @@ pub extern "C" fn ChannelInfo_read(ser: crate::c_types::u8slice) -> crate::c_typ local_res } +use lightning::routing::network_graph::DirectedChannelInfo as nativeDirectedChannelInfoImport; +pub(crate) type nativeDirectedChannelInfo = nativeDirectedChannelInfoImport<'static>; + +/// A wrapper around [`ChannelInfo`] representing information about the channel as directed from a +/// source node to a target node. +#[must_use] +#[repr(C)] +pub struct DirectedChannelInfo { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, 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 nativeDirectedChannelInfo, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust 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 DirectedChannelInfo { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeDirectedChannelInfo>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the DirectedChannelInfo, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn DirectedChannelInfo_free(this_obj: DirectedChannelInfo) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn DirectedChannelInfo_free_void(this_ptr: *mut c_void) { + unsafe { let _ = Box::from_raw(this_ptr as *mut nativeDirectedChannelInfo); } +} +#[allow(unused)] +impl DirectedChannelInfo { + pub(crate) fn get_native_ref(&self) -> &'static nativeDirectedChannelInfo { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeDirectedChannelInfo { + 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 nativeDirectedChannelInfo { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +impl Clone for DirectedChannelInfo { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeDirectedChannelInfo>::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 DirectedChannelInfo_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeDirectedChannelInfo)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the DirectedChannelInfo +pub extern "C" fn DirectedChannelInfo_clone(orig: &DirectedChannelInfo) -> DirectedChannelInfo { + orig.clone() +} +/// Returns information for the channel. +#[must_use] +#[no_mangle] +pub extern "C" fn DirectedChannelInfo_channel(this_arg: &DirectedChannelInfo) -> crate::lightning::routing::network_graph::ChannelInfo { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.channel(); + crate::lightning::routing::network_graph::ChannelInfo { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::routing::network_graph::ChannelInfo<>) as *mut _) }, is_owned: false } +} + +/// Returns information for the direction. +/// +/// 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 DirectedChannelInfo_direction(this_arg: &DirectedChannelInfo) -> crate::lightning::routing::network_graph::ChannelUpdateInfo { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.direction(); + let mut local_ret = crate::lightning::routing::network_graph::ChannelUpdateInfo { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning::routing::network_graph::ChannelUpdateInfo<>) as *mut _ }, is_owned: false }; + local_ret +} + +/// Returns the [`EffectiveCapacity`] of the channel in the direction. +/// +/// This is either the total capacity from the funding transaction, if known, or the +/// `htlc_maximum_msat` for the direction as advertised by the gossip network, if known, +/// whichever is smaller. +#[must_use] +#[no_mangle] +pub extern "C" fn DirectedChannelInfo_effective_capacity(this_arg: &DirectedChannelInfo) -> crate::lightning::routing::network_graph::EffectiveCapacity { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.effective_capacity(); + crate::lightning::routing::network_graph::EffectiveCapacity::native_into(ret) +} + +/// The effective capacity of a channel for routing purposes. +/// +/// While this may be smaller than the actual channel capacity, amounts greater than +/// [`Self::as_msat`] should not be routed through the channel. +#[must_use] +#[derive(Clone)] +#[repr(C)] +pub enum EffectiveCapacity { + /// The available liquidity in the channel known from being a channel counterparty, and thus a + /// direct hop. + ExactLiquidity { + /// Either the inbound or outbound liquidity depending on the direction, denominated in + /// millisatoshi. + liquidity_msat: u64, + }, + /// The maximum HTLC amount in one direction as advertised on the gossip network. + MaximumHTLC { + /// The maximum HTLC amount denominated in millisatoshi. + amount_msat: u64, + }, + /// The total capacity of the channel as determined by the funding transaction. + Total { + /// The funding amount denominated in millisatoshi. + capacity_msat: u64, + }, + /// A capacity sufficient to route any payment, typically used for private channels provided by + /// an invoice. + Infinite, + /// 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, +} +use lightning::routing::network_graph::EffectiveCapacity as nativeEffectiveCapacity; +impl EffectiveCapacity { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeEffectiveCapacity { + match self { + EffectiveCapacity::ExactLiquidity {ref liquidity_msat, } => { + let mut liquidity_msat_nonref = (*liquidity_msat).clone(); + nativeEffectiveCapacity::ExactLiquidity { + liquidity_msat: liquidity_msat_nonref, + } + }, + EffectiveCapacity::MaximumHTLC {ref amount_msat, } => { + let mut amount_msat_nonref = (*amount_msat).clone(); + nativeEffectiveCapacity::MaximumHTLC { + amount_msat: amount_msat_nonref, + } + }, + EffectiveCapacity::Total {ref capacity_msat, } => { + let mut capacity_msat_nonref = (*capacity_msat).clone(); + nativeEffectiveCapacity::Total { + capacity_msat: capacity_msat_nonref, + } + }, + EffectiveCapacity::Infinite => nativeEffectiveCapacity::Infinite, + EffectiveCapacity::Unknown => nativeEffectiveCapacity::Unknown, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeEffectiveCapacity { + match self { + EffectiveCapacity::ExactLiquidity {mut liquidity_msat, } => { + nativeEffectiveCapacity::ExactLiquidity { + liquidity_msat: liquidity_msat, + } + }, + EffectiveCapacity::MaximumHTLC {mut amount_msat, } => { + nativeEffectiveCapacity::MaximumHTLC { + amount_msat: amount_msat, + } + }, + EffectiveCapacity::Total {mut capacity_msat, } => { + nativeEffectiveCapacity::Total { + capacity_msat: capacity_msat, + } + }, + EffectiveCapacity::Infinite => nativeEffectiveCapacity::Infinite, + EffectiveCapacity::Unknown => nativeEffectiveCapacity::Unknown, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &nativeEffectiveCapacity) -> Self { + match native { + nativeEffectiveCapacity::ExactLiquidity {ref liquidity_msat, } => { + let mut liquidity_msat_nonref = (*liquidity_msat).clone(); + EffectiveCapacity::ExactLiquidity { + liquidity_msat: liquidity_msat_nonref, + } + }, + nativeEffectiveCapacity::MaximumHTLC {ref amount_msat, } => { + let mut amount_msat_nonref = (*amount_msat).clone(); + EffectiveCapacity::MaximumHTLC { + amount_msat: amount_msat_nonref, + } + }, + nativeEffectiveCapacity::Total {ref capacity_msat, } => { + let mut capacity_msat_nonref = (*capacity_msat).clone(); + EffectiveCapacity::Total { + capacity_msat: capacity_msat_nonref, + } + }, + nativeEffectiveCapacity::Infinite => EffectiveCapacity::Infinite, + nativeEffectiveCapacity::Unknown => EffectiveCapacity::Unknown, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeEffectiveCapacity) -> Self { + match native { + nativeEffectiveCapacity::ExactLiquidity {mut liquidity_msat, } => { + EffectiveCapacity::ExactLiquidity { + liquidity_msat: liquidity_msat, + } + }, + nativeEffectiveCapacity::MaximumHTLC {mut amount_msat, } => { + EffectiveCapacity::MaximumHTLC { + amount_msat: amount_msat, + } + }, + nativeEffectiveCapacity::Total {mut capacity_msat, } => { + EffectiveCapacity::Total { + capacity_msat: capacity_msat, + } + }, + nativeEffectiveCapacity::Infinite => EffectiveCapacity::Infinite, + nativeEffectiveCapacity::Unknown => EffectiveCapacity::Unknown, + } + } +} +/// Frees any resources used by the EffectiveCapacity +#[no_mangle] +pub extern "C" fn EffectiveCapacity_free(this_ptr: EffectiveCapacity) { } +/// Creates a copy of the EffectiveCapacity +#[no_mangle] +pub extern "C" fn EffectiveCapacity_clone(orig: &EffectiveCapacity) -> EffectiveCapacity { + orig.clone() +} +#[no_mangle] +/// Utility method to constructs a new ExactLiquidity-variant EffectiveCapacity +pub extern "C" fn EffectiveCapacity_exact_liquidity(liquidity_msat: u64) -> EffectiveCapacity { + EffectiveCapacity::ExactLiquidity { + liquidity_msat, + } +} +#[no_mangle] +/// Utility method to constructs a new MaximumHTLC-variant EffectiveCapacity +pub extern "C" fn EffectiveCapacity_maximum_htlc(amount_msat: u64) -> EffectiveCapacity { + EffectiveCapacity::MaximumHTLC { + amount_msat, + } +} +#[no_mangle] +/// Utility method to constructs a new Total-variant EffectiveCapacity +pub extern "C" fn EffectiveCapacity_total(capacity_msat: u64) -> EffectiveCapacity { + EffectiveCapacity::Total { + capacity_msat, + } +} +#[no_mangle] +/// Utility method to constructs a new Infinite-variant EffectiveCapacity +pub extern "C" fn EffectiveCapacity_infinite() -> EffectiveCapacity { + EffectiveCapacity::Infinite} +#[no_mangle] +/// Utility method to constructs a new Unknown-variant EffectiveCapacity +pub extern "C" fn EffectiveCapacity_unknown() -> EffectiveCapacity { + EffectiveCapacity::Unknown} +/// The presumed channel capacity denominated in millisatoshi for [`EffectiveCapacity::Unknown`] to +/// use when making routing decisions. + +#[no_mangle] +pub static UNKNOWN_CHANNEL_CAPACITY_MSAT: u64 = lightning::routing::network_graph::UNKNOWN_CHANNEL_CAPACITY_MSAT; +/// Returns the effective capacity denominated in millisatoshi. +#[must_use] +#[no_mangle] +pub extern "C" fn EffectiveCapacity_as_msat(this_arg: &EffectiveCapacity) -> u64 { + let mut ret = this_arg.to_native().as_msat(); + ret +} + + use lightning::routing::network_graph::RoutingFees as nativeRoutingFeesImport; pub(crate) type nativeRoutingFees = nativeRoutingFeesImport; @@ -1610,6 +1890,24 @@ pub extern "C" fn NetworkGraph_fail_node(this_arg: &NetworkGraph, mut _node_id: unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.fail_node(&_node_id.into_rust(), is_permanent) } +/// 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 is only available with the `std` feature. See +/// [`NetworkGraph::remove_stale_channels_with_time`] for `no-std` use. +#[no_mangle] +pub extern "C" fn NetworkGraph_remove_stale_channels(this_arg: &NetworkGraph) { + unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.remove_stale_channels() +} + /// 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. diff --git a/lightning-c-bindings/src/lightning/routing/router.rs b/lightning-c-bindings/src/lightning/routing/router.rs index 4e2a6f2..35a01f2 100644 --- a/lightning-c-bindings/src/lightning/routing/router.rs +++ b/lightning-c-bindings/src/lightning/routing/router.rs @@ -288,7 +288,7 @@ 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( { let mut local_val_0 = Vec::new(); for mut item in item.into_rust().drain(..) { local_val_0.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; local_val_0 }); }; unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.paths = local_val; } -/// The `payee` parameter passed to [`find_route`]. +/// 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`]. /// @@ -296,12 +296,12 @@ pub extern "C" fn Route_set_paths(this_ptr: &mut Route, mut val: crate::c_types: /// /// 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 Route_get_payee(this_ptr: &Route) -> crate::lightning::routing::router::Payee { - let mut inner_val = &mut this_ptr.get_native_mut_ref().payee; - let mut local_inner_val = crate::lightning::routing::router::Payee { 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::Payee<>) as *mut _ }, is_owned: false }; +pub extern "C" fn Route_get_payment_params(this_ptr: &Route) -> crate::lightning::routing::router::PaymentParameters { + let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_params; + 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 `payee` parameter passed to [`find_route`]. +/// 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`]. /// @@ -309,19 +309,19 @@ pub extern "C" fn Route_get_payee(this_ptr: &Route) -> crate::lightning::routing /// /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None #[no_mangle] -pub extern "C" fn Route_set_payee(this_ptr: &mut Route, mut val: crate::lightning::routing::router::Payee) { +pub extern "C" fn Route_set_payment_params(this_ptr: &mut Route, mut val: crate::lightning::routing::router::PaymentParameters) { 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) }.payee = local_val; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_params = local_val; } /// Constructs a new Route given each field #[must_use] #[no_mangle] -pub extern "C" fn Route_new(mut paths_arg: crate::c_types::derived::CVec_CVec_RouteHopZZ, mut payee_arg: crate::lightning::routing::router::Payee) -> Route { +pub extern "C" fn Route_new(mut paths_arg: crate::c_types::derived::CVec_CVec_RouteHopZZ, mut payment_params_arg: crate::lightning::routing::router::PaymentParameters) -> Route { let mut local_paths_arg = Vec::new(); for mut item in paths_arg.into_rust().drain(..) { local_paths_arg.push( { let mut local_paths_arg_0 = Vec::new(); for mut item in item.into_rust().drain(..) { local_paths_arg_0.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; local_paths_arg_0 }); }; - let mut local_payee_arg = if payee_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(payee_arg.take_inner()) } }) }; + let mut local_payment_params_arg = if payment_params_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(payment_params_arg.take_inner()) } }) }; Route { inner: ObjOps::heap_alloc(nativeRoute { paths: local_paths_arg, - payee: local_payee_arg, + payment_params: local_payment_params_arg, }), is_owned: true } } impl Clone for Route { @@ -401,7 +401,7 @@ pub extern "C" fn Route_read(ser: crate::c_types::u8slice) -> crate::c_types::de use lightning::routing::router::RouteParameters as nativeRouteParametersImport; pub(crate) type nativeRouteParameters = nativeRouteParametersImport; -/// Parameters needed to find a [`Route`] for paying a [`Payee`]. +/// Parameters needed to find a [`Route`]. /// /// Passed to [`find_route`] and also provided in [`Event::PaymentPathFailed`] for retrying a failed /// payment path. @@ -453,16 +453,16 @@ impl RouteParameters { ret } } -/// The recipient of the failed payment path. +/// The parameters of the failed payment path. #[no_mangle] -pub extern "C" fn RouteParameters_get_payee(this_ptr: &RouteParameters) -> crate::lightning::routing::router::Payee { - let mut inner_val = &mut this_ptr.get_native_mut_ref().payee; - crate::lightning::routing::router::Payee { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::routing::router::Payee<>) as *mut _) }, is_owned: false } +pub extern "C" fn RouteParameters_get_payment_params(this_ptr: &RouteParameters) -> crate::lightning::routing::router::PaymentParameters { + let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_params; + crate::lightning::routing::router::PaymentParameters { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::routing::router::PaymentParameters<>) as *mut _) }, is_owned: false } } -/// The recipient of the failed payment path. +/// The parameters of the failed payment path. #[no_mangle] -pub extern "C" fn RouteParameters_set_payee(this_ptr: &mut RouteParameters, mut val: crate::lightning::routing::router::Payee) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payee = *unsafe { Box::from_raw(val.take_inner()) }; +pub extern "C" fn RouteParameters_set_payment_params(this_ptr: &mut RouteParameters, mut val: crate::lightning::routing::router::PaymentParameters) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_params = *unsafe { Box::from_raw(val.take_inner()) }; } /// The amount in msats sent on the failed payment path. #[no_mangle] @@ -489,9 +489,9 @@ pub extern "C" fn RouteParameters_set_final_cltv_expiry_delta(this_ptr: &mut Rou /// Constructs a new RouteParameters given each field #[must_use] #[no_mangle] -pub extern "C" fn RouteParameters_new(mut payee_arg: crate::lightning::routing::router::Payee, mut final_value_msat_arg: u64, mut final_cltv_expiry_delta_arg: u32) -> RouteParameters { +pub extern "C" fn RouteParameters_new(mut payment_params_arg: crate::lightning::routing::router::PaymentParameters, mut final_value_msat_arg: u64, mut final_cltv_expiry_delta_arg: u32) -> RouteParameters { RouteParameters { inner: ObjOps::heap_alloc(nativeRouteParameters { - payee: *unsafe { Box::from_raw(payee_arg.take_inner()) }, + payment_params: *unsafe { Box::from_raw(payment_params_arg.take_inner()) }, final_value_msat: final_value_msat_arg, final_cltv_expiry_delta: final_cltv_expiry_delta_arg, }), is_owned: true } @@ -531,19 +531,23 @@ pub extern "C" fn RouteParameters_read(ser: crate::c_types::u8slice) -> crate::c let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::router::RouteParameters { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; local_res } +/// Maximum total CTLV difference we allow for a full payment path. -use lightning::routing::router::Payee as nativePayeeImport; -pub(crate) type nativePayee = nativePayeeImport; +#[no_mangle] +pub static DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA: u32 = lightning::routing::router::DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA; + +use lightning::routing::router::PaymentParameters as nativePaymentParametersImport; +pub(crate) type nativePaymentParameters = nativePaymentParametersImport; /// The recipient of a payment. #[must_use] #[repr(C)] -pub struct Payee { +pub struct PaymentParameters { /// A pointer to the opaque Rust object. /// Nearly everywhere, 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 nativePayee, + pub inner: *mut nativePaymentParameters, /// Indicates that this is the only struct which contains the same pointer. /// Rust functions which take ownership of an object provided via an argument require @@ -551,31 +555,31 @@ pub struct Payee { pub is_owned: bool, } -impl Drop for Payee { +impl Drop for PaymentParameters { fn drop(&mut self) { - if self.is_owned && !<*mut nativePayee>::is_null(self.inner) { + if self.is_owned && !<*mut nativePaymentParameters>::is_null(self.inner) { let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; } } } -/// Frees any resources used by the Payee, if is_owned is set and inner is non-NULL. +/// Frees any resources used by the PaymentParameters, if is_owned is set and inner is non-NULL. #[no_mangle] -pub extern "C" fn Payee_free(this_obj: Payee) { } +pub extern "C" fn PaymentParameters_free(this_obj: PaymentParameters) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn Payee_free_void(this_ptr: *mut c_void) { - unsafe { let _ = Box::from_raw(this_ptr as *mut nativePayee); } +pub(crate) extern "C" fn PaymentParameters_free_void(this_ptr: *mut c_void) { + unsafe { let _ = Box::from_raw(this_ptr as *mut nativePaymentParameters); } } #[allow(unused)] -impl Payee { - pub(crate) fn get_native_ref(&self) -> &'static nativePayee { +impl PaymentParameters { + pub(crate) fn get_native_ref(&self) -> &'static nativePaymentParameters { unsafe { &*ObjOps::untweak_ptr(self.inner) } } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePayee { + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePaymentParameters { 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 nativePayee { + pub(crate) fn take_inner(mut self) -> *mut nativePaymentParameters { assert!(self.is_owned); let ret = ObjOps::untweak_ptr(self.inner); self.inner = core::ptr::null_mut(); @@ -584,14 +588,14 @@ impl Payee { } /// The node id of the payee. #[no_mangle] -pub extern "C" fn Payee_get_pubkey(this_ptr: &Payee) -> crate::c_types::PublicKey { - let mut inner_val = &mut this_ptr.get_native_mut_ref().pubkey; +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 Payee_set_pubkey(this_ptr: &mut Payee, mut val: crate::c_types::PublicKey) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.pubkey = val.into_rust(); +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. /// @@ -602,7 +606,7 @@ pub extern "C" fn Payee_set_pubkey(this_ptr: &mut Payee, mut val: crate::c_types /// /// 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 Payee_get_features(this_ptr: &Payee) -> crate::lightning::ln::features::InvoiceFeatures { +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 @@ -616,54 +620,66 @@ pub extern "C" fn Payee_get_features(this_ptr: &Payee) -> crate::lightning::ln:: /// /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None #[no_mangle] -pub extern "C" fn Payee_set_features(this_ptr: &mut Payee, mut val: crate::lightning::ln::features::InvoiceFeatures) { +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. #[no_mangle] -pub extern "C" fn Payee_get_route_hints(this_ptr: &Payee) -> crate::c_types::derived::CVec_RouteHintZ { +pub extern "C" fn PaymentParameters_get_route_hints(this_ptr: &PaymentParameters) -> crate::c_types::derived::CVec_RouteHintZ { let mut inner_val = &mut this_ptr.get_native_mut_ref().route_hints; let mut local_inner_val = Vec::new(); for item in inner_val.iter() { local_inner_val.push( { crate::lightning::routing::router::RouteHint { inner: unsafe { ObjOps::nonnull_ptr_to_inner((item as *const lightning::routing::router::RouteHint<>) as *mut _) }, is_owned: false } }); }; local_inner_val.into() } /// Hints for routing to the payee, containing channels connecting the payee to public nodes. #[no_mangle] -pub extern "C" fn Payee_set_route_hints(this_ptr: &mut Payee, mut val: crate::c_types::derived::CVec_RouteHintZ) { +pub extern "C" fn PaymentParameters_set_route_hints(this_ptr: &mut PaymentParameters, mut val: crate::c_types::derived::CVec_RouteHintZ) { let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.route_hints = local_val; } /// Expiration of a payment to the payee, in seconds relative to the UNIX epoch. #[no_mangle] -pub extern "C" fn Payee_get_expiry_time(this_ptr: &Payee) -> crate::c_types::derived::COption_u64Z { +pub extern "C" fn PaymentParameters_get_expiry_time(this_ptr: &PaymentParameters) -> crate::c_types::derived::COption_u64Z { let mut inner_val = &mut this_ptr.get_native_mut_ref().expiry_time; 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 } /// Expiration of a payment to the payee, in seconds relative to the UNIX epoch. #[no_mangle] -pub extern "C" fn Payee_set_expiry_time(this_ptr: &mut Payee, mut val: crate::c_types::derived::COption_u64Z) { +pub extern "C" fn PaymentParameters_set_expiry_time(this_ptr: &mut PaymentParameters, 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) }.expiry_time = local_val; } -/// Constructs a new Payee given each field +/// The maximum total CLTV delta we accept for the route. +#[no_mangle] +pub extern "C" fn PaymentParameters_get_max_total_cltv_expiry_delta(this_ptr: &PaymentParameters) -> u32 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().max_total_cltv_expiry_delta; + *inner_val +} +/// The maximum total CLTV delta we accept for the route. +#[no_mangle] +pub extern "C" fn PaymentParameters_set_max_total_cltv_expiry_delta(this_ptr: &mut PaymentParameters, mut val: u32) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_total_cltv_expiry_delta = val; +} +/// Constructs a new PaymentParameters given each field #[must_use] #[no_mangle] -pub extern "C" fn Payee_new(mut pubkey_arg: crate::c_types::PublicKey, mut features_arg: crate::lightning::ln::features::InvoiceFeatures, mut route_hints_arg: crate::c_types::derived::CVec_RouteHintZ, mut expiry_time_arg: crate::c_types::derived::COption_u64Z) -> Payee { +pub extern "C" fn PaymentParameters_new(mut payee_pubkey_arg: crate::c_types::PublicKey, mut features_arg: crate::lightning::ln::features::InvoiceFeatures, mut route_hints_arg: crate::c_types::derived::CVec_RouteHintZ, mut expiry_time_arg: crate::c_types::derived::COption_u64Z, mut max_total_cltv_expiry_delta_arg: u32) -> PaymentParameters { let mut local_features_arg = if features_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(features_arg.take_inner()) } }) }; let mut local_route_hints_arg = Vec::new(); for mut item in route_hints_arg.into_rust().drain(..) { local_route_hints_arg.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; let mut local_expiry_time_arg = if expiry_time_arg.is_some() { Some( { expiry_time_arg.take() }) } else { None }; - Payee { inner: ObjOps::heap_alloc(nativePayee { - pubkey: pubkey_arg.into_rust(), + PaymentParameters { inner: ObjOps::heap_alloc(nativePaymentParameters { + payee_pubkey: payee_pubkey_arg.into_rust(), features: local_features_arg, route_hints: local_route_hints_arg, expiry_time: local_expiry_time_arg, + max_total_cltv_expiry_delta: max_total_cltv_expiry_delta_arg, }), is_owned: true } } -impl Clone for Payee { +impl Clone for PaymentParameters { fn clone(&self) -> Self { Self { - inner: if <*mut nativePayee>::is_null(self.inner) { core::ptr::null_mut() } else { + inner: if <*mut nativePaymentParameters>::is_null(self.inner) { core::ptr::null_mut() } else { ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, is_owned: true, } @@ -671,17 +687,17 @@ impl Clone for Payee { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn Payee_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativePayee)).clone() })) as *mut c_void +pub(crate) extern "C" fn PaymentParameters_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativePaymentParameters)).clone() })) as *mut c_void } #[no_mangle] -/// Creates a copy of the Payee -pub extern "C" fn Payee_clone(orig: &Payee) -> Payee { +/// Creates a copy of the PaymentParameters +pub extern "C" fn PaymentParameters_clone(orig: &PaymentParameters) -> PaymentParameters { orig.clone() } -/// Checks if two Payees contain equal inner contents. +/// Checks if two PaymentParameterss contain equal inner contents. #[no_mangle] -pub extern "C" fn Payee_hash(o: &Payee) -> u64 { +pub extern "C" fn PaymentParameters_hash(o: &PaymentParameters) -> 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)] @@ -689,45 +705,45 @@ pub extern "C" fn Payee_hash(o: &Payee) -> u64 { core::hash::Hash::hash(o.get_native_ref(), &mut hasher); core::hash::Hasher::finish(&hasher) } -/// Checks if two Payees contain equal inner contents. +/// Checks if two PaymentParameterss contain equal inner contents. /// This ignores pointers and is_owned flags and looks at the values in fields. /// Two objects with NULL inner values will be considered "equal" here. #[no_mangle] -pub extern "C" fn Payee_eq(a: &Payee, b: &Payee) -> bool { +pub extern "C" fn PaymentParameters_eq(a: &PaymentParameters, b: &PaymentParameters) -> 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 Payee object into a byte array which can be read by Payee_read -pub extern "C" fn Payee_write(obj: &Payee) -> crate::c_types::derived::CVec_u8Z { +/// Serialize the PaymentParameters object into a byte array which can be read by PaymentParameters_read +pub extern "C" fn PaymentParameters_write(obj: &PaymentParameters) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) } #[no_mangle] -pub(crate) extern "C" fn Payee_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePayee) }) +pub(crate) extern "C" fn PaymentParameters_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePaymentParameters) }) } #[no_mangle] -/// Read a Payee from a byte array, created by Payee_write -pub extern "C" fn Payee_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PayeeDecodeErrorZ { - let res: Result = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::router::Payee { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; +/// Read a PaymentParameters from a byte array, created by PaymentParameters_write +pub extern "C" fn PaymentParameters_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PaymentParametersDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::router::PaymentParameters { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; local_res } /// Creates a payee with the node id of the given `pubkey`. #[must_use] #[no_mangle] -pub extern "C" fn Payee_from_node_id(mut pubkey: crate::c_types::PublicKey) -> Payee { - let mut ret = lightning::routing::router::Payee::from_node_id(pubkey.into_rust()); - Payee { inner: ObjOps::heap_alloc(ret), is_owned: true } +pub extern "C" fn PaymentParameters_from_node_id(mut payee_pubkey: crate::c_types::PublicKey) -> PaymentParameters { + let mut ret = lightning::routing::router::PaymentParameters::from_node_id(payee_pubkey.into_rust()); + PaymentParameters { inner: ObjOps::heap_alloc(ret), is_owned: true } } /// Creates a payee with the node id of the given `pubkey` to use for keysend payments. #[must_use] #[no_mangle] -pub extern "C" fn Payee_for_keysend(mut pubkey: crate::c_types::PublicKey) -> Payee { - let mut ret = lightning::routing::router::Payee::for_keysend(pubkey.into_rust()); - Payee { inner: ObjOps::heap_alloc(ret), is_owned: true } +pub extern "C" fn PaymentParameters_for_keysend(mut payee_pubkey: crate::c_types::PublicKey) -> PaymentParameters { + let mut ret = lightning::routing::router::PaymentParameters::for_keysend(payee_pubkey.into_rust()); + PaymentParameters { inner: ObjOps::heap_alloc(ret), is_owned: true } } @@ -1076,9 +1092,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, params: &crate::lightning::routing::router::RouteParameters, network: &crate::lightning::routing::network_graph::NetworkGraph, first_hops: *mut crate::c_types::derived::CVec_ChannelDetailsZ, mut logger: crate::lightning::util::logger::Logger, scorer: &crate::lightning::routing::scoring::Score) -> 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: &crate::lightning::routing::network_graph::NetworkGraph, first_hops: *mut crate::c_types::derived::CVec_ChannelDetailsZ, mut logger: crate::lightning::util::logger::Logger, scorer: &crate::lightning::routing::scoring::Score) -> 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(), params.get_native_ref(), network.get_native_ref(), local_first_hops, logger, scorer); + let mut ret = lightning::routing::router::find_route::(&our_node_pubkey.into_rust(), route_params.get_native_ref(), network.get_native_ref(), local_first_hops, logger, scorer); 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 df292b1..31676d0 100644 --- a/lightning-c-bindings/src/lightning/routing/scoring.rs +++ b/lightning-c-bindings/src/lightning/routing/scoring.rs @@ -8,8 +8,8 @@ //! Utilities for scoring payment channels. //! -//! [`Scorer`] may be given to [`find_route`] to score payment channels during path finding when a -//! custom [`Score`] implementation is not needed. +//! [`ProbabilisticScorer`] may be given to [`find_route`] to score payment channels during path +//! finding when a custom [`Score`] implementation is not needed. //! //! # Example //! @@ -18,7 +18,7 @@ //! # //! # use lightning::routing::network_graph::NetworkGraph; //! # use lightning::routing::router::{RouteParameters, find_route}; -//! # use lightning::routing::scoring::{Scorer, ScoringParameters}; +//! # use lightning::routing::scoring::{ProbabilisticScorer, ProbabilisticScoringParameters, Scorer, ScoringParameters}; //! # use lightning::util::logger::{Logger, Record}; //! # use secp256k1::key::PublicKey; //! # @@ -26,20 +26,21 @@ //! # impl Logger for FakeLogger { //! # fn log(&self, record: &Record) { unimplemented!() } //! # } -//! # fn find_scored_route(payer: PublicKey, params: RouteParameters, network_graph: NetworkGraph) { +//! # fn find_scored_route(payer: PublicKey, route_params: RouteParameters, network_graph: NetworkGraph) { //! # let logger = FakeLogger {}; //! # //! // Use the default channel penalties. -//! let scorer = Scorer::default(); +//! let params = ProbabilisticScoringParameters::default(); +//! let scorer = ProbabilisticScorer::new(params, &network_graph); //! //! // Or use custom channel penalties. -//! let scorer = Scorer::new(ScoringParameters { -//! base_penalty_msat: 1000, -//! failure_penalty_msat: 2 * 1024 * 1000, -//! ..ScoringParameters::default() -//! }); +//! let params = ProbabilisticScoringParameters { +//! liquidity_penalty_multiplier_msat: 2 * 1000, +//! ..ProbabilisticScoringParameters::default() +//! }; +//! let scorer = ProbabilisticScorer::new(params, &network_graph); //! -//! let route = find_route(&payer, ¶ms, &network_graph, None, &logger, &scorer); +//! let route = find_route(&payer, &route_params, &network_graph, None, &logger, &scorer); //! # } //! ``` //! @@ -69,17 +70,13 @@ pub struct Score { /// 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 which are also being considered for use in - /// the same payment) is given by `channel_capacity_msat`. It may be guessed from various - /// sources or assumed from no data at all. - /// - /// For hints provided in the invoice, we assume the channel has sufficient capacity to accept - /// the invoice's full amount, and provide a `channel_capacity_msat` of `None`. In all other - /// cases it is set to `Some`, even if we're guessing at the channel value. - /// - /// Your code should be overflow-safe through a `channel_capacity_msat` of 21 million BTC. + /// 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. #[must_use] - pub channel_penalty_msat: extern "C" fn (this_arg: *const c_void, short_channel_id: u64, send_amt_msat: u64, channel_capacity_msat: crate::c_types::derived::COption_u64Z, source: &crate::lightning::routing::network_graph::NodeId, target: &crate::lightning::routing::network_graph::NodeId) -> u64, + pub channel_penalty_msat: extern "C" fn (this_arg: *const c_void, short_channel_id: u64, send_amt_msat: u64, capacity_msat: u64, source: &crate::lightning::routing::network_graph::NodeId, target: &crate::lightning::routing::network_graph::NodeId) -> u64, /// Handles updating channel penalties after failing to route through a channel. pub payment_path_failed: extern "C" fn (this_arg: *mut c_void, path: crate::c_types::derived::CVec_RouteHopZ, short_channel_id: u64), /// Handles updating channel penalties after successfully routing along a path. @@ -112,9 +109,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 send_amt_msat: u64, mut channel_capacity_msat: Option, mut source: &lightning::routing::network_graph::NodeId, mut target: &lightning::routing::network_graph::NodeId) -> u64 { - let mut local_channel_capacity_msat = if channel_capacity_msat.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { channel_capacity_msat.unwrap() }) }; - let mut ret = (self.channel_penalty_msat)(self.this_arg, short_channel_id, send_amt_msat, local_channel_capacity_msat, &crate::lightning::routing::network_graph::NodeId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((source as *const lightning::routing::network_graph::NodeId<>) as *mut _) }, is_owned: false }, &crate::lightning::routing::network_graph::NodeId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((target as *const lightning::routing::network_graph::NodeId<>) as *mut _) }, is_owned: false }); + fn channel_penalty_msat(&self, mut short_channel_id: u64, mut send_amt_msat: u64, mut capacity_msat: u64, mut source: &lightning::routing::network_graph::NodeId, mut target: &lightning::routing::network_graph::NodeId) -> u64 { + let mut ret = (self.channel_penalty_msat)(self.this_arg, short_channel_id, send_amt_msat, capacity_msat, &crate::lightning::routing::network_graph::NodeId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((source as *const lightning::routing::network_graph::NodeId<>) as *mut _) }, is_owned: false }, &crate::lightning::routing::network_graph::NodeId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((target as *const lightning::routing::network_graph::NodeId<>) as *mut _) }, is_owned: false }); ret } fn payment_path_failed(&mut self, mut path: &[&lightning::routing::router::RouteHop], mut short_channel_id: u64) { @@ -263,6 +259,119 @@ pub extern "C" fn MultiThreadedLockableScore_new(mut score: crate::lightning::ro } +use lightning::routing::scoring::FixedPenaltyScorer as nativeFixedPenaltyScorerImport; +pub(crate) type nativeFixedPenaltyScorer = nativeFixedPenaltyScorerImport; + +/// [`Score`] implementation that uses a fixed penalty. +#[must_use] +#[repr(C)] +pub struct FixedPenaltyScorer { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, 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 nativeFixedPenaltyScorer, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust 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 FixedPenaltyScorer { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeFixedPenaltyScorer>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the FixedPenaltyScorer, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn FixedPenaltyScorer_free(this_obj: FixedPenaltyScorer) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn FixedPenaltyScorer_free_void(this_ptr: *mut c_void) { + unsafe { let _ = Box::from_raw(this_ptr as *mut nativeFixedPenaltyScorer); } +} +#[allow(unused)] +impl FixedPenaltyScorer { + pub(crate) fn get_native_ref(&self) -> &'static nativeFixedPenaltyScorer { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeFixedPenaltyScorer { + 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 nativeFixedPenaltyScorer { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +#[no_mangle] +/// Serialize the FixedPenaltyScorer object into a byte array which can be read by FixedPenaltyScorer_read +pub extern "C" fn FixedPenaltyScorer_write(obj: &FixedPenaltyScorer) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[no_mangle] +pub(crate) extern "C" fn FixedPenaltyScorer_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFixedPenaltyScorer) }) +} +#[no_mangle] +/// Read a FixedPenaltyScorer from a byte array, created by FixedPenaltyScorer_write +pub extern "C" fn FixedPenaltyScorer_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FixedPenaltyScorerDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::scoring::FixedPenaltyScorer { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; + local_res +} +/// Creates a new scorer using `penalty_msat`. +#[must_use] +#[no_mangle] +pub extern "C" fn FixedPenaltyScorer_with_penalty(mut penalty_msat: u64) -> FixedPenaltyScorer { + let mut ret = lightning::routing::scoring::FixedPenaltyScorer::with_penalty(penalty_msat); + FixedPenaltyScorer { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +impl From for crate::lightning::routing::scoring::Score { + fn from(obj: nativeFixedPenaltyScorer) -> Self { + let mut rust_obj = FixedPenaltyScorer { inner: ObjOps::heap_alloc(obj), is_owned: true }; + let mut ret = FixedPenaltyScorer_as_Score(&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(FixedPenaltyScorer_free_void); + ret + } +} +/// Constructs a new Score which calls the relevant methods on this_arg. +/// This copies the `inner` pointer in this_arg and thus the returned Score must be freed before this_arg is +#[no_mangle] +pub extern "C" fn FixedPenaltyScorer_as_Score(this_arg: &FixedPenaltyScorer) -> crate::lightning::routing::scoring::Score { + crate::lightning::routing::scoring::Score { + this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, + free: None, + channel_penalty_msat: FixedPenaltyScorer_Score_channel_penalty_msat, + payment_path_failed: FixedPenaltyScorer_Score_payment_path_failed, + payment_path_successful: FixedPenaltyScorer_Score_payment_path_successful, + write: FixedPenaltyScorer_write_void, + } +} + +#[must_use] +extern "C" fn FixedPenaltyScorer_Score_channel_penalty_msat(this_arg: *const c_void, unused_0: u64, unused_1: u64, unused_2: u64, unused_3: &crate::lightning::routing::network_graph::NodeId, unused_4: &crate::lightning::routing::network_graph::NodeId) -> u64 { + let mut ret = >::channel_penalty_msat(unsafe { &mut *(this_arg as *mut nativeFixedPenaltyScorer) }, unused_0, unused_1, unused_2, unused_3.get_native_ref(), unused_4.get_native_ref()); + ret +} +extern "C" fn FixedPenaltyScorer_Score_payment_path_failed(this_arg: *mut c_void, mut _path: crate::c_types::derived::CVec_RouteHopZ, mut _short_channel_id: u64) { + let mut local__path = Vec::new(); for mut item in _path.as_slice().iter() { local__path.push( { item.get_native_ref() }); }; + >::payment_path_failed(unsafe { &mut *(this_arg as *mut nativeFixedPenaltyScorer) }, &local__path[..], _short_channel_id) +} +extern "C" fn FixedPenaltyScorer_Score_payment_path_successful(this_arg: *mut c_void, mut _path: crate::c_types::derived::CVec_RouteHopZ) { + let mut local__path = Vec::new(); for mut item in _path.as_slice().iter() { local__path.push( { item.get_native_ref() }); }; + >::payment_path_successful(unsafe { &mut *(this_arg as *mut nativeFixedPenaltyScorer) }, &local__path[..]) +} + + use lightning::routing::scoring::Scorer as nativeScorerImport; pub(crate) type nativeScorer = nativeScorerImport; @@ -271,7 +380,12 @@ pub(crate) type nativeScorer = nativeScorerImport; /// Used to apply a fixed penalty to each channel, thus avoiding long paths when shorter paths with /// slightly higher fees are available. Will further penalize channels that fail to relay payments. /// -/// See [module-level documentation] for usage. +/// See [module-level documentation] for usage and [`ScoringParameters`] for customization. +/// +/// # Note +/// +/// Mixing the `no-std` feature between serialization and deserialization results in undefined +/// behavior. /// /// [module-level documentation]: crate::routing::scoring #[must_use] @@ -460,6 +574,8 @@ pub extern "C" fn ScoringParameters_set_overuse_penalty_msat_per_1024th(this_ptr /// /// Successfully routing through a channel will immediately cut the penalty in half as well. /// +/// Default value: 1 hour +/// /// # Note /// /// When built with the `no-std` feature, time will never elapse. Therefore, this penalty will @@ -476,6 +592,8 @@ pub extern "C" fn ScoringParameters_get_failure_penalty_half_life(this_ptr: &Sco /// /// Successfully routing through a channel will immediately cut the penalty in half as well. /// +/// Default value: 1 hour +/// /// # Note /// /// When built with the `no-std` feature, time will never elapse. Therefore, this penalty will @@ -559,9 +677,8 @@ pub extern "C" fn Scorer_as_Score(this_arg: &Scorer) -> crate::lightning::routin } #[must_use] -extern "C" fn Scorer_Score_channel_penalty_msat(this_arg: *const c_void, mut short_channel_id: u64, mut send_amt_msat: u64, mut chan_capacity_opt: crate::c_types::derived::COption_u64Z, _source: &crate::lightning::routing::network_graph::NodeId, _target: &crate::lightning::routing::network_graph::NodeId) -> u64 { - let mut local_chan_capacity_opt = if chan_capacity_opt.is_some() { Some( { chan_capacity_opt.take() }) } else { None }; - let mut ret = >::channel_penalty_msat(unsafe { &mut *(this_arg as *mut nativeScorer) }, short_channel_id, send_amt_msat, local_chan_capacity_opt, _source.get_native_ref(), _target.get_native_ref()); +extern "C" fn Scorer_Score_channel_penalty_msat(this_arg: *const c_void, mut short_channel_id: u64, mut send_amt_msat: u64, mut capacity_msat: u64, _source: &crate::lightning::routing::network_graph::NodeId, _target: &crate::lightning::routing::network_graph::NodeId) -> u64 { + let mut ret = >::channel_penalty_msat(unsafe { &mut *(this_arg as *mut nativeScorer) }, short_channel_id, send_amt_msat, capacity_msat, _source.get_native_ref(), _target.get_native_ref()); ret } extern "C" fn Scorer_Score_payment_path_failed(this_arg: *mut c_void, mut _path: crate::c_types::derived::CVec_RouteHopZ, mut short_channel_id: u64) { @@ -589,6 +706,177 @@ pub extern "C" fn Scorer_read(ser: crate::c_types::u8slice) -> crate::c_types::d let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::scoring::Scorer { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; local_res } + +use lightning::routing::scoring::ProbabilisticScoringParameters as nativeProbabilisticScoringParametersImport; +pub(crate) type nativeProbabilisticScoringParameters = nativeProbabilisticScoringParametersImport; + +/// Parameters for configuring [`ProbabilisticScorer`]. +#[must_use] +#[repr(C)] +pub struct ProbabilisticScoringParameters { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, 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, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust 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 ProbabilisticScoringParameters { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeProbabilisticScoringParameters>::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. +#[no_mangle] +pub extern "C" fn ProbabilisticScoringParameters_free(this_obj: 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_free_void(this_ptr: *mut c_void) { + unsafe { let _ = Box::from_raw(this_ptr as *mut nativeProbabilisticScoringParameters); } +} +#[allow(unused)] +impl ProbabilisticScoringParameters { + pub(crate) fn get_native_ref(&self) -> &'static nativeProbabilisticScoringParameters { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeProbabilisticScoringParameters { + 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 { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } +} +/// A multiplier used to determine the amount in msats willing to be paid to avoid routing +/// through a channel, as per multiplying by the negative `log10` of the channel's success +/// probability for a payment. +/// +/// The success probability is determined by the effective channel capacity, the payment amount, +/// and knowledge learned from prior successful and unsuccessful payments. The lower bound of +/// the success probability is 0.01, effectively limiting the penalty to the range +/// `0..=2*liquidity_penalty_multiplier_msat`. The knowledge learned is decayed over time based +/// on [`liquidity_offset_half_life`]. +/// +/// Default value: 10,000 msat +/// +/// [`liquidity_offset_half_life`]: Self::liquidity_offset_half_life +#[no_mangle] +pub extern "C" fn ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat(this_ptr: &ProbabilisticScoringParameters) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().liquidity_penalty_multiplier_msat; + *inner_val +} +/// A multiplier used to determine the amount in msats willing to be paid to avoid routing +/// through a channel, as per multiplying by the negative `log10` of the channel's success +/// probability for a payment. +/// +/// The success probability is determined by the effective channel capacity, the payment amount, +/// and knowledge learned from prior successful and unsuccessful payments. The lower bound of +/// the success probability is 0.01, effectively limiting the penalty to the range +/// `0..=2*liquidity_penalty_multiplier_msat`. The knowledge learned is decayed over time based +/// on [`liquidity_offset_half_life`]. +/// +/// Default value: 10,000 msat +/// +/// [`liquidity_offset_half_life`]: Self::liquidity_offset_half_life +#[no_mangle] +pub extern "C" fn ProbabilisticScoringParameters_set_liquidity_penalty_multiplier_msat(this_ptr: &mut ProbabilisticScoringParameters, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.liquidity_penalty_multiplier_msat = val; +} +/// The time required to elapse before any knowledge learned about channel liquidity balances is +/// cut in half. +/// +/// The bounds are defined in terms of offsets and are initially zero. Increasing the offsets +/// gives tighter bounds on the channel liquidity balance. Thus, halving the offsets decreases +/// the certainty of the channel liquidity balance. +/// +/// Default value: 1 hour +/// +/// # 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() +} +/// The time required to elapse before any knowledge learned about channel liquidity balances is +/// cut in half. +/// +/// The bounds are defined in terms of offsets and are initially zero. Increasing the offsets +/// gives tighter bounds on the channel liquidity balance. Thus, halving the offsets decreases +/// the certainty of the channel liquidity balance. +/// +/// Default value: 1 hour +/// +/// # 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); +} +/// Constructs a new ProbabilisticScoringParameters given each field +#[must_use] +#[no_mangle] +pub extern "C" fn ProbabilisticScoringParameters_new(mut liquidity_penalty_multiplier_msat_arg: u64, mut liquidity_offset_half_life_arg: u64) -> ProbabilisticScoringParameters { + ProbabilisticScoringParameters { inner: ObjOps::heap_alloc(nativeProbabilisticScoringParameters { + liquidity_penalty_multiplier_msat: liquidity_penalty_multiplier_msat_arg, + liquidity_offset_half_life: core::time::Duration::from_secs(liquidity_offset_half_life_arg), + }), is_owned: true } +} +impl Clone for ProbabilisticScoringParameters { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeProbabilisticScoringParameters>::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 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 +} +#[no_mangle] +/// Creates a copy of the ProbabilisticScoringParameters +pub extern "C" fn ProbabilisticScoringParameters_clone(orig: &ProbabilisticScoringParameters) -> ProbabilisticScoringParameters { + orig.clone() +} +#[no_mangle] +/// Serialize the ProbabilisticScoringParameters object into a byte array which can be read by ProbabilisticScoringParameters_read +pub extern "C" fn ProbabilisticScoringParameters_write(obj: &ProbabilisticScoringParameters) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[no_mangle] +pub(crate) extern "C" fn ProbabilisticScoringParameters_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeProbabilisticScoringParameters) }) +} +#[no_mangle] +/// Read a ProbabilisticScoringParameters from a byte array, created by ProbabilisticScoringParameters_write +pub extern "C" fn ProbabilisticScoringParameters_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ProbabilisticScoringParametersDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::scoring::ProbabilisticScoringParameters { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; + local_res +} +/// 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 } +} mod time { use alloc::str::FromStr; diff --git a/lightning-c-bindings/src/lightning/util/config.rs b/lightning-c-bindings/src/lightning/util/config.rs index e8c7546..bf1972f 100644 --- a/lightning-c-bindings/src/lightning/util/config.rs +++ b/lightning-c-bindings/src/lightning/util/config.rs @@ -946,16 +946,52 @@ pub extern "C" fn UserConfig_get_accept_inbound_channels(this_ptr: &UserConfig) pub extern "C" fn UserConfig_set_accept_inbound_channels(this_ptr: &mut UserConfig, mut val: bool) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.accept_inbound_channels = val; } +/// If this is set to true, the user needs to manually accept inbound requests to open a new +/// channel. +/// +/// When set to true, [`Event::OpenChannelRequest`] will be triggered once a request to open a +/// new inbound channel is received through a [`msgs::OpenChannel`] message. In that case, a +/// [`msgs::AcceptChannel`] message will not be sent back to the counterparty node unless the +/// user explicitly chooses to accept the request. +/// +/// Default value: false. +/// +/// [`Event::OpenChannelRequest`]: crate::util::events::Event::OpenChannelRequest +/// [`msgs::OpenChannel`]: crate::ln::msgs::OpenChannel +/// [`msgs::AcceptChannel`]: crate::ln::msgs::AcceptChannel +#[no_mangle] +pub extern "C" fn UserConfig_get_manually_accept_inbound_channels(this_ptr: &UserConfig) -> bool { + let mut inner_val = &mut this_ptr.get_native_mut_ref().manually_accept_inbound_channels; + *inner_val +} +/// If this is set to true, the user needs to manually accept inbound requests to open a new +/// channel. +/// +/// When set to true, [`Event::OpenChannelRequest`] will be triggered once a request to open a +/// new inbound channel is received through a [`msgs::OpenChannel`] message. In that case, a +/// [`msgs::AcceptChannel`] message will not be sent back to the counterparty node unless the +/// user explicitly chooses to accept the request. +/// +/// Default value: false. +/// +/// [`Event::OpenChannelRequest`]: crate::util::events::Event::OpenChannelRequest +/// [`msgs::OpenChannel`]: crate::ln::msgs::OpenChannel +/// [`msgs::AcceptChannel`]: crate::ln::msgs::AcceptChannel +#[no_mangle] +pub extern "C" fn UserConfig_set_manually_accept_inbound_channels(this_ptr: &mut UserConfig, mut val: bool) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.manually_accept_inbound_channels = val; +} /// Constructs a new UserConfig given each field #[must_use] #[no_mangle] -pub extern "C" fn UserConfig_new(mut own_channel_config_arg: crate::lightning::util::config::ChannelHandshakeConfig, mut peer_channel_config_limits_arg: crate::lightning::util::config::ChannelHandshakeLimits, mut channel_options_arg: crate::lightning::util::config::ChannelConfig, mut accept_forwards_to_priv_channels_arg: bool, mut accept_inbound_channels_arg: bool) -> UserConfig { +pub extern "C" fn UserConfig_new(mut own_channel_config_arg: crate::lightning::util::config::ChannelHandshakeConfig, mut peer_channel_config_limits_arg: crate::lightning::util::config::ChannelHandshakeLimits, mut channel_options_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) -> UserConfig { UserConfig { inner: ObjOps::heap_alloc(nativeUserConfig { own_channel_config: *unsafe { Box::from_raw(own_channel_config_arg.take_inner()) }, peer_channel_config_limits: *unsafe { Box::from_raw(peer_channel_config_limits_arg.take_inner()) }, channel_options: *unsafe { Box::from_raw(channel_options_arg.take_inner()) }, accept_forwards_to_priv_channels: accept_forwards_to_priv_channels_arg, accept_inbound_channels: accept_inbound_channels_arg, + manually_accept_inbound_channels: manually_accept_inbound_channels_arg, }), is_owned: true } } impl Clone for UserConfig { diff --git a/lightning-c-bindings/src/lightning/util/events.rs b/lightning-c-bindings/src/lightning/util/events.rs index e93bd66..c284ddc 100644 --- a/lightning-c-bindings/src/lightning/util/events.rs +++ b/lightning-c-bindings/src/lightning/util/events.rs @@ -441,7 +441,7 @@ pub enum Event { /// Note that this does *not* indicate that all paths for an MPP payment have failed, see /// [`Event::PaymentFailed`] and [`all_paths_failed`]. /// - /// [`all_paths_failed`]: Self::all_paths_failed + /// [`all_paths_failed`]: Self::PaymentPathFailed::all_paths_failed PaymentPathFailed { /// The id returned by [`ChannelManager::send_payment`] and used with /// [`ChannelManager::retry_payment`] and [`ChannelManager::abandon_payment`]. @@ -610,6 +610,34 @@ pub enum Event { /// May contain a closed channel if the HTLC sent along the path was fulfilled on chain. path: crate::c_types::derived::CVec_RouteHopZ, }, + /// 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_channel`]. + /// + /// 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_channel`]: crate::ln::channelmanager::ChannelManager::force_close_channel + /// [`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 with [`ChannelManager::accept_inbound_channel`] to accept, + /// or to [`ChannelManager::force_close_channel`] to reject. + /// + /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel + /// [`ChannelManager::force_close_channel`]: crate::ln::channelmanager::ChannelManager::force_close_channel + temporary_channel_id: crate::c_types::ThirtyTwoBytes, + /// The node_id of the counterparty requesting to open the channel. + 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, + }, } use lightning::util::events::Event as nativeEvent; impl Event { @@ -737,6 +765,18 @@ impl Event { path: local_path_nonref, } }, + Event::OpenChannelRequest {ref temporary_channel_id, ref counterparty_node_id, ref funding_satoshis, ref push_msat, } => { + let mut temporary_channel_id_nonref = (*temporary_channel_id).clone(); + let mut counterparty_node_id_nonref = (*counterparty_node_id).clone(); + let mut funding_satoshis_nonref = (*funding_satoshis).clone(); + let mut push_msat_nonref = (*push_msat).clone(); + 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, + } + }, } } #[allow(unused)] @@ -830,6 +870,14 @@ impl Event { path: local_path, } }, + Event::OpenChannelRequest {mut temporary_channel_id, mut counterparty_node_id, mut funding_satoshis, mut push_msat, } => { + 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, + } + }, } } #[allow(unused)] @@ -956,6 +1004,18 @@ impl Event { path: local_path_nonref.into(), } }, + nativeEvent::OpenChannelRequest {ref temporary_channel_id, ref counterparty_node_id, ref funding_satoshis, ref push_msat, } => { + let mut temporary_channel_id_nonref = (*temporary_channel_id).clone(); + let mut counterparty_node_id_nonref = (*counterparty_node_id).clone(); + let mut funding_satoshis_nonref = (*funding_satoshis).clone(); + let mut push_msat_nonref = (*push_msat).clone(); + 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, + } + }, } } #[allow(unused)] @@ -1049,6 +1109,14 @@ impl Event { path: local_path.into(), } }, + nativeEvent::OpenChannelRequest {mut temporary_channel_id, mut counterparty_node_id, mut funding_satoshis, mut push_msat, } => { + 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, + } + }, } } } @@ -1160,6 +1228,16 @@ pub extern "C" fn Event_payment_path_successful(payment_id: crate::c_types::Thir } } #[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) -> Event { + Event::OpenChannelRequest { + temporary_channel_id, + counterparty_node_id, + funding_satoshis, + push_msat, + } +} +#[no_mangle] /// Serialize the Event object into a byte array which can be read by Event_read pub extern "C" fn Event_write(obj: &Event) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(&unsafe { &*obj }.to_native()) diff --git a/lightning-c-bindings/src/lightning/util/invoice.rs b/lightning-c-bindings/src/lightning/util/invoice.rs new file mode 100644 index 0000000..9103429 --- /dev/null +++ b/lightning-c-bindings/src/lightning/util/invoice.rs @@ -0,0 +1,27 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//! Low level invoice utilities. + +use alloc::str::FromStr; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + +/// Construct the invoice's HRP and signatureless data into a preimage to be hashed. +#[no_mangle] +pub extern "C" fn construct_invoice_preimage(mut hrp_bytes: crate::c_types::u8slice, mut data_without_signature: crate::c_types::derived::CVec_u5Z) -> crate::c_types::derived::CVec_u8Z { + let mut local_data_without_signature = Vec::new(); for mut item in data_without_signature.into_rust().drain(..) { local_data_without_signature.push( { item.into() }); }; + let mut ret = lightning::util::invoice::construct_invoice_preimage(hrp_bytes.to_slice(), &local_data_without_signature[..]); + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { item }); }; + local_ret.into() +} + diff --git a/lightning-c-bindings/src/lightning/util/mod.rs b/lightning-c-bindings/src/lightning/util/mod.rs index c80ae77..ea8cd46 100644 --- a/lightning-c-bindings/src/lightning/util/mod.rs +++ b/lightning-c-bindings/src/lightning/util/mod.rs @@ -20,6 +20,7 @@ pub mod events; pub mod errors; pub mod ser; pub mod message_signing; +pub mod invoice; pub mod logger; pub mod config; mod fuzz_wrappers { @@ -153,6 +154,17 @@ use crate::c_types::*; #[cfg(feature="no-std")] use alloc::{vec::Vec, boxed::Box}; +mod fake_scid { + +use alloc::str::FromStr; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + +} } mod macro_logger { @@ -165,3 +177,14 @@ use crate::c_types::*; use alloc::{vec::Vec, boxed::Box}; } +mod crypto { + +use alloc::str::FromStr; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + +} diff --git a/lightning-c-bindings/src/lightning_invoice/mod.rs b/lightning-c-bindings/src/lightning_invoice/mod.rs index 12845c6..760da32 100644 --- a/lightning-c-bindings/src/lightning_invoice/mod.rs +++ b/lightning-c-bindings/src/lightning_invoice/mod.rs @@ -97,22 +97,22 @@ 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 { - format!("{}", o.get_native_ref()).into() + 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 { - format!("{}", o.get_native_ref()).into() + alloc::format!("{}", o.get_native_ref()).into() } #[no_mangle] /// Get the string representation of a Currency object pub extern "C" fn Currency_to_str(o: &crate::lightning_invoice::Currency) -> Str { - format!("{}", &o.to_native()).into() + alloc::format!("{}", &o.to_native()).into() } #[no_mangle] /// Get the string representation of a SiPrefix object pub extern "C" fn SiPrefix_to_str(o: &crate::lightning_invoice::SiPrefix) -> Str { - format!("{}", &o.to_native()).into() + alloc::format!("{}", &o.to_native()).into() } } mod tb { @@ -126,9 +126,37 @@ use crate::c_types::*; use alloc::{vec::Vec, boxed::Box}; } +mod prelude { + +use alloc::str::FromStr; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + +} +mod sync { + +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}; + +} +/// The maximum timestamp as [`Duration::as_secs`] since the Unix epoch allowed by [`BOLT 11`]. +/// +/// [BOLT 11]: https://github.com/lightning/bolts/blob/master/11-payment-encoding.md + +#[no_mangle] +pub static MAX_TIMESTAMP: u64 = lightning_invoice::MAX_TIMESTAMP; /// Default expiry time as defined by [BOLT 11]. /// -/// [BOLT 11]: https://github.com/lightningnetwork/lightning-rfc/blob/master/11-payment-encoding.md +/// [BOLT 11]: https://github.com/lightning/bolts/blob/master/11-payment-encoding.md #[no_mangle] pub static DEFAULT_EXPIRY_TIME: u64 = lightning_invoice::DEFAULT_EXPIRY_TIME; @@ -137,29 +165,11 @@ pub static DEFAULT_EXPIRY_TIME: u64 = lightning_invoice::DEFAULT_EXPIRY_TIME; /// Note that this is *not* the same value as rust-lightning's minimum CLTV expiry, which is /// provided in [`MIN_FINAL_CLTV_EXPIRY`]. /// -/// [BOLT 11]: https://github.com/lightningnetwork/lightning-rfc/blob/master/11-payment-encoding.md +/// [BOLT 11]: https://github.com/lightning/bolts/blob/master/11-payment-encoding.md /// [`MIN_FINAL_CLTV_EXPIRY`]: lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY #[no_mangle] pub static DEFAULT_MIN_FINAL_CLTV_EXPIRY: u64 = lightning_invoice::DEFAULT_MIN_FINAL_CLTV_EXPIRY; -/// **Call this function on startup to ensure that all assumptions about the platform are valid.** -/// -/// Unfortunately we have to make assumptions about the upper bounds of the `SystemTime` type on -/// your platform which we can't fully verify at compile time and which isn't part of it's contract. -/// To our best knowledge our assumptions hold for all platforms officially supported by rust, but -/// since this check is fast we recommend to do it anyway. -/// -/// If this function fails this is considered a bug. Please open an issue describing your -/// platform and stating your current system time. -/// -/// # Panics -/// If the check fails this function panics. By calling this function on startup you ensure that -/// this wont happen at an arbitrary later point in time. -#[no_mangle] -pub extern "C" fn check_platform() { - lightning_invoice::check_platform() -} - use lightning_invoice::Invoice as nativeInvoiceImport; pub(crate) type nativeInvoice = nativeInvoiceImport; @@ -515,12 +525,12 @@ pub extern "C" fn RawDataPart_clone(orig: &RawDataPart) -> RawDataPart { use lightning_invoice::PositiveTimestamp as nativePositiveTimestampImport; pub(crate) type nativePositiveTimestamp = nativePositiveTimestampImport; -/// A timestamp that refers to a date after 1 January 1970 which means its representation as UNIX -/// timestamp is positive. +/// A timestamp that refers to a date after 1 January 1970. /// /// # Invariants -/// The UNIX timestamp representing the stored time has to be positive and small enough so that -/// a `EpiryTime` can be added to it without an overflow. +/// +/// The Unix timestamp representing the stored time has to be positive and no greater than +/// [`MAX_TIMESTAMP`]. #[must_use] #[repr(C)] pub struct PositiveTimestamp { @@ -1076,11 +1086,6 @@ pub(crate) type nativeExpiryTime = nativeExpiryTimeImport; /// Positive duration that defines when (relatively to the timestamp) in the future the invoice /// expires -/// -/// # Invariants -/// The number of seconds this expiry time represents has to be in the range -/// `0...(SYSTEM_TIME_MAX_UNIX_TIMESTAMP - MAX_EXPIRY_TIME)` to avoid overflows when adding it to a -/// timestamp #[must_use] #[repr(C)] pub struct ExpiryTime { @@ -1760,9 +1765,9 @@ pub extern "C" fn RawInvoice_currency(this_arg: &RawInvoice) -> crate::lightning crate::lightning_invoice::Currency::native_into(ret) } -/// Create a new `PositiveTimestamp` from a unix timestamp in the Range -/// `0...SYSTEM_TIME_MAX_UNIX_TIMESTAMP - MAX_EXPIRY_TIME`, otherwise return a -/// `CreationError::TimestampOutOfBounds`. +/// Creates a `PositiveTimestamp` from a Unix timestamp in the range `0..=MAX_TIMESTAMP`. +/// +/// Otherwise, returns a [`CreationError::TimestampOutOfBounds`]. #[must_use] #[no_mangle] pub extern "C" fn PositiveTimestamp_from_unix_timestamp(mut unix_seconds: u64) -> crate::c_types::derived::CResult_PositiveTimestampCreationErrorZ { @@ -1771,9 +1776,10 @@ pub extern "C" fn PositiveTimestamp_from_unix_timestamp(mut unix_seconds: u64) - local_ret } -/// Create a new `PositiveTimestamp` from a `SystemTime` with a corresponding unix timestamp in -/// the Range `0...SYSTEM_TIME_MAX_UNIX_TIMESTAMP - MAX_EXPIRY_TIME`, otherwise return a -/// `CreationError::TimestampOutOfBounds`. +/// Creates a `PositiveTimestamp` from a [`SystemTime`] with a corresponding Unix timestamp in +/// the range `0..=MAX_TIMESTAMP`. +/// +/// Otherwise, returns a [`CreationError::TimestampOutOfBounds`]. #[must_use] #[no_mangle] pub extern "C" fn PositiveTimestamp_from_system_time(mut time: u64) -> crate::c_types::derived::CResult_PositiveTimestampCreationErrorZ { @@ -1782,7 +1788,19 @@ pub extern "C" fn PositiveTimestamp_from_system_time(mut time: u64) -> crate::c_ local_ret } -/// Returns the UNIX timestamp representing the stored time +/// Creates a `PositiveTimestamp` from a [`Duration`] since the Unix epoch in the range +/// `0..=MAX_TIMESTAMP`. +/// +/// Otherwise, returns a [`CreationError::TimestampOutOfBounds`]. +#[must_use] +#[no_mangle] +pub extern "C" fn PositiveTimestamp_from_duration_since_epoch(mut duration: u64) -> crate::c_types::derived::CResult_PositiveTimestampCreationErrorZ { + let mut ret = lightning_invoice::PositiveTimestamp::from_duration_since_epoch(core::time::Duration::from_secs(duration)); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::PositiveTimestamp { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::CreationError::native_into(e) }).into() }; + local_ret +} + +/// Returns the Unix timestamp representing the stored time #[must_use] #[no_mangle] pub extern "C" fn PositiveTimestamp_as_unix_timestamp(this_arg: &PositiveTimestamp) -> u64 { @@ -1790,7 +1808,15 @@ pub extern "C" fn PositiveTimestamp_as_unix_timestamp(this_arg: &PositiveTimesta ret } -/// Returns a reference to the internal `SystemTime` time representation +/// Returns the duration of the stored time since the Unix epoch +#[must_use] +#[no_mangle] +pub extern "C" fn PositiveTimestamp_as_duration_since_epoch(this_arg: &PositiveTimestamp) -> u64 { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.as_duration_since_epoch(); + ret.as_secs() +} + +/// Returns the [`SystemTime`] representing the stored time #[must_use] #[no_mangle] pub extern "C" fn PositiveTimestamp_as_time(this_arg: &PositiveTimestamp) -> u64 { @@ -1843,7 +1869,7 @@ pub extern "C" fn Invoice_from_signed(mut signed_invoice: crate::lightning_invoi local_ret } -/// Returns the `Invoice`'s timestamp (should equal it's creation time) +/// Returns the `Invoice`'s timestamp (should equal its creation time) #[must_use] #[no_mangle] pub extern "C" fn Invoice_timestamp(this_arg: &Invoice) -> u64 { @@ -1851,6 +1877,14 @@ pub extern "C" fn Invoice_timestamp(this_arg: &Invoice) -> u64 { 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 +#[must_use] +#[no_mangle] +pub extern "C" fn Invoice_duration_since_epoch(this_arg: &Invoice) -> u64 { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.duration_since_epoch(); + ret.as_secs() +} + /// Returns the hash to which we will receive the preimage on completion of the payment #[must_use] #[no_mangle] @@ -1913,6 +1947,15 @@ pub extern "C" fn Invoice_is_expired(this_arg: &Invoice) -> bool { ret } +/// Returns whether the expiry time would pass at the given point in time. +/// `at_time` is the timestamp as a duration since the Unix epoch. +#[must_use] +#[no_mangle] +pub extern "C" fn Invoice_would_expire(this_arg: &Invoice, 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 +} + /// Returns the invoice's `min_final_cltv_expiry` time, if present, otherwise /// [`DEFAULT_MIN_FINAL_CLTV_EXPIRY`]. #[must_use] @@ -1977,26 +2020,20 @@ pub extern "C" fn Description_into_inner(mut this_arg: Description) -> crate::c_ ret.into() } -/// Construct an `ExpiryTime` from seconds. If there exists a `PositiveTimestamp` which would -/// overflow on adding the `EpiryTime` to it then this function will return a -/// `CreationError::ExpiryTimeOutOfBounds`. +/// Construct an `ExpiryTime` from seconds. #[must_use] #[no_mangle] -pub extern "C" fn ExpiryTime_from_seconds(mut seconds: u64) -> crate::c_types::derived::CResult_ExpiryTimeCreationErrorZ { +pub extern "C" fn ExpiryTime_from_seconds(mut seconds: u64) -> crate::lightning_invoice::ExpiryTime { let mut ret = lightning_invoice::ExpiryTime::from_seconds(seconds); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::ExpiryTime { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::CreationError::native_into(e) }).into() }; - local_ret + crate::lightning_invoice::ExpiryTime { inner: ObjOps::heap_alloc(ret), is_owned: true } } -/// Construct an `ExpiryTime` from a `Duration`. If there exists a `PositiveTimestamp` which -/// would overflow on adding the `EpiryTime` to it then this function will return a -/// `CreationError::ExpiryTimeOutOfBounds`. +/// Construct an `ExpiryTime` from a `Duration`. #[must_use] #[no_mangle] -pub extern "C" fn ExpiryTime_from_duration(mut duration: u64) -> crate::c_types::derived::CResult_ExpiryTimeCreationErrorZ { +pub extern "C" fn ExpiryTime_from_duration(mut duration: u64) -> crate::lightning_invoice::ExpiryTime { let mut ret = lightning_invoice::ExpiryTime::from_duration(core::time::Duration::from_secs(duration)); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::ExpiryTime { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::CreationError::native_into(e) }).into() }; - local_ret + crate::lightning_invoice::ExpiryTime { inner: ObjOps::heap_alloc(ret), is_owned: true } } /// Returns the expiry time in seconds @@ -2041,12 +2078,15 @@ pub enum CreationError { DescriptionTooLong, /// The specified route has too many hops and can't be encoded RouteTooLong, - /// The unix timestamp of the supplied date is <0 or can't be represented as `SystemTime` + /// The Unix timestamp of the supplied date is less than zero or greater than 35-bits TimestampOutOfBounds, - /// The supplied expiry time could cause an overflow if added to a `PositiveTimestamp` - ExpiryTimeOutOfBounds, /// The supplied millisatoshi amount was greater than the total bitcoin supply. InvalidAmount, + /// Route hints were required for this invoice and were missing. Applies to + /// [phantom invoices]. + /// + /// [phantom invoices]: crate::utils::create_phantom_invoice + MissingRouteHints, } use lightning_invoice::CreationError as nativeCreationError; impl CreationError { @@ -2056,8 +2096,8 @@ impl CreationError { CreationError::DescriptionTooLong => nativeCreationError::DescriptionTooLong, CreationError::RouteTooLong => nativeCreationError::RouteTooLong, CreationError::TimestampOutOfBounds => nativeCreationError::TimestampOutOfBounds, - CreationError::ExpiryTimeOutOfBounds => nativeCreationError::ExpiryTimeOutOfBounds, CreationError::InvalidAmount => nativeCreationError::InvalidAmount, + CreationError::MissingRouteHints => nativeCreationError::MissingRouteHints, } } #[allow(unused)] @@ -2066,8 +2106,8 @@ impl CreationError { CreationError::DescriptionTooLong => nativeCreationError::DescriptionTooLong, CreationError::RouteTooLong => nativeCreationError::RouteTooLong, CreationError::TimestampOutOfBounds => nativeCreationError::TimestampOutOfBounds, - CreationError::ExpiryTimeOutOfBounds => nativeCreationError::ExpiryTimeOutOfBounds, CreationError::InvalidAmount => nativeCreationError::InvalidAmount, + CreationError::MissingRouteHints => nativeCreationError::MissingRouteHints, } } #[allow(unused)] @@ -2076,8 +2116,8 @@ impl CreationError { nativeCreationError::DescriptionTooLong => CreationError::DescriptionTooLong, nativeCreationError::RouteTooLong => CreationError::RouteTooLong, nativeCreationError::TimestampOutOfBounds => CreationError::TimestampOutOfBounds, - nativeCreationError::ExpiryTimeOutOfBounds => CreationError::ExpiryTimeOutOfBounds, nativeCreationError::InvalidAmount => CreationError::InvalidAmount, + nativeCreationError::MissingRouteHints => CreationError::MissingRouteHints, } } #[allow(unused)] @@ -2086,8 +2126,8 @@ impl CreationError { nativeCreationError::DescriptionTooLong => CreationError::DescriptionTooLong, nativeCreationError::RouteTooLong => CreationError::RouteTooLong, nativeCreationError::TimestampOutOfBounds => CreationError::TimestampOutOfBounds, - nativeCreationError::ExpiryTimeOutOfBounds => CreationError::ExpiryTimeOutOfBounds, nativeCreationError::InvalidAmount => CreationError::InvalidAmount, + nativeCreationError::MissingRouteHints => CreationError::MissingRouteHints, } } } @@ -2109,13 +2149,13 @@ pub extern "C" fn CreationError_route_too_long() -> CreationError { pub extern "C" fn CreationError_timestamp_out_of_bounds() -> CreationError { CreationError::TimestampOutOfBounds} #[no_mangle] -/// Utility method to constructs a new ExpiryTimeOutOfBounds-variant CreationError -pub extern "C" fn CreationError_expiry_time_out_of_bounds() -> CreationError { - CreationError::ExpiryTimeOutOfBounds} -#[no_mangle] /// Utility method to constructs a new InvalidAmount-variant CreationError pub extern "C" fn CreationError_invalid_amount() -> CreationError { CreationError::InvalidAmount} +#[no_mangle] +/// Utility method to constructs a new MissingRouteHints-variant CreationError +pub extern "C" fn CreationError_missing_route_hints() -> CreationError { + CreationError::MissingRouteHints} /// Checks if two CreationErrors contain equal inner contents. /// This ignores pointers and is_owned flags and looks at the values in fields. #[no_mangle] @@ -2125,7 +2165,7 @@ pub extern "C" fn CreationError_eq(a: &CreationError, b: &CreationError) -> bool #[no_mangle] /// Get the string representation of a CreationError object pub extern "C" fn CreationError_to_str(o: &crate::lightning_invoice::CreationError) -> Str { - format!("{}", &o.to_native()).into() + 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 @@ -2272,7 +2312,7 @@ pub extern "C" fn SemanticError_eq(a: &SemanticError, b: &SemanticError) -> bool #[no_mangle] /// Get the string representation of a SemanticError object pub extern "C" fn SemanticError_to_str(o: &crate::lightning_invoice::SemanticError) -> Str { - format!("{}", &o.to_native()).into() + alloc::format!("{}", &o.to_native()).into() } /// When signing using a fallible method either an user-supplied `SignError` or a `CreationError` /// may occur. @@ -2371,5 +2411,5 @@ pub extern "C" fn SignOrCreationError_eq(a: &SignOrCreationError, b: &SignOrCrea #[no_mangle] /// Get the string representation of a SignOrCreationError object pub extern "C" fn SignOrCreationError_to_str(o: &crate::lightning_invoice::SignOrCreationError) -> Str { - format!("{}", &o.to_native()).into() + alloc::format!("{}", &o.to_native()).into() } diff --git a/lightning-c-bindings/src/lightning_invoice/payment.rs b/lightning-c-bindings/src/lightning_invoice/payment.rs index 973402b..037ab49 100644 --- a/lightning-c-bindings/src/lightning_invoice/payment.rs +++ b/lightning-c-bindings/src/lightning_invoice/payment.rs @@ -31,6 +31,9 @@ //! # extern crate lightning_invoice; //! # extern crate secp256k1; //! # +//! # #[cfg(feature = \"no-std\")] +//! # extern crate core2; +//! # //! # use lightning::ln::{PaymentHash, PaymentPreimage, PaymentSecret}; //! # use lightning::ln::channelmanager::{ChannelDetails, PaymentId, PaymentSendFailure}; //! # use lightning::ln::msgs::LightningError; @@ -46,6 +49,11 @@ //! # use std::cell::RefCell; //! # use std::ops::Deref; //! # +//! # #[cfg(not(feature = \"std\"))] +//! # use core2::io; +//! # #[cfg(feature = \"std\")] +//! # use std::io; +//! # //! # struct FakeEventProvider {} //! # impl EventsProvider for FakeEventProvider { //! # fn process_pending_events(&self, handler: H) where H::Target: EventHandler {} @@ -77,11 +85,11 @@ //! # //! # struct FakeScorer {} //! # impl Writeable for FakeScorer { -//! # fn write(&self, w: &mut W) -> Result<(), std::io::Error> { unimplemented!(); } +//! # fn write(&self, w: &mut W) -> Result<(), io::Error> { unimplemented!(); } //! # } //! # impl Score for FakeScorer { //! # fn channel_penalty_msat( -//! # &self, _short_channel_id: u64, _send_amt: u64, _chan_amt: Option, _source: &NodeId, _target: &NodeId +//! # &self, _short_channel_id: u64, _send_amt: u64, _chan_amt: u64, _source: &NodeId, _target: &NodeId //! # ) -> u64 { 0 } //! # fn payment_path_failed(&mut self, _path: &[&RouteHop], _short_channel_id: u64) {} //! # fn payment_path_successful(&mut self, _path: &[&RouteHop]) {} @@ -292,7 +300,7 @@ pub struct Router { /// /// 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, params: &crate::lightning::routing::router::RouteParameters, payment_hash: *const [u8; 32], first_hops: *mut crate::c_types::derived::CVec_ChannelDetailsZ, scorer: &crate::lightning::routing::scoring::Score) -> crate::c_types::derived::CResult_RouteLightningErrorZ, + pub find_route: extern "C" fn (this_arg: *const c_void, payer: crate::c_types::PublicKey, route_params: &crate::lightning::routing::router::RouteParameters, payment_hash: *const [u8; 32], first_hops: *mut crate::c_types::derived::CVec_ChannelDetailsZ, scorer: &crate::lightning::routing::scoring::Score) -> 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, @@ -310,9 +318,9 @@ pub(crate) extern "C" fn Router_clone_fields(orig: &Router) -> Router { use lightning_invoice::payment::Router as rustRouter; impl rustRouter for Router { - fn find_route(&self, mut payer: &secp256k1::key::PublicKey, mut params: &lightning::routing::router::RouteParameters, mut payment_hash: &lightning::ln::PaymentHash, mut first_hops: Option<&[&lightning::ln::channelmanager::ChannelDetails]>, mut scorer: &crate::lightning::routing::scoring::Score) -> Result { + fn find_route(&self, mut payer: &secp256k1::key::PublicKey, mut route_params: &lightning::routing::router::RouteParameters, mut payment_hash: &lightning::ln::PaymentHash, mut first_hops: Option<&[&lightning::ln::channelmanager::ChannelDetails]>, mut scorer: &crate::lightning::routing::scoring::Score) -> 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((params as *const lightning::routing::router::RouteParameters<>) as *mut _) }, is_owned: false }, &payment_hash.0, local_first_hops, scorer); + 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 }, &payment_hash.0, local_first_hops, scorer); 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 } diff --git a/lightning-c-bindings/src/lightning_invoice/utils.rs b/lightning-c-bindings/src/lightning_invoice/utils.rs index 79281aa..29d6583 100644 --- a/lightning-c-bindings/src/lightning_invoice/utils.rs +++ b/lightning-c-bindings/src/lightning_invoice/utils.rs @@ -16,6 +16,39 @@ use crate::c_types::*; #[cfg(feature="no-std")] use alloc::{vec::Vec, boxed::Box}; +/// Utility to create an invoice that can be paid to one of multiple nodes, or a \"phantom invoice.\" +/// See [`PhantomKeysManager`] for more information on phantom node payments. +/// +/// `phantom_route_hints` parameter: +/// * Contains channel info for all nodes participating in the phantom invoice +/// * Entries are retrieved from a call to [`ChannelManager::get_phantom_route_hints`] on each +/// participating node +/// * It is fine to cache `phantom_route_hints` and reuse it across invoices, as long as the data is +/// updated when a channel becomes disabled or closes +/// * Note that if too many channels are included in [`PhantomRouteHints::channels`], the invoice +/// may be too long for QR code scanning. To fix this, `PhantomRouteHints::channels` may be pared +/// down +/// +/// `payment_hash` and `payment_secret` come from [`ChannelManager::create_inbound_payment`] or +/// [`ChannelManager::create_inbound_payment_for_hash`]. These values can be retrieved from any +/// participating node. +/// +/// Note that the provided `keys_manager`'s `KeysInterface` implementation must support phantom +/// invoices in its `sign_invoice` implementation ([`PhantomKeysManager`] satisfies this +/// requirement). +/// +/// [`PhantomKeysManager`]: lightning::chain::keysinterface::PhantomKeysManager +/// [`ChannelManager::get_phantom_route_hints`]: lightning::ln::channelmanager::ChannelManager::get_phantom_route_hints +/// [`PhantomRouteHints::channels`]: lightning::ln::channelmanager::PhantomRouteHints::channels +#[no_mangle] +pub extern "C" fn create_phantom_invoice(mut amt_msat: crate::c_types::derived::COption_u64Z, mut description: crate::c_types::Str, mut payment_hash: crate::c_types::ThirtyTwoBytes, mut payment_secret: crate::c_types::ThirtyTwoBytes, mut phantom_route_hints: crate::c_types::derived::CVec_PhantomRouteHintsZ, mut keys_manager: crate::lightning::chain::keysinterface::KeysInterface, mut network: crate::lightning_invoice::Currency) -> crate::c_types::derived::CResult_InvoiceSignOrCreationErrorZ { + let mut local_amt_msat = if amt_msat.is_some() { Some( { amt_msat.take() }) } else { None }; + 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 ret = lightning_invoice::utils::create_phantom_invoice::(local_amt_msat, description.into_string(), ::lightning::ln::PaymentHash(payment_hash.data), ::lightning::ln::PaymentSecret(payment_secret.data), local_phantom_route_hints, keys_manager, network.into_native()); + 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() }; + local_ret +} + /// Utility to construct an invoice. Generally, unless you want to do something like a custom /// cltv_expiry, this is what you should be using to create an invoice. The reason being, this /// method stores the invoice's payment secret and preimage in `ChannelManager`, so (a) the user @@ -24,7 +57,18 @@ use alloc::{vec::Vec, boxed::Box}; #[no_mangle] pub extern "C" fn create_invoice_from_channelmanager(channelmanager: &crate::lightning::ln::channelmanager::ChannelManager, mut keys_manager: crate::lightning::chain::keysinterface::KeysInterface, mut network: crate::lightning_invoice::Currency, mut amt_msat: crate::c_types::derived::COption_u64Z, mut description: crate::c_types::Str) -> crate::c_types::derived::CResult_InvoiceSignOrCreationErrorZ { let mut local_amt_msat = if amt_msat.is_some() { Some( { amt_msat.take() }) } else { None }; - let mut ret = lightning_invoice::utils::create_invoice_from_channelmanager(channelmanager.get_native_ref(), keys_manager, network.into_native(), local_amt_msat, description.into_string()); + let mut ret = lightning_invoice::utils::create_invoice_from_channelmanager::(channelmanager.get_native_ref(), keys_manager, network.into_native(), local_amt_msat, description.into_string()); + 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() }; + local_ret +} + +/// See [`create_invoice_from_channelmanager`] +/// This version can be used in a `no_std` environment, where [`std::time::SystemTime`] is not +/// available and the current time is supplied by the caller. +#[no_mangle] +pub extern "C" fn create_invoice_from_channelmanager_and_duration_since_epoch(channelmanager: &crate::lightning::ln::channelmanager::ChannelManager, mut keys_manager: crate::lightning::chain::keysinterface::KeysInterface, 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) -> crate::c_types::derived::CResult_InvoiceSignOrCreationErrorZ { + let mut local_amt_msat = if amt_msat.is_some() { Some( { amt_msat.take() }) } else { None }; + let mut ret = lightning_invoice::utils::create_invoice_from_channelmanager_and_duration_since_epoch::(channelmanager.get_native_ref(), keys_manager, network.into_native(), local_amt_msat, description.into_string(), 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() }; local_ret } -- 2.39.5