X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning-c-bindings%2Finclude%2Flightning.h;h=ac086be8eb562b667066621c342136cae53ae403;hb=c4fa20597f2d4e41dad125ef009283e1a8e66d68;hp=a1b91e72ee07b855ceac0a4782c7f453a2ed3899;hpb=18337a0191c3abdca8d51861c328dd3d2d9ca6b7;p=ldk-c-bindings diff --git a/lightning-c-bindings/include/lightning.h b/lightning-c-bindings/include/lightning.h index a1b91e7..ac086be 100644 --- a/lightning-c-bindings/include/lightning.h +++ b/lightning-c-bindings/include/lightning.h @@ -1,7 +1,7 @@ #ifndef LDK_C_BINDINGS_H #define LDK_C_BINDINGS_H -/* Generated with cbindgen:0.19.0 */ +/* Generated with cbindgen:0.17.0 */ /* Warning, this file is autogenerated by cbindgen. Don't modify this manually. */ @@ -28,6 +28,24 @@ typedef enum LDKAccessError { LDKAccessError_Sentinel, } LDKAccessError; +/** + * An enum which can either contain a or not + */ +typedef enum LDKCOption_NoneZ { + /** + * When we're in this state, this COption_NoneZ contains a + */ + LDKCOption_NoneZ_Some, + /** + * When we're in this state, this COption_NoneZ contains nothing + */ + LDKCOption_NoneZ_None, + /** + * Must be last for serialization purposes + */ + LDKCOption_NoneZ_Sentinel, +} LDKCOption_NoneZ; + /** * An error enum representing a failure to persist a channel monitor update. */ @@ -138,13 +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` + * 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_ExpiryTimeOutOfBounds, + LDKCreationError_MissingRouteHints, /** * Must be last for serialization purposes */ @@ -213,6 +238,10 @@ typedef enum LDKIOError { * An enum representing the available verbosity levels of the logger. */ typedef enum LDKLevel { + /** + * Designates extremely verbose information, including gossip-induced messages + */ + LDKLevel_Gossip, /** * Designates very low priority, often extremely verbose, information */ @@ -265,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 */ @@ -471,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. */ @@ -587,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 */ @@ -1536,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. @@ -1659,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; @@ -2171,6 +2310,147 @@ typedef struct LDKCOption_C2Tuple_usizeTransactionZZ { }; } LDKCOption_C2Tuple_usizeTransactionZZ; +/** + * The reason the channel was closed. See individual variants more details. + */ +typedef enum LDKClosureReason_Tag { + /** + * Closure generated from receiving a peer error message. + * + * Our counterparty may have broadcasted their latest commitment state, and we have + * as well. + */ + LDKClosureReason_CounterpartyForceClosed, + /** + * Closure generated from [`ChannelManager::force_close_channel`], called by the user. + * + * [`ChannelManager::force_close_channel`]: crate::ln::channelmanager::ChannelManager::force_close_channel. + */ + LDKClosureReason_HolderForceClosed, + /** + * The channel was closed after negotiating a cooperative close and we've now broadcasted + * the cooperative close transaction. Note the shutdown may have been initiated by us. + */ + LDKClosureReason_CooperativeClosure, + /** + * A commitment transaction was confirmed on chain, closing the channel. Most likely this + * commitment transaction came from our counterparty, but it may also have come from + * a copy of our own `ChannelMonitor`. + */ + LDKClosureReason_CommitmentTxConfirmed, + /** + * The funding transaction failed to confirm in a timely manner on an inbound channel. + */ + LDKClosureReason_FundingTimedOut, + /** + * Closure generated from processing an event, likely a HTLC forward/relay/reception. + */ + LDKClosureReason_ProcessingError, + /** + * The `PeerManager` informed us that we've disconnected from the peer. We close channels + * if the `PeerManager` informed us that it is unlikely we'll be able to connect to the + * peer again in the future or if the peer disconnected before we finished negotiating + * the channel open. The first case may be caused by incompatible features which our + * counterparty, or we, require. + */ + LDKClosureReason_DisconnectedPeer, + /** + * Closure generated from `ChannelManager::read` if the ChannelMonitor is newer than + * the ChannelManager deserialized. + */ + LDKClosureReason_OutdatedChannelManager, + /** + * Must be last for serialization purposes + */ + LDKClosureReason_Sentinel, +} LDKClosureReason_Tag; + +typedef struct LDKClosureReason_LDKCounterpartyForceClosed_Body { + /** + * The error which the peer sent us. + * + * The string should be sanitized before it is used (e.g emitted to logs + * or printed to stdout). Otherwise, a well crafted error message may exploit + * a security vulnerability in the terminal emulator or the logging subsystem. + */ + struct LDKStr peer_msg; +} LDKClosureReason_LDKCounterpartyForceClosed_Body; + +typedef struct LDKClosureReason_LDKProcessingError_Body { + /** + * A developer-readable error message which we generated. + */ + struct LDKStr err; +} LDKClosureReason_LDKProcessingError_Body; + +typedef struct MUST_USE_STRUCT LDKClosureReason { + LDKClosureReason_Tag tag; + union { + LDKClosureReason_LDKCounterpartyForceClosed_Body counterparty_force_closed; + LDKClosureReason_LDKProcessingError_Body processing_error; + }; +} LDKClosureReason; + +/** + * An enum which can either contain a crate::lightning::util::events::ClosureReason or not + */ +typedef enum LDKCOption_ClosureReasonZ_Tag { + /** + * When we're in this state, this COption_ClosureReasonZ contains a crate::lightning::util::events::ClosureReason + */ + LDKCOption_ClosureReasonZ_Some, + /** + * When we're in this state, this COption_ClosureReasonZ contains nothing + */ + LDKCOption_ClosureReasonZ_None, + /** + * Must be last for serialization purposes + */ + LDKCOption_ClosureReasonZ_Sentinel, +} LDKCOption_ClosureReasonZ_Tag; + +typedef struct LDKCOption_ClosureReasonZ { + LDKCOption_ClosureReasonZ_Tag tag; + union { + struct { + struct LDKClosureReason some; + }; + }; +} LDKCOption_ClosureReasonZ; + +/** + * The contents of CResult_COption_ClosureReasonZDecodeErrorZ + */ +typedef union LDKCResult_COption_ClosureReasonZDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKCOption_ClosureReasonZ *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + struct LDKDecodeError *err; +} LDKCResult_COption_ClosureReasonZDecodeErrorZPtr; + +/** + * A CResult_COption_ClosureReasonZDecodeErrorZ represents the result of a fallible operation, + * containing a crate::c_types::derived::COption_ClosureReasonZ on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_COption_ClosureReasonZDecodeErrorZ { + /** + * The contents of this CResult_COption_ClosureReasonZDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_COption_ClosureReasonZDecodeErrorZPtr contents; + /** + * Whether this CResult_COption_ClosureReasonZDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_COption_ClosureReasonZDecodeErrorZ; + /** @@ -2431,208 +2711,807 @@ typedef struct LDKCVec_SpendableOutputDescriptorZ { uintptr_t datalen; } LDKCVec_SpendableOutputDescriptorZ; - - /** - * An accept_channel message to be sent or received from a peer - */ -typedef struct MUST_USE_STRUCT LDKAcceptChannel { + * Some information provided on receipt of payment depends on whether the payment received is a + * spontaneous payment or a \"conventional\" lightning payment that's paying an invoice. + */ +typedef enum LDKPaymentPurpose_Tag { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * Information for receiving a payment that we generated an invoice for. */ - LDKnativeAcceptChannel *inner; + LDKPaymentPurpose_InvoicePayment, /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * Because this is a spontaneous payment, the payer generated their own preimage rather than us + * (the payee) providing a preimage. */ - bool is_owned; -} LDKAcceptChannel; - - + LDKPaymentPurpose_SpontaneousPayment, + /** + * Must be last for serialization purposes + */ + LDKPaymentPurpose_Sentinel, +} LDKPaymentPurpose_Tag; -/** - * An open_channel message to be sent or received from a peer - */ -typedef struct MUST_USE_STRUCT LDKOpenChannel { +typedef struct LDKPaymentPurpose_LDKInvoicePayment_Body { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The preimage to the payment_hash, if the payment hash (and secret) were fetched via + * [`ChannelManager::create_inbound_payment`]. If provided, this can be handed directly to + * [`ChannelManager::claim_funds`]. + * + * [`ChannelManager::create_inbound_payment`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment + * [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds + * + * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None */ - LDKnativeOpenChannel *inner; + struct LDKThirtyTwoBytes payment_preimage; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The \"payment secret\". This authenticates the sender to the recipient, preventing a + * number of deanonymization attacks during the routing process. + * It is provided here for your reference, however its accuracy is enforced directly by + * [`ChannelManager`] using the values you previously provided to + * [`ChannelManager::create_inbound_payment`] or + * [`ChannelManager::create_inbound_payment_for_hash`]. + * + * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager + * [`ChannelManager::create_inbound_payment`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment + * [`ChannelManager::create_inbound_payment_for_hash`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash */ - bool is_owned; -} LDKOpenChannel; + struct LDKThirtyTwoBytes payment_secret; +} LDKPaymentPurpose_LDKInvoicePayment_Body; + +typedef struct MUST_USE_STRUCT LDKPaymentPurpose { + LDKPaymentPurpose_Tag tag; + union { + LDKPaymentPurpose_LDKInvoicePayment_Body invoice_payment; + struct { + struct LDKThirtyTwoBytes spontaneous_payment; + }; + }; +} LDKPaymentPurpose; /** - * A funding_created message to be sent or received from a peer + * Features used within the channel_type field in an OpenChannel message. + * + * A channel is always of some known \"type\", describing the transaction formats used and the exact + * semantics of our interaction with our peer. + * + * Note that because a channel is a specific type which is proposed by the opener and accepted by + * the counterparty, only required features are allowed here. + * + * This is serialized differently from other feature types - it is not prefixed by a length, and + * thus must only appear inside a TLV where its length is known in advance. */ -typedef struct MUST_USE_STRUCT LDKFundingCreated { +typedef struct MUST_USE_STRUCT LDKChannelTypeFeatures { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeFundingCreated *inner; + LDKnativeChannelTypeFeatures *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; -} LDKFundingCreated; - - +} LDKChannelTypeFeatures; /** - * A funding_signed message to be sent or received from a peer + * An Event which you should probably take some action in response to. + * + * Note that while Writeable and Readable are implemented for Event, you probably shouldn't use + * them directly as they don't round-trip exactly (for example FundingGenerationReady is never + * written as it makes no sense to respond to it after reconnecting to peers). */ -typedef struct MUST_USE_STRUCT LDKFundingSigned { +typedef enum LDKEvent_Tag { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * Used to indicate that the client should generate a funding transaction with the given + * parameters and then call [`ChannelManager::funding_transaction_generated`]. + * Generated in [`ChannelManager`] message handling. + * Note that *all inputs* in the funding transaction must spend SegWit outputs or your + * counterparty can steal your funds! + * + * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager + * [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated */ - LDKnativeFundingSigned *inner; + LDKEvent_FundingGenerationReady, /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * Indicates we've received money! Just gotta dig out that payment preimage and feed it to + * [`ChannelManager::claim_funds`] to get it.... + * Note that if the preimage is not known, you should call + * [`ChannelManager::fail_htlc_backwards`] to free up resources for this HTLC and avoid + * network congestion. + * If you fail to call either [`ChannelManager::claim_funds`] or + * [`ChannelManager::fail_htlc_backwards`] within the HTLC's timeout, the HTLC will be + * automatically failed. + * + * # Note + * LDK will not stop an inbound payment from being paid multiple times, so multiple + * `PaymentReceived` events may be generated for the same payment. + * + * [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds + * [`ChannelManager::fail_htlc_backwards`]: crate::ln::channelmanager::ChannelManager::fail_htlc_backwards */ - bool is_owned; -} LDKFundingSigned; - - - -/** - * A funding_locked message to be sent or received from a peer - */ -typedef struct MUST_USE_STRUCT LDKFundingLocked { + LDKEvent_PaymentReceived, /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * Indicates an outbound payment we made succeeded (i.e. it made it all the way to its target + * and we got back the payment preimage for it). + * + * Note for MPP payments: in rare cases, this event may be preceded by a `PaymentPathFailed` + * event. In this situation, you SHOULD treat this payment as having succeeded. */ - LDKnativeFundingLocked *inner; + LDKEvent_PaymentSent, /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * Indicates an outbound HTLC we sent failed. Probably some intermediary node dropped + * something. You may wish to retry with a different route. + * + * 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::PaymentPathFailed::all_paths_failed */ - bool is_owned; -} LDKFundingLocked; - - - -/** - * An announcement_signatures message to be sent or received from a peer - */ -typedef struct MUST_USE_STRUCT LDKAnnouncementSignatures { + LDKEvent_PaymentPathFailed, /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * Indicates an outbound payment failed. Individual [`Event::PaymentPathFailed`] events + * provide failure information for each MPP part in the payment. + * + * This event is provided once there are no further pending HTLCs for the payment and the + * payment is no longer retryable, either due to a several-block timeout or because + * [`ChannelManager::abandon_payment`] was previously called for the corresponding payment. + * + * [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment */ - LDKnativeAnnouncementSignatures *inner; + LDKEvent_PaymentFailed, /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * Used to indicate that [`ChannelManager::process_pending_htlc_forwards`] should be called at + * a time in the future. + * + * [`ChannelManager::process_pending_htlc_forwards`]: crate::ln::channelmanager::ChannelManager::process_pending_htlc_forwards */ - bool is_owned; -} LDKAnnouncementSignatures; - - - -/** - * Struct used to return values from revoke_and_ack messages, containing a bunch of commitment - * transaction updates if they were pending. - */ -typedef struct MUST_USE_STRUCT LDKCommitmentUpdate { + LDKEvent_PendingHTLCsForwardable, /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * Used to indicate that an output which you should know how to spend was confirmed on chain + * and is now spendable. + * Such an output will *not* ever be spent by rust-lightning, and are not at risk of your + * counterparty spending them due to some kind of timeout. Thus, you need to store them + * somewhere and spend them when you create on-chain transactions. */ - LDKnativeCommitmentUpdate *inner; + LDKEvent_SpendableOutputs, /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * This event is generated when a payment has been successfully forwarded through us and a + * forwarding fee earned. */ - bool is_owned; -} LDKCommitmentUpdate; - - - -/** - * A revoke_and_ack message to be sent or received from a peer - */ -typedef struct MUST_USE_STRUCT LDKRevokeAndACK { + LDKEvent_PaymentForwarded, /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * Used to indicate that a channel with the given `channel_id` is in the process of closure. */ - LDKnativeRevokeAndACK *inner; + LDKEvent_ChannelClosed, /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * Used to indicate to the user that they can abandon the funding transaction and recycle the + * inputs for another purpose. */ - bool is_owned; -} LDKRevokeAndACK; - - - -/** - * A closing_signed message to be sent or received from a peer - */ -typedef struct MUST_USE_STRUCT LDKClosingSigned { + LDKEvent_DiscardFunding, /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * Indicates that a path for an outbound payment was successful. + * + * Always generated after [`Event::PaymentSent`] and thus useful for scoring channels. See + * [`Event::PaymentSent`] for obtaining the payment preimage. */ - LDKnativeClosingSigned *inner; + LDKEvent_PaymentPathSuccessful, /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * Indicates 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 */ - bool is_owned; -} LDKClosingSigned; - - + LDKEvent_OpenChannelRequest, + /** + * Must be last for serialization purposes + */ + LDKEvent_Sentinel, +} LDKEvent_Tag; -/** - * A shutdown message to be sent or received from a peer - */ -typedef struct MUST_USE_STRUCT LDKShutdown { +typedef struct LDKEvent_LDKFundingGenerationReady_Body { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The random channel_id we picked which you'll need to pass into + * ChannelManager::funding_transaction_generated. */ - LDKnativeShutdown *inner; + struct LDKThirtyTwoBytes temporary_channel_id; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The value, in satoshis, that the output should have. */ - bool is_owned; -} LDKShutdown; - - + uint64_t channel_value_satoshis; + /** + * The script which should be used in the transaction output. + */ + struct LDKCVec_u8Z output_script; + /** + * The `user_channel_id` value passed in to [`ChannelManager::create_channel`], or 0 for + * an inbound channel. + * + * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel + */ + uint64_t user_channel_id; +} LDKEvent_LDKFundingGenerationReady_Body; + +typedef struct LDKEvent_LDKPaymentReceived_Body { + /** + * The hash for which the preimage should be handed to the ChannelManager. Note that LDK will + * not stop you from registering duplicate payment hashes for inbound payments. + */ + struct LDKThirtyTwoBytes payment_hash; + /** + * The value, in thousandths of a satoshi, that this payment is for. + */ + uint64_t amt; + /** + * Information for claiming this received payment, based on whether the purpose of the + * payment is to pay an invoice or to send a spontaneous payment. + */ + struct LDKPaymentPurpose purpose; +} LDKEvent_LDKPaymentReceived_Body; + +typedef struct LDKEvent_LDKPaymentSent_Body { + /** + * The id returned by [`ChannelManager::send_payment`] and used with + * [`ChannelManager::retry_payment`]. + * + * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment + * [`ChannelManager::retry_payment`]: crate::ln::channelmanager::ChannelManager::retry_payment + * + * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + */ + struct LDKThirtyTwoBytes payment_id; + /** + * The preimage to the hash given to ChannelManager::send_payment. + * Note that this serves as a payment receipt, if you wish to have such a thing, you must + * store it somehow! + */ + struct LDKThirtyTwoBytes payment_preimage; + /** + * The hash that was given to [`ChannelManager::send_payment`]. + * + * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment + */ + struct LDKThirtyTwoBytes payment_hash; + /** + * The total fee which was spent at intermediate hops in this payment, across all paths. + * + * Note that, like [`Route::get_total_fees`] this does *not* include any potential + * overpayment to the recipient node. + * + * If the recipient or an intermediate node misbehaves and gives us free money, this may + * overstate the amount paid, though this is unlikely. + * + * [`Route::get_total_fees`]: crate::routing::router::Route::get_total_fees + */ + struct LDKCOption_u64Z fee_paid_msat; +} LDKEvent_LDKPaymentSent_Body; + +typedef struct LDKEvent_LDKPaymentPathFailed_Body { + /** + * The id returned by [`ChannelManager::send_payment`] and used with + * [`ChannelManager::retry_payment`] and [`ChannelManager::abandon_payment`]. + * + * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment + * [`ChannelManager::retry_payment`]: crate::ln::channelmanager::ChannelManager::retry_payment + * [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment + * + * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + */ + struct LDKThirtyTwoBytes payment_id; + /** + * The hash that was given to [`ChannelManager::send_payment`]. + * + * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment + */ + struct LDKThirtyTwoBytes payment_hash; + /** + * Indicates the payment was rejected for some reason by the recipient. This implies that + * the payment has failed, not just the route in question. If this is not set, you may + * retry the payment via a different route. + */ + bool rejected_by_dest; + /** + * Any failure information conveyed via the Onion return packet by a node along the failed + * payment route. + * + * Should be applied to the [`NetworkGraph`] so that routing decisions can take into + * account the update. [`NetGraphMsgHandler`] is capable of doing this. + * + * [`NetworkGraph`]: crate::routing::network_graph::NetworkGraph + * [`NetGraphMsgHandler`]: crate::routing::network_graph::NetGraphMsgHandler + */ + struct LDKCOption_NetworkUpdateZ network_update; + /** + * For both single-path and multi-path payments, this is set if all paths of the payment have + * failed. This will be set to false if (1) this is an MPP payment and (2) other parts of the + * larger MPP payment were still in flight when this event was generated. + * + * Note that if you are retrying individual MPP parts, using this value to determine if a + * payment has fully failed is race-y. Because multiple failures can happen prior to events + * being processed, you may retry in response to a first failure, with a second failure + * (with `all_paths_failed` set) still pending. Then, when the second failure is processed + * you will see `all_paths_failed` set even though the retry of the first failure still + * has an associated in-flight HTLC. See (1) for an example of such a failure. + * + * If you wish to retry individual MPP parts and learn when a payment has failed, you must + * call [`ChannelManager::abandon_payment`] and wait for a [`Event::PaymentFailed`] event. + * + * (1) + * + * [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment + */ + bool all_paths_failed; + /** + * The payment path that failed. + */ + struct LDKCVec_RouteHopZ path; + /** + * The channel responsible for the failed payment path. + * + * If this is `Some`, then the corresponding channel should be avoided when the payment is + * retried. May be `None` for older [`Event`] serializations. + */ + struct LDKCOption_u64Z short_channel_id; + /** + * Parameters needed to compute a new [`Route`] when retrying the failed payment path. + * + * See [`find_route`] for details. + * + * [`Route`]: crate::routing::router::Route + * [`find_route`]: crate::routing::router::find_route + * + * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + */ + struct LDKRouteParameters retry; +} LDKEvent_LDKPaymentPathFailed_Body; + +typedef struct LDKEvent_LDKPaymentFailed_Body { + /** + * The id returned by [`ChannelManager::send_payment`] and used with + * [`ChannelManager::retry_payment`] and [`ChannelManager::abandon_payment`]. + * + * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment + * [`ChannelManager::retry_payment`]: crate::ln::channelmanager::ChannelManager::retry_payment + * [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment + */ + struct LDKThirtyTwoBytes payment_id; + /** + * The hash that was given to [`ChannelManager::send_payment`]. + * + * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment + */ + struct LDKThirtyTwoBytes payment_hash; +} LDKEvent_LDKPaymentFailed_Body; + +typedef struct LDKEvent_LDKPendingHTLCsForwardable_Body { + /** + * The minimum amount of time that should be waited prior to calling + * process_pending_htlc_forwards. To increase the effort required to correlate payments, + * you should wait a random amount of time in roughly the range (now + time_forwardable, + * now + 5*time_forwardable). + */ + uint64_t time_forwardable; +} LDKEvent_LDKPendingHTLCsForwardable_Body; + +typedef struct LDKEvent_LDKSpendableOutputs_Body { + /** + * The outputs which you should store as spendable by you. + */ + struct LDKCVec_SpendableOutputDescriptorZ outputs; +} LDKEvent_LDKSpendableOutputs_Body; + +typedef struct LDKEvent_LDKPaymentForwarded_Body { + /** + * The fee, in milli-satoshis, which was earned as a result of the payment. + * + * Note that if we force-closed the channel over which we forwarded an HTLC while the HTLC + * was pending, the amount the next hop claimed will have been rounded down to the nearest + * whole satoshi. Thus, the fee calculated here may be higher than expected as we still + * claimed the full value in millisatoshis from the source. In this case, + * `claim_from_onchain_tx` will be set. + * + * If the channel which sent us the payment has been force-closed, we will claim the funds + * via an on-chain transaction. In that case we do not yet know the on-chain transaction + * fees which we will spend and will instead set this to `None`. It is possible duplicate + * `PaymentForwarded` events are generated for the same payment iff `fee_earned_msat` is + * `None`. + */ + struct LDKCOption_u64Z fee_earned_msat; + /** + * If this is `true`, the forwarded HTLC was claimed by our counterparty via an on-chain + * transaction. + */ + bool claim_from_onchain_tx; +} LDKEvent_LDKPaymentForwarded_Body; + +typedef struct LDKEvent_LDKChannelClosed_Body { + /** + * The channel_id of the channel which has been closed. Note that on-chain transactions + * resolving the channel are likely still awaiting confirmation. + */ + struct LDKThirtyTwoBytes channel_id; + /** + * The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound + * channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if + * [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise + * `user_channel_id` will be 0 for an inbound channel. + * This will always be zero for objects serialized with LDK versions prior to 0.0.102. + * + * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel + * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel + * [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels + */ + uint64_t user_channel_id; + /** + * The reason the channel was closed. + */ + struct LDKClosureReason reason; +} LDKEvent_LDKChannelClosed_Body; + +typedef struct LDKEvent_LDKDiscardFunding_Body { + /** + * The channel_id of the channel which has been closed. + */ + struct LDKThirtyTwoBytes channel_id; + /** + * The full transaction received from the user + */ + struct LDKTransaction transaction; +} LDKEvent_LDKDiscardFunding_Body; + +typedef struct LDKEvent_LDKPaymentPathSuccessful_Body { + /** + * The id returned by [`ChannelManager::send_payment`] and used with + * [`ChannelManager::retry_payment`]. + * + * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment + * [`ChannelManager::retry_payment`]: crate::ln::channelmanager::ChannelManager::retry_payment + */ + struct LDKThirtyTwoBytes payment_id; + /** + * The hash that was given to [`ChannelManager::send_payment`]. + * + * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment + * + * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + */ + struct LDKThirtyTwoBytes payment_hash; + /** + * The payment path that was successful. + * + * May contain a closed channel if the HTLC sent along the path was fulfilled on chain. + */ + 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; + /** + * The features that this channel will operate with. If you reject the channel, a + * well-behaved counterparty may automatically re-attempt the channel with a new set of + * feature flags. + * + * Note that if [`ChannelTypeFeatures::supports_scid_privacy`] returns true on this type, + * the resulting [`ChannelManager`] will not be readable by versions of LDK prior to + * 0.0.106. + * + * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager + */ + struct LDKChannelTypeFeatures channel_type; +} LDKEvent_LDKOpenChannelRequest_Body; + +typedef struct MUST_USE_STRUCT LDKEvent { + LDKEvent_Tag tag; + union { + LDKEvent_LDKFundingGenerationReady_Body funding_generation_ready; + LDKEvent_LDKPaymentReceived_Body payment_received; + LDKEvent_LDKPaymentSent_Body payment_sent; + LDKEvent_LDKPaymentPathFailed_Body payment_path_failed; + LDKEvent_LDKPaymentFailed_Body payment_failed; + LDKEvent_LDKPendingHTLCsForwardable_Body pending_htl_cs_forwardable; + LDKEvent_LDKSpendableOutputs_Body spendable_outputs; + LDKEvent_LDKPaymentForwarded_Body payment_forwarded; + LDKEvent_LDKChannelClosed_Body channel_closed; + LDKEvent_LDKDiscardFunding_Body discard_funding; + LDKEvent_LDKPaymentPathSuccessful_Body payment_path_successful; + LDKEvent_LDKOpenChannelRequest_Body open_channel_request; + }; +} LDKEvent; + +/** + * An enum which can either contain a crate::lightning::util::events::Event or not + */ +typedef enum LDKCOption_EventZ_Tag { + /** + * When we're in this state, this COption_EventZ contains a crate::lightning::util::events::Event + */ + LDKCOption_EventZ_Some, + /** + * When we're in this state, this COption_EventZ contains nothing + */ + LDKCOption_EventZ_None, + /** + * Must be last for serialization purposes + */ + LDKCOption_EventZ_Sentinel, +} LDKCOption_EventZ_Tag; + +typedef struct LDKCOption_EventZ { + LDKCOption_EventZ_Tag tag; + union { + struct { + struct LDKEvent some; + }; + }; +} LDKCOption_EventZ; + +/** + * The contents of CResult_COption_EventZDecodeErrorZ + */ +typedef union LDKCResult_COption_EventZDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKCOption_EventZ *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + struct LDKDecodeError *err; +} LDKCResult_COption_EventZDecodeErrorZPtr; + +/** + * A CResult_COption_EventZDecodeErrorZ represents the result of a fallible operation, + * containing a crate::c_types::derived::COption_EventZ on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_COption_EventZDecodeErrorZ { + /** + * The contents of this CResult_COption_EventZDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_COption_EventZDecodeErrorZPtr contents; + /** + * Whether this CResult_COption_EventZDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_COption_EventZDecodeErrorZ; + + + +/** + * An accept_channel message to be sent or received from a peer + */ +typedef struct MUST_USE_STRUCT LDKAcceptChannel { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeAcceptChannel *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; +} LDKAcceptChannel; + + + +/** + * An open_channel message to be sent or received from a peer + */ +typedef struct MUST_USE_STRUCT LDKOpenChannel { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeOpenChannel *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; +} LDKOpenChannel; + + + +/** + * A funding_created message to be sent or received from a peer + */ +typedef struct MUST_USE_STRUCT LDKFundingCreated { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeFundingCreated *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; +} LDKFundingCreated; + + + +/** + * A funding_signed message to be sent or received from a peer + */ +typedef struct MUST_USE_STRUCT LDKFundingSigned { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeFundingSigned *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKFundingSigned; + + + +/** + * A funding_locked message to be sent or received from a peer + */ +typedef struct MUST_USE_STRUCT LDKFundingLocked { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeFundingLocked *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; +} LDKFundingLocked; + + + +/** + * An announcement_signatures message to be sent or received from a peer + */ +typedef struct MUST_USE_STRUCT LDKAnnouncementSignatures { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeAnnouncementSignatures *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; +} LDKAnnouncementSignatures; + + + +/** + * Struct used to return values from revoke_and_ack messages, containing a bunch of commitment + * transaction updates if they were pending. + */ +typedef struct MUST_USE_STRUCT LDKCommitmentUpdate { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeCommitmentUpdate *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; +} LDKCommitmentUpdate; + + + +/** + * A revoke_and_ack message to be sent or received from a peer + */ +typedef struct MUST_USE_STRUCT LDKRevokeAndACK { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeRevokeAndACK *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; +} LDKRevokeAndACK; + + + +/** + * A closing_signed message to be sent or received from a peer + */ +typedef struct MUST_USE_STRUCT LDKClosingSigned { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeClosingSigned *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; +} LDKClosingSigned; + + + +/** + * A shutdown message to be sent or received from a peer + */ +typedef struct MUST_USE_STRUCT LDKShutdown { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeShutdown *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKShutdown; + + /** * A channel_reestablish message to be sent or received from a peer @@ -2712,6 +3591,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 */ @@ -2729,10 +3628,20 @@ typedef enum LDKErrorAction_Tag { * If the error is logged, log it at the given level. */ LDKErrorAction_IgnoreAndLog, + /** + * The peer provided us with a gossip message which we'd already seen. In most cases this + * should be ignored, but it may result in the message being forwarded if it is a duplicate of + * our own channel announcements. + */ + LDKErrorAction_IgnoreDuplicateGossip, /** * The peer did something incorrect. Tell them. */ LDKErrorAction_SendErrorMessage, + /** + * The peer did something incorrect. Tell them without closing any channels. + */ + LDKErrorAction_SendWarningMessage, /** * Must be last for serialization purposes */ @@ -2755,6 +3664,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 { @@ -2763,6 +3685,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; @@ -2842,6 +3765,28 @@ typedef struct MUST_USE_STRUCT LDKReplyChannelRange { bool is_owned; } LDKReplyChannelRange; + + +/** + * A gossip_timestamp_filter message is used by a node to request + * gossip relay for messages in the requested time range when the + * gossip_queries feature has been negotiated. + */ +typedef struct MUST_USE_STRUCT LDKGossipTimestampFilter { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeGossipTimestampFilter *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKGossipTimestampFilter; + /** * An event generated by ChannelManager which indicates a message should be sent to a peer (or * broadcast to most peers). @@ -2938,6 +3883,11 @@ typedef enum LDKMessageSendEvent_Tag { * emitted during processing of the query. */ LDKMessageSendEvent_SendReplyChannelRange, + /** + * Sends a timestamp filter for inbound gossip. This should be sent on each new connection to + * enable receiving gossip messages from the peer. + */ + LDKMessageSendEvent_SendGossipTimestampFilter, /** * Must be last for serialization purposes */ @@ -3145,6 +4095,17 @@ typedef struct LDKMessageSendEvent_LDKSendReplyChannelRange_Body { struct LDKReplyChannelRange msg; } LDKMessageSendEvent_LDKSendReplyChannelRange_Body; +typedef struct LDKMessageSendEvent_LDKSendGossipTimestampFilter_Body { + /** + * The node_id of this message recipient + */ + struct LDKPublicKey node_id; + /** + * The gossip_timestamp_filter which should be sent. + */ + struct LDKGossipTimestampFilter msg; +} LDKMessageSendEvent_LDKSendGossipTimestampFilter_Body; + typedef struct MUST_USE_STRUCT LDKMessageSendEvent { LDKMessageSendEvent_Tag tag; union { @@ -3167,6 +4128,7 @@ typedef struct MUST_USE_STRUCT LDKMessageSendEvent { LDKMessageSendEvent_LDKSendChannelRangeQuery_Body send_channel_range_query; LDKMessageSendEvent_LDKSendShortIdsQuery_Body send_short_ids_query; LDKMessageSendEvent_LDKSendReplyChannelRange_Body send_reply_channel_range; + LDKMessageSendEvent_LDKSendGossipTimestampFilter_Body send_gossip_timestamp_filter; }; } LDKMessageSendEvent; @@ -3174,123 +4136,335 @@ typedef struct MUST_USE_STRUCT LDKMessageSendEvent { * A dynamically-allocated array of crate::lightning::util::events::MessageSendEvents of arbitrary size. * This corresponds to std::vector in C++ */ -typedef struct LDKCVec_MessageSendEventZ { +typedef struct LDKCVec_MessageSendEventZ { + /** + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + */ + struct LDKMessageSendEvent *data; + /** + * The number of elements pointed to by `data`. + */ + uintptr_t datalen; +} 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`]. + */ +typedef struct MUST_USE_STRUCT LDKScoringParameters { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeScoringParameters *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; +} LDKScoringParameters; + +/** + * The contents of CResult_ScoringParametersDecodeErrorZ + */ +typedef union LDKCResult_ScoringParametersDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKScoringParameters *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_ScoringParametersDecodeErrorZPtr; + +/** + * A CResult_ScoringParametersDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::routing::scoring::ScoringParameters 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_ScoringParametersDecodeErrorZ { + /** + * The contents of this CResult_ScoringParametersDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_ScoringParametersDecodeErrorZPtr contents; + /** + * Whether this CResult_ScoringParametersDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_ScoringParametersDecodeErrorZ; + + + +/** + * [`Score`] implementation that provides reasonable default behavior. + * + * 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 and [`ScoringParameters`] for customization. + * + * # Note + * + * Mixing the `no-std` feature between serialization and deserialization results in undefined + * behavior. + * + * [module-level documentation]: crate::routing::scoring + */ +typedef struct MUST_USE_STRUCT LDKScorer { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeScorer *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; +} LDKScorer; + +/** + * The contents of CResult_ScorerDecodeErrorZ + */ +typedef union LDKCResult_ScorerDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKScorer *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_ScorerDecodeErrorZPtr; + +/** + * A CResult_ScorerDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::routing::scoring::Scorer 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_ScorerDecodeErrorZ { + /** + * The contents of this CResult_ScorerDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_ScorerDecodeErrorZPtr contents; + /** + * Whether this CResult_ScorerDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_ScorerDecodeErrorZ; + + + +/** + * Represents the network as nodes and channels between them + */ +typedef struct MUST_USE_STRUCT LDKNetworkGraph { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - struct LDKMessageSendEvent *data; + LDKnativeNetworkGraph *inner; /** - * The number of elements pointed to by `data`. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - uintptr_t datalen; -} LDKCVec_MessageSendEventZ; + bool is_owned; +} LDKNetworkGraph; /** - * Features used within an `init` message. + * [`Score`] implementation using channel success probability distributions. + * + * Based on *Optimally Reliable & Cheap Payment Flows on the Lightning Network* by Rene Pickhardt + * and Stefan Richter [[1]]. Given the uncertainty of channel liquidity balances, probability + * distributions are defined based on knowledge learned from successful and unsuccessful attempts. + * Then the negative `log10` of the success probability is used to determine the cost of routing a + * specific HTLC amount through a channel. + * + * Knowledge about channel liquidity balances takes the form of upper and lower bounds on the + * possible liquidity. Certainty of the bounds is decreased over time using a decay function. See + * [`ProbabilisticScoringParameters`] for details. + * + * Since the scorer aims to learn the current channel liquidity balances, it works best for nodes + * with high payment volume or that actively probe the [`NetworkGraph`]. Nodes with low payment + * volume are more likely to experience failed payment paths, which would need to be retried. + * + * # Note + * + * Mixing the `no-std` feature between serialization and deserialization results in undefined + * behavior. + * + * [1]: https://arxiv.org/abs/2107.05322 */ -typedef struct MUST_USE_STRUCT LDKInitFeatures { +typedef struct MUST_USE_STRUCT LDKProbabilisticScorer { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeInitFeatures *inner; + LDKnativeProbabilisticScorer *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKInitFeatures; +} LDKProbabilisticScorer; /** - * The contents of CResult_InitFeaturesDecodeErrorZ + * The contents of CResult_ProbabilisticScorerDecodeErrorZ */ -typedef union LDKCResult_InitFeaturesDecodeErrorZPtr { +typedef union LDKCResult_ProbabilisticScorerDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKInitFeatures *result; + struct LDKProbabilisticScorer *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_InitFeaturesDecodeErrorZPtr; +} LDKCResult_ProbabilisticScorerDecodeErrorZPtr; /** - * A CResult_InitFeaturesDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::features::InitFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_ProbabilisticScorerDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::routing::scoring::ProbabilisticScorer on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_InitFeaturesDecodeErrorZ { +typedef struct LDKCResult_ProbabilisticScorerDecodeErrorZ { /** - * The contents of this CResult_InitFeaturesDecodeErrorZ, accessible via either + * The contents of this CResult_ProbabilisticScorerDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_InitFeaturesDecodeErrorZPtr contents; + union LDKCResult_ProbabilisticScorerDecodeErrorZPtr contents; /** - * Whether this CResult_InitFeaturesDecodeErrorZ represents a success state. + * Whether this CResult_ProbabilisticScorerDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_InitFeaturesDecodeErrorZ; +} LDKCResult_ProbabilisticScorerDecodeErrorZ; /** - * Features used within a `node_announcement` message. + * Features used within an `init` message. */ -typedef struct MUST_USE_STRUCT LDKNodeFeatures { +typedef struct MUST_USE_STRUCT LDKInitFeatures { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeNodeFeatures *inner; + LDKnativeInitFeatures *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKNodeFeatures; +} LDKInitFeatures; /** - * The contents of CResult_NodeFeaturesDecodeErrorZ + * The contents of CResult_InitFeaturesDecodeErrorZ */ -typedef union LDKCResult_NodeFeaturesDecodeErrorZPtr { +typedef union LDKCResult_InitFeaturesDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKNodeFeatures *result; + struct LDKInitFeatures *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_NodeFeaturesDecodeErrorZPtr; +} LDKCResult_InitFeaturesDecodeErrorZPtr; /** - * A CResult_NodeFeaturesDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::features::NodeFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_InitFeaturesDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::features::InitFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_NodeFeaturesDecodeErrorZ { +typedef struct LDKCResult_InitFeaturesDecodeErrorZ { /** - * The contents of this CResult_NodeFeaturesDecodeErrorZ, accessible via either + * The contents of this CResult_InitFeaturesDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_NodeFeaturesDecodeErrorZPtr contents; + union LDKCResult_InitFeaturesDecodeErrorZPtr contents; /** - * Whether this CResult_NodeFeaturesDecodeErrorZ represents a success state. + * Whether this CResult_InitFeaturesDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_NodeFeaturesDecodeErrorZ; +} LDKCResult_InitFeaturesDecodeErrorZ; @@ -3348,168 +4522,141 @@ typedef struct LDKCResult_ChannelFeaturesDecodeErrorZ { /** - * Features used within an invoice. + * Features used within a `node_announcement` message. */ -typedef struct MUST_USE_STRUCT LDKInvoiceFeatures { +typedef struct MUST_USE_STRUCT LDKNodeFeatures { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeInvoiceFeatures *inner; + LDKnativeNodeFeatures *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKInvoiceFeatures; +} LDKNodeFeatures; /** - * The contents of CResult_InvoiceFeaturesDecodeErrorZ + * The contents of CResult_NodeFeaturesDecodeErrorZ */ -typedef union LDKCResult_InvoiceFeaturesDecodeErrorZPtr { +typedef union LDKCResult_NodeFeaturesDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKInvoiceFeatures *result; + struct LDKNodeFeatures *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_InvoiceFeaturesDecodeErrorZPtr; +} LDKCResult_NodeFeaturesDecodeErrorZPtr; /** - * A CResult_InvoiceFeaturesDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::features::InvoiceFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_NodeFeaturesDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::features::NodeFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_InvoiceFeaturesDecodeErrorZ { +typedef struct LDKCResult_NodeFeaturesDecodeErrorZ { /** - * The contents of this CResult_InvoiceFeaturesDecodeErrorZ, accessible via either + * The contents of this CResult_NodeFeaturesDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_InvoiceFeaturesDecodeErrorZPtr contents; + union LDKCResult_NodeFeaturesDecodeErrorZPtr contents; /** - * Whether this CResult_InvoiceFeaturesDecodeErrorZ represents a success state. + * Whether this CResult_NodeFeaturesDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_InvoiceFeaturesDecodeErrorZ; +} LDKCResult_NodeFeaturesDecodeErrorZ; /** - * Parameters for configuring [`Scorer`]. + * Features used within an invoice. */ -typedef struct MUST_USE_STRUCT LDKScoringParameters { +typedef struct MUST_USE_STRUCT LDKInvoiceFeatures { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeScoringParameters *inner; + LDKnativeInvoiceFeatures *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; -} LDKScoringParameters; +} LDKInvoiceFeatures; /** - * The contents of CResult_ScoringParametersDecodeErrorZ + * The contents of CResult_InvoiceFeaturesDecodeErrorZ */ -typedef union LDKCResult_ScoringParametersDecodeErrorZPtr { +typedef union LDKCResult_InvoiceFeaturesDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKScoringParameters *result; + struct LDKInvoiceFeatures *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_ScoringParametersDecodeErrorZPtr; +} LDKCResult_InvoiceFeaturesDecodeErrorZPtr; /** - * A CResult_ScoringParametersDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::routing::scorer::ScoringParameters on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_InvoiceFeaturesDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::features::InvoiceFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_ScoringParametersDecodeErrorZ { +typedef struct LDKCResult_InvoiceFeaturesDecodeErrorZ { /** - * The contents of this CResult_ScoringParametersDecodeErrorZ, accessible via either + * The contents of this CResult_InvoiceFeaturesDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_ScoringParametersDecodeErrorZPtr contents; + union LDKCResult_InvoiceFeaturesDecodeErrorZPtr contents; /** - * Whether this CResult_ScoringParametersDecodeErrorZ represents a success state. + * Whether this CResult_InvoiceFeaturesDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_ScoringParametersDecodeErrorZ; - - - -/** - * [`routing::Score`] implementation that provides reasonable default behavior. - * - * 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. - * - * [module-level documentation]: crate::routing::scorer - */ -typedef struct MUST_USE_STRUCT LDKScorer { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeScorer *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; -} LDKScorer; +} LDKCResult_InvoiceFeaturesDecodeErrorZ; /** - * The contents of CResult_ScorerDecodeErrorZ + * The contents of CResult_ChannelTypeFeaturesDecodeErrorZ */ -typedef union LDKCResult_ScorerDecodeErrorZPtr { +typedef union LDKCResult_ChannelTypeFeaturesDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKScorer *result; + struct LDKChannelTypeFeatures *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_ScorerDecodeErrorZPtr; +} LDKCResult_ChannelTypeFeaturesDecodeErrorZPtr; /** - * A CResult_ScorerDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::routing::scorer::Scorer on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_ChannelTypeFeaturesDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::features::ChannelTypeFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_ScorerDecodeErrorZ { +typedef struct LDKCResult_ChannelTypeFeaturesDecodeErrorZ { /** - * The contents of this CResult_ScorerDecodeErrorZ, accessible via either + * The contents of this CResult_ChannelTypeFeaturesDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_ScorerDecodeErrorZPtr contents; + union LDKCResult_ChannelTypeFeaturesDecodeErrorZPtr contents; /** - * Whether this CResult_ScorerDecodeErrorZ represents a success state. + * Whether this CResult_ChannelTypeFeaturesDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_ScorerDecodeErrorZ; +} LDKCResult_ChannelTypeFeaturesDecodeErrorZ; /** * The contents of CResult_DelayedPaymentOutputDescriptorDecodeErrorZ @@ -3611,35 +4758,20 @@ typedef struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ { } LDKCResult_SpendableOutputDescriptorDecodeErrorZ; /** - * 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`. + * A dynamically-allocated array of crate::c_types::ThirtyTwoBytess of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef struct LDKCResult_NoneNoneZ { +typedef struct LDKCVec_PaymentPreimageZ { /** - * The contents of this CResult_NoneNoneZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - union LDKCResult_NoneNoneZPtr contents; + struct LDKThirtyTwoBytes *data; /** - * 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. @@ -3703,21 +4835,99 @@ typedef union LDKCResult_SignatureNoneZPtr { } LDKCResult_SignatureNoneZPtr; /** - * A CResult_SignatureNoneZ represents the result of a fallible operation, - * containing a crate::c_types::Signature on success and a () on failure. + * A CResult_SignatureNoneZ represents the result of a fallible operation, + * containing a crate::c_types::Signature on success and a () on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_SignatureNoneZ { + /** + * The contents of this CResult_SignatureNoneZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_SignatureNoneZPtr contents; + /** + * Whether this CResult_SignatureNoneZ represents a success state. + */ + 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_SignatureNoneZ { +typedef struct LDKCResult_SecretKeyNoneZ { /** - * The contents of this CResult_SignatureNoneZ, accessible via either + * The contents of this CResult_SecretKeyNoneZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_SignatureNoneZPtr contents; + union LDKCResult_SecretKeyNoneZPtr contents; /** - * Whether this CResult_SignatureNoneZ represents a success state. + * Whether this CResult_SecretKeyNoneZ represents a success state. */ bool result_ok; -} LDKCResult_SignatureNoneZ; +} LDKCResult_SecretKeyNoneZ; @@ -3812,8 +5022,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 */ @@ -3837,8 +5054,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. * @@ -3925,14 +5149,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. @@ -4020,6 +5247,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. @@ -4429,235 +5679,21 @@ typedef struct LDKAPIError_LDKIncompatibleShutdownScript_Body { struct LDKShutdownScript script; } LDKAPIError_LDKIncompatibleShutdownScript_Body; -typedef struct MUST_USE_STRUCT LDKAPIError { - LDKAPIError_Tag tag; - union { - LDKAPIError_LDKAPIMisuseError_Body api_misuse_error; - LDKAPIError_LDKFeeRateTooHigh_Body fee_rate_too_high; - LDKAPIError_LDKRouteError_Body route_error; - LDKAPIError_LDKChannelUnavailable_Body channel_unavailable; - LDKAPIError_LDKIncompatibleShutdownScript_Body incompatible_shutdown_script; - }; -} LDKAPIError; - -/** - * The contents of CResult_NoneAPIErrorZ - */ -typedef union LDKCResult_NoneAPIErrorZPtr { - /** - * Note that this value is always NULL, as there are no contents in the OK variant - */ - void *result; - /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. - */ - struct LDKAPIError *err; -} LDKCResult_NoneAPIErrorZPtr; - -/** - * A CResult_NoneAPIErrorZ represents the result of a fallible operation, - * containing a () on success and a crate::lightning::util::errors::APIError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_NoneAPIErrorZ { - /** - * The contents of this CResult_NoneAPIErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. - */ - union LDKCResult_NoneAPIErrorZPtr contents; - /** - * Whether this CResult_NoneAPIErrorZ represents a success state. - */ - bool result_ok; -} LDKCResult_NoneAPIErrorZ; - -/** - * A dynamically-allocated array of crate::c_types::derived::CResult_NoneAPIErrorZs of arbitrary size. - * This corresponds to std::vector in C++ - */ -typedef struct LDKCVec_CResult_NoneAPIErrorZZ { - /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - */ - struct LDKCResult_NoneAPIErrorZ *data; - /** - * The number of elements pointed to by `data`. - */ - uintptr_t datalen; -} LDKCVec_CResult_NoneAPIErrorZZ; - -/** - * A dynamically-allocated array of crate::lightning::util::errors::APIErrors of arbitrary size. - * This corresponds to std::vector in C++ - */ -typedef struct LDKCVec_APIErrorZ { - /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - */ - struct LDKAPIError *data; - /** - * The number of elements pointed to by `data`. - */ - uintptr_t datalen; -} LDKCVec_APIErrorZ; - -/** - * The contents of CResult__u832APIErrorZ - */ -typedef union LDKCResult__u832APIErrorZPtr { - /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. - */ - struct LDKThirtyTwoBytes *result; - /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. - */ - struct LDKAPIError *err; -} LDKCResult__u832APIErrorZPtr; - -/** - * A CResult__u832APIErrorZ represents the result of a fallible operation, - * containing a crate::c_types::ThirtyTwoBytes on success and a crate::lightning::util::errors::APIError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult__u832APIErrorZ { - /** - * The contents of this CResult__u832APIErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. - */ - union LDKCResult__u832APIErrorZPtr contents; - /** - * Whether this CResult__u832APIErrorZ represents a success state. - */ - bool result_ok; -} LDKCResult__u832APIErrorZ; - -/** - * If a payment fails to send, it can be in one of several states. This enum is returned as the - * Err() type describing which state the payment is in, see the description of individual enum - * states for more. - */ -typedef enum LDKPaymentSendFailure_Tag { - /** - * A parameter which was passed to send_payment was invalid, preventing us from attempting to - * send the payment at all. No channel state has been changed or messages sent to peers, and - * once you've changed the parameter at error, you can freely retry the payment in full. - */ - LDKPaymentSendFailure_ParameterError, - /** - * A parameter in a single path which was passed to send_payment was invalid, preventing us - * from attempting to send the payment at all. No channel state has been changed or messages - * sent to peers, and once you've changed the parameter at error, you can freely retry the - * payment in full. - * - * The results here are ordered the same as the paths in the route object which was passed to - * send_payment. - */ - LDKPaymentSendFailure_PathParameterError, - /** - * All paths which were attempted failed to send, with no channel state change taking place. - * You can freely retry the payment in full (though you probably want to do so over different - * paths than the ones selected). - */ - LDKPaymentSendFailure_AllFailedRetrySafe, - /** - * Some paths which were attempted failed to send, though possibly not all. At least some - * paths have irrevocably committed to the HTLC and retrying the payment in full would result - * in over-/re-payment. - * - * The results here are ordered the same as the paths in the route object which was passed to - * send_payment, and any Errs which are not APIError::MonitorUpdateFailed can be safely - * retried (though there is currently no API with which to do so). - * - * Any entries which contain Err(APIError::MonitorUpdateFailed) or Ok(()) MUST NOT be retried - * as they will result in over-/re-payment. These HTLCs all either successfully sent (in the - * case of Ok(())) or will send once channel_monitor_updated is called on the next-hop channel - * with the latest update_id. - */ - LDKPaymentSendFailure_PartialFailure, - /** - * Must be last for serialization purposes - */ - LDKPaymentSendFailure_Sentinel, -} LDKPaymentSendFailure_Tag; - -typedef struct LDKPaymentSendFailure_LDKPartialFailure_Body { - /** - * The errors themselves, in the same order as the route hops. - */ - struct LDKCVec_CResult_NoneAPIErrorZZ results; - /** - * If some paths failed without irrevocably committing to the new HTLC(s), this will - * contain a [`RouteParameters`] object which can be used to calculate a new route that - * will pay all remaining unpaid balance. - * - * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None - */ - struct LDKRouteParameters failed_paths_retry; - /** - * The payment id for the payment, which is now at least partially pending. - */ - struct LDKThirtyTwoBytes payment_id; -} LDKPaymentSendFailure_LDKPartialFailure_Body; - -typedef struct MUST_USE_STRUCT LDKPaymentSendFailure { - LDKPaymentSendFailure_Tag tag; - union { - struct { - struct LDKAPIError parameter_error; - }; - struct { - struct LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error; - }; - struct { - struct LDKCVec_APIErrorZ all_failed_retry_safe; - }; - LDKPaymentSendFailure_LDKPartialFailure_Body partial_failure; - }; -} LDKPaymentSendFailure; - -/** - * The contents of CResult_PaymentIdPaymentSendFailureZ - */ -typedef union LDKCResult_PaymentIdPaymentSendFailureZPtr { - /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. - */ - struct LDKThirtyTwoBytes *result; - /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. - */ - struct LDKPaymentSendFailure *err; -} LDKCResult_PaymentIdPaymentSendFailureZPtr; - -/** - * A CResult_PaymentIdPaymentSendFailureZ represents the result of a fallible operation, - * containing a crate::c_types::ThirtyTwoBytes on success and a crate::lightning::ln::channelmanager::PaymentSendFailure on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_PaymentIdPaymentSendFailureZ { - /** - * The contents of this CResult_PaymentIdPaymentSendFailureZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. - */ - union LDKCResult_PaymentIdPaymentSendFailureZPtr contents; - /** - * Whether this CResult_PaymentIdPaymentSendFailureZ represents a success state. - */ - bool result_ok; -} LDKCResult_PaymentIdPaymentSendFailureZ; - +typedef struct MUST_USE_STRUCT LDKAPIError { + LDKAPIError_Tag tag; + union { + LDKAPIError_LDKAPIMisuseError_Body api_misuse_error; + LDKAPIError_LDKFeeRateTooHigh_Body fee_rate_too_high; + LDKAPIError_LDKRouteError_Body route_error; + LDKAPIError_LDKChannelUnavailable_Body channel_unavailable; + LDKAPIError_LDKIncompatibleShutdownScript_Body incompatible_shutdown_script; + }; +} LDKAPIError; + /** - * The contents of CResult_NonePaymentSendFailureZ + * The contents of CResult_NoneAPIErrorZ */ -typedef union LDKCResult_NonePaymentSendFailureZPtr { +typedef union LDKCResult_NoneAPIErrorZPtr { /** * Note that this value is always NULL, as there are no contents in the OK variant */ @@ -4666,227 +5702,179 @@ typedef union LDKCResult_NonePaymentSendFailureZPtr { * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKPaymentSendFailure *err; -} LDKCResult_NonePaymentSendFailureZPtr; + struct LDKAPIError *err; +} LDKCResult_NoneAPIErrorZPtr; /** - * A CResult_NonePaymentSendFailureZ represents the result of a fallible operation, - * containing a () on success and a crate::lightning::ln::channelmanager::PaymentSendFailure on failure. + * A CResult_NoneAPIErrorZ represents the result of a fallible operation, + * containing a () on success and a crate::lightning::util::errors::APIError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_NonePaymentSendFailureZ { +typedef struct LDKCResult_NoneAPIErrorZ { /** - * The contents of this CResult_NonePaymentSendFailureZ, accessible via either + * The contents of this CResult_NoneAPIErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_NonePaymentSendFailureZPtr contents; + union LDKCResult_NoneAPIErrorZPtr contents; /** - * Whether this CResult_NonePaymentSendFailureZ represents a success state. + * Whether this CResult_NoneAPIErrorZ represents a success state. */ bool result_ok; -} LDKCResult_NonePaymentSendFailureZ; +} LDKCResult_NoneAPIErrorZ; /** - * A tuple of 2 elements. See the individual fields for the types contained. + * A dynamically-allocated array of crate::c_types::derived::CResult_NoneAPIErrorZs of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef struct LDKC2Tuple_PaymentHashPaymentIdZ { +typedef struct LDKCVec_CResult_NoneAPIErrorZZ { /** - * The element at position 0 + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - struct LDKThirtyTwoBytes a; + struct LDKCResult_NoneAPIErrorZ *data; /** - * The element at position 1 + * The number of elements pointed to by `data`. */ - struct LDKThirtyTwoBytes b; -} LDKC2Tuple_PaymentHashPaymentIdZ; + uintptr_t datalen; +} LDKCVec_CResult_NoneAPIErrorZZ; /** - * The contents of CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ + * A dynamically-allocated array of crate::lightning::util::errors::APIErrors of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef union LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZPtr { +typedef struct LDKCVec_APIErrorZ { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - struct LDKC2Tuple_PaymentHashPaymentIdZ *result; + struct LDKAPIError *data; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * The number of elements pointed to by `data`. */ - struct LDKPaymentSendFailure *err; -} LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZPtr; + uintptr_t datalen; +} LDKCVec_APIErrorZ; /** - * A CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ represents the result of a fallible operation, - * containing a crate::c_types::derived::C2Tuple_PaymentHashPaymentIdZ on success and a crate::lightning::ln::channelmanager::PaymentSendFailure on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * The contents of CResult__u832APIErrorZ */ -typedef struct LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ { - /** - * The contents of this CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. - */ - union LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZPtr contents; +typedef union LDKCResult__u832APIErrorZPtr { /** - * Whether this CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ represents a success state. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - bool result_ok; -} LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ; - -/** - * A 4-byte byte array. - */ -typedef struct LDKFourBytes { + struct LDKThirtyTwoBytes *result; /** - * The four bytes + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - uint8_t data[4]; -} LDKFourBytes; + struct LDKAPIError *err; +} LDKCResult__u832APIErrorZPtr; /** - * A 16-byte byte array. + * A CResult__u832APIErrorZ represents the result of a fallible operation, + * containing a crate::c_types::ThirtyTwoBytes on success and a crate::lightning::util::errors::APIError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKSixteenBytes { +typedef struct LDKCResult__u832APIErrorZ { /** - * The sixteen bytes + * The contents of this CResult__u832APIErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - uint8_t data[16]; -} LDKSixteenBytes; - -/** - * A 10-byte byte array. - */ -typedef struct LDKTenBytes { + union LDKCResult__u832APIErrorZPtr contents; /** - * The ten bytes + * Whether this CResult__u832APIErrorZ represents a success state. */ - uint8_t data[10]; -} LDKTenBytes; + bool result_ok; +} LDKCResult__u832APIErrorZ; /** - * An address which can be used to connect to a remote peer + * If a payment fails to send, it can be in one of several states. This enum is returned as the + * Err() type describing which state the payment is in, see the description of individual enum + * states for more. */ -typedef enum LDKNetAddress_Tag { +typedef enum LDKPaymentSendFailure_Tag { /** - * An IPv4 address/port on which the peer is listening. + * A parameter which was passed to send_payment was invalid, preventing us from attempting to + * send the payment at all. No channel state has been changed or messages sent to peers, and + * once you've changed the parameter at error, you can freely retry the payment in full. */ - LDKNetAddress_IPv4, + LDKPaymentSendFailure_ParameterError, /** - * An IPv6 address/port on which the peer is listening. + * A parameter in a single path which was passed to send_payment was invalid, preventing us + * from attempting to send the payment at all. No channel state has been changed or messages + * sent to peers, and once you've changed the parameter at error, you can freely retry the + * payment in full. + * + * The results here are ordered the same as the paths in the route object which was passed to + * send_payment. */ - LDKNetAddress_IPv6, + LDKPaymentSendFailure_PathParameterError, /** - * An old-style Tor onion address/port on which the peer is listening. + * All paths which were attempted failed to send, with no channel state change taking place. + * You can freely retry the payment in full (though you probably want to do so over different + * paths than the ones selected). */ - LDKNetAddress_OnionV2, + LDKPaymentSendFailure_AllFailedRetrySafe, /** - * A new-style Tor onion address/port on which the peer is listening. - * To create the human-readable \"hostname\", concatenate ed25519_pubkey, checksum, and version, - * wrap as base32 and append \".onion\". + * Some paths which were attempted failed to send, though possibly not all. At least some + * paths have irrevocably committed to the HTLC and retrying the payment in full would result + * in over-/re-payment. + * + * The results here are ordered the same as the paths in the route object which was passed to + * send_payment, and any Errs which are not APIError::MonitorUpdateFailed can be safely + * retried (though there is currently no API with which to do so). + * + * Any entries which contain Err(APIError::MonitorUpdateFailed) or Ok(()) MUST NOT be retried + * as they will result in over-/re-payment. These HTLCs all either successfully sent (in the + * case of Ok(())) or will send once channel_monitor_updated is called on the next-hop channel + * with the latest update_id. */ - LDKNetAddress_OnionV3, + LDKPaymentSendFailure_PartialFailure, /** * Must be last for serialization purposes */ - LDKNetAddress_Sentinel, -} LDKNetAddress_Tag; - -typedef struct LDKNetAddress_LDKIPv4_Body { - /** - * The 4-byte IPv4 address - */ - struct LDKFourBytes addr; - /** - * The port on which the node is listening - */ - uint16_t port; -} LDKNetAddress_LDKIPv4_Body; - -typedef struct LDKNetAddress_LDKIPv6_Body { - /** - * The 16-byte IPv6 address - */ - struct LDKSixteenBytes addr; - /** - * The port on which the node is listening - */ - uint16_t port; -} LDKNetAddress_LDKIPv6_Body; - -typedef struct LDKNetAddress_LDKOnionV2_Body { - /** - * The bytes (usually encoded in base32 with \".onion\" appended) - */ - struct LDKTenBytes addr; - /** - * The port on which the node is listening - */ - uint16_t port; -} LDKNetAddress_LDKOnionV2_Body; + LDKPaymentSendFailure_Sentinel, +} LDKPaymentSendFailure_Tag; -typedef struct LDKNetAddress_LDKOnionV3_Body { - /** - * The ed25519 long-term public key of the peer - */ - struct LDKThirtyTwoBytes ed25519_pubkey; - /** - * The checksum of the pubkey and version, as included in the onion address - */ - uint16_t checksum; - /** - * The version byte, as defined by the Tor Onion v3 spec. - */ - uint8_t version; +typedef struct LDKPaymentSendFailure_LDKPartialFailure_Body { /** - * The port on which the node is listening + * The errors themselves, in the same order as the route hops. */ - uint16_t port; -} LDKNetAddress_LDKOnionV3_Body; - -typedef struct MUST_USE_STRUCT LDKNetAddress { - LDKNetAddress_Tag tag; - union { - LDKNetAddress_LDKIPv4_Body i_pv4; - LDKNetAddress_LDKIPv6_Body i_pv6; - LDKNetAddress_LDKOnionV2_Body onion_v2; - LDKNetAddress_LDKOnionV3_Body onion_v3; - }; -} LDKNetAddress; - -/** - * A dynamically-allocated array of crate::lightning::ln::msgs::NetAddresss of arbitrary size. - * This corresponds to std::vector in C++ - */ -typedef struct LDKCVec_NetAddressZ { + struct LDKCVec_CResult_NoneAPIErrorZZ results; /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * If some paths failed without irrevocably committing to the new HTLC(s), this will + * contain a [`RouteParameters`] object which can be used to calculate a new route that + * will pay all remaining unpaid balance. + * + * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None */ - struct LDKNetAddress *data; + struct LDKRouteParameters failed_paths_retry; /** - * The number of elements pointed to by `data`. + * The payment id for the payment, which is now at least partially pending. */ - uintptr_t datalen; -} LDKCVec_NetAddressZ; + struct LDKThirtyTwoBytes payment_id; +} LDKPaymentSendFailure_LDKPartialFailure_Body; -/** - * A tuple of 2 elements. See the individual fields for the types contained. - */ -typedef struct LDKC2Tuple_PaymentHashPaymentSecretZ { - /** - * The element at position 0 - */ - struct LDKThirtyTwoBytes a; - /** - * The element at position 1 - */ - struct LDKThirtyTwoBytes b; -} LDKC2Tuple_PaymentHashPaymentSecretZ; +typedef struct MUST_USE_STRUCT LDKPaymentSendFailure { + LDKPaymentSendFailure_Tag tag; + union { + struct { + struct LDKAPIError parameter_error; + }; + struct { + struct LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error; + }; + struct { + struct LDKCVec_APIErrorZ all_failed_retry_safe; + }; + LDKPaymentSendFailure_LDKPartialFailure_Body partial_failure; + }; +} LDKPaymentSendFailure; /** - * The contents of CResult_PaymentSecretAPIErrorZ + * The contents of CResult_PaymentIdPaymentSendFailureZ */ -typedef union LDKCResult_PaymentSecretAPIErrorZPtr { +typedef union LDKCResult_PaymentIdPaymentSendFailureZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. @@ -4896,345 +5884,239 @@ typedef union LDKCResult_PaymentSecretAPIErrorZPtr { * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKAPIError *err; -} LDKCResult_PaymentSecretAPIErrorZPtr; + struct LDKPaymentSendFailure *err; +} LDKCResult_PaymentIdPaymentSendFailureZPtr; /** - * 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_PaymentIdPaymentSendFailureZ represents the result of a fallible operation, + * containing a crate::c_types::ThirtyTwoBytes on success and a crate::lightning::ln::channelmanager::PaymentSendFailure on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_PaymentSecretAPIErrorZ { +typedef struct LDKCResult_PaymentIdPaymentSendFailureZ { /** - * The contents of this CResult_PaymentSecretAPIErrorZ, accessible via either + * The contents of this CResult_PaymentIdPaymentSendFailureZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_PaymentSecretAPIErrorZPtr contents; + union LDKCResult_PaymentIdPaymentSendFailureZPtr contents; /** - * Whether this CResult_PaymentSecretAPIErrorZ represents a success state. + * Whether this CResult_PaymentIdPaymentSendFailureZ represents a success state. */ bool result_ok; -} LDKCResult_PaymentSecretAPIErrorZ; +} LDKCResult_PaymentIdPaymentSendFailureZ; /** - * A dynamically-allocated array of crate::lightning::chain::channelmonitor::ChannelMonitors of arbitrary size. - * This corresponds to std::vector in C++ + * The contents of CResult_NonePaymentSendFailureZ */ -typedef struct LDKCVec_ChannelMonitorZ { +typedef union LDKCResult_NonePaymentSendFailureZPtr { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * Note that this value is always NULL, as there are no contents in the OK variant */ - struct LDKChannelMonitor *data; + void *result; /** - * The number of elements pointed to by `data`. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - uintptr_t datalen; -} LDKCVec_ChannelMonitorZ; - - + struct LDKPaymentSendFailure *err; +} LDKCResult_NonePaymentSendFailureZPtr; /** - * An update generated by the underlying Channel itself which contains some new information the - * ChannelMonitor should be made aware of. + * A CResult_NonePaymentSendFailureZ represents the result of a fallible operation, + * containing a () on success and a crate::lightning::ln::channelmanager::PaymentSendFailure on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct MUST_USE_STRUCT LDKChannelMonitorUpdate { +typedef struct LDKCResult_NonePaymentSendFailureZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The contents of this CResult_NonePaymentSendFailureZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKnativeChannelMonitorUpdate *inner; + union LDKCResult_NonePaymentSendFailureZPtr contents; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * Whether this CResult_NonePaymentSendFailureZ represents a success state. */ - bool is_owned; -} LDKChannelMonitorUpdate; + bool result_ok; +} LDKCResult_NonePaymentSendFailureZ; /** - * The `Watch` trait defines behavior for watching on-chain activity pertaining to channels as - * blocks are connected and disconnected. - * - * Each channel is associated with a [`ChannelMonitor`]. Implementations of this trait are - * responsible for maintaining a set of monitors such that they can be updated accordingly as - * channel state changes and HTLCs are resolved. See method documentation for specific - * requirements. - * - * Implementations **must** ensure that updates are successfully applied and persisted upon method - * completion. If an update fails with a [`PermanentFailure`], then it must immediately shut down - * without taking any further action such as persisting the current state. - * - * If an implementation maintains multiple instances of a channel's monitor (e.g., by storing - * backup copies), then it must ensure that updates are applied across all instances. Otherwise, it - * could result in a revoked transaction being broadcast, allowing the counterparty to claim all - * funds in the channel. See [`ChannelMonitorUpdateErr`] for more details about how to handle - * multiple instances. - * - * [`PermanentFailure`]: ChannelMonitorUpdateErr::PermanentFailure + * A tuple of 2 elements. See the individual fields for the types contained. */ -typedef struct LDKWatch { - /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. - */ - void *this_arg; +typedef struct LDKC2Tuple_PaymentHashPaymentIdZ { /** - * Watches a channel identified by `funding_txo` using `monitor`. - * - * Implementations are responsible for watching the chain for the funding transaction along - * with any spends of outputs returned by [`get_outputs_to_watch`]. In practice, this means - * calling [`block_connected`] and [`block_disconnected`] on the monitor. - * - * Note: this interface MUST error with `ChannelMonitorUpdateErr::PermanentFailure` if - * the given `funding_txo` has previously been registered via `watch_channel`. - * - * [`get_outputs_to_watch`]: channelmonitor::ChannelMonitor::get_outputs_to_watch - * [`block_connected`]: channelmonitor::ChannelMonitor::block_connected - * [`block_disconnected`]: channelmonitor::ChannelMonitor::block_disconnected + * The element at position 0 */ - struct LDKCResult_NoneChannelMonitorUpdateErrZ (*watch_channel)(const void *this_arg, struct LDKOutPoint funding_txo, struct LDKChannelMonitor monitor); + struct LDKThirtyTwoBytes a; /** - * Updates a channel identified by `funding_txo` by applying `update` to its monitor. - * - * Implementations must call [`update_monitor`] with the given update. See - * [`ChannelMonitorUpdateErr`] for invariants around returning an error. - * - * [`update_monitor`]: channelmonitor::ChannelMonitor::update_monitor + * The element at position 1 */ - struct LDKCResult_NoneChannelMonitorUpdateErrZ (*update_channel)(const void *this_arg, struct LDKOutPoint funding_txo, struct LDKChannelMonitorUpdate update); + struct LDKThirtyTwoBytes b; +} LDKC2Tuple_PaymentHashPaymentIdZ; + +/** + * The contents of CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ + */ +typedef union LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZPtr { /** - * Returns any monitor events since the last call. Subsequent calls must only return new - * events. - * - * Note that after any block- or transaction-connection calls to a [`ChannelMonitor`], no - * further events may be returned here until the [`ChannelMonitor`] has been fully persisted - * to disk. - * - * For details on asynchronous [`ChannelMonitor`] updating and returning - * [`MonitorEvent::UpdateCompleted`] here, see [`ChannelMonitorUpdateErr::TemporaryFailure`]. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKCVec_MonitorEventZ (*release_pending_monitor_events)(const void *this_arg); + struct LDKC2Tuple_PaymentHashPaymentIdZ *result; /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - void (*free)(void *this_arg); -} LDKWatch; + struct LDKPaymentSendFailure *err; +} LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZPtr; /** - * An interface to send a transaction to the Bitcoin network. + * A CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ represents the result of a fallible operation, + * containing a crate::c_types::derived::C2Tuple_PaymentHashPaymentIdZ on success and a crate::lightning::ln::channelmanager::PaymentSendFailure on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKBroadcasterInterface { - /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. - */ - void *this_arg; +typedef struct LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ { /** - * Sends a transaction out to (hopefully) be mined. + * The contents of this CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - void (*broadcast_transaction)(const void *this_arg, struct LDKTransaction tx); + union LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZPtr contents; /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + * Whether this CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ represents a success state. */ - void (*free)(void *this_arg); -} LDKBroadcasterInterface; + bool result_ok; +} LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ; /** - * A "slice" referencing some byte array. This is simply a length-tagged pointer which does not - * own the memory pointed to by data. + * A 4-byte byte array. */ -typedef struct LDKu8slice { - /** - * A pointer to the byte buffer - */ - const uint8_t *data; +typedef struct LDKFourBytes { /** - * The number of bytes pointed to by `data`. + * The four bytes */ - uintptr_t datalen; -} LDKu8slice; + uint8_t data[4]; +} LDKFourBytes; /** - * A trait to describe an object which can get user secrets and key material. + * A 16-byte byte array. */ -typedef struct LDKKeysInterface { +typedef struct LDKSixteenBytes { /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. + * The sixteen bytes */ - void *this_arg; + uint8_t data[16]; +} LDKSixteenBytes; + +/** + * A 12-byte byte array. + */ +typedef struct LDKTwelveBytes { /** - * Get node secret key (aka node_id or network_key). - * - * This method must return the same value each time it is called. + * The twelve bytes */ - struct LDKSecretKey (*get_node_secret)(const void *this_arg); + uint8_t data[12]; +} LDKTwelveBytes; + +/** + * An address which can be used to connect to a remote peer + */ +typedef enum LDKNetAddress_Tag { /** - * Get a script pubkey which we send funds to when claiming on-chain contestable outputs. - * - * This method should return a different value each time it is called, to avoid linking - * on-chain funds across channels as controlled to the same user. + * An IPv4 address/port on which the peer is listening. */ - struct LDKCVec_u8Z (*get_destination_script)(const void *this_arg); + LDKNetAddress_IPv4, /** - * Get a script pubkey which we will send funds to when closing a channel. - * - * This method should return a different value each time it is called, to avoid linking - * on-chain funds across channels as controlled to the same user. + * An IPv6 address/port on which the peer is listening. */ - struct LDKShutdownScript (*get_shutdown_scriptpubkey)(const void *this_arg); + LDKNetAddress_IPv6, /** - * Get a new set of Sign for per-channel secrets. These MUST be unique even if you - * restarted with some stale data! + * An old-style Tor onion address/port on which the peer is listening. * - * This method must return a different value each time it is called. + * This field is deprecated and the Tor network generally no longer supports V2 Onion + * addresses. Thus, the details are not parsed here. */ - struct LDKSign (*get_channel_signer)(const void *this_arg, bool inbound, uint64_t channel_value_satoshis); + LDKNetAddress_OnionV2, /** - * Gets a unique, cryptographically-secure, random 32 byte value. This is used for encrypting - * onion packets and for temporary channel IDs. There is no requirement that these be - * persisted anywhere, though they must be unique across restarts. - * - * This method must return a different value each time it is called. + * A new-style Tor onion address/port on which the peer is listening. + * To create the human-readable \"hostname\", concatenate ed25519_pubkey, checksum, and version, + * wrap as base32 and append \".onion\". */ - struct LDKThirtyTwoBytes (*get_secure_random_bytes)(const void *this_arg); + LDKNetAddress_OnionV3, /** - * Reads a `Signer` for this `KeysInterface` from the given input stream. - * This is only called during deserialization of other objects which contain - * `Sign`-implementing objects (ie `ChannelMonitor`s and `ChannelManager`s). - * The bytes are exactly those which `::write()` writes, and - * contain no versioning scheme. You may wish to include your own version prefix and ensure - * you've read all of the provided bytes to ensure no corruption occurred. + * Must be last for serialization purposes */ - struct LDKCResult_SignDecodeErrorZ (*read_chan_signer)(const void *this_arg, struct LDKu8slice reader); + LDKNetAddress_Sentinel, +} LDKNetAddress_Tag; + +typedef struct LDKNetAddress_LDKIPv4_Body { /** - * 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 - * this trait to parse the invoice and make sure they're signing what they expect, rather than - * blindly signing the hash. + * The 4-byte IPv4 address */ - struct LDKCResult_RecoverableSignatureNoneZ (*sign_invoice)(const void *this_arg, struct LDKCVec_u8Z invoice_preimage); + struct LDKFourBytes addr; /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + * The port on which the node is listening */ - void (*free)(void *this_arg); -} LDKKeysInterface; + uint16_t port; +} LDKNetAddress_LDKIPv4_Body; -/** - * A trait which should be implemented to provide feerate information on a number of time - * horizons. - * - * Note that all of the functions implemented here *must* be reentrant-safe (obviously - they're - * called from inside the library in response to chain events, P2P events, or timer events). - */ -typedef struct LDKFeeEstimator { +typedef struct LDKNetAddress_LDKIPv6_Body { /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. + * The 16-byte IPv6 address */ - void *this_arg; + struct LDKSixteenBytes addr; /** - * Gets estimated satoshis of fee required per 1000 Weight-Units. - * - * Must be no smaller than 253 (ie 1 satoshi-per-byte rounded up to ensure later round-downs - * don't put us below 1 satoshi-per-byte). - * - * This translates to: - * * satoshis-per-byte * 250 - * * ceil(satoshis-per-kbyte / 4) + * The port on which the node is listening */ - uint32_t (*get_est_sat_per_1000_weight)(const void *this_arg, enum LDKConfirmationTarget confirmation_target); + uint16_t port; +} LDKNetAddress_LDKIPv6_Body; + +typedef struct LDKNetAddress_LDKOnionV3_Body { /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + * The ed25519 long-term public key of the peer */ - void (*free)(void *this_arg); -} LDKFeeEstimator; - -/** - * A trait encapsulating the operations required of a logger - */ -typedef struct LDKLogger { + struct LDKThirtyTwoBytes ed25519_pubkey; /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. + * The checksum of the pubkey and version, as included in the onion address */ - void *this_arg; + uint16_t checksum; /** - * Logs the `Record` + * The version byte, as defined by the Tor Onion v3 spec. */ - void (*log)(const void *this_arg, const char *record); + uint8_t version; /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + * The port on which the node is listening */ - void (*free)(void *this_arg); -} LDKLogger; - + uint16_t port; +} LDKNetAddress_LDKOnionV3_Body; +typedef struct MUST_USE_STRUCT LDKNetAddress { + LDKNetAddress_Tag tag; + union { + LDKNetAddress_LDKIPv4_Body i_pv4; + LDKNetAddress_LDKIPv6_Body i_pv6; + struct { + struct LDKTwelveBytes onion_v2; + }; + LDKNetAddress_LDKOnionV3_Body onion_v3; + }; +} LDKNetAddress; /** - * Manager which keeps track of a number of channels and sends messages to the appropriate - * channel, also tracking HTLC preimages and forwarding onion packets appropriately. - * - * Implements ChannelMessageHandler, handling the multi-channel parts and passing things through - * to individual Channels. - * - * Implements Writeable to write out all channel state to disk. Implies peer_disconnected() for - * all peers during write/read (though does not modify this instance, only the instance being - * serialized). This will result in any channels which have not yet exchanged funding_created (ie - * called funding_transaction_generated for outbound channels). - * - * Note that you can be a bit lazier about writing out ChannelManager than you can be with - * ChannelMonitors. With ChannelMonitors you MUST write each monitor update out to disk before - * returning from chain::Watch::watch_/update_channel, with ChannelManagers, writing updates - * happens out-of-band (and will prevent any other ChannelManager operations from occurring during - * the serialization process). If the deserialized version is out-of-date compared to the - * ChannelMonitors passed by reference to read(), those channels will be force-closed based on the - * ChannelMonitor state and no funds will be lost (mod on-chain transaction fees). - * - * Note that the deserializer is only implemented for (BlockHash, ChannelManager), which - * tells you the last block hash which was block_connect()ed. You MUST rescan any blocks along - * the \"reorg path\" (ie call block_disconnected() until you get to a common block and then call - * block_connected() to step towards your best block) upon deserialization before using the - * object! - * - * Note that ChannelManager is responsible for tracking liveness of its channels and generating - * ChannelUpdate messages informing peers that the channel is temporarily disabled. To avoid - * spam due to quick disconnection/reconnection, updates are not sent until the channel has been - * offline for a full minute. In order to track this, you must call - * timer_tick_occurred roughly once per minute, though it doesn't have to be perfect. - * - * Rather than using a plain ChannelManager, it is preferable to use either a SimpleArcChannelManager - * a SimpleRefChannelManager, for conciseness. See their documentation for more details, but - * essentially you should default to using a SimpleRefChannelManager, and use a - * SimpleArcChannelManager when you require a ChannelManager with a static lifetime, such as when - * you're using lightning-net-tokio. + * A dynamically-allocated array of crate::lightning::ln::msgs::NetAddresss of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef struct MUST_USE_STRUCT LDKChannelManager { +typedef struct LDKCVec_NetAddressZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - LDKnativeChannelManager *inner; + struct LDKNetAddress *data; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The number of elements pointed to by `data`. */ - bool is_owned; -} LDKChannelManager; + uintptr_t datalen; +} LDKCVec_NetAddressZ; /** * A tuple of 2 elements. See the individual fields for the types contained. */ -typedef struct LDKC2Tuple_BlockHashChannelManagerZ { +typedef struct LDKC2Tuple_PaymentHashPaymentSecretZ { /** * The element at position 0 */ @@ -5242,1534 +6124,1757 @@ typedef struct LDKC2Tuple_BlockHashChannelManagerZ { /** * The element at position 1 */ - struct LDKChannelManager b; -} LDKC2Tuple_BlockHashChannelManagerZ; + struct LDKThirtyTwoBytes b; +} LDKC2Tuple_PaymentHashPaymentSecretZ; /** - * The contents of CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ + * The contents of CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ */ -typedef union LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr { +typedef union LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKC2Tuple_BlockHashChannelManagerZ *result; + struct LDKC2Tuple_PaymentHashPaymentSecretZ *result; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * Note that this value is always NULL, as there are no contents in the Err variant */ - struct LDKDecodeError *err; -} LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr; + void *err; +} LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZPtr; /** - * A CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ represents the result of a fallible operation, - * containing a crate::c_types::derived::C2Tuple_BlockHashChannelManagerZ on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ represents the result of a fallible operation, + * containing a crate::c_types::derived::C2Tuple_PaymentHashPaymentSecretZ on success and a () on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ { +typedef struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ { /** - * The contents of this CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ, accessible via either + * The contents of this CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr contents; + union LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZPtr contents; /** - * Whether this CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ represents a success state. + * Whether this CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ represents a success state. */ bool result_ok; -} LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ; - +} LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ; +/** + * The contents of CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ + */ +typedef union LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKC2Tuple_PaymentHashPaymentSecretZ *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + struct LDKAPIError *err; +} LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZPtr; /** - * Options which apply on a per-channel basis and may change at runtime or based on negotiation - * with our counterparty. + * A CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ represents the result of a fallible operation, + * containing a crate::c_types::derived::C2Tuple_PaymentHashPaymentSecretZ on success and a crate::lightning::util::errors::APIError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct MUST_USE_STRUCT LDKChannelConfig { +typedef struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The contents of this CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKnativeChannelConfig *inner; + union LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZPtr contents; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * Whether this CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ represents a success state. */ - bool is_owned; -} LDKChannelConfig; + bool result_ok; +} LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ; /** - * The contents of CResult_ChannelConfigDecodeErrorZ + * The contents of CResult_PaymentSecretNoneZ */ -typedef union LDKCResult_ChannelConfigDecodeErrorZPtr { +typedef union LDKCResult_PaymentSecretNoneZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKChannelConfig *result; + struct LDKThirtyTwoBytes *result; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * Note that this value is always NULL, as there are no contents in the Err variant */ - struct LDKDecodeError *err; -} LDKCResult_ChannelConfigDecodeErrorZPtr; + void *err; +} LDKCResult_PaymentSecretNoneZPtr; /** - * A CResult_ChannelConfigDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::util::config::ChannelConfig on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_PaymentSecretNoneZ represents the result of a fallible operation, + * containing a crate::c_types::ThirtyTwoBytes on success and a () on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_ChannelConfigDecodeErrorZ { +typedef struct LDKCResult_PaymentSecretNoneZ { /** - * The contents of this CResult_ChannelConfigDecodeErrorZ, accessible via either + * The contents of this CResult_PaymentSecretNoneZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_ChannelConfigDecodeErrorZPtr contents; + union LDKCResult_PaymentSecretNoneZPtr contents; /** - * Whether this CResult_ChannelConfigDecodeErrorZ represents a success state. + * Whether this CResult_PaymentSecretNoneZ represents a success state. */ bool result_ok; -} LDKCResult_ChannelConfigDecodeErrorZ; +} LDKCResult_PaymentSecretNoneZ; /** - * The contents of CResult_OutPointDecodeErrorZ + * The contents of CResult_PaymentSecretAPIErrorZ */ -typedef union LDKCResult_OutPointDecodeErrorZPtr { +typedef union LDKCResult_PaymentSecretAPIErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKOutPoint *result; + struct LDKThirtyTwoBytes *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKDecodeError *err; -} LDKCResult_OutPointDecodeErrorZPtr; + struct LDKAPIError *err; +} LDKCResult_PaymentSecretAPIErrorZPtr; /** - * A CResult_OutPointDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::chain::transaction::OutPoint on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_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`. */ -typedef struct LDKCResult_OutPointDecodeErrorZ { +typedef struct LDKCResult_PaymentSecretAPIErrorZ { /** - * The contents of this CResult_OutPointDecodeErrorZ, accessible via either + * The contents of this CResult_PaymentSecretAPIErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_OutPointDecodeErrorZPtr contents; + union LDKCResult_PaymentSecretAPIErrorZPtr contents; /** - * Whether this CResult_OutPointDecodeErrorZ represents a success state. + * Whether this CResult_PaymentSecretAPIErrorZ represents a success state. */ bool result_ok; -} LDKCResult_OutPointDecodeErrorZ; +} LDKCResult_PaymentSecretAPIErrorZ; /** - * Defines a type identifier for sending messages over the wire. - * - * Messages implementing this trait specify a type and must be [`Writeable`]. + * The contents of CResult_PaymentPreimageAPIErrorZ */ -typedef struct LDKType { - /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. - */ - void *this_arg; +typedef union LDKCResult_PaymentPreimageAPIErrorZPtr { /** - * Returns the type identifying the message payload. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - uint16_t (*type_id)(const void *this_arg); + struct LDKThirtyTwoBytes *result; /** - * Return a human-readable "debug" string describing this object + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKStr (*debug_str)(const void *this_arg); + struct LDKAPIError *err; +} LDKCResult_PaymentPreimageAPIErrorZPtr; + +/** + * A CResult_PaymentPreimageAPIErrorZ represents the result of a fallible operation, + * containing a crate::c_types::ThirtyTwoBytes on success and a crate::lightning::util::errors::APIError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_PaymentPreimageAPIErrorZ { /** - * Serialize the object into a byte array + * The contents of this CResult_PaymentPreimageAPIErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKCVec_u8Z (*write)(const void *this_arg); + union LDKCResult_PaymentPreimageAPIErrorZPtr contents; /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + * Whether this CResult_PaymentPreimageAPIErrorZ represents a success state. */ - void (*free)(void *this_arg); -} LDKType; + bool result_ok; +} LDKCResult_PaymentPreimageAPIErrorZ; + + /** - * An enum which can either contain a crate::lightning::ln::wire::Type or not - */ -typedef enum LDKCOption_TypeZ_Tag { - /** - * When we're in this state, this COption_TypeZ contains a crate::lightning::ln::wire::Type - */ - LDKCOption_TypeZ_Some, + * Information needed for constructing an invoice route hint for this channel. + */ +typedef struct MUST_USE_STRUCT LDKCounterpartyForwardingInfo { /** - * When we're in this state, this COption_TypeZ contains nothing + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKCOption_TypeZ_None, + LDKnativeCounterpartyForwardingInfo *inner; /** - * Must be last for serialization purposes + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - LDKCOption_TypeZ_Sentinel, -} LDKCOption_TypeZ_Tag; - -typedef struct LDKCOption_TypeZ { - LDKCOption_TypeZ_Tag tag; - union { - struct { - struct LDKType some; - }; - }; -} LDKCOption_TypeZ; + bool is_owned; +} LDKCounterpartyForwardingInfo; /** - * The contents of CResult_COption_TypeZDecodeErrorZ + * The contents of CResult_CounterpartyForwardingInfoDecodeErrorZ */ -typedef union LDKCResult_COption_TypeZDecodeErrorZPtr { +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 LDKCOption_TypeZ *result; + struct LDKCounterpartyForwardingInfo *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_COption_TypeZDecodeErrorZPtr; +} LDKCResult_CounterpartyForwardingInfoDecodeErrorZPtr; /** - * A CResult_COption_TypeZDecodeErrorZ represents the result of a fallible operation, - * containing a crate::c_types::derived::COption_TypeZ on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_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_COption_TypeZDecodeErrorZ { +typedef struct LDKCResult_CounterpartyForwardingInfoDecodeErrorZ { /** - * The contents of this CResult_COption_TypeZDecodeErrorZ, accessible via either + * The contents of this CResult_CounterpartyForwardingInfoDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_COption_TypeZDecodeErrorZPtr contents; + union LDKCResult_CounterpartyForwardingInfoDecodeErrorZPtr contents; /** - * Whether this CResult_COption_TypeZDecodeErrorZ represents a success state. + * Whether this CResult_CounterpartyForwardingInfoDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_COption_TypeZDecodeErrorZ; +} LDKCResult_CounterpartyForwardingInfoDecodeErrorZ; + + /** - * An error that may occur when making a payment. + * Channel parameters which apply to our counterparty. These are split out from [`ChannelDetails`] + * to better separate parameters. */ -typedef enum LDKPaymentError_Tag { +typedef struct MUST_USE_STRUCT LDKChannelCounterparty { /** - * An error resulting from the provided [`Invoice`] or payment hash. + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKPaymentError_Invoice, + LDKnativeChannelCounterparty *inner; /** - * An error occurring when finding a route. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - LDKPaymentError_Routing, + bool is_owned; +} LDKChannelCounterparty; + +/** + * The contents of CResult_ChannelCounterpartyDecodeErrorZ + */ +typedef union LDKCResult_ChannelCounterpartyDecodeErrorZPtr { /** - * An error occurring when sending a payment. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - LDKPaymentError_Sending, + struct LDKChannelCounterparty *result; /** - * Must be last for serialization purposes + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - LDKPaymentError_Sentinel, -} LDKPaymentError_Tag; + struct LDKDecodeError *err; +} LDKCResult_ChannelCounterpartyDecodeErrorZPtr; -typedef struct MUST_USE_STRUCT LDKPaymentError { - LDKPaymentError_Tag tag; - union { - struct { - struct LDKStr invoice; - }; - struct { - struct LDKLightningError routing; - }; - struct { - struct LDKPaymentSendFailure sending; - }; - }; -} LDKPaymentError; +/** + * 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_PaymentIdPaymentErrorZ + * The contents of CResult_ChannelDetailsDecodeErrorZ */ -typedef union LDKCResult_PaymentIdPaymentErrorZPtr { +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 LDKThirtyTwoBytes *result; + struct LDKChannelDetails *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKPaymentError *err; -} LDKCResult_PaymentIdPaymentErrorZPtr; + struct LDKDecodeError *err; +} LDKCResult_ChannelDetailsDecodeErrorZPtr; /** - * A CResult_PaymentIdPaymentErrorZ represents the result of a fallible operation, - * containing a crate::c_types::ThirtyTwoBytes on success and a crate::lightning_invoice::payment::PaymentError on failure. + * A CResult_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_PaymentIdPaymentErrorZ { +typedef struct LDKCResult_ChannelDetailsDecodeErrorZ { /** - * The contents of this CResult_PaymentIdPaymentErrorZ, accessible via either + * The contents of this CResult_ChannelDetailsDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_PaymentIdPaymentErrorZPtr contents; + union LDKCResult_ChannelDetailsDecodeErrorZPtr contents; /** - * Whether this CResult_PaymentIdPaymentErrorZ represents a success state. + * Whether this CResult_ChannelDetailsDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_PaymentIdPaymentErrorZ; +} LDKCResult_ChannelDetailsDecodeErrorZ; + + /** - * The contents of CResult_SiPrefixNoneZ + * Route hints used in constructing invoices for [phantom node payents]. + * + * [phantom node payments]: crate::chain::keysinterface::PhantomKeysManager */ -typedef union LDKCResult_SiPrefixNoneZPtr { +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. */ - enum LDKSiPrefix *result; + struct LDKPhantomRouteHints *result; /** - * Note that this value is always NULL, as there are no contents in the Err variant + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - void *err; -} LDKCResult_SiPrefixNoneZPtr; + struct LDKDecodeError *err; +} LDKCResult_PhantomRouteHintsDecodeErrorZPtr; /** - * A CResult_SiPrefixNoneZ represents the result of a fallible operation, - * containing a crate::lightning_invoice::SiPrefix on success and a () 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`. */ -typedef struct LDKCResult_SiPrefixNoneZ { +typedef struct LDKCResult_PhantomRouteHintsDecodeErrorZ { /** - * The contents of this CResult_SiPrefixNoneZ, accessible via either + * The contents of this CResult_PhantomRouteHintsDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_SiPrefixNoneZPtr contents; + union LDKCResult_PhantomRouteHintsDecodeErrorZPtr contents; /** - * Whether this CResult_SiPrefixNoneZ represents a success state. + * Whether this CResult_PhantomRouteHintsDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_SiPrefixNoneZ; +} LDKCResult_PhantomRouteHintsDecodeErrorZ; + +/** + * A dynamically-allocated array of crate::lightning::chain::channelmonitor::ChannelMonitors of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_ChannelMonitorZ { + /** + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + */ + struct LDKChannelMonitor *data; + /** + * The number of elements pointed to by `data`. + */ + uintptr_t datalen; +} LDKCVec_ChannelMonitorZ; /** - * Represents a syntactically and semantically correct lightning BOLT11 invoice. - * - * There are three ways to construct an `Invoice`: - * 1. using `InvoiceBuilder` - * 2. using `Invoice::from_signed(SignedRawInvoice)` - * 3. using `str::parse::(&str)` + * An update generated by the underlying Channel itself which contains some new information the + * ChannelMonitor should be made aware of. */ -typedef struct MUST_USE_STRUCT LDKInvoice { +typedef struct MUST_USE_STRUCT LDKChannelMonitorUpdate { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeInvoice *inner; + LDKnativeChannelMonitorUpdate *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ - bool is_owned; -} LDKInvoice; + bool is_owned; +} LDKChannelMonitorUpdate; + +/** + * The `Watch` trait defines behavior for watching on-chain activity pertaining to channels as + * blocks are connected and disconnected. + * + * Each channel is associated with a [`ChannelMonitor`]. Implementations of this trait are + * responsible for maintaining a set of monitors such that they can be updated accordingly as + * channel state changes and HTLCs are resolved. See method documentation for specific + * requirements. + * + * Implementations **must** ensure that updates are successfully applied and persisted upon method + * completion. If an update fails with a [`PermanentFailure`], then it must immediately shut down + * without taking any further action such as persisting the current state. + * + * If an implementation maintains multiple instances of a channel's monitor (e.g., by storing + * backup copies), then it must ensure that updates are applied across all instances. Otherwise, it + * could result in a revoked transaction being broadcast, allowing the counterparty to claim all + * funds in the channel. See [`ChannelMonitorUpdateErr`] for more details about how to handle + * multiple instances. + * + * [`PermanentFailure`]: ChannelMonitorUpdateErr::PermanentFailure + */ +typedef struct LDKWatch { + /** + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. + */ + void *this_arg; + /** + * Watches a channel identified by `funding_txo` using `monitor`. + * + * Implementations are responsible for watching the chain for the funding transaction along + * with any spends of outputs returned by [`get_outputs_to_watch`]. In practice, this means + * calling [`block_connected`] and [`block_disconnected`] on the monitor. + * + * Note: this interface MUST error with `ChannelMonitorUpdateErr::PermanentFailure` if + * the given `funding_txo` has previously been registered via `watch_channel`. + * + * [`get_outputs_to_watch`]: channelmonitor::ChannelMonitor::get_outputs_to_watch + * [`block_connected`]: channelmonitor::ChannelMonitor::block_connected + * [`block_disconnected`]: channelmonitor::ChannelMonitor::block_disconnected + */ + struct LDKCResult_NoneChannelMonitorUpdateErrZ (*watch_channel)(const void *this_arg, struct LDKOutPoint funding_txo, struct LDKChannelMonitor monitor); + /** + * Updates a channel identified by `funding_txo` by applying `update` to its monitor. + * + * Implementations must call [`update_monitor`] with the given update. See + * [`ChannelMonitorUpdateErr`] for invariants around returning an error. + * + * [`update_monitor`]: channelmonitor::ChannelMonitor::update_monitor + */ + struct LDKCResult_NoneChannelMonitorUpdateErrZ (*update_channel)(const void *this_arg, struct LDKOutPoint funding_txo, struct LDKChannelMonitorUpdate update); + /** + * Returns any monitor events since the last call. Subsequent calls must only return new + * events. + * + * Note that after any block- or transaction-connection calls to a [`ChannelMonitor`], no + * further events may be returned here until the [`ChannelMonitor`] has been fully persisted + * to disk. + * + * For details on asynchronous [`ChannelMonitor`] updating and returning + * [`MonitorEvent::UpdateCompleted`] here, see [`ChannelMonitorUpdateErr::TemporaryFailure`]. + */ + struct LDKCVec_MonitorEventZ (*release_pending_monitor_events)(const void *this_arg); + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKWatch; + +/** + * An interface to send a transaction to the Bitcoin network. + */ +typedef struct LDKBroadcasterInterface { + /** + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. + */ + void *this_arg; + /** + * Sends a transaction out to (hopefully) be mined. + */ + void (*broadcast_transaction)(const void *this_arg, struct LDKTransaction tx); + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKBroadcasterInterface; /** - * The contents of CResult_InvoiceNoneZ + * A "slice" referencing some byte array. This is simply a length-tagged pointer which does not + * own the memory pointed to by data. */ -typedef union LDKCResult_InvoiceNoneZPtr { +typedef struct LDKu8slice { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * A pointer to the byte buffer */ - struct LDKInvoice *result; + const uint8_t *data; /** - * Note that this value is always NULL, as there are no contents in the Err variant + * The number of bytes pointed to by `data`. */ - void *err; -} LDKCResult_InvoiceNoneZPtr; + uintptr_t datalen; +} LDKu8slice; /** - * A CResult_InvoiceNoneZ represents the result of a fallible operation, - * containing a crate::lightning_invoice::Invoice on success and a () on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * A trait to describe an object which can get user secrets and key material. */ -typedef struct LDKCResult_InvoiceNoneZ { +typedef struct LDKKeysInterface { /** - * The contents of this CResult_InvoiceNoneZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. */ - union LDKCResult_InvoiceNoneZPtr contents; + void *this_arg; /** - * Whether this CResult_InvoiceNoneZ represents a success state. + * 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 with a given `Recipient` + * parameter. */ - bool result_ok; -} LDKCResult_InvoiceNoneZ; - - - -/** - * Represents a signed `RawInvoice` with cached hash. The signature is not checked and may be - * invalid. - * - * # Invariants - * The hash has to be either from the deserialized invoice or from the serialized `raw_invoice`. - */ -typedef struct MUST_USE_STRUCT LDKSignedRawInvoice { + struct LDKCResult_SecretKeyNoneZ (*get_node_secret)(const void *this_arg, enum LDKRecipient recipient); /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * Get a script pubkey which we send funds to when claiming on-chain contestable outputs. + * + * This method should return a different value each time it is called, to avoid linking + * on-chain funds across channels as controlled to the same user. */ - LDKnativeSignedRawInvoice *inner; + struct LDKCVec_u8Z (*get_destination_script)(const void *this_arg); /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * Get a script pubkey which we will send funds to when closing a channel. + * + * This method should return a different value each time it is called, to avoid linking + * on-chain funds across channels as controlled to the same user. */ - bool is_owned; -} LDKSignedRawInvoice; - -/** - * The contents of CResult_SignedRawInvoiceNoneZ - */ -typedef union LDKCResult_SignedRawInvoiceNoneZPtr { + struct LDKShutdownScript (*get_shutdown_scriptpubkey)(const void *this_arg); /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * Get a new set of Sign for per-channel secrets. These MUST be unique even if you + * restarted with some stale data! + * + * This method must return a different value each time it is called. */ - struct LDKSignedRawInvoice *result; + struct LDKSign (*get_channel_signer)(const void *this_arg, bool inbound, uint64_t channel_value_satoshis); /** - * Note that this value is always NULL, as there are no contents in the Err variant + * Gets a unique, cryptographically-secure, random 32 byte value. This is used for encrypting + * onion packets and for temporary channel IDs. There is no requirement that these be + * persisted anywhere, though they must be unique across restarts. + * + * This method must return a different value each time it is called. */ - void *err; -} LDKCResult_SignedRawInvoiceNoneZPtr; - -/** - * A CResult_SignedRawInvoiceNoneZ represents the result of a fallible operation, - * containing a crate::lightning_invoice::SignedRawInvoice on success and a () on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_SignedRawInvoiceNoneZ { + struct LDKThirtyTwoBytes (*get_secure_random_bytes)(const void *this_arg); /** - * The contents of this CResult_SignedRawInvoiceNoneZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * Reads a `Signer` for this `KeysInterface` from the given input stream. + * This is only called during deserialization of other objects which contain + * `Sign`-implementing objects (ie `ChannelMonitor`s and `ChannelManager`s). + * The bytes are exactly those which `::write()` writes, and + * contain no versioning scheme. You may wish to include your own version prefix and ensure + * you've read all of the provided bytes to ensure no corruption occurred. */ - union LDKCResult_SignedRawInvoiceNoneZPtr contents; + struct LDKCResult_SignDecodeErrorZ (*read_chan_signer)(const void *this_arg, struct LDKu8slice reader); /** - * Whether this CResult_SignedRawInvoiceNoneZ represents a success state. + * 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`]. */ - bool result_ok; -} LDKCResult_SignedRawInvoiceNoneZ; - - + 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); + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKKeysInterface; /** - * Represents an syntactically correct Invoice for a payment on the lightning network, - * but without the signature information. - * De- and encoding should not lead to information loss but may lead to different hashes. + * A trait which should be implemented to provide feerate information on a number of time + * horizons. * - * For methods without docs see the corresponding methods in `Invoice`. + * Note that all of the functions implemented here *must* be reentrant-safe (obviously - they're + * called from inside the library in response to chain events, P2P events, or timer events). */ -typedef struct MUST_USE_STRUCT LDKRawInvoice { +typedef struct LDKFeeEstimator { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. */ - LDKnativeRawInvoice *inner; + void *this_arg; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * Gets estimated satoshis of fee required per 1000 Weight-Units. + * + * Must return a value no smaller than 253 (ie 1 satoshi-per-byte rounded up to ensure later + * round-downs don't put us below 1 satoshi-per-byte). + * + * This method can be implemented with the following unit conversions: + * * max(satoshis-per-byte * 250, 253) + * * max(satoshis-per-kbyte / 4, 253) */ - bool is_owned; -} LDKRawInvoice; + uint32_t (*get_est_sat_per_1000_weight)(const void *this_arg, enum LDKConfirmationTarget confirmation_target); + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKFeeEstimator; /** - * Recoverable signature + * A Record, unit of logging output with Metadata to enable filtering + * Module_path, file, line to inform on log's source */ -typedef struct MUST_USE_STRUCT LDKInvoiceSignature { +typedef struct MUST_USE_STRUCT LDKRecord { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeInvoiceSignature *inner; + LDKnativeRecord *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKInvoiceSignature; +} LDKRecord; /** - * A tuple of 3 elements. See the individual fields for the types contained. + * A trait encapsulating the operations required of a logger */ -typedef struct LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ { +typedef struct LDKLogger { /** - * The element at position 0 + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. */ - struct LDKRawInvoice a; + void *this_arg; /** - * The element at position 1 + * Logs the `Record` */ - struct LDKThirtyTwoBytes b; + void (*log)(const void *this_arg, const struct LDKRecord *NONNULL_PTR record); /** - * The element at position 2 + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. */ - struct LDKInvoiceSignature c; -} LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ; + void (*free)(void *this_arg); +} LDKLogger; /** - * Payee public key + * Manager which keeps track of a number of channels and sends messages to the appropriate + * channel, also tracking HTLC preimages and forwarding onion packets appropriately. + * + * Implements ChannelMessageHandler, handling the multi-channel parts and passing things through + * to individual Channels. + * + * Implements Writeable to write out all channel state to disk. Implies peer_disconnected() for + * all peers during write/read (though does not modify this instance, only the instance being + * serialized). This will result in any channels which have not yet exchanged funding_created (ie + * called funding_transaction_generated for outbound channels). + * + * Note that you can be a bit lazier about writing out ChannelManager than you can be with + * ChannelMonitors. With ChannelMonitors you MUST write each monitor update out to disk before + * returning from chain::Watch::watch_/update_channel, with ChannelManagers, writing updates + * happens out-of-band (and will prevent any other ChannelManager operations from occurring during + * the serialization process). If the deserialized version is out-of-date compared to the + * ChannelMonitors passed by reference to read(), those channels will be force-closed based on the + * ChannelMonitor state and no funds will be lost (mod on-chain transaction fees). + * + * Note that the deserializer is only implemented for (BlockHash, ChannelManager), which + * tells you the last block hash which was block_connect()ed. You MUST rescan any blocks along + * the \"reorg path\" (ie call block_disconnected() until you get to a common block and then call + * block_connected() to step towards your best block) upon deserialization before using the + * object! + * + * Note that ChannelManager is responsible for tracking liveness of its channels and generating + * ChannelUpdate messages informing peers that the channel is temporarily disabled. To avoid + * spam due to quick disconnection/reconnection, updates are not sent until the channel has been + * offline for a full minute. In order to track this, you must call + * timer_tick_occurred roughly once per minute, though it doesn't have to be perfect. + * + * Rather than using a plain ChannelManager, it is preferable to use either a SimpleArcChannelManager + * a SimpleRefChannelManager, for conciseness. See their documentation for more details, but + * essentially you should default to using a SimpleRefChannelManager, and use a + * SimpleArcChannelManager when you require a ChannelManager with a static lifetime, such as when + * you're using lightning-net-tokio. */ -typedef struct MUST_USE_STRUCT LDKPayeePubKey { +typedef struct MUST_USE_STRUCT LDKChannelManager { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativePayeePubKey *inner; + LDKnativeChannelManager *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKPayeePubKey; - -/** - * The contents of CResult_PayeePubKeyErrorZ - */ -typedef union LDKCResult_PayeePubKeyErrorZPtr { - /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. - */ - struct LDKPayeePubKey *result; - /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. - */ - enum LDKSecp256k1Error *err; -} LDKCResult_PayeePubKeyErrorZPtr; +} LDKChannelManager; /** - * A CResult_PayeePubKeyErrorZ represents the result of a fallible operation, - * containing a crate::lightning_invoice::PayeePubKey on success and a crate::c_types::Secp256k1Error on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * A tuple of 2 elements. See the individual fields for the types contained. */ -typedef struct LDKCResult_PayeePubKeyErrorZ { +typedef struct LDKC2Tuple_BlockHashChannelManagerZ { /** - * The contents of this CResult_PayeePubKeyErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * The element at position 0 */ - union LDKCResult_PayeePubKeyErrorZPtr contents; + struct LDKThirtyTwoBytes a; /** - * Whether this CResult_PayeePubKeyErrorZ represents a success state. + * The element at position 1 */ - bool result_ok; -} LDKCResult_PayeePubKeyErrorZ; - - + struct LDKChannelManager b; +} LDKC2Tuple_BlockHashChannelManagerZ; /** - * Private routing information - * - * # Invariants - * The encoded route has to be <1024 5bit characters long (<=639 bytes or <=12 hops) - * + * The contents of CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ */ -typedef struct MUST_USE_STRUCT LDKPrivateRoute { +typedef union LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - LDKnativePrivateRoute *inner; + struct LDKC2Tuple_BlockHashChannelManagerZ *result; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - bool is_owned; -} LDKPrivateRoute; + struct LDKDecodeError *err; +} LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr; /** - * A dynamically-allocated array of crate::lightning_invoice::PrivateRoutes of arbitrary size. - * This corresponds to std::vector in C++ + * A CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ represents the result of a fallible operation, + * containing a crate::c_types::derived::C2Tuple_BlockHashChannelManagerZ on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCVec_PrivateRouteZ { +typedef struct LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * The contents of this CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKPrivateRoute *data; + union LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr contents; /** - * The number of elements pointed to by `data`. + * Whether this CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ represents a success state. */ - uintptr_t datalen; -} LDKCVec_PrivateRouteZ; + bool result_ok; +} LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ; /** - * A timestamp that refers to a date after 1 January 1970 which means its representation as UNIX - * timestamp is positive. - * - * # 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. + * Options which apply on a per-channel basis and may change at runtime or based on negotiation + * with our counterparty. */ -typedef struct MUST_USE_STRUCT LDKPositiveTimestamp { +typedef struct MUST_USE_STRUCT LDKChannelConfig { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativePositiveTimestamp *inner; + LDKnativeChannelConfig *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKPositiveTimestamp; +} LDKChannelConfig; /** - * The contents of CResult_PositiveTimestampCreationErrorZ + * The contents of CResult_ChannelConfigDecodeErrorZ */ -typedef union LDKCResult_PositiveTimestampCreationErrorZPtr { +typedef union LDKCResult_ChannelConfigDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKPositiveTimestamp *result; + struct LDKChannelConfig *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - enum LDKCreationError *err; -} LDKCResult_PositiveTimestampCreationErrorZPtr; + struct LDKDecodeError *err; +} LDKCResult_ChannelConfigDecodeErrorZPtr; /** - * A CResult_PositiveTimestampCreationErrorZ represents the result of a fallible operation, - * containing a crate::lightning_invoice::PositiveTimestamp on success and a crate::lightning_invoice::CreationError on failure. + * A CResult_ChannelConfigDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::util::config::ChannelConfig on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_PositiveTimestampCreationErrorZ { +typedef struct LDKCResult_ChannelConfigDecodeErrorZ { /** - * The contents of this CResult_PositiveTimestampCreationErrorZ, accessible via either + * The contents of this CResult_ChannelConfigDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_PositiveTimestampCreationErrorZPtr contents; + union LDKCResult_ChannelConfigDecodeErrorZPtr contents; /** - * Whether this CResult_PositiveTimestampCreationErrorZ represents a success state. + * Whether this CResult_ChannelConfigDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_PositiveTimestampCreationErrorZ; +} LDKCResult_ChannelConfigDecodeErrorZ; /** - * The contents of CResult_NoneSemanticErrorZ + * The contents of CResult_OutPointDecodeErrorZ */ -typedef union LDKCResult_NoneSemanticErrorZPtr { +typedef union LDKCResult_OutPointDecodeErrorZPtr { /** - * Note that this value is always NULL, as there are no contents in the OK variant + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - void *result; + struct LDKOutPoint *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - enum LDKSemanticError *err; -} LDKCResult_NoneSemanticErrorZPtr; + struct LDKDecodeError *err; +} LDKCResult_OutPointDecodeErrorZPtr; /** - * A CResult_NoneSemanticErrorZ represents the result of a fallible operation, - * containing a () on success and a crate::lightning_invoice::SemanticError on failure. + * A CResult_OutPointDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::chain::transaction::OutPoint on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_NoneSemanticErrorZ { +typedef struct LDKCResult_OutPointDecodeErrorZ { /** - * The contents of this CResult_NoneSemanticErrorZ, accessible via either + * The contents of this CResult_OutPointDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_NoneSemanticErrorZPtr contents; + union LDKCResult_OutPointDecodeErrorZPtr contents; /** - * Whether this CResult_NoneSemanticErrorZ represents a success state. + * Whether this CResult_OutPointDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_NoneSemanticErrorZ; +} LDKCResult_OutPointDecodeErrorZ; /** - * The contents of CResult_InvoiceSemanticErrorZ + * Defines a type identifier for sending messages over the wire. + * + * Messages implementing this trait specify a type and must be [`Writeable`]. */ -typedef union LDKCResult_InvoiceSemanticErrorZPtr { +typedef struct LDKType { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. */ - struct LDKInvoice *result; + void *this_arg; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * Returns the type identifying the message payload. */ - enum LDKSemanticError *err; -} LDKCResult_InvoiceSemanticErrorZPtr; - -/** - * A CResult_InvoiceSemanticErrorZ represents the result of a fallible operation, - * containing a crate::lightning_invoice::Invoice on success and a crate::lightning_invoice::SemanticError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_InvoiceSemanticErrorZ { + uint16_t (*type_id)(const void *this_arg); /** - * The contents of this CResult_InvoiceSemanticErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * Return a human-readable "debug" string describing this object */ - union LDKCResult_InvoiceSemanticErrorZPtr contents; + struct LDKStr (*debug_str)(const void *this_arg); /** - * Whether this CResult_InvoiceSemanticErrorZ represents a success state. + * Serialize the object into a byte array */ - bool result_ok; -} LDKCResult_InvoiceSemanticErrorZ; - - + struct LDKCVec_u8Z (*write)(const void *this_arg); + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKType; /** - * Description string - * - * # Invariants - * The description can be at most 639 __bytes__ long + * An enum which can either contain a crate::lightning::ln::wire::Type or not */ -typedef struct MUST_USE_STRUCT LDKDescription { +typedef enum LDKCOption_TypeZ_Tag { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * When we're in this state, this COption_TypeZ contains a crate::lightning::ln::wire::Type */ - LDKnativeDescription *inner; + LDKCOption_TypeZ_Some, /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * When we're in this state, this COption_TypeZ contains nothing */ - bool is_owned; -} LDKDescription; + LDKCOption_TypeZ_None, + /** + * Must be last for serialization purposes + */ + LDKCOption_TypeZ_Sentinel, +} LDKCOption_TypeZ_Tag; + +typedef struct LDKCOption_TypeZ { + LDKCOption_TypeZ_Tag tag; + union { + struct { + struct LDKType some; + }; + }; +} LDKCOption_TypeZ; /** - * The contents of CResult_DescriptionCreationErrorZ + * The contents of CResult_COption_TypeZDecodeErrorZ */ -typedef union LDKCResult_DescriptionCreationErrorZPtr { +typedef union LDKCResult_COption_TypeZDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKDescription *result; + struct LDKCOption_TypeZ *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - enum LDKCreationError *err; -} LDKCResult_DescriptionCreationErrorZPtr; + struct LDKDecodeError *err; +} LDKCResult_COption_TypeZDecodeErrorZPtr; /** - * A CResult_DescriptionCreationErrorZ represents the result of a fallible operation, - * containing a crate::lightning_invoice::Description on success and a crate::lightning_invoice::CreationError on failure. + * A CResult_COption_TypeZDecodeErrorZ represents the result of a fallible operation, + * containing a crate::c_types::derived::COption_TypeZ on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_DescriptionCreationErrorZ { +typedef struct LDKCResult_COption_TypeZDecodeErrorZ { /** - * The contents of this CResult_DescriptionCreationErrorZ, accessible via either + * The contents of this CResult_COption_TypeZDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_DescriptionCreationErrorZPtr contents; + union LDKCResult_COption_TypeZDecodeErrorZPtr contents; /** - * Whether this CResult_DescriptionCreationErrorZ represents a success state. + * Whether this CResult_COption_TypeZDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_DescriptionCreationErrorZ; - - +} LDKCResult_COption_TypeZDecodeErrorZ; /** - * 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 + * An error that may occur when making a payment. */ -typedef struct MUST_USE_STRUCT LDKExpiryTime { +typedef enum LDKPaymentError_Tag { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * An error resulting from the provided [`Invoice`] or payment hash. */ - LDKnativeExpiryTime *inner; + LDKPaymentError_Invoice, /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * An error occurring when finding a route. */ - bool is_owned; -} LDKExpiryTime; + LDKPaymentError_Routing, + /** + * An error occurring when sending a payment. + */ + LDKPaymentError_Sending, + /** + * Must be last for serialization purposes + */ + LDKPaymentError_Sentinel, +} LDKPaymentError_Tag; + +typedef struct MUST_USE_STRUCT LDKPaymentError { + LDKPaymentError_Tag tag; + union { + struct { + struct LDKStr invoice; + }; + struct { + struct LDKLightningError routing; + }; + struct { + struct LDKPaymentSendFailure sending; + }; + }; +} LDKPaymentError; /** - * The contents of CResult_ExpiryTimeCreationErrorZ + * The contents of CResult_PaymentIdPaymentErrorZ */ -typedef union LDKCResult_ExpiryTimeCreationErrorZPtr { +typedef union LDKCResult_PaymentIdPaymentErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKExpiryTime *result; + struct LDKThirtyTwoBytes *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - enum LDKCreationError *err; -} LDKCResult_ExpiryTimeCreationErrorZPtr; + struct LDKPaymentError *err; +} LDKCResult_PaymentIdPaymentErrorZPtr; /** - * 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. + * A CResult_PaymentIdPaymentErrorZ represents the result of a fallible operation, + * containing a crate::c_types::ThirtyTwoBytes on success and a crate::lightning_invoice::payment::PaymentError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_ExpiryTimeCreationErrorZ { +typedef struct LDKCResult_PaymentIdPaymentErrorZ { /** - * The contents of this CResult_ExpiryTimeCreationErrorZ, accessible via either + * The contents of this CResult_PaymentIdPaymentErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_ExpiryTimeCreationErrorZPtr contents; + union LDKCResult_PaymentIdPaymentErrorZPtr contents; /** - * Whether this CResult_ExpiryTimeCreationErrorZ represents a success state. + * Whether this CResult_PaymentIdPaymentErrorZ represents a success state. */ bool result_ok; -} LDKCResult_ExpiryTimeCreationErrorZ; +} LDKCResult_PaymentIdPaymentErrorZ; /** - * The contents of CResult_PrivateRouteCreationErrorZ + * The contents of CResult_SiPrefixNoneZ */ -typedef union LDKCResult_PrivateRouteCreationErrorZPtr { +typedef union LDKCResult_SiPrefixNoneZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKPrivateRoute *result; + enum LDKSiPrefix *result; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * Note that this value is always NULL, as there are no contents in the Err variant */ - enum LDKCreationError *err; -} LDKCResult_PrivateRouteCreationErrorZPtr; + void *err; +} LDKCResult_SiPrefixNoneZPtr; /** - * A CResult_PrivateRouteCreationErrorZ represents the result of a fallible operation, - * containing a crate::lightning_invoice::PrivateRoute on success and a crate::lightning_invoice::CreationError on failure. + * A CResult_SiPrefixNoneZ represents the result of a fallible operation, + * containing a crate::lightning_invoice::SiPrefix on success and a () on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_PrivateRouteCreationErrorZ { +typedef struct LDKCResult_SiPrefixNoneZ { /** - * The contents of this CResult_PrivateRouteCreationErrorZ, accessible via either + * The contents of this CResult_SiPrefixNoneZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_PrivateRouteCreationErrorZPtr contents; + union LDKCResult_SiPrefixNoneZPtr contents; /** - * Whether this CResult_PrivateRouteCreationErrorZ represents a success state. + * Whether this CResult_SiPrefixNoneZ represents a success state. */ bool result_ok; -} LDKCResult_PrivateRouteCreationErrorZ; +} LDKCResult_SiPrefixNoneZ; + + /** - * The contents of CResult_StringErrorZ + * Represents a syntactically and semantically correct lightning BOLT11 invoice. + * + * There are three ways to construct an `Invoice`: + * 1. using `InvoiceBuilder` + * 2. using `Invoice::from_signed(SignedRawInvoice)` + * 3. using `str::parse::(&str)` */ -typedef union LDKCResult_StringErrorZPtr { +typedef struct MUST_USE_STRUCT LDKInvoice { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - struct LDKStr *result; + LDKnativeInvoice *inner; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - enum LDKSecp256k1Error *err; -} LDKCResult_StringErrorZPtr; + bool is_owned; +} LDKInvoice; /** - * A CResult_StringErrorZ represents the result of a fallible operation, - * containing a crate::c_types::Str on success and a crate::c_types::Secp256k1Error on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * The contents of CResult_InvoiceNoneZ */ -typedef struct LDKCResult_StringErrorZ { +typedef union LDKCResult_InvoiceNoneZPtr { /** - * The contents of this CResult_StringErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - union LDKCResult_StringErrorZPtr contents; + struct LDKInvoice *result; /** - * Whether this CResult_StringErrorZ represents a success state. + * Note that this value is always NULL, as there are no contents in the Err variant */ - bool result_ok; -} LDKCResult_StringErrorZ; + void *err; +} LDKCResult_InvoiceNoneZPtr; /** - * The contents of CResult_ChannelMonitorUpdateDecodeErrorZ + * A CResult_InvoiceNoneZ represents the result of a fallible operation, + * containing a crate::lightning_invoice::Invoice on success and a () on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef union LDKCResult_ChannelMonitorUpdateDecodeErrorZPtr { +typedef struct LDKCResult_InvoiceNoneZ { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * The contents of this CResult_InvoiceNoneZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKChannelMonitorUpdate *result; + union LDKCResult_InvoiceNoneZPtr contents; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * Whether this CResult_InvoiceNoneZ represents a success state. */ - struct LDKDecodeError *err; -} LDKCResult_ChannelMonitorUpdateDecodeErrorZPtr; + bool result_ok; +} LDKCResult_InvoiceNoneZ; + + /** - * A CResult_ChannelMonitorUpdateDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::chain::channelmonitor::ChannelMonitorUpdate on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * Represents a signed `RawInvoice` with cached hash. The signature is not checked and may be + * invalid. + * + * # Invariants + * The hash has to be either from the deserialized invoice or from the serialized `raw_invoice`. */ -typedef struct LDKCResult_ChannelMonitorUpdateDecodeErrorZ { +typedef struct MUST_USE_STRUCT LDKSignedRawInvoice { /** - * The contents of this CResult_ChannelMonitorUpdateDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - union LDKCResult_ChannelMonitorUpdateDecodeErrorZPtr contents; + LDKnativeSignedRawInvoice *inner; /** - * Whether this CResult_ChannelMonitorUpdateDecodeErrorZ represents a success state. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - bool result_ok; -} LDKCResult_ChannelMonitorUpdateDecodeErrorZ; + bool is_owned; +} LDKSignedRawInvoice; /** - * The contents of CResult_HTLCUpdateDecodeErrorZ + * The contents of CResult_SignedRawInvoiceNoneZ */ -typedef union LDKCResult_HTLCUpdateDecodeErrorZPtr { +typedef union LDKCResult_SignedRawInvoiceNoneZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKHTLCUpdate *result; + struct LDKSignedRawInvoice *result; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * Note that this value is always NULL, as there are no contents in the Err variant */ - struct LDKDecodeError *err; -} LDKCResult_HTLCUpdateDecodeErrorZPtr; + void *err; +} LDKCResult_SignedRawInvoiceNoneZPtr; /** - * A CResult_HTLCUpdateDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::chain::channelmonitor::HTLCUpdate on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_SignedRawInvoiceNoneZ represents the result of a fallible operation, + * containing a crate::lightning_invoice::SignedRawInvoice on success and a () on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_HTLCUpdateDecodeErrorZ { +typedef struct LDKCResult_SignedRawInvoiceNoneZ { /** - * The contents of this CResult_HTLCUpdateDecodeErrorZ, accessible via either + * The contents of this CResult_SignedRawInvoiceNoneZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_HTLCUpdateDecodeErrorZPtr contents; + union LDKCResult_SignedRawInvoiceNoneZPtr contents; /** - * Whether this CResult_HTLCUpdateDecodeErrorZ represents a success state. + * Whether this CResult_SignedRawInvoiceNoneZ represents a success state. */ bool result_ok; -} LDKCResult_HTLCUpdateDecodeErrorZ; +} LDKCResult_SignedRawInvoiceNoneZ; /** - * General Err type for ChannelMonitor actions. Generally, this implies that the data provided is - * inconsistent with the ChannelMonitor being called. eg for ChannelMonitor::update_monitor this - * means you tried to update a monitor for a different channel or the ChannelMonitorUpdate was - * corrupted. - * Contains a developer-readable error message. + * Represents an syntactically correct Invoice for a payment on the lightning network, + * but without the signature information. + * De- and encoding should not lead to information loss but may lead to different hashes. + * + * For methods without docs see the corresponding methods in `Invoice`. */ -typedef struct MUST_USE_STRUCT LDKMonitorUpdateError { +typedef struct MUST_USE_STRUCT LDKRawInvoice { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeMonitorUpdateError *inner; + LDKnativeRawInvoice *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKMonitorUpdateError; +} LDKRawInvoice; + + /** - * The contents of CResult_NoneMonitorUpdateErrorZ + * Recoverable signature */ -typedef union LDKCResult_NoneMonitorUpdateErrorZPtr { +typedef struct MUST_USE_STRUCT LDKInvoiceSignature { /** - * Note that this value is always NULL, as there are no contents in the OK variant + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - void *result; + LDKnativeInvoiceSignature *inner; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - struct LDKMonitorUpdateError *err; -} LDKCResult_NoneMonitorUpdateErrorZPtr; + bool is_owned; +} LDKInvoiceSignature; /** - * A CResult_NoneMonitorUpdateErrorZ represents the result of a fallible operation, - * containing a () on success and a crate::lightning::chain::channelmonitor::MonitorUpdateError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * A tuple of 3 elements. See the individual fields for the types contained. */ -typedef struct LDKCResult_NoneMonitorUpdateErrorZ { +typedef struct LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ { /** - * The contents of this CResult_NoneMonitorUpdateErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * The element at position 0 */ - union LDKCResult_NoneMonitorUpdateErrorZPtr contents; + struct LDKRawInvoice a; /** - * Whether this CResult_NoneMonitorUpdateErrorZ represents a success state. + * The element at position 1 */ - bool result_ok; -} LDKCResult_NoneMonitorUpdateErrorZ; + struct LDKThirtyTwoBytes b; + /** + * The element at position 2 + */ + struct LDKInvoiceSignature c; +} LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ; + + /** - * A tuple of 2 elements. See the individual fields for the types contained. + * Payee public key */ -typedef struct LDKC2Tuple_OutPointScriptZ { +typedef struct MUST_USE_STRUCT LDKPayeePubKey { /** - * The element at position 0 + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - struct LDKOutPoint a; + LDKnativePayeePubKey *inner; /** - * The element at position 1 + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - struct LDKCVec_u8Z b; -} LDKC2Tuple_OutPointScriptZ; + bool is_owned; +} LDKPayeePubKey; /** - * A tuple of 2 elements. See the individual fields for the types contained. + * The contents of CResult_PayeePubKeyErrorZ */ -typedef struct LDKC2Tuple_u32ScriptZ { +typedef union LDKCResult_PayeePubKeyErrorZPtr { /** - * The element at position 0 + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - uint32_t a; + struct LDKPayeePubKey *result; /** - * The element at position 1 + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKCVec_u8Z b; -} LDKC2Tuple_u32ScriptZ; + enum LDKSecp256k1Error *err; +} LDKCResult_PayeePubKeyErrorZPtr; /** - * A dynamically-allocated array of crate::c_types::derived::C2Tuple_u32ScriptZs of arbitrary size. - * This corresponds to std::vector in C++ + * A CResult_PayeePubKeyErrorZ represents the result of a fallible operation, + * containing a crate::lightning_invoice::PayeePubKey on success and a crate::c_types::Secp256k1Error on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCVec_C2Tuple_u32ScriptZZ { +typedef struct LDKCResult_PayeePubKeyErrorZ { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * The contents of this CResult_PayeePubKeyErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKC2Tuple_u32ScriptZ *data; + union LDKCResult_PayeePubKeyErrorZPtr contents; /** - * The number of elements pointed to by `data`. + * Whether this CResult_PayeePubKeyErrorZ represents a success state. */ - uintptr_t datalen; -} LDKCVec_C2Tuple_u32ScriptZZ; + bool result_ok; +} LDKCResult_PayeePubKeyErrorZ; + + /** - * A tuple of 2 elements. See the individual fields for the types contained. + * Private routing information + * + * # Invariants + * The encoded route has to be <1024 5bit characters long (<=639 bytes or <=12 hops) + * */ -typedef struct LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ { +typedef struct MUST_USE_STRUCT LDKPrivateRoute { /** - * The element at position 0 + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - struct LDKThirtyTwoBytes a; + LDKnativePrivateRoute *inner; /** - * The element at position 1 + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - struct LDKCVec_C2Tuple_u32ScriptZZ b; -} LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ; + bool is_owned; +} LDKPrivateRoute; /** - * A dynamically-allocated array of crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZs of arbitrary size. + * A dynamically-allocated array of crate::lightning_invoice::PrivateRoutes of arbitrary size. * This corresponds to std::vector in C++ */ -typedef struct LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ { +typedef struct LDKCVec_PrivateRouteZ { /** * The elements in the array. * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - struct LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *data; + struct LDKPrivateRoute *data; /** * The number of elements pointed to by `data`. */ uintptr_t datalen; -} LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ; +} LDKCVec_PrivateRouteZ; + + /** - * Some information provided on receipt of payment depends on whether the payment received is a - * spontaneous payment or a \"conventional\" lightning payment that's paying an invoice. + * A timestamp that refers to a date after 1 January 1970. + * + * # Invariants + * + * The Unix timestamp representing the stored time has to be positive and no greater than + * [`MAX_TIMESTAMP`]. */ -typedef enum LDKPaymentPurpose_Tag { - /** - * Information for receiving a payment that we generated an invoice for. - */ - LDKPaymentPurpose_InvoicePayment, +typedef struct MUST_USE_STRUCT LDKPositiveTimestamp { /** - * Because this is a spontaneous payment, the payer generated their own preimage rather than us - * (the payee) providing a preimage. + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKPaymentPurpose_SpontaneousPayment, + LDKnativePositiveTimestamp *inner; /** - * Must be last for serialization purposes + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - LDKPaymentPurpose_Sentinel, -} LDKPaymentPurpose_Tag; + bool is_owned; +} LDKPositiveTimestamp; -typedef struct LDKPaymentPurpose_LDKInvoicePayment_Body { - /** - * The preimage to the payment_hash, if the payment hash (and secret) were fetched via - * [`ChannelManager::create_inbound_payment`]. If provided, this can be handed directly to - * [`ChannelManager::claim_funds`]. - * - * [`ChannelManager::create_inbound_payment`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment - * [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds - * - * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None - */ - struct LDKThirtyTwoBytes payment_preimage; +/** + * The contents of CResult_PositiveTimestampCreationErrorZ + */ +typedef union LDKCResult_PositiveTimestampCreationErrorZPtr { /** - * The \"payment secret\". This authenticates the sender to the recipient, preventing a - * number of deanonymization attacks during the routing process. - * It is provided here for your reference, however its accuracy is enforced directly by - * [`ChannelManager`] using the values you previously provided to - * [`ChannelManager::create_inbound_payment`] or - * [`ChannelManager::create_inbound_payment_for_hash`]. - * - * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager - * [`ChannelManager::create_inbound_payment`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment - * [`ChannelManager::create_inbound_payment_for_hash`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKThirtyTwoBytes payment_secret; + struct LDKPositiveTimestamp *result; /** - * This is the `user_payment_id` which was provided to - * [`ChannelManager::create_inbound_payment_for_hash`] or - * [`ChannelManager::create_inbound_payment`]. It has no meaning inside of LDK and is - * simply copied here. It may be used to correlate PaymentReceived events with invoice - * metadata stored elsewhere. - * - * [`ChannelManager::create_inbound_payment`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment - * [`ChannelManager::create_inbound_payment_for_hash`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - uint64_t user_payment_id; -} LDKPaymentPurpose_LDKInvoicePayment_Body; - -typedef struct MUST_USE_STRUCT LDKPaymentPurpose { - LDKPaymentPurpose_Tag tag; - union { - LDKPaymentPurpose_LDKInvoicePayment_Body invoice_payment; - struct { - struct LDKThirtyTwoBytes spontaneous_payment; - }; - }; -} LDKPaymentPurpose; + enum LDKCreationError *err; +} LDKCResult_PositiveTimestampCreationErrorZPtr; /** - * The reason the channel was closed. See individual variants more details. + * A CResult_PositiveTimestampCreationErrorZ represents the result of a fallible operation, + * containing a crate::lightning_invoice::PositiveTimestamp on success and a crate::lightning_invoice::CreationError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef enum LDKClosureReason_Tag { +typedef struct LDKCResult_PositiveTimestampCreationErrorZ { /** - * Closure generated from receiving a peer error message. - * - * Our counterparty may have broadcasted their latest commitment state, and we have - * as well. + * The contents of this CResult_PositiveTimestampCreationErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKClosureReason_CounterpartyForceClosed, + union LDKCResult_PositiveTimestampCreationErrorZPtr contents; /** - * Closure generated from [`ChannelManager::force_close_channel`], called by the user. - * - * [`ChannelManager::force_close_channel`]: crate::ln::channelmanager::ChannelManager::force_close_channel. + * Whether this CResult_PositiveTimestampCreationErrorZ represents a success state. */ - LDKClosureReason_HolderForceClosed, + bool result_ok; +} LDKCResult_PositiveTimestampCreationErrorZ; + +/** + * The contents of CResult_NoneSemanticErrorZ + */ +typedef union LDKCResult_NoneSemanticErrorZPtr { /** - * The channel was closed after negotiating a cooperative close and we've now broadcasted - * the cooperative close transaction. Note the shutdown may have been initiated by us. + * Note that this value is always NULL, as there are no contents in the OK variant */ - LDKClosureReason_CooperativeClosure, + void *result; /** - * A commitment transaction was confirmed on chain, closing the channel. Most likely this - * commitment transaction came from our counterparty, but it may also have come from - * a copy of our own `ChannelMonitor`. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - LDKClosureReason_CommitmentTxConfirmed, + enum LDKSemanticError *err; +} LDKCResult_NoneSemanticErrorZPtr; + +/** + * A CResult_NoneSemanticErrorZ represents the result of a fallible operation, + * containing a () on success and a crate::lightning_invoice::SemanticError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_NoneSemanticErrorZ { /** - * Closure generated from processing an event, likely a HTLC forward/relay/reception. + * The contents of this CResult_NoneSemanticErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKClosureReason_ProcessingError, + union LDKCResult_NoneSemanticErrorZPtr contents; /** - * The `PeerManager` informed us that we've disconnected from the peer. We close channels - * if the `PeerManager` informed us that it is unlikely we'll be able to connect to the - * peer again in the future or if the peer disconnected before we finished negotiating - * the channel open. The first case may be caused by incompatible features which our - * counterparty, or we, require. + * Whether this CResult_NoneSemanticErrorZ represents a success state. */ - LDKClosureReason_DisconnectedPeer, + bool result_ok; +} LDKCResult_NoneSemanticErrorZ; + +/** + * The contents of CResult_InvoiceSemanticErrorZ + */ +typedef union LDKCResult_InvoiceSemanticErrorZPtr { /** - * Closure generated from `ChannelManager::read` if the ChannelMonitor is newer than - * the ChannelManager deserialized. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - LDKClosureReason_OutdatedChannelManager, + struct LDKInvoice *result; /** - * Must be last for serialization purposes + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - LDKClosureReason_Sentinel, -} LDKClosureReason_Tag; + enum LDKSemanticError *err; +} LDKCResult_InvoiceSemanticErrorZPtr; -typedef struct LDKClosureReason_LDKCounterpartyForceClosed_Body { +/** + * A CResult_InvoiceSemanticErrorZ represents the result of a fallible operation, + * containing a crate::lightning_invoice::Invoice on success and a crate::lightning_invoice::SemanticError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_InvoiceSemanticErrorZ { /** - * The error which the peer sent us. - * - * The string should be sanitized before it is used (e.g emitted to logs - * or printed to stdout). Otherwise, a well crafted error message may exploit - * a security vulnerability in the terminal emulator or the logging subsystem. + * The contents of this CResult_InvoiceSemanticErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKStr peer_msg; -} LDKClosureReason_LDKCounterpartyForceClosed_Body; - -typedef struct LDKClosureReason_LDKProcessingError_Body { + union LDKCResult_InvoiceSemanticErrorZPtr contents; /** - * A developer-readable error message which we generated. + * Whether this CResult_InvoiceSemanticErrorZ represents a success state. */ - struct LDKStr err; -} LDKClosureReason_LDKProcessingError_Body; + bool result_ok; +} LDKCResult_InvoiceSemanticErrorZ; + -typedef struct MUST_USE_STRUCT LDKClosureReason { - LDKClosureReason_Tag tag; - union { - LDKClosureReason_LDKCounterpartyForceClosed_Body counterparty_force_closed; - LDKClosureReason_LDKProcessingError_Body processing_error; - }; -} LDKClosureReason; /** - * An Event which you should probably take some action in response to. + * Description string * - * Note that while Writeable and Readable are implemented for Event, you probably shouldn't use - * them directly as they don't round-trip exactly (for example FundingGenerationReady is never - * written as it makes no sense to respond to it after reconnecting to peers). + * # Invariants + * The description can be at most 639 __bytes__ long */ -typedef enum LDKEvent_Tag { +typedef struct MUST_USE_STRUCT LDKDescription { /** - * Used to indicate that the client should generate a funding transaction with the given - * parameters and then call ChannelManager::funding_transaction_generated. - * Generated in ChannelManager message handling. - * Note that *all inputs* in the funding transaction must spend SegWit outputs or your - * counterparty can steal your funds! + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKEvent_FundingGenerationReady, + LDKnativeDescription *inner; /** - * Indicates we've received money! Just gotta dig out that payment preimage and feed it to - * [`ChannelManager::claim_funds`] to get it.... - * Note that if the preimage is not known, you should call - * [`ChannelManager::fail_htlc_backwards`] to free up resources for this HTLC and avoid - * network congestion. - * If you fail to call either [`ChannelManager::claim_funds`] or - * [`ChannelManager::fail_htlc_backwards`] within the HTLC's timeout, the HTLC will be - * automatically failed. - * - * [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds - * [`ChannelManager::fail_htlc_backwards`]: crate::ln::channelmanager::ChannelManager::fail_htlc_backwards + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - LDKEvent_PaymentReceived, + bool is_owned; +} LDKDescription; + +/** + * The contents of CResult_DescriptionCreationErrorZ + */ +typedef union LDKCResult_DescriptionCreationErrorZPtr { /** - * Indicates an outbound payment we made succeeded (i.e. it made it all the way to its target - * and we got back the payment preimage for it). - * - * Note for MPP payments: in rare cases, this event may be preceded by a `PaymentPathFailed` - * event. In this situation, you SHOULD treat this payment as having succeeded. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - LDKEvent_PaymentSent, + struct LDKDescription *result; /** - * Indicates an outbound payment we made failed. Probably some intermediary node dropped - * something. You may wish to retry with a different route. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - LDKEvent_PaymentPathFailed, + enum LDKCreationError *err; +} LDKCResult_DescriptionCreationErrorZPtr; + +/** + * A CResult_DescriptionCreationErrorZ represents the result of a fallible operation, + * containing a crate::lightning_invoice::Description on success and a crate::lightning_invoice::CreationError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_DescriptionCreationErrorZ { /** - * Used to indicate that ChannelManager::process_pending_htlc_forwards should be called at a - * time in the future. + * The contents of this CResult_DescriptionCreationErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKEvent_PendingHTLCsForwardable, + union LDKCResult_DescriptionCreationErrorZPtr contents; /** - * Used to indicate that an output which you should know how to spend was confirmed on chain - * and is now spendable. - * Such an output will *not* ever be spent by rust-lightning, and are not at risk of your - * counterparty spending them due to some kind of timeout. Thus, you need to store them - * somewhere and spend them when you create on-chain transactions. + * Whether this CResult_DescriptionCreationErrorZ represents a success state. */ - LDKEvent_SpendableOutputs, + bool result_ok; +} LDKCResult_DescriptionCreationErrorZ; + +/** + * The contents of CResult_PrivateRouteCreationErrorZ + */ +typedef union LDKCResult_PrivateRouteCreationErrorZPtr { /** - * This event is generated when a payment has been successfully forwarded through us and a - * forwarding fee earned. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - LDKEvent_PaymentForwarded, + struct LDKPrivateRoute *result; /** - * Used to indicate that a channel with the given `channel_id` is in the process of closure. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - LDKEvent_ChannelClosed, + enum LDKCreationError *err; +} LDKCResult_PrivateRouteCreationErrorZPtr; + +/** + * A CResult_PrivateRouteCreationErrorZ represents the result of a fallible operation, + * containing a crate::lightning_invoice::PrivateRoute on success and a crate::lightning_invoice::CreationError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_PrivateRouteCreationErrorZ { /** - * Used to indicate to the user that they can abandon the funding transaction and recycle the - * inputs for another purpose. + * The contents of this CResult_PrivateRouteCreationErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKEvent_DiscardFunding, + union LDKCResult_PrivateRouteCreationErrorZPtr contents; /** - * Must be last for serialization purposes + * Whether this CResult_PrivateRouteCreationErrorZ represents a success state. */ - LDKEvent_Sentinel, -} LDKEvent_Tag; + bool result_ok; +} LDKCResult_PrivateRouteCreationErrorZ; -typedef struct LDKEvent_LDKFundingGenerationReady_Body { +/** + * The contents of CResult_StringErrorZ + */ +typedef union LDKCResult_StringErrorZPtr { /** - * The random channel_id we picked which you'll need to pass into - * ChannelManager::funding_transaction_generated. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKThirtyTwoBytes temporary_channel_id; + struct LDKStr *result; /** - * The value, in satoshis, that the output should have. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - uint64_t channel_value_satoshis; + enum LDKSecp256k1Error *err; +} LDKCResult_StringErrorZPtr; + +/** + * A CResult_StringErrorZ represents the result of a fallible operation, + * containing a crate::c_types::Str on success and a crate::c_types::Secp256k1Error on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_StringErrorZ { /** - * The script which should be used in the transaction output. + * The contents of this CResult_StringErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKCVec_u8Z output_script; + union LDKCResult_StringErrorZPtr contents; /** - * The `user_channel_id` value passed in to [`ChannelManager::create_channel`], or 0 for - * an inbound channel. - * - * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel + * Whether this CResult_StringErrorZ represents a success state. */ - uint64_t user_channel_id; -} LDKEvent_LDKFundingGenerationReady_Body; + bool result_ok; +} LDKCResult_StringErrorZ; -typedef struct LDKEvent_LDKPaymentReceived_Body { - /** - * The hash for which the preimage should be handed to the ChannelManager. - */ - struct LDKThirtyTwoBytes payment_hash; +/** + * The contents of CResult_ChannelMonitorUpdateDecodeErrorZ + */ +typedef union LDKCResult_ChannelMonitorUpdateDecodeErrorZPtr { /** - * The value, in thousandths of a satoshi, that this payment is for. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - uint64_t amt; + struct LDKChannelMonitorUpdate *result; /** - * Information for claiming this received payment, based on whether the purpose of the - * payment is to pay an invoice or to send a spontaneous payment. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKPaymentPurpose purpose; -} LDKEvent_LDKPaymentReceived_Body; + struct LDKDecodeError *err; +} LDKCResult_ChannelMonitorUpdateDecodeErrorZPtr; -typedef struct LDKEvent_LDKPaymentSent_Body { +/** + * A CResult_ChannelMonitorUpdateDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::chain::channelmonitor::ChannelMonitorUpdate on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_ChannelMonitorUpdateDecodeErrorZ { /** - * The id returned by [`ChannelManager::send_payment`] and used with - * [`ChannelManager::retry_payment`]. - * - * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment - * [`ChannelManager::retry_payment`]: crate::ln::channelmanager::ChannelManager::retry_payment - * - * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + * The contents of this CResult_ChannelMonitorUpdateDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKThirtyTwoBytes payment_id; + union LDKCResult_ChannelMonitorUpdateDecodeErrorZPtr contents; /** - * The preimage to the hash given to ChannelManager::send_payment. - * Note that this serves as a payment receipt, if you wish to have such a thing, you must - * store it somehow! + * Whether this CResult_ChannelMonitorUpdateDecodeErrorZ represents a success state. */ - struct LDKThirtyTwoBytes payment_preimage; + bool result_ok; +} LDKCResult_ChannelMonitorUpdateDecodeErrorZ; + +/** + * An enum which can either contain a crate::lightning::chain::channelmonitor::MonitorEvent or not + */ +typedef enum LDKCOption_MonitorEventZ_Tag { /** - * The hash which was given to [`ChannelManager::send_payment`]. - * - * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment + * When we're in this state, this COption_MonitorEventZ contains a crate::lightning::chain::channelmonitor::MonitorEvent */ - struct LDKThirtyTwoBytes payment_hash; + LDKCOption_MonitorEventZ_Some, /** - * The total fee which was spent at intermediate hops in this payment, across all paths. - * - * Note that, like [`Route::get_total_fees`] this does *not* include any potential - * overpayment to the recipient node. - * - * If the recipient or an intermediate node misbehaves and gives us free money, this may - * overstate the amount paid, though this is unlikely. - * - * [`Route::get_total_fees`]: crate::routing::router::Route::get_total_fees + * When we're in this state, this COption_MonitorEventZ contains nothing */ - struct LDKCOption_u64Z fee_paid_msat; -} LDKEvent_LDKPaymentSent_Body; - -typedef struct LDKEvent_LDKPaymentPathFailed_Body { + LDKCOption_MonitorEventZ_None, /** - * The id returned by [`ChannelManager::send_payment`] and used with - * [`ChannelManager::retry_payment`]. - * - * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment - * [`ChannelManager::retry_payment`]: crate::ln::channelmanager::ChannelManager::retry_payment - * - * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + * Must be last for serialization purposes */ - struct LDKThirtyTwoBytes payment_id; + LDKCOption_MonitorEventZ_Sentinel, +} LDKCOption_MonitorEventZ_Tag; + +typedef struct LDKCOption_MonitorEventZ { + LDKCOption_MonitorEventZ_Tag tag; + union { + struct { + struct LDKMonitorEvent some; + }; + }; +} LDKCOption_MonitorEventZ; + +/** + * The contents of CResult_COption_MonitorEventZDecodeErrorZ + */ +typedef union LDKCResult_COption_MonitorEventZDecodeErrorZPtr { /** - * The hash which was given to ChannelManager::send_payment. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKThirtyTwoBytes payment_hash; + struct LDKCOption_MonitorEventZ *result; /** - * Indicates the payment was rejected for some reason by the recipient. This implies that - * the payment has failed, not just the route in question. If this is not set, you may - * retry the payment via a different route. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - bool rejected_by_dest; + struct LDKDecodeError *err; +} LDKCResult_COption_MonitorEventZDecodeErrorZPtr; + +/** + * A CResult_COption_MonitorEventZDecodeErrorZ represents the result of a fallible operation, + * containing a crate::c_types::derived::COption_MonitorEventZ on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_COption_MonitorEventZDecodeErrorZ { /** - * Any failure information conveyed via the Onion return packet by a node along the failed - * payment route. - * - * Should be applied to the [`NetworkGraph`] so that routing decisions can take into - * account the update. [`NetGraphMsgHandler`] is capable of doing this. - * - * [`NetworkGraph`]: crate::routing::network_graph::NetworkGraph - * [`NetGraphMsgHandler`]: crate::routing::network_graph::NetGraphMsgHandler + * The contents of this CResult_COption_MonitorEventZDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKCOption_NetworkUpdateZ network_update; + union LDKCResult_COption_MonitorEventZDecodeErrorZPtr contents; /** - * For both single-path and multi-path payments, this is set if all paths of the payment have - * failed. This will be set to false if (1) this is an MPP payment and (2) other parts of the - * larger MPP payment were still in flight when this event was generated. + * Whether this CResult_COption_MonitorEventZDecodeErrorZ represents a success state. */ - bool all_paths_failed; + bool result_ok; +} LDKCResult_COption_MonitorEventZDecodeErrorZ; + +/** + * The contents of CResult_HTLCUpdateDecodeErrorZ + */ +typedef union LDKCResult_HTLCUpdateDecodeErrorZPtr { /** - * The payment path that failed. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKCVec_RouteHopZ path; + struct LDKHTLCUpdate *result; /** - * The channel responsible for the failed payment path. - * - * If this is `Some`, then the corresponding channel should be avoided when the payment is - * retried. May be `None` for older [`Event`] serializations. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKCOption_u64Z short_channel_id; + struct LDKDecodeError *err; +} LDKCResult_HTLCUpdateDecodeErrorZPtr; + +/** + * A CResult_HTLCUpdateDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::chain::channelmonitor::HTLCUpdate on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_HTLCUpdateDecodeErrorZ { /** - * Parameters needed to compute a new [`Route`] when retrying the failed payment path. - * - * See [`find_route`] for details. - * - * [`Route`]: crate::routing::router::Route - * [`find_route`]: crate::routing::router::find_route - * - * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + * The contents of this CResult_HTLCUpdateDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKRouteParameters retry; -} LDKEvent_LDKPaymentPathFailed_Body; - -typedef struct LDKEvent_LDKPendingHTLCsForwardable_Body { + union LDKCResult_HTLCUpdateDecodeErrorZPtr contents; /** - * The minimum amount of time that should be waited prior to calling - * process_pending_htlc_forwards. To increase the effort required to correlate payments, - * you should wait a random amount of time in roughly the range (now + time_forwardable, - * now + 5*time_forwardable). + * Whether this CResult_HTLCUpdateDecodeErrorZ represents a success state. */ - uint64_t time_forwardable; -} LDKEvent_LDKPendingHTLCsForwardable_Body; + bool result_ok; +} LDKCResult_HTLCUpdateDecodeErrorZ; -typedef struct LDKEvent_LDKSpendableOutputs_Body { +/** + * A tuple of 2 elements. See the individual fields for the types contained. + */ +typedef struct LDKC2Tuple_OutPointScriptZ { /** - * The outputs which you should store as spendable by you. + * The element at position 0 */ - struct LDKCVec_SpendableOutputDescriptorZ outputs; -} LDKEvent_LDKSpendableOutputs_Body; + struct LDKOutPoint a; + /** + * The element at position 1 + */ + struct LDKCVec_u8Z b; +} LDKC2Tuple_OutPointScriptZ; -typedef struct LDKEvent_LDKPaymentForwarded_Body { +/** + * A tuple of 2 elements. See the individual fields for the types contained. + */ +typedef struct LDKC2Tuple_u32ScriptZ { /** - * The fee, in milli-satoshis, which was earned as a result of the payment. - * - * Note that if we force-closed the channel over which we forwarded an HTLC while the HTLC - * was pending, the amount the next hop claimed will have been rounded down to the nearest - * whole satoshi. Thus, the fee calculated here may be higher than expected as we still - * claimed the full value in millisatoshis from the source. In this case, - * `claim_from_onchain_tx` will be set. - * - * If the channel which sent us the payment has been force-closed, we will claim the funds - * via an on-chain transaction. In that case we do not yet know the on-chain transaction - * fees which we will spend and will instead set this to `None`. It is possible duplicate - * `PaymentForwarded` events are generated for the same payment iff `fee_earned_msat` is - * `None`. + * The element at position 0 */ - struct LDKCOption_u64Z fee_earned_msat; + uint32_t a; /** - * If this is `true`, the forwarded HTLC was claimed by our counterparty via an on-chain - * transaction. + * The element at position 1 */ - bool claim_from_onchain_tx; -} LDKEvent_LDKPaymentForwarded_Body; + struct LDKCVec_u8Z b; +} LDKC2Tuple_u32ScriptZ; -typedef struct LDKEvent_LDKChannelClosed_Body { +/** + * A dynamically-allocated array of crate::c_types::derived::C2Tuple_u32ScriptZs of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_C2Tuple_u32ScriptZZ { /** - * The channel_id of the channel which has been closed. Note that on-chain transactions - * resolving the channel are likely still awaiting confirmation. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - struct LDKThirtyTwoBytes channel_id; + struct LDKC2Tuple_u32ScriptZ *data; /** - * The `user_channel_id` value passed in to [`ChannelManager::create_channel`], or 0 for - * an inbound channel. This will always be zero for objects serialized with LDK versions - * prior to 0.0.102. - * - * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel + * The number of elements pointed to by `data`. */ - uint64_t user_channel_id; + uintptr_t datalen; +} LDKCVec_C2Tuple_u32ScriptZZ; + +/** + * A tuple of 2 elements. See the individual fields for the types contained. + */ +typedef struct LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ { /** - * The reason the channel was closed. + * The element at position 0 */ - struct LDKClosureReason reason; -} LDKEvent_LDKChannelClosed_Body; + struct LDKThirtyTwoBytes a; + /** + * The element at position 1 + */ + struct LDKCVec_C2Tuple_u32ScriptZZ b; +} LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ; -typedef struct LDKEvent_LDKDiscardFunding_Body { +/** + * A dynamically-allocated array of crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZs of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ { /** - * The channel_id of the channel which has been closed. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - struct LDKThirtyTwoBytes channel_id; + struct LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *data; /** - * The full transaction received from the user + * The number of elements pointed to by `data`. */ - struct LDKTransaction transaction; -} LDKEvent_LDKDiscardFunding_Body; - -typedef struct MUST_USE_STRUCT LDKEvent { - LDKEvent_Tag tag; - union { - LDKEvent_LDKFundingGenerationReady_Body funding_generation_ready; - LDKEvent_LDKPaymentReceived_Body payment_received; - LDKEvent_LDKPaymentSent_Body payment_sent; - LDKEvent_LDKPaymentPathFailed_Body payment_path_failed; - LDKEvent_LDKPendingHTLCsForwardable_Body pending_htl_cs_forwardable; - LDKEvent_LDKSpendableOutputs_Body spendable_outputs; - LDKEvent_LDKPaymentForwarded_Body payment_forwarded; - LDKEvent_LDKChannelClosed_Body channel_closed; - LDKEvent_LDKDiscardFunding_Body discard_funding; - }; -} LDKEvent; + uintptr_t datalen; +} LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ; /** * A dynamically-allocated array of crate::lightning::util::events::Events of arbitrary size. @@ -7170,6 +8275,33 @@ typedef struct LDKCVec_PublicKeyZ { uintptr_t datalen; } LDKCVec_PublicKeyZ; +/** + * An enum which can either contain a crate::lightning::ln::msgs::NetAddress or not + */ +typedef enum LDKCOption_NetAddressZ_Tag { + /** + * When we're in this state, this COption_NetAddressZ contains a crate::lightning::ln::msgs::NetAddress + */ + LDKCOption_NetAddressZ_Some, + /** + * When we're in this state, this COption_NetAddressZ contains nothing + */ + LDKCOption_NetAddressZ_None, + /** + * Must be last for serialization purposes + */ + LDKCOption_NetAddressZ_Sentinel, +} LDKCOption_NetAddressZ_Tag; + +typedef struct LDKCOption_NetAddressZ { + LDKCOption_NetAddressZ_Tag tag; + union { + struct { + struct LDKNetAddress some; + }; + }; +} LDKCOption_NetAddressZ; + /** @@ -7343,6 +8475,39 @@ typedef struct LDKCResult_NodeIdDecodeErrorZ { bool result_ok; } LDKCResult_NodeIdDecodeErrorZ; +/** + * The contents of CResult_COption_NetworkUpdateZDecodeErrorZ + */ +typedef union LDKCResult_COption_NetworkUpdateZDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKCOption_NetworkUpdateZ *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + struct LDKDecodeError *err; +} LDKCResult_COption_NetworkUpdateZDecodeErrorZPtr; + +/** + * A CResult_COption_NetworkUpdateZDecodeErrorZ represents the result of a fallible operation, + * containing a crate::c_types::derived::COption_NetworkUpdateZ on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_COption_NetworkUpdateZDecodeErrorZ { + /** + * The contents of this CResult_COption_NetworkUpdateZDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_COption_NetworkUpdateZDecodeErrorZPtr contents; + /** + * Whether this CResult_COption_NetworkUpdateZDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_COption_NetworkUpdateZDecodeErrorZ; + /** * The `Access` trait defines behavior for accessing chain data and state, such as blocks and * UTXOs. @@ -7398,56 +8563,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; @@ -7678,26 +8842,6 @@ typedef struct LDKCResult_NodeInfoDecodeErrorZ { bool result_ok; } LDKCResult_NodeInfoDecodeErrorZ; - - -/** - * Represents the network as nodes and channels between them - */ -typedef struct MUST_USE_STRUCT LDKNetworkGraph { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeNetworkGraph *inner; - /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. - */ - bool is_owned; -} LDKNetworkGraph; - /** * The contents of CResult_NetworkGraphDecodeErrorZ */ @@ -8902,6 +10046,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; + /** @@ -9143,28 +10320,6 @@ typedef struct LDKCResult_ReplyChannelRangeDecodeErrorZ { bool result_ok; } LDKCResult_ReplyChannelRangeDecodeErrorZ; - - -/** - * A gossip_timestamp_filter message is used by a node to request - * gossip relay for messages in the requested time range when the - * gossip_queries feature has been negotiated. - */ -typedef struct MUST_USE_STRUCT LDKGossipTimestampFilter { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeGossipTimestampFilter *inner; - /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. - */ - bool is_owned; -} LDKGossipTimestampFilter; - /** * The contents of CResult_GossipTimestampFilterDecodeErrorZ */ @@ -9198,6 +10353,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. @@ -9899,86 +11070,85 @@ 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! - */ -typedef struct MUST_USE_STRUCT LDKKeysManager { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeKeysManager *inner; - /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. - */ - bool is_owned; -} LDKKeysManager; - - - -/** - * 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`. + * 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 LDKChainParameters { +typedef struct MUST_USE_STRUCT LDKKeysManager { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeChainParameters *inner; + LDKnativeKeysManager *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKChainParameters; +} LDKKeysManager; /** - * Information needed for constructing an invoice route hint for this channel. + * Similar to [`KeysManager`], but allows the node using this struct to receive phantom node + * payments. + * + * A phantom node payment is a payment made to a phantom invoice, which is an invoice that can be + * paid to one of multiple nodes. This works because we encode the invoice route hints such that + * LDK will recognize an incoming payment as destined for a phantom node, and collect the payment + * itself without ever needing to forward to this fake node. + * + * Phantom node payments are useful for load balancing between multiple LDK nodes. They also + * provide some fault tolerance, because payers will automatically retry paying other provided + * nodes in the case that one node goes down. + * + * Note that multi-path payments are not supported in phantom invoices for security reasons. + * Switching between this struct and [`KeysManager`] will invalidate any previously issued + * invoices and attempts to pay previous invoices will fail. */ -typedef struct MUST_USE_STRUCT 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. @@ -10220,7 +11390,7 @@ typedef struct LDKRoutingMessageHandler { * perform routing table synchronization using a strategy defined by the * implementor. */ - void (*sync_routing_table)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKInit *NONNULL_PTR init); + void (*peer_connected)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKInit *NONNULL_PTR init); /** * Handles the reply of a query we initiated to learn about channels * for a given range of blocks. We can expect to receive one or more @@ -10504,6 +11674,141 @@ typedef struct MUST_USE_STRUCT LDKDirectedChannelTransactionParameters { bool is_owned; } LDKDirectedChannelTransactionParameters; + + +/** + * A read-only view of [`NetworkGraph`]. + */ +typedef struct MUST_USE_STRUCT LDKReadOnlyNetworkGraph { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeReadOnlyNetworkGraph *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKReadOnlyNetworkGraph; + + + +/** + * Receives and validates network updates from peers, + * stores authentic and relevant data as a network graph. + * This network graph is then used for routing payments. + * Provides interface to help with initial routing sync by + * serving historical announcements. + * + * Serves as an [`EventHandler`] for applying updates from [`Event::PaymentPathFailed`] to the + * [`NetworkGraph`]. + */ +typedef struct MUST_USE_STRUCT LDKNetGraphMsgHandler { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeNetGraphMsgHandler *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; +} 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. * @@ -10516,14 +11821,24 @@ typedef struct LDKScore { */ void *this_arg; /** - * Returns the fee in msats willing to be paid to avoid routing through the given channel - * in the direction from `source` to `target`. + * Returns the fee in msats willing to be paid to avoid routing `send_amt_msat` through the + * given channel in the direction from `source` to `target`. + * + * The channel's capacity (less any other MPP parts that are also being considered for use in + * the same payment) is given by `capacity_msat`. It may be determined from various sources + * such as a chain data, network gossip, or invoice hints. For invoice hints, a capacity near + * [`u64::max_value`] is given to indicate sufficient capacity for the invoice's full amount. + * Thus, implementations should be overflow-safe. */ - uint64_t (*channel_penalty_msat)(const void *this_arg, uint64_t short_channel_id, const struct LDKNodeId *NONNULL_PTR source, const struct LDKNodeId *NONNULL_PTR target); + 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. */ void (*payment_path_failed)(void *this_arg, struct LDKCVec_RouteHopZ path, uint64_t short_channel_id); + /** + * Handles updating channel penalties after successfully routing along a path. + */ + void (*payment_path_successful)(void *this_arg, struct LDKCVec_RouteHopZ path); /** * Serialize the object into a byte array */ @@ -10535,8 +11850,6 @@ typedef struct LDKScore { void (*free)(void *this_arg); } LDKScore; - - /** * A scorer that is accessed under a lock. * @@ -10547,67 +11860,65 @@ typedef struct LDKScore { * * [`find_route`]: crate::routing::router::find_route */ -typedef struct MUST_USE_STRUCT LDKLockableScore { +typedef struct LDKLockableScore { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. + */ + void *this_arg; + /** + * Returns the locked scorer. */ - LDKnativeLockableScore *inner; + struct LDKScore (*lock)(const void *this_arg); /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. */ - bool is_owned; + void (*free)(void *this_arg); } LDKLockableScore; /** - * A read-only view of [`NetworkGraph`]. + * A concrete implementation of [`LockableScore`] which supports multi-threading. */ -typedef struct MUST_USE_STRUCT LDKReadOnlyNetworkGraph { +typedef struct MUST_USE_STRUCT LDKMultiThreadedLockableScore { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeReadOnlyNetworkGraph *inner; + LDKnativeMultiThreadedLockableScore *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKReadOnlyNetworkGraph; +} LDKMultiThreadedLockableScore; /** - * Receives and validates network updates from peers, - * stores authentic and relevant data as a network graph. - * This network graph is then used for routing payments. - * Provides interface to help with initial routing sync by - * serving historical announcements. + * Parameters for configuring [`ProbabilisticScorer`]. * - * Serves as an [`EventHandler`] for applying updates from [`Event::PaymentPathFailed`] to the - * [`NetworkGraph`]. + * Used to configure base, liquidity, and amount penalties, the sum of which comprises the channel + * penalty (i.e., the amount in msats willing to be paid to avoid routing through the channel). */ -typedef struct MUST_USE_STRUCT LDKNetGraphMsgHandler { +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. */ - LDKnativeNetGraphMsgHandler *inner; + 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; -} LDKNetGraphMsgHandler; +} LDKProbabilisticScoringParameters; @@ -10652,6 +11963,8 @@ typedef struct MUST_USE_STRUCT LDKFilesystemPersister { * [`ChannelManager`] persistence should be done in the background. * * Calling [`ChannelManager::timer_tick_occurred`] and [`PeerManager::timer_tick_occurred`] * at the appropriate intervals. + * * Calling [`NetworkGraph::remove_stale_channels`] (if a [`NetGraphMsgHandler`] is provided to + * [`BackgroundProcessor::start`]). * * It will also call [`PeerManager::process_events`] periodically though this shouldn't be relied * upon as doing so may result in high latency. @@ -10683,11 +11996,9 @@ typedef struct MUST_USE_STRUCT LDKBackgroundProcessor { } LDKBackgroundProcessor; /** - * Trait which handles persisting a [`ChannelManager`] to disk. - * - * [`ChannelManager`]: lightning::ln::channelmanager::ChannelManager + * Trait that handles persisting a [`ChannelManager`] and [`NetworkGraph`] to disk. */ -typedef struct LDKChannelManagerPersister { +typedef struct LDKPersister { /** * An opaque pointer which is passed to your function implementations as an argument. * This has no meaning in the LDK, and can be NULL or any other value. @@ -10695,17 +12006,19 @@ typedef struct LDKChannelManagerPersister { void *this_arg; /** * Persist the given [`ChannelManager`] to disk, returning an error if persistence failed - * (which will cause the [`BackgroundProcessor`] which called this method to exit. - * - * [`ChannelManager`]: lightning::ln::channelmanager::ChannelManager + * (which will cause the [`BackgroundProcessor`] which called this method to exit). */ struct LDKCResult_NoneErrorZ (*persist_manager)(const void *this_arg, const struct LDKChannelManager *NONNULL_PTR channel_manager); + /** + * Persist the given [`NetworkGraph`] to disk, returning an error if persistence failed. + */ + struct LDKCResult_NoneErrorZ (*persist_graph)(const void *this_arg, const struct LDKNetworkGraph *NONNULL_PTR network_graph); /** * Frees any resources associated with this object given its this_arg pointer. * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. */ void (*free)(void *this_arg); -} LDKChannelManagerPersister; +} LDKPersister; @@ -10749,6 +12062,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 */ @@ -10767,13 +12101,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. */ @@ -10838,10 +12165,18 @@ typedef struct LDKPayer { * Note that payment_secret (or a relevant inner pointer) may be NULL or all-0s to represent None */ struct LDKCResult_PaymentIdPaymentSendFailureZ (*send_payment)(const void *this_arg, const struct LDKRoute *NONNULL_PTR route, struct LDKThirtyTwoBytes payment_hash, struct LDKThirtyTwoBytes payment_secret); + /** + * Sends a spontaneous payment over the Lightning Network using the given [`Route`]. + */ + struct LDKCResult_PaymentIdPaymentSendFailureZ (*send_spontaneous_payment)(const void *this_arg, const struct LDKRoute *NONNULL_PTR route, struct LDKThirtyTwoBytes payment_preimage); /** * Retries a failed payment path for the [`PaymentId`] using the given [`Route`]. */ struct LDKCResult_NonePaymentSendFailureZ (*retry_payment)(const void *this_arg, const struct LDKRoute *NONNULL_PTR route, struct LDKThirtyTwoBytes payment_id); + /** + * Signals that no further retries for the given payment will occur. + */ + void (*abandon_payment)(const void *this_arg, struct LDKThirtyTwoBytes payment_id); /** * Frees any resources associated with this object given its this_arg pointer. * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. @@ -10863,7 +12198,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, 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. @@ -10874,7 +12209,11 @@ typedef struct LDKRouter { /** - * A utility for paying [`Invoice]`s. + * A utility for paying [`Invoice`]s and sending spontaneous payments. + * + * See [module-level documentation] for details. + * + * [module-level documentation]: crate::payment */ typedef struct MUST_USE_STRUCT LDKInvoicePayer { /** @@ -10951,6 +12290,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; @@ -11004,6 +12349,66 @@ struct LDKTxOut TxOut_clone(const struct LDKTxOut *NONNULL_PTR orig); */ void Str_free(struct LDKStr _res); +#if defined(LDK_DEBUG_BUILD) +/** + * This function exists for memory safety testing purposes. It should never be used in production + * code + */ +const void *__unmangle_inner_ptr(const void *ptr); +#endif + +/** + * 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. */ @@ -11014,11 +12419,22 @@ struct LDKCResult_SecretKeyErrorZ CResult_SecretKeyErrorZ_ok(struct LDKSecretKey */ struct LDKCResult_SecretKeyErrorZ CResult_SecretKeyErrorZ_err(enum LDKSecp256k1Error e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_SecretKeyErrorZ_is_ok(const struct LDKCResult_SecretKeyErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_SecretKeyErrorZ. */ void CResult_SecretKeyErrorZ_free(struct LDKCResult_SecretKeyErrorZ _res); +/** + * Creates a new CResult_SecretKeyErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_SecretKeyErrorZ CResult_SecretKeyErrorZ_clone(const struct LDKCResult_SecretKeyErrorZ *NONNULL_PTR orig); + /** * Creates a new CResult_PublicKeyErrorZ in the success state. */ @@ -11029,6 +12445,11 @@ struct LDKCResult_PublicKeyErrorZ CResult_PublicKeyErrorZ_ok(struct LDKPublicKey */ struct LDKCResult_PublicKeyErrorZ CResult_PublicKeyErrorZ_err(enum LDKSecp256k1Error e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_PublicKeyErrorZ_is_ok(const struct LDKCResult_PublicKeyErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_PublicKeyErrorZ. */ @@ -11050,6 +12471,11 @@ struct LDKCResult_TxCreationKeysDecodeErrorZ CResult_TxCreationKeysDecodeErrorZ_ */ struct LDKCResult_TxCreationKeysDecodeErrorZ CResult_TxCreationKeysDecodeErrorZ_err(struct LDKDecodeError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_TxCreationKeysDecodeErrorZ_is_ok(const struct LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_TxCreationKeysDecodeErrorZ. */ @@ -11071,6 +12497,11 @@ struct LDKCResult_ChannelPublicKeysDecodeErrorZ CResult_ChannelPublicKeysDecodeE */ struct LDKCResult_ChannelPublicKeysDecodeErrorZ CResult_ChannelPublicKeysDecodeErrorZ_err(struct LDKDecodeError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_ChannelPublicKeysDecodeErrorZ_is_ok(const struct LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_ChannelPublicKeysDecodeErrorZ. */ @@ -11090,7 +12521,12 @@ struct LDKCResult_TxCreationKeysErrorZ CResult_TxCreationKeysErrorZ_ok(struct LD /** * Creates a new CResult_TxCreationKeysErrorZ in the error state. */ -struct LDKCResult_TxCreationKeysErrorZ CResult_TxCreationKeysErrorZ_err(enum LDKSecp256k1Error e); +struct LDKCResult_TxCreationKeysErrorZ CResult_TxCreationKeysErrorZ_err(enum LDKSecp256k1Error e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_TxCreationKeysErrorZ_is_ok(const struct LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR o); /** * Frees any resources used by the CResult_TxCreationKeysErrorZ. @@ -11134,6 +12570,11 @@ struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ CResult_HTLCOutputInCommitm */ struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ CResult_HTLCOutputInCommitmentDecodeErrorZ_err(struct LDKDecodeError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(const struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_HTLCOutputInCommitmentDecodeErrorZ. */ @@ -11145,6 +12586,21 @@ void CResult_HTLCOutputInCommitmentDecodeErrorZ_free(struct LDKCResult_HTLCOutpu */ struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(const struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR orig); +/** + * Constructs a new COption_NoneZ containing a + */ +enum LDKCOption_NoneZ COption_NoneZ_some(void); + +/** + * Constructs a new COption_NoneZ containing nothing + */ +enum LDKCOption_NoneZ COption_NoneZ_none(void); + +/** + * Frees any resources associated with the , if we are in the Some state + */ +void COption_NoneZ_free(enum LDKCOption_NoneZ _res); + /** * Creates a new CResult_CounterpartyChannelTransactionParametersDecodeErrorZ in the success state. */ @@ -11155,6 +12611,11 @@ struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ CResult_C */ struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(struct LDKDecodeError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(const struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_CounterpartyChannelTransactionParametersDecodeErrorZ. */ @@ -11176,6 +12637,11 @@ struct LDKCResult_ChannelTransactionParametersDecodeErrorZ CResult_ChannelTransa */ struct LDKCResult_ChannelTransactionParametersDecodeErrorZ CResult_ChannelTransactionParametersDecodeErrorZ_err(struct LDKDecodeError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(const struct LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_ChannelTransactionParametersDecodeErrorZ. */ @@ -11202,6 +12668,11 @@ struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ CResult_HolderCommitme */ struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ CResult_HolderCommitmentTransactionDecodeErrorZ_err(struct LDKDecodeError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(const struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_HolderCommitmentTransactionDecodeErrorZ. */ @@ -11223,6 +12694,11 @@ struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ CResult_BuiltCommitment */ struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ CResult_BuiltCommitmentTransactionDecodeErrorZ_err(struct LDKDecodeError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(const struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_BuiltCommitmentTransactionDecodeErrorZ. */ @@ -11244,6 +12720,11 @@ struct LDKCResult_TrustedClosingTransactionNoneZ CResult_TrustedClosingTransacti */ struct LDKCResult_TrustedClosingTransactionNoneZ CResult_TrustedClosingTransactionNoneZ_err(void); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_TrustedClosingTransactionNoneZ_is_ok(const struct LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_TrustedClosingTransactionNoneZ. */ @@ -11259,6 +12740,11 @@ struct LDKCResult_CommitmentTransactionDecodeErrorZ CResult_CommitmentTransactio */ struct LDKCResult_CommitmentTransactionDecodeErrorZ CResult_CommitmentTransactionDecodeErrorZ_err(struct LDKDecodeError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_CommitmentTransactionDecodeErrorZ_is_ok(const struct LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_CommitmentTransactionDecodeErrorZ. */ @@ -11280,6 +12766,11 @@ struct LDKCResult_TrustedCommitmentTransactionNoneZ CResult_TrustedCommitmentTra */ struct LDKCResult_TrustedCommitmentTransactionNoneZ CResult_TrustedCommitmentTransactionNoneZ_err(void); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_TrustedCommitmentTransactionNoneZ_is_ok(const struct LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_TrustedCommitmentTransactionNoneZ. */ @@ -11295,6 +12786,11 @@ struct LDKCResult_CVec_SignatureZNoneZ CResult_CVec_SignatureZNoneZ_ok(struct LD */ struct LDKCResult_CVec_SignatureZNoneZ CResult_CVec_SignatureZNoneZ_err(void); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_CVec_SignatureZNoneZ_is_ok(const struct LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_CVec_SignatureZNoneZ. */ @@ -11316,6 +12812,11 @@ struct LDKCResult_ShutdownScriptDecodeErrorZ CResult_ShutdownScriptDecodeErrorZ_ */ struct LDKCResult_ShutdownScriptDecodeErrorZ CResult_ShutdownScriptDecodeErrorZ_err(struct LDKDecodeError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_ShutdownScriptDecodeErrorZ_is_ok(const struct LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_ShutdownScriptDecodeErrorZ. */ @@ -11337,11 +12838,22 @@ struct LDKCResult_ShutdownScriptInvalidShutdownScriptZ CResult_ShutdownScriptInv */ struct LDKCResult_ShutdownScriptInvalidShutdownScriptZ CResult_ShutdownScriptInvalidShutdownScriptZ_err(struct LDKInvalidShutdownScript e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(const struct LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_ShutdownScriptInvalidShutdownScriptZ. */ void CResult_ShutdownScriptInvalidShutdownScriptZ_free(struct LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res); +/** + * Creates a new CResult_ShutdownScriptInvalidShutdownScriptZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_ShutdownScriptInvalidShutdownScriptZ CResult_ShutdownScriptInvalidShutdownScriptZ_clone(const struct LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR orig); + /** * Creates a new CResult_NoneErrorZ in the success state. */ @@ -11352,6 +12864,11 @@ struct LDKCResult_NoneErrorZ CResult_NoneErrorZ_ok(void); */ struct LDKCResult_NoneErrorZ CResult_NoneErrorZ_err(enum LDKIOError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_NoneErrorZ_is_ok(const struct LDKCResult_NoneErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_NoneErrorZ. */ @@ -11373,6 +12890,11 @@ struct LDKCResult_RouteHopDecodeErrorZ CResult_RouteHopDecodeErrorZ_ok(struct LD */ struct LDKCResult_RouteHopDecodeErrorZ CResult_RouteHopDecodeErrorZ_err(struct LDKDecodeError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_RouteHopDecodeErrorZ_is_ok(const struct LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_RouteHopDecodeErrorZ. */ @@ -11404,6 +12926,11 @@ struct LDKCResult_RouteDecodeErrorZ CResult_RouteDecodeErrorZ_ok(struct LDKRoute */ struct LDKCResult_RouteDecodeErrorZ CResult_RouteDecodeErrorZ_err(struct LDKDecodeError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_RouteDecodeErrorZ_is_ok(const struct LDKCResult_RouteDecodeErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_RouteDecodeErrorZ. */ @@ -11425,6 +12952,11 @@ struct LDKCResult_RouteParametersDecodeErrorZ CResult_RouteParametersDecodeError */ struct LDKCResult_RouteParametersDecodeErrorZ CResult_RouteParametersDecodeErrorZ_err(struct LDKDecodeError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_RouteParametersDecodeErrorZ_is_ok(const struct LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_RouteParametersDecodeErrorZ. */ @@ -11463,223 +12995,439 @@ 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_PaymentParametersDecodeErrorZ CResult_PaymentParametersDecodeErrorZ_ok(struct LDKPaymentParameters o); + +/** + * Creates a new CResult_PaymentParametersDecodeErrorZ in the error state. + */ +struct LDKCResult_PaymentParametersDecodeErrorZ CResult_PaymentParametersDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_PaymentParametersDecodeErrorZ_is_ok(const struct LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_PaymentParametersDecodeErrorZ. + */ +void CResult_PaymentParametersDecodeErrorZ_free(struct LDKCResult_PaymentParametersDecodeErrorZ _res); + +/** + * Creates a new CResult_PaymentParametersDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_PaymentParametersDecodeErrorZ CResult_PaymentParametersDecodeErrorZ_clone(const struct LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR orig); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_RouteHintHopZ_free(struct LDKCVec_RouteHintHopZ _res); + +/** + * Creates a new CResult_RouteHintDecodeErrorZ in the success state. + */ +struct LDKCResult_RouteHintDecodeErrorZ CResult_RouteHintDecodeErrorZ_ok(struct LDKRouteHint o); + +/** + * Creates a new CResult_RouteHintDecodeErrorZ in the error state. + */ +struct LDKCResult_RouteHintDecodeErrorZ CResult_RouteHintDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_RouteHintDecodeErrorZ_is_ok(const struct LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_RouteHintDecodeErrorZ. + */ +void CResult_RouteHintDecodeErrorZ_free(struct LDKCResult_RouteHintDecodeErrorZ _res); + +/** + * Creates a new CResult_RouteHintDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_RouteHintDecodeErrorZ CResult_RouteHintDecodeErrorZ_clone(const struct LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_RouteHintHopDecodeErrorZ in the success state. + */ +struct LDKCResult_RouteHintHopDecodeErrorZ CResult_RouteHintHopDecodeErrorZ_ok(struct LDKRouteHintHop o); + +/** + * Creates a new CResult_RouteHintHopDecodeErrorZ in the error state. + */ +struct LDKCResult_RouteHintHopDecodeErrorZ CResult_RouteHintHopDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_RouteHintHopDecodeErrorZ_is_ok(const struct LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_RouteHintHopDecodeErrorZ. + */ +void CResult_RouteHintHopDecodeErrorZ_free(struct LDKCResult_RouteHintHopDecodeErrorZ _res); + +/** + * Creates a new CResult_RouteHintHopDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_RouteHintHopDecodeErrorZ CResult_RouteHintHopDecodeErrorZ_clone(const struct LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR orig); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_ChannelDetailsZ_free(struct LDKCVec_ChannelDetailsZ _res); + +/** + * Creates a new CResult_RouteLightningErrorZ in the success state. + */ +struct LDKCResult_RouteLightningErrorZ CResult_RouteLightningErrorZ_ok(struct LDKRoute o); + +/** + * Creates a new CResult_RouteLightningErrorZ in the error state. + */ +struct LDKCResult_RouteLightningErrorZ CResult_RouteLightningErrorZ_err(struct LDKLightningError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_RouteLightningErrorZ_is_ok(const struct LDKCResult_RouteLightningErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_RouteLightningErrorZ. + */ +void CResult_RouteLightningErrorZ_free(struct LDKCResult_RouteLightningErrorZ _res); + +/** + * Creates a new CResult_RouteLightningErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_RouteLightningErrorZ CResult_RouteLightningErrorZ_clone(const struct LDKCResult_RouteLightningErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_TxOutAccessErrorZ in the success state. + */ +struct LDKCResult_TxOutAccessErrorZ CResult_TxOutAccessErrorZ_ok(struct LDKTxOut o); + +/** + * Creates a new CResult_TxOutAccessErrorZ in the error state. + */ +struct LDKCResult_TxOutAccessErrorZ CResult_TxOutAccessErrorZ_err(enum LDKAccessError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_TxOutAccessErrorZ_is_ok(const struct LDKCResult_TxOutAccessErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_TxOutAccessErrorZ. + */ +void CResult_TxOutAccessErrorZ_free(struct LDKCResult_TxOutAccessErrorZ _res); + +/** + * Creates a new CResult_TxOutAccessErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_TxOutAccessErrorZ CResult_TxOutAccessErrorZ_clone(const struct LDKCResult_TxOutAccessErrorZ *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_usizeTransactionZ C2Tuple_usizeTransactionZ_clone(const struct LDKC2Tuple_usizeTransactionZ *NONNULL_PTR orig); + +/** + * Creates a new C2Tuple_usizeTransactionZ from the contained elements. + */ +struct LDKC2Tuple_usizeTransactionZ C2Tuple_usizeTransactionZ_new(uintptr_t a, struct LDKTransaction b); + +/** + * Frees any resources used by the C2Tuple_usizeTransactionZ. + */ +void C2Tuple_usizeTransactionZ_free(struct LDKC2Tuple_usizeTransactionZ _res); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_C2Tuple_usizeTransactionZZ_free(struct LDKCVec_C2Tuple_usizeTransactionZZ _res); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_TxidZ_free(struct LDKCVec_TxidZ _res); + +/** + * Creates a new CResult_NoneChannelMonitorUpdateErrZ in the success state. + */ +struct LDKCResult_NoneChannelMonitorUpdateErrZ CResult_NoneChannelMonitorUpdateErrZ_ok(void); + +/** + * Creates a new CResult_NoneChannelMonitorUpdateErrZ in the error state. + */ +struct LDKCResult_NoneChannelMonitorUpdateErrZ CResult_NoneChannelMonitorUpdateErrZ_err(enum LDKChannelMonitorUpdateErr e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_NoneChannelMonitorUpdateErrZ_is_ok(const struct LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_NoneChannelMonitorUpdateErrZ. + */ +void CResult_NoneChannelMonitorUpdateErrZ_free(struct LDKCResult_NoneChannelMonitorUpdateErrZ _res); + +/** + * Creates a new CResult_NoneChannelMonitorUpdateErrZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_NoneChannelMonitorUpdateErrZ CResult_NoneChannelMonitorUpdateErrZ_clone(const struct LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR orig); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_MonitorEventZ_free(struct LDKCVec_MonitorEventZ _res); + +/** + * Constructs a new COption_C2Tuple_usizeTransactionZZ containing a crate::c_types::derived::C2Tuple_usizeTransactionZ + */ +struct LDKCOption_C2Tuple_usizeTransactionZZ COption_C2Tuple_usizeTransactionZZ_some(struct LDKC2Tuple_usizeTransactionZ o); + +/** + * Constructs a new COption_C2Tuple_usizeTransactionZZ containing nothing + */ +struct LDKCOption_C2Tuple_usizeTransactionZZ COption_C2Tuple_usizeTransactionZZ_none(void); + +/** + * Frees any resources associated with the crate::c_types::derived::C2Tuple_usizeTransactionZ, if we are in the Some state + */ +void COption_C2Tuple_usizeTransactionZZ_free(struct LDKCOption_C2Tuple_usizeTransactionZZ _res); + +/** + * Creates a new COption_C2Tuple_usizeTransactionZZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCOption_C2Tuple_usizeTransactionZZ COption_C2Tuple_usizeTransactionZZ_clone(const struct LDKCOption_C2Tuple_usizeTransactionZZ *NONNULL_PTR orig); + +/** + * Constructs a new COption_ClosureReasonZ containing a crate::lightning::util::events::ClosureReason */ -struct LDKCResult_PayeeDecodeErrorZ CResult_PayeeDecodeErrorZ_ok(struct LDKPayee o); +struct LDKCOption_ClosureReasonZ COption_ClosureReasonZ_some(struct LDKClosureReason o); /** - * Creates a new CResult_PayeeDecodeErrorZ in the error state. + * Constructs a new COption_ClosureReasonZ containing nothing */ -struct LDKCResult_PayeeDecodeErrorZ CResult_PayeeDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCOption_ClosureReasonZ COption_ClosureReasonZ_none(void); /** - * Frees any resources used by the CResult_PayeeDecodeErrorZ. + * Frees any resources associated with the crate::lightning::util::events::ClosureReason, if we are in the Some state */ -void CResult_PayeeDecodeErrorZ_free(struct LDKCResult_PayeeDecodeErrorZ _res); +void COption_ClosureReasonZ_free(struct LDKCOption_ClosureReasonZ _res); /** - * Creates a new CResult_PayeeDecodeErrorZ which has the same data as `orig` + * Creates a new COption_ClosureReasonZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_PayeeDecodeErrorZ CResult_PayeeDecodeErrorZ_clone(const struct LDKCResult_PayeeDecodeErrorZ *NONNULL_PTR orig); +struct LDKCOption_ClosureReasonZ COption_ClosureReasonZ_clone(const struct LDKCOption_ClosureReasonZ *NONNULL_PTR orig); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Creates a new CResult_COption_ClosureReasonZDecodeErrorZ in the success state. */ -void CVec_RouteHintHopZ_free(struct LDKCVec_RouteHintHopZ _res); +struct LDKCResult_COption_ClosureReasonZDecodeErrorZ CResult_COption_ClosureReasonZDecodeErrorZ_ok(struct LDKCOption_ClosureReasonZ o); /** - * Creates a new CResult_RouteHintDecodeErrorZ in the success state. + * Creates a new CResult_COption_ClosureReasonZDecodeErrorZ in the error state. */ -struct LDKCResult_RouteHintDecodeErrorZ CResult_RouteHintDecodeErrorZ_ok(struct LDKRouteHint o); +struct LDKCResult_COption_ClosureReasonZDecodeErrorZ CResult_COption_ClosureReasonZDecodeErrorZ_err(struct LDKDecodeError e); /** - * Creates a new CResult_RouteHintDecodeErrorZ in the error state. + * Checks if the given object is currently in the success state */ -struct LDKCResult_RouteHintDecodeErrorZ CResult_RouteHintDecodeErrorZ_err(struct LDKDecodeError e); +bool CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(const struct LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_RouteHintDecodeErrorZ. + * Frees any resources used by the CResult_COption_ClosureReasonZDecodeErrorZ. */ -void CResult_RouteHintDecodeErrorZ_free(struct LDKCResult_RouteHintDecodeErrorZ _res); +void CResult_COption_ClosureReasonZDecodeErrorZ_free(struct LDKCResult_COption_ClosureReasonZDecodeErrorZ _res); /** - * Creates a new CResult_RouteHintDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_COption_ClosureReasonZDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_RouteHintDecodeErrorZ CResult_RouteHintDecodeErrorZ_clone(const struct LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_COption_ClosureReasonZDecodeErrorZ CResult_COption_ClosureReasonZDecodeErrorZ_clone(const struct LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_RouteHintHopDecodeErrorZ in the success state. + * Constructs a new COption_NetworkUpdateZ containing a crate::lightning::routing::network_graph::NetworkUpdate */ -struct LDKCResult_RouteHintHopDecodeErrorZ CResult_RouteHintHopDecodeErrorZ_ok(struct LDKRouteHintHop o); +struct LDKCOption_NetworkUpdateZ COption_NetworkUpdateZ_some(struct LDKNetworkUpdate o); /** - * Creates a new CResult_RouteHintHopDecodeErrorZ in the error state. + * Constructs a new COption_NetworkUpdateZ containing nothing */ -struct LDKCResult_RouteHintHopDecodeErrorZ CResult_RouteHintHopDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCOption_NetworkUpdateZ COption_NetworkUpdateZ_none(void); /** - * Frees any resources used by the CResult_RouteHintHopDecodeErrorZ. + * Frees any resources associated with the crate::lightning::routing::network_graph::NetworkUpdate, if we are in the Some state */ -void CResult_RouteHintHopDecodeErrorZ_free(struct LDKCResult_RouteHintHopDecodeErrorZ _res); +void COption_NetworkUpdateZ_free(struct LDKCOption_NetworkUpdateZ _res); /** - * Creates a new CResult_RouteHintHopDecodeErrorZ which has the same data as `orig` + * Creates a new COption_NetworkUpdateZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_RouteHintHopDecodeErrorZ CResult_RouteHintHopDecodeErrorZ_clone(const struct LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR orig); +struct LDKCOption_NetworkUpdateZ COption_NetworkUpdateZ_clone(const struct LDKCOption_NetworkUpdateZ *NONNULL_PTR orig); /** * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -void CVec_ChannelDetailsZ_free(struct LDKCVec_ChannelDetailsZ _res); +void CVec_SpendableOutputDescriptorZ_free(struct LDKCVec_SpendableOutputDescriptorZ _res); /** - * Creates a new CResult_RouteLightningErrorZ in the success state. + * Constructs a new COption_EventZ containing a crate::lightning::util::events::Event */ -struct LDKCResult_RouteLightningErrorZ CResult_RouteLightningErrorZ_ok(struct LDKRoute o); +struct LDKCOption_EventZ COption_EventZ_some(struct LDKEvent o); /** - * Creates a new CResult_RouteLightningErrorZ in the error state. + * Constructs a new COption_EventZ containing nothing */ -struct LDKCResult_RouteLightningErrorZ CResult_RouteLightningErrorZ_err(struct LDKLightningError e); +struct LDKCOption_EventZ COption_EventZ_none(void); /** - * Frees any resources used by the CResult_RouteLightningErrorZ. + * Frees any resources associated with the crate::lightning::util::events::Event, if we are in the Some state */ -void CResult_RouteLightningErrorZ_free(struct LDKCResult_RouteLightningErrorZ _res); +void COption_EventZ_free(struct LDKCOption_EventZ _res); /** - * Creates a new CResult_RouteLightningErrorZ which has the same data as `orig` + * Creates a new COption_EventZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_RouteLightningErrorZ CResult_RouteLightningErrorZ_clone(const struct LDKCResult_RouteLightningErrorZ *NONNULL_PTR orig); +struct LDKCOption_EventZ COption_EventZ_clone(const struct LDKCOption_EventZ *NONNULL_PTR orig); /** - * Creates a new CResult_TxOutAccessErrorZ in the success state. + * Creates a new CResult_COption_EventZDecodeErrorZ in the success state. */ -struct LDKCResult_TxOutAccessErrorZ CResult_TxOutAccessErrorZ_ok(struct LDKTxOut o); +struct LDKCResult_COption_EventZDecodeErrorZ CResult_COption_EventZDecodeErrorZ_ok(struct LDKCOption_EventZ o); /** - * Creates a new CResult_TxOutAccessErrorZ in the error state. + * Creates a new CResult_COption_EventZDecodeErrorZ in the error state. */ -struct LDKCResult_TxOutAccessErrorZ CResult_TxOutAccessErrorZ_err(enum LDKAccessError e); +struct LDKCResult_COption_EventZDecodeErrorZ CResult_COption_EventZDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees any resources used by the CResult_TxOutAccessErrorZ. + * Checks if the given object is currently in the success state */ -void CResult_TxOutAccessErrorZ_free(struct LDKCResult_TxOutAccessErrorZ _res); +bool CResult_COption_EventZDecodeErrorZ_is_ok(const struct LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR o); /** - * Creates a new CResult_TxOutAccessErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Frees any resources used by the CResult_COption_EventZDecodeErrorZ. */ -struct LDKCResult_TxOutAccessErrorZ CResult_TxOutAccessErrorZ_clone(const struct LDKCResult_TxOutAccessErrorZ *NONNULL_PTR orig); +void CResult_COption_EventZDecodeErrorZ_free(struct LDKCResult_COption_EventZDecodeErrorZ _res); /** - * Creates a new tuple which has the same data as `orig` + * Creates a new CResult_COption_EventZDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKC2Tuple_usizeTransactionZ C2Tuple_usizeTransactionZ_clone(const struct LDKC2Tuple_usizeTransactionZ *NONNULL_PTR orig); +struct LDKCResult_COption_EventZDecodeErrorZ CResult_COption_EventZDecodeErrorZ_clone(const struct LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new C2Tuple_usizeTransactionZ from the contained elements. + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -struct LDKC2Tuple_usizeTransactionZ C2Tuple_usizeTransactionZ_new(uintptr_t a, struct LDKTransaction b); +void CVec_MessageSendEventZ_free(struct LDKCVec_MessageSendEventZ _res); /** - * Frees any resources used by the C2Tuple_usizeTransactionZ. + * Creates a new CResult_FixedPenaltyScorerDecodeErrorZ in the success state. */ -void C2Tuple_usizeTransactionZ_free(struct LDKC2Tuple_usizeTransactionZ _res); +struct LDKCResult_FixedPenaltyScorerDecodeErrorZ CResult_FixedPenaltyScorerDecodeErrorZ_ok(struct LDKFixedPenaltyScorer o); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Creates a new CResult_FixedPenaltyScorerDecodeErrorZ in the error state. */ -void CVec_C2Tuple_usizeTransactionZZ_free(struct LDKCVec_C2Tuple_usizeTransactionZZ _res); +struct LDKCResult_FixedPenaltyScorerDecodeErrorZ CResult_FixedPenaltyScorerDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Checks if the given object is currently in the success state */ -void CVec_TxidZ_free(struct LDKCVec_TxidZ _res); +bool CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(const struct LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR o); /** - * Creates a new CResult_NoneChannelMonitorUpdateErrZ in the success state. + * Frees any resources used by the CResult_FixedPenaltyScorerDecodeErrorZ. */ -struct LDKCResult_NoneChannelMonitorUpdateErrZ CResult_NoneChannelMonitorUpdateErrZ_ok(void); +void CResult_FixedPenaltyScorerDecodeErrorZ_free(struct LDKCResult_FixedPenaltyScorerDecodeErrorZ _res); /** - * Creates a new CResult_NoneChannelMonitorUpdateErrZ in the error state. + * Creates a new CResult_FixedPenaltyScorerDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_NoneChannelMonitorUpdateErrZ CResult_NoneChannelMonitorUpdateErrZ_err(enum LDKChannelMonitorUpdateErr e); +struct LDKCResult_FixedPenaltyScorerDecodeErrorZ CResult_FixedPenaltyScorerDecodeErrorZ_clone(const struct LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR orig); /** - * Frees any resources used by the CResult_NoneChannelMonitorUpdateErrZ. + * Creates a new CResult_ScoringParametersDecodeErrorZ in the success state. */ -void CResult_NoneChannelMonitorUpdateErrZ_free(struct LDKCResult_NoneChannelMonitorUpdateErrZ _res); +struct LDKCResult_ScoringParametersDecodeErrorZ CResult_ScoringParametersDecodeErrorZ_ok(struct LDKScoringParameters o); /** - * Creates a new CResult_NoneChannelMonitorUpdateErrZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Creates a new CResult_ScoringParametersDecodeErrorZ in the error state. */ -struct LDKCResult_NoneChannelMonitorUpdateErrZ CResult_NoneChannelMonitorUpdateErrZ_clone(const struct LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR orig); +struct LDKCResult_ScoringParametersDecodeErrorZ CResult_ScoringParametersDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Checks if the given object is currently in the success state */ -void CVec_MonitorEventZ_free(struct LDKCVec_MonitorEventZ _res); +bool CResult_ScoringParametersDecodeErrorZ_is_ok(const struct LDKCResult_ScoringParametersDecodeErrorZ *NONNULL_PTR o); /** - * Constructs a new COption_C2Tuple_usizeTransactionZZ containing a crate::c_types::derived::C2Tuple_usizeTransactionZ + * Frees any resources used by the CResult_ScoringParametersDecodeErrorZ. */ -struct LDKCOption_C2Tuple_usizeTransactionZZ COption_C2Tuple_usizeTransactionZZ_some(struct LDKC2Tuple_usizeTransactionZ o); +void CResult_ScoringParametersDecodeErrorZ_free(struct LDKCResult_ScoringParametersDecodeErrorZ _res); /** - * Constructs a new COption_C2Tuple_usizeTransactionZZ containing nothing + * Creates a new CResult_ScoringParametersDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCOption_C2Tuple_usizeTransactionZZ COption_C2Tuple_usizeTransactionZZ_none(void); +struct LDKCResult_ScoringParametersDecodeErrorZ CResult_ScoringParametersDecodeErrorZ_clone(const struct LDKCResult_ScoringParametersDecodeErrorZ *NONNULL_PTR orig); /** - * Frees any resources associated with the crate::c_types::derived::C2Tuple_usizeTransactionZ, if we are in the Some state + * Creates a new CResult_ScorerDecodeErrorZ in the success state. */ -void COption_C2Tuple_usizeTransactionZZ_free(struct LDKCOption_C2Tuple_usizeTransactionZZ _res); +struct LDKCResult_ScorerDecodeErrorZ CResult_ScorerDecodeErrorZ_ok(struct LDKScorer o); /** - * Creates a new COption_C2Tuple_usizeTransactionZZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Creates a new CResult_ScorerDecodeErrorZ in the error state. */ -struct LDKCOption_C2Tuple_usizeTransactionZZ COption_C2Tuple_usizeTransactionZZ_clone(const struct LDKCOption_C2Tuple_usizeTransactionZZ *NONNULL_PTR orig); +struct LDKCResult_ScorerDecodeErrorZ CResult_ScorerDecodeErrorZ_err(struct LDKDecodeError e); /** - * Constructs a new COption_NetworkUpdateZ containing a crate::lightning::routing::network_graph::NetworkUpdate + * Checks if the given object is currently in the success state */ -struct LDKCOption_NetworkUpdateZ COption_NetworkUpdateZ_some(struct LDKNetworkUpdate o); +bool CResult_ScorerDecodeErrorZ_is_ok(const struct LDKCResult_ScorerDecodeErrorZ *NONNULL_PTR o); /** - * Constructs a new COption_NetworkUpdateZ containing nothing + * Frees any resources used by the CResult_ScorerDecodeErrorZ. */ -struct LDKCOption_NetworkUpdateZ COption_NetworkUpdateZ_none(void); +void CResult_ScorerDecodeErrorZ_free(struct LDKCResult_ScorerDecodeErrorZ _res); /** - * Frees any resources associated with the crate::lightning::routing::network_graph::NetworkUpdate, if we are in the Some state + * Creates a new CResult_ProbabilisticScorerDecodeErrorZ in the success state. */ -void COption_NetworkUpdateZ_free(struct LDKCOption_NetworkUpdateZ _res); +struct LDKCResult_ProbabilisticScorerDecodeErrorZ CResult_ProbabilisticScorerDecodeErrorZ_ok(struct LDKProbabilisticScorer o); /** - * Creates a new COption_NetworkUpdateZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Creates a new CResult_ProbabilisticScorerDecodeErrorZ in the error state. */ -struct LDKCOption_NetworkUpdateZ COption_NetworkUpdateZ_clone(const struct LDKCOption_NetworkUpdateZ *NONNULL_PTR orig); +struct LDKCResult_ProbabilisticScorerDecodeErrorZ CResult_ProbabilisticScorerDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Checks if the given object is currently in the success state */ -void CVec_SpendableOutputDescriptorZ_free(struct LDKCVec_SpendableOutputDescriptorZ _res); +bool CResult_ProbabilisticScorerDecodeErrorZ_is_ok(const struct LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR o); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Frees any resources used by the CResult_ProbabilisticScorerDecodeErrorZ. */ -void CVec_MessageSendEventZ_free(struct LDKCVec_MessageSendEventZ _res); +void CResult_ProbabilisticScorerDecodeErrorZ_free(struct LDKCResult_ProbabilisticScorerDecodeErrorZ _res); /** * Creates a new CResult_InitFeaturesDecodeErrorZ in the success state. @@ -11691,40 +13439,55 @@ struct LDKCResult_InitFeaturesDecodeErrorZ CResult_InitFeaturesDecodeErrorZ_ok(s */ struct LDKCResult_InitFeaturesDecodeErrorZ CResult_InitFeaturesDecodeErrorZ_err(struct LDKDecodeError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_InitFeaturesDecodeErrorZ_is_ok(const struct LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_InitFeaturesDecodeErrorZ. */ void CResult_InitFeaturesDecodeErrorZ_free(struct LDKCResult_InitFeaturesDecodeErrorZ _res); /** - * Creates a new CResult_NodeFeaturesDecodeErrorZ in the success state. + * Creates a new CResult_ChannelFeaturesDecodeErrorZ in the success state. */ -struct LDKCResult_NodeFeaturesDecodeErrorZ CResult_NodeFeaturesDecodeErrorZ_ok(struct LDKNodeFeatures o); +struct LDKCResult_ChannelFeaturesDecodeErrorZ CResult_ChannelFeaturesDecodeErrorZ_ok(struct LDKChannelFeatures o); /** - * Creates a new CResult_NodeFeaturesDecodeErrorZ in the error state. + * Creates a new CResult_ChannelFeaturesDecodeErrorZ in the error state. */ -struct LDKCResult_NodeFeaturesDecodeErrorZ CResult_NodeFeaturesDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_ChannelFeaturesDecodeErrorZ CResult_ChannelFeaturesDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees any resources used by the CResult_NodeFeaturesDecodeErrorZ. + * Checks if the given object is currently in the success state */ -void CResult_NodeFeaturesDecodeErrorZ_free(struct LDKCResult_NodeFeaturesDecodeErrorZ _res); +bool CResult_ChannelFeaturesDecodeErrorZ_is_ok(const struct LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR o); /** - * Creates a new CResult_ChannelFeaturesDecodeErrorZ in the success state. + * Frees any resources used by the CResult_ChannelFeaturesDecodeErrorZ. */ -struct LDKCResult_ChannelFeaturesDecodeErrorZ CResult_ChannelFeaturesDecodeErrorZ_ok(struct LDKChannelFeatures o); +void CResult_ChannelFeaturesDecodeErrorZ_free(struct LDKCResult_ChannelFeaturesDecodeErrorZ _res); /** - * Creates a new CResult_ChannelFeaturesDecodeErrorZ in the error state. + * Creates a new CResult_NodeFeaturesDecodeErrorZ in the success state. */ -struct LDKCResult_ChannelFeaturesDecodeErrorZ CResult_ChannelFeaturesDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_NodeFeaturesDecodeErrorZ CResult_NodeFeaturesDecodeErrorZ_ok(struct LDKNodeFeatures o); /** - * Frees any resources used by the CResult_ChannelFeaturesDecodeErrorZ. + * Creates a new CResult_NodeFeaturesDecodeErrorZ in the error state. */ -void CResult_ChannelFeaturesDecodeErrorZ_free(struct LDKCResult_ChannelFeaturesDecodeErrorZ _res); +struct LDKCResult_NodeFeaturesDecodeErrorZ CResult_NodeFeaturesDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_NodeFeaturesDecodeErrorZ_is_ok(const struct LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_NodeFeaturesDecodeErrorZ. + */ +void CResult_NodeFeaturesDecodeErrorZ_free(struct LDKCResult_NodeFeaturesDecodeErrorZ _res); /** * Creates a new CResult_InvoiceFeaturesDecodeErrorZ in the success state. @@ -11737,39 +13500,34 @@ struct LDKCResult_InvoiceFeaturesDecodeErrorZ CResult_InvoiceFeaturesDecodeError struct LDKCResult_InvoiceFeaturesDecodeErrorZ CResult_InvoiceFeaturesDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees any resources used by the CResult_InvoiceFeaturesDecodeErrorZ. - */ -void CResult_InvoiceFeaturesDecodeErrorZ_free(struct LDKCResult_InvoiceFeaturesDecodeErrorZ _res); - -/** - * Creates a new CResult_ScoringParametersDecodeErrorZ in the success state. + * Checks if the given object is currently in the success state */ -struct LDKCResult_ScoringParametersDecodeErrorZ CResult_ScoringParametersDecodeErrorZ_ok(struct LDKScoringParameters o); +bool CResult_InvoiceFeaturesDecodeErrorZ_is_ok(const struct LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR o); /** - * Creates a new CResult_ScoringParametersDecodeErrorZ in the error state. + * Frees any resources used by the CResult_InvoiceFeaturesDecodeErrorZ. */ -struct LDKCResult_ScoringParametersDecodeErrorZ CResult_ScoringParametersDecodeErrorZ_err(struct LDKDecodeError e); +void CResult_InvoiceFeaturesDecodeErrorZ_free(struct LDKCResult_InvoiceFeaturesDecodeErrorZ _res); /** - * Frees any resources used by the CResult_ScoringParametersDecodeErrorZ. + * Creates a new CResult_ChannelTypeFeaturesDecodeErrorZ in the success state. */ -void CResult_ScoringParametersDecodeErrorZ_free(struct LDKCResult_ScoringParametersDecodeErrorZ _res); +struct LDKCResult_ChannelTypeFeaturesDecodeErrorZ CResult_ChannelTypeFeaturesDecodeErrorZ_ok(struct LDKChannelTypeFeatures o); /** - * Creates a new CResult_ScorerDecodeErrorZ in the success state. + * Creates a new CResult_ChannelTypeFeaturesDecodeErrorZ in the error state. */ -struct LDKCResult_ScorerDecodeErrorZ CResult_ScorerDecodeErrorZ_ok(struct LDKScorer o); +struct LDKCResult_ChannelTypeFeaturesDecodeErrorZ CResult_ChannelTypeFeaturesDecodeErrorZ_err(struct LDKDecodeError e); /** - * Creates a new CResult_ScorerDecodeErrorZ in the error state. + * Checks if the given object is currently in the success state */ -struct LDKCResult_ScorerDecodeErrorZ CResult_ScorerDecodeErrorZ_err(struct LDKDecodeError e); +bool CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(const struct LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_ScorerDecodeErrorZ. + * Frees any resources used by the CResult_ChannelTypeFeaturesDecodeErrorZ. */ -void CResult_ScorerDecodeErrorZ_free(struct LDKCResult_ScorerDecodeErrorZ _res); +void CResult_ChannelTypeFeaturesDecodeErrorZ_free(struct LDKCResult_ChannelTypeFeaturesDecodeErrorZ _res); /** * Creates a new CResult_DelayedPaymentOutputDescriptorDecodeErrorZ in the success state. @@ -11781,6 +13539,11 @@ struct LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ CResult_DelayedPaym */ struct LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(struct LDKDecodeError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(const struct LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_DelayedPaymentOutputDescriptorDecodeErrorZ. */ @@ -11802,6 +13565,11 @@ struct LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ CResult_StaticPaymen */ struct LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(struct LDKDecodeError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(const struct LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_StaticPaymentOutputDescriptorDecodeErrorZ. */ @@ -11823,6 +13591,11 @@ struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ CResult_SpendableOutputD */ struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ CResult_SpendableOutputDescriptorDecodeErrorZ_err(struct LDKDecodeError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(const struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_SpendableOutputDescriptorDecodeErrorZ. */ @@ -11835,25 +13608,9 @@ 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. - */ -struct LDKCResult_NoneNoneZ CResult_NoneNoneZ_ok(void); - -/** - * Creates a new CResult_NoneNoneZ in the error state. - */ -struct LDKCResult_NoneNoneZ CResult_NoneNoneZ_err(void); - -/** - * 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. + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -struct LDKCResult_NoneNoneZ CResult_NoneNoneZ_clone(const struct LDKCResult_NoneNoneZ *NONNULL_PTR orig); +void CVec_PaymentPreimageZ_free(struct LDKCVec_PaymentPreimageZ _res); /** * Creates a new tuple which has the same data as `orig` @@ -11881,6 +13638,11 @@ struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ CResult_C2Tuple_Signatu */ struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err(void); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(const struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ. */ @@ -11902,6 +13664,11 @@ struct LDKCResult_SignatureNoneZ CResult_SignatureNoneZ_ok(struct LDKSignature o */ 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. */ @@ -11913,6 +13680,74 @@ void CResult_SignatureNoneZ_free(struct LDKCResult_SignatureNoneZ _res); */ 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_SignatureSignatureZ C2Tuple_SignatureSignatureZ_clone(const struct LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR orig); + +/** + * Creates a new C2Tuple_SignatureSignatureZ from the contained elements. + */ +struct LDKC2Tuple_SignatureSignatureZ C2Tuple_SignatureSignatureZ_new(struct LDKSignature a, struct LDKSignature b); + +/** + * Frees any resources used by the C2Tuple_SignatureSignatureZ. + */ +void C2Tuple_SignatureSignatureZ_free(struct LDKC2Tuple_SignatureSignatureZ _res); + +/** + * Creates a new CResult_C2Tuple_SignatureSignatureZNoneZ in the success state. + */ +struct LDKCResult_C2Tuple_SignatureSignatureZNoneZ CResult_C2Tuple_SignatureSignatureZNoneZ_ok(struct LDKC2Tuple_SignatureSignatureZ o); + +/** + * Creates a new CResult_C2Tuple_SignatureSignatureZNoneZ in the error state. + */ +struct LDKCResult_C2Tuple_SignatureSignatureZNoneZ CResult_C2Tuple_SignatureSignatureZNoneZ_err(void); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_C2Tuple_SignatureSignatureZNoneZ_is_ok(const struct LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_C2Tuple_SignatureSignatureZNoneZ. + */ +void CResult_C2Tuple_SignatureSignatureZNoneZ_free(struct LDKCResult_C2Tuple_SignatureSignatureZNoneZ _res); + +/** + * 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_SignatureSignatureZNoneZ CResult_C2Tuple_SignatureSignatureZNoneZ_clone(const struct LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_SecretKeyNoneZ in the success state. + */ +struct LDKCResult_SecretKeyNoneZ CResult_SecretKeyNoneZ_ok(struct LDKSecretKey o); + +/** + * Creates a new CResult_SecretKeyNoneZ in the error state. + */ +struct LDKCResult_SecretKeyNoneZ CResult_SecretKeyNoneZ_err(void); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_SecretKeyNoneZ_is_ok(const struct LDKCResult_SecretKeyNoneZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_SecretKeyNoneZ. + */ +void CResult_SecretKeyNoneZ_free(struct LDKCResult_SecretKeyNoneZ _res); + +/** + * Creates a new CResult_SecretKeyNoneZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_SecretKeyNoneZ CResult_SecretKeyNoneZ_clone(const struct LDKCResult_SecretKeyNoneZ *NONNULL_PTR orig); + /** * Creates a new CResult_SignDecodeErrorZ in the success state. */ @@ -11923,6 +13758,11 @@ struct LDKCResult_SignDecodeErrorZ CResult_SignDecodeErrorZ_ok(struct LDKSign o) */ struct LDKCResult_SignDecodeErrorZ CResult_SignDecodeErrorZ_err(struct LDKDecodeError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_SignDecodeErrorZ_is_ok(const struct LDKCResult_SignDecodeErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_SignDecodeErrorZ. */ @@ -11937,7 +13777,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. @@ -11949,6 +13789,11 @@ struct LDKCResult_RecoverableSignatureNoneZ CResult_RecoverableSignatureNoneZ_ok */ struct LDKCResult_RecoverableSignatureNoneZ CResult_RecoverableSignatureNoneZ_err(void); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_RecoverableSignatureNoneZ_is_ok(const struct LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_RecoverableSignatureNoneZ. */ @@ -11960,6 +13805,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. */ @@ -11975,6 +13825,11 @@ struct LDKCResult_CVec_CVec_u8ZZNoneZ CResult_CVec_CVec_u8ZZNoneZ_ok(struct LDKC */ struct LDKCResult_CVec_CVec_u8ZZNoneZ CResult_CVec_CVec_u8ZZNoneZ_err(void); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_CVec_CVec_u8ZZNoneZ_is_ok(const struct LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_CVec_CVec_u8ZZNoneZ. */ @@ -11996,6 +13851,11 @@ struct LDKCResult_InMemorySignerDecodeErrorZ CResult_InMemorySignerDecodeErrorZ_ */ struct LDKCResult_InMemorySignerDecodeErrorZ CResult_InMemorySignerDecodeErrorZ_err(struct LDKDecodeError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_InMemorySignerDecodeErrorZ_is_ok(const struct LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_InMemorySignerDecodeErrorZ. */ @@ -12020,7 +13880,12 @@ struct LDKCResult_TransactionNoneZ CResult_TransactionNoneZ_ok(struct LDKTransac /** * Creates a new CResult_TransactionNoneZ in the error state. */ -struct LDKCResult_TransactionNoneZ CResult_TransactionNoneZ_err(void); +struct LDKCResult_TransactionNoneZ CResult_TransactionNoneZ_err(void); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_TransactionNoneZ_is_ok(const struct LDKCResult_TransactionNoneZ *NONNULL_PTR o); /** * Frees any resources used by the CResult_TransactionNoneZ. @@ -12058,6 +13923,11 @@ struct LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ CResult_CVec_C2Tu */ struct LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(enum LDKIOError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_is_ok(const struct LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ. */ @@ -12094,6 +13964,11 @@ struct LDKCResult_NoneAPIErrorZ CResult_NoneAPIErrorZ_ok(void); */ struct LDKCResult_NoneAPIErrorZ CResult_NoneAPIErrorZ_err(struct LDKAPIError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_NoneAPIErrorZ_is_ok(const struct LDKCResult_NoneAPIErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_NoneAPIErrorZ. */ @@ -12125,6 +14000,11 @@ struct LDKCResult__u832APIErrorZ CResult__u832APIErrorZ_ok(struct LDKThirtyTwoBy */ struct LDKCResult__u832APIErrorZ CResult__u832APIErrorZ_err(struct LDKAPIError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult__u832APIErrorZ_is_ok(const struct LDKCResult__u832APIErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult__u832APIErrorZ. */ @@ -12146,6 +14026,11 @@ struct LDKCResult_PaymentIdPaymentSendFailureZ CResult_PaymentIdPaymentSendFailu */ struct LDKCResult_PaymentIdPaymentSendFailureZ CResult_PaymentIdPaymentSendFailureZ_err(struct LDKPaymentSendFailure e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_PaymentIdPaymentSendFailureZ_is_ok(const struct LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_PaymentIdPaymentSendFailureZ. */ @@ -12167,6 +14052,11 @@ struct LDKCResult_NonePaymentSendFailureZ CResult_NonePaymentSendFailureZ_ok(voi */ struct LDKCResult_NonePaymentSendFailureZ CResult_NonePaymentSendFailureZ_err(struct LDKPaymentSendFailure e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_NonePaymentSendFailureZ_is_ok(const struct LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_NonePaymentSendFailureZ. */ @@ -12204,6 +14094,11 @@ struct LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ CResult_C2Tup */ struct LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(struct LDKPaymentSendFailure e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(const struct LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ. */ @@ -12236,6 +14131,84 @@ struct LDKC2Tuple_PaymentHashPaymentSecretZ C2Tuple_PaymentHashPaymentSecretZ_ne */ void C2Tuple_PaymentHashPaymentSecretZ_free(struct LDKC2Tuple_PaymentHashPaymentSecretZ _res); +/** + * Creates a new CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ in the success state. + */ +struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(struct LDKC2Tuple_PaymentHashPaymentSecretZ o); + +/** + * Creates a new CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ in the error state. + */ +struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err(void); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(const struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ. + */ +void CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ _res); + +/** + * Creates a new CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(const struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ in the success state. + */ +struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(struct LDKC2Tuple_PaymentHashPaymentSecretZ o); + +/** + * Creates a new CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ in the error state. + */ +struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(struct LDKAPIError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok(const struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ. + */ +void CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ _res); + +/** + * Creates a new CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(const struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_PaymentSecretNoneZ in the success state. + */ +struct LDKCResult_PaymentSecretNoneZ CResult_PaymentSecretNoneZ_ok(struct LDKThirtyTwoBytes o); + +/** + * Creates a new CResult_PaymentSecretNoneZ in the error state. + */ +struct LDKCResult_PaymentSecretNoneZ CResult_PaymentSecretNoneZ_err(void); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_PaymentSecretNoneZ_is_ok(const struct LDKCResult_PaymentSecretNoneZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_PaymentSecretNoneZ. + */ +void CResult_PaymentSecretNoneZ_free(struct LDKCResult_PaymentSecretNoneZ _res); + +/** + * Creates a new CResult_PaymentSecretNoneZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_PaymentSecretNoneZ CResult_PaymentSecretNoneZ_clone(const struct LDKCResult_PaymentSecretNoneZ *NONNULL_PTR orig); + /** * Creates a new CResult_PaymentSecretAPIErrorZ in the success state. */ @@ -12246,6 +14219,11 @@ struct LDKCResult_PaymentSecretAPIErrorZ CResult_PaymentSecretAPIErrorZ_ok(struc */ struct LDKCResult_PaymentSecretAPIErrorZ CResult_PaymentSecretAPIErrorZ_err(struct LDKAPIError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_PaymentSecretAPIErrorZ_is_ok(const struct LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_PaymentSecretAPIErrorZ. */ @@ -12257,6 +14235,136 @@ void CResult_PaymentSecretAPIErrorZ_free(struct LDKCResult_PaymentSecretAPIError */ struct LDKCResult_PaymentSecretAPIErrorZ CResult_PaymentSecretAPIErrorZ_clone(const struct LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR orig); +/** + * Creates a new CResult_PaymentPreimageAPIErrorZ in the success state. + */ +struct LDKCResult_PaymentPreimageAPIErrorZ CResult_PaymentPreimageAPIErrorZ_ok(struct LDKThirtyTwoBytes o); + +/** + * Creates a new CResult_PaymentPreimageAPIErrorZ in the error state. + */ +struct LDKCResult_PaymentPreimageAPIErrorZ CResult_PaymentPreimageAPIErrorZ_err(struct LDKAPIError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_PaymentPreimageAPIErrorZ_is_ok(const struct LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_PaymentPreimageAPIErrorZ. + */ +void CResult_PaymentPreimageAPIErrorZ_free(struct LDKCResult_PaymentPreimageAPIErrorZ _res); + +/** + * Creates a new CResult_PaymentPreimageAPIErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_PaymentPreimageAPIErrorZ CResult_PaymentPreimageAPIErrorZ_clone(const struct LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_CounterpartyForwardingInfoDecodeErrorZ in the success state. + */ +struct LDKCResult_CounterpartyForwardingInfoDecodeErrorZ CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(struct LDKCounterpartyForwardingInfo o); + +/** + * Creates a new CResult_CounterpartyForwardingInfoDecodeErrorZ in the error state. + */ +struct LDKCResult_CounterpartyForwardingInfoDecodeErrorZ CResult_CounterpartyForwardingInfoDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(const struct LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_CounterpartyForwardingInfoDecodeErrorZ. + */ +void CResult_CounterpartyForwardingInfoDecodeErrorZ_free(struct LDKCResult_CounterpartyForwardingInfoDecodeErrorZ _res); + +/** + * Creates a new CResult_CounterpartyForwardingInfoDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_CounterpartyForwardingInfoDecodeErrorZ CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(const struct LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_ChannelCounterpartyDecodeErrorZ in the success state. + */ +struct LDKCResult_ChannelCounterpartyDecodeErrorZ CResult_ChannelCounterpartyDecodeErrorZ_ok(struct LDKChannelCounterparty o); + +/** + * Creates a new CResult_ChannelCounterpartyDecodeErrorZ in the error state. + */ +struct LDKCResult_ChannelCounterpartyDecodeErrorZ CResult_ChannelCounterpartyDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_ChannelCounterpartyDecodeErrorZ_is_ok(const struct LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_ChannelCounterpartyDecodeErrorZ. + */ +void CResult_ChannelCounterpartyDecodeErrorZ_free(struct LDKCResult_ChannelCounterpartyDecodeErrorZ _res); + +/** + * Creates a new CResult_ChannelCounterpartyDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_ChannelCounterpartyDecodeErrorZ CResult_ChannelCounterpartyDecodeErrorZ_clone(const struct LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_ChannelDetailsDecodeErrorZ in the success state. + */ +struct LDKCResult_ChannelDetailsDecodeErrorZ CResult_ChannelDetailsDecodeErrorZ_ok(struct LDKChannelDetails o); + +/** + * Creates a new CResult_ChannelDetailsDecodeErrorZ in the error state. + */ +struct LDKCResult_ChannelDetailsDecodeErrorZ CResult_ChannelDetailsDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_ChannelDetailsDecodeErrorZ_is_ok(const struct LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_ChannelDetailsDecodeErrorZ. + */ +void CResult_ChannelDetailsDecodeErrorZ_free(struct LDKCResult_ChannelDetailsDecodeErrorZ _res); + +/** + * Creates a new CResult_ChannelDetailsDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_ChannelDetailsDecodeErrorZ CResult_ChannelDetailsDecodeErrorZ_clone(const struct LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_PhantomRouteHintsDecodeErrorZ in the success state. + */ +struct LDKCResult_PhantomRouteHintsDecodeErrorZ CResult_PhantomRouteHintsDecodeErrorZ_ok(struct LDKPhantomRouteHints o); + +/** + * Creates a new CResult_PhantomRouteHintsDecodeErrorZ in the error state. + */ +struct LDKCResult_PhantomRouteHintsDecodeErrorZ CResult_PhantomRouteHintsDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_PhantomRouteHintsDecodeErrorZ_is_ok(const struct LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_PhantomRouteHintsDecodeErrorZ. + */ +void CResult_PhantomRouteHintsDecodeErrorZ_free(struct LDKCResult_PhantomRouteHintsDecodeErrorZ _res); + +/** + * Creates a new CResult_PhantomRouteHintsDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_PhantomRouteHintsDecodeErrorZ CResult_PhantomRouteHintsDecodeErrorZ_clone(const struct LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR orig); + /** * Frees the buffer pointed to by `data` if `datalen` is non-0. */ @@ -12282,6 +14390,11 @@ struct LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ CResult_C2Tuple_B */ struct LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(struct LDKDecodeError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(const struct LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ. */ @@ -12297,6 +14410,11 @@ struct LDKCResult_ChannelConfigDecodeErrorZ CResult_ChannelConfigDecodeErrorZ_ok */ struct LDKCResult_ChannelConfigDecodeErrorZ CResult_ChannelConfigDecodeErrorZ_err(struct LDKDecodeError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_ChannelConfigDecodeErrorZ_is_ok(const struct LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_ChannelConfigDecodeErrorZ. */ @@ -12318,6 +14436,11 @@ struct LDKCResult_OutPointDecodeErrorZ CResult_OutPointDecodeErrorZ_ok(struct LD */ struct LDKCResult_OutPointDecodeErrorZ CResult_OutPointDecodeErrorZ_err(struct LDKDecodeError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_OutPointDecodeErrorZ_is_ok(const struct LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_OutPointDecodeErrorZ. */ @@ -12354,6 +14477,11 @@ struct LDKCResult_COption_TypeZDecodeErrorZ CResult_COption_TypeZDecodeErrorZ_ok */ struct LDKCResult_COption_TypeZDecodeErrorZ CResult_COption_TypeZDecodeErrorZ_err(struct LDKDecodeError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_COption_TypeZDecodeErrorZ_is_ok(const struct LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_COption_TypeZDecodeErrorZ. */ @@ -12369,6 +14497,11 @@ struct LDKCResult_PaymentIdPaymentErrorZ CResult_PaymentIdPaymentErrorZ_ok(struc */ struct LDKCResult_PaymentIdPaymentErrorZ CResult_PaymentIdPaymentErrorZ_err(struct LDKPaymentError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_PaymentIdPaymentErrorZ_is_ok(const struct LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_PaymentIdPaymentErrorZ. */ @@ -12390,6 +14523,11 @@ struct LDKCResult_SiPrefixNoneZ CResult_SiPrefixNoneZ_ok(enum LDKSiPrefix o); */ struct LDKCResult_SiPrefixNoneZ CResult_SiPrefixNoneZ_err(void); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_SiPrefixNoneZ_is_ok(const struct LDKCResult_SiPrefixNoneZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_SiPrefixNoneZ. */ @@ -12411,6 +14549,11 @@ struct LDKCResult_InvoiceNoneZ CResult_InvoiceNoneZ_ok(struct LDKInvoice o); */ struct LDKCResult_InvoiceNoneZ CResult_InvoiceNoneZ_err(void); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_InvoiceNoneZ_is_ok(const struct LDKCResult_InvoiceNoneZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_InvoiceNoneZ. */ @@ -12432,6 +14575,11 @@ struct LDKCResult_SignedRawInvoiceNoneZ CResult_SignedRawInvoiceNoneZ_ok(struct */ struct LDKCResult_SignedRawInvoiceNoneZ CResult_SignedRawInvoiceNoneZ_err(void); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_SignedRawInvoiceNoneZ_is_ok(const struct LDKCResult_SignedRawInvoiceNoneZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_SignedRawInvoiceNoneZ. */ @@ -12469,6 +14617,11 @@ struct LDKCResult_PayeePubKeyErrorZ CResult_PayeePubKeyErrorZ_ok(struct LDKPayee */ struct LDKCResult_PayeePubKeyErrorZ CResult_PayeePubKeyErrorZ_err(enum LDKSecp256k1Error e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_PayeePubKeyErrorZ_is_ok(const struct LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_PayeePubKeyErrorZ. */ @@ -12495,6 +14648,11 @@ struct LDKCResult_PositiveTimestampCreationErrorZ CResult_PositiveTimestampCreat */ struct LDKCResult_PositiveTimestampCreationErrorZ CResult_PositiveTimestampCreationErrorZ_err(enum LDKCreationError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_PositiveTimestampCreationErrorZ_is_ok(const struct LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_PositiveTimestampCreationErrorZ. */ @@ -12516,6 +14674,11 @@ struct LDKCResult_NoneSemanticErrorZ CResult_NoneSemanticErrorZ_ok(void); */ struct LDKCResult_NoneSemanticErrorZ CResult_NoneSemanticErrorZ_err(enum LDKSemanticError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_NoneSemanticErrorZ_is_ok(const struct LDKCResult_NoneSemanticErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_NoneSemanticErrorZ. */ @@ -12537,6 +14700,11 @@ struct LDKCResult_InvoiceSemanticErrorZ CResult_InvoiceSemanticErrorZ_ok(struct */ struct LDKCResult_InvoiceSemanticErrorZ CResult_InvoiceSemanticErrorZ_err(enum LDKSemanticError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_InvoiceSemanticErrorZ_is_ok(const struct LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_InvoiceSemanticErrorZ. */ @@ -12558,6 +14726,11 @@ struct LDKCResult_DescriptionCreationErrorZ CResult_DescriptionCreationErrorZ_ok */ struct LDKCResult_DescriptionCreationErrorZ CResult_DescriptionCreationErrorZ_err(enum LDKCreationError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_DescriptionCreationErrorZ_is_ok(const struct LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_DescriptionCreationErrorZ. */ @@ -12569,27 +14742,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); - -/** - * 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. */ @@ -12600,6 +14752,11 @@ struct LDKCResult_PrivateRouteCreationErrorZ CResult_PrivateRouteCreationErrorZ_ */ struct LDKCResult_PrivateRouteCreationErrorZ CResult_PrivateRouteCreationErrorZ_err(enum LDKCreationError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_PrivateRouteCreationErrorZ_is_ok(const struct LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_PrivateRouteCreationErrorZ. */ @@ -12621,6 +14778,11 @@ struct LDKCResult_StringErrorZ CResult_StringErrorZ_ok(struct LDKStr o); */ struct LDKCResult_StringErrorZ CResult_StringErrorZ_err(enum LDKSecp256k1Error e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_StringErrorZ_is_ok(const struct LDKCResult_StringErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_StringErrorZ. */ @@ -12636,6 +14798,11 @@ struct LDKCResult_ChannelMonitorUpdateDecodeErrorZ CResult_ChannelMonitorUpdateD */ struct LDKCResult_ChannelMonitorUpdateDecodeErrorZ CResult_ChannelMonitorUpdateDecodeErrorZ_err(struct LDKDecodeError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(const struct LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_ChannelMonitorUpdateDecodeErrorZ. */ @@ -12648,46 +14815,77 @@ void CResult_ChannelMonitorUpdateDecodeErrorZ_free(struct LDKCResult_ChannelMoni struct LDKCResult_ChannelMonitorUpdateDecodeErrorZ CResult_ChannelMonitorUpdateDecodeErrorZ_clone(const struct LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_HTLCUpdateDecodeErrorZ in the success state. + * Constructs a new COption_MonitorEventZ containing a crate::lightning::chain::channelmonitor::MonitorEvent */ -struct LDKCResult_HTLCUpdateDecodeErrorZ CResult_HTLCUpdateDecodeErrorZ_ok(struct LDKHTLCUpdate o); +struct LDKCOption_MonitorEventZ COption_MonitorEventZ_some(struct LDKMonitorEvent o); /** - * Creates a new CResult_HTLCUpdateDecodeErrorZ in the error state. + * Constructs a new COption_MonitorEventZ containing nothing */ -struct LDKCResult_HTLCUpdateDecodeErrorZ CResult_HTLCUpdateDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCOption_MonitorEventZ COption_MonitorEventZ_none(void); /** - * Frees any resources used by the CResult_HTLCUpdateDecodeErrorZ. + * Frees any resources associated with the crate::lightning::chain::channelmonitor::MonitorEvent, if we are in the Some state */ -void CResult_HTLCUpdateDecodeErrorZ_free(struct LDKCResult_HTLCUpdateDecodeErrorZ _res); +void COption_MonitorEventZ_free(struct LDKCOption_MonitorEventZ _res); /** - * Creates a new CResult_HTLCUpdateDecodeErrorZ which has the same data as `orig` + * Creates a new COption_MonitorEventZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_HTLCUpdateDecodeErrorZ CResult_HTLCUpdateDecodeErrorZ_clone(const struct LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR orig); +struct LDKCOption_MonitorEventZ COption_MonitorEventZ_clone(const struct LDKCOption_MonitorEventZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_COption_MonitorEventZDecodeErrorZ in the success state. + */ +struct LDKCResult_COption_MonitorEventZDecodeErrorZ CResult_COption_MonitorEventZDecodeErrorZ_ok(struct LDKCOption_MonitorEventZ o); + +/** + * Creates a new CResult_COption_MonitorEventZDecodeErrorZ in the error state. + */ +struct LDKCResult_COption_MonitorEventZDecodeErrorZ CResult_COption_MonitorEventZDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_COption_MonitorEventZDecodeErrorZ_is_ok(const struct LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_COption_MonitorEventZDecodeErrorZ. + */ +void CResult_COption_MonitorEventZDecodeErrorZ_free(struct LDKCResult_COption_MonitorEventZDecodeErrorZ _res); + +/** + * Creates a new CResult_COption_MonitorEventZDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_COption_MonitorEventZDecodeErrorZ CResult_COption_MonitorEventZDecodeErrorZ_clone(const struct LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_HTLCUpdateDecodeErrorZ in the success state. + */ +struct LDKCResult_HTLCUpdateDecodeErrorZ CResult_HTLCUpdateDecodeErrorZ_ok(struct LDKHTLCUpdate o); /** - * Creates a new CResult_NoneMonitorUpdateErrorZ in the success state. + * Creates a new CResult_HTLCUpdateDecodeErrorZ in the error state. */ -struct LDKCResult_NoneMonitorUpdateErrorZ CResult_NoneMonitorUpdateErrorZ_ok(void); +struct LDKCResult_HTLCUpdateDecodeErrorZ CResult_HTLCUpdateDecodeErrorZ_err(struct LDKDecodeError e); /** - * Creates a new CResult_NoneMonitorUpdateErrorZ in the error state. + * Checks if the given object is currently in the success state */ -struct LDKCResult_NoneMonitorUpdateErrorZ CResult_NoneMonitorUpdateErrorZ_err(struct LDKMonitorUpdateError e); +bool CResult_HTLCUpdateDecodeErrorZ_is_ok(const struct LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_NoneMonitorUpdateErrorZ. + * Frees any resources used by the CResult_HTLCUpdateDecodeErrorZ. */ -void CResult_NoneMonitorUpdateErrorZ_free(struct LDKCResult_NoneMonitorUpdateErrorZ _res); +void CResult_HTLCUpdateDecodeErrorZ_free(struct LDKCResult_HTLCUpdateDecodeErrorZ _res); /** - * Creates a new CResult_NoneMonitorUpdateErrorZ which has the same data as `orig` + * Creates a new CResult_HTLCUpdateDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_NoneMonitorUpdateErrorZ CResult_NoneMonitorUpdateErrorZ_clone(const struct LDKCResult_NoneMonitorUpdateErrorZ *NONNULL_PTR orig); +struct LDKCResult_HTLCUpdateDecodeErrorZ CResult_HTLCUpdateDecodeErrorZ_clone(const struct LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR orig); /** * Creates a new tuple which has the same data as `orig` @@ -12814,6 +15012,11 @@ struct LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ CResult_C2Tuple_B */ struct LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(struct LDKDecodeError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(const struct LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ. */ @@ -12829,6 +15032,11 @@ struct LDKCResult_NoneLightningErrorZ CResult_NoneLightningErrorZ_ok(void); */ struct LDKCResult_NoneLightningErrorZ CResult_NoneLightningErrorZ_err(struct LDKLightningError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_NoneLightningErrorZ_is_ok(const struct LDKCResult_NoneLightningErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_NoneLightningErrorZ. */ @@ -12863,7 +15071,12 @@ struct LDKCResult_boolLightningErrorZ CResult_boolLightningErrorZ_ok(bool o); /** * Creates a new CResult_boolLightningErrorZ in the error state. */ -struct LDKCResult_boolLightningErrorZ CResult_boolLightningErrorZ_err(struct LDKLightningError e); +struct LDKCResult_boolLightningErrorZ CResult_boolLightningErrorZ_err(struct LDKLightningError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_boolLightningErrorZ_is_ok(const struct LDKCResult_boolLightningErrorZ *NONNULL_PTR o); /** * Frees any resources used by the CResult_boolLightningErrorZ. @@ -12907,6 +15120,27 @@ void CVec_NodeAnnouncementZ_free(struct LDKCVec_NodeAnnouncementZ _res); */ void CVec_PublicKeyZ_free(struct LDKCVec_PublicKeyZ _res); +/** + * Constructs a new COption_NetAddressZ containing a crate::lightning::ln::msgs::NetAddress + */ +struct LDKCOption_NetAddressZ COption_NetAddressZ_some(struct LDKNetAddress o); + +/** + * Constructs a new COption_NetAddressZ containing nothing + */ +struct LDKCOption_NetAddressZ COption_NetAddressZ_none(void); + +/** + * Frees any resources associated with the crate::lightning::ln::msgs::NetAddress, if we are in the Some state + */ +void COption_NetAddressZ_free(struct LDKCOption_NetAddressZ _res); + +/** + * Creates a new COption_NetAddressZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCOption_NetAddressZ COption_NetAddressZ_clone(const struct LDKCOption_NetAddressZ *NONNULL_PTR orig); + /** * Creates a new CResult_CVec_u8ZPeerHandleErrorZ in the success state. */ @@ -12917,6 +15151,11 @@ struct LDKCResult_CVec_u8ZPeerHandleErrorZ CResult_CVec_u8ZPeerHandleErrorZ_ok(s */ struct LDKCResult_CVec_u8ZPeerHandleErrorZ CResult_CVec_u8ZPeerHandleErrorZ_err(struct LDKPeerHandleError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_CVec_u8ZPeerHandleErrorZ_is_ok(const struct LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_CVec_u8ZPeerHandleErrorZ. */ @@ -12938,6 +15177,11 @@ struct LDKCResult_NonePeerHandleErrorZ CResult_NonePeerHandleErrorZ_ok(void); */ struct LDKCResult_NonePeerHandleErrorZ CResult_NonePeerHandleErrorZ_err(struct LDKPeerHandleError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_NonePeerHandleErrorZ_is_ok(const struct LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_NonePeerHandleErrorZ. */ @@ -12959,6 +15203,11 @@ struct LDKCResult_boolPeerHandleErrorZ CResult_boolPeerHandleErrorZ_ok(bool o); */ struct LDKCResult_boolPeerHandleErrorZ CResult_boolPeerHandleErrorZ_err(struct LDKPeerHandleError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_boolPeerHandleErrorZ_is_ok(const struct LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_boolPeerHandleErrorZ. */ @@ -12980,6 +15229,11 @@ struct LDKCResult_NodeIdDecodeErrorZ CResult_NodeIdDecodeErrorZ_ok(struct LDKNod */ struct LDKCResult_NodeIdDecodeErrorZ CResult_NodeIdDecodeErrorZ_err(struct LDKDecodeError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_NodeIdDecodeErrorZ_is_ok(const struct LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_NodeIdDecodeErrorZ. */ @@ -12991,6 +15245,32 @@ void CResult_NodeIdDecodeErrorZ_free(struct LDKCResult_NodeIdDecodeErrorZ _res); */ struct LDKCResult_NodeIdDecodeErrorZ CResult_NodeIdDecodeErrorZ_clone(const struct LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR orig); +/** + * Creates a new CResult_COption_NetworkUpdateZDecodeErrorZ in the success state. + */ +struct LDKCResult_COption_NetworkUpdateZDecodeErrorZ CResult_COption_NetworkUpdateZDecodeErrorZ_ok(struct LDKCOption_NetworkUpdateZ o); + +/** + * Creates a new CResult_COption_NetworkUpdateZDecodeErrorZ in the error state. + */ +struct LDKCResult_COption_NetworkUpdateZDecodeErrorZ CResult_COption_NetworkUpdateZDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(const struct LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_COption_NetworkUpdateZDecodeErrorZ. + */ +void CResult_COption_NetworkUpdateZDecodeErrorZ_free(struct LDKCResult_COption_NetworkUpdateZDecodeErrorZ _res); + +/** + * Creates a new CResult_COption_NetworkUpdateZDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_COption_NetworkUpdateZDecodeErrorZ CResult_COption_NetworkUpdateZDecodeErrorZ_clone(const struct LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR orig); + /** * Constructs a new COption_AccessZ containing a crate::lightning::chain::Access */ @@ -13007,25 +15287,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_ChannelUpdateInfoDecodeErrorZ CResult_ChannelUpdateInfoDecodeErrorZ_ok(struct LDKChannelUpdateInfo o); + +/** + * Creates a new CResult_ChannelUpdateInfoDecodeErrorZ in the error state. */ -struct LDKCResult_DirectionalChannelInfoDecodeErrorZ CResult_DirectionalChannelInfoDecodeErrorZ_ok(struct LDKDirectionalChannelInfo o); +struct LDKCResult_ChannelUpdateInfoDecodeErrorZ CResult_ChannelUpdateInfoDecodeErrorZ_err(struct LDKDecodeError e); /** - * Creates a new CResult_DirectionalChannelInfoDecodeErrorZ in the error state. + * Checks if the given object is currently in the success state */ -struct LDKCResult_DirectionalChannelInfoDecodeErrorZ CResult_DirectionalChannelInfoDecodeErrorZ_err(struct LDKDecodeError e); +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. @@ -13037,6 +15322,11 @@ struct LDKCResult_ChannelInfoDecodeErrorZ CResult_ChannelInfoDecodeErrorZ_ok(str */ struct LDKCResult_ChannelInfoDecodeErrorZ CResult_ChannelInfoDecodeErrorZ_err(struct LDKDecodeError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_ChannelInfoDecodeErrorZ_is_ok(const struct LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_ChannelInfoDecodeErrorZ. */ @@ -13058,6 +15348,11 @@ struct LDKCResult_RoutingFeesDecodeErrorZ CResult_RoutingFeesDecodeErrorZ_ok(str */ struct LDKCResult_RoutingFeesDecodeErrorZ CResult_RoutingFeesDecodeErrorZ_err(struct LDKDecodeError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_RoutingFeesDecodeErrorZ_is_ok(const struct LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_RoutingFeesDecodeErrorZ. */ @@ -13079,6 +15374,11 @@ struct LDKCResult_NodeAnnouncementInfoDecodeErrorZ CResult_NodeAnnouncementInfoD */ struct LDKCResult_NodeAnnouncementInfoDecodeErrorZ CResult_NodeAnnouncementInfoDecodeErrorZ_err(struct LDKDecodeError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(const struct LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_NodeAnnouncementInfoDecodeErrorZ. */ @@ -13105,6 +15405,11 @@ struct LDKCResult_NodeInfoDecodeErrorZ CResult_NodeInfoDecodeErrorZ_ok(struct LD */ struct LDKCResult_NodeInfoDecodeErrorZ CResult_NodeInfoDecodeErrorZ_err(struct LDKDecodeError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_NodeInfoDecodeErrorZ_is_ok(const struct LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_NodeInfoDecodeErrorZ. */ @@ -13126,6 +15431,11 @@ struct LDKCResult_NetworkGraphDecodeErrorZ CResult_NetworkGraphDecodeErrorZ_ok(s */ struct LDKCResult_NetworkGraphDecodeErrorZ CResult_NetworkGraphDecodeErrorZ_err(struct LDKDecodeError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_NetworkGraphDecodeErrorZ_is_ok(const struct LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_NetworkGraphDecodeErrorZ. */ @@ -13168,6 +15478,11 @@ struct LDKCResult_NetAddressDecodeErrorZ CResult_NetAddressDecodeErrorZ_ok(struc */ struct LDKCResult_NetAddressDecodeErrorZ CResult_NetAddressDecodeErrorZ_err(struct LDKDecodeError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_NetAddressDecodeErrorZ_is_ok(const struct LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_NetAddressDecodeErrorZ. */ @@ -13209,6 +15524,11 @@ struct LDKCResult_AcceptChannelDecodeErrorZ CResult_AcceptChannelDecodeErrorZ_ok */ struct LDKCResult_AcceptChannelDecodeErrorZ CResult_AcceptChannelDecodeErrorZ_err(struct LDKDecodeError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_AcceptChannelDecodeErrorZ_is_ok(const struct LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_AcceptChannelDecodeErrorZ. */ @@ -13230,6 +15550,11 @@ struct LDKCResult_AnnouncementSignaturesDecodeErrorZ CResult_AnnouncementSignatu */ struct LDKCResult_AnnouncementSignaturesDecodeErrorZ CResult_AnnouncementSignaturesDecodeErrorZ_err(struct LDKDecodeError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(const struct LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_AnnouncementSignaturesDecodeErrorZ. */ @@ -13251,6 +15576,11 @@ struct LDKCResult_ChannelReestablishDecodeErrorZ CResult_ChannelReestablishDecod */ struct LDKCResult_ChannelReestablishDecodeErrorZ CResult_ChannelReestablishDecodeErrorZ_err(struct LDKDecodeError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_ChannelReestablishDecodeErrorZ_is_ok(const struct LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_ChannelReestablishDecodeErrorZ. */ @@ -13272,6 +15602,11 @@ struct LDKCResult_ClosingSignedDecodeErrorZ CResult_ClosingSignedDecodeErrorZ_ok */ struct LDKCResult_ClosingSignedDecodeErrorZ CResult_ClosingSignedDecodeErrorZ_err(struct LDKDecodeError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_ClosingSignedDecodeErrorZ_is_ok(const struct LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_ClosingSignedDecodeErrorZ. */ @@ -13293,6 +15628,11 @@ struct LDKCResult_ClosingSignedFeeRangeDecodeErrorZ CResult_ClosingSignedFeeRang */ struct LDKCResult_ClosingSignedFeeRangeDecodeErrorZ CResult_ClosingSignedFeeRangeDecodeErrorZ_err(struct LDKDecodeError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(const struct LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_ClosingSignedFeeRangeDecodeErrorZ. */ @@ -13314,6 +15654,11 @@ struct LDKCResult_CommitmentSignedDecodeErrorZ CResult_CommitmentSignedDecodeErr */ struct LDKCResult_CommitmentSignedDecodeErrorZ CResult_CommitmentSignedDecodeErrorZ_err(struct LDKDecodeError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_CommitmentSignedDecodeErrorZ_is_ok(const struct LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_CommitmentSignedDecodeErrorZ. */ @@ -13335,6 +15680,11 @@ struct LDKCResult_FundingCreatedDecodeErrorZ CResult_FundingCreatedDecodeErrorZ_ */ struct LDKCResult_FundingCreatedDecodeErrorZ CResult_FundingCreatedDecodeErrorZ_err(struct LDKDecodeError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_FundingCreatedDecodeErrorZ_is_ok(const struct LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_FundingCreatedDecodeErrorZ. */ @@ -13356,6 +15706,11 @@ struct LDKCResult_FundingSignedDecodeErrorZ CResult_FundingSignedDecodeErrorZ_ok */ struct LDKCResult_FundingSignedDecodeErrorZ CResult_FundingSignedDecodeErrorZ_err(struct LDKDecodeError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_FundingSignedDecodeErrorZ_is_ok(const struct LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_FundingSignedDecodeErrorZ. */ @@ -13377,6 +15732,11 @@ struct LDKCResult_FundingLockedDecodeErrorZ CResult_FundingLockedDecodeErrorZ_ok */ struct LDKCResult_FundingLockedDecodeErrorZ CResult_FundingLockedDecodeErrorZ_err(struct LDKDecodeError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_FundingLockedDecodeErrorZ_is_ok(const struct LDKCResult_FundingLockedDecodeErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_FundingLockedDecodeErrorZ. */ @@ -13398,6 +15758,11 @@ struct LDKCResult_InitDecodeErrorZ CResult_InitDecodeErrorZ_ok(struct LDKInit o) */ struct LDKCResult_InitDecodeErrorZ CResult_InitDecodeErrorZ_err(struct LDKDecodeError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_InitDecodeErrorZ_is_ok(const struct LDKCResult_InitDecodeErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_InitDecodeErrorZ. */ @@ -13419,6 +15784,11 @@ struct LDKCResult_OpenChannelDecodeErrorZ CResult_OpenChannelDecodeErrorZ_ok(str */ struct LDKCResult_OpenChannelDecodeErrorZ CResult_OpenChannelDecodeErrorZ_err(struct LDKDecodeError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_OpenChannelDecodeErrorZ_is_ok(const struct LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_OpenChannelDecodeErrorZ. */ @@ -13440,6 +15810,11 @@ struct LDKCResult_RevokeAndACKDecodeErrorZ CResult_RevokeAndACKDecodeErrorZ_ok(s */ struct LDKCResult_RevokeAndACKDecodeErrorZ CResult_RevokeAndACKDecodeErrorZ_err(struct LDKDecodeError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_RevokeAndACKDecodeErrorZ_is_ok(const struct LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_RevokeAndACKDecodeErrorZ. */ @@ -13461,6 +15836,11 @@ struct LDKCResult_ShutdownDecodeErrorZ CResult_ShutdownDecodeErrorZ_ok(struct LD */ struct LDKCResult_ShutdownDecodeErrorZ CResult_ShutdownDecodeErrorZ_err(struct LDKDecodeError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_ShutdownDecodeErrorZ_is_ok(const struct LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_ShutdownDecodeErrorZ. */ @@ -13482,6 +15862,11 @@ struct LDKCResult_UpdateFailHTLCDecodeErrorZ CResult_UpdateFailHTLCDecodeErrorZ_ */ struct LDKCResult_UpdateFailHTLCDecodeErrorZ CResult_UpdateFailHTLCDecodeErrorZ_err(struct LDKDecodeError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_UpdateFailHTLCDecodeErrorZ_is_ok(const struct LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_UpdateFailHTLCDecodeErrorZ. */ @@ -13503,6 +15888,11 @@ struct LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ CResult_UpdateFailMalforme */ struct LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(struct LDKDecodeError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(const struct LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_UpdateFailMalformedHTLCDecodeErrorZ. */ @@ -13524,6 +15914,11 @@ struct LDKCResult_UpdateFeeDecodeErrorZ CResult_UpdateFeeDecodeErrorZ_ok(struct */ struct LDKCResult_UpdateFeeDecodeErrorZ CResult_UpdateFeeDecodeErrorZ_err(struct LDKDecodeError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_UpdateFeeDecodeErrorZ_is_ok(const struct LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_UpdateFeeDecodeErrorZ. */ @@ -13545,6 +15940,11 @@ struct LDKCResult_UpdateFulfillHTLCDecodeErrorZ CResult_UpdateFulfillHTLCDecodeE */ struct LDKCResult_UpdateFulfillHTLCDecodeErrorZ CResult_UpdateFulfillHTLCDecodeErrorZ_err(struct LDKDecodeError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(const struct LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_UpdateFulfillHTLCDecodeErrorZ. */ @@ -13566,6 +15966,11 @@ struct LDKCResult_UpdateAddHTLCDecodeErrorZ CResult_UpdateAddHTLCDecodeErrorZ_ok */ struct LDKCResult_UpdateAddHTLCDecodeErrorZ CResult_UpdateAddHTLCDecodeErrorZ_err(struct LDKDecodeError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_UpdateAddHTLCDecodeErrorZ_is_ok(const struct LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_UpdateAddHTLCDecodeErrorZ. */ @@ -13587,6 +15992,11 @@ struct LDKCResult_PingDecodeErrorZ CResult_PingDecodeErrorZ_ok(struct LDKPing o) */ struct LDKCResult_PingDecodeErrorZ CResult_PingDecodeErrorZ_err(struct LDKDecodeError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_PingDecodeErrorZ_is_ok(const struct LDKCResult_PingDecodeErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_PingDecodeErrorZ. */ @@ -13608,6 +16018,11 @@ struct LDKCResult_PongDecodeErrorZ CResult_PongDecodeErrorZ_ok(struct LDKPong o) */ struct LDKCResult_PongDecodeErrorZ CResult_PongDecodeErrorZ_err(struct LDKDecodeError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_PongDecodeErrorZ_is_ok(const struct LDKCResult_PongDecodeErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_PongDecodeErrorZ. */ @@ -13629,6 +16044,11 @@ struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ CResult_UnsignedChanne */ struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(struct LDKDecodeError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(const struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_UnsignedChannelAnnouncementDecodeErrorZ. */ @@ -13650,6 +16070,11 @@ struct LDKCResult_ChannelAnnouncementDecodeErrorZ CResult_ChannelAnnouncementDec */ struct LDKCResult_ChannelAnnouncementDecodeErrorZ CResult_ChannelAnnouncementDecodeErrorZ_err(struct LDKDecodeError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_ChannelAnnouncementDecodeErrorZ_is_ok(const struct LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_ChannelAnnouncementDecodeErrorZ. */ @@ -13671,6 +16096,11 @@ struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ CResult_UnsignedChannelUpdat */ struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ CResult_UnsignedChannelUpdateDecodeErrorZ_err(struct LDKDecodeError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(const struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_UnsignedChannelUpdateDecodeErrorZ. */ @@ -13692,6 +16122,11 @@ struct LDKCResult_ChannelUpdateDecodeErrorZ CResult_ChannelUpdateDecodeErrorZ_ok */ struct LDKCResult_ChannelUpdateDecodeErrorZ CResult_ChannelUpdateDecodeErrorZ_err(struct LDKDecodeError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_ChannelUpdateDecodeErrorZ_is_ok(const struct LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_ChannelUpdateDecodeErrorZ. */ @@ -13713,6 +16148,11 @@ struct LDKCResult_ErrorMessageDecodeErrorZ CResult_ErrorMessageDecodeErrorZ_ok(s */ struct LDKCResult_ErrorMessageDecodeErrorZ CResult_ErrorMessageDecodeErrorZ_err(struct LDKDecodeError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_ErrorMessageDecodeErrorZ_is_ok(const struct LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_ErrorMessageDecodeErrorZ. */ @@ -13724,6 +16164,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. */ @@ -13734,6 +16200,11 @@ struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ CResult_UnsignedNodeAnnou */ struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(struct LDKDecodeError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(const struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_UnsignedNodeAnnouncementDecodeErrorZ. */ @@ -13755,6 +16226,11 @@ struct LDKCResult_NodeAnnouncementDecodeErrorZ CResult_NodeAnnouncementDecodeErr */ struct LDKCResult_NodeAnnouncementDecodeErrorZ CResult_NodeAnnouncementDecodeErrorZ_err(struct LDKDecodeError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_NodeAnnouncementDecodeErrorZ_is_ok(const struct LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_NodeAnnouncementDecodeErrorZ. */ @@ -13776,6 +16252,11 @@ struct LDKCResult_QueryShortChannelIdsDecodeErrorZ CResult_QueryShortChannelIdsD */ struct LDKCResult_QueryShortChannelIdsDecodeErrorZ CResult_QueryShortChannelIdsDecodeErrorZ_err(struct LDKDecodeError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(const struct LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_QueryShortChannelIdsDecodeErrorZ. */ @@ -13797,6 +16278,11 @@ struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ CResult_ReplyShortChannelI */ struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(struct LDKDecodeError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(const struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_ReplyShortChannelIdsEndDecodeErrorZ. */ @@ -13818,6 +16304,11 @@ struct LDKCResult_QueryChannelRangeDecodeErrorZ CResult_QueryChannelRangeDecodeE */ struct LDKCResult_QueryChannelRangeDecodeErrorZ CResult_QueryChannelRangeDecodeErrorZ_err(struct LDKDecodeError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_QueryChannelRangeDecodeErrorZ_is_ok(const struct LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_QueryChannelRangeDecodeErrorZ. */ @@ -13839,6 +16330,11 @@ struct LDKCResult_ReplyChannelRangeDecodeErrorZ CResult_ReplyChannelRangeDecodeE */ struct LDKCResult_ReplyChannelRangeDecodeErrorZ CResult_ReplyChannelRangeDecodeErrorZ_err(struct LDKDecodeError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_ReplyChannelRangeDecodeErrorZ_is_ok(const struct LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_ReplyChannelRangeDecodeErrorZ. */ @@ -13860,6 +16356,11 @@ struct LDKCResult_GossipTimestampFilterDecodeErrorZ CResult_GossipTimestampFilte */ struct LDKCResult_GossipTimestampFilterDecodeErrorZ CResult_GossipTimestampFilterDecodeErrorZ_err(struct LDKDecodeError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_GossipTimestampFilterDecodeErrorZ_is_ok(const struct LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_GossipTimestampFilterDecodeErrorZ. */ @@ -13871,6 +16372,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. */ @@ -13881,6 +16387,11 @@ struct LDKCResult_InvoiceSignOrCreationErrorZ CResult_InvoiceSignOrCreationError */ struct LDKCResult_InvoiceSignOrCreationErrorZ CResult_InvoiceSignOrCreationErrorZ_err(struct LDKSignOrCreationError e); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_InvoiceSignOrCreationErrorZ_is_ok(const struct LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_InvoiceSignOrCreationErrorZ. */ @@ -13917,6 +16428,11 @@ struct LDKCResult_LockedChannelMonitorNoneZ CResult_LockedChannelMonitorNoneZ_ok */ struct LDKCResult_LockedChannelMonitorNoneZ CResult_LockedChannelMonitorNoneZ_err(void); +/** + * Checks if the given object is currently in the success state + */ +bool CResult_LockedChannelMonitorNoneZ_is_ok(const struct LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR o); + /** * Frees any resources used by the CResult_LockedChannelMonitorNoneZ. */ @@ -13940,7 +16456,7 @@ struct LDKPaymentPurpose PaymentPurpose_clone(const struct LDKPaymentPurpose *NO /** * Utility method to constructs a new InvoicePayment-variant PaymentPurpose */ -struct LDKPaymentPurpose PaymentPurpose_invoice_payment(struct LDKThirtyTwoBytes payment_preimage, struct LDKThirtyTwoBytes payment_secret, uint64_t user_payment_id); +struct LDKPaymentPurpose PaymentPurpose_invoice_payment(struct LDKThirtyTwoBytes payment_preimage, struct LDKThirtyTwoBytes payment_secret); /** * Utility method to constructs a new SpontaneousPayment-variant PaymentPurpose @@ -13977,6 +16493,11 @@ struct LDKClosureReason ClosureReason_cooperative_closure(void); */ struct LDKClosureReason ClosureReason_commitment_tx_confirmed(void); +/** + * Utility method to constructs a new FundingTimedOut-variant ClosureReason + */ +struct LDKClosureReason ClosureReason_funding_timed_out(void); + /** * Utility method to constructs a new ProcessingError-variant ClosureReason */ @@ -13997,6 +16518,11 @@ struct LDKClosureReason ClosureReason_outdated_channel_manager(void); */ struct LDKCVec_u8Z ClosureReason_write(const struct LDKClosureReason *NONNULL_PTR obj); +/** + * Read a ClosureReason from a byte array, created by ClosureReason_write + */ +struct LDKCResult_COption_ClosureReasonZDecodeErrorZ ClosureReason_read(struct LDKu8slice ser); + /** * Frees any resources used by the Event */ @@ -14027,6 +16553,11 @@ struct LDKEvent Event_payment_sent(struct LDKThirtyTwoBytes payment_id, struct L */ struct LDKEvent Event_payment_path_failed(struct LDKThirtyTwoBytes payment_id, struct LDKThirtyTwoBytes payment_hash, bool rejected_by_dest, struct LDKCOption_NetworkUpdateZ network_update, bool all_paths_failed, struct LDKCVec_RouteHopZ path, struct LDKCOption_u64Z short_channel_id, struct LDKRouteParameters retry); +/** + * Utility method to constructs a new PaymentFailed-variant Event + */ +struct LDKEvent Event_payment_failed(struct LDKThirtyTwoBytes payment_id, struct LDKThirtyTwoBytes payment_hash); + /** * Utility method to constructs a new PendingHTLCsForwardable-variant Event */ @@ -14052,11 +16583,26 @@ struct LDKEvent Event_channel_closed(struct LDKThirtyTwoBytes channel_id, uint64 */ struct LDKEvent Event_discard_funding(struct LDKThirtyTwoBytes channel_id, struct LDKTransaction transaction); +/** + * Utility method to constructs a new PaymentPathSuccessful-variant Event + */ +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, struct LDKChannelTypeFeatures channel_type); + /** * Serialize the Event object into a byte array which can be read by Event_read */ struct LDKCVec_u8Z Event_write(const struct LDKEvent *NONNULL_PTR obj); +/** + * Read a Event from a byte array, created by Event_write + */ +struct LDKCResult_COption_EventZDecodeErrorZ Event_read(struct LDKu8slice ser); + /** * Frees any resources used by the MessageSendEvent */ @@ -14162,6 +16708,11 @@ struct LDKMessageSendEvent MessageSendEvent_send_short_ids_query(struct LDKPubli */ struct LDKMessageSendEvent MessageSendEvent_send_reply_channel_range(struct LDKPublicKey node_id, struct LDKReplyChannelRange msg); +/** + * Utility method to constructs a new SendGossipTimestampFilter-variant MessageSendEvent + */ +struct LDKMessageSendEvent MessageSendEvent_send_gossip_timestamp_filter(struct LDKPublicKey node_id, struct LDKGossipTimestampFilter msg); + /** * Calls the free function if one is set */ @@ -14235,11 +16786,21 @@ 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 */ enum LDKLevel Level_clone(const enum LDKLevel *NONNULL_PTR orig); +/** + * Utility method to constructs a new Gossip-variant Level + */ +enum LDKLevel Level_gossip(void); + /** * Utility method to constructs a new Trace-variant Level */ @@ -14263,23 +16824,83 @@ enum LDKLevel Level_warn(void); /** * Utility method to constructs a new Error-variant Level */ -enum LDKLevel Level_error(void); +enum LDKLevel Level_error(void); + +/** + * Checks if two Levels contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + */ +bool Level_eq(const enum LDKLevel *NONNULL_PTR a, const enum LDKLevel *NONNULL_PTR b); + +/** + * Checks if two Levels contain equal inner contents. + */ +uint64_t Level_hash(const enum LDKLevel *NONNULL_PTR o); + +/** + * Returns the most verbose logging level. + */ +MUST_USE_RES enum LDKLevel Level_max(void); + +/** + * Frees any resources used by the Record, if is_owned is set and inner is non-NULL. + */ +void Record_free(struct LDKRecord this_obj); + +/** + * The verbosity level of the message. + */ +enum LDKLevel Record_get_level(const struct LDKRecord *NONNULL_PTR this_ptr); + +/** + * The verbosity level of the message. + */ +void Record_set_level(struct LDKRecord *NONNULL_PTR this_ptr, enum LDKLevel val); + +/** + * The message body. + */ +struct LDKStr Record_get_args(const struct LDKRecord *NONNULL_PTR this_ptr); + +/** + * The message body. + */ +void Record_set_args(struct LDKRecord *NONNULL_PTR this_ptr, struct LDKStr val); + +/** + * The module path of the message. + */ +struct LDKStr Record_get_module_path(const struct LDKRecord *NONNULL_PTR this_ptr); + +/** + * The module path of the message. + */ +void Record_set_module_path(struct LDKRecord *NONNULL_PTR this_ptr, struct LDKStr val); + +/** + * The source file containing the message. + */ +struct LDKStr Record_get_file(const struct LDKRecord *NONNULL_PTR this_ptr); + +/** + * The source file containing the message. + */ +void Record_set_file(struct LDKRecord *NONNULL_PTR this_ptr, struct LDKStr val); /** - * Checks if two Levels contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * The line containing the message. */ -bool Level_eq(const enum LDKLevel *NONNULL_PTR a, const enum LDKLevel *NONNULL_PTR b); +uint32_t Record_get_line(const struct LDKRecord *NONNULL_PTR this_ptr); /** - * Checks if two Levels contain equal inner contents. + * The line containing the message. */ -uint64_t Level_hash(const enum LDKLevel *NONNULL_PTR o); +void Record_set_line(struct LDKRecord *NONNULL_PTR this_ptr, uint32_t val); /** - * Returns the most verbose logging level. + * Creates a copy of the Record */ -MUST_USE_RES enum LDKLevel Level_max(void); +struct LDKRecord Record_clone(const struct LDKRecord *NONNULL_PTR orig); /** * Calls the free function if one is set @@ -14369,10 +16990,60 @@ uint64_t ChannelHandshakeConfig_get_our_htlc_minimum_msat(const struct LDKChanne */ void ChannelHandshakeConfig_set_our_htlc_minimum_msat(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, uint64_t val); +/** + * If set, we attempt to negotiate the `scid_privacy` (referred to as `scid_alias` in the + * BOLTs) option for outbound private channels. This provides better privacy by not including + * our real on-chain channel UTXO in each invoice and requiring that our counterparty only + * relay HTLCs to us using the channel's SCID alias. + * + * If this option is set, channels may be created that will not be readable by LDK versions + * prior to 0.0.106, causing [`ChannelManager`]'s read method to return a + * [`DecodeError:InvalidValue`]. + * + * Note that setting this to true does *not* prevent us from opening channels with + * counterparties that do not support the `scid_alias` option; we will simply fall back to a + * private channel without that option. + * + * Ignored if the channel is negotiated to be announced, see + * [`ChannelConfig::announced_channel`] and + * [`ChannelHandshakeLimits::force_announced_channel_preference`] for more. + * + * Default value: false. This value is likely to change to true in the future. + * + * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager + * [`DecodeError:InvalidValue`]: crate::ln::msgs::DecodeError::InvalidValue + */ +bool ChannelHandshakeConfig_get_negotiate_scid_privacy(const struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr); + +/** + * If set, we attempt to negotiate the `scid_privacy` (referred to as `scid_alias` in the + * BOLTs) option for outbound private channels. This provides better privacy by not including + * our real on-chain channel UTXO in each invoice and requiring that our counterparty only + * relay HTLCs to us using the channel's SCID alias. + * + * If this option is set, channels may be created that will not be readable by LDK versions + * prior to 0.0.106, causing [`ChannelManager`]'s read method to return a + * [`DecodeError:InvalidValue`]. + * + * Note that setting this to true does *not* prevent us from opening channels with + * counterparties that do not support the `scid_alias` option; we will simply fall back to a + * private channel without that option. + * + * Ignored if the channel is negotiated to be announced, see + * [`ChannelConfig::announced_channel`] and + * [`ChannelHandshakeLimits::force_announced_channel_preference`] for more. + * + * Default value: false. This value is likely to change to true in the future. + * + * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager + * [`DecodeError:InvalidValue`]: crate::ln::msgs::DecodeError::InvalidValue + */ +void ChannelHandshakeConfig_set_negotiate_scid_privacy(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, bool val); + /** * Constructs a new ChannelHandshakeConfig given each field */ -MUST_USE_RES struct LDKChannelHandshakeConfig ChannelHandshakeConfig_new(uint32_t minimum_depth_arg, uint16_t our_to_self_delay_arg, uint64_t our_htlc_minimum_msat_arg); +MUST_USE_RES struct LDKChannelHandshakeConfig ChannelHandshakeConfig_new(uint32_t minimum_depth_arg, uint16_t our_to_self_delay_arg, uint64_t our_htlc_minimum_msat_arg, bool negotiate_scid_privacy_arg); /** * Creates a copy of the ChannelHandshakeConfig @@ -14905,10 +17576,56 @@ bool UserConfig_get_accept_forwards_to_priv_channels(const struct LDKUserConfig */ void UserConfig_set_accept_forwards_to_priv_channels(struct LDKUserConfig *NONNULL_PTR this_ptr, bool val); +/** + * If this is set to false, we do not accept inbound requests to open a new channel. + * Default value: true. + */ +bool UserConfig_get_accept_inbound_channels(const struct LDKUserConfig *NONNULL_PTR this_ptr); + +/** + * If this is set to false, we do not accept inbound requests to open a new channel. + * Default value: true. + */ +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); +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 @@ -15265,25 +17982,6 @@ struct LDKCVec_u8Z ChannelMonitorUpdate_write(const struct LDKChannelMonitorUpda */ struct LDKCResult_ChannelMonitorUpdateDecodeErrorZ ChannelMonitorUpdate_read(struct LDKu8slice ser); -/** - * Frees any resources used by the MonitorUpdateError, if is_owned is set and inner is non-NULL. - */ -void MonitorUpdateError_free(struct LDKMonitorUpdateError this_obj); - -struct LDKStr MonitorUpdateError_get_a(const struct LDKMonitorUpdateError *NONNULL_PTR this_ptr); - -void MonitorUpdateError_set_a(struct LDKMonitorUpdateError *NONNULL_PTR this_ptr, struct LDKStr val); - -/** - * Constructs a new MonitorUpdateError given each field - */ -MUST_USE_RES struct LDKMonitorUpdateError MonitorUpdateError_new(struct LDKStr a_arg); - -/** - * Creates a copy of the MonitorUpdateError - */ -struct LDKMonitorUpdateError MonitorUpdateError_clone(const struct LDKMonitorUpdateError *NONNULL_PTR orig); - /** * Frees any resources used by the MonitorEvent */ @@ -15319,6 +18017,11 @@ struct LDKMonitorEvent MonitorEvent_update_failed(struct LDKOutPoint a); */ struct LDKCVec_u8Z MonitorEvent_write(const struct LDKMonitorEvent *NONNULL_PTR obj); +/** + * Read a MonitorEvent from a byte array, created by MonitorEvent_write + */ +struct LDKCResult_COption_MonitorEventZDecodeErrorZ MonitorEvent_read(struct LDKu8slice ser); + /** * Frees any resources used by the HTLCUpdate, if is_owned is set and inner is non-NULL. */ @@ -15391,7 +18094,7 @@ struct LDKCVec_u8Z ChannelMonitor_write(const struct LDKChannelMonitor *NONNULL_ * * panics if the given update is not the next update by update_id. */ -MUST_USE_RES struct LDKCResult_NoneMonitorUpdateErrorZ ChannelMonitor_update_monitor(const struct LDKChannelMonitor *NONNULL_PTR this_arg, const struct LDKChannelMonitorUpdate *NONNULL_PTR updates, const struct LDKBroadcasterInterface *NONNULL_PTR broadcaster, const struct LDKFeeEstimator *NONNULL_PTR fee_estimator, const struct LDKLogger *NONNULL_PTR logger); +MUST_USE_RES struct LDKCResult_NoneNoneZ ChannelMonitor_update_monitor(const struct LDKChannelMonitor *NONNULL_PTR this_arg, const struct LDKChannelMonitorUpdate *NONNULL_PTR updates, const struct LDKBroadcasterInterface *NONNULL_PTR broadcaster, const struct LDKFeeEstimator *NONNULL_PTR fee_estimator, const struct LDKLogger *NONNULL_PTR logger); /** * Gets the update_id from the latest ChannelMonitorUpdate which was applied to this @@ -15807,6 +18510,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 */ @@ -15885,7 +18603,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. @@ -15929,12 +18647,19 @@ MUST_USE_RES struct LDKOutPoint InMemorySigner_funding_outpoint(const struct LDK */ MUST_USE_RES struct LDKChannelTransactionParameters InMemorySigner_get_channel_parameters(const struct LDKInMemorySigner *NONNULL_PTR this_arg); +/** + * Whether anchors should be used. + * Will panic if ready_channel wasn't called. + */ +MUST_USE_RES bool InMemorySigner_opt_anchors(const struct LDKInMemorySigner *NONNULL_PTR this_arg); + /** * Sign the single input of spend_tx at index `input_idx` which spends the output * described by descriptor, returning the witness stack for the input. * * Returns an 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); @@ -15943,8 +18668,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); @@ -15968,7 +18694,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. @@ -16012,8 +18738,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. * @@ -16028,6 +18755,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. */ @@ -16251,18 +19013,74 @@ struct LDKOutPoint ChannelDetails_get_funding_txo(const struct LDKChannelDetails */ void ChannelDetails_set_funding_txo(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKOutPoint val); +/** + * The features which this channel operates with. See individual features for more info. + * + * `None` until negotiation completes and the channel type is finalized. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +struct LDKChannelTypeFeatures ChannelDetails_get_channel_type(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + +/** + * The features which this channel operates with. See individual features for more info. + * + * `None` until negotiation completes and the channel type is finalized. + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +void ChannelDetails_set_channel_type(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKChannelTypeFeatures val); + /** * The position of the funding transaction in the chain. None if the funding transaction has * not yet been confirmed and the channel fully opened. + * + * Note that if [`inbound_scid_alias`] is set, it must be used for invoices and inbound + * payments instead of this. See [`get_inbound_payment_scid`]. + * + * [`inbound_scid_alias`]: Self::inbound_scid_alias + * [`get_inbound_payment_scid`]: Self::get_inbound_payment_scid */ struct LDKCOption_u64Z ChannelDetails_get_short_channel_id(const struct LDKChannelDetails *NONNULL_PTR this_ptr); /** * The position of the funding transaction in the chain. None if the funding transaction has * not yet been confirmed and the channel fully opened. + * + * Note that if [`inbound_scid_alias`] is set, it must be used for invoices and inbound + * payments instead of this. See [`get_inbound_payment_scid`]. + * + * [`inbound_scid_alias`]: Self::inbound_scid_alias + * [`get_inbound_payment_scid`]: Self::get_inbound_payment_scid */ void ChannelDetails_set_short_channel_id(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); +/** + * An optional [`short_channel_id`] alias for this channel, randomly generated by our + * counterparty and usable in place of [`short_channel_id`] in invoice route hints. Our + * counterparty will recognize the alias provided here in place of the [`short_channel_id`] + * when they see a payment to be routed to us. + * + * Our counterparty may choose to rotate this value at any time, though will always recognize + * previous values for inbound payment forwarding. + * + * [`short_channel_id`]: Self::short_channel_id + */ +struct LDKCOption_u64Z ChannelDetails_get_inbound_scid_alias(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + +/** + * An optional [`short_channel_id`] alias for this channel, randomly generated by our + * counterparty and usable in place of [`short_channel_id`] in invoice route hints. Our + * counterparty will recognize the alias provided here in place of the [`short_channel_id`] + * when they see a payment to be routed to us. + * + * Our counterparty may choose to rotate this value at any time, though will always recognize + * previous values for inbound payment forwarding. + * + * [`short_channel_id`]: Self::short_channel_id + */ +void ChannelDetails_set_inbound_scid_alias(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); + /** * The value, in satoshis, of this channel as appears in the funding output */ @@ -16309,12 +19127,42 @@ uint64_t ChannelDetails_get_user_channel_id(const struct LDKChannelDetails *NONN */ void ChannelDetails_set_user_channel_id(struct LDKChannelDetails *NONNULL_PTR this_ptr, uint64_t val); +/** + * Our total balance. This is the amount we would get if we close the channel. + * This value is not exact. Due to various in-flight changes and feerate changes, exactly this + * amount is not likely to be recoverable on close. + * + * This does not include any pending HTLCs which are not yet fully resolved (and, thus, whose + * balance is not available for inclusion in new outbound HTLCs). This further does not include + * any pending outgoing HTLCs which are awaiting some other resolution to be sent. + * This does not consider any on-chain fees. + * + * See also [`ChannelDetails::outbound_capacity_msat`] + */ +uint64_t ChannelDetails_get_balance_msat(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + +/** + * Our total balance. This is the amount we would get if we close the channel. + * This value is not exact. Due to various in-flight changes and feerate changes, exactly this + * amount is not likely to be recoverable on close. + * + * This does not include any pending HTLCs which are not yet fully resolved (and, thus, whose + * balance is not available for inclusion in new outbound HTLCs). This further does not include + * any pending outgoing HTLCs which are awaiting some other resolution to be sent. + * This does not consider any on-chain fees. + * + * See also [`ChannelDetails::outbound_capacity_msat`] + */ +void ChannelDetails_set_balance_msat(struct LDKChannelDetails *NONNULL_PTR this_ptr, uint64_t val); + /** * The available outbound capacity for sending HTLCs to the remote peer. This does not include - * any pending HTLCs which are not yet fully resolved (and, thus, who's balance is not + * any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not * available for inclusion in new outbound HTLCs). This further does not include any pending * outgoing HTLCs which are awaiting some other resolution to be sent. * + * See also [`ChannelDetails::balance_msat`] + * * This value is not exact. Due to various in-flight changes, feerate changes, and our * conflict-avoidance policy, exactly this amount is not likely to be spendable. However, we * should be able to spend nearly this amount. @@ -16323,10 +19171,12 @@ uint64_t ChannelDetails_get_outbound_capacity_msat(const struct LDKChannelDetail /** * The available outbound capacity for sending HTLCs to the remote peer. This does not include - * any pending HTLCs which are not yet fully resolved (and, thus, who's balance is not + * any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not * available for inclusion in new outbound HTLCs). This further does not include any pending * outgoing HTLCs which are awaiting some other resolution to be sent. * + * See also [`ChannelDetails::balance_msat`] + * * This value is not exact. Due to various in-flight changes, feerate changes, and our * conflict-avoidance policy, exactly this amount is not likely to be spendable. However, we * should be able to spend nearly this amount. @@ -16335,7 +19185,7 @@ void ChannelDetails_set_outbound_capacity_msat(struct LDKChannelDetails *NONNULL /** * The available inbound capacity for the remote peer to send HTLCs to us. This does not - * include any pending HTLCs which are not yet fully resolved (and, thus, who's balance is not + * include any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not * available for inclusion in new inbound HTLCs). * Note that there are some corner cases not fully handled here, so the actual available * inbound capacity may be slightly higher than this. @@ -16348,7 +19198,7 @@ uint64_t ChannelDetails_get_inbound_capacity_msat(const struct LDKChannelDetails /** * The available inbound capacity for the remote peer to send HTLCs to us. This does not - * include any pending HTLCs which are not yet fully resolved (and, thus, who's balance is not + * include any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not * available for inclusion in new inbound HTLCs). * Note that there are some corner cases not fully handled here, so the actual available * inbound capacity may be slightly higher than this. @@ -16472,13 +19322,23 @@ void ChannelDetails_set_is_public(struct LDKChannelDetails *NONNULL_PTR this_ptr /** * Constructs a new ChannelDetails given each field */ -MUST_USE_RES struct LDKChannelDetails ChannelDetails_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKChannelCounterparty counterparty_arg, struct LDKOutPoint funding_txo_arg, struct LDKCOption_u64Z short_channel_id_arg, uint64_t channel_value_satoshis_arg, struct LDKCOption_u64Z unspendable_punishment_reserve_arg, uint64_t user_channel_id_arg, uint64_t outbound_capacity_msat_arg, uint64_t inbound_capacity_msat_arg, struct LDKCOption_u32Z confirmations_required_arg, struct LDKCOption_u16Z force_close_spend_delay_arg, bool is_outbound_arg, bool is_funding_locked_arg, bool is_usable_arg, bool is_public_arg); +MUST_USE_RES struct LDKChannelDetails ChannelDetails_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKChannelCounterparty counterparty_arg, struct LDKOutPoint funding_txo_arg, struct LDKChannelTypeFeatures channel_type_arg, struct LDKCOption_u64Z short_channel_id_arg, struct LDKCOption_u64Z inbound_scid_alias_arg, uint64_t channel_value_satoshis_arg, struct LDKCOption_u64Z unspendable_punishment_reserve_arg, uint64_t user_channel_id_arg, uint64_t balance_msat_arg, uint64_t outbound_capacity_msat_arg, uint64_t inbound_capacity_msat_arg, struct LDKCOption_u32Z confirmations_required_arg, struct LDKCOption_u16Z force_close_spend_delay_arg, bool is_outbound_arg, bool is_funding_locked_arg, bool is_usable_arg, bool is_public_arg); /** * Creates a copy of the ChannelDetails */ struct LDKChannelDetails ChannelDetails_clone(const struct LDKChannelDetails *NONNULL_PTR orig); +/** + * Gets the current SCID which should be used to identify this channel for inbound payments. + * This should be used for providing invoice hints or in any other context where our + * counterparty will forward a payment to us. + * + * This is either the [`ChannelDetails::inbound_scid_alias`], if set, or the + * [`ChannelDetails::short_channel_id`]. See those for more information. + */ +MUST_USE_RES struct LDKCOption_u64Z ChannelDetails_get_inbound_payment_scid(const struct LDKChannelDetails *NONNULL_PTR this_arg); + /** * Frees any resources used by the PaymentSendFailure */ @@ -16509,6 +19369,53 @@ 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); + +/** + * Creates a copy of the PhantomRouteHints + */ +struct LDKPhantomRouteHints PhantomRouteHints_clone(const struct LDKPhantomRouteHints *NONNULL_PTR orig); + /** * Constructs a new ChannelManager to hold several channels and route between them. * @@ -16684,13 +19591,33 @@ MUST_USE_RES struct LDKCResult_PaymentIdPaymentSendFailureZ ChannelManager_send_ * * Errors returned are a superset of those returned from [`send_payment`], so see * [`send_payment`] documentation for more details on errors. This method will also error if the - * retry amount puts the payment more than 10% over the payment's total amount, or if the payment - * for the given `payment_id` cannot be found (likely due to timeout or success). + * retry amount puts the payment more than 10% over the payment's total amount, if the payment + * for the given `payment_id` cannot be found (likely due to timeout or success), or if + * further retries have been disabled with [`abandon_payment`]. * * [`send_payment`]: [`ChannelManager::send_payment`] + * [`abandon_payment`]: [`ChannelManager::abandon_payment`] */ MUST_USE_RES struct LDKCResult_NonePaymentSendFailureZ ChannelManager_retry_payment(const struct LDKChannelManager *NONNULL_PTR this_arg, const struct LDKRoute *NONNULL_PTR route, struct LDKThirtyTwoBytes payment_id); +/** + * Signals that no further retries for the given payment will occur. + * + * After this method returns, any future calls to [`retry_payment`] for the given `payment_id` + * will fail with [`PaymentSendFailure::ParameterError`]. If no such event has been generated, + * an [`Event::PaymentFailed`] event will be generated as soon as there are no remaining + * pending HTLCs for this payment. + * + * Note that calling this method does *not* prevent a payment from succeeding. You must still + * wait until you receive either a [`Event::PaymentFailed`] or [`Event::PaymentSent`] event to + * determine the ultimate status of a payment. + * + * [`retry_payment`]: Self::retry_payment + * [`Event::PaymentFailed`]: events::Event::PaymentFailed + * [`Event::PaymentSent`]: events::Event::PaymentSent + */ +void ChannelManager_abandon_payment(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes payment_id); + /** * Send a spontaneous payment, which is a payment that does not require the recipient to have * generated an invoice. Optionally, you may specify the preimage. If you do choose to specify @@ -16717,7 +19644,8 @@ MUST_USE_RES struct LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ * Returns an [`APIError::APIMisuseError`] if the funding_transaction spent non-SegWit outputs * or if no output was found which matches the parameters in [`Event::FundingGenerationReady`]. * - * Panics if a funding transaction has already been provided for this channel. + * Returns [`APIError::ChannelUnavailable`] if a funding transaction has already been provided + * for the channel or if the channel has been closed as indicated by [`Event::ChannelClosed`]. * * May panic if the output found in the funding transaction is duplicative with some other * channel (note that this should be trivially prevented by using unique funding transaction @@ -16732,6 +19660,7 @@ MUST_USE_RES struct LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ * create a new channel with a conflicting funding transaction. * * [`Event::FundingGenerationReady`]: crate::util::events::Event::FundingGenerationReady + * [`Event::ChannelClosed`]: crate::util::events::Event::ChannelClosed */ MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_funding_transaction_generated(const struct LDKChannelManager *NONNULL_PTR this_arg, const uint8_t (*temporary_channel_id)[32], struct LDKTransaction funding_transaction); @@ -16789,19 +19718,21 @@ void ChannelManager_timer_tick_occurred(const struct LDKChannelManager *NONNULL_ MUST_USE_RES bool ChannelManager_fail_htlc_backwards(const struct LDKChannelManager *NONNULL_PTR this_arg, const uint8_t (*payment_hash)[32]); /** - * Provides a payment preimage in response to a PaymentReceived event, returning true and - * generating message events for the net layer to claim the payment, if possible. Thus, you - * should probably kick the net layer to go send messages if this returns true! + * Provides a payment preimage in response to [`Event::PaymentReceived`], generating any + * [`MessageSendEvent`]s needed to claim the payment. * * Note that if you did not set an `amount_msat` when calling [`create_inbound_payment`] or * [`create_inbound_payment_for_hash`] you must check that the amount in the `PaymentReceived` * event matches your expectation. If you fail to do so and call this method, you may provide * the sender \"proof-of-payment\" when they did not fulfill the full expected payment. * - * May panic if called except in response to a PaymentReceived event. + * Returns whether any HTLCs were claimed, and thus if any new [`MessageSendEvent`]s are now + * pending for processing via [`get_and_clear_pending_msg_events`]. * + * [`Event::PaymentReceived`]: crate::util::events::Event::PaymentReceived * [`create_inbound_payment`]: Self::create_inbound_payment * [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash + * [`get_and_clear_pending_msg_events`]: MessageSendEventsProvider::get_and_clear_pending_msg_events */ MUST_USE_RES bool ChannelManager_claim_funds(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes payment_preimage); @@ -16810,12 +19741,27 @@ 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. + * + * For inbound channels, the `user_channel_id` parameter will be provided back in + * [`Event::ChannelClosed::user_channel_id`] to allow tracking of which events correspond + * with which `accept_inbound_channel` call. + * + * [`Event::OpenChannelRequest`]: events::Event::OpenChannelRequest + * [`Event::ChannelClosed::user_channel_id`]: events::Event::ChannelClosed::user_channel_id + */ +MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_accept_inbound_channel(const struct LDKChannelManager *NONNULL_PTR this_arg, const uint8_t (*temporary_channel_id)[32], uint64_t user_channel_id); + /** * Gets a payment secret and payment hash for use in an invoice given to a third party wishing * to pay us. * * This differs from [`create_inbound_payment_for_hash`] only in that it generates the - * [`PaymentHash`] and [`PaymentPreimage`] for you, returning the first and storing the second. + * [`PaymentHash`] and [`PaymentPreimage`] for you. * * The [`PaymentPreimage`] will ultimately be returned to you in the [`PaymentReceived`], which * will have the [`PaymentReceived::payment_preimage`] field filled in. That should then be @@ -16823,12 +19769,35 @@ MUST_USE_RES struct LDKPublicKey ChannelManager_get_our_node_id(const struct LDK * * See [`create_inbound_payment_for_hash`] for detailed documentation on behavior and requirements. * + * Note that a malicious eavesdropper can intuit whether an inbound payment was created by + * `create_inbound_payment` or `create_inbound_payment_for_hash` based on runtime. + * + * # Note + * + * If you register an inbound payment with this method, then serialize the `ChannelManager`, then + * deserialize it with a node running 0.0.103 and earlier, the payment will fail to be received. + * + * Errors if `min_value_msat` is greater than total bitcoin supply. + * * [`claim_funds`]: Self::claim_funds * [`PaymentReceived`]: events::Event::PaymentReceived * [`PaymentReceived::payment_preimage`]: events::Event::PaymentReceived::payment_preimage * [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash */ -MUST_USE_RES struct LDKC2Tuple_PaymentHashPaymentSecretZ ChannelManager_create_inbound_payment(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKCOption_u64Z min_value_msat, uint32_t invoice_expiry_delta_secs, uint64_t user_payment_id); +MUST_USE_RES struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ ChannelManager_create_inbound_payment(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKCOption_u64Z min_value_msat, uint32_t invoice_expiry_delta_secs); + +/** + * Legacy version of [`create_inbound_payment`]. Use this method if you wish to share + * serialized state with LDK node(s) running 0.0.103 and earlier. + * + * May panic if `invoice_expiry_delta_secs` is greater than one year. + * + * # Note + * This method is deprecated and will be removed soon. + * + * [`create_inbound_payment`]: Self::create_inbound_payment + */ +MUST_USE_RES struct LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ ChannelManager_create_inbound_payment_legacy(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKCOption_u64Z min_value_msat, uint32_t invoice_expiry_delta_secs); /** * Gets a [`PaymentSecret`] for a given [`PaymentHash`], for which the payment preimage is @@ -16838,14 +19807,9 @@ MUST_USE_RES struct LDKC2Tuple_PaymentHashPaymentSecretZ ChannelManager_create_i * payment secret fetched via this method or [`create_inbound_payment`], and which is at least * the `min_value_msat` provided here, if one is provided. * - * The [`PaymentHash`] (and corresponding [`PaymentPreimage`]) must be globally unique. This - * method may return an Err if another payment with the same payment_hash is still pending. - * - * `user_payment_id` will be provided back in [`PaymentPurpose::InvoicePayment::user_payment_id`] events to - * allow tracking of which events correspond with which calls to this and - * [`create_inbound_payment`]. `user_payment_id` has no meaning inside of LDK, it is simply - * copied to events and otherwise ignored. It may be used to correlate PaymentReceived events - * with invoice metadata stored elsewhere. + * The [`PaymentHash`] (and corresponding [`PaymentPreimage`]) should be globally unique, though + * note that LDK will not stop you from registering duplicate payment hashes for inbound + * payments. * * `min_value_msat` should be set if the invoice being generated contains a value. Any payment * received for the returned [`PaymentHash`] will be required to be at least `min_value_msat` @@ -16864,20 +19828,59 @@ MUST_USE_RES struct LDKC2Tuple_PaymentHashPaymentSecretZ ChannelManager_create_i * If you need exact expiry semantics, you should enforce them upon receipt of * [`PaymentReceived`]. * - * Pending inbound payments are stored in memory and in serialized versions of this - * [`ChannelManager`]. If potentially unbounded numbers of inbound payments may exist and - * space is limited, you may wish to rate-limit inbound payment creation. - * - * May panic if `invoice_expiry_delta_secs` is greater than one year. - * * Note that invoices generated for inbound payments should have their `min_final_cltv_expiry` * set to at least [`MIN_FINAL_CLTV_EXPIRY`]. * + * Note that a malicious eavesdropper can intuit whether an inbound payment was created by + * `create_inbound_payment` or `create_inbound_payment_for_hash` based on runtime. + * + * # Note + * + * If you register an inbound payment with this method, then serialize the `ChannelManager`, then + * deserialize it with a node running 0.0.103 and earlier, the payment will fail to be received. + * + * Errors if `min_value_msat` is greater than total bitcoin supply. + * * [`create_inbound_payment`]: Self::create_inbound_payment * [`PaymentReceived`]: events::Event::PaymentReceived - * [`PaymentPurpose::InvoicePayment::user_payment_id`]: events::PaymentPurpose::InvoicePayment::user_payment_id */ -MUST_USE_RES struct LDKCResult_PaymentSecretAPIErrorZ ChannelManager_create_inbound_payment_for_hash(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes payment_hash, struct LDKCOption_u64Z min_value_msat, uint32_t invoice_expiry_delta_secs, uint64_t user_payment_id); +MUST_USE_RES struct LDKCResult_PaymentSecretNoneZ ChannelManager_create_inbound_payment_for_hash(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes payment_hash, struct LDKCOption_u64Z min_value_msat, uint32_t invoice_expiry_delta_secs); + +/** + * Legacy version of [`create_inbound_payment_for_hash`]. Use this method if you wish to share + * serialized state with LDK node(s) running 0.0.103 and earlier. + * + * May panic if `invoice_expiry_delta_secs` is greater than one year. + * + * # Note + * This method is deprecated and will be removed soon. + * + * [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash + */ +MUST_USE_RES struct LDKCResult_PaymentSecretAPIErrorZ ChannelManager_create_inbound_payment_for_hash_legacy(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes payment_hash, struct LDKCOption_u64Z min_value_msat, uint32_t invoice_expiry_delta_secs); + +/** + * Gets an LDK-generated payment preimage from a payment hash and payment secret that were + * previously returned from [`create_inbound_payment`]. + * + * [`create_inbound_payment`]: Self::create_inbound_payment + */ +MUST_USE_RES struct 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. @@ -16908,7 +19911,8 @@ struct LDKConfirm ChannelManager_as_Confirm(const struct LDKChannelManager *NONN * indicating whether persistence is necessary. Only one listener on * `await_persistable_update` or `await_persistable_update_timeout` is guaranteed to be woken * up. - * Note that the feature `allow_wallclock_use` must be enabled to use this function. + * + * 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); @@ -16917,19 +19921,59 @@ MUST_USE_RES bool ChannelManager_await_persistable_update_timeout(const struct L * `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); +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); + +/** + * Serialize the ChannelDetails object into a byte array which can be read by ChannelDetails_read + */ +struct LDKCVec_u8Z ChannelDetails_write(const struct LDKChannelDetails *NONNULL_PTR obj); + +/** + * Read a ChannelDetails from a byte array, created by ChannelDetails_write + */ +struct LDKCResult_ChannelDetailsDecodeErrorZ ChannelDetails_read(struct LDKu8slice ser); /** - * Gets the latest best block which was connected either via the [`chain::Listen`] or - * [`chain::Confirm`] interfaces. + * Serialize the PhantomRouteHints object into a byte array which can be read by PhantomRouteHints_read */ -MUST_USE_RES struct LDKBestBlock ChannelManager_current_best_block(const struct LDKChannelManager *NONNULL_PTR this_arg); +struct LDKCVec_u8Z PhantomRouteHints_write(const struct LDKPhantomRouteHints *NONNULL_PTR obj); /** - * 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 + * Read a PhantomRouteHints from a byte array, created by PhantomRouteHints_write */ -struct LDKChannelMessageHandler ChannelManager_as_ChannelMessageHandler(const struct LDKChannelManager *NONNULL_PTR this_arg); +struct LDKCResult_PhantomRouteHintsDecodeErrorZ PhantomRouteHints_read(struct LDKu8slice ser); /** * Serialize the ChannelManager object into a byte array which can be read by ChannelManager_read @@ -17062,10 +20106,26 @@ struct LDKInitFeatures Init_get_features(const struct LDKInit *NONNULL_PTR this_ */ void Init_set_features(struct LDKInit *NONNULL_PTR this_ptr, struct LDKInitFeatures val); +/** + * The receipient's network address. This adds the option to report a remote IP address + * back to a connecting peer using the init message. A node can decide to use that information + * to discover a potential update to its public IPv4 address (NAT) and use + * that for a node_announcement update message containing the new address. + */ +struct LDKCOption_NetAddressZ Init_get_remote_network_address(const struct LDKInit *NONNULL_PTR this_ptr); + +/** + * The receipient's network address. This adds the option to report a remote IP address + * back to a connecting peer using the init message. A node can decide to use that information + * to discover a potential update to its public IPv4 address (NAT) and use + * that for a node_announcement update message containing the new address. + */ +void Init_set_remote_network_address(struct LDKInit *NONNULL_PTR this_ptr, struct LDKCOption_NetAddressZ val); + /** * Constructs a new Init given each field */ -MUST_USE_RES struct LDKInit Init_new(struct LDKInitFeatures features_arg); +MUST_USE_RES struct LDKInit Init_new(struct LDKInitFeatures features_arg, struct LDKCOption_NetAddressZ remote_network_address_arg); /** * Creates a copy of the Init @@ -17078,28 +20138,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); @@ -17113,6 +20179,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. */ @@ -17362,6 +20473,24 @@ uint8_t OpenChannel_get_channel_flags(const struct LDKOpenChannel *NONNULL_PTR t */ void OpenChannel_set_channel_flags(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint8_t val); +/** + * The channel type that this channel will represent. If none is set, we derive the channel + * type from the intersection of our feature bits with our counterparty's feature bits from + * the Init message. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +struct LDKChannelTypeFeatures OpenChannel_get_channel_type(const struct LDKOpenChannel *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. + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +void OpenChannel_set_channel_type(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKChannelTypeFeatures val); + /** * Creates a copy of the OpenChannel */ @@ -17512,6 +20641,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 */ @@ -17632,10 +20783,22 @@ struct LDKPublicKey FundingLocked_get_next_per_commitment_point(const struct LDK */ void FundingLocked_set_next_per_commitment_point(struct LDKFundingLocked *NONNULL_PTR this_ptr, struct LDKPublicKey val); +/** + * If set, provides a short_channel_id alias for this channel. The sender will accept payments + * to be forwarded over this SCID and forward them to this messages' recipient. + */ +struct LDKCOption_u64Z FundingLocked_get_short_channel_id_alias(const struct LDKFundingLocked *NONNULL_PTR this_ptr); + +/** + * If set, provides a short_channel_id alias for this channel. The sender will accept payments + * to be forwarded over this SCID and forward them to this messages' recipient. + */ +void FundingLocked_set_short_channel_id_alias(struct LDKFundingLocked *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); + /** * Constructs a new FundingLocked given each field */ -MUST_USE_RES struct LDKFundingLocked FundingLocked_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKPublicKey next_per_commitment_point_arg); +MUST_USE_RES struct LDKFundingLocked FundingLocked_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKPublicKey next_per_commitment_point_arg, struct LDKCOption_u64Z short_channel_id_alias_arg); /** * Creates a copy of the FundingLocked @@ -18229,7 +21392,7 @@ struct LDKNetAddress NetAddress_ipv6(struct LDKSixteenBytes addr, uint16_t port) /** * Utility method to constructs a new OnionV2-variant NetAddress */ -struct LDKNetAddress NetAddress_onion_v2(struct LDKTenBytes addr, uint16_t port); +struct LDKNetAddress NetAddress_onion_v2(struct LDKTwelveBytes a); /** * Utility method to constructs a new OnionV3-variant NetAddress @@ -18876,11 +22039,21 @@ struct LDKErrorAction ErrorAction_ignore_error(void); */ struct LDKErrorAction ErrorAction_ignore_and_log(enum LDKLevel a); +/** + * Utility method to constructs a new IgnoreDuplicateGossip-variant ErrorAction + */ +struct LDKErrorAction ErrorAction_ignore_duplicate_gossip(void); + /** * Utility method to constructs a new SendErrorMessage-variant ErrorAction */ 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. */ @@ -19255,6 +22428,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 */ @@ -19494,7 +22677,13 @@ MUST_USE_RES struct LDKPeerManager PeerManager_new(struct LDKMessageHandler mess MUST_USE_RES struct LDKCVec_PublicKeyZ PeerManager_get_peer_node_ids(const struct LDKPeerManager *NONNULL_PTR this_arg); /** - * Indicates a new outbound connection has been established to a node with the given node_id. + * Indicates a new outbound connection has been established to a node with the given node_id + * and an optional remote network address. + * + * The remote network address adds the option to report a remote IP address back to a connecting + * peer using the init message. + * The user should pass the remote network address of the host they are connected to. + * * Note that if an Err is returned here you MUST NOT call socket_disconnected for the new * descriptor but must disconnect the connection immediately. * @@ -19505,10 +22694,15 @@ MUST_USE_RES struct LDKCVec_PublicKeyZ PeerManager_get_peer_node_ids(const struc * * [`socket_disconnected()`]: PeerManager::socket_disconnected */ -MUST_USE_RES struct LDKCResult_CVec_u8ZPeerHandleErrorZ PeerManager_new_outbound_connection(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKPublicKey their_node_id, struct LDKSocketDescriptor descriptor); +MUST_USE_RES struct LDKCResult_CVec_u8ZPeerHandleErrorZ PeerManager_new_outbound_connection(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKPublicKey their_node_id, struct LDKSocketDescriptor descriptor, struct LDKCOption_NetAddressZ remote_network_address); /** - * Indicates a new inbound connection has been established. + * Indicates a new inbound connection has been established to a node with an optional remote + * network address. + * + * The remote network address adds the option to report a remote IP address back to a connecting + * peer using the init message. + * The user should pass the remote network address of the host they are connected to. * * May refuse the connection by returning an Err, but will never write bytes to the remote end * (outbound connector always speaks first). Note that if an Err is returned here you MUST NOT @@ -19520,7 +22714,7 @@ MUST_USE_RES struct LDKCResult_CVec_u8ZPeerHandleErrorZ PeerManager_new_outbound * * [`socket_disconnected()`]: PeerManager::socket_disconnected */ -MUST_USE_RES struct LDKCResult_NonePeerHandleErrorZ PeerManager_new_inbound_connection(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKSocketDescriptor descriptor); +MUST_USE_RES struct LDKCResult_NonePeerHandleErrorZ PeerManager_new_inbound_connection(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKSocketDescriptor descriptor, struct LDKCOption_NetAddressZ remote_network_address); /** * Indicates that there is room to write data to the given socket descriptor. @@ -19602,9 +22796,9 @@ void PeerManager_disconnect_all_peers(const struct LDKPeerManager *NONNULL_PTR t * Send pings to each peer and disconnect those which did not respond to the last round of * pings. * - * This may be called on any timescale you want, however, roughly once every five to ten - * seconds is preferred. The call rate determines both how often we send a ping to our peers - * and how much time they have to respond before we disconnect them. + * This may be called on any timescale you want, however, roughly once every ten seconds is + * preferred. The call rate determines both how often we send a ping to our peers and how much + * time they have to respond before we disconnect them. * * May call [`send_data`] on all [`SocketDescriptor`]s. Thus, be very careful with reentrancy * issues! @@ -19613,6 +22807,16 @@ void PeerManager_disconnect_all_peers(const struct LDKPeerManager *NONNULL_PTR t */ void PeerManager_timer_tick_occurred(const struct LDKPeerManager *NONNULL_PTR this_arg); +/** + * Gets the weight for an HTLC-Success transaction. + */ +uint64_t htlc_success_tx_weight(bool opt_anchors); + +/** + * Gets the weight for an HTLC-Timeout transaction. + */ +uint64_t htlc_timeout_tx_weight(bool opt_anchors); + /** * Build the commitment secret from the seed and the commitment number */ @@ -19623,6 +22827,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. @@ -19952,7 +23201,7 @@ struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ HTLCOutputInCommitment_read * Gets the witness redeemscript for an HTLC output in a commitment transaction. Note that htlc * does not need to have its previous_output_index filled. */ -struct LDKCVec_u8Z get_htlc_redeemscript(const struct LDKHTLCOutputInCommitment *NONNULL_PTR htlc, const struct LDKTxCreationKeys *NONNULL_PTR keys); +struct LDKCVec_u8Z get_htlc_redeemscript(const struct LDKHTLCOutputInCommitment *NONNULL_PTR htlc, bool opt_anchors, const struct LDKTxCreationKeys *NONNULL_PTR keys); /** * Gets the redeemscript for a funding output from the two funding public keys. @@ -19969,7 +23218,17 @@ struct LDKCVec_u8Z make_funding_redeemscript(struct LDKPublicKey broadcaster, st * Panics if htlc.transaction_output_index.is_none() (as such HTLCs do not appear in the * commitment transaction). */ -struct LDKTransaction build_htlc_transaction(const uint8_t (*commitment_txid)[32], uint32_t feerate_per_kw, uint16_t contest_delay, const struct LDKHTLCOutputInCommitment *NONNULL_PTR htlc, struct LDKPublicKey broadcaster_delayed_payment_key, struct LDKPublicKey revocation_key); +struct LDKTransaction build_htlc_transaction(const uint8_t (*commitment_txid)[32], uint32_t feerate_per_kw, uint16_t contest_delay, const struct LDKHTLCOutputInCommitment *NONNULL_PTR htlc, bool opt_anchors, struct LDKPublicKey broadcaster_delayed_payment_key, struct LDKPublicKey revocation_key); + +/** + * Gets the witnessScript for an anchor output from the funding public key. + * The witness in the spending input must be: + * + * After 16 blocks of confirmation, an alternative satisfying witness could be: + * <> + * (empty vector required to satisfy compliance with MINIMALIF-standard rule) + */ +struct LDKCVec_u8Z get_anchor_redeemscript(struct LDKPublicKey funding_pubkey); /** * Frees any resources used by the ChannelTransactionParameters, if is_owned is set and inner is non-NULL. @@ -20038,10 +23297,20 @@ struct LDKOutPoint ChannelTransactionParameters_get_funding_outpoint(const struc */ void ChannelTransactionParameters_set_funding_outpoint(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, struct LDKOutPoint val); +/** + * Are anchors used for this channel. Boolean is serialization backwards-compatible + */ +enum LDKCOption_NoneZ ChannelTransactionParameters_get_opt_anchors(const struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr); + +/** + * Are anchors used for this channel. Boolean is serialization backwards-compatible + */ +void ChannelTransactionParameters_set_opt_anchors(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, enum LDKCOption_NoneZ val); + /** * Constructs a new ChannelTransactionParameters given each field */ -MUST_USE_RES struct LDKChannelTransactionParameters ChannelTransactionParameters_new(struct LDKChannelPublicKeys holder_pubkeys_arg, uint16_t holder_selected_contest_delay_arg, bool is_outbound_from_holder_arg, struct LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg, struct LDKOutPoint funding_outpoint_arg); +MUST_USE_RES struct LDKChannelTransactionParameters ChannelTransactionParameters_new(struct LDKChannelPublicKeys holder_pubkeys_arg, uint16_t holder_selected_contest_delay_arg, bool is_outbound_from_holder_arg, struct LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg, struct LDKOutPoint funding_outpoint_arg, enum LDKCOption_NoneZ opt_anchors_arg); /** * Creates a copy of the ChannelTransactionParameters @@ -20158,6 +23427,11 @@ MUST_USE_RES bool DirectedChannelTransactionParameters_is_outbound(const struct */ MUST_USE_RES struct LDKOutPoint DirectedChannelTransactionParameters_funding_outpoint(const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR this_arg); +/** + * Whether to use anchors for this channel + */ +MUST_USE_RES bool DirectedChannelTransactionParameters_opt_anchors(const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR this_arg); + /** * Frees any resources used by the HolderCommitmentTransaction, if is_owned is set and inner is non-NULL. */ @@ -20268,6 +23542,16 @@ MUST_USE_RES struct LDKSignature BuiltCommitmentTransaction_sign(const struct LD */ void ClosingTransaction_free(struct LDKClosingTransaction this_obj); +/** + * Creates a copy of the ClosingTransaction + */ +struct LDKClosingTransaction ClosingTransaction_clone(const struct LDKClosingTransaction *NONNULL_PTR orig); + +/** + * Checks if two ClosingTransactions contain equal inner contents. + */ +uint64_t ClosingTransaction_hash(const struct LDKClosingTransaction *NONNULL_PTR o); + /** * Construct an object of the class */ @@ -20416,11 +23700,18 @@ MUST_USE_RES struct LDKBuiltCommitmentTransaction TrustedCommitmentTransaction_b */ MUST_USE_RES struct LDKTxCreationKeys TrustedCommitmentTransaction_keys(const struct LDKTrustedCommitmentTransaction *NONNULL_PTR this_arg); +/** + * Should anchors be used. + */ +MUST_USE_RES bool TrustedCommitmentTransaction_opt_anchors(const struct LDKTrustedCommitmentTransaction *NONNULL_PTR this_arg); + /** * Get a signature for each HTLC which was included in the commitment transaction (ie for * which HTLCOutputInCommitment::transaction_output_index.is_some()). * * The returned Vec has one entry for each HTLC, and in the same order. + * + * This function is only valid in the holder commitment context, it always uses 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); @@ -20462,6 +23753,13 @@ bool ChannelFeatures_eq(const struct LDKChannelFeatures *NONNULL_PTR a, const st */ bool InvoiceFeatures_eq(const struct LDKInvoiceFeatures *NONNULL_PTR a, const struct LDKInvoiceFeatures *NONNULL_PTR b); +/** + * Checks if two ChannelTypeFeaturess contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ +bool ChannelTypeFeatures_eq(const struct LDKChannelTypeFeatures *NONNULL_PTR a, const struct LDKChannelTypeFeatures *NONNULL_PTR b); + /** * Creates a copy of the InitFeatures */ @@ -20482,6 +23780,11 @@ struct LDKChannelFeatures ChannelFeatures_clone(const struct LDKChannelFeatures */ struct LDKInvoiceFeatures InvoiceFeatures_clone(const struct LDKInvoiceFeatures *NONNULL_PTR orig); +/** + * Creates a copy of the ChannelTypeFeatures + */ +struct LDKChannelTypeFeatures ChannelTypeFeatures_clone(const struct LDKChannelTypeFeatures *NONNULL_PTR orig); + /** * Frees any resources used by the InitFeatures, if is_owned is set and inner is non-NULL. */ @@ -20502,6 +23805,11 @@ void ChannelFeatures_free(struct LDKChannelFeatures this_obj); */ void InvoiceFeatures_free(struct LDKInvoiceFeatures this_obj); +/** + * Frees any resources used by the ChannelTypeFeatures, if is_owned is set and inner is non-NULL. + */ +void ChannelTypeFeatures_free(struct LDKChannelTypeFeatures this_obj); + /** * Create a blank Features with no features set */ @@ -20567,19 +23875,20 @@ MUST_USE_RES struct LDKInvoiceFeatures InvoiceFeatures_known(void); MUST_USE_RES bool InvoiceFeatures_requires_unknown_bits(const struct LDKInvoiceFeatures *NONNULL_PTR this_arg); /** - * Returns whether the `payment_secret` feature is supported. + * Create a blank Features with no features set */ -MUST_USE_RES bool InitFeatures_supports_payment_secret(const struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKChannelTypeFeatures ChannelTypeFeatures_empty(void); /** - * Returns whether the `payment_secret` feature is supported. + * Creates a Features with the bits set which are known by the implementation */ -MUST_USE_RES bool NodeFeatures_supports_payment_secret(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKChannelTypeFeatures ChannelTypeFeatures_known(void); /** - * Returns whether the `payment_secret` feature is supported. + * Returns true if this `Features` object contains unknown feature flags which are set as + * \"required\". */ -MUST_USE_RES bool InvoiceFeatures_supports_payment_secret(const struct LDKInvoiceFeatures *NONNULL_PTR this_arg); +MUST_USE_RES bool ChannelTypeFeatures_requires_unknown_bits(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** * Serialize the InitFeatures object into a byte array which can be read by InitFeatures_read @@ -20587,9 +23896,9 @@ MUST_USE_RES bool InvoiceFeatures_supports_payment_secret(const struct LDKInvoic struct LDKCVec_u8Z InitFeatures_write(const struct LDKInitFeatures *NONNULL_PTR obj); /** - * Serialize the NodeFeatures object into a byte array which can be read by NodeFeatures_read + * Read a InitFeatures from a byte array, created by InitFeatures_write */ -struct LDKCVec_u8Z NodeFeatures_write(const struct LDKNodeFeatures *NONNULL_PTR obj); +struct LDKCResult_InitFeaturesDecodeErrorZ InitFeatures_read(struct LDKu8slice ser); /** * Serialize the ChannelFeatures object into a byte array which can be read by ChannelFeatures_read @@ -20597,14 +23906,14 @@ struct LDKCVec_u8Z NodeFeatures_write(const struct LDKNodeFeatures *NONNULL_PTR struct LDKCVec_u8Z ChannelFeatures_write(const struct LDKChannelFeatures *NONNULL_PTR obj); /** - * Serialize the InvoiceFeatures object into a byte array which can be read by InvoiceFeatures_read + * Read a ChannelFeatures from a byte array, created by ChannelFeatures_write */ -struct LDKCVec_u8Z InvoiceFeatures_write(const struct LDKInvoiceFeatures *NONNULL_PTR obj); +struct LDKCResult_ChannelFeaturesDecodeErrorZ ChannelFeatures_read(struct LDKu8slice ser); /** - * Read a InitFeatures from a byte array, created by InitFeatures_write + * Serialize the NodeFeatures object into a byte array which can be read by NodeFeatures_read */ -struct LDKCResult_InitFeaturesDecodeErrorZ InitFeatures_read(struct LDKu8slice ser); +struct LDKCVec_u8Z NodeFeatures_write(const struct LDKNodeFeatures *NONNULL_PTR obj); /** * Read a NodeFeatures from a byte array, created by NodeFeatures_write @@ -20612,15 +23921,25 @@ struct LDKCResult_InitFeaturesDecodeErrorZ InitFeatures_read(struct LDKu8slice s struct LDKCResult_NodeFeaturesDecodeErrorZ NodeFeatures_read(struct LDKu8slice ser); /** - * Read a ChannelFeatures from a byte array, created by ChannelFeatures_write + * Serialize the InvoiceFeatures object into a byte array which can be read by InvoiceFeatures_read */ -struct LDKCResult_ChannelFeaturesDecodeErrorZ ChannelFeatures_read(struct LDKu8slice ser); +struct LDKCVec_u8Z InvoiceFeatures_write(const struct LDKInvoiceFeatures *NONNULL_PTR obj); /** * Read a InvoiceFeatures from a byte array, created by InvoiceFeatures_write */ struct LDKCResult_InvoiceFeaturesDecodeErrorZ InvoiceFeatures_read(struct LDKu8slice ser); +/** + * Serialize the ChannelTypeFeatures object into a byte array which can be read by ChannelTypeFeatures_read + */ +struct LDKCVec_u8Z ChannelTypeFeatures_write(const struct LDKChannelTypeFeatures *NONNULL_PTR obj); + +/** + * Read a ChannelTypeFeatures from a byte array, created by ChannelTypeFeatures_write + */ +struct LDKCResult_ChannelTypeFeaturesDecodeErrorZ ChannelTypeFeatures_read(struct LDKu8slice ser); + /** * Frees any resources used by the ShutdownScript, if is_owned is set and inner is non-NULL. */ @@ -20655,6 +23974,11 @@ void InvalidShutdownScript_set_script(struct LDKInvalidShutdownScript *NONNULL_P */ MUST_USE_RES struct LDKInvalidShutdownScript InvalidShutdownScript_new(struct LDKCVec_u8Z script_arg); +/** + * Creates a copy of the InvalidShutdownScript + */ +struct LDKInvalidShutdownScript InvalidShutdownScript_clone(const struct LDKInvalidShutdownScript *NONNULL_PTR orig); + /** * Serialize the ShutdownScript object into a byte array which can be read by ShutdownScript_read */ @@ -20716,26 +24040,6 @@ void CustomMessageReader_free(struct LDKCustomMessageReader this_ptr); */ void Type_free(struct LDKType this_ptr); -/** - * Calls the free function if one is set - */ -void Score_free(struct LDKScore this_ptr); - -/** - * Frees any resources used by the LockableScore, if is_owned is set and inner is non-NULL. - */ -void LockableScore_free(struct LDKLockableScore this_obj); - -/** - * Constructs a new LockableScore from a Score - */ -MUST_USE_RES struct LDKLockableScore LockableScore_new(struct LDKScore score); - -/** - * Serialize the LockableScore object into a byte array which can be read by LockableScore_read - */ -struct LDKCVec_u8Z LockableScore_write(const struct LDKLockableScore *NONNULL_PTR obj); - /** * Frees any resources used by the NodeId, if is_owned is set and inner is non-NULL. */ @@ -20816,6 +24120,11 @@ struct LDKNetworkUpdate NetworkUpdate_node_failure(struct LDKPublicKey node_id, */ struct LDKCVec_u8Z NetworkUpdate_write(const struct LDKNetworkUpdate *NONNULL_PTR obj); +/** + * Read a NetworkUpdate from a byte array, created by NetworkUpdate_write + */ +struct LDKCResult_COption_NetworkUpdateZDecodeErrorZ NetworkUpdate_read(struct LDKu8slice ser); + /** * Constructs a new EventHandler which calls the relevant methods on this_arg. * This copies the `inner` pointer in this_arg and thus the returned EventHandler must be freed before this_arg is @@ -20856,71 +24165,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 @@ -20930,7 +24239,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 @@ -20940,27 +24249,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. @@ -20992,14 +24301,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 @@ -21016,64 +24325,130 @@ 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 + * 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 LDKChannelUpdateInfo val); + +/** + * The channel capacity as seen on-chain, if chain lookup is available. + */ +struct LDKCOption_u64Z ChannelInfo_get_capacity_sats(const struct LDKChannelInfo *NONNULL_PTR this_ptr); + +/** + * The channel capacity as seen on-chain, if chain lookup is available. + */ +void ChannelInfo_set_capacity_sats(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); + +/** + * An initial announcement of the channel + * Mostly redundant with the data we store in fields explicitly. + * Everything else is useful only for sending out for initial routing sync. + * Not stored if contains excess data to prevent DoS. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +struct LDKChannelAnnouncement ChannelInfo_get_announcement_message(const struct LDKChannelInfo *NONNULL_PTR this_ptr); + +/** + * An initial announcement of the channel + * Mostly redundant with the data we store in fields explicitly. + * Everything else is useful only for sending out for initial routing sync. + * Not stored if contains excess data to prevent DoS. + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +void ChannelInfo_set_announcement_message(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKChannelAnnouncement val); + +/** + * Creates a copy of the ChannelInfo + */ +struct LDKChannelInfo ChannelInfo_clone(const struct LDKChannelInfo *NONNULL_PTR orig); + +/** + * Serialize the ChannelInfo object into a byte array which can be read by ChannelInfo_read + */ +struct LDKCVec_u8Z ChannelInfo_write(const struct LDKChannelInfo *NONNULL_PTR obj); + +/** + * Read a ChannelInfo from a byte array, created by ChannelInfo_write + */ +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. */ -void ChannelInfo_set_two_to_one(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKDirectionalChannelInfo val); +MUST_USE_RES struct LDKEffectiveCapacity DirectedChannelInfo_effective_capacity(const struct LDKDirectedChannelInfo *NONNULL_PTR this_arg); /** - * The channel capacity as seen on-chain, if chain lookup is available. + * Frees any resources used by the EffectiveCapacity */ -struct LDKCOption_u64Z ChannelInfo_get_capacity_sats(const struct LDKChannelInfo *NONNULL_PTR this_ptr); +void EffectiveCapacity_free(struct LDKEffectiveCapacity this_ptr); /** - * The channel capacity as seen on-chain, if chain lookup is available. + * Creates a copy of the EffectiveCapacity */ -void ChannelInfo_set_capacity_sats(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); +struct LDKEffectiveCapacity EffectiveCapacity_clone(const struct LDKEffectiveCapacity *NONNULL_PTR orig); /** - * An initial announcement of the channel - * Mostly redundant with the data we store in fields explicitly. - * Everything else is useful only for sending out for initial routing sync. - * Not stored if contains excess data to prevent DoS. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Utility method to constructs a new ExactLiquidity-variant EffectiveCapacity */ -struct LDKChannelAnnouncement ChannelInfo_get_announcement_message(const struct LDKChannelInfo *NONNULL_PTR this_ptr); +struct LDKEffectiveCapacity EffectiveCapacity_exact_liquidity(uint64_t liquidity_msat); /** - * An initial announcement of the channel - * Mostly redundant with the data we store in fields explicitly. - * Everything else is useful only for sending out for initial routing sync. - * Not stored if contains excess data to prevent DoS. - * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * Utility method to constructs a new MaximumHTLC-variant EffectiveCapacity */ -void ChannelInfo_set_announcement_message(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKChannelAnnouncement val); +struct LDKEffectiveCapacity EffectiveCapacity_maximum_htlc(uint64_t amount_msat); /** - * Constructs a new ChannelInfo given each field + * Utility method to constructs a new Total-variant EffectiveCapacity */ -MUST_USE_RES struct LDKChannelInfo ChannelInfo_new(struct LDKChannelFeatures features_arg, struct LDKNodeId node_one_arg, struct LDKDirectionalChannelInfo one_to_two_arg, struct LDKNodeId node_two_arg, struct LDKDirectionalChannelInfo two_to_one_arg, struct LDKCOption_u64Z capacity_sats_arg, struct LDKChannelAnnouncement announcement_message_arg); +struct LDKEffectiveCapacity EffectiveCapacity_total(uint64_t capacity_msat); /** - * Creates a copy of the ChannelInfo + * Utility method to constructs a new Infinite-variant EffectiveCapacity */ -struct LDKChannelInfo ChannelInfo_clone(const struct LDKChannelInfo *NONNULL_PTR orig); +struct LDKEffectiveCapacity EffectiveCapacity_infinite(void); /** - * Serialize the ChannelInfo object into a byte array which can be read by ChannelInfo_read + * Utility method to constructs a new Unknown-variant EffectiveCapacity */ -struct LDKCVec_u8Z ChannelInfo_write(const struct LDKChannelInfo *NONNULL_PTR obj); +struct LDKEffectiveCapacity EffectiveCapacity_unknown(void); /** - * Read a ChannelInfo from a byte array, created by ChannelInfo_write + * Returns the effective capacity denominated in millisatoshi. */ -struct LDKCResult_ChannelInfoDecodeErrorZ ChannelInfo_read(struct LDKu8slice ser); +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. @@ -21369,6 +24744,37 @@ 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 + * exist. + * + * While there is no formal requirement that nodes regularly re-broadcast their channel + * updates every two weeks, the non-normative section of BOLT 7 currently suggests that + * pruning occur for updates which are at least two weeks old, which we implement here. + * + * This function takes the current unix time as an argument. For users with the `std` feature + * enabled, [`NetworkGraph::remove_stale_channels`] may be preferable. + */ +void NetworkGraph_remove_stale_channels_with_time(const struct LDKNetworkGraph *NONNULL_PTR this_arg, uint64_t current_time_unix); + /** * For an already known (from announcement) channel, update info about one of the directions * of the channel. @@ -21376,6 +24782,9 @@ void NetworkGraph_fail_node(const struct LDKNetworkGraph *NONNULL_PTR this_arg, * You probably don't want to call this directly, instead relying on a NetGraphMsgHandler's * RoutingMessageHandler implementation to call it indirectly. This may be useful to accept * routing messages from a source using a protocol other than the lightning P2P protocol. + * + * If built with `no-std`, any updates with a timestamp more than two weeks in the past or + * materially in the future will be rejected. */ MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKChannelUpdate *NONNULL_PTR msg); @@ -21383,6 +24792,9 @@ MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel(c * For an already known (from announcement) channel, update info about one of the directions * of the channel without verifying the associated signatures. Because we aren't given the * associated signatures here we cannot relay the channel update to any of our peers. + * + * If built with `no-std`, any updates with a timestamp more than two weeks in the past or + * materially in the future will be rejected. */ MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_unsigned(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKUnsignedChannelUpdate *NONNULL_PTR msg); @@ -21526,7 +24938,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`]. * @@ -21534,10 +24946,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`]. * @@ -21545,12 +24957,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 @@ -21598,14 +25010,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. @@ -21630,7 +25042,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 @@ -21648,19 +25060,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. @@ -21672,7 +25084,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. @@ -21684,69 +25096,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. @@ -21918,7 +25340,58 @@ 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, const uint8_t (*random_seed_bytes)[32]); + +/** + * Calls the free function if one is set + */ +void Score_free(struct LDKScore this_ptr); + +/** + * Calls the free function if one is set + */ +void LockableScore_free(struct LDKLockableScore this_ptr); + +/** + * Frees any resources used by the MultiThreadedLockableScore, if is_owned is set and inner is non-NULL. + */ +void MultiThreadedLockableScore_free(struct LDKMultiThreadedLockableScore this_obj); + +/** + * Creates a new [`MultiThreadedLockableScore`] given an underlying [`Score`]. + */ +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); + +/** + * Creates a copy of the FixedPenaltyScorer + */ +struct LDKFixedPenaltyScorer FixedPenaltyScorer_clone(const struct LDKFixedPenaltyScorer *NONNULL_PTR orig); + +/** + * Creates a new scorer using `penalty_msat`. + */ +MUST_USE_RES struct LDKFixedPenaltyScorer FixedPenaltyScorer_with_penalty(uint64_t penalty_msat); + +/** + * Constructs a new 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); + +/** + * Serialize the FixedPenaltyScorer object into a byte array which can be read by FixedPenaltyScorer_read + */ +struct LDKCVec_u8Z FixedPenaltyScorer_write(const struct LDKFixedPenaltyScorer *NONNULL_PTR obj); + +/** + * Read a FixedPenaltyScorer from a byte array, created by FixedPenaltyScorer_write + */ +struct LDKCResult_FixedPenaltyScorerDecodeErrorZ FixedPenaltyScorer_read(struct LDKu8slice ser, uint64_t arg); /** * Frees any resources used by the Scorer, if is_owned is set and inner is non-NULL. @@ -21932,11 +25405,15 @@ void ScoringParameters_free(struct LDKScoringParameters this_obj); /** * A fixed penalty in msats to apply to each channel. + * + * Default value: 500 msat */ uint64_t ScoringParameters_get_base_penalty_msat(const struct LDKScoringParameters *NONNULL_PTR this_ptr); /** * A fixed penalty in msats to apply to each channel. + * + * Default value: 500 msat */ void ScoringParameters_set_base_penalty_msat(struct LDKScoringParameters *NONNULL_PTR this_ptr, uint64_t val); @@ -21944,7 +25421,9 @@ void ScoringParameters_set_base_penalty_msat(struct LDKScoringParameters *NONNUL * A penalty in msats to apply to a channel upon failing to relay a payment. * * This accumulates for each failure but may be reduced over time based on - * [`failure_penalty_half_life`]. + * [`failure_penalty_half_life`] or when successfully routing through a channel. + * + * Default value: 1,024,000 msat * * [`failure_penalty_half_life`]: Self::failure_penalty_half_life */ @@ -21954,20 +25433,68 @@ uint64_t ScoringParameters_get_failure_penalty_msat(const struct LDKScoringParam * A penalty in msats to apply to a channel upon failing to relay a payment. * * This accumulates for each failure but may be reduced over time based on - * [`failure_penalty_half_life`]. + * [`failure_penalty_half_life`] or when successfully routing through a channel. + * + * Default value: 1,024,000 msat * * [`failure_penalty_half_life`]: Self::failure_penalty_half_life */ void ScoringParameters_set_failure_penalty_msat(struct LDKScoringParameters *NONNULL_PTR this_ptr, uint64_t val); +/** + * When the amount being sent over a channel is this many 1024ths of the total channel + * capacity, we begin applying [`overuse_penalty_msat_per_1024th`]. + * + * Default value: 128 1024ths (i.e. begin penalizing when an HTLC uses 1/8th of a channel) + * + * [`overuse_penalty_msat_per_1024th`]: Self::overuse_penalty_msat_per_1024th + */ +uint16_t ScoringParameters_get_overuse_penalty_start_1024th(const struct LDKScoringParameters *NONNULL_PTR this_ptr); + +/** + * When the amount being sent over a channel is this many 1024ths of the total channel + * capacity, we begin applying [`overuse_penalty_msat_per_1024th`]. + * + * Default value: 128 1024ths (i.e. begin penalizing when an HTLC uses 1/8th of a channel) + * + * [`overuse_penalty_msat_per_1024th`]: Self::overuse_penalty_msat_per_1024th + */ +void ScoringParameters_set_overuse_penalty_start_1024th(struct LDKScoringParameters *NONNULL_PTR this_ptr, uint16_t val); + +/** + * A penalty applied, per whole 1024ths of the channel capacity which the amount being sent + * over the channel exceeds [`overuse_penalty_start_1024th`] by. + * + * Default value: 20 msat (i.e. 2560 msat penalty to use 1/4th of a channel, 7680 msat penalty + * to use half a channel, and 12,560 msat penalty to use 3/4ths of a channel) + * + * [`overuse_penalty_start_1024th`]: Self::overuse_penalty_start_1024th + */ +uint64_t ScoringParameters_get_overuse_penalty_msat_per_1024th(const struct LDKScoringParameters *NONNULL_PTR this_ptr); + +/** + * A penalty applied, per whole 1024ths of the channel capacity which the amount being sent + * over the channel exceeds [`overuse_penalty_start_1024th`] by. + * + * Default value: 20 msat (i.e. 2560 msat penalty to use 1/4th of a channel, 7680 msat penalty + * to use half a channel, and 12,560 msat penalty to use 3/4ths of a channel) + * + * [`overuse_penalty_start_1024th`]: Self::overuse_penalty_start_1024th + */ +void ScoringParameters_set_overuse_penalty_msat_per_1024th(struct LDKScoringParameters *NONNULL_PTR this_ptr, uint64_t val); + /** * The time required to elapse before any accumulated [`failure_penalty_msat`] penalties are * cut in half. * + * Successfully routing through a channel will immediately cut the penalty in half as well. + * + * Default value: 1 hour + * * # Note * - * When time is an [`Eternity`], as is default when enabling feature `no-std`, it will never - * elapse. Therefore, this penalty will never decay. + * When built with the `no-std` feature, time will never elapse. Therefore, this penalty will + * never decay. * * [`failure_penalty_msat`]: Self::failure_penalty_msat */ @@ -21977,10 +25504,14 @@ uint64_t ScoringParameters_get_failure_penalty_half_life(const struct LDKScoring * The time required to elapse before any accumulated [`failure_penalty_msat`] penalties are * cut in half. * + * Successfully routing through a channel will immediately cut the penalty in half as well. + * + * Default value: 1 hour + * * # Note * - * When time is an [`Eternity`], as is default when enabling feature `no-std`, it will never - * elapse. Therefore, this penalty will never decay. + * When built with the `no-std` feature, time will never elapse. Therefore, this penalty will + * never decay. * * [`failure_penalty_msat`]: Self::failure_penalty_msat */ @@ -21989,7 +25520,12 @@ void ScoringParameters_set_failure_penalty_half_life(struct LDKScoringParameters /** * Constructs a new ScoringParameters given each field */ -MUST_USE_RES struct LDKScoringParameters ScoringParameters_new(uint64_t base_penalty_msat_arg, uint64_t failure_penalty_msat_arg, uint64_t failure_penalty_half_life_arg); +MUST_USE_RES struct LDKScoringParameters ScoringParameters_new(uint64_t base_penalty_msat_arg, uint64_t failure_penalty_msat_arg, uint16_t overuse_penalty_start_1024th_arg, uint64_t overuse_penalty_msat_per_1024th_arg, uint64_t failure_penalty_half_life_arg); + +/** + * Creates a copy of the ScoringParameters + */ +struct LDKScoringParameters ScoringParameters_clone(const struct LDKScoringParameters *NONNULL_PTR orig); /** * Serialize the ScoringParameters object into a byte array which can be read by ScoringParameters_read @@ -22032,6 +25568,177 @@ 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 ProbabilisticScorer, if is_owned is set and inner is non-NULL. + */ +void ProbabilisticScorer_free(struct LDKProbabilisticScorer this_obj); + +/** + * 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 fixed penalty in msats to apply to each channel. + * + * Default value: 500 msat + */ +uint64_t ProbabilisticScoringParameters_get_base_penalty_msat(const struct LDKProbabilisticScoringParameters *NONNULL_PTR this_ptr); + +/** + * A fixed penalty in msats to apply to each channel. + * + * Default value: 500 msat + */ +void ProbabilisticScoringParameters_set_base_penalty_msat(struct LDKProbabilisticScoringParameters *NONNULL_PTR this_ptr, uint64_t val); + +/** + * A multiplier used in conjunction with the negative `log10` of the channel's success + * probability for a payment to determine the liquidity penalty. + * + * The penalty is based in part on the knowledge learned from prior successful and unsuccessful + * payments. This knowledge is decayed over time based on [`liquidity_offset_half_life`]. The + * penalty is effectively limited to `2 * liquidity_penalty_multiplier_msat` (corresponding to + * lower bounding the success probability to `0.01`) when the amount falls within the + * uncertainty bounds of the channel liquidity balance. Amounts above the upper bound will + * result in a `u64::max_value` penalty, however. + * + * Default value: 40,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 in conjunction with the negative `log10` of the channel's success + * probability for a payment to determine the liquidity penalty. + * + * The penalty is based in part on the knowledge learned from prior successful and unsuccessful + * payments. This knowledge is decayed over time based on [`liquidity_offset_half_life`]. The + * penalty is effectively limited to `2 * liquidity_penalty_multiplier_msat` (corresponding to + * lower bounding the success probability to `0.01`) when the amount falls within the + * uncertainty bounds of the channel liquidity balance. Amounts above the upper bound will + * result in a `u64::max_value` penalty, however. + * + * Default value: 40,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); + +/** + * A multiplier used in conjunction with a payment amount and the negative `log10` of the + * channel's success probability for the payment to determine the amount penalty. + * + * The purpose of the amount penalty is to avoid having fees dominate the channel cost (i.e., + * fees plus penalty) for large payments. The penalty is computed as the product of this + * multiplier and `2^20`ths of the payment amount, weighted by the negative `log10` of the + * success probability. + * + * `-log10(success_probability) * amount_penalty_multiplier_msat * amount_msat / 2^20` + * + * In practice, this means for 0.1 success probability (`-log10(0.1) == 1`) each `2^20`th of + * the amount will result in a penalty of the multiplier. And, as the success probability + * decreases, the negative `log10` weighting will increase dramatically. For higher success + * probabilities, the multiplier will have a decreasing effect as the negative `log10` will + * fall below `1`. + * + * Default value: 256 msat + */ +uint64_t ProbabilisticScoringParameters_get_amount_penalty_multiplier_msat(const struct LDKProbabilisticScoringParameters *NONNULL_PTR this_ptr); + +/** + * A multiplier used in conjunction with a payment amount and the negative `log10` of the + * channel's success probability for the payment to determine the amount penalty. + * + * The purpose of the amount penalty is to avoid having fees dominate the channel cost (i.e., + * fees plus penalty) for large payments. The penalty is computed as the product of this + * multiplier and `2^20`ths of the payment amount, weighted by the negative `log10` of the + * success probability. + * + * `-log10(success_probability) * amount_penalty_multiplier_msat * amount_msat / 2^20` + * + * In practice, this means for 0.1 success probability (`-log10(0.1) == 1`) each `2^20`th of + * the amount will result in a penalty of the multiplier. And, as the success probability + * decreases, the negative `log10` weighting will increase dramatically. For higher success + * probabilities, the multiplier will have a decreasing effect as the negative `log10` will + * fall below `1`. + * + * Default value: 256 msat + */ +void ProbabilisticScoringParameters_set_amount_penalty_multiplier_msat(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 base_penalty_msat_arg, uint64_t liquidity_penalty_multiplier_msat_arg, uint64_t liquidity_offset_half_life_arg, uint64_t amount_penalty_multiplier_msat_arg); + +/** + * Creates a copy of the ProbabilisticScoringParameters + */ +struct LDKProbabilisticScoringParameters ProbabilisticScoringParameters_clone(const struct LDKProbabilisticScoringParameters *NONNULL_PTR orig); + +/** + * Creates a new scorer using the given scoring parameters for sending payments from a node + * through a network graph. + */ +MUST_USE_RES struct LDKProbabilisticScorer ProbabilisticScorer_new(struct LDKProbabilisticScoringParameters params, const struct LDKNetworkGraph *NONNULL_PTR network_graph); + +/** + * 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); + +/** + * 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 ProbabilisticScorer_as_Score(const struct LDKProbabilisticScorer *NONNULL_PTR this_arg); + +/** + * Serialize the ProbabilisticScorer object into a byte array which can be read by ProbabilisticScorer_read + */ +struct LDKCVec_u8Z ProbabilisticScorer_write(const struct LDKProbabilisticScorer *NONNULL_PTR obj); + +/** + * Read a ProbabilisticScorer from a byte array, created by ProbabilisticScorer_write + */ +struct LDKCResult_ProbabilisticScorerDecodeErrorZ ProbabilisticScorer_read(struct LDKu8slice ser, struct LDKProbabilisticScoringParameters arg_a, const struct LDKNetworkGraph *NONNULL_PTR arg_b); + /** * Frees any resources used by the FilesystemPersister, if is_owned is set and inner is non-NULL. */ @@ -22054,6 +25761,12 @@ MUST_USE_RES struct LDKStr FilesystemPersister_get_data_dir(const struct LDKFile */ MUST_USE_RES struct LDKCResult_NoneErrorZ FilesystemPersister_persist_manager(struct LDKStr data_dir, const struct LDKChannelManager *NONNULL_PTR manager); +/** + * Write the provided `NetworkGraph` to the path provided at `FilesystemPersister` + * initialization, within a file called \"network_graph\" + */ +MUST_USE_RES struct LDKCResult_NoneErrorZ FilesystemPersister_persist_network_graph(struct LDKStr data_dir, const struct LDKNetworkGraph *NONNULL_PTR network_graph); + /** * Read `ChannelMonitor`s from disk. */ @@ -22073,24 +25786,28 @@ void BackgroundProcessor_free(struct LDKBackgroundProcessor this_obj); /** * Calls the free function if one is set */ -void ChannelManagerPersister_free(struct LDKChannelManagerPersister this_ptr); +void Persister_free(struct LDKPersister this_ptr); /** * Start a background thread that takes care of responsibilities enumerated in the [top-level * documentation]. * * The thread runs indefinitely unless the object is dropped, [`stop`] is called, or - * `persist_manager` returns an error. In case of an error, the error is retrieved by calling + * [`Persister::persist_manager`] returns an error. In case of an error, the error is retrieved by calling * either [`join`] or [`stop`]. * * # Data Persistence * - * `persist_manager` is responsible for writing out the [`ChannelManager`] to disk, and/or + * [`Persister::persist_manager`] is responsible for writing out the [`ChannelManager`] to disk, and/or * uploading to one or more backup services. See [`ChannelManager::write`] for writing out a * [`ChannelManager`]. See [`FilesystemPersister::persist_manager`] for Rust-Lightning's * provided implementation. * - * Typically, users should either implement [`ChannelManagerPersister`] to never return an + * [`Persister::persist_graph`] is responsible for writing out the [`NetworkGraph`] to disk. See + * [`NetworkGraph::write`] for writing out a [`NetworkGraph`]. See [`FilesystemPersister::persist_network_graph`] + * for Rust-Lightning's provided implementation. + * + * Typically, users should either implement [`Persister::persist_manager`] to never return an * error or call [`join`] and handle any error that may arise. For the latter case, * `BackgroundProcessor` must be restarted by calling `start` again after handling the error. * @@ -22101,17 +25818,19 @@ void ChannelManagerPersister_free(struct LDKChannelManagerPersister this_ptr); * functionality implemented by other handlers. * * [`NetGraphMsgHandler`] if given will update the [`NetworkGraph`] based on payment failures. * - * [top-level documentation]: Self + * [top-level documentation]: BackgroundProcessor * [`join`]: Self::join * [`stop`]: Self::stop * [`ChannelManager`]: lightning::ln::channelmanager::ChannelManager * [`ChannelManager::write`]: lightning::ln::channelmanager::ChannelManager#impl-Writeable * [`FilesystemPersister::persist_manager`]: lightning_persister::FilesystemPersister::persist_manager + * [`FilesystemPersister::persist_network_graph`]: lightning_persister::FilesystemPersister::persist_network_graph * [`NetworkGraph`]: lightning::routing::network_graph::NetworkGraph + * [`NetworkGraph::write`]: lightning::routing::network_graph::NetworkGraph#impl-Writeable * * Note that net_graph_msg_handler (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKBackgroundProcessor BackgroundProcessor_start(struct LDKChannelManagerPersister persister, struct LDKEventHandler event_handler, const struct LDKChainMonitor *NONNULL_PTR chain_monitor, const struct LDKChannelManager *NONNULL_PTR channel_manager, struct LDKNetGraphMsgHandler net_graph_msg_handler, const struct LDKPeerManager *NONNULL_PTR peer_manager, struct LDKLogger logger); +MUST_USE_RES struct LDKBackgroundProcessor BackgroundProcessor_start(struct LDKPersister persister, struct LDKEventHandler event_handler, const struct LDKChainMonitor *NONNULL_PTR chain_monitor, const struct LDKChannelManager *NONNULL_PTR channel_manager, struct LDKNetGraphMsgHandler net_graph_msg_handler, const struct LDKPeerManager *NONNULL_PTR peer_manager, struct LDKLogger logger); /** * Join `BackgroundProcessor`'s thread, returning any error that occurred while persisting @@ -22139,23 +25858,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. */ @@ -22636,26 +26338,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); @@ -22694,10 +26410,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 */ @@ -22737,6 +26458,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`]. @@ -22777,18 +26504,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 @@ -22831,9 +26554,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_invalid_amount(void); + +/** + * Utility method to constructs a new MissingRouteHints-variant CreationError */ -enum LDKCreationError CreationError_expiry_time_out_of_bounds(void); +enum LDKCreationError CreationError_missing_route_hints(void); /** * Checks if two CreationErrors contain equal inner contents. @@ -23020,7 +26748,7 @@ struct LDKPaymentError PaymentError_sending(struct LDKPaymentSendFailure a); * Will forward any [`Event::PaymentPathFailed`] events to the decorated `event_handler` once * `retry_attempts` has been exceeded for a given [`Invoice`]. */ -MUST_USE_RES struct LDKInvoicePayer InvoicePayer_new(struct LDKPayer payer, struct LDKRouter router, const struct LDKLockableScore *NONNULL_PTR scorer, struct LDKLogger logger, struct LDKEventHandler event_handler, struct LDKRetryAttempts retry_attempts); +MUST_USE_RES struct LDKInvoicePayer InvoicePayer_new(struct LDKPayer payer, struct LDKRouter router, const struct LDKMultiThreadedLockableScore *NONNULL_PTR scorer, struct LDKLogger logger, struct LDKEventHandler event_handler, struct LDKRetryAttempts retry_attempts); /** * Pays the given [`Invoice`], caching it for later use in case a retry is needed. @@ -23041,6 +26769,15 @@ MUST_USE_RES struct LDKCResult_PaymentIdPaymentErrorZ InvoicePayer_pay_invoice(c */ MUST_USE_RES struct LDKCResult_PaymentIdPaymentErrorZ InvoicePayer_pay_zero_value_invoice(const struct LDKInvoicePayer *NONNULL_PTR this_arg, const struct LDKInvoice *NONNULL_PTR invoice, uint64_t amount_msats); +/** + * Pays `pubkey` an amount using the hash of the given preimage, caching it for later use in + * case a retry is needed. + * + * You should ensure that `payment_preimage` is unique and that its `payment_hash` has never + * been paid before. Because [`InvoicePayer`] is stateless no effort is made to do so for you. + */ +MUST_USE_RES struct LDKCResult_PaymentIdPaymentErrorZ InvoicePayer_pay_pubkey(const struct LDKInvoicePayer *NONNULL_PTR this_arg, struct LDKPublicKey pubkey, struct LDKThirtyTwoBytes payment_preimage, uint64_t amount_msats, uint32_t final_cltv_expiry_delta); + /** * Removes the payment cached by the given payment hash. * @@ -23055,6 +26792,64 @@ 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 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 + * + * `description_hash` is a SHA-256 hash of the description text + * + * `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_with_description_hash(struct LDKCOption_u64Z amt_msat, struct LDKSha256 description_hash, 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 @@ -23064,15 +26859,40 @@ 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); +/** + * Utility to construct an invoice. Generally, unless you want to do something like a custom + * cltv_expiry, this is what you should be using to create an invoice. The reason being, this + * method stores the invoice's payment secret and preimage in `ChannelManager`, so (a) the user + * doesn't have to store preimage/payment secret information and (b) `ChannelManager` can verify + * that the payment secret is valid when the invoice is paid. + * Use this variant if you want to pass the `description_hash` to the invoice. + */ +struct LDKCResult_InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager_with_description_hash(const struct LDKChannelManager *NONNULL_PTR channelmanager, struct LDKKeysInterface keys_manager, enum LDKCurrency network, struct LDKCOption_u64Z amt_msat, struct LDKSha256 description_hash); + +/** + * See [`create_invoice_from_channelmanager_with_description_hash`] + * This version can be used in a `no_std` environment, where [`std::time::SystemTime`] is not + * available and the current time is supplied by the caller. + */ +struct LDKCResult_InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch(const struct LDKChannelManager *NONNULL_PTR channelmanager, struct LDKKeysInterface keys_manager, enum LDKCurrency network, struct LDKCOption_u64Z amt_msat, struct LDKSha256 description_hash, uint64_t duration_since_epoch); + +/** + * 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. */ void DefaultRouter_free(struct LDKDefaultRouter this_obj); /** - * Creates a new router using the given [`NetworkGraph`] and [`Logger`]. + * Creates a new router using the given [`NetworkGraph`], a [`Logger`], and a randomness source + * `random_seed_bytes`. */ -MUST_USE_RES struct LDKDefaultRouter DefaultRouter_new(const struct LDKNetworkGraph *NONNULL_PTR network_graph, struct LDKLogger logger); +MUST_USE_RES struct LDKDefaultRouter DefaultRouter_new(const struct LDKNetworkGraph *NONNULL_PTR network_graph, struct LDKLogger logger, struct LDKThirtyTwoBytes random_seed_bytes); /** * Constructs a new Router which calls the relevant methods on this_arg.